Commit cc1a38dc authored by Rinnegatamante's avatar Rinnegatamante
Browse files

Test for better renderer.

parent e46316dd
......@@ -133,9 +133,9 @@ void GLimp_Init( qboolean coreContext)
}
vglIndexPointerMapped(indices);
glEnableClientState(GL_VERTEX_ARRAY);
gVertexBufferPtr = (float*)malloc(0x400000);
gColorBufferPtr = (uint8_t*)malloc(0x200000);
gTexCoordBufferPtr = (float*)malloc(0x200000);
gVertexBufferPtr = (float*)malloc(0x10000);
gColorBufferPtr = (uint8_t*)malloc(0x10000);
gTexCoordBufferPtr = (float*)malloc(0x10000);
gVertexBuffer = gVertexBufferPtr;
gColorBuffer = gColorBufferPtr;
gTexCoordBuffer = gTexCoordBufferPtr;
......
......@@ -350,15 +350,15 @@ void RB_MDRSurfaceAnim( mdrSurface_t *surface )
triangles = (int *) ((byte *)surface + surface->ofsTriangles);
indexes = surface->numTriangles * 3;
baseIndex = tess.numIndexes;
baseVertex = tess.numVertexes;
baseIndex = tess->numIndexes;
baseVertex = tess->numVertexes;
// Set up all triangles.
for (j = 0 ; j < indexes ; j++)
{
tess.indexes[baseIndex + j] = baseVertex + triangles[j];
tess->indexes[baseIndex + j] = baseVertex + triangles[j];
}
tess.numIndexes += indexes;
tess->numIndexes += indexes;
//
// lerp all the needed bones
......@@ -404,21 +404,21 @@ void RB_MDRSurfaceAnim( mdrSurface_t *surface )
tempNormal[2] += w->boneWeight * DotProduct( bone->matrix[2], v->normal );
}
tess.xyz[baseVertex + j][0] = tempVert[0];
tess.xyz[baseVertex + j][1] = tempVert[1];
tess.xyz[baseVertex + j][2] = tempVert[2];
tess->xyz[baseVertex + j][0] = tempVert[0];
tess->xyz[baseVertex + j][1] = tempVert[1];
tess->xyz[baseVertex + j][2] = tempVert[2];
tess.normal[baseVertex + j][0] = tempNormal[0];
tess.normal[baseVertex + j][1] = tempNormal[1];
tess.normal[baseVertex + j][2] = tempNormal[2];
tess->normal[baseVertex + j][0] = tempNormal[0];
tess->normal[baseVertex + j][1] = tempNormal[1];
tess->normal[baseVertex + j][2] = tempNormal[2];
tess.texCoords[baseVertex + j][0][0] = v->texCoords[0];
tess.texCoords[baseVertex + j][0][1] = v->texCoords[1];
tess->texCoords[baseVertex + j][0][0] = v->texCoords[0];
tess->texCoords[baseVertex + j][0][1] = v->texCoords[1];
v = (mdrVertex_t *)&v->weights[v->numWeights];
}
tess.numVertexes += surface->numVerts;
tess->numVertexes += surface->numVerts;
}
......
......@@ -543,7 +543,7 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
// we have to reset the shaderTime as well otherwise image animations start
// from the wrong frame
tess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset;
tess->shaderTime = backEnd.refdef.floatTime - tess->shader->timeOffset;
// set up the transformation matrix
R_RotateForEntity( backEnd.currentEntity, &backEnd.viewParms, &backEnd.or );
......@@ -567,7 +567,7 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
backEnd.or = backEnd.viewParms.world;
// we have to reset the shaderTime as well otherwise image animations on
// the world (like water) continue with the wrong frame
tess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset;
tess->shaderTime = backEnd.refdef.floatTime - tess->shader->timeOffset;
R_TransformDlights( backEnd.refdef.num_dlights, backEnd.refdef.dlights, &backEnd.or );
}
......@@ -714,7 +714,7 @@ void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte *
}
R_IssuePendingRenderCommands();
if ( tess.numIndexes ) {
if ( tess->numIndexes ) {
RB_EndSurface();
}
......@@ -842,8 +842,8 @@ const void *RB_StretchPic ( const void *data ) {
}
shader = cmd->shader;
if ( shader != tess.shader ) {
if ( tess.numIndexes ) {
if ( shader != tess->shader ) {
if ( tess->numIndexes ) {
RB_EndSurface();
}
backEnd.currentEntity = &backEnd.entity2D;
......@@ -851,51 +851,51 @@ const void *RB_StretchPic ( const void *data ) {
}
RB_CHECKOVERFLOW( 4, 6 );
numVerts = tess.numVertexes;
numIndexes = tess.numIndexes;
numVerts = tess->numVertexes;
numIndexes = tess->numIndexes;
tess.numVertexes += 4;
tess.numIndexes += 6;
tess->numVertexes += 4;
tess->numIndexes += 6;
tess.indexes[ numIndexes ] = numVerts + 3;
tess.indexes[ numIndexes + 1 ] = numVerts + 0;
tess.indexes[ numIndexes + 2 ] = numVerts + 2;
tess.indexes[ numIndexes + 3 ] = numVerts + 2;
tess.indexes[ numIndexes + 4 ] = numVerts + 0;
tess.indexes[ numIndexes + 5 ] = numVerts + 1;
tess->indexes[ numIndexes ] = numVerts + 3;
tess->indexes[ numIndexes + 1 ] = numVerts + 0;
tess->indexes[ numIndexes + 2 ] = numVerts + 2;
tess->indexes[ numIndexes + 3 ] = numVerts + 2;
tess->indexes[ numIndexes + 4 ] = numVerts + 0;
tess->indexes[ numIndexes + 5 ] = numVerts + 1;
*(int *)tess.vertexColors[ numVerts ] =
*(int *)tess.vertexColors[ numVerts + 1 ] =
*(int *)tess.vertexColors[ numVerts + 2 ] =
*(int *)tess.vertexColors[ numVerts + 3 ] = *(int *)backEnd.color2D;
*(int *)tess->vertexColors[ numVerts ] =
*(int *)tess->vertexColors[ numVerts + 1 ] =
*(int *)tess->vertexColors[ numVerts + 2 ] =
*(int *)tess->vertexColors[ numVerts + 3 ] = *(int *)backEnd.color2D;
tess.xyz[ numVerts ][0] = cmd->x;
tess.xyz[ numVerts ][1] = cmd->y;
tess.xyz[ numVerts ][2] = 0;
tess->xyz[ numVerts ][0] = cmd->x;
tess->xyz[ numVerts ][1] = cmd->y;
tess->xyz[ numVerts ][2] = 0;
tess.texCoords[ numVerts ][0][0] = cmd->s1;
tess.texCoords[ numVerts ][0][1] = cmd->t1;
tess->texCoords[ numVerts ][0][0] = cmd->s1;
tess->texCoords[ numVerts ][0][1] = cmd->t1;
tess.xyz[ numVerts + 1 ][0] = cmd->x + cmd->w;
tess.xyz[ numVerts + 1 ][1] = cmd->y;
tess.xyz[ numVerts + 1 ][2] = 0;
tess->xyz[ numVerts + 1 ][0] = cmd->x + cmd->w;
tess->xyz[ numVerts + 1 ][1] = cmd->y;
tess->xyz[ numVerts + 1 ][2] = 0;
tess.texCoords[ numVerts + 1 ][0][0] = cmd->s2;
tess.texCoords[ numVerts + 1 ][0][1] = cmd->t1;
tess->texCoords[ numVerts + 1 ][0][0] = cmd->s2;
tess->texCoords[ numVerts + 1 ][0][1] = cmd->t1;
tess.xyz[ numVerts + 2 ][0] = cmd->x + cmd->w;
tess.xyz[ numVerts + 2 ][1] = cmd->y + cmd->h;
tess.xyz[ numVerts + 2 ][2] = 0;
tess->xyz[ numVerts + 2 ][0] = cmd->x + cmd->w;
tess->xyz[ numVerts + 2 ][1] = cmd->y + cmd->h;
tess->xyz[ numVerts + 2 ][2] = 0;
tess.texCoords[ numVerts + 2 ][0][0] = cmd->s2;
tess.texCoords[ numVerts + 2 ][0][1] = cmd->t2;
tess->texCoords[ numVerts + 2 ][0][0] = cmd->s2;
tess->texCoords[ numVerts + 2 ][0][1] = cmd->t2;
tess.xyz[ numVerts + 3 ][0] = cmd->x;
tess.xyz[ numVerts + 3 ][1] = cmd->y + cmd->h;
tess.xyz[ numVerts + 3 ][2] = 0;
tess->xyz[ numVerts + 3 ][0] = cmd->x;
tess->xyz[ numVerts + 3 ][1] = cmd->y + cmd->h;
tess->xyz[ numVerts + 3 ][2] = 0;
tess.texCoords[ numVerts + 3 ][0][0] = cmd->s1;
tess.texCoords[ numVerts + 3 ][0][1] = cmd->t2;
tess->texCoords[ numVerts + 3 ][0][0] = cmd->s1;
tess->texCoords[ numVerts + 3 ][0][1] = cmd->t2;
return (const void *)(cmd + 1);
}
......@@ -911,7 +911,7 @@ const void *RB_DrawSurfs( const void *data ) {
const drawSurfsCommand_t *cmd;
// finish any 2D drawing if needed
if ( tess.numIndexes ) {
if ( tess->numIndexes ) {
RB_EndSurface();
}
......@@ -1038,7 +1038,7 @@ const void *RB_ClearDepth(const void *data)
{
const clearDepthCommand_t *cmd = data;
if(tess.numIndexes)
if(tess->numIndexes)
RB_EndSurface();
// texture swapping test
......@@ -1060,7 +1060,7 @@ const void *RB_SwapBuffers( const void *data ) {
const swapBuffersCommand_t *cmd;
// finish any 2D drawing if needed
if ( tess.numIndexes ) {
if ( tess->numIndexes ) {
RB_EndSurface();
}
......
......@@ -372,9 +372,9 @@ void RB_RenderFlare( flare_t *f ) {
// Calculations for fogging
if(tr.world && f->fogNum > 0 && f->fogNum < tr.world->numfogs)
{
tess.numVertexes = 1;
VectorCopy(f->origin, tess.xyz[0]);
tess.fogNum = f->fogNum;
tess->numVertexes = 1;
VectorCopy(f->origin, tess->xyz[0]);
tess->fogNum = f->fogNum;
RB_CalcModulateColorsByFog(fogFactors);
......@@ -390,52 +390,52 @@ void RB_RenderFlare( flare_t *f ) {
RB_BeginSurface( tr.flareShader, f->fogNum );
// FIXME: use quadstamp?
tess.xyz[tess.numVertexes][0] = f->windowX - size;
tess.xyz[tess.numVertexes][1] = f->windowY - size;
tess.texCoords[tess.numVertexes][0][0] = 0;
tess.texCoords[tess.numVertexes][0][1] = 0;
tess.vertexColors[tess.numVertexes][0] = iColor[0];
tess.vertexColors[tess.numVertexes][1] = iColor[1];
tess.vertexColors[tess.numVertexes][2] = iColor[2];
tess.vertexColors[tess.numVertexes][3] = 255;
tess.numVertexes++;
tess.xyz[tess.numVertexes][0] = f->windowX - size;
tess.xyz[tess.numVertexes][1] = f->windowY + size;
tess.texCoords[tess.numVertexes][0][0] = 0;
tess.texCoords[tess.numVertexes][0][1] = 1;
tess.vertexColors[tess.numVertexes][0] = iColor[0];
tess.vertexColors[tess.numVertexes][1] = iColor[1];
tess.vertexColors[tess.numVertexes][2] = iColor[2];
tess.vertexColors[tess.numVertexes][3] = 255;
tess.numVertexes++;
tess.xyz[tess.numVertexes][0] = f->windowX + size;
tess.xyz[tess.numVertexes][1] = f->windowY + size;
tess.texCoords[tess.numVertexes][0][0] = 1;
tess.texCoords[tess.numVertexes][0][1] = 1;
tess.vertexColors[tess.numVertexes][0] = iColor[0];
tess.vertexColors[tess.numVertexes][1] = iColor[1];
tess.vertexColors[tess.numVertexes][2] = iColor[2];
tess.vertexColors[tess.numVertexes][3] = 255;
tess.numVertexes++;
tess.xyz[tess.numVertexes][0] = f->windowX + size;
tess.xyz[tess.numVertexes][1] = f->windowY - size;
tess.texCoords[tess.numVertexes][0][0] = 1;
tess.texCoords[tess.numVertexes][0][1] = 0;
tess.vertexColors[tess.numVertexes][0] = iColor[0];
tess.vertexColors[tess.numVertexes][1] = iColor[1];
tess.vertexColors[tess.numVertexes][2] = iColor[2];
tess.vertexColors[tess.numVertexes][3] = 255;
tess.numVertexes++;
tess.indexes[tess.numIndexes++] = 0;
tess.indexes[tess.numIndexes++] = 1;
tess.indexes[tess.numIndexes++] = 2;
tess.indexes[tess.numIndexes++] = 0;
tess.indexes[tess.numIndexes++] = 2;
tess.indexes[tess.numIndexes++] = 3;
tess->xyz[tess->numVertexes][0] = f->windowX - size;
tess->xyz[tess->numVertexes][1] = f->windowY - size;
tess->texCoords[tess->numVertexes][0][0] = 0;
tess->texCoords[tess->numVertexes][0][1] = 0;
tess->vertexColors[tess->numVertexes][0] = iColor[0];
tess->vertexColors[tess->numVertexes][1] = iColor[1];
tess->vertexColors[tess->numVertexes][2] = iColor[2];
tess->vertexColors[tess->numVertexes][3] = 255;
tess->numVertexes++;
tess->xyz[tess->numVertexes][0] = f->windowX - size;
tess->xyz[tess->numVertexes][1] = f->windowY + size;
tess->texCoords[tess->numVertexes][0][0] = 0;
tess->texCoords[tess->numVertexes][0][1] = 1;
tess->vertexColors[tess->numVertexes][0] = iColor[0];
tess->vertexColors[tess->numVertexes][1] = iColor[1];
tess->vertexColors[tess->numVertexes][2] = iColor[2];
tess->vertexColors[tess->numVertexes][3] = 255;
tess->numVertexes++;
tess->xyz[tess->numVertexes][0] = f->windowX + size;
tess->xyz[tess->numVertexes][1] = f->windowY + size;
tess->texCoords[tess->numVertexes][0][0] = 1;
tess->texCoords[tess->numVertexes][0][1] = 1;
tess->vertexColors[tess->numVertexes][0] = iColor[0];
tess->vertexColors[tess->numVertexes][1] = iColor[1];
tess->vertexColors[tess->numVertexes][2] = iColor[2];
tess->vertexColors[tess->numVertexes][3] = 255;
tess->numVertexes++;
tess->xyz[tess->numVertexes][0] = f->windowX + size;
tess->xyz[tess->numVertexes][1] = f->windowY - size;
tess->texCoords[tess->numVertexes][0][0] = 1;
tess->texCoords[tess->numVertexes][0][1] = 0;
tess->vertexColors[tess->numVertexes][0] = iColor[0];
tess->vertexColors[tess->numVertexes][1] = iColor[1];
tess->vertexColors[tess->numVertexes][2] = iColor[2];
tess->vertexColors[tess->numVertexes][3] = 255;
tess->numVertexes++;
tess->indexes[tess->numIndexes++] = 0;
tess->indexes[tess->numIndexes++] = 1;
tess->indexes[tess->numIndexes++] = 2;
tess->indexes[tess->numIndexes++] = 0;
tess->indexes[tess->numIndexes++] = 2;
tess->indexes[tess->numIndexes++] = 3;
RB_EndSurface();
}
......
......@@ -1188,6 +1188,8 @@ void R_Register( void )
ri.Cmd_AddCommand( "minimize", GLimp_Minimize );
}
shaderCommands_t *tess_pool[256];
/*
===============
R_Init
......@@ -1200,19 +1202,24 @@ void R_Init( void ) {
ri.Printf( PRINT_ALL, "----- R_Init -----\n" );
for (i=0; i < 256; i++){
tess_pool[i] = (shaderCommands_t*)malloc(sizeof(shaderCommands_t));
}
tess = tess_pool[0];
// clear all our internal state
Com_Memset( &tr, 0, sizeof( tr ) );
Com_Memset( &backEnd, 0, sizeof( backEnd ) );
Com_Memset( &tess, 0, sizeof( tess ) );
Com_Memset( tess, 0, sizeof( shaderCommands_t ) );
if(sizeof(glconfig_t) != 11332)
ri.Error( ERR_FATAL, "Mod ABI incompatible: sizeof(glconfig_t) == %u != 11332", (unsigned int) sizeof(glconfig_t));
// Swap_Init();
if ( (intptr_t)tess.xyz & 15 ) {
ri.Printf( PRINT_WARNING, "tess.xyz not 16 byte aligned\n" );
if ( (intptr_t)tess->xyz & 15 ) {
ri.Printf( PRINT_WARNING, "tess->xyz not 16 byte aligned\n" );
}
Com_Memset( tess.constantColor255, 255, sizeof( tess.constantColor255 ) );
Com_Memset( tess->constantColor255, 255, sizeof( tess->constantColor255 ) );
//
// init function tables
......
......@@ -33,7 +33,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "../renderercommon/qgl.h"
#define GL_INDEX_TYPE GL_UNSIGNED_INT
typedef unsigned int glIndex_t;
typedef uint16_t glIndex_t;
// 14 bits
// can't be increased without changing bit packing for drawsurfs
......@@ -160,8 +160,8 @@ typedef enum {
CGEN_IDENTITY, // always (1,1,1,1)
CGEN_ENTITY, // grabbed from entity's modulate field
CGEN_ONE_MINUS_ENTITY, // grabbed from 1 - entity.modulate
CGEN_EXACT_VERTEX, // tess.vertexColors
CGEN_VERTEX, // tess.vertexColors * tr.identityLight
CGEN_EXACT_VERTEX, // tess->vertexColors
CGEN_VERTEX, // tess->vertexColors * tr.identityLight
CGEN_ONE_MINUS_VERTEX,
CGEN_WAVEFORM, // programmatically generated
CGEN_LIGHTING_DIFFUSE,
......@@ -1231,12 +1231,14 @@ typedef struct shaderCommands_s
shaderStage_t **xstages;
} shaderCommands_t;
extern shaderCommands_t tess;
extern shaderCommands_t *tess;
extern shaderCommands_t *tess_pool[256];
extern uint8_t tess_idx;
void RB_BeginSurface(shader_t *shader, int fogNum );
void RB_EndSurface(void);
void RB_CheckOverflow( int verts, int indexes );
#define RB_CHECKOVERFLOW(v,i) if (tess.numVertexes + (v) >= SHADER_MAX_VERTEXES || tess.numIndexes + (i) >= SHADER_MAX_INDEXES ) {RB_CheckOverflow(v,i);}
#define RB_CHECKOVERFLOW(v,i) if (tess->numVertexes + (v) >= SHADER_MAX_VERTEXES || tess->numIndexes + (i) >= SHADER_MAX_INDEXES ) {RB_CheckOverflow(v,i);}
void RB_StageIteratorGeneric( void );
void RB_StageIteratorSky( void );
......
......@@ -864,14 +864,14 @@ static qboolean SurfIsOffscreen( const drawSurf_t *drawSurf, vec4_t clipDest[128
RB_BeginSurface( shader, fogNum );
rb_surfaceTable[ *drawSurf->surface ]( drawSurf->surface );
assert( tess.numVertexes < 128 );
assert( tess->numVertexes < 128 );
for ( i = 0; i < tess.numVertexes; i++ )
for ( i = 0; i < tess->numVertexes; i++ )
{
int j;
unsigned int pointFlags = 0;
R_TransformModelToClip( tess.xyz[i], tr.or.modelMatrix, tr.viewParms.projectionMatrix, eye, clip );
R_TransformModelToClip( tess->xyz[i], tr.or.modelMatrix, tr.viewParms.projectionMatrix, eye, clip );
for ( j = 0; j < 3; j++ )
{
......@@ -899,14 +899,14 @@ static qboolean SurfIsOffscreen( const drawSurf_t *drawSurf, vec4_t clipDest[128
// based on vertex distance isn't 100% correct (we should be checking for
// range to the surface), but it's good enough for the types of portals
// we have in the game right now.
numTriangles = tess.numIndexes / 3;
numTriangles = tess->numIndexes / 3;
for ( i = 0; i < tess.numIndexes; i += 3 )
for ( i = 0; i < tess->numIndexes; i += 3 )
{
vec3_t normal;
float len;
VectorSubtract( tess.xyz[tess.indexes[i]], tr.viewParms.or.origin, normal );
VectorSubtract( tess->xyz[tess->indexes[i]], tr.viewParms.or.origin, normal );
len = VectorLengthSquared( normal ); // lose the sqrt
if ( len < shortest )
......@@ -914,7 +914,7 @@ static qboolean SurfIsOffscreen( const drawSurf_t *drawSurf, vec4_t clipDest[128
shortest = len;
}
if ( DotProduct( normal, tess.normal[tess.indexes[i]] ) >= 0 )
if ( DotProduct( normal, tess->normal[tess->indexes[i]] ) >= 0 )
{
numTriangles--;
}
......@@ -931,7 +931,7 @@ static qboolean SurfIsOffscreen( const drawSurf_t *drawSurf, vec4_t clipDest[128
return qfalse;
}
if ( shortest > (tess.shader->portalRange*tess.shader->portalRange) )
if ( shortest > (tess->shader->portalRange*tess->shader->portalRange) )
{
return qtrue;
}
......
......@@ -1035,10 +1035,10 @@ void RB_IQMSurfaceAnim( surfaceType_t *surface ) {
RB_CHECKOVERFLOW( surf->num_vertexes, surf->num_triangles * 3 );
outXYZ = &tess.xyz[tess.numVertexes];
outNormal = &tess.normal[tess.numVertexes];
outTexCoord = &tess.texCoords[tess.numVertexes];
outColor = &tess.vertexColors[tess.numVertexes];
outXYZ = &tess->xyz[tess->numVertexes];
outNormal = &tess->normal[tess->numVertexes];
outTexCoord = &tess->texCoords[tess->numVertexes];
outColor = &tess->vertexColors[tess->numVertexes];
// compute interpolated joint matrices
if ( data->num_poses > 0 ) {
......@@ -1134,8 +1134,8 @@ void RB_IQMSurfaceAnim( surfaceType_t *surface ) {
}
tri = data->triangles + 3 * surf->first_triangle;
ptr = &tess.indexes[tess.numIndexes];
base = tess.numVertexes;
ptr = &tess->indexes[tess->numIndexes];
base = tess->numVertexes;
for( i = 0; i < surf->num_triangles; i++ ) {
*ptr++ = base + (*tri++ - surf->first_vertex);
......@@ -1143,8 +1143,8 @@ void RB_IQMSurfaceAnim( surfaceType_t *surface ) {
*ptr++ = base + (*tri++ - surf->first_vertex);
}
tess.numIndexes += 3 * surf->num_triangles;
tess.numVertexes += surf->num_vertexes;
tess->numIndexes += 3 * surf->num_triangles;
tess->numVertexes += surf->num_vertexes;
}
int R_IQMLerpTag( orientation_t *tag, iqmData_t *data,
......
......@@ -40,6 +40,7 @@ without compiled vertex arrays.
==================
*/
static void R_DrawElements( int numIndexes, const glIndex_t *indexes ) {
vglIndexPointerMapped(indexes);
vglDrawObjects(GL_TRIANGLES, numIndexes, GL_TRUE);
}
......@@ -52,7 +53,7 @@ SURFACE SHADERS
=============================================================
*/
shaderCommands_t tess;
shaderCommands_t *tess;
static qboolean setArraysOnce;
/*
......@@ -77,7 +78,7 @@ static void R_BindAnimatedImage( textureBundle_t *bundle ) {
// it is necessary to do this messy calc to make sure animations line up
// exactly with waveforms of the same frequency
index = tess.shaderTime * bundle->imageAnimationSpeed * FUNCTABLE_SIZE;
index = tess->shaderTime * bundle->imageAnimationSpeed * FUNCTABLE_SIZE;
index >>= FUNCTABLE_SIZE2;
if ( index < 0 ) {
......@@ -114,7 +115,7 @@ static void DrawTris (shaderCommands_t *input) {
memcpy(gVertexBuffer, input->xyz[input->indexes[i]], sizeof(vec3_t));
gVertexBuffer += 3;
}
vglVertexPointerMapped(vertices);
//->vglVertexPointerMapped(vertices);
//->if (qglLockArraysEXT) {
//-> qglLockArraysEXT(0, input->numVertexes);
......@@ -155,7 +156,7 @@ static void DrawNormals (shaderCommands_t *input) {
memcpy(gVertexBuffer, temp, sizeof(vec3_t));
gVertexBuffer += 3;
}
vglVertexPointerMapped(vertices);
//->vglVertexPointerMapped(vertices);
vglDrawObjects(GL_LINES, input->numVertexes * 2, GL_TRUE);
qglDepthRange( 0, 1 );
......@@ -170,22 +171,25 @@ because a surface may be forced to perform a RB_End due
to overflow.
==============
*/
uint8_t tess_idx = 0;
void RB_BeginSurface( shader_t *shader, int fogNum ) {
shader_t *state = (shader->remappedShader) ? shader->remappedShader : shader;
tess.numIndexes = 0;
tess.numVertexes = 0;
tess.shader = state;
tess.fogNum = fogNum;
tess.dlightBits = 0; // will be OR'd in by surface functions
tess.xstages = state->stages;
tess.numPasses = state->numUnfoggedPasses;
tess.currentStageIteratorFunc = state->optimalStageIteratorFunc;
tess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset;
if (tess.shader->clampTime && tess.shaderTime >= tess.shader->clampTime) {
tess.shaderTime = tess.shader->clampTime;
tess_idx = (tess_idx + 1) % 256;
tess = tess_pool[tess_idx];
tess->numIndexes = 0;
tess->numVertexes = 0;
tess->shader = state;
tess->fogNum = fogNum;
tess->dlightBits = 0; // will be OR'd in by surface functions
tess->xstages = state->stages;
tess->numPasses = state->numUnfoggedPasses;
tess->currentStageIteratorFunc = state->optimalStageIteratorFunc;
tess->shaderTime = backEnd.refdef.floatTime - tess->shader->timeOffset;
if (tess->shader->clampTime && tess->shaderTime >= tess->shader->clampTime) {
tess->shaderTime = tess->shader->clampTime;
}
......@@ -204,7 +208,7 @@ t1 = most downstream according to spec
static void DrawMultitextured( shaderCommands_t *input, int stage ) {
shaderStage_t *pStage;
pStage = tess.xstages[stage];
pStage = tess->xstages[stage];
GL_State( pStage->stateBits );
......@@ -218,13 +222,7 @@ static void DrawMultitextured( shaderCommands_t *input, int stage ) {
// base