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

@ -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);
}