From 4031ee211acb72ef27248232f6bfc0bf1f0e6a7c Mon Sep 17 00:00:00 2001 From: rogerman Date: Thu, 26 Mar 2015 11:01:27 +0000 Subject: [PATCH] =?UTF-8?q?OGLRender:=20-=20Revert=20depth=20buffer=20calc?= =?UTF-8?q?ulation=20change=20in=20r5133=20for=20the=20z-buffer=20mode.=20?= =?UTF-8?q?Keep=20the=20w-buffer=20mode=20change,=20since=20that=E2=80=99s?= =?UTF-8?q?=20the=20one=20that=20works.=20Fixes=20the=20buttons=20in=20Bla?= =?UTF-8?q?zer=20Drive.=20(Regression=20from=20r5133.)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- desmume/src/OGLRender.cpp | 3 ++- desmume/src/OGLRender_3_2.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/desmume/src/OGLRender.cpp b/desmume/src/OGLRender.cpp index 5944ec282..b5ee2c2a4 100644 --- a/desmume/src/OGLRender.cpp +++ b/desmume/src/OGLRender.cpp @@ -331,7 +331,8 @@ static const char *fragmentShader_100 = {"\ discard; \n\ } \n\ \n\ - gl_FragDepth = (oglWBuffer) ? vtxPosition.w/4096.0 : vtxPosition.z/4096.0; \n\ + float vertW = (vtxPosition.w == 0.0f) ? 0.00000001f : vtxPosition.w; \n\ + gl_FragDepth = (oglWBuffer) ? vtxPosition.w/4096.0 : (vtxPosition.z / vertW) * 0.5 + 0.5; \n\ gl_FragColor = fragColor; \n\ } \n\ "}; diff --git a/desmume/src/OGLRender_3_2.cpp b/desmume/src/OGLRender_3_2.cpp index 543ab9e2b..902ba4c43 100644 --- a/desmume/src/OGLRender_3_2.cpp +++ b/desmume/src/OGLRender_3_2.cpp @@ -181,7 +181,8 @@ static const char *fragmentShader_150 = {"\ discard; \n\ } \n\ \n\ - gl_FragDepth = (oglWBuffer) ? vtxPosition.w/4096.0 : vtxPosition.z/4096.0; \n\ + float vertW = (vtxPosition.w == 0.0f) ? 0.00000001f : vtxPosition.w; \n\ + gl_FragDepth = (oglWBuffer) ? vtxPosition.w/4096.0 : (vtxPosition.z / vertW) * 0.5 + 0.5; \n\ outFragColor = fragColor; \n\ } \n\ "};