Don't allow video modes larger than the maximum size
authorSam Lantinga <slouken@libsdl.org>
Tue, 24 Feb 2004 07:42:19 +0000
changeset 853dddfc37e1f65
parent 852 2651b6b43840
child 854 59a93320f326
Don't allow video modes larger than the maximum size
src/video/SDL_video.c
     1.1 --- a/src/video/SDL_video.c	Tue Feb 24 06:53:22 2004 +0000
     1.2 +++ b/src/video/SDL_video.c	Tue Feb 24 07:42:19 2004 +0000
     1.3 @@ -359,7 +359,14 @@
     1.4  	{ 0, 32, 16, 15, 24, 8, 0, 0 }
     1.5  };
     1.6  
     1.7 -int SDL_VideoModeOK (int width, int height, int bpp, Uint32 flags) 
     1.8 +
     1.9 +#ifdef macintosh /* MPW optimization bug? */
    1.10 +#define NEGATIVE_ONE 0xFFFFFFFF
    1.11 +#else
    1.12 +#define NEGATIVE_ONE -1
    1.13 +#endif
    1.14 +
    1.15 +int SDL_VideoModeOK (int width, int height, int bpp, Uint32 flags)
    1.16  {
    1.17  	int table, b, i;
    1.18  	int supported;
    1.19 @@ -387,15 +394,18 @@
    1.20  			/* No sizes supported at this bit-depth */
    1.21  			continue;
    1.22  		} else 
    1.23 -#ifdef macintosh /* MPW optimization bug? */
    1.24 -		if ( (sizes == (SDL_Rect **)0xFFFFFFFF) ||
    1.25 -#else
    1.26 -		if ( (sizes == (SDL_Rect **)-1) ||
    1.27 -#endif
    1.28 -		     current_video->handles_any_size ) {
    1.29 +		if (sizes == (SDL_Rect **)NEGATIVE_ONE) {
    1.30  			/* Any size supported at this bit-depth */
    1.31  			supported = 1;
    1.32  			continue;
    1.33 +		} else if (current_video->handles_any_size) {
    1.34 +			/* Driver can center a smaller surface to simulate fullscreen */
    1.35 +			for ( i=0; sizes[i]; ++i ) {
    1.36 +				if ((sizes[i]->w >= width) && (sizes[i]->h >= height)) {
    1.37 +					supported = 1; /* this mode can fit the centered window. */
    1.38 +					break;
    1.39 +				}
    1.40 +			}
    1.41  		} else
    1.42  		for ( i=0; sizes[i]; ++i ) {
    1.43  			if ((sizes[i]->w == width) && (sizes[i]->h == height)) {