- use triangles instead of triangle fans to render flats.

This commit is contained in:
Christoph Oelckers 2018-05-19 14:42:25 +02:00
parent fd3681dae2
commit 2125f8b9d1
2 changed files with 15 additions and 7 deletions

View file

@ -181,24 +181,23 @@ void FDrawInfo::DrawSubsectors(GLFlat *flat, int pass, bool processlights, bool
for (int i=0; i<flat->sector->subsectorcount; i++)
{
subsector_t * sub = flat->sector->subsectors[i];
if (sub->numlines <= 2) continue;
if (gl_drawinfo->ss_renderflags[sub->Index()]& flat->renderflags || istrans)
{
if (processlights) SetupSubsectorLights(flat, GLPASS_ALL, sub, &dli);
drawcalls.Clock();
//glDrawArrays(GL_TRIANGLE_FAN, index, sub->numlines);
glDrawElements(GL_TRIANGLE_FAN, sub->numlines, GL_UNSIGNED_INT, GLRenderer->mVBO->GetIndexPointer() + index);
glDrawElements(GL_TRIANGLES, (sub->numlines - 2) * 3, GL_UNSIGNED_INT, GLRenderer->mVBO->GetIndexPointer() + index);
drawcalls.Unclock();
flatvertices += sub->numlines;
flatprimitives++;
}
index += sub->numlines;
index += (sub->numlines - 2) * 3;
}
}
else
{
// Draw the subsectors belonging to this sector
// (can this case even happen?)
for (int i=0; i<flat->sector->subsectorcount; i++)
{
subsector_t * sub = flat->sector->subsectors[i];

View file

@ -234,11 +234,20 @@ void FFlatVertexGenerator::CreateFlatVertices()
int FFlatVertexGenerator::CreateIndexedSubsectorVertices(subsector_t *sub, const secplane_t &plane, int floor, int vi, FFlatVertexGenerator::FIndexGenerationInfo &gen)
{
int idx = ibo_data.Reserve(sub->numlines);
for (unsigned int k = 0; k<sub->numlines; k++)
if (sub->numlines < 3) return -1;
int idx = ibo_data.Reserve((sub->numlines - 2) * 3);
int idxc = idx;
int firstndx = gen.GetIndex(sub->firstline[0].v1);
int secondndx = gen.GetIndex(sub->firstline[1].v1);
for (unsigned int k = 2; k<sub->numlines; k++)
{
auto ndx = gen.GetIndex(sub->firstline[k].v1);
ibo_data[idx + k] = vi + ndx;
ibo_data[idx++] = vi + firstndx;
ibo_data[idx++] = vi + secondndx;
ibo_data[idx++] = vi + ndx;
secondndx = ndx;
}
return idx;
}