From 34c60eaca4abb0e828e6e4311d1d1957ddd84c09 Mon Sep 17 00:00:00 2001 From: Arisotura Date: Wed, 12 Jun 2019 13:14:11 +0200 Subject: [PATCH] fix bugs with line polygons --- src/GPU3D.cpp | 33 ++++++++++++++++++--------------- src/GPU3D_OpenGL.cpp | 5 ++++- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/GPU3D.cpp b/src/GPU3D.cpp index c94d3631..1c3fbee0 100644 --- a/src/GPU3D.cpp +++ b/src/GPU3D.cpp @@ -1144,6 +1144,23 @@ void SubmitPolygon() for (int i = clipstart; i < nverts; i++) clippedvertices[i] = TempVertexBuffer[i]; + // detect lines, for the OpenGL renderer + + int polytype = 0; + if (nverts == 3) + { + if (ClipCoordsEqual(&clippedvertices[0], &clippedvertices[1]) || + ClipCoordsEqual(&clippedvertices[0], &clippedvertices[2]) || + ClipCoordsEqual(&clippedvertices[1], &clippedvertices[2])) + { + polytype = 1; + } + } + else if (nverts == 4) + { + // TODO + } + // clipping nverts = ClipPolygon(clippedvertices, nverts, clipstart); @@ -1198,21 +1215,7 @@ void SubmitPolygon() if (!poly->Translucent) NumOpaquePolygons++; - if (ClipCoordsEqual(v0, v1) || - ClipCoordsEqual(v0, v2) || - ClipCoordsEqual(v1, v2)) - { - poly->Type = 1; - } - else if (nverts == 4) - { - if (ClipCoordsEqual(v0, v3) || - ClipCoordsEqual(v1, v3) || - ClipCoordsEqual(v2, v3)) - { - poly->Type = 1; - } - } + poly->Type = polytype; if (LastStripPolygon && clipstart > 0) { diff --git a/src/GPU3D_OpenGL.cpp b/src/GPU3D_OpenGL.cpp index 2f259120..0d866904 100644 --- a/src/GPU3D_OpenGL.cpp +++ b/src/GPU3D_OpenGL.cpp @@ -582,7 +582,10 @@ void BuildPolygons(RendererPolygon* polygons, int npolys) y = vtx->FinalPosition[1]; } - if (lastx == x && lasty == y) continue; + if (j > 0) + { + if (lastx == x && lasty == y) continue; + } *vptr++ = x | (y << 16); *vptr++ = z | (w << 16);