Allow creation of window bigger than visible size SDL-1.2
authorPatrice Mandin <patmandin@gmail.com>
Sun, 27 May 2007 08:53:48 +0000
branchSDL-1.2
changeset 3944d59dacd36696
parent 3943 1d9cd0ff67cc
child 3945 14bec334705f
Allow creation of window bigger than visible size
src/video/gem/SDL_gemvideo.c
     1.1 --- a/src/video/gem/SDL_gemvideo.c	Sat May 26 20:12:58 2007 +0000
     1.2 +++ b/src/video/gem/SDL_gemvideo.c	Sun May 27 08:53:48 2007 +0000
     1.3 @@ -621,30 +621,27 @@
     1.4  SDL_Surface *GEM_SetVideoMode(_THIS, SDL_Surface *current,
     1.5  				int width, int height, int bpp, Uint32 flags)
     1.6  {
     1.7 -	int maxwidth, maxheight;
     1.8  	Uint32 modeflags, screensize;
     1.9  	SDL_bool use_shadow1, use_shadow2;
    1.10  
    1.11 -	/*--- Verify if asked mode can be used ---*/
    1.12 -	if (flags & SDL_FULLSCREEN) {
    1.13 -		maxwidth=VDI_w;
    1.14 -		maxheight=VDI_h;
    1.15 -	} else {
    1.16 -		/* Windowed mode */
    1.17 -		maxwidth=GEM_desk_w;
    1.18 -		maxheight=GEM_desk_h;
    1.19 -	}
    1.20 -
    1.21  	/* width must be multiple of 16, for vro_cpyfm() and c2p_convert() */
    1.22  	if ((width & 15) != 0) {
    1.23  		width = (width | 15) +1;
    1.24  	}
    1.25  
    1.26 -	if ((maxwidth < width) || (maxheight < height) || (VDI_bpp != bpp)) {
    1.27 -		SDL_SetError("Couldn't find requested mode in list");
    1.28 +	/*--- Verify if asked mode can be used ---*/
    1.29 +	if (VDI_bpp != bpp) {
    1.30 +		SDL_SetError("%d bpp mode not supported", bpp);
    1.31  		return(NULL);
    1.32  	}
    1.33  
    1.34 +	if (flags & SDL_FULLSCREEN) {
    1.35 +		if ((VDI_w < width) || (VDI_h < height)) {
    1.36 +			SDL_SetError("%dx%d mode is too large", width, height);
    1.37 +			return(NULL);
    1.38 +		}
    1.39 +	}
    1.40 +
    1.41  	/*--- Allocate the new pixel format for the screen ---*/
    1.42  	if ( ! SDL_ReallocFormat(current, VDI_bpp, VDI_redmask, VDI_greenmask, VDI_bluemask, VDI_alphamask) ) {
    1.43  		SDL_SetError("Couldn't allocate new pixel format for requested mode");
    1.44 @@ -750,8 +747,16 @@
    1.45  			}
    1.46  
    1.47  			/* Center window */
    1.48 -			x2 = GEM_desk_x+((GEM_desk_w-w2)>>1);
    1.49 -			y2 = GEM_desk_y+((GEM_desk_h-h2)>>1);
    1.50 +			x2 = (GEM_desk_w-w2)>>1;
    1.51 +			y2 = (GEM_desk_h-h2)>>1;
    1.52 +			if (x2<0) {
    1.53 +				x2 = 0;
    1.54 +			}
    1.55 +			if (y2<0) {
    1.56 +				y2 = 0;
    1.57 +			}
    1.58 +			x2 += GEM_desk_x;
    1.59 +			y2 += GEM_desk_y;
    1.60  
    1.61  			/* Destroy existing window */
    1.62  			if (GEM_handle >= 0) {