]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
fixed VBO batching bug in rtlight rendering
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 29 Jan 2008 01:50:40 +0000 (01:50 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 29 Jan 2008 01:50:40 +0000 (01:50 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8035 d7cf8633-e32d-0410-b094-e92efae38249

gl_rsurf.c

index 68ec5e3dab2cf81860fd72c0c2fe3dc938654c7d..76f4782cbc0fa1c811d068ef70f8b7996504a3a6 100644 (file)
@@ -1103,8 +1103,6 @@ void R_Q1BSP_DrawLight(entity_render_t *ent, int numsurfaces, const int *surface
                                }
                                else
                                {
-                                       // use the bufferobject if all triangles are accepted
-                                       usebufferobject = true;
                                        batchnumtriangles = 0;
                                        batchfirsttriangle = surface->num_firsttriangle;
                                        for (l = k;l < kend;l++)
@@ -1133,7 +1131,8 @@ void R_Q1BSP_DrawLight(entity_render_t *ent, int numsurfaces, const int *surface
                                                        {
                                                                r_refdef.stats.lights_lighttriangles += batchnumtriangles;
                                                                Mod_VertexRangeFromElements(batchnumtriangles*3, batchelements, &batchfirstvertex, &batchlastvertex);
-                                                               if (usebufferobject && batchnumtriangles >= 100)
+                                                               // use the element buffer if all triangles are consecutive
+                                                               if (m == batchfirsttriangle + batchnumtriangles)
                                                                        R_Shadow_RenderLighting(batchfirstvertex, batchlastvertex + 1 - batchfirstvertex, batchnumtriangles, batchelements, ent->model->surfmesh.ebo, sizeof(int[3]) * batchfirsttriangle);
                                                                else
                                                                        R_Shadow_RenderLighting(batchfirstvertex, batchlastvertex + 1 - batchfirstvertex, batchnumtriangles, batchelements, 0, 0);
@@ -1151,7 +1150,8 @@ void R_Q1BSP_DrawLight(entity_render_t *ent, int numsurfaces, const int *surface
                                        {
                                                r_refdef.stats.lights_lighttriangles += batchnumtriangles;
                                                Mod_VertexRangeFromElements(batchnumtriangles*3, batchelements, &batchfirstvertex, &batchlastvertex);
-                                               if (usebufferobject && batchnumtriangles >= 100)
+                                               // use the element buffer if all triangles are consecutive
+                                               if (m == batchfirsttriangle + batchnumtriangles)
                                                        R_Shadow_RenderLighting(batchfirstvertex, batchlastvertex + 1 - batchfirstvertex, batchnumtriangles, batchelements, ent->model->surfmesh.ebo, sizeof(int[3]) * batchfirsttriangle);
                                                else
                                                        R_Shadow_RenderLighting(batchfirstvertex, batchlastvertex + 1 - batchfirstvertex, batchnumtriangles, batchelements, 0, 0);