mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-12 07:34:50 +00:00
- render sector hacks through the quad renderer if the vertex buffer is not accessible.
This commit is contained in:
parent
f6544f3c44
commit
abba548e40
1 changed files with 40 additions and 10 deletions
|
@ -47,6 +47,7 @@
|
||||||
#include "doomstat.h"
|
#include "doomstat.h"
|
||||||
#include "d_player.h"
|
#include "d_player.h"
|
||||||
#include "portal.h"
|
#include "portal.h"
|
||||||
|
#include "templates.h"
|
||||||
|
|
||||||
#include "gl/system/gl_interface.h"
|
#include "gl/system/gl_interface.h"
|
||||||
#include "gl/system/gl_cvars.h"
|
#include "gl/system/gl_cvars.h"
|
||||||
|
@ -176,18 +177,46 @@ void GLFlat::SetupSubsectorLights(int pass, subsector_t * sub, int *dli)
|
||||||
|
|
||||||
void GLFlat::DrawSubsector(subsector_t * sub)
|
void GLFlat::DrawSubsector(subsector_t * sub)
|
||||||
{
|
{
|
||||||
FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
|
if (gl.buffermethod != BM_DEFERRED)
|
||||||
for (unsigned int k = 0; k < sub->numlines; k++)
|
|
||||||
{
|
{
|
||||||
vertex_t *vt = sub->firstline[k].v1;
|
FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
|
||||||
ptr->x = vt->fX();
|
for (unsigned int k = 0; k < sub->numlines; k++)
|
||||||
ptr->z = plane.plane.ZatPoint(vt) + dz;
|
{
|
||||||
ptr->y = vt->fY();
|
vertex_t *vt = sub->firstline[k].v1;
|
||||||
ptr->u = vt->fX() / 64.f;
|
ptr->x = vt->fX();
|
||||||
ptr->v = -vt->fY() / 64.f;
|
ptr->z = plane.plane.ZatPoint(vt) + dz;
|
||||||
ptr++;
|
ptr->y = vt->fY();
|
||||||
|
ptr->u = vt->fX() / 64.f;
|
||||||
|
ptr->v = -vt->fY() / 64.f;
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN);
|
|
||||||
|
|
||||||
flatvertices += sub->numlines;
|
flatvertices += sub->numlines;
|
||||||
flatprimitives++;
|
flatprimitives++;
|
||||||
|
@ -263,6 +292,7 @@ void GLFlat::DrawSubsectors(int pass, bool processlights, bool istrans)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Draw the subsectors belonging to this sector
|
// Draw the subsectors belonging to this sector
|
||||||
|
// (can this case even happen?)
|
||||||
for (int i=0; i<sector->subsectorcount; i++)
|
for (int i=0; i<sector->subsectorcount; i++)
|
||||||
{
|
{
|
||||||
subsector_t * sub = sector->subsectors[i];
|
subsector_t * sub = sector->subsectors[i];
|
||||||
|
|
Loading…
Reference in a new issue