e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync# Copyright (c) 2001, Stanford University
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync# All rights reserved.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync# See the file LICENSE.txt for information on redistributing this software.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync# This script generates the packer_bbox.c file from gl_header.parsed
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncimport sys
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncimport cPickle
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncimport string
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncimport apiutil
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncapiutil.CopyrightC()
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncprint """
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/* DO NOT EDIT - THIS FILE GENERATED BY THE packer_bbox.py SCRIPT */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/* These functions pack glVertex functions and also update the bounding box
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * if the cr_packer_globals.updateBBOX variable is non-zero.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#include "packer.h"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#include "cr_opcodes.h"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#include "pack_bbox.h"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#include <float.h>
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Reset packer bounding box to empty state.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid crPackResetBoundingBox( CRPackContext *pc )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
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}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Query current bounding box.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * \return GL_TRUE if non-empty box, GL_FALSE if empty box.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncGLboolean crPackGetBoundingBox( CRPackContext *pc,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync GLfloat *xmin, GLfloat *ymin, GLfloat *zmin,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync GLfloat *xmax, GLfloat *ymax, GLfloat *zmax)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
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 }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync return GL_FALSE;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync"""
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncdef WriteData( offset, arg_type, arg_name, is_swapped ):
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if string.find( arg_type, '*' ) != -1:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync retval = "\tWRITE_NETWORK_POINTER( %d, (void *) %s );" % (offset, arg_name )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if is_swapped:
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 elif apiutil.sizeof(arg_type) == 1:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync retval = "\tWRITE_DATA( %d, %s, %s );" % (offset, arg_type, arg_name)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elif apiutil.sizeof(arg_type) == 2:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync retval = "\tWRITE_DATA( %d, %s, SWAP16(%s) );" % (offset, arg_type, arg_name)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elif apiutil.sizeof(arg_type) == 4:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync retval = "\tWRITE_DATA( %d, %s, SWAP32(%s) );" % (offset, arg_type, arg_name)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if arg_type == "GLdouble" or arg_type == "GLclampd":
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync retval = "\tWRITE_DOUBLE( %d, %s );" % (offset, arg_name)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync retval = "\tWRITE_DATA( %d, %s, %s );" % (offset, arg_type, arg_name)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync return retval
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncdef PrintFunction( func_name, extSuffix, num_coords, argtype,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync do_swapped, do_count, do_vector ):
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync """
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 """
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if do_count:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync countSuffix = "_COUNT"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync countSuffix = ""
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if do_swapped:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync swapSuffix = "SWAP"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync swapSuffix = ""
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if func_name[0:12] == "VertexAttrib":
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync isVertexAttrib = 1
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync isVertexAttrib = 0
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if argtype[0] == "N":
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync normalized = 1
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync normalized = 0;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if argtype == "b" or argtype == "Nb":
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync vector_type = "GLbyte"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elif argtype == "ub" or argtype == "Nub":
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync vector_type = "GLubyte"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elif argtype == "s" or argtype == "Ns":
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync vector_type = "GLshort"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elif argtype == "us" or argtype == "Nus":
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync vector_type = "GLushort"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elif argtype == "i" or argtype == "Ni":
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync vector_type = "GLint"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elif argtype == "ui" or argtype == "Nui":
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync vector_type = "GLuint"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elif argtype == "f":
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync vector_type = "GLfloat"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elif argtype == "d":
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync vector_type = "GLdouble"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print "type is %s" % argtype
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync abort()
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if do_vector:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if isVertexAttrib:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync func_name = 'VertexAttrib%d%sv' % (num_coords, argtype)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync func_name = 'Vertex%d%sv' % (num_coords,argtype)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync params = apiutil.Parameters(func_name + extSuffix)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print 'void PACK_APIENTRY crPack%sBBOX%s%s( %s )' % (func_name + extSuffix, countSuffix,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync swapSuffix, apiutil.MakeDeclarationString(params))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print '{'
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if do_vector:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync # vector version
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync packet_length = num_coords * apiutil.sizeof(vector_type)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if isVertexAttrib:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync packet_length += 4 # for index
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if packet_length % 4 != 0:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync packet_length += 2
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync # non-vector
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync packet_length = apiutil.PacketLength( params )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if isVertexAttrib:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync packet_length += 0 # for index
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if packet_length % 4 != 0:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync packet_length += 2
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
2f44080df90cb90c1e524d97c8e327b40298f3c6vboxsync print "\tCR_GET_PACKER_CONTEXT(pc);"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print "\tunsigned char *data_ptr;"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if normalized:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if argtype == "Nb":
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync t = "B"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elif argtype == "Ni":
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync t = "I"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elif argtype == "Nui":
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync t = "UI"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elif argtype == "Nub":
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync t = "UB"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elif argtype == "Ns":
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync t = "S"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elif argtype == "Nus":
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync t = "US"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync abort()
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if do_vector:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print "\tCREATE_%dD_VFLOATS_%s_NORMALIZED();" % (num_coords, t)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print "\tCREATE_%dD_FLOATS_%s_NORMALIZED();" % (num_coords, t)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if do_vector:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print "\tCREATE_%dD_VFLOATS();" % num_coords
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print "\tCREATE_%dD_FLOATS();" % num_coords
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
2f44080df90cb90c1e524d97c8e327b40298f3c6vboxsync print "\tCR_GET_BUFFERED%s_POINTER( pc, %d );" % (countSuffix, packet_length)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync # Bounding box code
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if isVertexAttrib:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print "\tif (pc->updateBBOX && index == 0)"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print "\tif (pc->updateBBOX)"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print "\t{"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if num_coords < 4:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print "\t\tUPDATE_%dD_BBOX();" % num_coords
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print "\t\tUPDATE_3D_BBOX();"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print "\t}"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if isVertexAttrib:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print "\tif (index > 0) {"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync t = argtype
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 if do_count:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print "\t\tpc->current.vtx_count--;"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print "\t}"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync fname = func_name + extSuffix
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if do_vector:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync # use non-vector opcode
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync opcode = apiutil.OpcodeName( func_name[:-1] + extSuffix )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync opcode = apiutil.OpcodeName( func_name + extSuffix )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync counter = 0
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if do_vector:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if isVertexAttrib:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if do_swapped:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print "\tWRITE_DATA( 0, GLuint, SWAP32(index) );"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print "\tWRITE_DATA( 0, GLuint, index );"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync counter += 4
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync argname = params[1][0] # skip 'index' parameter
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync argname = params[0][0]
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for index in range(num_coords):
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print WriteData( counter, vector_type, "%s[%d]" % (argname, index), do_swapped )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync counter += apiutil.sizeof(vector_type)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if isVertexAttrib:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if do_vector == 2:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync # this is a bit of a hack
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print "\tWRITE_OPCODE( pc, %s );" % apiutil.OpcodeName( func_name + "ARB" )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print "\tWRITE_OPCODE( pc, %s );" % apiutil.OpcodeName( func_name[:-1] + "ARB" )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print "\tWRITE_OPCODE( pc, %s );" % apiutil.OpcodeName( func_name[:-1] )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for index in range(0,len(params)):
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync (name, type, vecSize) = params[index]
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print WriteData( counter, type, name, do_swapped )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync counter += apiutil.sizeof(type)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if isVertexAttrib:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print "\tWRITE_OPCODE( pc, %s );" % apiutil.OpcodeName( func_name + "ARB" )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print "\tWRITE_OPCODE( pc, %s );" % apiutil.OpcodeName( func_name )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
2f44080df90cb90c1e524d97c8e327b40298f3c6vboxsync print "\tCR_UNLOCK_PACKER_CONTEXT(pc);"
2f44080df90cb90c1e524d97c8e327b40298f3c6vboxsync
2f44080df90cb90c1e524d97c8e327b40298f3c6vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync print '}\n'
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#end PrintFunction()
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncfor num_coords in [2,3,4]:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for argtype in ['d', 'f', 'i', 's']:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync func_name = 'Vertex%d%s' % (num_coords, argtype)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for swap in range(0, 2):
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for count in range(0, 2):
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for vec in range(0, 2):
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync PrintFunction( func_name, "", num_coords, argtype, swap,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync count, vec )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncfor num_coords in [1,2,3,4]:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for argtype in ['d', 'f', 's']:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync func_name = 'VertexAttrib%d%s' % (num_coords, argtype)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for swap in range(0, 2):
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for count in range(0, 2):
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for vec in range(0, 2):
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync PrintFunction( func_name, "ARB", num_coords, argtype, swap,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync count, vec )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync# Special vector functions
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncmoreFuncs = [ [ "VertexAttrib4ubv", "ub" ],
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync [ "VertexAttrib4usv", "us" ],
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync [ "VertexAttrib4uiv", "ui" ],
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync [ "VertexAttrib4bv", "b" ],
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync [ "VertexAttrib4iv", "i" ],
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync [ "VertexAttrib4Nbv", "Nb" ],
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync [ "VertexAttrib4Nsv", "Ns" ],
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync [ "VertexAttrib4Niv", "Ni" ],
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync [ "VertexAttrib4Nubv", "Nub" ],
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync [ "VertexAttrib4Nusv", "Nus" ],
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync [ "VertexAttrib4Nuiv", "Nui" ]
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync ]
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncfor (func_name, argtype) in moreFuncs:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync vec = 2 # special, hacked value
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync num_coords = 4
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for swap in range(0, 2):
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for count in range(0, 2):
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync PrintFunction( func_name, "ARB", num_coords, argtype, swap, count, vec )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync# Special non-vector functions
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncmoreFuncs = [ [ "VertexAttrib4Nub", "Nub" ] ]
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncfor (func_name, argtype) in moreFuncs:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync vec = 0
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync num_coords = 4
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for swap in range(0, 2):
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for count in range(0, 2):
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync PrintFunction( func_name, "ARB", num_coords, argtype, swap, count, vec )