Mercurial > sdl-ios-xcode
diff src/video/ataricommon/SDL_atarigl.c @ 992:0324ce32b2d9
Keep current OpenGL context when possible
author | Patrice Mandin <patmandin@gmail.com> |
---|---|
date | Fri, 26 Nov 2004 22:11:30 +0000 |
parents | 12b13601a544 |
children | 2662da16d668 |
line wrap: on
line diff
--- a/src/video/ataricommon/SDL_atarigl.c Fri Nov 26 16:16:50 2004 +0000 +++ b/src/video/ataricommon/SDL_atarigl.c Fri Nov 26 22:11:30 2004 +0000 @@ -80,13 +80,9 @@ return (gl_active); } -void SDL_AtariGL_Quit(_THIS) +void SDL_AtariGL_Quit(_THIS, SDL_bool unload) { #ifdef HAVE_OPENGL - if (!gl_active) { - return; - } - if (gl_oldmesa) { /* Old mesa implementations */ if (this->gl_data->OSMesaDestroyLDG) { @@ -106,7 +102,9 @@ } } - SDL_AtariGL_UnloadLibrary(this); + if (unload) { + SDL_AtariGL_UnloadLibrary(this); + } #endif /* HAVE_OPENGL */ gl_active = 0; @@ -378,6 +376,8 @@ GLenum osmesa_format; SDL_PixelFormat *pixel_format; Uint32 redmask; + int recreatecontext; + GLint newaccumsize; if (this->gl_config.dll_handle) { if (this->gl_data->OSMesaCreateContextExt == NULL) { @@ -440,11 +440,39 @@ break; } - gl_ctx = this->gl_data->OSMesaCreateContextExt( - osmesa_format, this->gl_config.depth_size, - this->gl_config.stencil_size, this->gl_config.accum_red_size + - this->gl_config.accum_green_size + this->gl_config.accum_blue_size + - this->gl_config.accum_alpha_size, NULL ); + /* Try to keep current context if possible */ + newaccumsize = + this->gl_config.accum_red_size + + this->gl_config.accum_green_size + + this->gl_config.accum_blue_size + + this->gl_config.accum_alpha_size; + recreatecontext=1; + if (gl_ctx && + (gl_curformat == osmesa_format) && + (gl_curdepth == this->gl_config.depth_size) && + (gl_curstencil == this->gl_config.stencil_size) && + (gl_curaccum == newaccumsize)) { + recreatecontext = 0; + } + if (recreatecontext) { + SDL_AtariGL_Quit(this, SDL_FALSE); + + gl_ctx = this->gl_data->OSMesaCreateContextExt( + osmesa_format, this->gl_config.depth_size, + this->gl_config.stencil_size, newaccumsize, NULL ); + + if (gl_ctx) { + gl_curformat = osmesa_format; + gl_curdepth = this->gl_config.depth_size; + gl_curstencil = this->gl_config.stencil_size; + gl_curaccum = newaccumsize; + } else { + gl_curformat = 0; + gl_curdepth = 0; + gl_curstencil = 0; + gl_curaccum = 0; + } + } return (gl_ctx != NULL); } @@ -454,6 +482,7 @@ GLenum osmesa_format; SDL_PixelFormat *pixel_format; Uint32 redmask; + int recreatecontext; if (this->gl_config.dll_handle) { if (this->gl_data->OSMesaCreateLDG == NULL) { @@ -520,9 +549,31 @@ break; } - gl_shadow = this->gl_data->OSMesaCreateLDG( - osmesa_format, GL_UNSIGNED_BYTE, current->w, current->h - ); + /* Try to keep current context if possible */ + recreatecontext=1; + if (gl_shadow && + (gl_curformat == osmesa_format) && + (gl_curwidth == current->w) && + (gl_curheight == current->h)) { + recreatecontext = 0; + } + if (recreatecontext) { + SDL_AtariGL_Quit(this, SDL_FALSE); + + gl_shadow = this->gl_data->OSMesaCreateLDG( + osmesa_format, GL_UNSIGNED_BYTE, current->w, current->h + ); + + if (gl_shadow) { + gl_curformat = osmesa_format; + gl_curwidth = current->w; + gl_curheight = current->h; + } else { + gl_curformat = 0; + gl_curwidth = 0; + gl_curheight = 0; + } + } return (gl_shadow != NULL); }