make OpenGL ClearScreen use glClear

This commit is contained in:
Jordan Woyak 2011-11-29 21:50:31 -06:00
parent cda94290f5
commit 88700e817a
1 changed files with 24 additions and 31 deletions

View File

@ -595,7 +595,7 @@ void Renderer::RenderText(const char *text, int left, int top, u32 color)
{ {
const int nBackbufferWidth = (int)OpenGL_GetBackbufferWidth(); const int nBackbufferWidth = (int)OpenGL_GetBackbufferWidth();
const int nBackbufferHeight = (int)OpenGL_GetBackbufferHeight(); const int nBackbufferHeight = (int)OpenGL_GetBackbufferHeight();
glColor4f(((color>>16) & 0xff)/255.0f, ((color>> 8) & 0xff)/255.0f, glColor4f(((color>>16) & 0xff)/255.0f, ((color>> 8) & 0xff)/255.0f,
((color>> 0) & 0xff)/255.0f, ((color>>24) & 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(); ResetAPIState();
GLenum ColorMask = GL_FALSE, AlphaMask = GL_FALSE; // color
if (colorEnable) ColorMask = GL_TRUE; GLboolean const
if (alphaEnable) AlphaMask = GL_TRUE; color_mask = colorEnable ? GL_TRUE : GL_FALSE,
glColorMask(ColorMask, ColorMask, ColorMask, AlphaMask); alpha_mask = alphaEnable ? GL_TRUE : GL_FALSE;
glColorMask(color_mask, color_mask, color_mask, alpha_mask);
if (zEnable) glClearColor(
{ float((color >> 16) & 0xFF) / 255.0f,
glEnable(GL_DEPTH_TEST); float((color >> 8) & 0xFF) / 255.0f,
glDepthMask(GL_TRUE); float((color >> 0) & 0xFF) / 255.0f,
glDepthFunc(GL_ALWAYS); float((color >> 24) & 0xFF) / 255.0f);
}
else
{
glDisable(GL_DEPTH_TEST);
glDepthMask(GL_FALSE);
glDepthFunc(GL_NEVER);
}
// Update viewport for clearing the picture // depth
TargetRectangle targetRc = ConvertEFBRectangle(rc); glDepthMask(zEnable ? GL_TRUE : GL_FALSE);
glViewport(targetRc.left, targetRc.bottom, targetRc.GetWidth(), targetRc.GetHeight());
glDepthRange(0.0, (float)(z & 0xFFFFFF) / float(0xFFFFFF));
glColor4f((float)((color >> 16) & 0xFF) / 255.0f, glClearDepth(float(z & 0xFFFFFF) / float(0xFFFFFF));
(float)((color >> 8) & 0xFF) / 255.0f,
(float)(color & 0xFF) / 255.0f, // Update rect for clearing the picture
(float)((color >> 24) & 0xFF) / 255.0f); glEnable(GL_SCISSOR_TEST);
glBegin(GL_QUADS);
glVertex3f(-1.f, -1.f, 1.f); TargetRectangle const targetRc = ConvertEFBRectangle(rc);
glVertex3f(-1.f, 1.f, 1.f); glScissor(targetRc.left, targetRc.bottom, targetRc.GetWidth(), targetRc.GetHeight());
glVertex3f( 1.f, 1.f, 1.f);
glVertex3f( 1.f, -1.f, 1.f); // glColorMask/glDepthMask/glScissor affect glClear (glViewport does not)
glEnd(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
RestoreAPIState(); RestoreAPIState();
@ -1436,6 +1428,7 @@ void Renderer::ResetAPIState()
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
// make sure to disable wireframe when drawing the clear quad // 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); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
} }