From 09ba62fbef5a858ea5ed35f5926baeca74988441 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 20 May 2014 22:37:38 +0200 Subject: [PATCH] - put all the common part of buffer based drawing into a separate method of the vertex buffer. --- src/gl/data/gl_vertexbuffer.h | 8 ++++++++ src/gl/scene/gl_decal.cpp | 4 +--- src/gl/scene/gl_drawinfo.cpp | 12 +++--------- src/gl/scene/gl_flats.cpp | 4 +--- src/gl/scene/gl_scene.cpp | 4 +--- src/gl/scene/gl_walls_draw.cpp | 4 +--- src/gl/scene/gl_weapon.cpp | 4 +--- 7 files changed, 16 insertions(+), 24 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index 013e6d73a..80db0d64e 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -70,6 +70,14 @@ public: mCurIndex = newofs; return diff; } +#ifdef __GL_PCH_H // we need the system includes for this but we cannot include them ourselves without creating #define clashes. The affected files wouldn't try to draw anyway. + void RenderCurrent(FFlatVertex *newptr, unsigned int primtype) + { + unsigned int offset; + unsigned int count = GetCount(newptr, &offset); + glDrawArrays(primtype, offset, count); + } +#endif void Reset() { mCurIndex = mIndex; diff --git a/src/gl/scene/gl_decal.cpp b/src/gl/scene/gl_decal.cpp index 61c92d3fd..8f2e7977a 100644 --- a/src/gl/scene/gl_decal.cpp +++ b/src/gl/scene/gl_decal.cpp @@ -355,9 +355,7 @@ void GLWall::DrawDecal(DBaseDecal *decal) ptr->Set(dv[i].x, dv[i].z, dv[i].y, dv[i].u, dv[i].v); ptr++; } - unsigned int offset; - unsigned int count = GLRenderer->mVBO->GetCount(ptr, &offset); - glDrawArrays(GL_TRIANGLE_FAN, offset, count); + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); } rendered_decals++; gl_RenderState.SetTextureMode(TM_MODULATE); diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index e0e6cf8df..fc44c7896 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -1011,9 +1011,7 @@ void FDrawInfo::SetupFloodStencil(wallseg * ws) ptr++; ptr->Set(ws->x2, ws->z1, ws->y2, 0, 0); ptr++; - unsigned int offset; - unsigned int count = GLRenderer->mVBO->GetCount(ptr, &offset); - glDrawArrays(GL_TRIANGLE_FAN, offset, count); + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); } glStencilFunc(GL_EQUAL,recursion+1,~0); // draw sky into stencil @@ -1055,9 +1053,7 @@ void FDrawInfo::ClearFloodStencil(wallseg * ws) ptr++; ptr->Set(ws->x2, ws->z1, ws->y2, 0, 0); ptr++; - unsigned int offset; - unsigned int count = GLRenderer->mVBO->GetCount(ptr, &offset); - glDrawArrays(GL_TRIANGLE_FAN, offset, count); + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); } // restore old stencil op. @@ -1158,9 +1154,7 @@ void FDrawInfo::DrawFloodedPlane(wallseg * ws, float planez, sector_t * sec, boo ptr++; ptr->Set(px4, planez, py4, px4 / 64, -py4 / 64); ptr++; - unsigned int offset; - unsigned int count = GLRenderer->mVBO->GetCount(ptr, &offset); - glDrawArrays(GL_TRIANGLE_FAN, offset, count); + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); } if (pushed) diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 4d3f4c3f6..71bb2197b 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -295,9 +295,7 @@ void GLFlat::DrawSubsector(subsector_t * sub) ptr++; } } - unsigned int offset; - unsigned int count = GLRenderer->mVBO->GetCount(ptr, &offset); - glDrawArrays(GL_TRIANGLE_FAN, offset, count); + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); } flatvertices += sub->numlines; diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 809a516e7..15f9444d4 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -637,9 +637,7 @@ static void FillScreen() ptr++; ptr->Set((float)SCREENWIDTH, (float)SCREENHEIGHT, 0, 0, 0); ptr++; - unsigned int offset; - unsigned int count = GLRenderer->mVBO->GetCount(ptr, &offset); - glDrawArrays(GL_TRIANGLE_FAN, offset, count); + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); } } diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index ca32e98a6..98ae66800 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -302,9 +302,7 @@ void GLWall::RenderWall(int textured, float * color2, ADynamicLight * light) ptr->Set(glseg.x2, zbottom[1], glseg.y2, tcs[3].u, tcs[3].v); ptr++; if (split && !(flags & GLWF_NOSPLITLOWER)) SplitLowerEdge(tcs, ptr); - unsigned int offset; - unsigned int count = GLRenderer->mVBO->GetCount(ptr, &offset); - glDrawArrays(GL_TRIANGLE_FAN, offset, count); + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); vertexcount += 4; } diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 5fca4bb49..a91fa252f 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -174,9 +174,7 @@ void FGLRenderer::DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed ptr++; ptr->Set(x2, y2, 0, fU2, fV2); ptr++; - unsigned int offset; - unsigned int count = GLRenderer->mVBO->GetCount(ptr, &offset); - glDrawArrays(GL_TRIANGLE_STRIP, offset, count); + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); } if (tex->GetTransparent() || OverrideShader != 0) {