From d946e4e23830d3070319f17e570559dad667333b Mon Sep 17 00:00:00 2001 From: Tony Wasserka Date: Sat, 23 Nov 2013 12:33:03 +0100 Subject: [PATCH] OpenGL: Implement color and z pokes. --- Source/Core/VideoBackends/OGL/Render.cpp | 44 +++++++++++++++++++++--- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/Source/Core/VideoBackends/OGL/Render.cpp b/Source/Core/VideoBackends/OGL/Render.cpp index cd682137b6..bbe2169182 100644 --- a/Source/Core/VideoBackends/OGL/Render.cpp +++ b/Source/Core/VideoBackends/OGL/Render.cpp @@ -1064,12 +1064,46 @@ u32 Renderer::AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data) } case POKE_COLOR: - case POKE_Z: - // TODO: Implement. One way is to draw a tiny pixel-sized rectangle at - // the exact location. Note: EFB pokes are susceptible to Z-buffering - // and perhaps blending. - //WARN_LOG(VIDEOINTERFACE, "This is probably some kind of software rendering"); + { + ResetAPIState(); + + glClearColor(float((poke_data >> 16) & 0xFF) / 255.0f, + float((poke_data >> 8) & 0xFF) / 255.0f, + float((poke_data >> 0) & 0xFF) / 255.0f, + float((poke_data >> 24) & 0xFF) / 255.0f); + + glEnable(GL_SCISSOR_TEST); + glScissor(targetPixelRc.left, targetPixelRc.bottom, targetPixelRc.GetWidth(), targetPixelRc.GetHeight()); + + glClear(GL_COLOR_BUFFER_BIT); + + RestoreAPIState(); + + // TODO: Could just update the EFB cache with the new value + ClearEFBCache(); + break; + } + + case POKE_Z: + { + ResetAPIState(); + + glDepthMask(GL_TRUE); + glClearDepthf(float(poke_data & 0xFFFFFF) / float(0xFFFFFF)); + + glEnable(GL_SCISSOR_TEST); + glScissor(targetPixelRc.left, targetPixelRc.bottom, targetPixelRc.GetWidth(), targetPixelRc.GetHeight()); + + glClear(GL_DEPTH_BUFFER_BIT); + + RestoreAPIState(); + + // TODO: Could just update the EFB cache with the new value + ClearEFBCache(); + + break; + } default: break;