e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync# Copyright (c) 2001, Stanford University
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync# All rights reserved.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync# See the file LICENSE.txt for information on redistributing this software.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync# This script generates the packer_bbox.c file from gl_header.parsed
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/* DO NOT EDIT - THIS FILE GENERATED BY THE packer_bbox.py SCRIPT */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/* These functions pack glVertex functions and also update the bounding box
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * if the cr_packer_globals.updateBBOX variable is non-zero.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#include "packer.h"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#include "cr_opcodes.h"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#include "pack_bbox.h"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#include <float.h>
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Reset packer bounding box to empty state.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid crPackResetBoundingBox( CRPackContext *pc )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pc->bounds_min.x = FLT_MAX;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pc->bounds_min.y = FLT_MAX;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pc->bounds_min.z = FLT_MAX;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pc->bounds_max.x = -FLT_MAX;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pc->bounds_max.y = -FLT_MAX;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pc->bounds_max.z = -FLT_MAX;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pc->updateBBOX = 1;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Query current bounding box.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * \return GL_TRUE if non-empty box, GL_FALSE if empty box.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncGLboolean crPackGetBoundingBox( CRPackContext *pc,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync GLfloat *xmin, GLfloat *ymin, GLfloat *zmin,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync GLfloat *xmax, GLfloat *ymax, GLfloat *zmax)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pc->bounds_min.x != FLT_MAX) {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync *xmin = pc->bounds_min.x;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync *ymin = pc->bounds_min.y;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync *zmin = pc->bounds_min.z;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync *xmax = pc->bounds_max.x;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync *ymax = pc->bounds_max.y;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync *zmax = pc->bounds_max.z;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync return GL_TRUE;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync return GL_FALSE;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncdef WriteData( offset, arg_type, arg_name, is_swapped ):
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync retval = "\tWRITE_NETWORK_POINTER( %d, (void *) %s );" % (offset, arg_name )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if arg_type == "GLfloat" or arg_type == "GLclampf":
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync retval = "\tWRITE_DATA( %d, GLuint, SWAPFLOAT(%s) );" % (offset, arg_name)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elif arg_type == "GLdouble" or arg_type == "GLclampd":
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync retval = "\tWRITE_SWAPPED_DOUBLE( %d, %s );" % (offset, arg_name)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync retval = "\tWRITE_DATA( %d, %s, %s );" % (offset, arg_type, arg_name)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync retval = "\tWRITE_DATA( %d, %s, SWAP16(%s) );" % (offset, arg_type, arg_name)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync retval = "\tWRITE_DATA( %d, %s, SWAP32(%s) );" % (offset, arg_type, arg_name)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if arg_type == "GLdouble" or arg_type == "GLclampd":
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync retval = "\tWRITE_DOUBLE( %d, %s );" % (offset, arg_name)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync retval = "\tWRITE_DATA( %d, %s, %s );" % (offset, arg_type, arg_name)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncdef PrintFunction( func_name, extSuffix, num_coords, argtype,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Generate all the functions named crPackVertex[234][dfis][v]BBOX() and
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync crPackVertex[234][dfis][v]BBOX_COUNT().
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync We also handle glVertexAttrib*ARB.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Note: func_name should not have an ARB suffix.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync func_name = 'VertexAttrib%d%sv' % (num_coords, argtype)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print 'void PACK_APIENTRY crPack%sBBOX%s%s( %s )' % (func_name + extSuffix, countSuffix,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync # vector version
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync packet_length = num_coords * apiutil.sizeof(vector_type)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync # non-vector
2f44080df90cb90c1e524d97c8e327b40298f3c6vboxsync print "\tCR_GET_PACKER_CONTEXT(pc);"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print "\tunsigned char *data_ptr;"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print "\tCREATE_%dD_VFLOATS_%s_NORMALIZED();" % (num_coords, t)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print "\tCREATE_%dD_FLOATS_%s_NORMALIZED();" % (num_coords, t)
2f44080df90cb90c1e524d97c8e327b40298f3c6vboxsync print "\tCR_GET_BUFFERED%s_POINTER( pc, %d );" % (countSuffix, packet_length)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync # Bounding box code
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print "\tif (pc->updateBBOX && index == 0)"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print "\tif (pc->updateBBOX)"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print "\t{"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print "\t\tUPDATE_3D_BBOX();"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print "\t}"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print "\tif (index > 0) {"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print "\t\tpc->current.c.vertexAttrib.%s%d[index] = data_ptr + 4;" % (t, num_coords)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print "\t\tpc->current.attribsUsedMask |= (1 << index);"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print "\t\tpc->current.vtx_count--;"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print "\t}"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync # use non-vector opcode
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync opcode = apiutil.OpcodeName( func_name[:-1] + extSuffix )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync opcode = apiutil.OpcodeName( func_name + extSuffix )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print "\tWRITE_DATA( 0, GLuint, SWAP32(index) );"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print "\tWRITE_DATA( 0, GLuint, index );"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print WriteData( counter, vector_type, "%s[%d]" % (argname, index), do_swapped )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync # this is a bit of a hack
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print "\tWRITE_OPCODE( pc, %s );" % apiutil.OpcodeName( func_name + "ARB" )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print "\tWRITE_OPCODE( pc, %s );" % apiutil.OpcodeName( func_name[:-1] + "ARB" )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print "\tWRITE_OPCODE( pc, %s );" % apiutil.OpcodeName( func_name[:-1] )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print "\tWRITE_OPCODE( pc, %s );" % apiutil.OpcodeName( func_name + "ARB" )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print "\tWRITE_OPCODE( pc, %s );" % apiutil.OpcodeName( func_name )
2f44080df90cb90c1e524d97c8e327b40298f3c6vboxsync print "\tCR_UNLOCK_PACKER_CONTEXT(pc);"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print '}\n'
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#end PrintFunction()
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync PrintFunction( func_name, "", num_coords, argtype, swap,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync func_name = 'VertexAttrib%d%s' % (num_coords, argtype)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync PrintFunction( func_name, "ARB", num_coords, argtype, swap,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync# Special vector functions
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync PrintFunction( func_name, "ARB", num_coords, argtype, swap, count, vec )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync# Special non-vector functions