From bce335fc4fa0303f899da8e8a697fca29bb4f1dc Mon Sep 17 00:00:00 2001 From: Sergey Lipskiy Date: Fri, 14 Oct 2016 18:28:05 +0700 Subject: [PATCH] Fix Z for rects. Fixed CyberTiger: flicker in game (regression) #1170 The game sometimes set invalid viewport with gSP.viewport.nearz > 1, so the rect is clipped. --- src/OpenGL.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenGL.cpp b/src/OpenGL.cpp index f84f6d14..6370ae6e 100644 --- a/src/OpenGL.cpp +++ b/src/OpenGL.cpp @@ -1515,7 +1515,7 @@ void OGLRender::drawRect(int _ulx, int _uly, int _lrx, int _lry, float *_pColor) const float scaleX = pCurrentBuffer != nullptr ? 1.0f / pCurrentBuffer->m_width : VI.rwidth; const float scaleY = pCurrentBuffer != nullptr ? 1.0f / pCurrentBuffer->m_height : VI.rheight; - const float Z = (gDP.otherMode.depthSource == G_ZS_PRIM) ? gDP.primDepth.z : gSP.viewport.nearz; + const float Z = (gDP.otherMode.depthSource == G_ZS_PRIM) ? gDP.primDepth.z : 0.0f; const float W = 1.0f; m_rect[0].x = (float)_ulx * (2.0f * scaleX) - 1.0; m_rect[0].y = (float)_uly * (-2.0f * scaleY) + 1.0; @@ -1775,7 +1775,7 @@ void OGLRender::drawTexturedRect(const TexturedRectParams & _params) const float scaleX = pCurrentBuffer != nullptr ? 1.0f / pCurrentBuffer->m_width : VI.rwidth; const float scaleY = pCurrentBuffer != nullptr ? 1.0f / pCurrentBuffer->m_height : VI.rheight; - const float Z = (gDP.otherMode.depthSource == G_ZS_PRIM) ? gDP.primDepth.z : gSP.viewport.nearz; + const float Z = (gDP.otherMode.depthSource == G_ZS_PRIM) ? gDP.primDepth.z : 0.0f; const float W = 1.0f; f32 uly, lry; if (bUseTexrectDrawer) {