pack_client.c revision 977a7ff905883c1b7d4650a211a089684db421f6
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
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#include "packer.h"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#include "cr_opcodes.h"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#include "cr_version.h"
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync#include "state/cr_limits.h"
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync#include "cr_glstate.h"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync/*Convert from GLint to GLfloat in [-1.f,1.f]*/
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync#define CRP_I2F_NORM(i) ((2.f*((GLint)(i))+1.f) * (1.f/4294967294.f))
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync/*Convert from GLshort to GLfloat in [-1.f,1.f]*/
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync#define CRP_S2F_NORM(s) ((2.f*((GLshort)(s))+1.f) * (1.f/65535.f))
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsyncstatic void crPackVertexAttrib(const CRVertexArrays *array, unsigned int attr, GLint index)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync GLint *iPtr;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync GLshort *sPtr;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync unsigned char *p = array->a[attr].p + index * array->a[attr].stride;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync#ifdef CR_ARB_vertex_buffer_object
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync if (array->a[attr].buffer && array->a[attr].buffer->data)
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync p = (unsigned char *)(array->a[attr].buffer->data) + (unsigned long)p;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync#endif
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync switch (array->a[attr].type)
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case GL_SHORT:
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync sPtr = (GLshort*) p;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync switch (array->a[attr].size)
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 1:
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync if (array->a[attr].normalized)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync crPackVertexAttrib1fARB(attr, CRP_S2F_NORM(sPtr[0]));
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync else
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync crPackVertexAttrib1svARB(attr, sPtr);
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 2:
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync if (array->a[attr].normalized)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync crPackVertexAttrib2fARB(attr, CRP_S2F_NORM(sPtr[0]), CRP_S2F_NORM(sPtr[1]));
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync else
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync crPackVertexAttrib2svARB(attr, sPtr);
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 3:
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync if (array->a[attr].normalized)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync crPackVertexAttrib3fARB(attr, CRP_S2F_NORM(sPtr[0]), CRP_S2F_NORM(sPtr[1]), CRP_S2F_NORM(sPtr[2]));
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync else
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync crPackVertexAttrib3svARB(attr, sPtr);
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 4:
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync if (array->a[attr].normalized)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync crPackVertexAttrib4NsvARB(attr, sPtr);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync else
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync crPackVertexAttrib4svARB(attr, sPtr);
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync break;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case GL_INT:
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync iPtr = (GLint*) p;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync switch (array->a[attr].size)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 1:
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync if (array->a[attr].normalized)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync crPackVertexAttrib1fARB(attr, CRP_I2F_NORM(iPtr[0]));
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync else
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync crPackVertexAttrib1fARB(attr, iPtr[0]);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 2:
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync if (array->a[attr].normalized)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync crPackVertexAttrib2fARB(attr, CRP_I2F_NORM(iPtr[0]), CRP_I2F_NORM(iPtr[1]));
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync else
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync crPackVertexAttrib2fARB(attr, iPtr[0], iPtr[1]);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 3:
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync if (array->a[attr].normalized)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync crPackVertexAttrib3fARB(attr, CRP_I2F_NORM(iPtr[0]), CRP_I2F_NORM(iPtr[1]), CRP_I2F_NORM(iPtr[2]));
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync else
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync crPackVertexAttrib3fARB(attr, iPtr[0], iPtr[1], iPtr[2]);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 4:
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync if (array->a[attr].normalized)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync crPackVertexAttrib4NivARB(attr, iPtr);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync else
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync crPackVertexAttrib4fARB(attr, iPtr[0], iPtr[1], iPtr[2], iPtr[3]);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case GL_FLOAT:
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync switch (array->a[attr].size)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 1: crPackVertexAttrib1fvARB(attr, (GLfloat *)p); break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 2: crPackVertexAttrib2fvARB(attr, (GLfloat *)p); break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 3: crPackVertexAttrib3fvARB(attr, (GLfloat *)p); break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 4: crPackVertexAttrib4fvARB(attr, (GLfloat *)p); break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case GL_DOUBLE:
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync switch (array->a[attr].size)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 1: crPackVertexAttrib1dvARB(attr, (GLdouble *)p); break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 2: crPackVertexAttrib2dvARB(attr, (GLdouble *)p); break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 3: crPackVertexAttrib3dvARB(attr, (GLdouble *)p); break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 4: crPackVertexAttrib4dvARB(attr, (GLdouble *)p); break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync default:
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync crWarning("Bad datatype for vertex attribute [%d] array: 0x%x\n",
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync attr, array->a[attr].type);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync}
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync/*
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync * Expand glArrayElement into crPackVertex/Color/Normal/etc.
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync */
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsyncvoid
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsynccrPackExpandArrayElement(GLint index, CRClientState *c)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync{
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync unsigned char *p;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync unsigned int unit, attr;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync const CRVertexArrays *array = &(c->array);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync const GLboolean vpEnabled = crStateGetCurrent()->program.vpEnabled;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync if (array->n.enabled && !(vpEnabled && array->a[VERT_ATTRIB_NORMAL].enabled))
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync p = array->n.p + index * array->n.stride;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync#ifdef CR_ARB_vertex_buffer_object
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync if (array->n.buffer && array->n.buffer->data)
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync p = (unsigned char *)(array->n.buffer->data) + (unsigned long)p;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync#endif
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync switch (array->n.type)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case GL_BYTE: crPackNormal3bv((GLbyte *)p); break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case GL_SHORT: crPackNormal3sv((GLshort *)p); break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case GL_INT: crPackNormal3iv((GLint *)p); break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case GL_FLOAT: crPackNormal3fv((GLfloat *)p); break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case GL_DOUBLE: crPackNormal3dv((GLdouble *)p); break;
977a7ff905883c1b7d4650a211a089684db421f6vboxsync default:
977a7ff905883c1b7d4650a211a089684db421f6vboxsync crWarning("Unhandled: crPackExpandArrayElement, array->n.type 0x%x", array->n.type);
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync }
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync if (array->c.enabled && !(vpEnabled && array->a[VERT_ATTRIB_COLOR0].enabled))
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync p = array->c.p + index * array->c.stride;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync#ifdef CR_ARB_vertex_buffer_object
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync if (array->c.buffer && array->c.buffer->data)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync p = (unsigned char *)(array->c.buffer->data) + (unsigned long)p;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync#endif
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync switch (array->c.type)
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync {
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync case GL_BYTE:
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync switch (c->array.c.size)
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync {
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync case 3: crPackColor3bv((GLbyte *)p); break;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync case 4: crPackColor4bv((GLbyte *)p); break;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync }
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync break;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync case GL_UNSIGNED_BYTE:
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync switch (c->array.c.size)
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync {
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync case 3: crPackColor3ubv((GLubyte *)p); break;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync case 4: crPackColor4ubv((GLubyte *)p); break;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync }
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync break;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync case GL_SHORT:
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync switch (c->array.c.size)
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync {
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync case 3: crPackColor3sv((GLshort *)p); break;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync case 4: crPackColor4sv((GLshort *)p); break;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync }
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync break;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync case GL_UNSIGNED_SHORT:
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync switch (c->array.c.size)
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync {
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync case 3: crPackColor3usv((GLushort *)p); break;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync case 4: crPackColor4usv((GLushort *)p); break;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync }
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync break;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync case GL_INT:
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync switch (c->array.c.size)
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync {
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync case 3: crPackColor3iv((GLint *)p); break;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync case 4: crPackColor4iv((GLint *)p); break;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync }
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync break;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync case GL_UNSIGNED_INT:
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync switch (c->array.c.size)
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync {
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync case 3: crPackColor3uiv((GLuint *)p); break;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync case 4: crPackColor4uiv((GLuint *)p); break;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync }
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync break;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync case GL_FLOAT:
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync switch (c->array.c.size)
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync {
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync case 3: crPackColor3fv((GLfloat *)p); break;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync case 4: crPackColor4fv((GLfloat *)p); break;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync }
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync break;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync case GL_DOUBLE:
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync switch (c->array.c.size)
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync {
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync case 3: crPackColor3dv((GLdouble *)p); break;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync case 4: crPackColor4dv((GLdouble *)p); break;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync }
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync break;
977a7ff905883c1b7d4650a211a089684db421f6vboxsync default:
977a7ff905883c1b7d4650a211a089684db421f6vboxsync crWarning("Unhandled: crPackExpandArrayElement, array->c.type 0x%x", array->c.type);
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync }
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync#ifdef CR_EXT_secondary_color
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync if (array->s.enabled && !(vpEnabled && array->a[VERT_ATTRIB_COLOR1].enabled))
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync p = array->s.p + index * array->s.stride;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync#ifdef CR_ARB_vertex_buffer_object
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync if (array->s.buffer && array->s.buffer->data)
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync p = (unsigned char *)(array->s.buffer->data) + (unsigned long)p;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync#endif
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync switch (array->s.type)
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync {
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync case GL_BYTE:
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync crPackSecondaryColor3bvEXT((GLbyte *)p); break;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync case GL_UNSIGNED_BYTE:
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync crPackSecondaryColor3ubvEXT((GLubyte *)p); break;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync case GL_SHORT:
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync crPackSecondaryColor3svEXT((GLshort *)p); break;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync case GL_UNSIGNED_SHORT:
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync crPackSecondaryColor3usvEXT((GLushort *)p); break;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync case GL_INT:
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync crPackSecondaryColor3ivEXT((GLint *)p); break;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync case GL_UNSIGNED_INT:
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync crPackSecondaryColor3uivEXT((GLuint *)p); break;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync case GL_FLOAT:
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync crPackSecondaryColor3fvEXT((GLfloat *)p); break;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync case GL_DOUBLE:
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync crPackSecondaryColor3dvEXT((GLdouble *)p); break;
977a7ff905883c1b7d4650a211a089684db421f6vboxsync default:
977a7ff905883c1b7d4650a211a089684db421f6vboxsync crWarning("Unhandled: crPackExpandArrayElement, array->s.type 0x%x", array->s.type);
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync }
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync#endif // CR_EXT_secondary_color
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync#ifdef CR_EXT_fog_coord
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync if (array->f.enabled && !(vpEnabled && array->a[VERT_ATTRIB_FOG].enabled))
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync p = array->f.p + index * array->f.stride;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync#ifdef CR_ARB_vertex_buffer_object
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync if (array->f.buffer && array->f.buffer->data)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync p = (unsigned char *)(array->f.buffer->data) + (unsigned long)p;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync#endif
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync crPackFogCoordfEXT( *((GLfloat *) p) );
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync#endif // CR_EXT_fog_coord
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync for (unit = 0 ; unit < CR_MAX_TEXTURE_UNITS ; unit++)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync if (array->t[unit].enabled && !(vpEnabled && array->a[VERT_ATTRIB_TEX0+unit].enabled))
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync p = array->t[unit].p + index * array->t[unit].stride;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync#ifdef CR_ARB_vertex_buffer_object
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync if (array->t[unit].buffer && array->t[unit].buffer->data)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync p = (unsigned char *)(array->t[unit].buffer->data) + (unsigned long)p;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#endif
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync switch (array->t[unit].type)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case GL_SHORT:
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync switch (array->t[unit].size)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 1: crPackMultiTexCoord1svARB(GL_TEXTURE0_ARB + unit, (GLshort *)p); break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 2: crPackMultiTexCoord2svARB(GL_TEXTURE0_ARB + unit, (GLshort *)p); break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 3: crPackMultiTexCoord3svARB(GL_TEXTURE0_ARB + unit, (GLshort *)p); break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 4: crPackMultiTexCoord4svARB(GL_TEXTURE0_ARB + unit, (GLshort *)p); break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case GL_INT:
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync switch (array->t[unit].size)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 1: crPackMultiTexCoord1ivARB(GL_TEXTURE0_ARB + unit, (GLint *)p); break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 2: crPackMultiTexCoord2ivARB(GL_TEXTURE0_ARB + unit, (GLint *)p); break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 3: crPackMultiTexCoord3ivARB(GL_TEXTURE0_ARB + unit, (GLint *)p); break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 4: crPackMultiTexCoord4ivARB(GL_TEXTURE0_ARB + unit, (GLint *)p); break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case GL_FLOAT:
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync switch (array->t[unit].size)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 1: crPackMultiTexCoord1fvARB(GL_TEXTURE0_ARB + unit, (GLfloat *)p); break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 2: crPackMultiTexCoord2fvARB(GL_TEXTURE0_ARB + unit, (GLfloat *)p); break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 3: crPackMultiTexCoord3fvARB(GL_TEXTURE0_ARB + unit, (GLfloat *)p); break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 4: crPackMultiTexCoord4fvARB(GL_TEXTURE0_ARB + unit, (GLfloat *)p); break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case GL_DOUBLE:
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync switch (array->t[unit].size)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 1: crPackMultiTexCoord1dvARB(GL_TEXTURE0_ARB + unit, (GLdouble *)p); break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 2: crPackMultiTexCoord2dvARB(GL_TEXTURE0_ARB + unit, (GLdouble *)p); break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 3: crPackMultiTexCoord3dvARB(GL_TEXTURE0_ARB + unit, (GLdouble *)p); break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 4: crPackMultiTexCoord4dvARB(GL_TEXTURE0_ARB + unit, (GLdouble *)p); break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync break;
977a7ff905883c1b7d4650a211a089684db421f6vboxsync default:
977a7ff905883c1b7d4650a211a089684db421f6vboxsync crWarning("Unhandled: crPackExpandArrayElement, array->t[%i].type 0x%x", unit, array->t[unit].type);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync if (array->i.enabled)
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync p = array->i.p + index * array->i.stride;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync#ifdef CR_ARB_vertex_buffer_object
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync if (array->i.buffer && array->i.buffer->data)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync p = (unsigned char *)(array->i.buffer->data) + (unsigned long)p;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync#endif
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync switch (array->i.type)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case GL_SHORT: crPackIndexsv((GLshort *)p); break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case GL_INT: crPackIndexiv((GLint *)p); break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case GL_FLOAT: crPackIndexfv((GLfloat *)p); break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case GL_DOUBLE: crPackIndexdv((GLdouble *)p); break;
977a7ff905883c1b7d4650a211a089684db421f6vboxsync default:
977a7ff905883c1b7d4650a211a089684db421f6vboxsync crWarning("Unhandled: crPackExpandArrayElement, array->i.type 0x%x", array->i.type);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync if (array->e.enabled)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync p = array->e.p + index * array->e.stride;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync#ifdef CR_ARB_vertex_buffer_object
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync if (array->e.buffer && array->e.buffer->data)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync p = (unsigned char *)(array->e.buffer->data) + (unsigned long)p;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync#endif
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync crPackEdgeFlagv(p);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync for (attr = 1; attr < VERT_ATTRIB_MAX; attr++)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync if (array->a[attr].enabled)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync crPackVertexAttrib(array, attr, index);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync if (array->a[VERT_ATTRIB_POS].enabled)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync crPackVertexAttrib(array, 0, index);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync else if (array->v.enabled)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync p = array->v.p + index * array->v.stride;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync#ifdef CR_ARB_vertex_buffer_object
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync if (array->v.buffer && array->v.buffer->data)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync p = (unsigned char *)(array->v.buffer->data) + (unsigned long)p;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync#endif
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync switch (array->v.type)
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync {
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync case GL_SHORT:
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync switch (c->array.v.size)
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 2: crPackVertex2sv((GLshort *)p); break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 3: crPackVertex3sv((GLshort *)p); break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 4: crPackVertex4sv((GLshort *)p); break;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync }
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync break;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync case GL_INT:
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync switch (c->array.v.size)
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 2: crPackVertex2iv((GLint *)p); break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 3: crPackVertex3iv((GLint *)p); break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 4: crPackVertex4iv((GLint *)p); break;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync }
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync break;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync case GL_FLOAT:
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync switch (c->array.v.size)
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 2: crPackVertex2fv((GLfloat *)p); break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 3: crPackVertex3fv((GLfloat *)p); break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 4: crPackVertex4fv((GLfloat *)p); break;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync }
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync break;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync case GL_DOUBLE:
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync switch (c->array.v.size)
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 2: crPackVertex2dv((GLdouble *)p); break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 3: crPackVertex3dv((GLdouble *)p); break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case 4: crPackVertex4dv((GLdouble *)p); break;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync }
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync break;
977a7ff905883c1b7d4650a211a089684db421f6vboxsync default:
977a7ff905883c1b7d4650a211a089684db421f6vboxsync crWarning("Unhandled: crPackExpandArrayElement, array->v.type 0x%x", array->v.type);
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync }
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsynccrPackExpandDrawArrays(GLenum mode, GLint first, GLsizei count, CRClientState *c)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync int i;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync if (count < 0)
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync {
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync __PackError(__LINE__, __FILE__, GL_INVALID_VALUE, "crPackDrawArrays(negative count)");
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync return;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync }
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync if (mode > GL_POLYGON)
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync {
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync __PackError(__LINE__, __FILE__, GL_INVALID_ENUM, "crPackDrawArrays(bad mode)");
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync return;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync }
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync crPackBegin(mode);
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync for (i=0; i<count; i++)
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync {
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync crPackExpandArrayElement(first + i, c);
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync }
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync crPackEnd();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsyncstatic GLsizei crPackElementsIndexSize(GLenum type)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync{
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync switch (type)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case GL_UNSIGNED_BYTE:
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync return sizeof(GLubyte);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case GL_UNSIGNED_SHORT:
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync return sizeof(GLushort);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case GL_UNSIGNED_INT:
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync return sizeof(GLuint);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync default:
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync crError("Unknown type 0x%x in crPackElementsIndexSize", type);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync return 0;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid PACK_APIENTRY
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsynccrPackDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync unsigned char *data_ptr, *start_ptr;
4aef33e90cfa798b2e6db5b45f02c2a6c8bbc4aevboxsync int packet_length = sizeof(int) + sizeof(mode) + sizeof(count) + sizeof(type) + sizeof(GLuint);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync GLsizei indexsize;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync#ifdef CR_ARB_vertex_buffer_object
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync CRBufferObject *elementsBuffer = crStateGetCurrent()->bufferobject.elementsBuffer;
521a799e2d6b107f295561fbb2d4c8852717dbf1vboxsync packet_length += sizeof(GLint);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync if (elementsBuffer && elementsBuffer->name)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync /*@todo not sure it's possible, and not sure what to do*/
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync if (!elementsBuffer->data)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync crWarning("crPackDrawElements: trying to use bound but empty elements buffer, ignoring.");
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync return;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync indexsize = 0;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync else
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync#endif
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync indexsize = crPackElementsIndexSize(type);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync packet_length += count * indexsize;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync start_ptr = data_ptr = (unsigned char *) crPackAlloc(packet_length);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync WRITE_DATA_AI(GLenum, CR_DRAWELEMENTS_EXTEND_OPCODE );
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync WRITE_DATA_AI(GLenum, mode );
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync WRITE_DATA_AI(GLsizei, count);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync WRITE_DATA_AI(GLenum, type);
4aef33e90cfa798b2e6db5b45f02c2a6c8bbc4aevboxsync WRITE_DATA_AI(GLuint, (GLuint) indices );
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync#ifdef CR_ARB_vertex_buffer_object
521a799e2d6b107f295561fbb2d4c8852717dbf1vboxsync WRITE_DATA_AI(GLint, (GLint)(indexsize>0));
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync#endif
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync if (indexsize>0)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync crMemcpy(data_ptr, indices, count * indexsize);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync crHugePacket(CR_EXTEND_OPCODE, start_ptr);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync crPackFree(start_ptr);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync}
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsyncvoid PACK_APIENTRY
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsynccrPackDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count,
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync GLenum type, const GLvoid *indices)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync{
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync unsigned char *data_ptr, *start_ptr;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync int packet_length = sizeof(int) + sizeof(mode) + sizeof(start)
4aef33e90cfa798b2e6db5b45f02c2a6c8bbc4aevboxsync + sizeof(end) + sizeof(count) + sizeof(type) + sizeof(GLuint);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync GLsizei indexsize;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync#ifdef CR_ARB_vertex_buffer_object
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync CRBufferObject *elementsBuffer = crStateGetCurrent()->bufferobject.elementsBuffer;
521a799e2d6b107f295561fbb2d4c8852717dbf1vboxsync packet_length += sizeof(GLint);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync if (elementsBuffer && elementsBuffer->name)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync /*@todo not sure it's possible, and not sure what to do*/
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync if (!elementsBuffer->data)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync crWarning("crPackDrawElements: trying to use bound but empty elements buffer, ignoring.");
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync return;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync indexsize = 0;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync else
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync#endif
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync indexsize = crPackElementsIndexSize(type);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync packet_length += count * indexsize;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync start_ptr = data_ptr = (unsigned char *) crPackAlloc(packet_length);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync WRITE_DATA_AI(GLenum, CR_DRAWRANGEELEMENTS_EXTEND_OPCODE);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync WRITE_DATA_AI(GLenum, mode);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync WRITE_DATA_AI(GLuint, start);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync WRITE_DATA_AI(GLuint, end);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync WRITE_DATA_AI(GLsizei, count);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync WRITE_DATA_AI(GLenum, type);
4aef33e90cfa798b2e6db5b45f02c2a6c8bbc4aevboxsync WRITE_DATA_AI(GLuint, (GLuint) indices);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync#ifdef CR_ARB_vertex_buffer_object
521a799e2d6b107f295561fbb2d4c8852717dbf1vboxsync WRITE_DATA_AI(GLint, (GLint) (indexsize>0));
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync#endif
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync if (indexsize>0)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync crMemcpy(data_ptr, indices, count * indexsize);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync crHugePacket(CR_EXTEND_OPCODE, start_ptr);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync crPackFree(start_ptr);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Expand glDrawElements into crPackBegin/Vertex/End, etc commands.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Note: if mode==999, don't call glBegin/glEnd.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsynccrPackExpandDrawElements(GLenum mode, GLsizei count, GLenum type,
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync const GLvoid *indices, CRClientState *c)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync int i;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync GLubyte *p = (GLubyte *)indices;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync#ifdef CR_ARB_vertex_buffer_object
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync CRBufferObject *elementsBuffer = crStateGetCurrent()->bufferobject.elementsBuffer;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync#endif
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync if (count < 0)
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync {
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync __PackError(__LINE__, __FILE__, GL_INVALID_VALUE,
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync "crPackDrawElements(negative count)");
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync return;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync }
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync if (mode > GL_POLYGON && mode != 999)
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync {
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync __PackError(__LINE__, __FILE__, GL_INVALID_ENUM,
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync "crPackDrawElements(bad mode)");
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync return;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync }
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync if (type != GL_UNSIGNED_BYTE &&
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync type != GL_UNSIGNED_SHORT &&
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync type != GL_UNSIGNED_INT)
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync {
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync __PackError(__LINE__, __FILE__, GL_INVALID_ENUM,
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync "crPackDrawElements(bad type)");
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync return;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync }
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync#ifdef CR_ARB_vertex_buffer_object
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync if (elementsBuffer && elementsBuffer->data)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync p = (unsigned char *)(elementsBuffer->data) + (unsigned long)p;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync#endif
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync if (mode != 999)
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync crPackBegin(mode);
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync //crDebug("crPackExpandDrawElements mode:0x%x, count:%d, type:0x%x", mode, count, type);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync switch (type)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case GL_UNSIGNED_BYTE:
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync for (i=0; i<count; i++)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync crPackExpandArrayElement((GLint) *p++, c);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case GL_UNSIGNED_SHORT:
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync for (i=0; i<count; i++)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync crPackExpandArrayElement((GLint) * (GLushort *) p, c);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync p+=sizeof (GLushort);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync case GL_UNSIGNED_INT:
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync for (i=0; i<count; i++)
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync crPackExpandArrayElement((GLint) * (GLuint *) p, c);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync p+=sizeof (GLuint);
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync }
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync break;
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync default:
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync crError( "this can't happen: array_spu.self.DrawElements" );
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync break;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync }
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync if (mode != 999)
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync crPackEnd();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Convert a glDrawElements command into a sequence of ArrayElement() calls.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * NOTE: Caller must issue the glBegin/glEnd.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsynccrPackUnrollDrawElements(GLsizei count, GLenum type,
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync const GLvoid *indices)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync int i;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync switch (type) {
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync case GL_UNSIGNED_BYTE:
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync {
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync const GLubyte *p = (const GLubyte *) indices;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync for (i = 0; i < count; i++)
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync crPackArrayElement(p[i]);
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync }
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync break;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync case GL_UNSIGNED_SHORT:
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync {
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync const GLushort *p = (const GLushort *) indices;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync for (i = 0; i < count; i++)
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync crPackArrayElement(p[i]);
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync }
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync break;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync case GL_UNSIGNED_INT:
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync {
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync const GLuint *p = (const GLuint *) indices;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync for (i = 0; i < count; i++)
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync crPackArrayElement(p[i]);
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync }
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync break;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync default:
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync __PackError(__LINE__, __FILE__, GL_INVALID_ENUM,
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync "crPackUnrollDrawElements(bad type)");
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/*
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * glDrawRangeElements, expanded into crPackBegin/Vertex/End/etc.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsynccrPackExpandDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, CRClientState *c)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync if (start>end)
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync {
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync crWarning("crPackExpandDrawRangeElements start>end (%d>%d)", start, end);
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync return;
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync }
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync
236b6e0fdf652661ff4c655314fe488998c5c17dvboxsync crPackExpandDrawElements(mode, count, type, indices, c);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#ifdef CR_EXT_multi_draw_arrays
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/*
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Pack real DrawArrays commands.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid PACK_APIENTRY
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsynccrPackMultiDrawArraysEXT( GLenum mode, GLint *first, GLsizei *count,
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync GLsizei primcount )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync GLint i;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for (i = 0; i < primcount; i++) {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (count[i] > 0) {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync crPackDrawArrays(mode, first[i], count[i]);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/*
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Pack with crPackBegin/Vertex/End/etc.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsynccrPackExpandMultiDrawArraysEXT( GLenum mode, GLint *first, GLsizei *count,
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync GLsizei primcount, CRClientState *c )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync GLint i;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for (i = 0; i < primcount; i++) {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (count[i] > 0) {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync crPackExpandDrawArrays(mode, first[i], count[i], c);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/*
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Pack real DrawElements commands.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid PACK_APIENTRY
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsynccrPackMultiDrawElementsEXT( GLenum mode, const GLsizei *count, GLenum type,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const GLvoid **indices, GLsizei primcount )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync GLint i;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for (i = 0; i < primcount; i++) {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (count[i] > 0) {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync crPackDrawElements(mode, count[i], type, indices[i]);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/*
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Pack with crPackBegin/Vertex/End/etc.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsynccrPackExpandMultiDrawElementsEXT( GLenum mode, const GLsizei *count,
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync GLenum type, const GLvoid **indices,
54cdd2a4e7676bc8694fa8db62ece5a1447b3597vboxsync GLsizei primcount, CRClientState *c )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync GLint i;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for (i = 0; i < primcount; i++) {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (count[i] > 0) {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync crPackExpandDrawElements(mode, count[i], type, indices[i], c);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#endif /* CR_EXT_multi_draw_arrays */