summaryrefslogtreecommitdiff
path: root/src/renderergl2/tr_surface.c
diff options
context:
space:
mode:
authorSmileTheory <SmileTheory@gmail.com>2013-11-08 01:46:17 -0800
committerTim Angus <tim@ngus.net>2014-06-17 17:43:36 +0100
commit877ec28e7cab95c190366ae2d3d26955bc6993d7 (patch)
tree12be964e06132c9e08ab16f60573b94cda301eee /src/renderergl2/tr_surface.c
parent98078a30922ff0da92f7023b18f954f894058a18 (diff)
OpenGL2: Remove srfTriangle_t, and use glIndex_t instead.
Diffstat (limited to 'src/renderergl2/tr_surface.c')
-rw-r--r--src/renderergl2/tr_surface.c50
1 files changed, 21 insertions, 29 deletions
diff --git a/src/renderergl2/tr_surface.c b/src/renderergl2/tr_surface.c
index 563c75c1..eff3a257 100644
--- a/src/renderergl2/tr_surface.c
+++ b/src/renderergl2/tr_surface.c
@@ -312,30 +312,28 @@ static void RB_SurfacePolychain( srfPoly_t *p ) {
tess.numVertexes = numv;
}
-static void RB_SurfaceVertsAndTris( int numVerts, srfVert_t *verts, int numTriangles, srfTriangle_t *triangles, int dlightBits, int pshadowBits)
+static void RB_SurfaceVertsAndIndexes( int numVerts, srfVert_t *verts, int numIndexes, glIndex_t *indexes, int dlightBits, int pshadowBits)
{
int i;
- srfTriangle_t *tri;
+ glIndex_t *inIndex;
srfVert_t *dv;
float *xyz, *normal, *texCoords, *lightCoords, *lightdir;
#ifdef USE_VERT_TANGENT_SPACE
float *tangent, *bitangent;
#endif
- glIndex_t *index;
+ glIndex_t *outIndex;
float *color;
RB_CheckVBOandIBO(tess.vbo, tess.ibo);
- RB_CHECKOVERFLOW( numVerts, numTriangles * 3 );
+ RB_CHECKOVERFLOW( numVerts, numIndexes );
- tri = triangles;
- index = &tess.indexes[ tess.numIndexes ];
- for ( i = 0 ; i < numTriangles ; i++, tri++ ) {
- *index++ = tess.numVertexes + tri->indexes[0];
- *index++ = tess.numVertexes + tri->indexes[1];
- *index++ = tess.numVertexes + tri->indexes[2];
+ inIndex = indexes;
+ outIndex = &tess.indexes[ tess.numIndexes ];
+ for ( i = 0 ; i < numIndexes ; i++ ) {
+ *outIndex++ = tess.numVertexes + *inIndex++;
}
- tess.numIndexes += numTriangles * 3;
+ tess.numIndexes += numIndexes;
if ( tess.shader->vertexAttribs & ATTR_POSITION )
{
@@ -524,14 +522,14 @@ RB_SurfaceTriangles
=============
*/
static void RB_SurfaceTriangles( srfBspSurface_t *srf ) {
- if( RB_SurfaceVbo (srf->vbo, srf->ibo, srf->numVerts, srf->numTriangles * 3,
+ if( RB_SurfaceVbo (srf->vbo, srf->ibo, srf->numVerts, srf->numIndexes,
srf->firstIndex, srf->minIndex, srf->maxIndex, srf->dlightBits, srf->pshadowBits, qtrue ) )
{
return;
}
- RB_SurfaceVertsAndTris(srf->numVerts, srf->verts, srf->numTriangles,
- srf->triangles, srf->dlightBits, srf->pshadowBits);
+ RB_SurfaceVertsAndIndexes(srf->numVerts, srf->verts, srf->numIndexes,
+ srf->indexes, srf->dlightBits, srf->pshadowBits);
}
@@ -1202,9 +1200,7 @@ RB_SurfaceMesh
static void RB_SurfaceMesh(mdvSurface_t *surface) {
int j;
float backlerp;
- srfTriangle_t *triangles;
mdvSt_t *texCoords;
- int indexes;
int Bob, Doug;
int numVerts;
@@ -1214,20 +1210,16 @@ static void RB_SurfaceMesh(mdvSurface_t *surface) {
backlerp = backEnd.currentEntity->e.backlerp;
}
- RB_CHECKOVERFLOW( surface->numVerts, surface->numTriangles*3 );
+ RB_CHECKOVERFLOW( surface->numVerts, surface->numIndexes );
LerpMeshVertexes (surface, backlerp);
- triangles = surface->triangles;
- indexes = surface->numTriangles * 3;
Bob = tess.numIndexes;
Doug = tess.numVertexes;
- for (j = 0 ; j < surface->numTriangles ; j++) {
- tess.indexes[Bob + j*3 + 0] = Doug + triangles[j].indexes[0];
- tess.indexes[Bob + j*3 + 1] = Doug + triangles[j].indexes[1];
- tess.indexes[Bob + j*3 + 2] = Doug + triangles[j].indexes[2];
+ for (j = 0 ; j < surface->numIndexes ; j++) {
+ tess.indexes[Bob + j] = Doug + surface->indexes[j];
}
- tess.numIndexes += indexes;
+ tess.numIndexes += surface->numIndexes;
texCoords = surface->st;
@@ -1249,14 +1241,14 @@ RB_SurfaceFace
==============
*/
static void RB_SurfaceFace( srfBspSurface_t *srf ) {
- if( RB_SurfaceVbo (srf->vbo, srf->ibo, srf->numVerts, srf->numTriangles * 3,
+ if( RB_SurfaceVbo (srf->vbo, srf->ibo, srf->numVerts, srf->numIndexes,
srf->firstIndex, srf->minIndex, srf->maxIndex, srf->dlightBits, srf->pshadowBits, qtrue ) )
{
return;
}
- RB_SurfaceVertsAndTris(srf->numVerts, srf->verts, srf->numTriangles,
- srf->triangles, srf->dlightBits, srf->pshadowBits);
+ RB_SurfaceVertsAndIndexes(srf->numVerts, srf->verts, srf->numIndexes,
+ srf->indexes, srf->dlightBits, srf->pshadowBits);
}
@@ -1318,7 +1310,7 @@ static void RB_SurfaceGrid( srfBspSurface_t *srf ) {
int pshadowBits;
//int *vDlightBits;
- if( RB_SurfaceVbo (srf->vbo, srf->ibo, srf->numVerts, srf->numTriangles * 3,
+ if( RB_SurfaceVbo (srf->vbo, srf->ibo, srf->numVerts, srf->numIndexes,
srf->firstIndex, srf->minIndex, srf->maxIndex, srf->dlightBits, srf->pshadowBits, qtrue ) )
{
return;
@@ -1577,7 +1569,7 @@ static void RB_SurfaceFlare(srfFlare_t *surf)
static void RB_SurfaceVBOMesh(srfBspSurface_t * srf)
{
- RB_SurfaceVbo (srf->vbo, srf->ibo, srf->numVerts, srf->numTriangles * 3, srf->firstIndex,
+ RB_SurfaceVbo (srf->vbo, srf->ibo, srf->numVerts, srf->numIndexes, srf->firstIndex,
srf->minIndex, srf->maxIndex, srf->dlightBits, srf->pshadowBits, qfalse );
}