From: havoc Date: Sat, 16 Nov 2002 13:35:36 +0000 (+0000) Subject: merged GL_DrawRangeElements into R_Mesh_Draw for a mild speed gain X-Git-Tag: RELEASE_0_2_0_RC1~66 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=200ecb6b75b266bbace45e68aa9139a942c4896b;p=xonotic%2Fdarkplaces.git merged GL_DrawRangeElements into R_Mesh_Draw for a mild speed gain git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2631 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/gl_backend.c b/gl_backend.c index a6648711..a815ba62 100644 --- a/gl_backend.c +++ b/gl_backend.c @@ -528,35 +528,6 @@ void GL_ConvertColorsFloatToByte(int numverts) } } -void GL_DrawRangeElements(int firstvert, int endvert, int indexcount, const int *index) -{ - int arraylocked = false; - c_meshs++; - c_meshelements += indexcount; - if (indexcount == 0 || endvert == firstvert) - { - Con_Printf("GL_DrawRangeElements(%d, %d, %d, %08p);\n", firstvert, endvert, indexcount, index); - return; - } - if (gl_supportslockarrays && gl_lockarrays.integer) - { - qglLockArraysEXT(firstvert, endvert - firstvert); - CHECKGLERROR - arraylocked = true; - } - if (gl_mesh_drawrangeelements.integer && qglDrawRangeElements != NULL) - qglDrawRangeElements(GL_TRIANGLES, firstvert, endvert, indexcount, GL_UNSIGNED_INT, (const GLuint *) index); - else - qglDrawElements(GL_TRIANGLES, indexcount, GL_UNSIGNED_INT, (const GLuint *) index); - CHECKGLERROR - if (arraylocked) - { - qglUnlockArraysEXT(); - CHECKGLERROR - arraylocked = false; - } -} - // enlarges geometry buffers if they are too small void _R_Mesh_ResizeCheck(int numverts) { @@ -571,15 +542,36 @@ void _R_Mesh_ResizeCheck(int numverts) // renders the mesh void R_Mesh_Draw(int numverts, int numtriangles, const int *elements) { - BACKENDACTIVECHECK - - CHECKGLERROR - + int numelements; + if (numtriangles == 0 || numverts == 0) + { + Con_Printf("R_Mesh_Draw(%d, %d, %08p);\n", numverts, numtriangles, elements); + return; + } + numelements = numtriangles * 3; + c_meshs++; + c_meshelements += numelements; if (gl_state.colorarray && !gl_mesh_floatcolors.integer) GL_ConvertColorsFloatToByte(numverts); if (!r_render.integer) return; - GL_DrawRangeElements(0, numverts, numtriangles * 3, elements); + if (gl_supportslockarrays && gl_lockarrays.integer) + { + qglLockArraysEXT(0, numverts); + CHECKGLERROR + if (gl_mesh_drawrangeelements.integer && qglDrawRangeElements != NULL) + qglDrawRangeElements(GL_TRIANGLES, 0, numverts, numelements, GL_UNSIGNED_INT, (const GLuint *) elements); + else + qglDrawElements(GL_TRIANGLES, numelements, GL_UNSIGNED_INT, (const GLuint *) elements); + CHECKGLERROR + qglUnlockArraysEXT(); + CHECKGLERROR + } + else + { + qglDrawElements(GL_TRIANGLES, numelements, GL_UNSIGNED_INT, (const GLuint *) elements); + CHECKGLERROR + } } // restores backend state, used when done with 3D rendering diff --git a/gl_backend.h b/gl_backend.h index f26fa654..143b0f24 100644 --- a/gl_backend.h +++ b/gl_backend.h @@ -7,8 +7,6 @@ #define POLYGONELEMENTS_MAXPOINTS 258 extern int polygonelements[768]; -void GL_DrawRangeElements(int firstvert, int endvert, int indexcount, const int *index); - void GL_SetupView_ViewPort (int x, int y, int width, int height); void GL_SetupView_Orientation_Identity (void); void GL_SetupView_Orientation_FromEntity (vec3_t origin, vec3_t angles);