From 88700e817accbf611ee974db76b4a03b4d3c3935 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Tue, 29 Nov 2011 21:50:31 -0600 Subject: [PATCH 1/3] make OpenGL ClearScreen use glClear --- Source/Plugins/Plugin_VideoOGL/Src/Render.cpp | 55 ++++++++----------- 1 file changed, 24 insertions(+), 31 deletions(-) diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp index 792c14960e..c5f5212e95 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp @@ -595,7 +595,7 @@ void Renderer::RenderText(const char *text, int left, int top, u32 color) { const int nBackbufferWidth = (int)OpenGL_GetBackbufferWidth(); const int nBackbufferHeight = (int)OpenGL_GetBackbufferHeight(); - + glColor4f(((color>>16) & 0xff)/255.0f, ((color>> 8) & 0xff)/255.0f, ((color>> 0) & 0xff)/255.0f, ((color>>24) & 0xFF)/255.0f); @@ -871,39 +871,31 @@ void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaE { ResetAPIState(); - GLenum ColorMask = GL_FALSE, AlphaMask = GL_FALSE; - if (colorEnable) ColorMask = GL_TRUE; - if (alphaEnable) AlphaMask = GL_TRUE; - glColorMask(ColorMask, ColorMask, ColorMask, AlphaMask); + // color + GLboolean const + color_mask = colorEnable ? GL_TRUE : GL_FALSE, + alpha_mask = alphaEnable ? GL_TRUE : GL_FALSE; + glColorMask(color_mask, color_mask, color_mask, alpha_mask); - if (zEnable) - { - glEnable(GL_DEPTH_TEST); - glDepthMask(GL_TRUE); - glDepthFunc(GL_ALWAYS); - } - else - { - glDisable(GL_DEPTH_TEST); - glDepthMask(GL_FALSE); - glDepthFunc(GL_NEVER); - } + glClearColor( + float((color >> 16) & 0xFF) / 255.0f, + float((color >> 8) & 0xFF) / 255.0f, + float((color >> 0) & 0xFF) / 255.0f, + float((color >> 24) & 0xFF) / 255.0f); - // Update viewport for clearing the picture - TargetRectangle targetRc = ConvertEFBRectangle(rc); - glViewport(targetRc.left, targetRc.bottom, targetRc.GetWidth(), targetRc.GetHeight()); - glDepthRange(0.0, (float)(z & 0xFFFFFF) / float(0xFFFFFF)); + // depth + glDepthMask(zEnable ? GL_TRUE : GL_FALSE); - glColor4f((float)((color >> 16) & 0xFF) / 255.0f, - (float)((color >> 8) & 0xFF) / 255.0f, - (float)(color & 0xFF) / 255.0f, - (float)((color >> 24) & 0xFF) / 255.0f); - glBegin(GL_QUADS); - glVertex3f(-1.f, -1.f, 1.f); - glVertex3f(-1.f, 1.f, 1.f); - glVertex3f( 1.f, 1.f, 1.f); - glVertex3f( 1.f, -1.f, 1.f); - glEnd(); + glClearDepth(float(z & 0xFFFFFF) / float(0xFFFFFF)); + + // Update rect for clearing the picture + glEnable(GL_SCISSOR_TEST); + + TargetRectangle const targetRc = ConvertEFBRectangle(rc); + glScissor(targetRc.left, targetRc.bottom, targetRc.GetWidth(), targetRc.GetHeight()); + + // glColorMask/glDepthMask/glScissor affect glClear (glViewport does not) + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); RestoreAPIState(); @@ -1436,6 +1428,7 @@ void Renderer::ResetAPIState() glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); // make sure to disable wireframe when drawing the clear quad + // TODO: ClearScreen no longer draws a quad. Can this be killed? glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); } From 0dfca1cf2be54efbc88adcbdece61830ea92f32b Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Tue, 29 Nov 2011 22:02:18 -0600 Subject: [PATCH 2/3] remove now unnecessary glPolygonMode from ResetAPIState --- Source/Plugins/Plugin_VideoOGL/Src/Render.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp index c5f5212e95..6a373dd4e8 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp @@ -1426,10 +1426,6 @@ void Renderer::ResetAPIState() glDisable(GL_BLEND); glDepthMask(GL_FALSE); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); - - // make sure to disable wireframe when drawing the clear quad - // TODO: ClearScreen no longer draws a quad. Can this be killed? - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); } void Renderer::RestoreAPIState() From 4fcd6994c6fe3e34c986d7701e75fc8e3f6c5937 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Tue, 29 Nov 2011 22:21:43 -0600 Subject: [PATCH 3/3] fix wireframe setting toggling --- Source/Plugins/Plugin_VideoOGL/Src/Render.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp index 6a373dd4e8..03ae9bee47 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp @@ -1439,8 +1439,7 @@ void Renderer::RestoreAPIState() SetBlendMode(true); VertexShaderManager::SetViewportChanged(); - if (g_ActiveConfig.bWireFrame) - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + glPolygonMode(GL_FRONT_AND_BACK, g_ActiveConfig.bWireFrame ? GL_LINE : GL_FILL); VertexShaderCache::SetCurrentShader(0); PixelShaderCache::SetCurrentShader(0);