diff options
author | Anthony Pesch <inolen@gmail.com> | 2013-05-06 18:01:44 -0700 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2014-06-17 17:43:33 +0100 |
commit | c0b0fd714ed3c805a72d8f81b9b1ff1fbb51c872 (patch) | |
tree | 19a8f24ef58dd9fa8ae7c4712b1f8852392ae23e /src | |
parent | 856665c109d6a2ea79f223d680771e3040e43d15 (diff) |
Misc fixes to IBO code to correctly use sizeof(glIndex_t)
Diffstat (limited to 'src')
-rw-r--r-- | src/renderergl2/tr_shade.c | 4 | ||||
-rw-r--r-- | src/renderergl2/tr_sky.c | 2 | ||||
-rw-r--r-- | src/renderergl2/tr_surface.c | 4 | ||||
-rw-r--r-- | src/renderergl2/tr_vbo.c | 13 |
4 files changed, 10 insertions, 13 deletions
diff --git a/src/renderergl2/tr_shade.c b/src/renderergl2/tr_shade.c index d2aedaec..0810547b 100644 --- a/src/renderergl2/tr_shade.c +++ b/src/renderergl2/tr_shade.c @@ -45,9 +45,9 @@ R_DrawElements void R_DrawElementsVBO( int numIndexes, glIndex_t firstIndex, glIndex_t minIndex, glIndex_t maxIndex ) { if (glRefConfig.drawRangeElements) - qglDrawRangeElementsEXT(GL_TRIANGLES, minIndex, maxIndex, numIndexes, GL_INDEX_TYPE, BUFFER_OFFSET(firstIndex * sizeof(GL_INDEX_TYPE))); + qglDrawRangeElementsEXT(GL_TRIANGLES, minIndex, maxIndex, numIndexes, GL_INDEX_TYPE, BUFFER_OFFSET(firstIndex * sizeof(glIndex_t))); else - qglDrawElements(GL_TRIANGLES, numIndexes, GL_INDEX_TYPE, BUFFER_OFFSET(firstIndex * sizeof(GL_INDEX_TYPE))); + qglDrawElements(GL_TRIANGLES, numIndexes, GL_INDEX_TYPE, BUFFER_OFFSET(firstIndex * sizeof(glIndex_t))); } diff --git a/src/renderergl2/tr_sky.c b/src/renderergl2/tr_sky.c index 624ab364..d8fcf506 100644 --- a/src/renderergl2/tr_sky.c +++ b/src/renderergl2/tr_sky.c @@ -469,7 +469,7 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max R_DrawElementsVBO(tess.numIndexes - tess.firstIndex, tess.firstIndex, tess.minIndex, tess.maxIndex); - //qglDrawElements(GL_TRIANGLES, tess.numIndexes - tess.firstIndex, GL_INDEX_TYPE, BUFFER_OFFSET(tess.firstIndex * sizeof(GL_INDEX_TYPE))); + //qglDrawElements(GL_TRIANGLES, tess.numIndexes - tess.firstIndex, GL_INDEX_TYPE, BUFFER_OFFSET(tess.firstIndex * sizeof(glIndex_t))); //R_BindNullVBO(); //R_BindNullIBO(); diff --git a/src/renderergl2/tr_surface.c b/src/renderergl2/tr_surface.c index 2d71ba1a..ffdb2964 100644 --- a/src/renderergl2/tr_surface.c +++ b/src/renderergl2/tr_surface.c @@ -438,8 +438,8 @@ static qboolean RB_SurfaceVbo(VBO_t *vbo, IBO_t *ibo, int numVerts, int numIndex // merge this into any existing multidraw primitives mergeForward = -1; mergeBack = -1; - firstIndexOffset = BUFFER_OFFSET(firstIndex * sizeof(GL_INDEX_TYPE)); - lastIndexOffset = BUFFER_OFFSET((firstIndex + numIndexes) * sizeof(GL_INDEX_TYPE)); + firstIndexOffset = BUFFER_OFFSET(firstIndex * sizeof(glIndex_t)); + lastIndexOffset = BUFFER_OFFSET((firstIndex + numIndexes) * sizeof(glIndex_t)); if (r_mergeMultidraws->integer) { diff --git a/src/renderergl2/tr_vbo.c b/src/renderergl2/tr_vbo.c index e9f2598b..09f6104a 100644 --- a/src/renderergl2/tr_vbo.c +++ b/src/renderergl2/tr_vbo.c @@ -506,12 +506,11 @@ IBO_t *R_CreateIBO2(const char *name, int numTriangles, srfTriangle_t * IBO_t *ibo; int i, j; - byte *indexes; + glIndex_t *indexes; int indexesSize; - int indexesOfs; + int indexesCount; srfTriangle_t *tri; - glIndex_t index; int glUsage; switch (usage) @@ -548,17 +547,15 @@ IBO_t *R_CreateIBO2(const char *name, int numTriangles, srfTriangle_t * Q_strncpyz(ibo->name, name, sizeof(ibo->name)); - indexesSize = numTriangles * 3 * sizeof(int); + indexesSize = numTriangles * 3 * sizeof(glIndex_t); indexes = ri.Hunk_AllocateTempMemory(indexesSize); - indexesOfs = 0; + indexesCount = 0; for(i = 0, tri = triangles; i < numTriangles; i++, tri++) { for(j = 0; j < 3; j++) { - index = tri->indexes[j]; - memcpy(indexes + indexesOfs, &index, sizeof(glIndex_t)); - indexesOfs += sizeof(glIndex_t); + indexes[indexesCount++] = tri->indexes[j]; } } |