From 2125f8b9d1a12b14d9ff5159b14ffad34b68bab5 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 19 May 2018 14:42:25 +0200 Subject: [PATCH] - use triangles instead of triangle fans to render flats. --- src/gl/scene/gl_flats.cpp | 7 +++---- src/hwrenderer/data/flatvertices.cpp | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 41e4e0e691..ac6415b439 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -181,24 +181,23 @@ void FDrawInfo::DrawSubsectors(GLFlat *flat, int pass, bool processlights, bool for (int i=0; isector->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; isector->subsectorcount; i++) { subsector_t * sub = flat->sector->subsectors[i]; diff --git a/src/hwrenderer/data/flatvertices.cpp b/src/hwrenderer/data/flatvertices.cpp index a5149a60e2..cfa929d31e 100644 --- a/src/hwrenderer/data/flatvertices.cpp +++ b/src/hwrenderer/data/flatvertices.cpp @@ -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; knumlines; 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; knumlines; 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; }