Skip to content

Commit

Permalink
Fix glslscale bug when binding a framebuffer before gl_swap_buffers. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
AliceLR committed Mar 6, 2024
1 parent aecf657 commit 5597800
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
3 changes: 3 additions & 0 deletions docs/changelog.txt
Expand Up @@ -7,6 +7,9 @@ USERS

+ All "gamecontroller[...]" config.txt options have been renamed
to "gamepad[...]". The old names are still supported.
+ Fixed blank screen bugs that occur with the glslscale renderer
in conjunction with Intel HD Graphics 2500 graphics drivers
and possibly some other old drivers.
+ The softscale renderer now respects disable_screensaver.
+ HTML5: fixed the poor performance of FREADn and other features
that rely on calculating the length of an open file.
Expand Down
27 changes: 13 additions & 14 deletions src/render_glsl.c
Expand Up @@ -1491,30 +1491,29 @@ static void glsl_sync_screen(struct graphics_data *graphics)
gl_check_error();
}

gl_swap_buffers(graphics);
render_data->dirty_palette = true;
render_data->dirty_indices = true;

if(glsl.has_fbo)
{
/* Switch back to the texture framebuffer. This needs to be done after
* gl_swap_buffers or the screen won't draw properly for some drivers.
* The SDL documentation cites macOS, but MegaZeux bugs were encountered
* using the Intel HD Graphics 2500 driver in Windows too.
*/
glsl.glBindFramebuffer(GL_FRAMEBUFFER, render_data->fbos[FBO_SCREEN_TEX]);
gl_check_error();

// Clear the framebuffer so elements of this frame don't bleed through.
glsl.glClear(GL_COLOR_BUFFER_BIT);
gl_check_error();
}

gl_swap_buffers(graphics);
render_data->dirty_palette = true;
render_data->dirty_indices = true;

/**
* Clear the framebuffer so elements of this frame don't bleed through.
* When FBOs are not available, the next window frame needs to be cleared
* since the screen will be temporarily drawn there before scaling. This call
* was previously disabled for Emscripten (which should always have FBOs).
* was previously disabled for Emscripten.
*/
if(!glsl.has_fbo)
{
glsl.glClear(GL_COLOR_BUFFER_BIT);
gl_check_error();
}
glsl.glClear(GL_COLOR_BUFFER_BIT);
gl_check_error();
}

static boolean glsl_switch_shader(struct graphics_data *graphics,
Expand Down

0 comments on commit 5597800

Please sign in to comment.