- use a software buffer for immediate mode rendering. This allows using the regular buffer code to collect data for both render modes and allows removal of a lot of duplicated code.

This commit is contained in:
Christoph Oelckers 2014-06-15 01:14:41 +02:00
commit 3644073bbd
12 changed files with 232 additions and 636 deletions

View file

@ -991,28 +991,17 @@ void FDrawInfo::SetupFloodStencil(wallseg * ws)
glDepthMask(true);
gl_RenderState.Apply();
if (!gl_usevbo)
{
glBegin(GL_TRIANGLE_FAN);
glVertex3f(ws->x1, ws->z1, ws->y1);
glVertex3f(ws->x1, ws->z2, ws->y1);
glVertex3f(ws->x2, ws->z2, ws->y2);
glVertex3f(ws->x2, ws->z1, ws->y2);
glEnd();
}
else
{
FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
ptr->Set(ws->x1, ws->z1, ws->y1, 0, 0);
ptr++;
ptr->Set(ws->x1, ws->z2, ws->y1, 0, 0);
ptr++;
ptr->Set(ws->x2, ws->z2, ws->y2, 0, 0);
ptr++;
ptr->Set(ws->x2, ws->z1, ws->y2, 0, 0);
ptr++;
GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN);
}
FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
ptr->Set(ws->x1, ws->z1, ws->y1, 0, 0);
ptr++;
ptr->Set(ws->x1, ws->z2, ws->y1, 0, 0);
ptr++;
ptr->Set(ws->x2, ws->z2, ws->y2, 0, 0);
ptr++;
ptr->Set(ws->x2, ws->z1, ws->y2, 0, 0);
ptr++;
GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN);
glStencilFunc(GL_EQUAL,recursion+1,~0); // draw sky into stencil
glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP); // this stage doesn't modify the stencil
@ -1033,28 +1022,16 @@ void FDrawInfo::ClearFloodStencil(wallseg * ws)
gl_RenderState.ResetColor();
gl_RenderState.Apply();
if (!gl_usevbo)
{
glBegin(GL_TRIANGLE_FAN);
glVertex3f(ws->x1, ws->z1, ws->y1);
glVertex3f(ws->x1, ws->z2, ws->y1);
glVertex3f(ws->x2, ws->z2, ws->y2);
glVertex3f(ws->x2, ws->z1, ws->y2);
glEnd();
}
else
{
FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
ptr->Set(ws->x1, ws->z1, ws->y1, 0, 0);
ptr++;
ptr->Set(ws->x1, ws->z2, ws->y1, 0, 0);
ptr++;
ptr->Set(ws->x2, ws->z2, ws->y2, 0, 0);
ptr++;
ptr->Set(ws->x2, ws->z1, ws->y2, 0, 0);
ptr++;
GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN);
}
FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
ptr->Set(ws->x1, ws->z1, ws->y1, 0, 0);
ptr++;
ptr->Set(ws->x1, ws->z2, ws->y1, 0, 0);
ptr++;
ptr->Set(ws->x2, ws->z2, ws->y2, 0, 0);
ptr++;
ptr->Set(ws->x2, ws->z1, ws->y2, 0, 0);
ptr++;
GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN);
// restore old stencil op.
glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP);
@ -1126,36 +1103,16 @@ void FDrawInfo::DrawFloodedPlane(wallseg * ws, float planez, sector_t * sec, boo
float px4 = fviewx + prj_fac1 * (ws->x2-fviewx);
float py4 = fviewy + prj_fac1 * (ws->y2-fviewy);
if (!gl_usevbo)
{
glBegin(GL_TRIANGLE_FAN);
glTexCoord2f(px1 / 64, -py1 / 64);
glVertex3f(px1, planez, py1);
glTexCoord2f(px2 / 64, -py2 / 64);
glVertex3f(px2, planez, py2);
glTexCoord2f(px3 / 64, -py3 / 64);
glVertex3f(px3, planez, py3);
glTexCoord2f(px4 / 64, -py4 / 64);
glVertex3f(px4, planez, py4);
glEnd();
}
else
{
FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
ptr->Set(px1, planez, py1, px1 / 64, -py1 / 64);
ptr++;
ptr->Set(px2, planez, py2, px2 / 64, -py2 / 64);
ptr++;
ptr->Set(px3, planez, py3, px3 / 64, -py3 / 64);
ptr++;
ptr->Set(px4, planez, py4, px4 / 64, -py4 / 64);
ptr++;
GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN);
}
FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
ptr->Set(px1, planez, py1, px1 / 64, -py1 / 64);
ptr++;
ptr->Set(px2, planez, py2, px2 / 64, -py2 / 64);
ptr++;
ptr->Set(px3, planez, py3, px3 / 64, -py3 / 64);
ptr++;
ptr->Set(px4, planez, py4, px4 / 64, -py4 / 64);
ptr++;
GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN);
if (pushed)
{