Fix ClearScreen in OpenGL as well (uses clear quads instead of glClear now).
Thanks to kiesel and sl1nk3 for helping me out here ;) git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6678 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
7de6773483
commit
6cc1468292
|
@ -166,7 +166,12 @@ FramebufferManager::FramebufferManager(int targetWidth, int targetHeight, int ms
|
||||||
|
|
||||||
glGenFramebuffersEXT(1, &m_xfbFramebuffer);
|
glGenFramebuffersEXT(1, &m_xfbFramebuffer);
|
||||||
|
|
||||||
// EFB framebuffer is currently bound.
|
// EFB framebuffer is currently bound, make sure to clear its alpha value to 1.f
|
||||||
|
glViewport(0, 0, m_targetWidth, m_targetHeight);
|
||||||
|
glScissor(0, 0, m_targetWidth, m_targetHeight);
|
||||||
|
glClearColor(0.f, 0.f, 0.f, 1.f);
|
||||||
|
glClearDepth(1.0);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
FramebufferManager::~FramebufferManager()
|
FramebufferManager::~FramebufferManager()
|
||||||
|
|
|
@ -829,38 +829,49 @@ void Renderer::UpdateViewport()
|
||||||
glDepthRange(GLNear, GLFar);
|
glDepthRange(GLNear, GLFar);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Clearing RGB or alpha only isn't implemented, yet!
|
|
||||||
void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable, u32 color, u32 z)
|
void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable, u32 color, u32 z)
|
||||||
{
|
{
|
||||||
// Update the view port for clearing the picture
|
ResetAPIState();
|
||||||
TargetRectangle targetRc = ConvertEFBRectangle(rc);
|
|
||||||
glViewport(targetRc.left, targetRc.bottom, targetRc.GetWidth(), targetRc.GetHeight());
|
|
||||||
|
|
||||||
// Always set the scissor in case it was set by the game and has not been reset
|
GLenum ColorMask = GL_FALSE, AlphaMask = GL_FALSE;
|
||||||
glScissor(targetRc.left, targetRc.bottom, targetRc.GetWidth(), targetRc.GetHeight());
|
if (colorEnable) ColorMask = GL_TRUE;
|
||||||
|
if (alphaEnable) AlphaMask = GL_TRUE;
|
||||||
|
glColorMask(ColorMask, ColorMask, ColorMask, AlphaMask);
|
||||||
|
|
||||||
VertexShaderManager::SetViewportChanged();
|
|
||||||
|
|
||||||
GLbitfield bits = 0;
|
|
||||||
if (colorEnable)
|
|
||||||
{
|
|
||||||
bits |= GL_COLOR_BUFFER_BIT;
|
|
||||||
glClearColor(
|
|
||||||
((color >> 16) & 0xFF) / 255.0f,
|
|
||||||
((color >> 8) & 0xFF) / 255.0f,
|
|
||||||
(color & 0xFF) / 255.0f,
|
|
||||||
((color >> 24) & 0xFF) / 255.0f
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (zEnable)
|
if (zEnable)
|
||||||
{
|
{
|
||||||
bits |= GL_DEPTH_BUFFER_BIT;
|
glEnable(GL_DEPTH_TEST);
|
||||||
glClearDepth((z & 0xFFFFFF) / float(0xFFFFFF));
|
glDepthMask(GL_TRUE);
|
||||||
|
glDepthFunc(GL_ALWAYS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
glDepthMask(GL_FALSE);
|
||||||
|
glDepthFunc(GL_NEVER);
|
||||||
}
|
}
|
||||||
|
|
||||||
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
glEnable(GL_SCISSOR_TEST);
|
||||||
glClear(bits);
|
|
||||||
SetScissorRect();
|
// Update the viewport and scissor rect for clearing the picture
|
||||||
|
TargetRectangle targetRc = ConvertEFBRectangle(rc);
|
||||||
|
glViewport(targetRc.left, targetRc.bottom, targetRc.GetWidth(), targetRc.GetHeight());
|
||||||
|
glScissor(targetRc.left, targetRc.bottom, targetRc.GetWidth(), targetRc.GetHeight());
|
||||||
|
glDepthRange(0.0, 1.0);
|
||||||
|
|
||||||
|
glColor4f((float)((color >> 16) & 0xFF) / 255.0f,
|
||||||
|
(float)((color >> 8) & 0xFF) / 255.0f,
|
||||||
|
(float)(color & 0xFF) / 255.0f,
|
||||||
|
(float)((color >> 24) & 0xFF) / 255.0f);
|
||||||
|
float zval = -1.f + 2.f * (float)(z & 0xFFFFFF) / float(0xFFFFFF); // convert range [0;1] to [-1;1]
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
glVertex3f(-1.f, -1.f, zval);
|
||||||
|
glVertex3f(-1.f, 1.f, zval);
|
||||||
|
glVertex3f( 1.f, 1.f, zval);
|
||||||
|
glVertex3f( 1.f, -1.f, zval);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
RestoreAPIState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::ReinterpretPixelData(unsigned int convtype)
|
void Renderer::ReinterpretPixelData(unsigned int convtype)
|
||||||
|
@ -1386,17 +1397,13 @@ void Renderer::ResetAPIState()
|
||||||
void Renderer::RestoreAPIState()
|
void Renderer::RestoreAPIState()
|
||||||
{
|
{
|
||||||
// Gets us back into a more game-like state.
|
// Gets us back into a more game-like state.
|
||||||
|
|
||||||
UpdateViewport();
|
|
||||||
|
|
||||||
if (bpmem.genMode.cullmode > 0) glEnable(GL_CULL_FACE);
|
|
||||||
if (bpmem.zmode.testenable) glEnable(GL_DEPTH_TEST);
|
|
||||||
if (bpmem.zmode.updateenable) glDepthMask(GL_TRUE);
|
|
||||||
|
|
||||||
glEnable(GL_SCISSOR_TEST);
|
glEnable(GL_SCISSOR_TEST);
|
||||||
|
SetGenerationMode();
|
||||||
SetScissorRect();
|
SetScissorRect();
|
||||||
SetColorMask();
|
SetColorMask();
|
||||||
|
SetDepthMode();
|
||||||
SetBlendMode(true);
|
SetBlendMode(true);
|
||||||
|
UpdateViewport();
|
||||||
|
|
||||||
VertexShaderCache::SetCurrentShader(0);
|
VertexShaderCache::SetCurrentShader(0);
|
||||||
PixelShaderCache::SetCurrentShader(0);
|
PixelShaderCache::SetCurrentShader(0);
|
||||||
|
|
Loading…
Reference in New Issue