Merge branch 'blackscreenfix' of https://github.com/dpjudas/zdoom

This commit is contained in:
Christoph Oelckers 2016-07-30 20:28:41 +02:00
commit bc51e98612
1 changed files with 45 additions and 5 deletions

View File

@ -110,6 +110,15 @@ void FGLRenderer::BloomScene()
int sampleCount = gl_bloom_kernel_size;
// TBD: Maybe need a better way to share state with other parts of the pipeline
GLint activeTex, textureBinding, samplerBinding;
glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTex);
glActiveTexture(GL_TEXTURE0);
glGetIntegerv(GL_TEXTURE_BINDING_2D, &textureBinding);
if (gl.flags & RFL_SAMPLER_OBJECTS)
{
glGetIntegerv(GL_SAMPLER_BINDING, &samplerBinding);
glBindSampler(0, 0);
}
GLboolean blendEnabled, scissorEnabled;
GLint currentProgram, blendEquationRgb, blendEquationAlpha, blendSrcRgb, blendSrcAlpha, blendDestRgb, blendDestAlpha;
glGetBooleanv(GL_BLEND, &blendEnabled);
@ -215,6 +224,10 @@ void FGLRenderer::BloomScene()
glBlendEquationSeparate(blendEquationRgb, blendEquationAlpha);
glBlendFuncSeparate(blendSrcRgb, blendDestRgb, blendSrcAlpha, blendDestAlpha);
glUseProgram(currentProgram);
glBindTexture(GL_TEXTURE_2D, textureBinding);
if (gl.flags & RFL_SAMPLER_OBJECTS)
glBindSampler(0, samplerBinding);
glActiveTexture(activeTex);
}
//-----------------------------------------------------------------------------
@ -228,6 +241,16 @@ void FGLRenderer::TonemapScene()
if (gl_tonemap == 0)
return;
GLint activeTex, textureBinding, samplerBinding;
glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTex);
glActiveTexture(GL_TEXTURE0);
glGetIntegerv(GL_TEXTURE_BINDING_2D, &textureBinding);
if (gl.flags & RFL_SAMPLER_OBJECTS)
{
glGetIntegerv(GL_SAMPLER_BINDING, &samplerBinding);
glBindSampler(0, 0);
}
GLboolean blendEnabled, scissorEnabled;
glGetBooleanv(GL_BLEND, &blendEnabled);
glGetBooleanv(GL_SCISSOR_TEST, &scissorEnabled);
@ -252,6 +275,10 @@ void FGLRenderer::TonemapScene()
glEnable(GL_BLEND);
if (scissorEnabled)
glEnable(GL_SCISSOR_TEST);
glBindTexture(GL_TEXTURE_2D, textureBinding);
if (gl.flags & RFL_SAMPLER_OBJECTS)
glBindSampler(0, samplerBinding);
glActiveTexture(activeTex);
}
//-----------------------------------------------------------------------------
@ -268,6 +295,20 @@ void FGLRenderer::Flush()
glDisable(GL_DEPTH_TEST);
glDisable(GL_STENCIL_TEST);
GLboolean blendEnabled;
GLint currentProgram;
GLint activeTex, textureBinding, samplerBinding;
glGetBooleanv(GL_BLEND, &blendEnabled);
glGetIntegerv(GL_CURRENT_PROGRAM, &currentProgram);
glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTex);
glActiveTexture(GL_TEXTURE0);
glGetIntegerv(GL_TEXTURE_BINDING_2D, &textureBinding);
if (gl.flags & RFL_SAMPLER_OBJECTS)
{
glGetIntegerv(GL_SAMPLER_BINDING, &samplerBinding);
glBindSampler(0, 0);
}
mBuffers->BindOutputFB();
// Calculate letterbox
@ -309,11 +350,6 @@ void FGLRenderer::Flush()
// Present what was rendered:
glViewport(x, y, width, height);
GLboolean blendEnabled;
GLint currentProgram;
glGetBooleanv(GL_BLEND, &blendEnabled);
glGetIntegerv(GL_CURRENT_PROGRAM, &currentProgram);
glDisable(GL_BLEND);
mPresentShader->Bind();
@ -342,5 +378,9 @@ void FGLRenderer::Flush()
if (blendEnabled)
glEnable(GL_BLEND);
glUseProgram(currentProgram);
glBindTexture(GL_TEXTURE_2D, textureBinding);
if (gl.flags & RFL_SAMPLER_OBJECTS)
glBindSampler(0, samplerBinding);
glActiveTexture(activeTex);
}
}