comparison src/video/windib/SDL_dibvideo.c @ 4143:73e7e7f5b5a1 SDL-1.2

Don't recreate the GL content in windib target if SDL_SetVideoMode() is being called in response to a window resize event...prevents loss of GL state and objects.
author Ryan C. Gordon <icculus@icculus.org>
date Wed, 12 Mar 2008 22:01:48 +0000
parents 568c9b3c0167
children a1b03ba2fcd0
comparison
equal deleted inserted replaced
4142:4433ef2a1802 4143:73e7e7f5b5a1
509 BITMAPINFO *binfo; 509 BITMAPINFO *binfo;
510 HDC hdc; 510 HDC hdc;
511 RECT bounds; 511 RECT bounds;
512 int x, y; 512 int x, y;
513 Uint32 Rmask, Gmask, Bmask; 513 Uint32 Rmask, Gmask, Bmask;
514
515 /*
516 * Special case for OpenGL windows...since the app needs to call
517 * SDL_SetVideoMode() in response to resize events to continue to
518 * function, but WGL handles the GL context details behind the scenes,
519 * there's no sense in tearing the context down just to rebuild it
520 * to what it already was...tearing it down sacrifices your GL state
521 * and uploaded textures. So if we're requesting the same video mode
522 * attributes and the width/height matches the physical window, just
523 * return immediately.
524 */
525 if ( (SDL_Window != NULL) &&
526 (current != NULL) &&
527 (current->flags == flags) &&
528 (current->format->BitsPerPixel == bpp) &&
529 ((flags & SDL_FULLSCREEN) == 0) ) { /* probably not safe for fs */
530 int curwidth, curheight;
531 RECT size;
532
533 /* Get the current position of our window */
534 GetClientRect(SDL_Window, &size);
535
536 curwidth = (size.right - size.left);
537 curheight = (size.bottom - size.top);
538 if ((width == curwidth) && (height == curheight)) {
539 current->w = width;
540 current->h = height;
541 return current; /* we're already good to go. */
542 }
543 }
514 544
515 prev_flags = current->flags; 545 prev_flags = current->flags;
516 546
517 /* Clean up any GL context that may be hanging around */ 547 /* Clean up any GL context that may be hanging around */
518 if ( current->flags & SDL_OPENGL ) { 548 if ( current->flags & SDL_OPENGL ) {