mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2024-11-27 22:22:08 +00:00
Fix not switching back to the default frame buffer when gl_renderbuffers is toggled off
This commit is contained in:
parent
ee503ea275
commit
77dde2e3ad
2 changed files with 14 additions and 18 deletions
|
@ -156,6 +156,13 @@ void FGLRenderBuffers::DeleteFrameBuffer(GLuint &handle)
|
|||
|
||||
bool FGLRenderBuffers::Setup(int width, int height, int sceneWidth, int sceneHeight)
|
||||
{
|
||||
if (gl_renderbuffers != BuffersActive)
|
||||
{
|
||||
if (BuffersActive)
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, mOutputFB);
|
||||
BuffersActive = gl_renderbuffers;
|
||||
}
|
||||
|
||||
if (!IsEnabled())
|
||||
return false;
|
||||
|
||||
|
@ -223,7 +230,7 @@ void FGLRenderBuffers::CreateScene(int width, int height, int samples)
|
|||
ClearScene();
|
||||
|
||||
if (samples > 1)
|
||||
mSceneMultisample = CreateRenderBuffer("SceneMultisample", GetHdrFormat(), samples, width, height);
|
||||
mSceneMultisample = CreateRenderBuffer("SceneMultisample", GL_RGBA16F, samples, width, height);
|
||||
|
||||
mSceneDepthStencil = CreateRenderBuffer("SceneDepthStencil", GL_DEPTH24_STENCIL8, samples, width, height);
|
||||
mSceneFB = CreateFrameBuffer("SceneFB", samples > 1 ? mSceneMultisample : mPipelineTexture[0], mSceneDepthStencil, samples > 1);
|
||||
|
@ -241,7 +248,7 @@ void FGLRenderBuffers::CreatePipeline(int width, int height)
|
|||
|
||||
for (int i = 0; i < NumPipelineTextures; i++)
|
||||
{
|
||||
mPipelineTexture[i] = Create2DTexture("PipelineTexture", GetHdrFormat(), width, height);
|
||||
mPipelineTexture[i] = Create2DTexture("PipelineTexture", GL_RGBA16F, width, height);
|
||||
mPipelineFB[i] = CreateFrameBuffer("PipelineFB", mPipelineTexture[i]);
|
||||
}
|
||||
}
|
||||
|
@ -268,8 +275,8 @@ void FGLRenderBuffers::CreateBloom(int width, int height)
|
|||
level.Width = MAX(bloomWidth / 2, 1);
|
||||
level.Height = MAX(bloomHeight / 2, 1);
|
||||
|
||||
level.VTexture = Create2DTexture("Bloom.VTexture", GetHdrFormat(), level.Width, level.Height);
|
||||
level.HTexture = Create2DTexture("Bloom.HTexture", GetHdrFormat(), level.Width, level.Height);
|
||||
level.VTexture = Create2DTexture("Bloom.VTexture", GL_RGBA16F, level.Width, level.Height);
|
||||
level.HTexture = Create2DTexture("Bloom.HTexture", GL_RGBA16F, level.Width, level.Height);
|
||||
level.VFramebuffer = CreateFrameBuffer("Bloom.VFramebuffer", level.VTexture);
|
||||
level.HFramebuffer = CreateFrameBuffer("Bloom.HFramebuffer", level.HTexture);
|
||||
|
||||
|
@ -278,17 +285,6 @@ void FGLRenderBuffers::CreateBloom(int width, int height)
|
|||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Fallback support for older OpenGL where RGBA16F might not be available
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
GLuint FGLRenderBuffers::GetHdrFormat()
|
||||
{
|
||||
return GL_RGBA16F;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Creates a 2D texture defaulting to linear filtering and clamp to edge
|
||||
|
@ -557,7 +553,8 @@ void FGLRenderBuffers::BindOutputFB()
|
|||
|
||||
bool FGLRenderBuffers::IsEnabled()
|
||||
{
|
||||
return gl_renderbuffers && !gl.legacyMode && !FailedCreate;
|
||||
return BuffersActive && !gl.legacyMode && !FailedCreate;
|
||||
}
|
||||
|
||||
bool FGLRenderBuffers::FailedCreate = false;
|
||||
bool FGLRenderBuffers::BuffersActive = false;
|
||||
|
|
|
@ -59,8 +59,6 @@ private:
|
|||
void DeleteRenderBuffer(GLuint &handle);
|
||||
void DeleteFrameBuffer(GLuint &handle);
|
||||
|
||||
GLuint GetHdrFormat();
|
||||
|
||||
int mWidth = 0;
|
||||
int mHeight = 0;
|
||||
int mSamples = 0;
|
||||
|
@ -86,6 +84,7 @@ private:
|
|||
GLuint mOutputFB = 0;
|
||||
|
||||
static bool FailedCreate;
|
||||
static bool BuffersActive;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue