- put all the common part of buffer based drawing into a separate method of the vertex buffer.

This commit is contained in:
Christoph Oelckers 2014-05-20 22:37:38 +02:00
parent 23fbd69963
commit 09ba62fbef
7 changed files with 16 additions and 24 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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