Keep current OpenGL context when possible
--HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40993
This commit is contained in:
parent
a9ce9ef9a9
commit
064aa65648
4 changed files with 90 additions and 27 deletions
|
@ -80,13 +80,9 @@ int SDL_AtariGL_Init(_THIS, SDL_Surface *current)
|
||||||
return (gl_active);
|
return (gl_active);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_AtariGL_Quit(_THIS)
|
void SDL_AtariGL_Quit(_THIS, SDL_bool unload)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_OPENGL
|
#ifdef HAVE_OPENGL
|
||||||
if (!gl_active) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gl_oldmesa) {
|
if (gl_oldmesa) {
|
||||||
/* Old mesa implementations */
|
/* Old mesa implementations */
|
||||||
if (this->gl_data->OSMesaDestroyLDG) {
|
if (this->gl_data->OSMesaDestroyLDG) {
|
||||||
|
@ -106,7 +102,9 @@ void SDL_AtariGL_Quit(_THIS)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_AtariGL_UnloadLibrary(this);
|
if (unload) {
|
||||||
|
SDL_AtariGL_UnloadLibrary(this);
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* HAVE_OPENGL */
|
#endif /* HAVE_OPENGL */
|
||||||
gl_active = 0;
|
gl_active = 0;
|
||||||
|
@ -378,6 +376,8 @@ static int InitNew(_THIS, SDL_Surface *current)
|
||||||
GLenum osmesa_format;
|
GLenum osmesa_format;
|
||||||
SDL_PixelFormat *pixel_format;
|
SDL_PixelFormat *pixel_format;
|
||||||
Uint32 redmask;
|
Uint32 redmask;
|
||||||
|
int recreatecontext;
|
||||||
|
GLint newaccumsize;
|
||||||
|
|
||||||
if (this->gl_config.dll_handle) {
|
if (this->gl_config.dll_handle) {
|
||||||
if (this->gl_data->OSMesaCreateContextExt == NULL) {
|
if (this->gl_data->OSMesaCreateContextExt == NULL) {
|
||||||
|
@ -440,11 +440,39 @@ static int InitNew(_THIS, SDL_Surface *current)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
gl_ctx = this->gl_data->OSMesaCreateContextExt(
|
/* Try to keep current context if possible */
|
||||||
osmesa_format, this->gl_config.depth_size,
|
newaccumsize =
|
||||||
this->gl_config.stencil_size, this->gl_config.accum_red_size +
|
this->gl_config.accum_red_size +
|
||||||
this->gl_config.accum_green_size + this->gl_config.accum_blue_size +
|
this->gl_config.accum_green_size +
|
||||||
this->gl_config.accum_alpha_size, NULL );
|
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);
|
return (gl_ctx != NULL);
|
||||||
}
|
}
|
||||||
|
@ -454,6 +482,7 @@ static int InitOld(_THIS, SDL_Surface *current)
|
||||||
GLenum osmesa_format;
|
GLenum osmesa_format;
|
||||||
SDL_PixelFormat *pixel_format;
|
SDL_PixelFormat *pixel_format;
|
||||||
Uint32 redmask;
|
Uint32 redmask;
|
||||||
|
int recreatecontext;
|
||||||
|
|
||||||
if (this->gl_config.dll_handle) {
|
if (this->gl_config.dll_handle) {
|
||||||
if (this->gl_data->OSMesaCreateLDG == NULL) {
|
if (this->gl_data->OSMesaCreateLDG == NULL) {
|
||||||
|
@ -520,9 +549,31 @@ static int InitOld(_THIS, SDL_Surface *current)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
gl_shadow = this->gl_data->OSMesaCreateLDG(
|
/* Try to keep current context if possible */
|
||||||
osmesa_format, GL_UNSIGNED_BYTE, current->w, current->h
|
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);
|
return (gl_shadow != NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,11 @@ struct SDL_PrivateGLData {
|
||||||
/* mesa_gl.ldg, tiny_gl.ldg */
|
/* mesa_gl.ldg, tiny_gl.ldg */
|
||||||
void *(*OSMesaCreateLDG)( long format, long type, long width, long height );
|
void *(*OSMesaCreateLDG)( long format, long type, long width, long height );
|
||||||
void (*OSMesaDestroyLDG)(void);
|
void (*OSMesaDestroyLDG)(void);
|
||||||
|
|
||||||
|
/* Info needed to compare existing context with new asked one */
|
||||||
|
int width, height;
|
||||||
|
GLenum format;
|
||||||
|
GLint depth,stencil,accum;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Variable names */
|
/* Variable names */
|
||||||
|
@ -71,10 +76,16 @@ struct SDL_PrivateGLData {
|
||||||
#define gl_shadow (this->gl_data->gl_shadow)
|
#define gl_shadow (this->gl_data->gl_shadow)
|
||||||
#define gl_convert (this->gl_data->ConvertSurface)
|
#define gl_convert (this->gl_data->ConvertSurface)
|
||||||
#define gl_copyshadow (this->gl_data->CopyShadow)
|
#define gl_copyshadow (this->gl_data->CopyShadow)
|
||||||
|
#define gl_curformat (this->gl_data->format)
|
||||||
|
#define gl_curdepth (this->gl_data->depth)
|
||||||
|
#define gl_curstencil (this->gl_data->stencil)
|
||||||
|
#define gl_curaccum (this->gl_data->accum)
|
||||||
|
#define gl_curwidth (this->gl_data->width)
|
||||||
|
#define gl_curheight (this->gl_data->height)
|
||||||
|
|
||||||
/* OpenGL functions */
|
/* OpenGL functions */
|
||||||
extern int SDL_AtariGL_Init(_THIS, SDL_Surface *current);
|
extern int SDL_AtariGL_Init(_THIS, SDL_Surface *current);
|
||||||
extern void SDL_AtariGL_Quit(_THIS);
|
extern void SDL_AtariGL_Quit(_THIS, SDL_bool unload);
|
||||||
extern void SDL_AtariGL_InitPointers(_THIS);
|
extern void SDL_AtariGL_InitPointers(_THIS);
|
||||||
|
|
||||||
extern int SDL_AtariGL_LoadLibrary(_THIS, const char *path);
|
extern int SDL_AtariGL_LoadLibrary(_THIS, const char *path);
|
||||||
|
|
|
@ -475,12 +475,6 @@ SDL_Rect **GEM_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
|
||||||
|
|
||||||
static void GEM_FreeBuffers(_THIS)
|
static void GEM_FreeBuffers(_THIS)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_OPENGL
|
|
||||||
if (gl_active) {
|
|
||||||
SDL_AtariGL_Quit(this);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Release buffer */
|
/* Release buffer */
|
||||||
if ( GEM_buffer2 ) {
|
if ( GEM_buffer2 ) {
|
||||||
free( GEM_buffer2 );
|
free( GEM_buffer2 );
|
||||||
|
@ -1047,6 +1041,12 @@ void GEM_VideoQuit(_THIS)
|
||||||
|
|
||||||
GEM_FreeBuffers(this);
|
GEM_FreeBuffers(this);
|
||||||
|
|
||||||
|
#ifdef HAVE_OPENGL
|
||||||
|
if (gl_active) {
|
||||||
|
SDL_AtariGL_Quit(this, SDL_TRUE);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Destroy window */
|
/* Destroy window */
|
||||||
if (GEM_handle>=0) {
|
if (GEM_handle>=0) {
|
||||||
wind_close(GEM_handle);
|
wind_close(GEM_handle);
|
||||||
|
|
|
@ -434,12 +434,6 @@ static void XBIOS_FreeBuffers(_THIS)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
#ifdef HAVE_OPENGL
|
|
||||||
if (gl_active) {
|
|
||||||
SDL_AtariGL_Quit(this);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (i=0;i<2;i++) {
|
for (i=0;i<2;i++) {
|
||||||
if (XBIOS_screensmem[i]!=NULL) {
|
if (XBIOS_screensmem[i]!=NULL) {
|
||||||
Mfree(XBIOS_screensmem[i]);
|
Mfree(XBIOS_screensmem[i]);
|
||||||
|
@ -859,6 +853,13 @@ static void XBIOS_VideoQuit(_THIS)
|
||||||
Vsync();
|
Vsync();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef HAVE_OPENGL
|
||||||
|
if (gl_active) {
|
||||||
|
SDL_AtariGL_Quit(this, SDL_TRUE);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (XBIOS_oldpalette) {
|
if (XBIOS_oldpalette) {
|
||||||
free(XBIOS_oldpalette);
|
free(XBIOS_oldpalette);
|
||||||
XBIOS_oldpalette=NULL;
|
XBIOS_oldpalette=NULL;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue