Skip to content

Commit

Permalink
Clamp the multisample level to the max level to prevent screen smeari…
Browse files Browse the repository at this point in the history
…ng glitch.

The bug could be triggered after switching from a graphics card that
supported a higher multisample level to one with a lower max than what
was configured. The glitch caused the visuals to be dark and elements
would blur on the screen.
  • Loading branch information
blast007 committed Aug 31, 2023
1 parent 258cfad commit 1fac318
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/bzflag/playing.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -6374,10 +6374,14 @@ void drawFrame(const float dt)
else
{
// bind the multisample framebuffer, if enabled
bool useMultisampling = OpenGLGState::getMaxSamples() > 1 && BZDB.evalInt("multisample") > 1;
int maxSamples = OpenGLGState::getMaxSamples();
bool useMultisampling = maxSamples > 1 && BZDB.evalInt("multisample") > 1;
if(useMultisampling)
{
glFramebuffer.checkState(mainWindow->getWidth(), mainWindow->getHeight(), BZDB.evalInt("multisample"));
int samples = BZDB.evalInt("multisample");
if (samples > maxSamples)
samples = maxSamples;
glFramebuffer.checkState(mainWindow->getWidth(), mainWindow->getHeight(), samples);
glBindFramebuffer(GL_FRAMEBUFFER, glFramebuffer.getFramebuffer());
}

Expand Down

0 comments on commit 1fac318

Please sign in to comment.