From 8cf53f04e87151fbf317a1ad5f71d41dc0eb7abd Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 25 Aug 2016 22:54:08 +0200 Subject: [PATCH] - split off the vertex creation from RenderWall. --- src/gl/scene/gl_wall.h | 1 + src/gl/scene/gl_walls_draw.cpp | 57 ++++++++++++++++++++++------------ 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index 59f21dc37..f8d8ef1bb 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -195,6 +195,7 @@ private: void SetupLights(); bool PrepareLight(ADynamicLight * light, int pass); + void MakeVertices(bool nosplit); void RenderWall(int textured, unsigned int *store = NULL); void RenderTextured(int rflags); diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 5c0455fdb..9f0d168a4 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -167,6 +167,36 @@ void GLWall::SetupLights() dynlightindex = GLRenderer->mLights->UploadLights(lightdata); } +//========================================================================== +// +// build the vertices for this wall +// +//========================================================================== + +void GLWall::MakeVertices(bool nosplit) +{ + if (vertcount == 0) + { + bool split = (gl_seamless && !nosplit && seg->sidedef != NULL && !(seg->sidedef->Flags & WALLF_POLYOBJ) && !(flags & GLWF_NOSPLIT)); + + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + + ptr->Set(glseg.x1, zbottom[0], glseg.y1, tcs[LOLFT].u, tcs[LOLFT].v); + ptr++; + if (split && glseg.fracleft == 0) SplitLeftEdge(ptr); + ptr->Set(glseg.x1, ztop[0], glseg.y1, tcs[UPLFT].u, tcs[UPLFT].v); + ptr++; + if (split && !(flags & GLWF_NOSPLITUPPER)) SplitUpperEdge(ptr); + ptr->Set(glseg.x2, ztop[1], glseg.y2, tcs[UPRGT].u, tcs[UPRGT].v); + ptr++; + if (split && glseg.fracright == 1) SplitRightEdge(ptr); + ptr->Set(glseg.x2, zbottom[1], glseg.y2, tcs[LORGT].u, tcs[LORGT].v); + ptr++; + if (split && !(flags & GLWF_NOSPLITLOWER)) SplitLowerEdge(ptr); + vertcount = GLRenderer->mVBO->GetCount(ptr, &vertindex); + } +} + //========================================================================== // @@ -177,31 +207,18 @@ void GLWall::SetupLights() void GLWall::RenderWall(int textured, unsigned int *store) { - bool split = (gl_seamless && !(textured&RWF_NOSPLIT) && seg->sidedef != NULL && !(seg->sidedef->Flags & WALLF_POLYOBJ) && !(flags & GLWF_NOSPLIT)); - if (!(textured & RWF_NORENDER)) { gl_RenderState.Apply(); gl_RenderState.ApplyLightIndex(dynlightindex); } - - // the rest of the code is identical for textured rendering and lights - FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); - unsigned int count, offset; - - ptr->Set(glseg.x1, zbottom[0], glseg.y1, tcs[LOLFT].u, tcs[LOLFT].v); - ptr++; - if (split && glseg.fracleft == 0) SplitLeftEdge(ptr); - ptr->Set(glseg.x1, ztop[0], glseg.y1, tcs[UPLFT].u, tcs[UPLFT].v); - ptr++; - if (split && !(flags & GLWF_NOSPLITUPPER)) SplitUpperEdge(ptr); - ptr->Set(glseg.x2, ztop[1], glseg.y2, tcs[UPRGT].u, tcs[UPRGT].v); - ptr++; - if (split && glseg.fracright == 1) SplitRightEdge(ptr); - ptr->Set(glseg.x2, zbottom[1], glseg.y2, tcs[LORGT].u, tcs[LORGT].v); - ptr++; - if (split && !(flags & GLWF_NOSPLITLOWER)) SplitLowerEdge(ptr); - count = GLRenderer->mVBO->GetCount(ptr, &offset); + + if (gl.buffermethod != BM_DEFERRED) + { + MakeVertices(!(textured&RWF_NOSPLIT)); + } + + unsigned int count = vertcount, offset = vertindex; if (!(textured & RWF_NORENDER)) { GLRenderer->mVBO->RenderArray(GL_TRIANGLE_FAN, offset, count);