mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2024-11-24 12:51:09 +00:00
Fix uninitialized data in render buffers at creation
This commit is contained in:
parent
847d2e8862
commit
af62352860
2 changed files with 28 additions and 0 deletions
|
@ -336,6 +336,7 @@ GLuint FGLRenderBuffers::CreateFrameBuffer(GLuint colorbuffer)
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, handle);
|
glBindFramebuffer(GL_FRAMEBUFFER, handle);
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer, 0);
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer, 0);
|
||||||
CheckFrameBufferCompleteness();
|
CheckFrameBufferCompleteness();
|
||||||
|
ClearFrameBuffer();
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,6 +351,7 @@ GLuint FGLRenderBuffers::CreateFrameBuffer(GLuint colorbuffer, GLuint depthstenc
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer, 0);
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer, 0);
|
||||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, depthstencil);
|
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, depthstencil);
|
||||||
CheckFrameBufferCompleteness();
|
CheckFrameBufferCompleteness();
|
||||||
|
ClearFrameBuffer();
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,6 +367,7 @@ GLuint FGLRenderBuffers::CreateFrameBuffer(GLuint colorbuffer, GLuint depth, GLu
|
||||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth);
|
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth);
|
||||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, stencil);
|
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, stencil);
|
||||||
CheckFrameBufferCompleteness();
|
CheckFrameBufferCompleteness();
|
||||||
|
ClearFrameBuffer();
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -396,6 +399,30 @@ void FGLRenderBuffers::CheckFrameBufferCompleteness()
|
||||||
I_FatalError(error);
|
I_FatalError(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// Clear frame buffer to make sure it never contains uninitialized data
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
void FGLRenderBuffers::ClearFrameBuffer()
|
||||||
|
{
|
||||||
|
GLint scissorEnabled, stencilValue;
|
||||||
|
GLdouble depthValue;
|
||||||
|
glGetIntegerv(GL_SCISSOR_TEST, &scissorEnabled);
|
||||||
|
glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &stencilValue);
|
||||||
|
glGetDoublev(GL_DEPTH_CLEAR_VALUE, &depthValue);
|
||||||
|
glDisable(GL_SCISSOR_TEST);
|
||||||
|
glClearColor(0.0, 0.0, 0.0, 0.0);
|
||||||
|
glClearDepth(0.0);
|
||||||
|
glClearStencil(0);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||||
|
glClearStencil(stencilValue);
|
||||||
|
glClearDepth(depthValue);
|
||||||
|
if (scissorEnabled)
|
||||||
|
glEnable(GL_SCISSOR_TEST);
|
||||||
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// Resolves the multisample frame buffer by copying it to the scene texture
|
// Resolves the multisample frame buffer by copying it to the scene texture
|
||||||
|
|
|
@ -54,6 +54,7 @@ private:
|
||||||
GLuint CreateFrameBuffer(GLuint colorbuffer, GLuint depthstencil, bool colorIsARenderBuffer);
|
GLuint CreateFrameBuffer(GLuint colorbuffer, GLuint depthstencil, bool colorIsARenderBuffer);
|
||||||
GLuint CreateFrameBuffer(GLuint colorbuffer, GLuint depth, GLuint stencil, bool colorIsARenderBuffer);
|
GLuint CreateFrameBuffer(GLuint colorbuffer, GLuint depth, GLuint stencil, bool colorIsARenderBuffer);
|
||||||
void CheckFrameBufferCompleteness();
|
void CheckFrameBufferCompleteness();
|
||||||
|
void ClearFrameBuffer();
|
||||||
void DeleteTexture(GLuint &handle);
|
void DeleteTexture(GLuint &handle);
|
||||||
void DeleteRenderBuffer(GLuint &handle);
|
void DeleteRenderBuffer(GLuint &handle);
|
||||||
void DeleteFrameBuffer(GLuint &handle);
|
void DeleteFrameBuffer(GLuint &handle);
|
||||||
|
|
Loading…
Reference in a new issue