- render sector hacks through the quad renderer if the vertex buffer is not accessible.

This commit is contained in:
Christoph Oelckers 2016-08-26 02:03:24 +02:00
parent f6544f3c44
commit abba548e40

View file

@ -47,6 +47,7 @@
#include "doomstat.h"
#include "d_player.h"
#include "portal.h"
#include "templates.h"
#include "gl/system/gl_interface.h"
#include "gl/system/gl_cvars.h"
@ -175,6 +176,8 @@ void GLFlat::SetupSubsectorLights(int pass, subsector_t * sub, int *dli)
//==========================================================================
void GLFlat::DrawSubsector(subsector_t * sub)
{
if (gl.buffermethod != BM_DEFERRED)
{
FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
for (unsigned int k = 0; k < sub->numlines; k++)
@ -188,6 +191,32 @@ void GLFlat::DrawSubsector(subsector_t * sub)
ptr++;
}
GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN);
}
else
{
// if we cannot access the buffer, use the quad drawer as fallback by splitting the subsector into quads.
// Trying to get this into the vertex buffer in the processing pass is too costly and this is only used for render hacks.
FQuadDrawer qd;
unsigned int vi[4];
vi[0] = 0;
for (unsigned int i = 1; i < sub->numlines; i += 2)
{
if (i < sub->numlines - 3)
{
for (unsigned int j = 1; j < 4; j++)
{
vi[j] = MIN(i + j, sub->numlines - 1);
}
for (unsigned int x = 0; x < 4; x++)
{
vertex_t *vt = sub->firstline[vi[x]].v1;
qd.Set(x, vt->fX(), plane.plane.ZatPoint(vt) + dz, vt->fY(), vt->fX() / 64.f, -vt->fY() / 64.f);
}
qd.Render(GL_TRIANGLE_FAN);
}
}
}
flatvertices += sub->numlines;
flatprimitives++;
@ -263,6 +292,7 @@ void GLFlat::DrawSubsectors(int pass, bool processlights, bool istrans)
else
{
// Draw the subsectors belonging to this sector
// (can this case even happen?)
for (int i=0; i<sector->subsectorcount; i++)
{
subsector_t * sub = sector->subsectors[i];