From 22a0864337d4a6fdda901003ea9456c3f445dc5e Mon Sep 17 00:00:00 2001 From: Rodolfo Osvaldo Bogado Date: Sun, 1 Nov 2009 01:15:06 +0000 Subject: [PATCH] Discover that various games that have black screen problem in nvidia is just caused by having negative zfar or znear values, in ati is not a problem, the drivers can handle it. This is a test, clamp the values to see if this fix the problem, please test a lot don't know if this breaks something else git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4491 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Plugins/Plugin_VideoDX9/Src/Render.cpp | 4 +++- Source/Plugins/Plugin_VideoOGL/Src/Render.cpp | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp b/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp index 8dcd62831e..c565ee8d43 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp @@ -610,8 +610,10 @@ void UpdateViewport() // This seems to happen a lot - the above calc is probably wrong. if (vp.MinZ < 0.0f) vp.MinZ = 0.0f; + if (vp.MinZ > 1.0f) vp.MinZ = 1.0f; if (vp.MaxZ > 1.0f) vp.MaxZ = 1.0f; - + if (vp.MaxZ < 0.0f) vp.MaxZ = 0.0f; + D3D::dev->SetViewport(&vp); } diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp index 43bb17a15d..0036b494b5 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp @@ -1347,6 +1347,11 @@ void UpdateViewport() double GLNear = (xfregs.rawViewport[5] - xfregs.rawViewport[2]) / 16777216.0f; double GLFar = xfregs.rawViewport[5] / 16777216.0f; + if (GLNear < 0.0f) GLNear = 0.0f; + if (GLNear > 1.0f) GLNear = 1.0f; + if (GLFar > 1.0f) GLFar = 1.0f; + if (GLFar < 0.0f) GLFar = 0.0f; + // Update the view port glViewport(GLx, GLy, GLWidth, GLHeight); glDepthRange(GLNear, GLFar);