From 70c69a46d3d1f3e3ce0d03e0f7e38f6f6d086bbe Mon Sep 17 00:00:00 2001 From: rogerman Date: Sat, 23 Sep 2017 21:32:34 -0700 Subject: [PATCH] OpenGL Renderer: Fix a bug where the behavior of translucent polygons can become undefined if the frame contains nothing but translucent polygons. Fixes a graphical glitch in Grey's intro scene in Mega Man ZX Advent. (Regression from commit 1742114.) --- desmume/src/OGLRender.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/desmume/src/OGLRender.cpp b/desmume/src/OGLRender.cpp index b82bfbf5b..f224e4b6b 100755 --- a/desmume/src/OGLRender.cpp +++ b/desmume/src/OGLRender.cpp @@ -3693,10 +3693,10 @@ Render3DError OpenGLRenderer_1_2::RenderGeometry(const GFX3D_State &renderState, const POLY &firstPoly = polyList->list[indexList->list[0]]; u32 lastPolyAttr = firstPoly.polyAttr; - this->SetupPolygon(firstPoly, false, true); if (polyList->opaqueCount > 0) { + this->SetupPolygon(firstPoly, false, true); this->DrawPolygonsForIndexRange(polyList, indexList, 0, polyList->opaqueCount - 1, indexOffset, lastPolyAttr); } @@ -3704,6 +3704,11 @@ Render3DError OpenGLRenderer_1_2::RenderGeometry(const GFX3D_State &renderState, { if (this->_needsZeroDstAlphaPass) { + if (polyList->opaqueCount == 0) + { + this->SetupPolygon(firstPoly, true, false); + } + this->ZeroDstAlphaPass(polyList, indexList, renderState.enableAlphaBlending, indexOffset, lastPolyAttr); if (polyList->opaqueCount > 0) @@ -3712,7 +3717,11 @@ Render3DError OpenGLRenderer_1_2::RenderGeometry(const GFX3D_State &renderState, lastPolyAttr = lastOpaquePoly.polyAttr; this->SetupPolygon(lastOpaquePoly, false, true); } - + } + + if (polyList->opaqueCount == 0) + { + this->SetupPolygon(firstPoly, true, true); } this->DrawPolygonsForIndexRange(polyList, indexList, polyList->opaqueCount, polyList->count - 1, indexOffset, lastPolyAttr);