From 2b26bac067529d79edc962abc5d1793662e53c88 Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Sat, 27 Nov 2004 21:28:49 +0000 Subject: [PATCH] Forgot to flush OpenGL buffer using glFinish --- src/video/ataricommon/SDL_atarigl.c | 41 +++++++++++++++++++-------- src/video/ataricommon/SDL_atarigl_c.h | 5 +++- src/video/gem/SDL_gemvideo.c | 7 ++--- src/video/xbios/SDL_xbios.c | 9 ++---- 4 files changed, 38 insertions(+), 24 deletions(-) diff --git a/src/video/ataricommon/SDL_atarigl.c b/src/video/ataricommon/SDL_atarigl.c index e2540b203..5693e9599 100644 --- a/src/video/ataricommon/SDL_atarigl.c +++ b/src/video/ataricommon/SDL_atarigl.c @@ -156,13 +156,24 @@ int SDL_AtariGL_LoadLibrary(_THIS, const char *path) return -1; } + this->gl_data->glGetIntegerv = SDL_LoadFunction(handle, "glGetIntegerv"); + this->gl_data->glFinish = SDL_LoadFunction(handle, "glFinish"); + + if ( (this->gl_data->glGetIntegerv == NULL) || + (this->gl_data->glFinish == NULL)) { + SDL_SetError("Could not retrieve OpenGL functions"); + SDL_UnloadObject(handle); + /* Restore pointers to static library */ + SDL_AtariGL_InitPointers(this); + return -1; + } + /* Load functions pointers (osmesa.ldg) */ this->gl_data->OSMesaCreateContextExt = SDL_LoadFunction(handle, "OSMesaCreateContextExt"); this->gl_data->OSMesaDestroyContext = SDL_LoadFunction(handle, "OSMesaDestroyContext"); this->gl_data->OSMesaMakeCurrent = SDL_LoadFunction(handle, "OSMesaMakeCurrent"); this->gl_data->OSMesaPixelStore = SDL_LoadFunction(handle, "OSMesaPixelStore"); this->gl_data->OSMesaGetProcAddress = SDL_LoadFunction(handle, "OSMesaGetProcAddress"); - this->gl_data->glGetIntegerv = SDL_LoadFunction(handle, "glGetIntegerv"); /* Load old functions pointers (mesa_gl.ldg, tiny_gl.ldg) */ this->gl_data->OSMesaCreateLDG = SDL_LoadFunction(handle, "OSMesaCreateLDG"); @@ -174,12 +185,14 @@ int SDL_AtariGL_LoadLibrary(_THIS, const char *path) (this->gl_data->OSMesaDestroyContext == NULL) || (this->gl_data->OSMesaMakeCurrent == NULL) || (this->gl_data->OSMesaPixelStore == NULL) || - (this->gl_data->glGetIntegerv == NULL) || (this->gl_data->OSMesaGetProcAddress == NULL)) { /* Hum, maybe old library ? */ if ( (this->gl_data->OSMesaCreateLDG == NULL) || (this->gl_data->OSMesaDestroyLDG == NULL)) { - SDL_SetError("Could not retrieve OpenGL functions"); + SDL_SetError("Could not retrieve OSMesa functions"); + SDL_UnloadObject(handle); + /* Restore pointers to static library */ + SDL_AtariGL_InitPointers(this); return -1; } else { gl_oldmesa = 1; @@ -328,6 +341,13 @@ void SDL_AtariGL_SwapBuffers(_THIS) { #ifdef HAVE_OPENGL if (gl_active) { + if (this->gl_config.dll_handle) { + if (this->gl_data->glFinish) { + this->gl_data->glFinish(); + } + } else { + this->gl_data->glFinish(); + } gl_copyshadow(this, this->screen); gl_convert(this, this->screen); } @@ -342,7 +362,12 @@ void SDL_AtariGL_InitPointers(_THIS) this->gl_data->OSMesaMakeCurrent = OSMesaMakeCurrent; this->gl_data->OSMesaPixelStore = OSMesaPixelStore; this->gl_data->OSMesaGetProcAddress = OSMesaGetProcAddress; + this->gl_data->glGetIntegerv = glGetIntegerv; + this->gl_data->glFinish = glFinish; + + this->gl_data->OSMesaCreateLDG = NULL; + this->gl_data->OSMesaDestroyLDG = NULL; #endif } @@ -356,15 +381,7 @@ static void SDL_AtariGL_UnloadLibrary(_THIS) this->gl_config.dll_handle = NULL; /* Restore pointers to static library */ - this->gl_data->OSMesaCreateContextExt = OSMesaCreateContextExt; - this->gl_data->OSMesaDestroyContext = OSMesaDestroyContext; - this->gl_data->OSMesaMakeCurrent = OSMesaMakeCurrent; - this->gl_data->OSMesaPixelStore = OSMesaPixelStore; - this->gl_data->OSMesaGetProcAddress = OSMesaGetProcAddress; - this->gl_data->glGetIntegerv = glGetIntegerv; - - this->gl_data->OSMesaCreateLDG = NULL; - this->gl_data->OSMesaDestroyLDG = NULL; + SDL_AtariGL_InitPointers(this); } #endif } diff --git a/src/video/ataricommon/SDL_atarigl_c.h b/src/video/ataricommon/SDL_atarigl_c.h index 59af86a35..afe695fb2 100644 --- a/src/video/ataricommon/SDL_atarigl_c.h +++ b/src/video/ataricommon/SDL_atarigl_c.h @@ -50,13 +50,16 @@ struct SDL_PrivateGLData { OSMesaContext ctx; + /* OpenGL functions */ + void (*glGetIntegerv)( GLenum pname, GLint *value ); + void (*glFinish)(void); + /* osmesa.ldg */ OSMesaContext (*OSMesaCreateContextExt)( GLenum format, GLint depthBits, GLint stencilBits, GLint accumBits, OSMesaContext sharelist); void (*OSMesaDestroyContext)( OSMesaContext ctx ); GLboolean (*OSMesaMakeCurrent)( OSMesaContext ctx, void *buffer, GLenum type, GLsizei width, GLsizei height ); void (*OSMesaPixelStore)( GLint pname, GLint value ); void * (*OSMesaGetProcAddress)( const char *funcName ); - void (*glGetIntegerv)( GLenum pname, GLint *value ); /* mesa_gl.ldg, tiny_gl.ldg */ void *(*OSMesaCreateLDG)( long format, long type, long width, long height ); diff --git a/src/video/gem/SDL_gemvideo.c b/src/video/gem/SDL_gemvideo.c index b69378070..257b31491 100644 --- a/src/video/gem/SDL_gemvideo.c +++ b/src/video/gem/SDL_gemvideo.c @@ -1276,11 +1276,8 @@ static void refresh_window(_THIS, int winhandle, short *rect) static void GEM_GL_SwapBuffers(_THIS) { - if (gl_active) { - gl_copyshadow(this, this->screen); - gl_convert(this, this->screen); - GEM_FlipHWSurface(this, this->screen); - } + SDL_AtariGL_SwapBuffers(this); + GEM_FlipHWSurface(this, this->screen); } #endif diff --git a/src/video/xbios/SDL_xbios.c b/src/video/xbios/SDL_xbios.c index b95a91d6c..361a823cf 100644 --- a/src/video/xbios/SDL_xbios.c +++ b/src/video/xbios/SDL_xbios.c @@ -883,12 +883,9 @@ static void XBIOS_VideoQuit(_THIS) static void XBIOS_GL_SwapBuffers(_THIS) { - if (gl_active) { - gl_copyshadow(this, this->screen); - gl_convert(this, this->screen); - XBIOS_FlipHWSurface(this, this->screen); - SDL_AtariGL_MakeCurrent(this); - } + SDL_AtariGL_SwapBuffers(this); + XBIOS_FlipHWSurface(this, this->screen); + SDL_AtariGL_MakeCurrent(this); } #endif