From 1837acd0dd4d557276b761fb2846a8b7d6d8beb7 Mon Sep 17 00:00:00 2001 From: plombo Date: Wed, 9 Feb 2011 05:05:13 +0000 Subject: [PATCH] sdl: Attempt to fix flickering garbage data in OpenGL fullscreen mode with fglrx (and possibly other drivers using page flipping) --- src/drivers/sdl/sdl-opengl.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/drivers/sdl/sdl-opengl.cpp b/src/drivers/sdl/sdl-opengl.cpp index 02b38cc1..ebb1116d 100644 --- a/src/drivers/sdl/sdl-opengl.cpp +++ b/src/drivers/sdl/sdl-opengl.cpp @@ -90,6 +90,7 @@ SetOpenGLPalette(uint8 *data) void BlitOpenGL(uint8 *buf) { + p_glClear(GL_COLOR_BUFFER_BIT); p_glBindTexture(GL_TEXTURE_2D, textures[0]); if(HiBuffer) { Blit8ToHigh(buf, (uint8*)HiBuffer, 256, 240, 256*4, 1, 1); @@ -277,11 +278,16 @@ InitOpenGL(int l, p_glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP); p_glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP); p_glEnable(GL_TEXTURE_2D); + p_glDisable(GL_DEPTH_TEST); p_glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Background color to black. p_glMatrixMode(GL_MODELVIEW); - - p_glClear(GL_COLOR_BUFFER_BIT); p_glLoadIdentity(); + // In a double buffered setup with page flipping, be sure to clear both buffers. + p_glClear(GL_COLOR_BUFFER_BIT); + SDL_GL_SwapBuffers(); + p_glClear(GL_COLOR_BUFFER_BIT); + SDL_GL_SwapBuffers(); + return(1); }