merged GL_DrawRangeElements into R_Mesh_Draw for a mild speed gain
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 16 Nov 2002 13:35:36 +0000 (13:35 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 16 Nov 2002 13:35:36 +0000 (13:35 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2631 d7cf8633-e32d-0410-b094-e92efae38249

gl_backend.c
gl_backend.h

index a664871..a815ba6 100644 (file)
@@ -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
index f26fa65..143b0f2 100644 (file)
@@ -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);