Skip to content

Commit

Permalink
OpenGL: Improve frameclear
Browse files Browse the repository at this point in the history
Make sure to clear the depth buffer, and the builtin color buffer when using an FBO.
Fixes issues with some VM drivers
  • Loading branch information
0x1F9F1 committed Mar 13, 2024
1 parent 255135b commit 0515da7
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions code/midtown/agigl/glpipe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,17 +264,29 @@ void agiGLPipeline::BeginFrame()

gl_context_->MakeCurrent();

if (PARAM_frameclear.get_or(true))
bool frameclear = PARAM_frameclear.get_or(true);

if (frameclear)
{
agiGL->EnableDisable(GL_SCISSOR_TEST, false);
agiGL->DepthMask(true);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT);
}

if (fbo_ != 0)
{
if (frameclear)
{
glClear(GL_COLOR_BUFFER_BIT);
}

glBindFramebuffer(GL_FRAMEBUFFER, fbo_);
}

if (frameclear)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
}

void agiGLPipeline::BeginScene()
Expand Down

0 comments on commit 0515da7

Please sign in to comment.