- split off the vertex creation from RenderWall.

This commit is contained in:
Christoph Oelckers 2016-08-25 22:54:08 +02:00
parent 4ab8ca63ce
commit 8cf53f04e8
2 changed files with 38 additions and 20 deletions

View File

@ -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);

View File

@ -167,27 +167,19 @@ void GLWall::SetupLights()
dynlightindex = GLRenderer->mLights->UploadLights(lightdata);
}
//==========================================================================
//
// General purpose wall rendering function
// everything goes through here
// build the vertices for this wall
//
//==========================================================================
void GLWall::RenderWall(int textured, unsigned int *store)
void GLWall::MakeVertices(bool nosplit)
{
bool split = (gl_seamless && !(textured&RWF_NOSPLIT) && seg->sidedef != NULL && !(seg->sidedef->Flags & WALLF_POLYOBJ) && !(flags & GLWF_NOSPLIT));
if (!(textured & RWF_NORENDER))
if (vertcount == 0)
{
gl_RenderState.Apply();
gl_RenderState.ApplyLightIndex(dynlightindex);
}
bool split = (gl_seamless && !nosplit && seg->sidedef != NULL && !(seg->sidedef->Flags & WALLF_POLYOBJ) && !(flags & GLWF_NOSPLIT));
// 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++;
@ -201,7 +193,32 @@ void GLWall::RenderWall(int textured, unsigned int *store)
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);
vertcount = GLRenderer->mVBO->GetCount(ptr, &vertindex);
}
}
//==========================================================================
//
// General purpose wall rendering function
// everything goes through here
//
//==========================================================================
void GLWall::RenderWall(int textured, unsigned int *store)
{
if (!(textured & RWF_NORENDER))
{
gl_RenderState.Apply();
gl_RenderState.ApplyLightIndex(dynlightindex);
}
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);