Skip to content
Permalink
Browse files

Mac OS X: Try to resize--without destroying--the GL context in SetVid…

…eoMode.
  • Loading branch information
icculus committed Nov 4, 2011
1 parent 2a7c512 commit 704dcf7398ec9f97ce2bb8b97a1ee20f604285d5
Showing with 31 additions and 0 deletions.
  1. +31 −0 src/video/quartz/SDL_QuartzVideo.m
@@ -1113,6 +1113,37 @@ other blitting while waiting on the VBL (and hence results in higher framerates)
int height, int bpp, Uint32 flags)
{
const BOOL isLion = IS_LION_OR_LATER(this);

/* Don't throw away the GL context if we can just resize the current one. */
if ( (video_set == SDL_TRUE) && ((flags & (SDL_OPENGL | SDL_FULLSCREEN)) == (current->flags & (SDL_OPENGL | SDL_FULLSCREEN))) && (bpp == current->format->BitsPerPixel) ) {
const NSRect contentRect = NSMakeRect (0, 0, width, height);
if (flags & SDL_FULLSCREEN) {
/* if these fail, we'll try the old way, of tearing everything down. */
const void *newmode = QZ_BestMode(this, bpp, width, height);
if ( newmode != NULL ) {
if ( QZ_SetDisplayMode(this, newmode) != CGDisplayNoErr ) {
QZ_ReleaseDisplayMode(this, newmode);
} else {
QZ_ReleaseDisplayMode(this, mode); /* NULL is okay. */
mode = newmode;
current->w = width;
current->h = height;
[ qz_window setContentSize:contentRect.size ];
[ window_view setFrameSize:contentRect.size ];
[ gl_context update ];
return current;
}
}
} else {
current->w = width;
current->h = height;
[ qz_window setContentSize:contentRect.size ];
[ window_view setFrameSize:contentRect.size ];
[ gl_context update ];
return current;
}
}

current->flags = 0;
current->pixels = NULL;

0 comments on commit 704dcf7

Please sign in to comment.