Fix the background not rendering on the second frame, this was imply due to a bug in the GLBackend

This commit is contained in:
Sam Cake 2017-06-12 21:25:27 -07:00
parent c32f5c1f2b
commit f973f7b5e3
2 changed files with 14 additions and 3 deletions

View file

@ -1873,8 +1873,8 @@ void Application::initializeGL() {
isDeferred = false;
}
_renderEngine->addJob<MainRenderTask>("MainFrame", cullFunctor, isDeferred);
_renderEngine->addJob<SecondaryCameraRenderTask>("SecondaryCameraFrame", cullFunctor);
_renderEngine->addJob<MainRenderTask>("MainFrame", cullFunctor, isDeferred);
/* _renderEngine->addJob<RenderShadowTask>("RenderShadowTask", cullFunctor);

View file

@ -63,11 +63,17 @@ void GLBackend::do_clearFramebuffer(const Batch& batch, size_t paramOffset) {
int useScissor = batch._params[paramOffset + 0]._int;
GLuint glmask = 0;
bool restoreStencilMask = false;
uint8_t cacheStencilMask = 0xFF;
if (masks & Framebuffer::BUFFER_STENCIL) {
glClearStencil(stencil);
glmask |= GL_STENCIL_BUFFER_BIT;
// TODO: we will probably need to also check the write mask of stencil like we do
// for depth buffer, but as would say a famous Fez owner "We'll cross that bridge when we come to it"
cacheStencilMask = _pipeline._stateCache.stencilActivation.getWriteMaskFront();
if (cacheStencilMask != 0xFF) {
restoreStencilMask = true;
glStencilMask( 0xFF);
}
}
bool restoreDepthMask = false;
@ -121,6 +127,11 @@ void GLBackend::do_clearFramebuffer(const Batch& batch, size_t paramOffset) {
glDisable(GL_SCISSOR_TEST);
}
// Restore Stencil write mask
if (restoreStencilMask) {
glStencilMask(cacheStencilMask);
}
// Restore write mask meaning turn back off
if (restoreDepthMask) {
glDepthMask(GL_FALSE);