src/video/SDL_video.c
changeset 2744 1aede15771d0
parent 2743 453ec0c21f6f
child 2745 587d2b5fb805
     1.1 --- a/src/video/SDL_video.c	Tue Sep 02 20:05:33 2008 +0000
     1.2 +++ b/src/video/SDL_video.c	Tue Sep 02 20:11:06 2008 +0000
     1.3 @@ -39,125 +39,125 @@
     1.4  #ifdef CreateWindow
     1.5  #undef CreateWindow
     1.6  #endif
     1.7 -#endif /* SDL_VIDEO_OPENGL */
     1.8 +#endif				/* SDL_VIDEO_OPENGL */
     1.9  
    1.10  /* Available video drivers */
    1.11  static VideoBootStrap *bootstrap[] = {
    1.12  #if SDL_VIDEO_DRIVER_COCOA
    1.13 -    &COCOA_bootstrap,
    1.14 +	&COCOA_bootstrap,
    1.15  #endif
    1.16  #if SDL_VIDEO_DRIVER_X11
    1.17 -    &X11_bootstrap,
    1.18 +	&X11_bootstrap,
    1.19  #endif
    1.20  #if SDL_VIDEO_DRIVER_NANOX
    1.21 -    &NX_bootstrap,
    1.22 +	&NX_bootstrap,
    1.23  #endif
    1.24  #if SDL_VIDEO_DRIVER_IPOD
    1.25 -    &iPod_bootstrap,
    1.26 +	&iPod_bootstrap,
    1.27  #endif
    1.28  #if SDL_VIDEO_DRIVER_WSCONS
    1.29 -    &WSCONS_bootstrap,
    1.30 +	&WSCONS_bootstrap,
    1.31  #endif
    1.32  #if SDL_VIDEO_DRIVER_FBCON
    1.33 -    &FBCON_bootstrap,
    1.34 +	&FBCON_bootstrap,
    1.35  #endif
    1.36  #if SDL_VIDEO_DRIVER_DIRECTFB
    1.37 -    &DirectFB_bootstrap,
    1.38 +	&DirectFB_bootstrap,
    1.39  #endif
    1.40  #if SDL_VIDEO_DRIVER_PS2GS
    1.41 -    &PS2GS_bootstrap,
    1.42 +	&PS2GS_bootstrap,
    1.43  #endif
    1.44  #if SDL_VIDEO_DRIVER_VGL
    1.45 -    &VGL_bootstrap,
    1.46 +	&VGL_bootstrap,
    1.47  #endif
    1.48  #if SDL_VIDEO_DRIVER_SVGALIB
    1.49 -    &SVGALIB_bootstrap,
    1.50 +	&SVGALIB_bootstrap,
    1.51  #endif
    1.52  #if SDL_VIDEO_DRIVER_GAPI
    1.53 -    &GAPI_bootstrap,
    1.54 +	&GAPI_bootstrap,
    1.55  #endif
    1.56  #if SDL_VIDEO_DRIVER_WIN32
    1.57 -    &WIN32_bootstrap,
    1.58 +	&WIN32_bootstrap,
    1.59  #endif
    1.60  #if SDL_VIDEO_DRIVER_BWINDOW
    1.61 -    &BWINDOW_bootstrap,
    1.62 +	&BWINDOW_bootstrap,
    1.63  #endif
    1.64  #if SDL_VIDEO_DRIVER_PHOTON
    1.65 -    &ph_bootstrap,
    1.66 +	&ph_bootstrap,
    1.67  #endif
    1.68  #if SDL_VIDEO_DRIVER_EPOC
    1.69 -    &EPOC_bootstrap,
    1.70 +	&EPOC_bootstrap,
    1.71  #endif
    1.72  #if SDL_VIDEO_DRIVER_XBIOS
    1.73 -    &XBIOS_bootstrap,
    1.74 +	&XBIOS_bootstrap,
    1.75  #endif
    1.76  #if SDL_VIDEO_DRIVER_GEM
    1.77 -    &GEM_bootstrap,
    1.78 +	&GEM_bootstrap,
    1.79  #endif
    1.80  #if SDL_VIDEO_DRIVER_DC
    1.81 -    &DC_bootstrap,
    1.82 +	&DC_bootstrap,
    1.83  #endif
    1.84  #if SDL_VIDEO_DRIVER_RISCOS
    1.85 -    &RISCOS_bootstrap,
    1.86 +	&RISCOS_bootstrap,
    1.87  #endif
    1.88  #if SDL_VIDEO_DRIVER_OS2FS
    1.89 -    &OS2FSLib_bootstrap,
    1.90 +	&OS2FSLib_bootstrap,
    1.91  #endif
    1.92  #if SDL_VIDEO_DRIVER_NDS
    1.93 -    &NDS_bootstrap,
    1.94 +	&NDS_bootstrap,
    1.95  #endif
    1.96  #if SDL_VIDEO_DRIVER_DUMMY
    1.97 -    &DUMMY_bootstrap,
    1.98 +	&DUMMY_bootstrap,
    1.99  #endif
   1.100 -    NULL
   1.101 +	NULL
   1.102  };
   1.103  
   1.104  static SDL_VideoDevice *_this = NULL;
   1.105  
   1.106  /* Various local functions */
   1.107 -int SDL_VideoInit(const char *driver_name, Uint32 flags);
   1.108 -void SDL_VideoQuit(void);
   1.109 +int             SDL_VideoInit(const char *driver_name, Uint32 flags);
   1.110 +void            SDL_VideoQuit(void);
   1.111  
   1.112  static int
   1.113  cmpmodes(const void *A, const void *B)
   1.114  {
   1.115 -    SDL_DisplayMode a = *(const SDL_DisplayMode *) A;
   1.116 -    SDL_DisplayMode b = *(const SDL_DisplayMode *) B;
   1.117 +	SDL_DisplayMode a = *(const SDL_DisplayMode *) A;
   1.118 +	SDL_DisplayMode b = *(const SDL_DisplayMode *) B;
   1.119  
   1.120 -    if (a.w != b.w) {
   1.121 -        return b.w - a.w;
   1.122 -    }
   1.123 -    if (a.h != b.h) {
   1.124 -        return b.h - a.h;
   1.125 -    }
   1.126 -    if (SDL_BITSPERPIXEL(a.format) != SDL_BITSPERPIXEL(b.format)) {
   1.127 -        return SDL_BITSPERPIXEL(b.format) - SDL_BITSPERPIXEL(a.format);
   1.128 -    }
   1.129 -    if (a.refresh_rate != b.refresh_rate) {
   1.130 -        return b.refresh_rate - a.refresh_rate;
   1.131 -    }
   1.132 -    return 0;
   1.133 +	if (a.w != b.w) {
   1.134 +		return b.w - a.w;
   1.135 +	}
   1.136 +	if (a.h != b.h) {
   1.137 +		return b.h - a.h;
   1.138 +	}
   1.139 +	if (SDL_BITSPERPIXEL(a.format) != SDL_BITSPERPIXEL(b.format)) {
   1.140 +		return SDL_BITSPERPIXEL(b.format) - SDL_BITSPERPIXEL(a.format);
   1.141 +	}
   1.142 +	if (a.refresh_rate != b.refresh_rate) {
   1.143 +		return b.refresh_rate - a.refresh_rate;
   1.144 +	}
   1.145 +	return 0;
   1.146  }
   1.147  
   1.148  static void
   1.149  SDL_UninitializedVideo()
   1.150  {
   1.151 -    SDL_SetError("Video subsystem has not been initialized");
   1.152 +	SDL_SetError("Video subsystem has not been initialized");
   1.153  }
   1.154  
   1.155  int
   1.156  SDL_GetNumVideoDrivers(void)
   1.157  {
   1.158 -    return SDL_arraysize(bootstrap) - 1;
   1.159 +	return SDL_arraysize(bootstrap) - 1;
   1.160  }
   1.161  
   1.162 -const char *
   1.163 +const char     *
   1.164  SDL_GetVideoDriver(int index)
   1.165  {
   1.166 -    if (index >= 0 && index < SDL_GetNumVideoDrivers()) {
   1.167 -        return bootstrap[index]->name;
   1.168 -    }
   1.169 -    return NULL;
   1.170 +	if (index >= 0 && index < SDL_GetNumVideoDrivers()) {
   1.171 +		return bootstrap[index]->name;
   1.172 +	}
   1.173 +	return NULL;
   1.174  }
   1.175  
   1.176  /*
   1.177 @@ -166,1077 +166,1040 @@
   1.178  int
   1.179  SDL_VideoInit(const char *driver_name, Uint32 flags)
   1.180  {
   1.181 -    SDL_VideoDevice *video;
   1.182 -    int index;
   1.183 -    int i;
   1.184 +	SDL_VideoDevice *video;
   1.185 +	int             index;
   1.186 +	int             i;
   1.187  
   1.188 -    /* Toggle the event thread flags, based on OS requirements */
   1.189 +	/* Toggle the event thread flags, based on OS requirements */
   1.190  #if defined(MUST_THREAD_EVENTS)
   1.191 -    flags |= SDL_INIT_EVENTTHREAD;
   1.192 +	flags |= SDL_INIT_EVENTTHREAD;
   1.193  #elif defined(CANT_THREAD_EVENTS)
   1.194 -    if ((flags & SDL_INIT_EVENTTHREAD) == SDL_INIT_EVENTTHREAD) {
   1.195 -        SDL_SetError("OS doesn't support threaded events");
   1.196 -        return -1;
   1.197 -    }
   1.198 +	if ((flags & SDL_INIT_EVENTTHREAD) == SDL_INIT_EVENTTHREAD) {
   1.199 +		SDL_SetError("OS doesn't support threaded events");
   1.200 +		return -1;
   1.201 +	}
   1.202  #endif
   1.203  
   1.204 -    /* Start the event loop */
   1.205 -    if (SDL_StartEventLoop(flags) < 0) {
   1.206 -        return -1;
   1.207 -    }
   1.208 -
   1.209 -    /* Check to make sure we don't overwrite '_this' */
   1.210 -    if (_this != NULL) {
   1.211 -        SDL_VideoQuit();
   1.212 -    }
   1.213 -
   1.214 -    /* Select the proper video driver */
   1.215 -    index = 0;
   1.216 -    video = NULL;
   1.217 -    if (driver_name == NULL) {
   1.218 -        driver_name = SDL_getenv("SDL_VIDEODRIVER");
   1.219 -    }
   1.220 -    if (driver_name != NULL) {
   1.221 -        for (i = 0; bootstrap[i]; ++i) {
   1.222 -            if (SDL_strcasecmp(bootstrap[i]->name, driver_name) == 0) {
   1.223 -                if (bootstrap[i]->available()) {
   1.224 -                    video = bootstrap[i]->create(index);
   1.225 -                }
   1.226 -                break;
   1.227 -            }
   1.228 -        }
   1.229 -    } else {
   1.230 -        for (i = 0; bootstrap[i]; ++i) {
   1.231 -            if (bootstrap[i]->available()) {
   1.232 -                video = bootstrap[i]->create(index);
   1.233 -                if (video != NULL) {
   1.234 -                    break;
   1.235 -                }
   1.236 -            }
   1.237 -        }
   1.238 -    }
   1.239 -    if (video == NULL) {
   1.240 -        if (driver_name) {
   1.241 -            SDL_SetError("%s not available", driver_name);
   1.242 -        } else {
   1.243 -            SDL_SetError("No available video device");
   1.244 -        }
   1.245 -        return -1;
   1.246 -    }
   1.247 -    _this = video;
   1.248 -    _this->name = bootstrap[i]->name;
   1.249 -    _this->next_object_id = 1;
   1.250 +	/* Start the event loop */
   1.251 +	if (SDL_StartEventLoop(flags) < 0) {
   1.252 +		return -1;
   1.253 +	}
   1.254 +	/* Check to make sure we don't overwrite '_this' */
   1.255 +	if (_this != NULL) {
   1.256 +		SDL_VideoQuit();
   1.257 +	}
   1.258 +	/* Select the proper video driver */
   1.259 +	index = 0;
   1.260 +	video = NULL;
   1.261 +	if (driver_name == NULL) {
   1.262 +		driver_name = SDL_getenv("SDL_VIDEODRIVER");
   1.263 +	}
   1.264 +	if (driver_name != NULL) {
   1.265 +		for (i = 0; bootstrap[i]; ++i) {
   1.266 +			if (SDL_strcasecmp(bootstrap[i]->name, driver_name) == 0) {
   1.267 +				if (bootstrap[i]->available()) {
   1.268 +					video = bootstrap[i]->create(index);
   1.269 +				}
   1.270 +				break;
   1.271 +			}
   1.272 +		}
   1.273 +	} else {
   1.274 +		for (i = 0; bootstrap[i]; ++i) {
   1.275 +			if (bootstrap[i]->available()) {
   1.276 +				video = bootstrap[i]->create(index);
   1.277 +				if (video != NULL) {
   1.278 +					break;
   1.279 +				}
   1.280 +			}
   1.281 +		}
   1.282 +	}
   1.283 +	if (video == NULL) {
   1.284 +		if (driver_name) {
   1.285 +			SDL_SetError("%s not available", driver_name);
   1.286 +		} else {
   1.287 +			SDL_SetError("No available video device");
   1.288 +		}
   1.289 +		return -1;
   1.290 +	}
   1.291 +	_this = video;
   1.292 +	_this->name = bootstrap[i]->name;
   1.293 +	_this->next_object_id = 1;
   1.294  
   1.295  
   1.296 -    /* Set some very sane GL defaults */
   1.297 -    _this->gl_config.driver_loaded = 0;
   1.298 -    _this->gl_config.dll_handle = NULL;
   1.299 -    _this->gl_config.red_size = 3;
   1.300 -    _this->gl_config.green_size = 3;
   1.301 -    _this->gl_config.blue_size = 2;
   1.302 -    _this->gl_config.alpha_size = 0;
   1.303 -    _this->gl_config.buffer_size = 0;
   1.304 -    _this->gl_config.depth_size = 16;
   1.305 -    _this->gl_config.stencil_size = 0;
   1.306 -    _this->gl_config.double_buffer = 1;
   1.307 -    _this->gl_config.accum_red_size = 0;
   1.308 -    _this->gl_config.accum_green_size = 0;
   1.309 -    _this->gl_config.accum_blue_size = 0;
   1.310 -    _this->gl_config.accum_alpha_size = 0;
   1.311 -    _this->gl_config.stereo = 0;
   1.312 -    _this->gl_config.multisamplebuffers = 0;
   1.313 -    _this->gl_config.multisamplesamples = 0;
   1.314 -    _this->gl_config.accelerated = -1;  /* not known, don't set */
   1.315 +	/* Set some very sane GL defaults */
   1.316 +	_this->gl_config.driver_loaded = 0;
   1.317 +	_this->gl_config.dll_handle = NULL;
   1.318 +	_this->gl_config.red_size = 3;
   1.319 +	_this->gl_config.green_size = 3;
   1.320 +	_this->gl_config.blue_size = 2;
   1.321 +	_this->gl_config.alpha_size = 0;
   1.322 +	_this->gl_config.buffer_size = 0;
   1.323 +	_this->gl_config.depth_size = 16;
   1.324 +	_this->gl_config.stencil_size = 0;
   1.325 +	_this->gl_config.double_buffer = 1;
   1.326 +	_this->gl_config.accum_red_size = 0;
   1.327 +	_this->gl_config.accum_green_size = 0;
   1.328 +	_this->gl_config.accum_blue_size = 0;
   1.329 +	_this->gl_config.accum_alpha_size = 0;
   1.330 +	_this->gl_config.stereo = 0;
   1.331 +	_this->gl_config.multisamplebuffers = 0;
   1.332 +	_this->gl_config.multisamplesamples = 0;
   1.333 +	_this->gl_config.accelerated = -1;	/* not known, don't set */
   1.334  
   1.335 -    /* Initialize the video subsystem */
   1.336 -    if (_this->VideoInit(_this) < 0) {
   1.337 -        SDL_VideoQuit();
   1.338 -        return -1;
   1.339 -    }
   1.340 -
   1.341 -    /* Make sure some displays were added */
   1.342 -    if (_this->num_displays == 0) {
   1.343 -        SDL_SetError("The video driver did not add any displays");
   1.344 -        SDL_VideoQuit();
   1.345 -        return (-1);
   1.346 -    }
   1.347 +	/* Initialize the video subsystem */
   1.348 +	if (_this->VideoInit(_this) < 0) {
   1.349 +		SDL_VideoQuit();
   1.350 +		return -1;
   1.351 +	}
   1.352 +	/* Make sure some displays were added */
   1.353 +	if (_this->num_displays == 0) {
   1.354 +		SDL_SetError("The video driver did not add any displays");
   1.355 +		SDL_VideoQuit();
   1.356 +		return (-1);
   1.357 +	}
   1.358 +	/* The software renderer is always available */
   1.359 +	for (i = 0; i < _this->num_displays; ++i) {
   1.360 +#if SDL_VIDEO_RENDER_OGL
   1.361 +		SDL_AddRenderDriver(i, &GL_RenderDriver);
   1.362 +#endif
   1.363 +		if (_this->displays[i].num_render_drivers > 0) {
   1.364 +			SDL_AddRenderDriver(i, &SW_RenderDriver);
   1.365 +		}
   1.366 +	}
   1.367  
   1.368 -    /* The software renderer is always available */
   1.369 -    for (i = 0; i < _this->num_displays; ++i) {
   1.370 -#if SDL_VIDEO_RENDER_OGL
   1.371 -        SDL_AddRenderDriver(i, &GL_RenderDriver);
   1.372 -#endif
   1.373 -        if (_this->displays[i].num_render_drivers > 0) {
   1.374 -            SDL_AddRenderDriver(i, &SW_RenderDriver);
   1.375 -        }
   1.376 -    }
   1.377 -
   1.378 -    /* We're ready to go! */
   1.379 -    return 0;
   1.380 +	/* We're ready to go! */
   1.381 +	return 0;
   1.382  }
   1.383  
   1.384 -const char *
   1.385 +const char     *
   1.386  SDL_GetCurrentVideoDriver()
   1.387  {
   1.388 -    if (!_this) {
   1.389 -        SDL_UninitializedVideo();
   1.390 -        return NULL;
   1.391 -    }
   1.392 -    return _this->name;
   1.393 +	if (!_this) {
   1.394 +		SDL_UninitializedVideo();
   1.395 +		return NULL;
   1.396 +	}
   1.397 +	return _this->name;
   1.398  }
   1.399  
   1.400  SDL_VideoDevice *
   1.401  SDL_GetVideoDevice()
   1.402  {
   1.403 -    return _this;
   1.404 +	return _this;
   1.405  }
   1.406  
   1.407  int
   1.408  SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode)
   1.409  {
   1.410 -    SDL_VideoDisplay display;
   1.411 +	SDL_VideoDisplay display;
   1.412  
   1.413 -    SDL_zero(display);
   1.414 -    if (desktop_mode) {
   1.415 -        display.desktop_mode = *desktop_mode;
   1.416 -    }
   1.417 -    display.current_mode = display.desktop_mode;
   1.418 +	SDL_zero(display);
   1.419 +	if (desktop_mode) {
   1.420 +		display.desktop_mode = *desktop_mode;
   1.421 +	}
   1.422 +	display.current_mode = display.desktop_mode;
   1.423  
   1.424 -    return SDL_AddVideoDisplay(&display);
   1.425 +	return SDL_AddVideoDisplay(&display);
   1.426  }
   1.427  
   1.428  int
   1.429  SDL_AddVideoDisplay(const SDL_VideoDisplay * display)
   1.430  {
   1.431 -    SDL_VideoDisplay *displays;
   1.432 -    int index = -1;
   1.433 +	SDL_VideoDisplay *displays;
   1.434 +	int             index = -1;
   1.435  
   1.436 -    displays =
   1.437 -        SDL_realloc(_this->displays,
   1.438 -                    (_this->num_displays + 1) * sizeof(*displays));
   1.439 -    if (displays) {
   1.440 -        index = _this->num_displays++;
   1.441 -        displays[index] = *display;
   1.442 -        displays[index].device = _this;
   1.443 -        _this->displays = displays;
   1.444 -    } else {
   1.445 -        SDL_OutOfMemory();
   1.446 -    }
   1.447 -    return index;
   1.448 +	displays =
   1.449 +		SDL_realloc(_this->displays,
   1.450 +			    (_this->num_displays + 1) * sizeof(*displays));
   1.451 +	if (displays) {
   1.452 +		index = _this->num_displays++;
   1.453 +		displays[index] = *display;
   1.454 +		displays[index].device = _this;
   1.455 +		_this->displays = displays;
   1.456 +	} else {
   1.457 +		SDL_OutOfMemory();
   1.458 +	}
   1.459 +	return index;
   1.460  }
   1.461  
   1.462  int
   1.463  SDL_GetNumVideoDisplays(void)
   1.464  {
   1.465 -    if (!_this) {
   1.466 -        SDL_UninitializedVideo();
   1.467 -        return 0;
   1.468 -    }
   1.469 -    return _this->num_displays;
   1.470 +	if (!_this) {
   1.471 +		SDL_UninitializedVideo();
   1.472 +		return 0;
   1.473 +	}
   1.474 +	return _this->num_displays;
   1.475  }
   1.476  
   1.477  int
   1.478  SDL_SelectVideoDisplay(int index)
   1.479  {
   1.480 -    if (!_this) {
   1.481 -        SDL_UninitializedVideo();
   1.482 -        return (-1);
   1.483 -    }
   1.484 -    if (index < 0 || index >= _this->num_displays) {
   1.485 -        SDL_SetError("index must be in the range 0 - %d",
   1.486 -                     _this->num_displays - 1);
   1.487 -        return -1;
   1.488 -    }
   1.489 -    _this->current_display = index;
   1.490 -    return 0;
   1.491 +	if (!_this) {
   1.492 +		SDL_UninitializedVideo();
   1.493 +		return (-1);
   1.494 +	}
   1.495 +	if (index < 0 || index >= _this->num_displays) {
   1.496 +		SDL_SetError("index must be in the range 0 - %d",
   1.497 +			     _this->num_displays - 1);
   1.498 +		return -1;
   1.499 +	}
   1.500 +	_this->current_display = index;
   1.501 +	return 0;
   1.502  }
   1.503  
   1.504  int
   1.505  SDL_GetCurrentVideoDisplay(void)
   1.506  {
   1.507 -    if (!_this) {
   1.508 -        SDL_UninitializedVideo();
   1.509 -        return (-1);
   1.510 -    }
   1.511 -    return _this->current_display;
   1.512 +	if (!_this) {
   1.513 +		SDL_UninitializedVideo();
   1.514 +		return (-1);
   1.515 +	}
   1.516 +	return _this->current_display;
   1.517  }
   1.518  
   1.519  SDL_bool
   1.520  SDL_AddDisplayMode(int displayIndex, const SDL_DisplayMode * mode)
   1.521  {
   1.522 -    SDL_VideoDisplay *display = &_this->displays[displayIndex];
   1.523 -    SDL_DisplayMode *modes;
   1.524 -    int i, nmodes;
   1.525 +	SDL_VideoDisplay *display = &_this->displays[displayIndex];
   1.526 +	SDL_DisplayMode *modes;
   1.527 +	int             i, nmodes;
   1.528  
   1.529 -    /* Make sure we don't already have the mode in the list */
   1.530 -    modes = display->display_modes;
   1.531 -    nmodes = display->num_display_modes;
   1.532 -    for (i = nmodes; i--;) {
   1.533 -        if (SDL_memcmp(mode, &modes[i], sizeof(*mode)) == 0) {
   1.534 -            return SDL_FALSE;
   1.535 -        }
   1.536 -    }
   1.537 +	/* Make sure we don't already have the mode in the list */
   1.538 +	modes = display->display_modes;
   1.539 +	nmodes = display->num_display_modes;
   1.540 +	for (i = nmodes; i--;) {
   1.541 +		if (SDL_memcmp(mode, &modes[i], sizeof(*mode)) == 0) {
   1.542 +			return SDL_FALSE;
   1.543 +		}
   1.544 +	}
   1.545  
   1.546 -    /* Go ahead and add the new mode */
   1.547 -    if (nmodes == display->max_display_modes) {
   1.548 -        modes =
   1.549 -            SDL_realloc(modes,
   1.550 -                        (display->max_display_modes + 32) * sizeof(*modes));
   1.551 -        if (!modes) {
   1.552 -            return SDL_FALSE;
   1.553 -        }
   1.554 -        display->display_modes = modes;
   1.555 -        display->max_display_modes += 32;
   1.556 -    }
   1.557 -    modes[nmodes] = *mode;
   1.558 -    display->num_display_modes++;
   1.559 +	/* Go ahead and add the new mode */
   1.560 +	if (nmodes == display->max_display_modes) {
   1.561 +		modes =
   1.562 +			SDL_realloc(modes,
   1.563 +			(display->max_display_modes + 32) * sizeof(*modes));
   1.564 +		if (!modes) {
   1.565 +			return SDL_FALSE;
   1.566 +		}
   1.567 +		display->display_modes = modes;
   1.568 +		display->max_display_modes += 32;
   1.569 +	}
   1.570 +	modes[nmodes] = *mode;
   1.571 +	display->num_display_modes++;
   1.572  
   1.573 -    return SDL_TRUE;
   1.574 +	return SDL_TRUE;
   1.575  }
   1.576  
   1.577  int
   1.578  SDL_GetNumDisplayModes()
   1.579  {
   1.580 -    if (_this) {
   1.581 -        SDL_VideoDisplay *display = &SDL_CurrentDisplay;
   1.582 -        if (!display->num_display_modes && _this->GetDisplayModes) {
   1.583 -            _this->GetDisplayModes(_this);
   1.584 -            SDL_qsort(display->display_modes, display->num_display_modes,
   1.585 -                      sizeof(SDL_DisplayMode), cmpmodes);
   1.586 -        }
   1.587 -        return display->num_display_modes;
   1.588 -    }
   1.589 -    return 0;
   1.590 +	if (_this) {
   1.591 +		SDL_VideoDisplay *display = &SDL_CurrentDisplay;
   1.592 +		if (!display->num_display_modes && _this->GetDisplayModes) {
   1.593 +			_this->GetDisplayModes(_this);
   1.594 +			SDL_qsort(display->display_modes, display->num_display_modes,
   1.595 +				  sizeof(SDL_DisplayMode), cmpmodes);
   1.596 +		}
   1.597 +		return display->num_display_modes;
   1.598 +	}
   1.599 +	return 0;
   1.600  }
   1.601  
   1.602  int
   1.603  SDL_GetDisplayMode(int index, SDL_DisplayMode * mode)
   1.604  {
   1.605 -    if (index < 0 || index >= SDL_GetNumDisplayModes()) {
   1.606 -        SDL_SetError("index must be in the range of 0 - %d",
   1.607 -                     SDL_GetNumDisplayModes() - 1);
   1.608 -        return -1;
   1.609 -    }
   1.610 -    if (mode) {
   1.611 -        *mode = SDL_CurrentDisplay.display_modes[index];
   1.612 -    }
   1.613 -    return 0;
   1.614 +	if (index < 0 || index >= SDL_GetNumDisplayModes()) {
   1.615 +		SDL_SetError("index must be in the range of 0 - %d",
   1.616 +			     SDL_GetNumDisplayModes() - 1);
   1.617 +		return -1;
   1.618 +	}
   1.619 +	if (mode) {
   1.620 +		*mode = SDL_CurrentDisplay.display_modes[index];
   1.621 +	}
   1.622 +	return 0;
   1.623  }
   1.624  
   1.625  int
   1.626  SDL_GetDesktopDisplayMode(SDL_DisplayMode * mode)
   1.627  {
   1.628 -    if (!_this) {
   1.629 -        SDL_UninitializedVideo();
   1.630 -        return -1;
   1.631 -    }
   1.632 -    if (mode) {
   1.633 -        *mode = SDL_CurrentDisplay.desktop_mode;
   1.634 -    }
   1.635 -    return 0;
   1.636 +	if (!_this) {
   1.637 +		SDL_UninitializedVideo();
   1.638 +		return -1;
   1.639 +	}
   1.640 +	if (mode) {
   1.641 +		*mode = SDL_CurrentDisplay.desktop_mode;
   1.642 +	}
   1.643 +	return 0;
   1.644  }
   1.645  
   1.646  int
   1.647  SDL_GetCurrentDisplayMode(SDL_DisplayMode * mode)
   1.648  {
   1.649 -    if (!_this) {
   1.650 -        SDL_UninitializedVideo();
   1.651 -        return -1;
   1.652 -    }
   1.653 -    if (mode) {
   1.654 -        *mode = SDL_CurrentDisplay.current_mode;
   1.655 -    }
   1.656 -    return 0;
   1.657 +	if (!_this) {
   1.658 +		SDL_UninitializedVideo();
   1.659 +		return -1;
   1.660 +	}
   1.661 +	if (mode) {
   1.662 +		*mode = SDL_CurrentDisplay.current_mode;
   1.663 +	}
   1.664 +	return 0;
   1.665  }
   1.666  
   1.667  SDL_DisplayMode *
   1.668  SDL_GetClosestDisplayMode(const SDL_DisplayMode * mode,
   1.669 -                          SDL_DisplayMode * closest)
   1.670 +			  SDL_DisplayMode * closest)
   1.671  {
   1.672 -    Uint32 target_format;
   1.673 -    int target_refresh_rate;
   1.674 -    int i;
   1.675 -    SDL_DisplayMode *current, *match;
   1.676 -
   1.677 -    if (!_this || !mode || !closest) {
   1.678 -        return NULL;
   1.679 -    }
   1.680 +	Uint32          target_format;
   1.681 +	int             target_refresh_rate;
   1.682 +	int             i;
   1.683 +	SDL_DisplayMode *current, *match;
   1.684  
   1.685 -    /* Default to the desktop format */
   1.686 -    if (mode->format) {
   1.687 -        target_format = mode->format;
   1.688 -    } else {
   1.689 -        target_format = SDL_CurrentDisplay.desktop_mode.format;
   1.690 -    }
   1.691 +	if (!_this || !mode || !closest) {
   1.692 +		return NULL;
   1.693 +	}
   1.694 +	/* Default to the desktop format */
   1.695 +	if (mode->format) {
   1.696 +		target_format = mode->format;
   1.697 +	} else {
   1.698 +		target_format = SDL_CurrentDisplay.desktop_mode.format;
   1.699 +	}
   1.700  
   1.701 -    /* Default to the desktop refresh rate */
   1.702 -    if (mode->refresh_rate) {
   1.703 -        target_refresh_rate = mode->refresh_rate;
   1.704 -    } else {
   1.705 -        target_refresh_rate = SDL_CurrentDisplay.desktop_mode.refresh_rate;
   1.706 -    }
   1.707 +	/* Default to the desktop refresh rate */
   1.708 +	if (mode->refresh_rate) {
   1.709 +		target_refresh_rate = mode->refresh_rate;
   1.710 +	} else {
   1.711 +		target_refresh_rate = SDL_CurrentDisplay.desktop_mode.refresh_rate;
   1.712 +	}
   1.713  
   1.714 -    match = NULL;
   1.715 -    for (i = 0; i < SDL_GetNumDisplayModes(); ++i) {
   1.716 -        current = &SDL_CurrentDisplay.display_modes[i];
   1.717 +	match = NULL;
   1.718 +	for (i = 0; i < SDL_GetNumDisplayModes(); ++i) {
   1.719 +		current = &SDL_CurrentDisplay.display_modes[i];
   1.720  
   1.721 -        if ((current->w && current->h) &&
   1.722 -            (current->w < mode->w || current->h < mode->h)) {
   1.723 -            /* Out of sorted modes large enough here */
   1.724 -            break;
   1.725 -        }
   1.726 -        if (!match || current->w < match->w || current->h < match->h) {
   1.727 -            match = current;
   1.728 -            continue;
   1.729 -        }
   1.730 -        if (current->format != match->format) {
   1.731 -            /* Sorted highest depth to lowest */
   1.732 -            if (current->format == target_format ||
   1.733 -                (SDL_BITSPERPIXEL(current->format) >=
   1.734 -                 SDL_BITSPERPIXEL(target_format)
   1.735 -                 && SDL_PIXELTYPE(current->format) ==
   1.736 -                 SDL_PIXELTYPE(target_format))) {
   1.737 -                match = current;
   1.738 -            }
   1.739 -            continue;
   1.740 -        }
   1.741 -        if (current->refresh_rate != match->refresh_rate) {
   1.742 -            /* Sorted highest refresh to lowest */
   1.743 -            if (current->refresh_rate >= target_refresh_rate) {
   1.744 -                match = current;
   1.745 -            }
   1.746 -        }
   1.747 -    }
   1.748 -    if (match) {
   1.749 -        if (match->format) {
   1.750 -            closest->format = match->format;
   1.751 -        } else {
   1.752 -            closest->format = mode->format;
   1.753 -        }
   1.754 -        if (match->w && match->h) {
   1.755 -            closest->w = match->w;
   1.756 -            closest->h = match->h;
   1.757 -        } else {
   1.758 -            closest->w = mode->w;
   1.759 -            closest->h = mode->h;
   1.760 -        }
   1.761 -        if (match->refresh_rate) {
   1.762 -            closest->refresh_rate = match->refresh_rate;
   1.763 -        } else {
   1.764 -            closest->refresh_rate = mode->refresh_rate;
   1.765 -        }
   1.766 -        closest->driverdata = match->driverdata;
   1.767 +		if ((current->w && current->h) &&
   1.768 +		    (current->w < mode->w || current->h < mode->h)) {
   1.769 +			/* Out of sorted modes large enough here */
   1.770 +			break;
   1.771 +		}
   1.772 +		if (!match || current->w < match->w || current->h < match->h) {
   1.773 +			match = current;
   1.774 +			continue;
   1.775 +		}
   1.776 +		if (current->format != match->format) {
   1.777 +			/* Sorted highest depth to lowest */
   1.778 +			if (current->format == target_format ||
   1.779 +			    (SDL_BITSPERPIXEL(current->format) >=
   1.780 +			     SDL_BITSPERPIXEL(target_format)
   1.781 +			     && SDL_PIXELTYPE(current->format) ==
   1.782 +			     SDL_PIXELTYPE(target_format))) {
   1.783 +				match = current;
   1.784 +			}
   1.785 +			continue;
   1.786 +		}
   1.787 +		if (current->refresh_rate != match->refresh_rate) {
   1.788 +			/* Sorted highest refresh to lowest */
   1.789 +			if (current->refresh_rate >= target_refresh_rate) {
   1.790 +				match = current;
   1.791 +			}
   1.792 +		}
   1.793 +	}
   1.794 +	if (match) {
   1.795 +		if (match->format) {
   1.796 +			closest->format = match->format;
   1.797 +		} else {
   1.798 +			closest->format = mode->format;
   1.799 +		}
   1.800 +		if (match->w && match->h) {
   1.801 +			closest->w = match->w;
   1.802 +			closest->h = match->h;
   1.803 +		} else {
   1.804 +			closest->w = mode->w;
   1.805 +			closest->h = mode->h;
   1.806 +		}
   1.807 +		if (match->refresh_rate) {
   1.808 +			closest->refresh_rate = match->refresh_rate;
   1.809 +		} else {
   1.810 +			closest->refresh_rate = mode->refresh_rate;
   1.811 +		}
   1.812 +		closest->driverdata = match->driverdata;
   1.813  
   1.814 -        /* Pick some reasonable defaults if the app and driver don't care */
   1.815 -        if (!closest->format) {
   1.816 -            closest->format = SDL_PIXELFORMAT_RGB888;
   1.817 -        }
   1.818 -        if (!closest->w) {
   1.819 -            closest->w = 640;
   1.820 -        }
   1.821 -        if (!closest->h) {
   1.822 -            closest->h = 480;
   1.823 -        }
   1.824 -        return closest;
   1.825 -    }
   1.826 -    return NULL;
   1.827 +		/*
   1.828 +		 * Pick some reasonable defaults if the app and driver don't
   1.829 +		 * care
   1.830 +		 */
   1.831 +		if (!closest->format) {
   1.832 +			closest->format = SDL_PIXELFORMAT_RGB888;
   1.833 +		}
   1.834 +		if (!closest->w) {
   1.835 +			closest->w = 640;
   1.836 +		}
   1.837 +		if (!closest->h) {
   1.838 +			closest->h = 480;
   1.839 +		}
   1.840 +		return closest;
   1.841 +	}
   1.842 +	return NULL;
   1.843  }
   1.844  
   1.845  int
   1.846  SDL_SetDisplayMode(const SDL_DisplayMode * mode)
   1.847  {
   1.848 -    SDL_VideoDisplay *display;
   1.849 -    SDL_DisplayMode display_mode;
   1.850 -    SDL_DisplayMode current_mode;
   1.851 -    int i, ncolors;
   1.852 -
   1.853 -    if (!_this) {
   1.854 -        SDL_UninitializedVideo();
   1.855 -        return -1;
   1.856 -    }
   1.857 -
   1.858 -    display = &SDL_CurrentDisplay;
   1.859 -    if (!mode) {
   1.860 -        mode = &display->desktop_mode;
   1.861 -    }
   1.862 -    display_mode = *mode;
   1.863 +	SDL_VideoDisplay *display;
   1.864 +	SDL_DisplayMode display_mode;
   1.865 +	SDL_DisplayMode current_mode;
   1.866 +	int             i, ncolors;
   1.867  
   1.868 -    /* Default to the current mode */
   1.869 -    if (!display_mode.format) {
   1.870 -        display_mode.format = display->current_mode.format;
   1.871 -    }
   1.872 -    if (!display_mode.w) {
   1.873 -        display_mode.w = display->current_mode.w;
   1.874 -    }
   1.875 -    if (!display_mode.h) {
   1.876 -        display_mode.h = display->current_mode.h;
   1.877 -    }
   1.878 -    if (!display_mode.refresh_rate) {
   1.879 -        display_mode.refresh_rate = display->current_mode.refresh_rate;
   1.880 -    }
   1.881 -
   1.882 -    /* Get a good video mode, the closest one possible */
   1.883 -    if (!SDL_GetClosestDisplayMode(&display_mode, &display_mode)) {
   1.884 -        SDL_SetError("No video mode large enough for %dx%d",
   1.885 -                     display_mode.w, display_mode.h);
   1.886 -        return -1;
   1.887 -    }
   1.888 +	if (!_this) {
   1.889 +		SDL_UninitializedVideo();
   1.890 +		return -1;
   1.891 +	}
   1.892 +	display = &SDL_CurrentDisplay;
   1.893 +	if (!mode) {
   1.894 +		mode = &display->desktop_mode;
   1.895 +	}
   1.896 +	display_mode = *mode;
   1.897  
   1.898 -    /* See if there's anything left to do */
   1.899 -    SDL_GetCurrentDisplayMode(&current_mode);
   1.900 -    if (SDL_memcmp(&display_mode, &current_mode, sizeof(display_mode)) == 0) {
   1.901 -        return 0;
   1.902 -    }
   1.903 -
   1.904 -    /* Actually change the display mode */
   1.905 -    if (_this->SetDisplayMode(_this, &display_mode) < 0) {
   1.906 -        return -1;
   1.907 -    }
   1.908 -    display->current_mode = display_mode;
   1.909 +	/* Default to the current mode */
   1.910 +	if (!display_mode.format) {
   1.911 +		display_mode.format = display->current_mode.format;
   1.912 +	}
   1.913 +	if (!display_mode.w) {
   1.914 +		display_mode.w = display->current_mode.w;
   1.915 +	}
   1.916 +	if (!display_mode.h) {
   1.917 +		display_mode.h = display->current_mode.h;
   1.918 +	}
   1.919 +	if (!display_mode.refresh_rate) {
   1.920 +		display_mode.refresh_rate = display->current_mode.refresh_rate;
   1.921 +	}
   1.922 +	/* Get a good video mode, the closest one possible */
   1.923 +	if (!SDL_GetClosestDisplayMode(&display_mode, &display_mode)) {
   1.924 +		SDL_SetError("No video mode large enough for %dx%d",
   1.925 +			     display_mode.w, display_mode.h);
   1.926 +		return -1;
   1.927 +	}
   1.928 +	/* See if there's anything left to do */
   1.929 +	SDL_GetCurrentDisplayMode(&current_mode);
   1.930 +	if (SDL_memcmp(&display_mode, &current_mode, sizeof(display_mode)) == 0) {
   1.931 +		return 0;
   1.932 +	}
   1.933 +	/* Actually change the display mode */
   1.934 +	if (_this->SetDisplayMode(_this, &display_mode) < 0) {
   1.935 +		return -1;
   1.936 +	}
   1.937 +	display->current_mode = display_mode;
   1.938  
   1.939 -    /* Set up a palette, if necessary */
   1.940 -    if (SDL_ISPIXELFORMAT_INDEXED(display_mode.format)) {
   1.941 -        ncolors = (1 << SDL_BITSPERPIXEL(display_mode.format));
   1.942 -    } else {
   1.943 -        ncolors = 0;
   1.944 -    }
   1.945 -    if ((!ncolors && display->palette) || (ncolors && !display->palette)
   1.946 -        || (ncolors && ncolors != display->palette->ncolors)) {
   1.947 -        if (display->palette) {
   1.948 -            SDL_FreePalette(display->palette);
   1.949 -            display->palette = NULL;
   1.950 -        }
   1.951 -        if (ncolors) {
   1.952 -            display->palette = SDL_AllocPalette(ncolors);
   1.953 -            if (!display->palette) {
   1.954 -                return -1;
   1.955 -            }
   1.956 -            SDL_DitherColors(display->palette->colors,
   1.957 -                             SDL_BITSPERPIXEL(display_mode.format));
   1.958 -        }
   1.959 -    }
   1.960 +	/* Set up a palette, if necessary */
   1.961 +	if (SDL_ISPIXELFORMAT_INDEXED(display_mode.format)) {
   1.962 +		ncolors = (1 << SDL_BITSPERPIXEL(display_mode.format));
   1.963 +	} else {
   1.964 +		ncolors = 0;
   1.965 +	}
   1.966 +	if ((!ncolors && display->palette) || (ncolors && !display->palette)
   1.967 +	    || (ncolors && ncolors != display->palette->ncolors)) {
   1.968 +		if (display->palette) {
   1.969 +			SDL_FreePalette(display->palette);
   1.970 +			display->palette = NULL;
   1.971 +		}
   1.972 +		if (ncolors) {
   1.973 +			display->palette = SDL_AllocPalette(ncolors);
   1.974 +			if (!display->palette) {
   1.975 +				return -1;
   1.976 +			}
   1.977 +			SDL_DitherColors(display->palette->colors,
   1.978 +				     SDL_BITSPERPIXEL(display_mode.format));
   1.979 +		}
   1.980 +	}
   1.981 +	/* Move any fullscreen windows into position */
   1.982 +	for (i = 0; i < display->num_windows; ++i) {
   1.983 +		SDL_Window     *window = &display->windows[i];
   1.984 +		if (FULLSCREEN_VISIBLE(window)) {
   1.985 +			SDL_SetWindowPosition(window->id, SDL_WINDOWPOS_CENTERED,
   1.986 +					      SDL_WINDOWPOS_CENTERED);
   1.987 +		}
   1.988 +	}
   1.989  
   1.990 -    /* Move any fullscreen windows into position */
   1.991 -    for (i = 0; i < display->num_windows; ++i) {
   1.992 -        SDL_Window *window = &display->windows[i];
   1.993 -        if (FULLSCREEN_VISIBLE(window)) {
   1.994 -            SDL_SetWindowPosition(window->id, SDL_WINDOWPOS_CENTERED,
   1.995 -                                  SDL_WINDOWPOS_CENTERED);
   1.996 -        }
   1.997 -    }
   1.998 -
   1.999 -    return 0;
  1.1000 +	return 0;
  1.1001  }
  1.1002  
  1.1003  int
  1.1004  SDL_SetFullscreenDisplayMode(const SDL_DisplayMode * mode)
  1.1005  {
  1.1006 -    SDL_VideoDisplay *display;
  1.1007 -    SDL_DisplayMode fullscreen_mode;
  1.1008 -    int i;
  1.1009 -
  1.1010 -    if (!_this) {
  1.1011 -        SDL_UninitializedVideo();
  1.1012 -        return -1;
  1.1013 -    }
  1.1014 -
  1.1015 -    display = &SDL_CurrentDisplay;
  1.1016 -    if (!mode) {
  1.1017 -        mode = &display->desktop_mode;
  1.1018 -    }
  1.1019 +	SDL_VideoDisplay *display;
  1.1020 +	SDL_DisplayMode fullscreen_mode;
  1.1021 +	int             i;
  1.1022  
  1.1023 -    SDL_GetClosestDisplayMode(mode, &fullscreen_mode);
  1.1024 -    if (SDL_memcmp
  1.1025 -        (&fullscreen_mode, &display->fullscreen_mode,
  1.1026 -         sizeof(fullscreen_mode)) == 0) {
  1.1027 -        /* Nothing to do... */
  1.1028 -        return 0;
  1.1029 -    }
  1.1030 -    display->fullscreen_mode = fullscreen_mode;
  1.1031 +	if (!_this) {
  1.1032 +		SDL_UninitializedVideo();
  1.1033 +		return -1;
  1.1034 +	}
  1.1035 +	display = &SDL_CurrentDisplay;
  1.1036 +	if (!mode) {
  1.1037 +		mode = &display->desktop_mode;
  1.1038 +	}
  1.1039 +	SDL_GetClosestDisplayMode(mode, &fullscreen_mode);
  1.1040 +	if (SDL_memcmp
  1.1041 +	    (&fullscreen_mode, &display->fullscreen_mode,
  1.1042 +	     sizeof(fullscreen_mode)) == 0) {
  1.1043 +		/* Nothing to do... */
  1.1044 +		return 0;
  1.1045 +	}
  1.1046 +	display->fullscreen_mode = fullscreen_mode;
  1.1047  
  1.1048 -    /* Actually set the mode if we have a fullscreen window visible */
  1.1049 -    for (i = 0; i < display->num_windows; ++i) {
  1.1050 -        SDL_Window *window = &display->windows[i];
  1.1051 -        if (FULLSCREEN_VISIBLE(window)) {
  1.1052 -            if (SDL_SetDisplayMode(&display->fullscreen_mode) < 0) {
  1.1053 -                return -1;
  1.1054 -            }
  1.1055 -        }
  1.1056 -        if (window->flags & SDL_WINDOW_FULLSCREEN) {
  1.1057 -            SDL_OnWindowResized(window);
  1.1058 -        }
  1.1059 -    }
  1.1060 -    return 0;
  1.1061 +	/* Actually set the mode if we have a fullscreen window visible */
  1.1062 +	for (i = 0; i < display->num_windows; ++i) {
  1.1063 +		SDL_Window     *window = &display->windows[i];
  1.1064 +		if (FULLSCREEN_VISIBLE(window)) {
  1.1065 +			if (SDL_SetDisplayMode(&display->fullscreen_mode) < 0) {
  1.1066 +				return -1;
  1.1067 +			}
  1.1068 +		}
  1.1069 +		if (window->flags & SDL_WINDOW_FULLSCREEN) {
  1.1070 +			SDL_OnWindowResized(window);
  1.1071 +		}
  1.1072 +	}
  1.1073 +	return 0;
  1.1074  }
  1.1075  
  1.1076  int
  1.1077  SDL_GetFullscreenDisplayMode(SDL_DisplayMode * mode)
  1.1078  {
  1.1079 -    if (!_this) {
  1.1080 -        SDL_UninitializedVideo();
  1.1081 -        return -1;
  1.1082 -    }
  1.1083 -    if (mode) {
  1.1084 -        *mode = SDL_CurrentDisplay.fullscreen_mode;
  1.1085 -    }
  1.1086 -    return 0;
  1.1087 +	if (!_this) {
  1.1088 +		SDL_UninitializedVideo();
  1.1089 +		return -1;
  1.1090 +	}
  1.1091 +	if (mode) {
  1.1092 +		*mode = SDL_CurrentDisplay.fullscreen_mode;
  1.1093 +	}
  1.1094 +	return 0;
  1.1095  }
  1.1096  
  1.1097  int
  1.1098  SDL_SetDisplayPalette(const SDL_Color * colors, int firstcolor, int ncolors)
  1.1099  {
  1.1100 -    SDL_Palette *palette;
  1.1101 -    int status = 0;
  1.1102 +	SDL_Palette    *palette;
  1.1103 +	int             status = 0;
  1.1104  
  1.1105 -    if (!_this) {
  1.1106 -        SDL_UninitializedVideo();
  1.1107 -        return -1;
  1.1108 -    }
  1.1109 -    palette = SDL_CurrentDisplay.palette;
  1.1110 -    if (!palette) {
  1.1111 -        SDL_SetError("Display mode does not have a palette");
  1.1112 -        return -1;
  1.1113 -    }
  1.1114 +	if (!_this) {
  1.1115 +		SDL_UninitializedVideo();
  1.1116 +		return -1;
  1.1117 +	}
  1.1118 +	palette = SDL_CurrentDisplay.palette;
  1.1119 +	if (!palette) {
  1.1120 +		SDL_SetError("Display mode does not have a palette");
  1.1121 +		return -1;
  1.1122 +	}
  1.1123 +	status = SDL_SetPaletteColors(palette, colors, firstcolor, ncolors);
  1.1124  
  1.1125 -    status = SDL_SetPaletteColors(palette, colors, firstcolor, ncolors);
  1.1126 -
  1.1127 -    if (_this->SetDisplayPalette) {
  1.1128 -        if (_this->SetDisplayPalette(_this, palette) < 0) {
  1.1129 -            status = -1;
  1.1130 -        }
  1.1131 -    }
  1.1132 -    return status;
  1.1133 +	if (_this->SetDisplayPalette) {
  1.1134 +		if (_this->SetDisplayPalette(_this, palette) < 0) {
  1.1135 +			status = -1;
  1.1136 +		}
  1.1137 +	}
  1.1138 +	return status;
  1.1139  }
  1.1140  
  1.1141  int
  1.1142  SDL_GetDisplayPalette(SDL_Color * colors, int firstcolor, int ncolors)
  1.1143  {
  1.1144 -    SDL_Palette *palette;
  1.1145 -
  1.1146 -    if (!_this) {
  1.1147 -        SDL_UninitializedVideo();
  1.1148 -        return -1;
  1.1149 -    }
  1.1150 +	SDL_Palette    *palette;
  1.1151  
  1.1152 -    palette = SDL_CurrentDisplay.palette;
  1.1153 -    if (!palette->ncolors) {
  1.1154 -        SDL_SetError("Display mode does not have a palette");
  1.1155 -        return -1;
  1.1156 -    }
  1.1157 -
  1.1158 -    if (firstcolor < 0 || (firstcolor + ncolors) > palette->ncolors) {
  1.1159 -        SDL_SetError("Palette indices are out of range");
  1.1160 -        return -1;
  1.1161 -    }
  1.1162 -
  1.1163 -    SDL_memcpy(colors, &palette->colors[firstcolor],
  1.1164 -               ncolors * sizeof(*colors));
  1.1165 -    return 0;
  1.1166 +	if (!_this) {
  1.1167 +		SDL_UninitializedVideo();
  1.1168 +		return -1;
  1.1169 +	}
  1.1170 +	palette = SDL_CurrentDisplay.palette;
  1.1171 +	if (!palette->ncolors) {
  1.1172 +		SDL_SetError("Display mode does not have a palette");
  1.1173 +		return -1;
  1.1174 +	}
  1.1175 +	if (firstcolor < 0 || (firstcolor + ncolors) > palette->ncolors) {
  1.1176 +		SDL_SetError("Palette indices are out of range");
  1.1177 +		return -1;
  1.1178 +	}
  1.1179 +	SDL_memcpy(colors, &palette->colors[firstcolor],
  1.1180 +		   ncolors * sizeof(*colors));
  1.1181 +	return 0;
  1.1182  }
  1.1183  
  1.1184  SDL_WindowID
  1.1185  SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
  1.1186  {
  1.1187 -    const Uint32 allowed_flags = (SDL_WINDOW_FULLSCREEN |
  1.1188 -                                  SDL_WINDOW_OPENGL |
  1.1189 -                                  SDL_WINDOW_BORDERLESS |
  1.1190 -                                  SDL_WINDOW_RESIZABLE);
  1.1191 -    SDL_VideoDisplay *display;
  1.1192 -    SDL_Window window;
  1.1193 -    int num_windows;
  1.1194 -    SDL_Window *windows;
  1.1195 -
  1.1196 -    if (!_this) {
  1.1197 -        SDL_UninitializedVideo();
  1.1198 -        return 0;
  1.1199 -    }
  1.1200 +	const Uint32    allowed_flags = (SDL_WINDOW_FULLSCREEN |
  1.1201 +					 SDL_WINDOW_OPENGL |
  1.1202 +					 SDL_WINDOW_BORDERLESS |
  1.1203 +					 SDL_WINDOW_RESIZABLE);
  1.1204 +	SDL_VideoDisplay *display;
  1.1205 +	SDL_Window      window;
  1.1206 +	int             num_windows;
  1.1207 +	SDL_Window     *windows;
  1.1208  
  1.1209 -    if ((flags & SDL_WINDOW_OPENGL) && !_this->GL_CreateContext) {
  1.1210 -        SDL_SetError("No OpenGL support in video driver");
  1.1211 -        return 0;
  1.1212 -    }
  1.1213 -
  1.1214 -    /* Fullscreen windows don't have any window decorations */
  1.1215 -    if (flags & SDL_WINDOW_FULLSCREEN) {
  1.1216 -        flags |= SDL_WINDOW_BORDERLESS;
  1.1217 -        flags &= ~SDL_WINDOW_RESIZABLE;
  1.1218 -    }
  1.1219 -
  1.1220 -    SDL_zero(window);
  1.1221 -    window.id = _this->next_object_id++;
  1.1222 -    window.x = x;
  1.1223 -    window.y = y;
  1.1224 -    window.w = w;
  1.1225 -    window.h = h;
  1.1226 -    window.flags = (flags & allowed_flags);
  1.1227 -    window.display = _this->current_display;
  1.1228 +	if (!_this) {
  1.1229 +		SDL_UninitializedVideo();
  1.1230 +		return 0;
  1.1231 +	}
  1.1232 +	if ((flags & SDL_WINDOW_OPENGL) && !_this->GL_CreateContext) {
  1.1233 +		SDL_SetError("No OpenGL support in video driver");
  1.1234 +		return 0;
  1.1235 +	}
  1.1236 +	/* Fullscreen windows don't have any window decorations */
  1.1237 +	if (flags & SDL_WINDOW_FULLSCREEN) {
  1.1238 +		flags |= SDL_WINDOW_BORDERLESS;
  1.1239 +		flags &= ~SDL_WINDOW_RESIZABLE;
  1.1240 +	}
  1.1241 +	SDL_zero(window);
  1.1242 +	window.id = _this->next_object_id++;
  1.1243 +	window.x = x;
  1.1244 +	window.y = y;
  1.1245 +	window.w = w;
  1.1246 +	window.h = h;
  1.1247 +	window.flags = (flags & allowed_flags);
  1.1248 +	window.display = _this->current_display;
  1.1249  
  1.1250 -    if (_this->CreateWindow && _this->CreateWindow(_this, &window) < 0) {
  1.1251 -        return 0;
  1.1252 -    }
  1.1253 +	if (_this->CreateWindow && _this->CreateWindow(_this, &window) < 0) {
  1.1254 +		return 0;
  1.1255 +	}
  1.1256 +	display = &SDL_CurrentDisplay;
  1.1257 +	num_windows = display->num_windows;
  1.1258 +	windows =
  1.1259 +		SDL_realloc(display->windows, (num_windows + 1) * sizeof(*windows));
  1.1260 +	if (!windows) {
  1.1261 +		if (_this->DestroyWindow) {
  1.1262 +			_this->DestroyWindow(_this, &window);
  1.1263 +		}
  1.1264 +		return 0;
  1.1265 +	}
  1.1266 +	windows[num_windows] = window;
  1.1267 +	display->windows = windows;
  1.1268 +	display->num_windows++;
  1.1269  
  1.1270 -    display = &SDL_CurrentDisplay;
  1.1271 -    num_windows = display->num_windows;
  1.1272 -    windows =
  1.1273 -        SDL_realloc(display->windows, (num_windows + 1) * sizeof(*windows));
  1.1274 -    if (!windows) {
  1.1275 -        if (_this->DestroyWindow) {
  1.1276 -            _this->DestroyWindow(_this, &window);
  1.1277 -        }
  1.1278 -        return 0;
  1.1279 -    }
  1.1280 -    windows[num_windows] = window;
  1.1281 -    display->windows = windows;
  1.1282 -    display->num_windows++;
  1.1283 -
  1.1284 -    if (title) {
  1.1285 -        SDL_SetWindowTitle(window.id, title);
  1.1286 -    }
  1.1287 -    if (flags & SDL_WINDOW_MAXIMIZED) {
  1.1288 -        SDL_MaximizeWindow(window.id);
  1.1289 -    }
  1.1290 -    if (flags & SDL_WINDOW_MINIMIZED) {
  1.1291 -        SDL_MinimizeWindow(window.id);
  1.1292 -    }
  1.1293 -    if (flags & SDL_WINDOW_SHOWN) {
  1.1294 -        SDL_ShowWindow(window.id);
  1.1295 -    }
  1.1296 -    if (flags & SDL_WINDOW_INPUT_GRABBED) {
  1.1297 -        SDL_SetWindowGrab(window.id, 1);
  1.1298 -    }
  1.1299 -    return window.id;
  1.1300 +	if (title) {
  1.1301 +		SDL_SetWindowTitle(window.id, title);
  1.1302 +	}
  1.1303 +	if (flags & SDL_WINDOW_MAXIMIZED) {
  1.1304 +		SDL_MaximizeWindow(window.id);
  1.1305 +	}
  1.1306 +	if (flags & SDL_WINDOW_MINIMIZED) {
  1.1307 +		SDL_MinimizeWindow(window.id);
  1.1308 +	}
  1.1309 +	if (flags & SDL_WINDOW_SHOWN) {
  1.1310 +		SDL_ShowWindow(window.id);
  1.1311 +	}
  1.1312 +	if (flags & SDL_WINDOW_INPUT_GRABBED) {
  1.1313 +		SDL_SetWindowGrab(window.id, 1);
  1.1314 +	}
  1.1315 +	return window.id;
  1.1316  }
  1.1317  
  1.1318  SDL_WindowID
  1.1319  SDL_CreateWindowFrom(const void *data)
  1.1320  {
  1.1321 -    SDL_VideoDisplay *display;
  1.1322 -    SDL_Window window;
  1.1323 -    int num_windows;
  1.1324 -    SDL_Window *windows;
  1.1325 +	SDL_VideoDisplay *display;
  1.1326 +	SDL_Window      window;
  1.1327 +	int             num_windows;
  1.1328 +	SDL_Window     *windows;
  1.1329  
  1.1330 -    if (!_this) {
  1.1331 -        SDL_UninitializedVideo();
  1.1332 -        return (0);
  1.1333 -    }
  1.1334 -
  1.1335 -    SDL_zero(window);
  1.1336 -    window.id = _this->next_object_id++;
  1.1337 -    window.display = _this->current_display;
  1.1338 -
  1.1339 -    if (!_this->CreateWindowFrom ||
  1.1340 -        _this->CreateWindowFrom(_this, &window, data) < 0) {
  1.1341 -        return 0;
  1.1342 -    }
  1.1343 +	if (!_this) {
  1.1344 +		SDL_UninitializedVideo();
  1.1345 +		return (0);
  1.1346 +	}
  1.1347 +	SDL_zero(window);
  1.1348 +	window.id = _this->next_object_id++;
  1.1349 +	window.display = _this->current_display;
  1.1350  
  1.1351 -    display = &SDL_CurrentDisplay;
  1.1352 -    num_windows = display->num_windows;
  1.1353 -    windows =
  1.1354 -        SDL_realloc(display->windows, (num_windows + 1) * sizeof(*windows));
  1.1355 -    if (!windows) {
  1.1356 -        if (_this->DestroyWindow) {
  1.1357 -            _this->DestroyWindow(_this, &window);
  1.1358 -        }
  1.1359 -        if (window.title) {
  1.1360 -            SDL_free(window.title);
  1.1361 -        }
  1.1362 -        return 0;
  1.1363 -    }
  1.1364 -    windows[num_windows] = window;
  1.1365 -    display->windows = windows;
  1.1366 -    display->num_windows++;
  1.1367 +	if (!_this->CreateWindowFrom ||
  1.1368 +	    _this->CreateWindowFrom(_this, &window, data) < 0) {
  1.1369 +		return 0;
  1.1370 +	}
  1.1371 +	display = &SDL_CurrentDisplay;
  1.1372 +	num_windows = display->num_windows;
  1.1373 +	windows =
  1.1374 +		SDL_realloc(display->windows, (num_windows + 1) * sizeof(*windows));
  1.1375 +	if (!windows) {
  1.1376 +		if (_this->DestroyWindow) {
  1.1377 +			_this->DestroyWindow(_this, &window);
  1.1378 +		}
  1.1379 +		if (window.title) {
  1.1380 +			SDL_free(window.title);
  1.1381 +		}
  1.1382 +		return 0;
  1.1383 +	}
  1.1384 +	windows[num_windows] = window;
  1.1385 +	display->windows = windows;
  1.1386 +	display->num_windows++;
  1.1387  
  1.1388 -    return window.id;
  1.1389 +	return window.id;
  1.1390  }
  1.1391  
  1.1392  int
  1.1393  SDL_RecreateWindow(SDL_Window * window, Uint32 flags)
  1.1394  {
  1.1395 -    char *title = window->title;
  1.1396 -
  1.1397 -    if ((flags & SDL_WINDOW_OPENGL) && !_this->GL_CreateContext) {
  1.1398 -        SDL_SetError("No OpenGL support in video driver");
  1.1399 -        return -1;
  1.1400 -    }
  1.1401 +	char           *title = window->title;
  1.1402  
  1.1403 -    if (_this->DestroyWindow) {
  1.1404 -        _this->DestroyWindow(_this, window);
  1.1405 -    }
  1.1406 -
  1.1407 -    window->title = NULL;
  1.1408 -    window->flags =
  1.1409 -        (flags &
  1.1410 -         ~(SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED | SDL_WINDOW_SHOWN |
  1.1411 -           SDL_WINDOW_INPUT_GRABBED));
  1.1412 +	if ((flags & SDL_WINDOW_OPENGL) && !_this->GL_CreateContext) {
  1.1413 +		SDL_SetError("No OpenGL support in video driver");
  1.1414 +		return -1;
  1.1415 +	}
  1.1416 +	if (_this->DestroyWindow) {
  1.1417 +		_this->DestroyWindow(_this, window);
  1.1418 +	}
  1.1419 +	window->title = NULL;
  1.1420 +	window->flags =
  1.1421 +		(flags &
  1.1422 +	  ~(SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED | SDL_WINDOW_SHOWN |
  1.1423 +	    SDL_WINDOW_INPUT_GRABBED));
  1.1424  
  1.1425 -    if (_this->CreateWindow && _this->CreateWindow(_this, window) < 0) {
  1.1426 -        return -1;
  1.1427 -    }
  1.1428 -
  1.1429 -    if (title) {
  1.1430 -        SDL_SetWindowTitle(window->id, title);
  1.1431 -        SDL_free(title);
  1.1432 -    }
  1.1433 -    if (flags & SDL_WINDOW_MAXIMIZED) {
  1.1434 -        SDL_MaximizeWindow(window->id);
  1.1435 -    }
  1.1436 -    if (flags & SDL_WINDOW_MINIMIZED) {
  1.1437 -        SDL_MinimizeWindow(window->id);
  1.1438 -    }
  1.1439 -    if (flags & SDL_WINDOW_SHOWN) {
  1.1440 -        SDL_ShowWindow(window->id);
  1.1441 -    }
  1.1442 -    if (flags & SDL_WINDOW_INPUT_GRABBED) {
  1.1443 -        SDL_SetWindowGrab(window->id, 1);
  1.1444 -    }
  1.1445 -    return 0;
  1.1446 +	if (_this->CreateWindow && _this->CreateWindow(_this, window) < 0) {
  1.1447 +		return -1;
  1.1448 +	}
  1.1449 +	if (title) {
  1.1450 +		SDL_SetWindowTitle(window->id, title);
  1.1451 +		SDL_free(title);
  1.1452 +	}
  1.1453 +	if (flags & SDL_WINDOW_MAXIMIZED) {
  1.1454 +		SDL_MaximizeWindow(window->id);
  1.1455 +	}
  1.1456 +	if (flags & SDL_WINDOW_MINIMIZED) {
  1.1457 +		SDL_MinimizeWindow(window->id);
  1.1458 +	}
  1.1459 +	if (flags & SDL_WINDOW_SHOWN) {
  1.1460 +		SDL_ShowWindow(window->id);
  1.1461 +	}
  1.1462 +	if (flags & SDL_WINDOW_INPUT_GRABBED) {
  1.1463 +		SDL_SetWindowGrab(window->id, 1);
  1.1464 +	}
  1.1465 +	return 0;
  1.1466  }
  1.1467  
  1.1468 -SDL_Window *
  1.1469 +SDL_Window     *
  1.1470  SDL_GetWindowFromID(SDL_WindowID windowID)
  1.1471  {
  1.1472 -    int i, j;
  1.1473 -
  1.1474 -    if (!_this) {
  1.1475 -        SDL_UninitializedVideo();
  1.1476 -        return NULL;
  1.1477 -    }
  1.1478 +	int             i, j;
  1.1479  
  1.1480 -    for (i = 0; i < _this->num_displays; ++i) {
  1.1481 -        SDL_VideoDisplay *display = &_this->displays[i];
  1.1482 -        for (j = 0; j < display->num_windows; ++j) {
  1.1483 -            SDL_Window *window = &display->windows[j];
  1.1484 -            if (window->id == windowID) {
  1.1485 -                return window;
  1.1486 -            }
  1.1487 -        }
  1.1488 -    }
  1.1489 -    return NULL;
  1.1490 +	if (!_this) {
  1.1491 +		SDL_UninitializedVideo();
  1.1492 +		return NULL;
  1.1493 +	}
  1.1494 +	for (i = 0; i < _this->num_displays; ++i) {
  1.1495 +		SDL_VideoDisplay *display = &_this->displays[i];
  1.1496 +		for (j = 0; j < display->num_windows; ++j) {
  1.1497 +			SDL_Window     *window = &display->windows[j];
  1.1498 +			if (window->id == windowID) {
  1.1499 +				return window;
  1.1500 +			}
  1.1501 +		}
  1.1502 +	}
  1.1503 +	return NULL;
  1.1504  }
  1.1505  
  1.1506  SDL_VideoDisplay *
  1.1507  SDL_GetDisplayFromWindow(SDL_Window * window)
  1.1508  {
  1.1509 -    if (!_this) {
  1.1510 -        SDL_UninitializedVideo();
  1.1511 -        return NULL;
  1.1512 -    }
  1.1513 -    if (!window) {
  1.1514 -        return NULL;
  1.1515 -    }
  1.1516 -    return &_this->displays[window->display];
  1.1517 +	if (!_this) {
  1.1518 +		SDL_UninitializedVideo();
  1.1519 +		return NULL;
  1.1520 +	}
  1.1521 +	if (!window) {
  1.1522 +		return NULL;
  1.1523 +	}
  1.1524 +	return &_this->displays[window->display];
  1.1525  }
  1.1526  
  1.1527  Uint32
  1.1528  SDL_GetWindowFlags(SDL_WindowID windowID)
  1.1529  {
  1.1530 -    SDL_Window *window = SDL_GetWindowFromID(windowID);
  1.1531 +	SDL_Window     *window = SDL_GetWindowFromID(windowID);
  1.1532  
  1.1533 -    if (!window) {
  1.1534 -        return 0;
  1.1535 -    }
  1.1536 -    return window->flags;
  1.1537 +	if (!window) {
  1.1538 +		return 0;
  1.1539 +	}
  1.1540 +	return window->flags;
  1.1541  }
  1.1542  
  1.1543  void
  1.1544  SDL_SetWindowTitle(SDL_WindowID windowID, const char *title)
  1.1545  {
  1.1546 -    SDL_Window *window = SDL_GetWindowFromID(windowID);
  1.1547 -
  1.1548 -    if (!window || title == window->title) {
  1.1549 -        return;
  1.1550 -    }
  1.1551 +	SDL_Window     *window = SDL_GetWindowFromID(windowID);
  1.1552  
  1.1553 -    if (window->title) {
  1.1554 -        SDL_free(window->title);
  1.1555 -    }
  1.1556 -    if (title) {
  1.1557 -        window->title = SDL_strdup(title);
  1.1558 -    } else {
  1.1559 -        window->title = NULL;
  1.1560 -    }
  1.1561 +	if (!window || title == window->title) {
  1.1562 +		return;
  1.1563 +	}
  1.1564 +	if (window->title) {
  1.1565 +		SDL_free(window->title);
  1.1566 +	}
  1.1567 +	if (title) {
  1.1568 +		window->title = SDL_strdup(title);
  1.1569 +	} else {
  1.1570 +		window->title = NULL;
  1.1571 +	}
  1.1572  
  1.1573 -    if (_this->SetWindowTitle) {
  1.1574 -        _this->SetWindowTitle(_this, window);
  1.1575 -    }
  1.1576 +	if (_this->SetWindowTitle) {
  1.1577 +		_this->SetWindowTitle(_this, window);
  1.1578 +	}
  1.1579  }
  1.1580  
  1.1581 -const char *
  1.1582 +const char     *
  1.1583  SDL_GetWindowTitle(SDL_WindowID windowID)
  1.1584  {
  1.1585 -    SDL_Window *window = SDL_GetWindowFromID(windowID);
  1.1586 +	SDL_Window     *window = SDL_GetWindowFromID(windowID);
  1.1587  
  1.1588 -    if (!window) {
  1.1589 -        return NULL;
  1.1590 -    }
  1.1591 -    return window->title;
  1.1592 +	if (!window) {
  1.1593 +		return NULL;
  1.1594 +	}
  1.1595 +	return window->title;
  1.1596  }
  1.1597  
  1.1598  void
  1.1599  SDL_SetWindowData(SDL_WindowID windowID, void *userdata)
  1.1600  {
  1.1601 -    SDL_Window *window = SDL_GetWindowFromID(windowID);
  1.1602 +	SDL_Window     *window = SDL_GetWindowFromID(windowID);
  1.1603  
  1.1604 -    if (!window) {
  1.1605 -        return;
  1.1606 -    }
  1.1607 -    window->userdata = userdata;
  1.1608 +	if (!window) {
  1.1609 +		return;
  1.1610 +	}
  1.1611 +	window->userdata = userdata;
  1.1612  }
  1.1613  
  1.1614 -void *
  1.1615 +void           *
  1.1616  SDL_GetWindowData(SDL_WindowID windowID)
  1.1617  {
  1.1618 -    SDL_Window *window = SDL_GetWindowFromID(windowID);
  1.1619 +	SDL_Window     *window = SDL_GetWindowFromID(windowID);
  1.1620  
  1.1621 -    if (!window) {
  1.1622 -        return NULL;
  1.1623 -    }
  1.1624 -    return window->userdata;
  1.1625 +	if (!window) {
  1.1626 +		return NULL;
  1.1627 +	}
  1.1628 +	return window->userdata;
  1.1629  }
  1.1630  
  1.1631  void
  1.1632  SDL_SetWindowPosition(SDL_WindowID windowID, int x, int y)
  1.1633  {
  1.1634 -    SDL_Window *window = SDL_GetWindowFromID(windowID);
  1.1635 -    SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
  1.1636 -
  1.1637 -    if (!window) {
  1.1638 -        return;
  1.1639 -    }
  1.1640 +	SDL_Window     *window = SDL_GetWindowFromID(windowID);
  1.1641 +	SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
  1.1642  
  1.1643 -    if (x == SDL_WINDOWPOS_CENTERED) {
  1.1644 -        window->x = (display->current_mode.w - window->w) / 2;
  1.1645 -    } else if (x != SDL_WINDOWPOS_UNDEFINED) {
  1.1646 -        window->x = x;
  1.1647 -    }
  1.1648 -    if (y == SDL_WINDOWPOS_CENTERED) {
  1.1649 -        window->y = (display->current_mode.h - window->h) / 2;
  1.1650 -    } else if (y != SDL_WINDOWPOS_UNDEFINED) {
  1.1651 -        window->y = y;
  1.1652 -    }
  1.1653 -
  1.1654 -    if (_this->SetWindowPosition) {
  1.1655 -        _this->SetWindowPosition(_this, window);
  1.1656 -    }
  1.1657 +	if (!window) {
  1.1658 +		return;
  1.1659 +	}
  1.1660 +	if (x == SDL_WINDOWPOS_CENTERED) {
  1.1661 +		window->x = (display->current_mode.w - window->w) / 2;
  1.1662 +	} else if (x != SDL_WINDOWPOS_UNDEFINED) {
  1.1663 +		window->x = x;
  1.1664 +	}
  1.1665 +	if (y == SDL_WINDOWPOS_CENTERED) {
  1.1666 +		window->y = (display->current_mode.h - window->h) / 2;
  1.1667 +	} else if (y != SDL_WINDOWPOS_UNDEFINED) {
  1.1668 +		window->y = y;
  1.1669 +	}
  1.1670 +	if (_this->SetWindowPosition) {
  1.1671 +		_this->SetWindowPosition(_this, window);
  1.1672 +	}
  1.1673  }
  1.1674  
  1.1675  void
  1.1676  SDL_GetWindowPosition(SDL_WindowID windowID, int *x, int *y)
  1.1677  {
  1.1678 -    SDL_Window *window = SDL_GetWindowFromID(windowID);
  1.1679 +	SDL_Window     *window = SDL_GetWindowFromID(windowID);
  1.1680  
  1.1681 -    if (!window) {
  1.1682 -        return;
  1.1683 -    }
  1.1684 -    if (x) {
  1.1685 -        *x = window->x;
  1.1686 -    }
  1.1687 -    if (y) {
  1.1688 -        *y = window->y;
  1.1689 -    }
  1.1690 +	if (!window) {
  1.1691 +		return;
  1.1692 +	}
  1.1693 +	if (x) {
  1.1694 +		*x = window->x;
  1.1695 +	}
  1.1696 +	if (y) {
  1.1697 +		*y = window->y;
  1.1698 +	}
  1.1699  }
  1.1700  
  1.1701  void
  1.1702  SDL_SetWindowSize(SDL_WindowID windowID, int w, int h)
  1.1703  {
  1.1704 -    SDL_Window *window = SDL_GetWindowFromID(windowID);
  1.1705 -
  1.1706 -    if (!window) {
  1.1707 -        return;
  1.1708 -    }
  1.1709 +	SDL_Window     *window = SDL_GetWindowFromID(windowID);
  1.1710  
  1.1711 -    window->w = w;
  1.1712 -    window->h = h;
  1.1713 +	if (!window) {
  1.1714 +		return;
  1.1715 +	}
  1.1716 +	window->w = w;
  1.1717 +	window->h = h;
  1.1718  
  1.1719 -    if (_this->SetWindowSize) {
  1.1720 -        _this->SetWindowSize(_this, window);
  1.1721 -    }
  1.1722 +	if (_this->SetWindowSize) {
  1.1723 +		_this->SetWindowSize(_this, window);
  1.1724 +	}
  1.1725  }
  1.1726  
  1.1727  void
  1.1728  SDL_GetWindowSize(SDL_WindowID windowID, int *w, int *h)
  1.1729  {
  1.1730 -    SDL_Window *window = SDL_GetWindowFromID(windowID);
  1.1731 +	SDL_Window     *window = SDL_GetWindowFromID(windowID);
  1.1732  
  1.1733 -    if (!window) {
  1.1734 -        return;
  1.1735 -    }
  1.1736 -    if (w) {
  1.1737 -        *w = window->w;
  1.1738 -    }
  1.1739 -    if (h) {
  1.1740 -        *h = window->h;
  1.1741 -    }
  1.1742 +	if (!window) {
  1.1743 +		return;
  1.1744 +	}
  1.1745 +	if (w) {
  1.1746 +		*w = window->w;
  1.1747 +	}
  1.1748 +	if (h) {
  1.1749 +		*h = window->h;
  1.1750 +	}
  1.1751  }
  1.1752  
  1.1753  void
  1.1754  SDL_ShowWindow(SDL_WindowID windowID)
  1.1755  {
  1.1756 -    SDL_Window *window = SDL_GetWindowFromID(windowID);
  1.1757 -
  1.1758 -    if (!window || (window->flags & SDL_WINDOW_SHOWN)) {
  1.1759 -        return;
  1.1760 -    }
  1.1761 +	SDL_Window     *window = SDL_GetWindowFromID(windowID);
  1.1762  
  1.1763 -    SDL_SendWindowEvent(window->id, SDL_WINDOWEVENT_SHOWN, 0, 0);
  1.1764 +	if (!window || (window->flags & SDL_WINDOW_SHOWN)) {
  1.1765 +		return;
  1.1766 +	}
  1.1767 +	SDL_SendWindowEvent(window->id, SDL_WINDOWEVENT_SHOWN, 0, 0);
  1.1768  
  1.1769 -    if (_this->ShowWindow) {
  1.1770 -        _this->ShowWindow(_this, window);
  1.1771 -    }
  1.1772 +	if (_this->ShowWindow) {
  1.1773 +		_this->ShowWindow(_this, window);
  1.1774 +	}
  1.1775  }
  1.1776  
  1.1777  void
  1.1778  SDL_HideWindow(SDL_WindowID windowID)
  1.1779  {
  1.1780 -    SDL_Window *window = SDL_GetWindowFromID(windowID);
  1.1781 -
  1.1782 -    if (!window || !(window->flags & SDL_WINDOW_SHOWN)) {
  1.1783 -        return;
  1.1784 -    }
  1.1785 +	SDL_Window     *window = SDL_GetWindowFromID(windowID);
  1.1786  
  1.1787 -    SDL_SendWindowEvent(window->id, SDL_WINDOWEVENT_HIDDEN, 0, 0);
  1.1788 +	if (!window || !(window->flags & SDL_WINDOW_SHOWN)) {
  1.1789 +		return;
  1.1790 +	}
  1.1791 +	SDL_SendWindowEvent(window->id, SDL_WINDOWEVENT_HIDDEN, 0, 0);
  1.1792  
  1.1793 -    if (_this->HideWindow) {
  1.1794 -        _this->HideWindow(_this, window);
  1.1795 -    }
  1.1796 +	if (_this->HideWindow) {
  1.1797 +		_this->HideWindow(_this, window);
  1.1798 +	}
  1.1799  }
  1.1800  
  1.1801  void
  1.1802  SDL_RaiseWindow(SDL_WindowID windowID)
  1.1803  {
  1.1804 -    SDL_Window *window = SDL_GetWindowFromID(windowID);
  1.1805 +	SDL_Window     *window = SDL_GetWindowFromID(windowID);
  1.1806  
  1.1807 -    if (!window || !(window->flags & SDL_WINDOW_SHOWN)) {
  1.1808 -        return;
  1.1809 -    }
  1.1810 -
  1.1811 -    if (_this->RaiseWindow) {
  1.1812 -        _this->RaiseWindow(_this, window);
  1.1813 -    }
  1.1814 +	if (!window || !(window->flags & SDL_WINDOW_SHOWN)) {
  1.1815 +		return;
  1.1816 +	}
  1.1817 +	if (_this->RaiseWindow) {
  1.1818 +		_this->RaiseWindow(_this, window);
  1.1819 +	}
  1.1820  }
  1.1821  
  1.1822  void
  1.1823  SDL_MaximizeWindow(SDL_WindowID windowID)
  1.1824  {
  1.1825 -    SDL_Window *window = SDL_GetWindowFromID(windowID);
  1.1826 -
  1.1827 -    if (!window || (window->flags & SDL_WINDOW_MAXIMIZED)) {
  1.1828 -        return;
  1.1829 -    }
  1.1830 +	SDL_Window     *window = SDL_GetWindowFromID(windowID);
  1.1831  
  1.1832 -    SDL_SendWindowEvent(window->id, SDL_WINDOWEVENT_MAXIMIZED, 0, 0);
  1.1833 +	if (!window || (window->flags & SDL_WINDOW_MAXIMIZED)) {
  1.1834 +		return;
  1.1835 +	}
  1.1836 +	SDL_SendWindowEvent(window->id, SDL_WINDOWEVENT_MAXIMIZED, 0, 0);
  1.1837  
  1.1838 -    if (_this->MaximizeWindow) {
  1.1839 -        _this->MaximizeWindow(_this, window);
  1.1840 -    }
  1.1841 +	if (_this->MaximizeWindow) {
  1.1842 +		_this->MaximizeWindow(_this, window);
  1.1843 +	}
  1.1844  }
  1.1845  
  1.1846  void
  1.1847  SDL_MinimizeWindow(SDL_WindowID windowID)
  1.1848  {
  1.1849 -    SDL_Window *window = SDL_GetWindowFromID(windowID);
  1.1850 -
  1.1851 -    if (!window || (window->flags & SDL_WINDOW_MINIMIZED)) {
  1.1852 -        return;
  1.1853 -    }
  1.1854 +	SDL_Window     *window = SDL_GetWindowFromID(windowID);
  1.1855  
  1.1856 -    SDL_SendWindowEvent(window->id, SDL_WINDOWEVENT_MINIMIZED, 0, 0);
  1.1857 +	if (!window || (window->flags & SDL_WINDOW_MINIMIZED)) {
  1.1858 +		return;
  1.1859 +	}
  1.1860 +	SDL_SendWindowEvent(window->id, SDL_WINDOWEVENT_MINIMIZED, 0, 0);
  1.1861  
  1.1862 -    if (_this->MinimizeWindow) {
  1.1863 -        _this->MinimizeWindow(_this, window);
  1.1864 -    }
  1.1865 +	if (_this->MinimizeWindow) {
  1.1866 +		_this->MinimizeWindow(_this, window);
  1.1867 +	}
  1.1868  }
  1.1869  
  1.1870  void
  1.1871  SDL_RestoreWindow(SDL_WindowID windowID)
  1.1872  {
  1.1873 -    SDL_Window *window = SDL_GetWindowFromID(windowID);
  1.1874 +	SDL_Window     *window = SDL_GetWindowFromID(windowID);
  1.1875  
  1.1876 -    if (!window
  1.1877 -        || (window->flags & (SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED))) {
  1.1878 -        return;
  1.1879 -    }
  1.1880 +	if (!window
  1.1881 +	|| (window->flags & (SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED))) {
  1.1882 +		return;
  1.1883 +	}
  1.1884 +	SDL_SendWindowEvent(window->id, SDL_WINDOWEVENT_RESTORED, 0, 0);
  1.1885  
  1.1886 -    SDL_SendWindowEvent(window->id, SDL_WINDOWEVENT_RESTORED, 0, 0);
  1.1887 -
  1.1888 -    if (_this->RestoreWindow) {
  1.1889 -        _this->RestoreWindow(_this, window);
  1.1890 -    }
  1.1891 +	if (_this->RestoreWindow) {
  1.1892 +		_this->RestoreWindow(_this, window);
  1.1893 +	}
  1.1894  }
  1.1895  
  1.1896  int
  1.1897  SDL_SetWindowFullscreen(SDL_WindowID windowID, int fullscreen)
  1.1898  {
  1.1899 -    SDL_Window *window = SDL_GetWindowFromID(windowID);
  1.1900 -
  1.1901 -    if (!window) {
  1.1902 -        return -1;
  1.1903 -    }
  1.1904 +	SDL_Window     *window = SDL_GetWindowFromID(windowID);
  1.1905  
  1.1906 -    if (fullscreen) {
  1.1907 -        fullscreen = SDL_WINDOW_FULLSCREEN;
  1.1908 -    }
  1.1909 -    if ((window->flags & SDL_WINDOW_FULLSCREEN) == fullscreen) {
  1.1910 -        return 0;
  1.1911 -    }
  1.1912 +	if (!window) {
  1.1913 +		return -1;
  1.1914 +	}
  1.1915 +	if (fullscreen) {
  1.1916 +		fullscreen = SDL_WINDOW_FULLSCREEN;
  1.1917 +	}
  1.1918 +	if ((window->flags & SDL_WINDOW_FULLSCREEN) == fullscreen) {
  1.1919 +		return 0;
  1.1920 +	}
  1.1921 +	if (fullscreen) {
  1.1922 +		window->flags |= SDL_WINDOW_FULLSCREEN;
  1.1923  
  1.1924 -    if (fullscreen) {
  1.1925 -        window->flags |= SDL_WINDOW_FULLSCREEN;
  1.1926 -
  1.1927 -        if (FULLSCREEN_VISIBLE(window)) {
  1.1928 -            SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
  1.1929 +		if (FULLSCREEN_VISIBLE(window)) {
  1.1930 +			SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
  1.1931  
  1.1932 -            /* Hide any other fullscreen windows */
  1.1933 -            int i;
  1.1934 -            for (i = 0; i < display->num_windows; ++i) {
  1.1935 -                SDL_Window *other = &display->windows[i];
  1.1936 -                if (other->id != windowID && FULLSCREEN_VISIBLE(other)) {
  1.1937 -                    SDL_MinimizeWindow(other->id);
  1.1938 -                }
  1.1939 -            }
  1.1940 +			/* Hide any other fullscreen windows */
  1.1941 +			int             i;
  1.1942 +			for (i = 0; i < display->num_windows; ++i) {
  1.1943 +				SDL_Window     *other = &display->windows[i];
  1.1944 +				if (other->id != windowID && FULLSCREEN_VISIBLE(other)) {
  1.1945 +					SDL_MinimizeWindow(other->id);
  1.1946 +				}
  1.1947 +			}
  1.1948  
  1.1949 -            SDL_SetDisplayMode(&display->fullscreen_mode);
  1.1950 -        }
  1.1951 -    } else {
  1.1952 -        window->flags &= ~SDL_WINDOW_FULLSCREEN;
  1.1953 +			SDL_SetDisplayMode(&display->fullscreen_mode);
  1.1954 +		}
  1.1955 +	} else {
  1.1956 +		window->flags &= ~SDL_WINDOW_FULLSCREEN;
  1.1957  
  1.1958 -        if (FULLSCREEN_VISIBLE(window)) {
  1.1959 -            SDL_SetDisplayMode(NULL);
  1.1960 -        }
  1.1961 -    }
  1.1962 -    return 0;
  1.1963 +		if (FULLSCREEN_VISIBLE(window)) {
  1.1964 +			SDL_SetDisplayMode(NULL);
  1.1965 +		}
  1.1966 +	}
  1.1967 +	return 0;
  1.1968  }
  1.1969  
  1.1970  void
  1.1971  SDL_SetWindowGrab(SDL_WindowID windowID, int mode)
  1.1972  {
  1.1973 -    SDL_Window *window = SDL_GetWindowFromID(windowID);
  1.1974 -
  1.1975 -    if (!window || (!!mode == !!(window->flags & SDL_WINDOW_INPUT_GRABBED))) {
  1.1976 -        return;
  1.1977 -    }
  1.1978 +	SDL_Window     *window = SDL_GetWindowFromID(windowID);
  1.1979  
  1.1980 -    if (mode) {
  1.1981 -        window->flags |= SDL_WINDOW_INPUT_GRABBED;
  1.1982 -    } else {
  1.1983 -        window->flags &= ~SDL_WINDOW_INPUT_GRABBED;
  1.1984 -    }
  1.1985 +	if (!window || (!!mode == !!(window->flags & SDL_WINDOW_INPUT_GRABBED))) {
  1.1986 +		return;
  1.1987 +	}
  1.1988 +	if (mode) {
  1.1989 +		window->flags |= SDL_WINDOW_INPUT_GRABBED;
  1.1990 +	} else {
  1.1991 +		window->flags &= ~SDL_WINDOW_INPUT_GRABBED;
  1.1992 +	}
  1.1993  
  1.1994 -    if ((window->flags & SDL_WINDOW_INPUT_FOCUS) && _this->SetWindowGrab) {
  1.1995 -        _this->SetWindowGrab(_this, window);
  1.1996 -    }
  1.1997 +	if ((window->flags & SDL_WINDOW_INPUT_FOCUS) && _this->SetWindowGrab) {
  1.1998 +		_this->SetWindowGrab(_this, window);
  1.1999 +	}
  1.2000  }
  1.2001  
  1.2002  int
  1.2003  SDL_GetWindowGrab(SDL_WindowID windowID)
  1.2004  {
  1.2005 -    SDL_Window *window = SDL_GetWindowFromID(windowID);
  1.2006 +	SDL_Window     *window = SDL_GetWindowFromID(windowID);
  1.2007  
  1.2008 -    if (!window) {
  1.2009 -        return 0;
  1.2010 -    }
  1.2011 -
  1.2012 -    return ((window->flags & SDL_WINDOW_INPUT_GRABBED) != 0);
  1.2013 +	if (!window) {
  1.2014 +		return 0;
  1.2015 +	}
  1.2016 +	return ((window->flags & SDL_WINDOW_INPUT_GRABBED) != 0);
  1.2017  }
  1.2018  
  1.2019  void
  1.2020 @@ -1252,1088 +1215,1041 @@
  1.2021  void
  1.2022  SDL_OnWindowResized(SDL_Window * window)
  1.2023  {
  1.2024 -    SDL_Renderer *renderer = window->renderer;
  1.2025 +	SDL_Renderer   *renderer = window->renderer;
  1.2026  
  1.2027 -    if (renderer && renderer->DisplayModeChanged) {
  1.2028 -        renderer->DisplayModeChanged(renderer);
  1.2029 -    }
  1.2030 +	if (renderer && renderer->DisplayModeChanged) {
  1.2031 +		renderer->DisplayModeChanged(renderer);
  1.2032 +	}
  1.2033  }
  1.2034  
  1.2035  void
  1.2036  SDL_OnWindowFocusGained(SDL_Window * window)
  1.2037  {
  1.2038 -    SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
  1.2039 +	SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
  1.2040  
  1.2041 -    if (window->flags & SDL_WINDOW_FULLSCREEN) {
  1.2042 -        SDL_SetDisplayMode(&display->fullscreen_mode);
  1.2043 -    }
  1.2044 -    if (display->gamma && _this->SetDisplayGammaRamp) {
  1.2045 -        _this->SetDisplayGammaRamp(_this, display->gamma);
  1.2046 -    }
  1.2047 -    if ((window->flags & SDL_WINDOW_INPUT_GRABBED) && _this->SetWindowGrab) {
  1.2048 -        _this->SetWindowGrab(_this, window);
  1.2049 -    }
  1.2050 +	if (window->flags & SDL_WINDOW_FULLSCREEN) {
  1.2051 +		SDL_SetDisplayMode(&display->fullscreen_mode);
  1.2052 +	}
  1.2053 +	if (display->gamma && _this->SetDisplayGammaRamp) {
  1.2054 +		_this->SetDisplayGammaRamp(_this, display->gamma);
  1.2055 +	}
  1.2056 +	if ((window->flags & SDL_WINDOW_INPUT_GRABBED) && _this->SetWindowGrab) {
  1.2057 +		_this->SetWindowGrab(_this, window);
  1.2058 +	}
  1.2059  }
  1.2060  
  1.2061  void
  1.2062  SDL_OnWindowFocusLost(SDL_Window * window)
  1.2063  {
  1.2064 -    SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
  1.2065 +	SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
  1.2066  
  1.2067 -    if (window->flags & SDL_WINDOW_FULLSCREEN) {
  1.2068 -        SDL_MinimizeWindow(window->id);
  1.2069 -        SDL_SetDisplayMode(NULL);
  1.2070 -    }
  1.2071 -    if (display->gamma && _this->SetDisplayGammaRamp) {
  1.2072 -        _this->SetDisplayGammaRamp(_this, display->saved_gamma);
  1.2073 -    }
  1.2074 -    if ((window->flags & SDL_WINDOW_INPUT_GRABBED) && _this->SetWindowGrab) {
  1.2075 -        _this->SetWindowGrab(_this, window);
  1.2076 -    }
  1.2077 +	if (window->flags & SDL_WINDOW_FULLSCREEN) {
  1.2078 +		SDL_MinimizeWindow(window->id);
  1.2079 +		SDL_SetDisplayMode(NULL);
  1.2080 +	}
  1.2081 +	if (display->gamma && _this->SetDisplayGammaRamp) {
  1.2082 +		_this->SetDisplayGammaRamp(_this, display->saved_gamma);
  1.2083 +	}
  1.2084 +	if ((window->flags & SDL_WINDOW_INPUT_GRABBED) && _this->SetWindowGrab) {
  1.2085 +		_this->SetWindowGrab(_this, window);
  1.2086 +	}
  1.2087  }
  1.2088  
  1.2089  SDL_WindowID
  1.2090  SDL_GetFocusWindow(void)
  1.2091  {
  1.2092 -    SDL_VideoDisplay *display;
  1.2093 -    int i;
  1.2094 -
  1.2095 -    if (!_this) {
  1.2096 -        return 0;
  1.2097 -    }
  1.2098 +	SDL_VideoDisplay *display;
  1.2099 +	int             i;
  1.2100  
  1.2101 -    display = &SDL_CurrentDisplay;
  1.2102 -    for (i = 0; i < display->num_windows; ++i) {
  1.2103 -        SDL_Window *window = &display->windows[i];
  1.2104 +	if (!_this) {
  1.2105 +		return 0;
  1.2106 +	}
  1.2107 +	display = &SDL_CurrentDisplay;
  1.2108 +	for (i = 0; i < display->num_windows; ++i) {
  1.2109 +		SDL_Window     *window = &display->windows[i];
  1.2110  
  1.2111 -        if (window->flags & SDL_WINDOW_INPUT_FOCUS) {
  1.2112 -            return window->id;
  1.2113 -        }
  1.2114 -    }
  1.2115 -    return 0;
  1.2116 +		if (window->flags & SDL_WINDOW_INPUT_FOCUS) {
  1.2117 +			return window->id;
  1.2118 +		}
  1.2119 +	}
  1.2120 +	return 0;
  1.2121  }
  1.2122  
  1.2123  void
  1.2124  SDL_DestroyWindow(SDL_WindowID windowID)
  1.2125  {
  1.2126 -    int i, j;
  1.2127 +	int             i, j;
  1.2128  
  1.2129 -    if (!_this) {
  1.2130 -        return;
  1.2131 -    }
  1.2132 -
  1.2133 -    /* Restore video mode, etc. */
  1.2134 -    SDL_SendWindowEvent(windowID, SDL_WINDOWEVENT_FOCUS_LOST, 0, 0);
  1.2135 +	if (!_this) {
  1.2136 +		return;
  1.2137 +	}
  1.2138 +	/* Restore video mode, etc. */
  1.2139 +	SDL_SendWindowEvent(windowID, SDL_WINDOWEVENT_FOCUS_LOST, 0, 0);
  1.2140  
  1.2141 -    for (i = 0; i < _this->num_displays; ++i) {
  1.2142 -        SDL_VideoDisplay *display = &_this->displays[i];
  1.2143 -        for (j = 0; j < display->num_windows; ++j) {
  1.2144 -            SDL_Window *window = &display->windows[j];
  1.2145 -            if (window->id != windowID) {
  1.2146 -                continue;
  1.2147 -            }
  1.2148 -            if (window->title) {
  1.2149 -                SDL_free(window->title);
  1.2150 -                window->title = NULL;
  1.2151 -            }
  1.2152 -            if (window->renderer) {
  1.2153 -                SDL_DestroyRenderer(window->id);
  1.2154 -                window->renderer = NULL;
  1.2155 -            }
  1.2156 -            if (_this->DestroyWindow) {
  1.2157 -                _this->DestroyWindow(_this, window);
  1.2158 -            }
  1.2159 -            if (j != display->num_windows - 1) {
  1.2160 -                SDL_memcpy(&display->windows[i],
  1.2161 -                           &display->windows[i + 1],
  1.2162 -                           (display->num_windows - i - 1) * sizeof(*window));
  1.2163 -            }
  1.2164 -            --display->num_windows;
  1.2165 -            return;
  1.2166 -        }
  1.2167 -    }
  1.2168 +	for (i = 0; i < _this->num_displays; ++i) {
  1.2169 +		SDL_VideoDisplay *display = &_this->displays[i];
  1.2170 +		for (j = 0; j < display->num_windows; ++j) {
  1.2171 +			SDL_Window     *window = &display->windows[j];
  1.2172 +			if (window->id != windowID) {
  1.2173 +				continue;
  1.2174 +			}
  1.2175 +			if (window->title) {
  1.2176 +				SDL_free(window->title);
  1.2177 +				window->title = NULL;
  1.2178 +			}
  1.2179 +			if (window->renderer) {
  1.2180 +				SDL_DestroyRenderer(window->id);
  1.2181 +				window->renderer = NULL;
  1.2182 +			}
  1.2183 +			if (_this->DestroyWindow) {
  1.2184 +				_this->DestroyWindow(_this, window);
  1.2185 +			}
  1.2186 +			if (j != display->num_windows - 1) {
  1.2187 +				SDL_memcpy(&display->windows[i],
  1.2188 +					   &display->windows[i + 1],
  1.2189 +					   (display->num_windows - i - 1) * sizeof(*window));
  1.2190 +			}
  1.2191 +			--display->num_windows;
  1.2192 +			return;
  1.2193 +		}
  1.2194 +	}
  1.2195  }
  1.2196  
  1.2197  void
  1.2198  SDL_AddRenderDriver(int displayIndex, const SDL_RenderDriver * driver)
  1.2199  {
  1.2200 -    SDL_VideoDisplay *display;
  1.2201 -    SDL_RenderDriver *render_drivers;
  1.2202 +	SDL_VideoDisplay *display;
  1.2203 +	SDL_RenderDriver *render_drivers;
  1.2204  
  1.2205 -    if (displayIndex >= _this->num_displays) {
  1.2206 -        return;
  1.2207 -    }
  1.2208 -    display = &_this->displays[displayIndex];
  1.2209 +	if (displayIndex >= _this->num_displays) {
  1.2210 +		return;
  1.2211 +	}
  1.2212 +	display = &_this->displays[displayIndex];
  1.2213  
  1.2214 -    render_drivers =
  1.2215 -        SDL_realloc(display->render_drivers,
  1.2216 -                    (display->num_render_drivers +
  1.2217 -                     1) * sizeof(*render_drivers));
  1.2218 -    if (render_drivers) {
  1.2219 -        render_drivers[display->num_render_drivers] = *driver;
  1.2220 -        display->render_drivers = render_drivers;
  1.2221 -        display->num_render_drivers++;
  1.2222 -    }
  1.2223 +	render_drivers =
  1.2224 +		SDL_realloc(display->render_drivers,
  1.2225 +			    (display->num_render_drivers +
  1.2226 +			     1) * sizeof(*render_drivers));
  1.2227 +	if (render_drivers) {
  1.2228 +		render_drivers[display->num_render_drivers] = *driver;
  1.2229 +		display->render_drivers = render_drivers;
  1.2230 +		display->num_render_drivers++;
  1.2231 +	}
  1.2232  }
  1.2233  
  1.2234  int
  1.2235  SDL_GetNumRenderDrivers(void)
  1.2236  {
  1.2237 -    if (_this) {
  1.2238 -        return SDL_CurrentDisplay.num_render_drivers;
  1.2239 -    }
  1.2240 -    return 0;
  1.2241 +	if (_this) {
  1.2242 +		return SDL_CurrentDisplay.num_render_drivers;
  1.2243 +	}
  1.2244 +	return 0;
  1.2245  }
  1.2246  
  1.2247  int
  1.2248  SDL_GetRenderDriverInfo(int index, SDL_RendererInfo * info)
  1.2249  {
  1.2250 -    if (!_this) {
  1.2251 -        SDL_UninitializedVideo();
  1.2252 -        return -1;
  1.2253 -    }
  1.2254 -
  1.2255 -    if (index < 0 || index >= SDL_GetNumRenderDrivers()) {
  1.2256 -        SDL_SetError("index must be in the range of 0 - %d",
  1.2257 -                     SDL_GetNumRenderDrivers() - 1);
  1.2258 -        return -1;
  1.2259 -    }
  1.2260 -    *info = SDL_CurrentDisplay.render_drivers[index].info;
  1.2261 -    return 0;
  1.2262 +	if (!_this) {
  1.2263 +		SDL_UninitializedVideo();
  1.2264 +		return -1;
  1.2265 +	}
  1.2266 +	if (index < 0 || index >= SDL_GetNumRenderDrivers()) {
  1.2267 +		SDL_SetError("index must be in the range of 0 - %d",
  1.2268 +			     SDL_GetNumRenderDrivers() - 1);
  1.2269 +		return -1;
  1.2270 +	}
  1.2271 +	*info = SDL_CurrentDisplay.render_drivers[index].info;
  1.2272 +	return 0;
  1.2273  }
  1.2274  
  1.2275  int
  1.2276  SDL_CreateRenderer(SDL_WindowID windowID, int index, Uint32 flags)
  1.2277  {
  1.2278 -    SDL_Window *window = SDL_GetWindowFromID(windowID);
  1.2279 -
  1.2280 -    if (!window) {
  1.2281 -        return 0;
  1.2282 -    }
  1.2283 +	SDL_Window     *window = SDL_GetWindowFromID(windowID);
  1.2284  
  1.2285 -    if (index < 0) {
  1.2286 -        const char *override = SDL_getenv("SDL_VIDEO_RENDERER");
  1.2287 -        int n = SDL_GetNumRenderDrivers();
  1.2288 -        for (index = 0; index < n; ++index) {
  1.2289 -            SDL_RenderDriver *driver =
  1.2290 -                &SDL_CurrentDisplay.render_drivers[index];
  1.2291 +	if (!window) {
  1.2292 +		return 0;
  1.2293 +	}
  1.2294 +	if (index < 0) {
  1.2295 +		const char     *override = SDL_getenv("SDL_VIDEO_RENDERER");
  1.2296 +		int             n = SDL_GetNumRenderDrivers();
  1.2297 +		for (index = 0; index < n; ++index) {
  1.2298 +			SDL_RenderDriver *driver =
  1.2299 +			&SDL_CurrentDisplay.render_drivers[index];
  1.2300  
  1.2301 -            if (override) {
  1.2302 -                if (SDL_strcasecmp(override, driver->info.name) == 0) {
  1.2303 -                    break;
  1.2304 -                }
  1.2305 -            } else {
  1.2306 -                if ((driver->info.flags & flags) == flags) {
  1.2307 -                    break;
  1.2308 -                }
  1.2309 -            }
  1.2310 -        }
  1.2311 -        if (index == n) {
  1.2312 -            SDL_SetError("Couldn't find matching render driver");
  1.2313 -            return -1;
  1.2314 -        }
  1.2315 -    }
  1.2316 +			if (override) {
  1.2317 +				if (SDL_strcasecmp(override, driver->info.name) == 0) {
  1.2318 +					break;
  1.2319 +				}
  1.2320 +			} else {
  1.2321 +				if ((driver->info.flags & flags) == flags) {
  1.2322 +					break;
  1.2323 +				}
  1.2324 +			}
  1.2325 +		}
  1.2326 +		if (index == n) {
  1.2327 +			SDL_SetError("Couldn't find matching render driver");
  1.2328 +			return -1;
  1.2329 +		}
  1.2330 +	}
  1.2331 +	if (index >= SDL_GetNumRenderDrivers()) {
  1.2332 +		SDL_SetError("index must be -1 or in the range of 0 - %d",
  1.2333 +			     SDL_GetNumRenderDrivers() - 1);
  1.2334 +		return -1;
  1.2335 +	}
  1.2336 +	/* Free any existing renderer */
  1.2337 +	SDL_DestroyRenderer(windowID);
  1.2338  
  1.2339 -    if (index >= SDL_GetNumRenderDrivers()) {
  1.2340 -        SDL_SetError("index must be -1 or in the range of 0 - %d",
  1.2341 -                     SDL_GetNumRenderDrivers() - 1);
  1.2342 -        return -1;
  1.2343 -    }
  1.2344 +	/* Create a new renderer instance */
  1.2345 +	window->renderer = SDL_CurrentDisplay.render_drivers[index]
  1.2346 +		.CreateRenderer(window, flags);
  1.2347 +	SDL_SelectRenderer(window->id);
  1.2348  
  1.2349 -    /* Free any existing renderer */
  1.2350 -    SDL_DestroyRenderer(windowID);
  1.2351 -
  1.2352 -    /* Create a new renderer instance */
  1.2353 -    window->renderer = SDL_CurrentDisplay.render_drivers[index]
  1.2354 -        .CreateRenderer(window, flags);
  1.2355 -    SDL_SelectRenderer(window->id);
  1.2356 -
  1.2357 -    return 0;
  1.2358 +	return 0;
  1.2359  }
  1.2360  
  1.2361  int
  1.2362  SDL_SelectRenderer(SDL_WindowID windowID)
  1.2363  {
  1.2364 -    SDL_Window *window = SDL_GetWindowFromID(windowID);
  1.2365 -    SDL_Renderer *renderer;
  1.2366 +	SDL_Window     *window = SDL_GetWindowFromID(windowID);
  1.2367 +	SDL_Renderer   *renderer;
  1.2368  
  1.2369 -    if (!window || !window->renderer) {
  1.2370 -        return -1;
  1.2371 -    }
  1.2372 -    renderer = window->renderer;
  1.2373 -    if (renderer && renderer->ActivateRenderer) {
  1.2374 -        if (renderer->ActivateRenderer(renderer) < 0) {
  1.2375 -            return -1;
  1.2376 -        }
  1.2377 -    }
  1.2378 -    SDL_CurrentDisplay.current_renderer = renderer;
  1.2379 -    return 0;
  1.2380 +	if (!window || !window->renderer) {
  1.2381 +		return -1;
  1.2382 +	}
  1.2383 +	renderer = window->renderer;
  1.2384 +	if (renderer && renderer->ActivateRenderer) {
  1.2385 +		if (renderer->ActivateRenderer(renderer) < 0) {
  1.2386 +			return -1;
  1.2387 +		}
  1.2388 +	}
  1.2389 +	SDL_CurrentDisplay.current_renderer = renderer;
  1.2390 +	return 0;
  1.2391  }
  1.2392  
  1.2393  int
  1.2394  SDL_GetRendererInfo(SDL_RendererInfo * info)
  1.2395  {
  1.2396 -    if (!_this) {
  1.2397 -        SDL_UninitializedVideo();
  1.2398 -        return -1;
  1.2399 -    }
  1.2400 -
  1.2401 -    if (!SDL_CurrentDisplay.current_renderer) {
  1.2402 -        SDL_SetError("There is no current renderer");
  1.2403 -        return -1;
  1.2404 -    }
  1.2405 -    *info = SDL_CurrentDisplay.current_renderer->info;
  1.2406 -    return 0;
  1.2407 +	if (!_this) {
  1.2408 +		SDL_UninitializedVideo();
  1.2409 +		return -1;
  1.2410 +	}
  1.2411 +	if (!SDL_CurrentDisplay.current_renderer) {
  1.2412 +		SDL_SetError("There is no current renderer");
  1.2413 +		return -1;
  1.2414 +	}
  1.2415 +	*info = SDL_CurrentDisplay.current_renderer->info;
  1.2416 +	return 0;
  1.2417  }
  1.2418  
  1.2419  SDL_TextureID
  1.2420  SDL_CreateTexture(Uint32 format, int access, int w, int h)
  1.2421  {
  1.2422 -    int hash;
  1.2423 -    SDL_Renderer *renderer;
  1.2424 -    SDL_Texture *texture;
  1.2425 -
  1.2426 -    if (!_this) {
  1.2427 -        SDL_UninitializedVideo();
  1.2428 -        return 0;
  1.2429 -    }
  1.2430 -
  1.2431 -    renderer = SDL_CurrentDisplay.current_renderer;
  1.2432 -    if (!renderer || !renderer->CreateTexture) {
  1.2433 -        return 0;
  1.2434 -    }
  1.2435 -
  1.2436 -    texture = (SDL_Texture *) SDL_calloc(1, sizeof(*texture));
  1.2437 -    if (!texture) {
  1.2438 -        SDL_OutOfMemory();
  1.2439 -        return 0;
  1.2440 -    }
  1.2441 +	int             hash;
  1.2442 +	SDL_Renderer   *renderer;
  1.2443 +	SDL_Texture    *texture;
  1.2444  
  1.2445 -    texture->id = _this->next_object_id++;
  1.2446 -    texture->format = format;
  1.2447 -    texture->access = access;
  1.2448 -    texture->w = w;
  1.2449 -    texture->h = h;
  1.2450 -    texture->r = 255;
  1.2451 -    texture->g = 255;
  1.2452 -    texture->b = 255;
  1.2453 -    texture->a = 255;
  1.2454 -    texture->renderer = renderer;
  1.2455 +	if (!_this) {
  1.2456 +		SDL_UninitializedVideo();
  1.2457 +		return 0;
  1.2458 +	}
  1.2459 +	renderer = SDL_CurrentDisplay.current_renderer;
  1.2460 +	if (!renderer || !renderer->CreateTexture) {
  1.2461 +		return 0;
  1.2462 +	}
  1.2463 +	texture = (SDL_Texture *) SDL_calloc(1, sizeof(*texture));
  1.2464 +	if (!texture) {
  1.2465 +		SDL_OutOfMemory();
  1.2466 +		return 0;
  1.2467 +	}
  1.2468 +	texture->id = _this->next_object_id++;
  1.2469 +	texture->format = format;
  1.2470 +	texture->access = access;
  1.2471 +	texture->w = w;
  1.2472 +	texture->h = h;
  1.2473 +	texture->r = 255;
  1.2474 +	texture->g = 255;
  1.2475 +	texture->b = 255;
  1.2476 +	texture->a = 255;
  1.2477 +	texture->renderer = renderer;
  1.2478  
  1.2479 -    if (renderer->CreateTexture(renderer, texture) < 0) {
  1.2480 -        if (renderer->DestroyTexture) {
  1.2481 -            renderer->DestroyTexture(renderer, texture);
  1.2482 -        }
  1.2483 -        SDL_free(texture);
  1.2484 -        return 0;
  1.2485 -    }
  1.2486 +	if (renderer->CreateTexture(renderer, texture) < 0) {
  1.2487 +		if (renderer->DestroyTexture) {
  1.2488 +			renderer->DestroyTexture(renderer, texture);
  1.2489 +		}
  1.2490 +		SDL_free(texture);
  1.2491 +		return 0;
  1.2492 +	}
  1.2493 +	hash = (texture->id % SDL_arraysize(SDL_CurrentDisplay.textures));
  1.2494 +	texture->next = SDL_CurrentDisplay.textures[hash];
  1.2495 +	SDL_CurrentDisplay.textures[hash] = texture;
  1.2496  
  1.2497 -    hash = (texture->id % SDL_arraysize(SDL_CurrentDisplay.textures));
  1.2498 -    texture->next = SDL_CurrentDisplay.textures[hash];
  1.2499 -    SDL_CurrentDisplay.textures[hash] = texture;
  1.2500 -
  1.2501 -    return texture->id;
  1.2502 +	return texture->id;
  1.2503  }
  1.2504  
  1.2505  SDL_TextureID
  1.2506  SDL_CreateTextureFromSurface(Uint32 format, SDL_Surface * surface)
  1.2507  {
  1.2508 -    SDL_TextureID textureID;
  1.2509 -    SDL_PixelFormat *fmt;
  1.2510 -    int bpp;
  1.2511 -    Uint32 Rmask, Gmask, Bmask, Amask;
  1.2512 +	SDL_TextureID   textureID;
  1.2513 +	SDL_PixelFormat *fmt;
  1.2514 +	int             bpp;
  1.2515 +	Uint32          Rmask, Gmask, Bmask, Amask;
  1.2516  
  1.2517 -    if (!surface) {
  1.2518 -        SDL_SetError("SDL_CreateTextureFromSurface() passed NULL surface");
  1.2519 -        return 0;
  1.2520 -    }
  1.2521 -    fmt = surface->format;
  1.2522 +	if (!surface) {
  1.2523 +		SDL_SetError("SDL_CreateTextureFromSurface() passed NULL surface");
  1.2524 +		return 0;
  1.2525 +	}
  1.2526 +	fmt = surface->format;
  1.2527  
  1.2528 -    if (format) {
  1.2529 -        if (!SDL_PixelFormatEnumToMasks
  1.2530 -            (format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
  1.2531 -            SDL_SetError("Unknown pixel format");
  1.2532 -            return 0;
  1.2533 -        }
  1.2534 -    } else {
  1.2535 -        if (surface->format->Amask
  1.2536 -            || !(surface->map->info.flags &
  1.2537 -                 (SDL_COPY_COLORKEY | SDL_COPY_MASK | SDL_COPY_BLEND))) {
  1.2538 -            bpp = fmt->BitsPerPixel;
  1.2539 -            Rmask = fmt->Rmask;
  1.2540 -            Gmask = fmt->Gmask;
  1.2541 -            Bmask = fmt->Bmask;
  1.2542 -            Amask = fmt->Amask;
  1.2543 -        } else {
  1.2544 -            /* Need a format with alpha */
  1.2545 -            bpp = 32;
  1.2546 -            Rmask = 0x00FF0000;
  1.2547 -            Gmask = 0x0000FF00;
  1.2548 -            Bmask = 0x000000FF;
  1.2549 -            Amask = 0xFF000000;
  1.2550 -        }
  1.2551 -        format = SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask);
  1.2552 -        if (!format) {
  1.2553 -            SDL_SetError("Unknown pixel format");
  1.2554 -            return 0;
  1.2555 -        }
  1.2556 -    }
  1.2557 -
  1.2558 -    textureID =
  1.2559 -        SDL_CreateTexture(format, SDL_TEXTUREACCESS_STATIC, surface->w,
  1.2560 -                          surface->h);
  1.2561 -    if (!textureID) {
  1.2562 -        return 0;
  1.2563 -    }
  1.2564 +	if (format) {
  1.2565 +		if (!SDL_PixelFormatEnumToMasks
  1.2566 +		    (format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
  1.2567 +			SDL_SetError("Unknown pixel format");
  1.2568 +			return 0;
  1.2569 +		}
  1.2570 +	} else {
  1.2571 +		if (surface->format->Amask
  1.2572 +		    || !(surface->map->info.flags &
  1.2573 +		    (SDL_COPY_COLORKEY | SDL_COPY_MASK | SDL_COPY_BLEND))) {
  1.2574 +			bpp = fmt->BitsPerPixel;
  1.2575 +			Rmask = fmt->Rmask;
  1.2576 +			Gmask = fmt->Gmask;
  1.2577 +			Bmask = fmt->Bmask;
  1.2578 +			Amask = fmt->Amask;
  1.2579 +		} else {
  1.2580 +			/* Need a format with alpha */
  1.2581 +			bpp = 32;
  1.2582 +			Rmask = 0x00FF0000;
  1.2583 +			Gmask = 0x0000FF00;
  1.2584 +			Bmask = 0x000000FF;
  1.2585 +			Amask = 0xFF000000;
  1.2586 +		}
  1.2587 +		format = SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask);
  1.2588 +		if (!format) {
  1.2589 +			SDL_SetError("Unknown pixel format");
  1.2590 +			return 0;
  1.2591 +		}
  1.2592 +	}
  1.2593  
  1.2594 -    if (bpp == fmt->BitsPerPixel && Rmask == fmt->Rmask && Gmask == fmt->Gmask
  1.2595 -        && Bmask == fmt->Bmask && Amask == fmt->Amask) {
  1.2596 -        if (SDL_MUSTLOCK(surface)) {
  1.2597 -            if (SDL_LockSurface(surface) < 0) {
  1.2598 -                SDL_DestroyTexture(textureID);
  1.2599 -                return 0;
  1.2600 -            }
  1.2601 -            SDL_UpdateTexture(textureID, NULL, surface->pixels,
  1.2602 -                              surface->pitch);
  1.2603 -            SDL_UnlockSurface(surface);
  1.2604 -        } else {
  1.2605 -            SDL_UpdateTexture(textureID, NULL, surface->pixels,
  1.2606 -                              surface->pitch);
  1.2607 -        }
  1.2608 -    } else {
  1.2609 -        SDL_PixelFormat *dst_fmt;
  1.2610 -        SDL_Surface *dst = NULL;
  1.2611 +	textureID =
  1.2612 +		SDL_CreateTexture(format, SDL_TEXTUREACCESS_STATIC, surface->w,
  1.2613 +				  surface->h);
  1.2614 +	if (!textureID) {
  1.2615 +		return 0;
  1.2616 +	}
  1.2617 +	if (bpp == fmt->BitsPerPixel && Rmask == fmt->Rmask && Gmask == fmt->Gmask
  1.2618 +	    && Bmask == fmt->Bmask && Amask == fmt->Amask) {
  1.2619 +		if (SDL_MUSTLOCK(surface)) {
  1.2620 +			if (SDL_LockSurface(surface) < 0) {
  1.2621 +				SDL_DestroyTexture(textureID);
  1.2622 +				return 0;
  1.2623 +			}
  1.2624 +			SDL_UpdateTexture(textureID, NULL, surface->pixels,
  1.2625 +					  surface->pitch);
  1.2626 +			SDL_UnlockSurface(surface);
  1.2627 +		} else {
  1.2628 +			SDL_UpdateTexture(textureID, NULL, surface->pixels,
  1.2629 +					  surface->pitch);
  1.2630 +		}
  1.2631 +	} else {
  1.2632 +		SDL_PixelFormat *dst_fmt;
  1.2633 +		SDL_Surface    *dst = NULL;
  1.2634  
  1.2635 -        /* Set up a destination surface for the texture update */
  1.2636 -        dst_fmt = SDL_AllocFormat(bpp, Rmask, Gmask, Bmask, Amask);
  1.2637 -        if (dst_fmt) {
  1.2638 -            if (SDL_ISPIXELFORMAT_INDEXED(format)) {
  1.2639 -                dst_fmt->palette =
  1.2640 -                    SDL_AllocPalette((1 << SDL_BITSPERPIXEL(format)));
  1.2641 -                if (dst_fmt->palette) {
  1.2642 -                    /* FIXME: Should we try to copy fmt->palette? */
  1.2643 -                    SDL_DitherColors(dst_fmt->palette->colors,
  1.2644 -                                     SDL_BITSPERPIXEL(format));
  1.2645 -                }
  1.2646 -            }
  1.2647 +		/* Set up a destination surface for the texture update */
  1.2648 +		dst_fmt = SDL_AllocFormat(bpp, Rmask, Gmask, Bmask, Amask);
  1.2649 +		if (dst_fmt) {
  1.2650 +			if (SDL_ISPIXELFORMAT_INDEXED(format)) {
  1.2651 +				dst_fmt->palette =
  1.2652 +					SDL_AllocPalette((1 << SDL_BITSPERPIXEL(format)));
  1.2653 +				if (dst_fmt->palette) {
  1.2654 +					/*
  1.2655 +					 * FIXME: Should we try to copy
  1.2656 +					 * fmt->palette?
  1.2657 +					 */
  1.2658 +					SDL_DitherColors(dst_fmt->palette->colors,
  1.2659 +						  SDL_BITSPERPIXEL(format));
  1.2660 +				}
  1.2661 +			}
  1.2662 +			dst = SDL_ConvertSurface(surface, dst_fmt, 0);
  1.2663 +			if (dst) {
  1.2664 +				SDL_UpdateTexture(textureID, NULL, dst->pixels, dst->pitch);
  1.2665 +				SDL_FreeSurface(dst);
  1.2666 +			}
  1.2667 +			if (dst_fmt->palette) {
  1.2668 +				SDL_FreePalette(dst_fmt->palette);
  1.2669 +			}
  1.2670 +			SDL_FreeFormat(dst_fmt);
  1.2671 +		}
  1.2672 +		if (!dst) {
  1.2673 +			SDL_DestroyTexture(textureID);
  1.2674 +			return 0;
  1.2675 +		}
  1.2676 +	}
  1.2677  
  1.2678 -            dst = SDL_ConvertSurface(surface, dst_fmt, 0);
  1.2679 -            if (dst) {
  1.2680 -                SDL_UpdateTexture(textureID, NULL, dst->pixels, dst->pitch);
  1.2681 -                SDL_FreeSurface(dst);
  1.2682 -            }
  1.2683 -            if (dst_fmt->palette) {
  1.2684 -                SDL_FreePalette(dst_fmt->palette);
  1.2685 -            }
  1.2686 -            SDL_FreeFormat(dst_fmt);
  1.2687 -        }
  1.2688 -        if (!dst) {
  1.2689 -            SDL_DestroyTexture(textureID);
  1.2690 -            return 0;
  1.2691 -        }
  1.2692 -    }
  1.2693 -
  1.2694 -    if (SDL_ISPIXELFORMAT_INDEXED(format) && fmt->palette) {
  1.2695 -        SDL_SetTexturePalette(textureID, fmt->palette->colors, 0,
  1.2696 -                              fmt->palette->ncolors);
  1.2697 -    }
  1.2698 -
  1.2699 -    return textureID;
  1.2700 +	if (SDL_ISPIXELFORMAT_INDEXED(format) && fmt->palette) {
  1.2701 +		SDL_SetTexturePalette(textureID, fmt->palette->colors, 0,
  1.2702 +				      fmt->palette->ncolors);
  1.2703 +	}
  1.2704 +	return textureID;
  1.2705  }
  1.2706  
  1.2707  static __inline__ SDL_Texture *
  1.2708  SDL_GetTextureFromID(SDL_TextureID textureID)
  1.2709  {
  1.2710 -    int hash;
  1.2711 -    SDL_Texture *texture;
  1.2712 -
  1.2713 -    if (!_this) {
  1.2714 -        return NULL;
  1.2715 -    }
  1.2716 +	int             hash;
  1.2717 +	SDL_Texture    *texture;
  1.2718  
  1.2719 -    hash = (textureID % SDL_arraysize(SDL_CurrentDisplay.textures));
  1.2720 -    for (texture = SDL_CurrentDisplay.textures[hash]; texture;
  1.2721 -         texture = texture->next) {
  1.2722 -        if (texture->id == textureID) {
  1.2723 -            return texture;
  1.2724 -        }
  1.2725 -    }
  1.2726 -    return NULL;
  1.2727 +	if (!_this) {
  1.2728 +		return NULL;
  1.2729 +	}
  1.2730 +	hash = (textureID % SDL_arraysize(SDL_CurrentDisplay.textures));
  1.2731 +	for (texture = SDL_CurrentDisplay.textures[hash]; texture;
  1.2732 +	     texture = texture->next) {
  1.2733 +		if (texture->id == textureID) {
  1.2734 +			return texture;
  1.2735 +		}
  1.2736 +	}
  1.2737 +	return NULL;
  1.2738  }
  1.2739  
  1.2740  int
  1.2741  SDL_QueryTexture(SDL_TextureID textureID, Uint32 * format, int *access,
  1.2742 -                 int *w, int *h)
  1.2743 +		 int *w, int *h)
  1.2744  {
  1.2745 -    SDL_Texture *texture = SDL_GetTextureFromID(textureID);
  1.2746 -
  1.2747 -    if (!texture) {
  1.2748 -        return -1;
  1.2749 -    }
  1.2750 +	SDL_Texture    *texture = SDL_GetTextureFromID(textureID);
  1.2751  
  1.2752 -    if (format) {
  1.2753 -        *format = texture->format;
  1.2754 -    }
  1.2755 -    if (access) {
  1.2756 -        *access = texture->access;
  1.2757 -    }
  1.2758 -    if (w) {
  1.2759 -        *w = texture->w;
  1.2760 -    }
  1.2761 -    if (h) {
  1.2762 -        *h = texture->h;
  1.2763 -    }
  1.2764 -    return 0;
  1.2765 +	if (!texture) {
  1.2766 +		return -1;
  1.2767 +	}
  1.2768 +	if (format) {
  1.2769 +		*format = texture->format;
  1.2770 +	}
  1.2771 +	if (access) {
  1.2772 +		*access = texture->access;
  1.2773 +	}
  1.2774 +	if (w) {
  1.2775 +		*w = texture->w;
  1.2776 +	}
  1.2777 +	if (h) {
  1.2778 +		*h = texture->h;
  1.2779 +	}
  1.2780 +	return 0;
  1.2781  }
  1.2782  
  1.2783  int
  1.2784  SDL_QueryTexturePixels(SDL_TextureID textureID, void **pixels, int *pitch)
  1.2785  {
  1.2786 -    SDL_Texture *texture = SDL_GetTextureFromID(textureID);
  1.2787 -    SDL_Renderer *renderer;
  1.2788 +	SDL_Texture    *texture = SDL_GetTextureFromID(textureID);
  1.2789 +	SDL_Renderer   *renderer;
  1.2790  
  1.2791 -    if (!texture) {
  1.2792 -        return -1;
  1.2793 -    }
  1.2794 -
  1.2795 -    renderer = texture->renderer;
  1.2796 -    if (!renderer->QueryTexturePixels) {
  1.2797 -        return -1;
  1.2798 -    }
  1.2799 -    return renderer->QueryTexturePixels(renderer, texture, pixels, pitch);
  1.2800 +	if (!texture) {
  1.2801 +		return -1;
  1.2802 +	}
  1.2803 +	renderer = texture->renderer;
  1.2804 +	if (!renderer->QueryTexturePixels) {
  1.2805 +		return -1;
  1.2806 +	}
  1.2807 +	return renderer->QueryTexturePixels(renderer, texture, pixels, pitch);
  1.2808  }
  1.2809  
  1.2810  int
  1.2811  SDL_SetTexturePalette(SDL_TextureID textureID, const SDL_Color * colors,
  1.2812 -                      int firstcolor, int ncolors)
  1.2813 +		      int firstcolor, int ncolors)
  1.2814  {
  1.2815 -    SDL_Texture *texture = SDL_GetTextureFromID(textureID);
  1.2816 -    SDL_Renderer *renderer;
  1.2817 +	SDL_Texture    *texture = SDL_GetTextureFromID(textureID);
  1.2818 +	SDL_Renderer   *renderer;
  1.2819  
  1.2820 -    if (!texture) {
  1.2821 -        return -1;
  1.2822 -    }
  1.2823 -
  1.2824 -    renderer = texture->renderer;
  1.2825 -    if (!renderer->SetTexturePalette) {
  1.2826 -        return -1;
  1.2827 -    }
  1.2828 -    return renderer->SetTexturePalette(renderer, texture, colors, firstcolor,
  1.2829 -                                       ncolors);
  1.2830 +	if (!texture) {
  1.2831 +		return -1;
  1.2832 +	}
  1.2833 +	renderer = texture->renderer;
  1.2834 +	if (!renderer->SetTexturePalette) {
  1.2835 +		return -1;
  1.2836 +	}
  1.2837 +	return renderer->SetTexturePalette(renderer, texture, colors, firstcolor,
  1.2838 +					   ncolors);
  1.2839  }
  1.2840  
  1.2841  int
  1.2842  SDL_GetTexturePalette(SDL_TextureID textureID, SDL_Color * colors,
  1.2843 -                      int firstcolor, int ncolors)
  1.2844 +		      int firstcolor, int ncolors)
  1.2845  {
  1.2846 -    SDL_Texture *texture = SDL_GetTextureFromID(textureID);
  1.2847 -    SDL_Renderer *renderer;
  1.2848 +	SDL_Texture    *texture = SDL_GetTextureFromID(textureID);
  1.2849 +	SDL_Renderer   *renderer;
  1.2850  
  1.2851 -    if (!texture) {
  1.2852 -        return -1;
  1.2853 -    }
  1.2854 -
  1.2855 -    renderer = texture->renderer;
  1.2856 -    if (!renderer->GetTexturePalette) {
  1.2857 -        return -1;
  1.2858 -    }
  1.2859 -    return renderer->GetTexturePalette(renderer, texture, colors, firstcolor,
  1.2860 -                                       ncolors);
  1.2861 +	if (!texture) {
  1.2862 +		return -1;
  1.2863 +	}
  1.2864 +	renderer = texture->renderer;
  1.2865 +	if (!renderer->GetTexturePalette) {
  1.2866 +		return -1;
  1.2867 +	}
  1.2868 +	return renderer->GetTexturePalette(renderer, texture, colors, firstcolor,
  1.2869 +					   ncolors);
  1.2870  }
  1.2871  
  1.2872  int
  1.2873  SDL_SetTextureColorMod(SDL_TextureID textureID, Uint8 r, Uint8 g, Uint8 b)
  1.2874  {
  1.2875 -    SDL_Texture *texture = SDL_GetTextureFromID(textureID);
  1.2876 -    SDL_Renderer *renderer;
  1.2877 -
  1.2878 -    if (!texture) {
  1.2879 -        return -1;
  1.2880 -    }
  1.2881 +	SDL_Texture    *texture = SDL_GetTextureFromID(textureID);
  1.2882 +	SDL_Renderer   *renderer;
  1.2883  
  1.2884 -    renderer = texture->renderer;
  1.2885 -    if (!renderer->SetTextureColorMod) {
  1.2886 -        return -1;
  1.2887 -    }
  1.2888 -    if (r < 255 || g < 255 || b < 255) {
  1.2889 -        texture->modMode |= SDL_TEXTUREMODULATE_COLOR;
  1.2890 -    } else {
  1.2891 -        texture->modMode &= ~SDL_TEXTUREMODULATE_COLOR;
  1.2892 -    }
  1.2893 -    texture->r = r;
  1.2894 -    texture->g = g;
  1.2895 -    texture->b = b;
  1.2896 -    return renderer->SetTextureColorMod(renderer, texture);
  1.2897 +	if (!texture) {
  1.2898 +		return -1;
  1.2899 +	}
  1.2900 +	renderer = texture->renderer;
  1.2901 +	if (!renderer->SetTextureColorMod) {
  1.2902 +		return -1;
  1.2903 +	}
  1.2904 +	if (r < 255 || g < 255 || b < 255) {
  1.2905 +		texture->modMode |= SDL_TEXTUREMODULATE_COLOR;
  1.2906 +	} else {
  1.2907 +		texture->modMode &= ~SDL_TEXTUREMODULATE_COLOR;
  1.2908 +	}
  1.2909 +	texture->r = r;
  1.2910 +	texture->g = g;
  1.2911 +	texture->b = b;
  1.2912 +	return renderer->SetTextureColorMod(renderer, texture);
  1.2913  }
  1.2914  
  1.2915  int
  1.2916  SDL_GetTextureColorMod(SDL_TextureID textureID, Uint8 * r, Uint8 * g,
  1.2917 -                       Uint8 * b)
  1.2918 +		       Uint8 * b)
  1.2919  {
  1.2920 -    SDL_Texture *texture = SDL_GetTextureFromID(textureID);
  1.2921 -    SDL_Renderer *renderer;
  1.2922 -
  1.2923 -    if (!texture) {
  1.2924 -        return -1;
  1.2925 -    }
  1.2926 +	SDL_Texture    *texture = SDL_GetTextureFromID(textureID);
  1.2927 +	SDL_Renderer   *renderer;
  1.2928  
  1.2929 -    renderer = texture->renderer;
  1.2930 -    if (r) {
  1.2931 -        *r = texture->r;
  1.2932 -    }
  1.2933 -    if (g) {
  1.2934 -        *g = texture->g;
  1.2935 -    }
  1.2936 -    if (b) {
  1.2937 -        *b = texture->b;
  1.2938 -    }
  1.2939 -    return 0;
  1.2940 +	if (!texture) {
  1.2941 +		return -1;
  1.2942 +	}
  1.2943 +	renderer = texture->renderer;
  1.2944 +	if (r) {
  1.2945 +		*r = texture->r;
  1.2946 +	}
  1.2947 +	if (g) {
  1.2948 +		*g = texture->g;
  1.2949 +	}
  1.2950 +	if (b) {
  1.2951 +		*b = texture->b;
  1.2952 +	}
  1.2953 +	return 0;
  1.2954  }
  1.2955  
  1.2956  int
  1.2957  SDL_SetTextureAlphaMod(SDL_TextureID textureID, Uint8 alpha)
  1.2958  {
  1.2959 -    SDL_Texture *texture = SDL_GetTextureFromID(textureID);
  1.2960 -    SDL_Renderer *renderer;
  1.2961 -
  1.2962 -    if (!texture) {
  1.2963 -        return -1;
  1.2964 -    }
  1.2965 +	SDL_Texture    *texture = SDL_GetTextureFromID(textureID);
  1.2966 +	SDL_Renderer   *renderer;
  1.2967  
  1.2968 -    renderer = texture->renderer;
  1.2969 -    if (!renderer->SetTextureAlphaMod) {
  1.2970 -        return -1;
  1.2971 -    }
  1.2972 -    if (alpha < 255) {
  1.2973 -        texture->modMode |= SDL_TEXTUREMODULATE_ALPHA;
  1.2974 -    } else {
  1.2975 -        texture->modMode &= ~SDL_TEXTUREMODULATE_ALPHA;
  1.2976 -    }
  1.2977 -    texture->a = alpha;
  1.2978 -    return renderer->SetTextureAlphaMod(renderer, texture);
  1.2979 +	if (!texture) {
  1.2980 +		return -1;
  1.2981 +	}
  1.2982 +	renderer = texture->renderer;
  1.2983 +	if (!renderer->SetTextureAlphaMod) {
  1.2984 +		return -1;
  1.2985 +	}
  1.2986 +	if (alpha < 255) {
  1.2987 +		texture->modMode |= SDL_TEXTUREMODULATE_ALPHA;
  1.2988 +	} else {
  1.2989 +		texture->modMode &= ~SDL_TEXTUREMODULATE_ALPHA;
  1.2990 +	}
  1.2991 +	texture->a = alpha;
  1.2992 +	return renderer->SetTextureAlphaMod(renderer, texture);
  1.2993  }
  1.2994  
  1.2995  int
  1.2996  SDL_GetTextureAlphaMod(SDL_TextureID textureID, Uint8 * alpha)
  1.2997  {
  1.2998 -    SDL_Texture *texture = SDL_GetTextureFromID(textureID);
  1.2999 +	SDL_Texture    *texture = SDL_GetTextureFromID(textureID);
  1.3000  
  1.3001 -    if (!texture) {
  1.3002 -        return -1;
  1.3003 -    }
  1.3004 -
  1.3005 -    if (alpha) {
  1.3006 -        *alpha = texture->a;
  1.3007 -    }
  1.3008 -    return 0;
  1.3009 +	if (!texture) {
  1.3010 +		return -1;
  1.3011 +	}
  1.3012 +	if (alpha) {
  1.3013 +		*alpha = texture->a;
  1.3014 +	}
  1.3015 +	return 0;
  1.3016  }
  1.3017  
  1.3018  int
  1.3019  SDL_SetTextureBlendMode(SDL_TextureID textureID, int blendMode)
  1.3020  {
  1.3021 -    SDL_Texture *texture = SDL_GetTextureFromID(textureID);
  1.3022 -    SDL_Renderer *renderer;
  1.3023 -
  1.3024 -    if (!texture) {
  1.3025 -        return -1;
  1.3026 -    }
  1.3027 +	SDL_Texture    *texture = SDL_GetTextureFromID(textureID);
  1.3028 +	SDL_Renderer   *renderer;
  1.3029  
  1.3030 -    renderer = texture->renderer;
  1.3031 -    if (!renderer->SetTextureBlendMode) {
  1.3032 -        return -1;
  1.3033 -    }
  1.3034 -    texture->blendMode = blendMode;
  1.3035 -    return renderer->SetTextureBlendMode(renderer, texture);
  1.3036 +	if (!texture) {
  1.3037 +		return -1;
  1.3038 +	}
  1.3039 +	renderer = texture->renderer;
  1.3040 +	if (!renderer->SetTextureBlendMode) {
  1.3041 +		return -1;
  1.3042 +	}
  1.3043 +	texture->blendMode = blendMode;
  1.3044 +	return renderer->SetTextureBlendMode(renderer, texture);
  1.3045  }
  1.3046  
  1.3047  int
  1.3048  SDL_GetTextureBlendMode(SDL_TextureID textureID, int *blendMode)
  1.3049  {
  1.3050 -    SDL_Texture *texture = SDL_GetTextureFromID(textureID);
  1.3051 +	SDL_Texture    *texture = SDL_GetTextureFromID(textureID);
  1.3052  
  1.3053 -    if (!texture) {
  1.3054 -        return -1;
  1.3055 -    }
  1.3056 -
  1.3057 -    if (blendMode) {
  1.3058 -        *blendMode = texture->blendMode;
  1.3059 -    }
  1.3060 -    return 0;
  1.3061 +	if (!texture) {
  1.3062 +		return -1;
  1.3063 +	}
  1.3064 +	if (blendMode) {
  1.3065 +		*blendMode = texture->blendMode;
  1.3066 +	}
  1.3067 +	return 0;
  1.3068  }
  1.3069  
  1.3070  int
  1.3071  SDL_SetTextureScaleMode(SDL_TextureID textureID, int scaleMode)
  1.3072  {
  1.3073 -    SDL_Texture *texture = SDL_GetTextureFromID(textureID);
  1.3074 -    SDL_Renderer *renderer;
  1.3075 -
  1.3076 -    if (!texture) {
  1.3077 -        return -1;
  1.3078 -    }
  1.3079 +	SDL_Texture    *texture = SDL_GetTextureFromID(textureID);
  1.3080 +	SDL_Renderer   *renderer;
  1.3081  
  1.3082 -    renderer = texture->renderer;
  1.3083 -    if (!renderer->SetTextureScaleMode) {
  1.3084 -        return -1;
  1.3085 -    }
  1.3086 -    texture->scaleMode = scaleMode;
  1.3087 -    return renderer->SetTextureScaleMode(renderer, texture);
  1.3088 +	if (!texture) {
  1.3089 +		return -1;
  1.3090 +	}
  1.3091 +	renderer = texture->renderer;
  1.3092 +	if (!renderer->SetTextureScaleMode) {
  1.3093 +		return -1;
  1.3094 +	}
  1.3095 +	texture->scaleMode = scaleMode;
  1.3096 +	return renderer->SetTextureScaleMode(renderer, texture);
  1.3097  }
  1.3098  
  1.3099  int
  1.3100  SDL_GetTextureScaleMode(SDL_TextureID textureID, int *scaleMode)
  1.3101  {
  1.3102 -    SDL_Texture *texture = SDL_GetTextureFromID(textureID);
  1.3103 +	SDL_Texture    *texture = SDL_GetTextureFromID(textureID);
  1.3104  
  1.3105 -    if (!texture) {
  1.3106 -        return -1;
  1.3107 -    }
  1.3108 -
  1.3109 -    if (scaleMode) {
  1.3110 -        *scaleMode = texture->scaleMode;
  1.3111 -    }
  1.3112 -    return 0;
  1.3113 +	if (!texture) {
  1.3114 +		return -1;
  1.3115 +	}
  1.3116 +	if (scaleMode) {
  1.3117 +		*scaleMode = texture->scaleMode;
  1.3118 +	}
  1.3119 +	return 0;
  1.3120  }
  1.3121  
  1.3122  int
  1.3123  SDL_UpdateTexture(SDL_TextureID textureID, const SDL_Rect * rect,
  1.3124 -                  const void *pixels, int pitch)
  1.3125 +		  const void *pixels, int pitch)
  1.3126  {
  1.3127 -    SDL_Texture *texture = SDL_GetTextureFromID(textureID);
  1.3128 -    SDL_Renderer *renderer;
  1.3129 -    SDL_Rect full_rect;
  1.3130 -
  1.3131 -    if (!texture) {
  1.3132 -        return -1;
  1.3133 -    }
  1.3134 +	SDL_Texture    *texture = SDL_GetTextureFromID(textureID);
  1.3135 +	SDL_Renderer   *renderer;
  1.3136 +	SDL_Rect        full_rect;
  1.3137  
  1.3138 -    renderer = texture->renderer;
  1.3139 -    if (!renderer->UpdateTexture) {
  1.3140 -        return -1;
  1.3141 -    }
  1.3142 -
  1.3143 -    if (!rect) {
  1.3144 -        full_rect.x = 0;
  1.3145 -        full_rect.y = 0;
  1.3146 -        full_rect.w = texture->w;
  1.3147 -        full_rect.h = texture->h;
  1.3148 -        rect = &full_rect;
  1.3149 -    }
  1.3150 -
  1.3151 -    return renderer->UpdateTexture(renderer, texture, rect, pixels, pitch);
  1.3152 +	if (!texture) {
  1.3153 +		return -1;
  1.3154 +	}
  1.3155 +	renderer = texture->renderer;
  1.3156 +	if (!renderer->UpdateTexture) {
  1.3157 +		return -1;
  1.3158 +	}
  1.3159 +	if (!rect) {
  1.3160 +		full_rect.x = 0;
  1.3161 +		full_rect.y = 0;
  1.3162 +		full_rect.w = texture->w;
  1.3163 +		full_rect.h = texture->h;
  1.3164 +		rect = &full_rect;
  1.3165 +	}
  1.3166 +	return renderer->UpdateTexture(renderer, texture, rect, pixels, pitch);
  1.3167  }
  1.3168  
  1.3169  int
  1.3170  SDL_LockTexture(SDL_TextureID textureID, const SDL_Rect * rect, int markDirty,
  1.3171 -                void **pixels, int *pitch)
  1.3172 +		void **pixels, int *pitch)
  1.3173  {
  1.3174 -    SDL_Texture *texture = SDL_GetTextureFromID(textureID);
  1.3175 -    SDL_Renderer *renderer;
  1.3176 -    SDL_Rect full_rect;
  1.3177 -
  1.3178 -    if (!texture) {
  1.3179 -        return -1;
  1.3180 -    }
  1.3181 -    if (texture->access != SDL_TEXTUREACCESS_STREAMING) {
  1.3182 -        SDL_SetError("SDL_LockTexture(): texture must be streaming");
  1.3183 -        return -1;
  1.3184 -    }
  1.3185 +	SDL_Texture    *texture = SDL_GetTextureFromID(textureID);
  1.3186 +	SDL_Renderer   *renderer;
  1.3187 +	SDL_Rect        full_rect;
  1.3188  
  1.3189 -    renderer = texture->renderer;
  1.3190 -    if (!renderer->LockTexture) {
  1.3191 -        return -1;
  1.3192 -    }
  1.3193 -
  1.3194 -    if (!rect) {
  1.3195 -        full_rect.x = 0;
  1.3196 -        full_rect.y = 0;
  1.3197 -        full_rect.w = texture->w;
  1.3198 -        full_rect.h = texture->h;
  1.3199 -        rect = &full_rect;
  1.3200 -    }
  1.3201 -
  1.3202 -    return renderer->LockTexture(renderer, texture, rect, markDirty, pixels,
  1.3203 -                                 pitch);
  1.3204 +	if (!texture) {
  1.3205 +		return -1;
  1.3206 +	}
  1.3207 +	if (texture->access != SDL_TEXTUREACCESS_STREAMING) {
  1.3208 +		SDL_SetError("SDL_LockTexture(): texture must be streaming");
  1.3209 +		return -1;
  1.3210 +	}
  1.3211 +	renderer = texture->renderer;
  1.3212 +	if (!renderer->LockTexture) {
  1.3213 +		return -1;
  1.3214 +	}
  1.3215 +	if (!rect) {
  1.3216 +		full_rect.x = 0;
  1.3217 +		full_rect.y = 0;
  1.3218 +		full_rect.w = texture->w;
  1.3219 +		full_rect.h = texture->h;
  1.3220 +		rect = &full_rect;
  1.3221 +	}
  1.3222 +	return renderer->LockTexture(renderer, texture, rect, markDirty, pixels,
  1.3223 +				     pitch);
  1.3224  }
  1.3225  
  1.3226  void
  1.3227  SDL_UnlockTexture(SDL_TextureID textureID)
  1.3228  {
  1.3229 -    SDL_Texture *texture = SDL_GetTextureFromID(textureID);
  1.3230 -    SDL_Renderer *renderer;
  1.3231 +	SDL_Texture    *texture = SDL_GetTextureFromID(textureID);
  1.3232 +	SDL_Renderer   *renderer;
  1.3233  
  1.3234 -    if (!texture) {
  1.3235 -        return;
  1.3236 -    }
  1.3237 -    if (texture->access != SDL_TEXTUREACCESS_STREAMING) {
  1.3238 -        return;
  1.3239 -    }
  1.3240 -
  1.3241 -    renderer = texture->renderer;
  1.3242 -    if (!renderer->UnlockTexture) {
  1.3243 -        return;
  1.3244 -    }
  1.3245 -    renderer->UnlockTexture(renderer, texture);
  1.3246 +	if (!texture) {
  1.3247 +		return;
  1.3248 +	}
  1.3249 +	if (texture->access != SDL_TEXTUREACCESS_STREAMING) {
  1.3250 +		return;
  1.3251 +	}
  1.3252 +	renderer = texture->renderer;
  1.3253 +	if (!renderer->UnlockTexture) {
  1.3254 +		return;
  1.3255 +	}
  1.3256 +	renderer->UnlockTexture(renderer, texture);
  1.3257  }
  1.3258  
  1.3259  void
  1.3260  SDL_DirtyTexture(SDL_TextureID textureID, int numrects,
  1.3261 -                 const SDL_Rect * rects)
  1.3262 +		 const SDL_Rect * rects)
  1.3263  {
  1.3264 -    SDL_Texture *texture = SDL_GetTextureFromID(textureID);
  1.3265 -    SDL_Renderer *renderer;
  1.3266 +	SDL_Texture    *texture = SDL_GetTextureFromID(textureID);
  1.3267 +	SDL_Renderer   *renderer;
  1.3268  
  1.3269 -    if (!texture) {
  1.3270 -        return;
  1.3271 -    }
  1.3272 -    if (texture->access != SDL_TEXTUREACCESS_STREAMING) {
  1.3273 -        return;
  1.3274 -    }
  1.3275 -
  1.3276 -    renderer = texture->renderer;
  1.3277 -    if (!renderer->DirtyTexture) {
  1.3278 -        return;
  1.3279 -    }
  1.3280 -    renderer->DirtyTexture(renderer, texture, numrects, rects);
  1.3281 +	if (!texture) {
  1.3282 +		return;
  1.3283 +	}
  1.3284 +	if (texture->access != SDL_TEXTUREACCESS_STREAMING) {
  1.3285 +		return;
  1.3286 +	}
  1.3287 +	renderer = texture->renderer;
  1.3288 +	if (!renderer->DirtyTexture) {
  1.3289 +		return;
  1.3290 +	}
  1.3291 +	renderer->DirtyTexture(renderer, texture, numrects, rects);
  1.3292  }
  1.3293  
  1.3294  int
  1.3295  SDL_RenderFill(Uint8 r, Uint8 g, Uint8 b, Uint8 a, const SDL_Rect * rect)
  1.3296  {
  1.3297 -    SDL_Renderer *renderer;
  1.3298 -    SDL_Window *window;
  1.3299 -    SDL_Rect real_rect;
  1.3300 -
  1.3301 -    if (!_this) {
  1.3302 -        SDL_UninitializedVideo();
  1.3303 -        return -1;
  1.3304 -    }
  1.3305 +	SDL_Renderer   *renderer;
  1.3306 +	SDL_Window     *window;
  1.3307 +	SDL_Rect        real_rect;
  1.3308  
  1.3309 -    renderer = SDL_CurrentDisplay.current_renderer;
  1.3310 -    if (!renderer || !renderer->RenderFill) {
  1.3311 -        return -1;
  1.3312 -    }
  1.3313 -
  1.3314 -    window = SDL_GetWindowFromID(renderer->window);
  1.3315 -    real_rect.x = 0;
  1.3316 -    real_rect.y = 0;
  1.3317 -    real_rect.w = window->w;
  1.3318 -    real_rect.h = window->h;
  1.3319 -    if (rect) {
  1.3320 -        if (!SDL_IntersectRect(rect, &real_rect, &real_rect)) {
  1.3321 -            return 0;
  1.3322 -        }
  1.3323 -    }
  1.3324 -
  1.3325 -    return renderer->RenderFill(renderer, r, g, b, a, &real_rect);
  1.3326 +	if (!_this) {
  1.3327 +		SDL_UninitializedVideo();
  1.3328 +		return -1;
  1.3329 +	}
  1.3330 +	renderer = SDL_CurrentDisplay.current_renderer;
  1.3331 +	if (!renderer || !renderer->RenderFill) {
  1.3332 +		return -1;
  1.3333 +	}
  1.3334 +	window = SDL_GetWindowFromID(renderer->window);
  1.3335 +	real_rect.x = 0;
  1.3336 +	real_rect.y = 0;
  1.3337 +	real_rect.w = window->w;
  1.3338 +	real_rect.h = window->h;
  1.3339 +	if (rect) {
  1.3340 +		if (!SDL_IntersectRect(rect, &real_rect, &real_rect)) {
  1.3341 +			return 0;
  1.3342 +		}
  1.3343 +	}
  1.3344 +	return renderer->RenderFill(renderer, r, g, b, a, &real_rect);
  1.3345  }
  1.3346  
  1.3347  int
  1.3348  SDL_RenderCopy(SDL_TextureID textureID, const SDL_Rect * srcrect,
  1.3349 -               const SDL_Rect * dstrect)
  1.3350 +	       const SDL_Rect * dstrect)
  1.3351  {
  1.3352 -    SDL_Texture *texture = SDL_GetTextureFromID(textureID);
  1.3353 -    SDL_Renderer *renderer;
  1.3354 -    SDL_Window *window;
  1.3355 -    SDL_Rect real_srcrect;
  1.3356 -    SDL_Rect real_dstrect;
  1.3357 -
  1.3358 -    if (!texture || texture->renderer != SDL_CurrentDisplay.current_renderer) {
  1.3359 -        return -1;
  1.3360 -    }
  1.3361 -
  1.3362 -    renderer = SDL_CurrentDisplay.current_renderer;
  1.3363 -    if (!renderer || !renderer->RenderCopy) {
  1.3364 -        return -1;
  1.3365 -    }
  1.3366 +	SDL_Texture    *texture = SDL_GetTextureFromID(textureID);
  1.3367 +	SDL_Renderer   *renderer;
  1.3368 +	SDL_Window     *window;
  1.3369 +	SDL_Rect        real_srcrect;
  1.3370 +	SDL_Rect        real_dstrect;
  1.3371  
  1.3372 -    window = SDL_GetWindowFromID(renderer->window);
  1.3373 -    if (srcrect) {
  1.3374 -        real_srcrect = *srcrect;
  1.3375 -    } else {
  1.3376 -        real_srcrect.x = 0;
  1.3377 -        real_srcrect.y = 0;
  1.3378 -        real_srcrect.w = texture->w;
  1.3379 -        real_srcrect.h = texture->h;
  1.3380 -    }
  1.3381 -    if (dstrect) {
  1.3382 -        real_dstrect = *dstrect;
  1.3383 -    } else {
  1.3384 -        real_dstrect.x = 0;
  1.3385 -        real_dstrect.y = 0;
  1.3386 -        real_dstrect.w = window->w;
  1.3387 -        real_dstrect.h = window->h;
  1.3388 -    }
  1.3389 +	if (!texture || texture->renderer != SDL_CurrentDisplay.current_renderer) {
  1.3390 +		return -1;
  1.3391 +	}
  1.3392 +	renderer = SDL_CurrentDisplay.current_renderer;
  1.3393 +	if (!renderer || !renderer->RenderCopy) {
  1.3394 +		return -1;
  1.3395 +	}
  1.3396 +	window = SDL_GetWindowFromID(renderer->window);
  1.3397 +	if (srcrect) {
  1.3398 +		real_srcrect = *srcrect;
  1.3399 +	} else {
  1.3400 +		real_srcrect.x = 0;
  1.3401 +		real_srcrect.y = 0;
  1.3402 +		real_srcrect.w = texture->w;
  1.3403 +		real_srcrect.h = texture->h;
  1.3404 +	}
  1.3405 +	if (dstrect) {
  1.3406 +		real_dstrect = *dstrect;
  1.3407 +	} else {
  1.3408 +		real_dstrect.x = 0;
  1.3409 +		real_dstrect.y = 0;
  1.3410 +		real_dstrect.w = window->w;
  1.3411 +		real_dstrect.h = window->h;
  1.3412 +	}
  1.3413  
  1.3414 -    return renderer->RenderCopy(renderer, texture, &real_srcrect,
  1.3415 -                                &real_dstrect);
  1.3416 +	return renderer->RenderCopy(renderer, texture, &real_srcrect,
  1.3417 +				    &real_dstrect);
  1.3418  }
  1.3419  
  1.3420  void
  1.3421  SDL_RenderPresent(void)
  1.3422  {
  1.3423 -    SDL_Renderer *renderer;
  1.3424 +	SDL_Renderer   *renderer;
  1.3425  
  1.3426 -    if (!_this) {
  1.3427 -        SDL_UninitializedVideo();
  1.3428 -        return;
  1.3429 -    }
  1.3430 -
  1.3431 -    renderer = SDL_CurrentDisplay.current_renderer;
  1.3432 -    if (!renderer || !renderer->RenderPresent) {
  1.3433 -        return;
  1.3434 -    }
  1.3435 -    renderer->RenderPresent(renderer);
  1.3436 +	if (!_this) {
  1.3437 +		SDL_UninitializedVideo();
  1.3438 +		return;
  1.3439 +	}
  1.3440 +	renderer = SDL_CurrentDisplay.current_renderer;
  1.3441 +	if (!renderer || !renderer->RenderPresent) {
  1.3442 +		return;
  1.3443 +	}
  1.3444 +	renderer->RenderPresent(renderer);
  1.3445  }
  1.3446  
  1.3447  void
  1.3448  SDL_DestroyTexture(SDL_TextureID textureID)
  1.3449  {
  1.3450 -    int hash;
  1.3451 -    SDL_Texture *prev, *texture;
  1.3452 -    SDL_Renderer *renderer;
  1.3453 -
  1.3454 -    if (!_this) {
  1.3455 -        SDL_UninitializedVideo();
  1.3456 -        return;
  1.3457 -    }
  1.3458 +	int             hash;
  1.3459 +	SDL_Texture    *prev, *texture;
  1.3460 +	SDL_Renderer   *renderer;
  1.3461  
  1.3462 -    /* Look up the texture in the hash table */
  1.3463 -    hash = (textureID % SDL_arraysize(SDL_CurrentDisplay.textures));
  1.3464 -    prev = NULL;
  1.3465 -    for (texture = SDL_CurrentDisplay.textures[hash]; texture;
  1.3466 -         prev = texture, texture = texture->next) {
  1.3467 -        if (texture->id == textureID) {
  1.3468 -            break;
  1.3469 -        }
  1.3470 -    }
  1.3471 -    if (!texture) {
  1.3472 -        return;
  1.3473 -    }
  1.3474 +	if (!_this) {
  1.3475 +		SDL_UninitializedVideo();
  1.3476 +		return;
  1.3477 +	}
  1.3478 +	/* Look up the texture in the hash table */
  1.3479 +	hash = (textureID % SDL_arraysize(SDL_CurrentDisplay.textures));
  1.3480 +	prev = NULL;
  1.3481 +	for (texture = SDL_CurrentDisplay.textures[hash]; texture;
  1.3482 +	     prev = texture, texture = texture->next) {
  1.3483 +		if (texture->id == textureID) {
  1.3484 +			break;
  1.3485 +		}
  1.3486 +	}
  1.3487 +	if (!texture) {
  1.3488 +		return;
  1.3489 +	}
  1.3490 +	/* Unlink the texture from the list */
  1.3491 +	if (prev) {
  1.3492 +		prev->next = texture->next;
  1.3493 +	} else {
  1.3494 +		SDL_CurrentDisplay.textures[hash] = texture->next;
  1.3495 +	}
  1.3496  
  1.3497 -    /* Unlink the texture from the list */
  1.3498 -    if (prev) {
  1.3499 -        prev->next = texture->next;
  1.3500 -    } else {
  1.3501 -        SDL_CurrentDisplay.textures[hash] = texture->next;
  1.3502 -    }
  1.3503 -
  1.3504 -    /* Free the texture */
  1.3505 -    renderer = texture->renderer;
  1.3506 -    renderer->DestroyTexture(renderer, texture);
  1.3507 -    SDL_free(texture);
  1.3508 +	/* Free the texture */
  1.3509 +	renderer = texture->renderer;
  1.3510 +	renderer->DestroyTexture(renderer, texture);
  1.3511 +	SDL_free(texture);
  1.3512  }
  1.3513  
  1.3514  void
  1.3515  SDL_DestroyRenderer(SDL_WindowID windowID)
  1.3516  {
  1.3517 -    SDL_Window *window = SDL_GetWindowFromID(windowID);
  1.3518 -    SDL_Renderer *renderer;
  1.3519 -    int i;
  1.3520 -
  1.3521 -    if (!window) {
  1.3522 -        return;
  1.3523 -    }
  1.3524 -
  1.3525 -    renderer = window->renderer;
  1.3526 -    if (!renderer) {
  1.3527 -        return;
  1.3528 -    }
  1.3529 +	SDL_Window     *window = SDL_GetWindowFromID(windowID);
  1.3530 +	SDL_Renderer   *renderer;
  1.3531 +	int             i;
  1.3532  
  1.3533 -    /* Free existing textures for this renderer */
  1.3534 -    for (i = 0; i < SDL_arraysize(SDL_CurrentDisplay.textures); ++i) {
  1.3535 -        SDL_Texture *texture;
  1.3536 -        SDL_Texture *prev = NULL;
  1.3537 -        SDL_Texture *next;
  1.3538 -        for (texture = SDL_CurrentDisplay.textures[i]; texture;
  1.3539 -             texture = next) {
  1.3540 -            next = texture->next;
  1.3541 -            if (texture->renderer == renderer) {
  1.3542 -                if (prev) {
  1.3543 -                    prev->next = next;
  1.3544 -                } else {
  1.3545 -                    SDL_CurrentDisplay.textures[i] = next;
  1.3546 -                }
  1.3547 -                renderer->DestroyTexture(renderer, texture);
  1.3548 -                SDL_free(texture);
  1.3549 -            } else {
  1.3550 -                prev = texture;
  1.3551 -            }
  1.3552 -        }
  1.3553 -    }
  1.3554 +	if (!window) {
  1.3555 +		return;
  1.3556 +	}
  1.3557 +	renderer = window->renderer;
  1.3558 +	if (!renderer) {
  1.3559 +		return;
  1.3560 +	}
  1.3561 +	/* Free existing textures for this renderer */
  1.3562 +	for (i = 0; i < SDL_arraysize(SDL_CurrentDisplay.textures); ++i) {
  1.3563 +		SDL_Texture    *texture;
  1.3564 +		SDL_Texture    *prev = NULL;
  1.3565 +		SDL_Texture    *next;
  1.3566 +		for (texture = SDL_CurrentDisplay.textures[i]; texture;
  1.3567 +		     texture = next) {
  1.3568 +			next = texture->next;
  1.3569 +			if (texture->renderer == renderer) {
  1.3570 +				if (prev) {
  1.3571 +					prev->next = next;
  1.3572 +				} else {
  1.3573 +					SDL_CurrentDisplay.textures[i] = next;
  1.3574 +				}
  1.3575 +				renderer->DestroyTexture(renderer, texture);
  1.3576 +				SDL_free(texture);
  1.3577 +			} else {
  1.3578 +				prev = texture;
  1.3579 +			}
  1.3580 +		}
  1.3581 +	}
  1.3582  
  1.3583 -    /* Free the renderer instance */
  1.3584 -    renderer->DestroyRenderer(renderer);
  1.3585 +	/* Free the renderer instance */
  1.3586 +	renderer->DestroyRenderer(renderer);
  1.3587  
  1.3588 -    /* Clear references */
  1.3589 -    window->renderer = NULL;
  1.3590 -    if (SDL_CurrentDisplay.current_renderer == renderer) {
  1.3591 -        SDL_CurrentDisplay.current_renderer = NULL;
  1.3592 -    }
  1.3593 +	/* Clear references */
  1.3594 +	window->renderer = NULL;
  1.3595 +	if (SDL_CurrentDisplay.current_renderer == renderer) {
  1.3596 +		SDL_CurrentDisplay.current_renderer = NULL;
  1.3597 +	}
  1.3598  }
  1.3599  
  1.3600  void
  1.3601  SDL_VideoQuit(void)
  1.3602  {
  1.3603 -    int i, j;
  1.3604 +	int             i, j;
  1.3605  
  1.3606 -    if (!_this) {
  1.3607 -        return;
  1.3608 -    }
  1.3609 -
  1.3610 -    /* Halt event processing before doing anything else */
  1.3611 -    SDL_StopEventLoop();
  1.3612 +	if (!_this) {
  1.3613 +		return;
  1.3614 +	}
  1.3615 +	/* Halt event processing before doing anything else */
  1.3616 +	SDL_StopEventLoop();
  1.3617  
  1.3618 -    /* Clean up the system video */
  1.3619 -    for (i = _this->num_displays; i--;) {
  1.3620 -        SDL_VideoDisplay *display = &_this->displays[i];
  1.3621 -        for (j = display->num_windows; j--;) {
  1.3622 -            SDL_DestroyWindow(display->windows[i].id);
  1.3623 -        }
  1.3624 -        if (display->windows) {
  1.3625 -            SDL_free(display->windows);
  1.3626 -            display->windows = NULL;
  1.3627 -        }
  1.3628 -        display->num_windows = 0;
  1.3629 -        if (display->render_drivers) {
  1.3630 -            SDL_free(display->render_drivers);
  1.3631 -            display->render_drivers = NULL;
  1.3632 -        }
  1.3633 -        display->num_render_drivers = 0;
  1.3634 -    }
  1.3635 -    _this->VideoQuit(_this);
  1.3636 +	/* Clean up the system video */
  1.3637 +	for (i = _this->num_displays; i--;) {
  1.3638 +		SDL_VideoDisplay *display = &_this->displays[i];
  1.3639 +		for (j = display->num_windows; j--;) {
  1.3640 +			SDL_DestroyWindow(display->windows[i].id);
  1.3641 +		}
  1.3642 +		if (display->windows) {
  1.3643 +			SDL_free(display->windows);
  1.3644 +			display->windows = NULL;
  1.3645 +		}
  1.3646 +		display->num_windows = 0;
  1.3647 +		if (display->render_drivers) {
  1.3648 +			SDL_free(display->render_drivers);
  1.3649 +			display->render_drivers = NULL;
  1.3650 +		}
  1.3651 +		display->num_render_drivers = 0;
  1.3652 +	}
  1.3653 +	_this->VideoQuit(_this);
  1.3654  
  1.3655 -    for (i = _this->num_displays; i--;) {
  1.3656 -        SDL_VideoDisplay *display = &_this->displays[i];
  1.3657 -        for (j = display->num_display_modes; j--;) {
  1.3658 -            if (display->display_modes[j].driverdata) {
  1.3659 -                SDL_free(display->display_modes[j].driverdata);
  1.3660 -                display->display_modes[j].driverdata = NULL;
  1.3661 -            }
  1.3662 -        }
  1.3663 -        if (display->display_modes) {
  1.3664 -            SDL_free(display->display_modes);
  1.3665 -            display->display_modes = NULL;
  1.3666 -        }
  1.3667 -        if (display->desktop_mode.driverdata) {
  1.3668 -            SDL_free(display->desktop_mode.driverdata);
  1.3669 -            display->desktop_mode.driverdata = NULL;
  1.3670 -        }
  1.3671 -        if (display->palette) {
  1.3672 -            SDL_FreePalette(display->palette);
  1.3673 -            display->palette = NULL;
  1.3674 -        }
  1.3675 -        if (display->gamma) {
  1.3676 -            SDL_free(display->gamma);
  1.3677 -            display->gamma = NULL;
  1.3678 -        }
  1.3679 -        if (display->driverdata) {
  1.3680 -            SDL_free(display->driverdata);
  1.3681 -            display->driverdata = NULL;
  1.3682 -        }
  1.3683 -    }
  1.3684 -    if (_this->displays) {
  1.3685 -        SDL_free(_this->displays);
  1.3686 -        _this->displays = NULL;
  1.3687 -    }
  1.3688 -    _this->free(_this);
  1.3689 -    _this = NULL;
  1.3690 +	for (i = _this->num_displays; i--;) {
  1.3691 +		SDL_VideoDisplay *display = &_this->displays[i];
  1.3692 +		for (j = display->num_display_modes; j--;) {
  1.3693 +			if (display->display_modes[j].driverdata) {
  1.3694 +				SDL_free(display->display_modes[j].driverdata);
  1.3695 +				display->display_modes[j].driverdata = NULL;
  1.3696 +			}
  1.3697 +		}
  1.3698 +		if (display->display_modes) {
  1.3699 +			SDL_free(display->display_modes);
  1.3700 +			display->display_modes = NULL;
  1.3701 +		}
  1.3702 +		if (display->desktop_mode.driverdata) {
  1.3703 +			SDL_free(display->desktop_mode.driverdata);
  1.3704 +			display->desktop_mode.driverdata = NULL;
  1.3705 +		}
  1.3706 +		if (display->palette) {
  1.3707 +			SDL_FreePalette(display->palette);
  1.3708 +			display->palette = NULL;
  1.3709 +		}
  1.3710 +		if (display->gamma) {
  1.3711 +			SDL_free(display->gamma);
  1.3712 +			display->gamma = NULL;
  1.3713 +		}
  1.3714 +		if (display->driverdata) {
  1.3715 +			SDL_free(display->driverdata);
  1.3716 +			display->driverdata = NULL;
  1.3717 +		}
  1.3718 +	}
  1.3719 +	if (_this->displays) {
  1.3720 +		SDL_free(_this->displays);
  1.3721 +		_this->displays = NULL;
  1.3722 +	}
  1.3723 +	_this->free(_this);
  1.3724 +	_this = NULL;
  1.3725  }
  1.3726  
  1.3727  int
  1.3728  SDL_GL_LoadLibrary(const char *path)
  1.3729  {
  1.3730 -    int retval;
  1.3731 -
  1.3732 -    if (!_this) {
  1.3733 -        SDL_UninitializedVideo();
  1.3734 -        return -1;
  1.3735 -    }
  1.3736 +	int             retval;
  1.3737  
  1.3738 -    if (_this->GL_LoadLibrary) {
  1.3739 -        retval = _this->GL_LoadLibrary(_this, path);
  1.3740 -    } else {
  1.3741 -        SDL_SetError("No dynamic GL support in video driver");
  1.3742 -        retval = -1;
  1.3743 -    }
  1.3744 -    return (retval);
  1.3745 +	if (!_this) {
  1.3746 +		SDL_UninitializedVideo();
  1.3747 +		return -1;
  1.3748 +	}
  1.3749 +	if (_this->GL_LoadLibrary) {
  1.3750 +		retval = _this->GL_LoadLibrary(_this, path);
  1.3751 +	} else {
  1.3752 +		SDL_SetError("No dynamic GL support in video driver");
  1.3753 +		retval = -1;
  1.3754 +	}
  1.3755 +	return (retval);
  1.3756  }
  1.3757  
  1.3758 -void *
  1.3759 +void           *
  1.3760  SDL_GL_GetProcAddress(const char *proc)
  1.3761  {
  1.3762 -    void *func;
  1.3763 -
  1.3764 -    if (!_this) {
  1.3765 -        SDL_UninitializedVideo();
  1.3766 -        return NULL;
  1.3767 -    }
  1.3768 +	void           *func;
  1.3769  
  1.3770 -    func = NULL;
  1.3771 -    if (_this->GL_GetProcAddress) {
  1.3772 -        if (_this->gl_config.driver_loaded) {
  1.3773 -            func = _this->GL_GetProcAddress(_this, proc);
  1.3774 -        } else {
  1.3775 -            SDL_SetError("No GL driver has been loaded");
  1.3776 -        }
  1.3777 -    } else {
  1.3778 -        SDL_SetError("No dynamic GL support in video driver");
  1.3779 -    }
  1.3780 -    return func;
  1.3781 +	if (!_this) {
  1.3782 +		SDL_UninitializedVideo();
  1.3783 +		return NULL;
  1.3784 +	}
  1.3785 +	func = NULL;
  1.3786 +	if (_this->GL_GetProcAddress) {
  1.3787 +		if (_this->gl_config.driver_loaded) {
  1.3788 +			func = _this->GL_GetProcAddress(_this, proc);
  1.3789 +		} else {
  1.3790 +			SDL_SetError("No GL driver has been loaded");
  1.3791 +		}
  1.3792 +	} else {
  1.3793 +		SDL_SetError("No dynamic GL support in video driver");
  1.3794 +	}
  1.3795 +	return func;
  1.3796  }
  1.3797  
  1.3798  SDL_bool
  1.3799  SDL_GL_ExtensionSupported(const char *extension)
  1.3800  {
  1.3801  #if SDL_VIDEO_OPENGL
  1.3802 -    const GLubyte *(APIENTRY * glGetStringFunc) (GLenum);
  1.3803 -    const char *extensions;
  1.3804 -    const char *start;
  1.3805 -    const char *where, *terminator;
  1.3806 -
  1.3807 -    /* Extension names should not have spaces. */
  1.3808 -    where = SDL_strchr(extension, ' ');
  1.3809 -    if (where || *extension == '\0') {
  1.3810 -        return SDL_FALSE;
  1.3811 -    }
  1.3812 -
  1.3813 -    /* See if there's an environment variable override */
  1.3814 -    start = SDL_getenv(extension);
  1.3815 -    if (start && *start == '0') {
  1.3816 -        return SDL_FALSE;
  1.3817 -    }
  1.3818 +	const GLubyte  *(APIENTRY * glGetStringFunc) (GLenum);
  1.3819 +	const char     *extensions;
  1.3820 +	const char     *start;
  1.3821 +	const char     *where, *terminator;
  1.3822  
  1.3823 -    /* Lookup the available extensions */
  1.3824 -    glGetStringFunc = SDL_GL_GetProcAddress("glGetString");
  1.3825 -    if (glGetStringFunc) {
  1.3826 -        extensions = (const char *) glGetStringFunc(GL_EXTENSIONS);
  1.3827 -    } else {
  1.3828 -        extensions = NULL;
  1.3829 -    }
  1.3830 -    if (!extensions) {
  1.3831 -        return SDL_FALSE;
  1.3832 -    }
  1.3833 -
  1.3834 -    /* It takes a bit of care to be fool-proof about parsing the
  1.3835 -     * OpenGL extensions string. Don't be fooled by sub-strings,
  1.3836 -     * etc. */
  1.3837 +	/* Extension names should not have spaces. */
  1.3838 +	where = SDL_strchr(extension, ' ');
  1.3839 +	if (where || *extension == '\0') {
  1.3840 +		return SDL_FALSE;
  1.3841 +	}
  1.3842 +	/* See if there's an environment variable override */
  1.3843 +	start = SDL_getenv(extension);
  1.3844 +	if (start && *start == '0') {
  1.3845 +		return SDL_FALSE;
  1.3846 +	}
  1.3847 +	/* Lookup the available extensions */
  1.3848 +	glGetStringFunc = SDL_GL_GetProcAddress("glGetString");
  1.3849 +	if (glGetStringFunc) {
  1.3850 +		extensions = (const char *) glGetStringFunc(GL_EXTENSIONS);
  1.3851 +	} else {
  1.3852 +		extensions = NULL;
  1.3853 +	}
  1.3854 +	if (!extensions) {
  1.3855 +		return SDL_FALSE;
  1.3856 +	}
  1.3857 +	/*
  1.3858 +	 * It takes a bit of care to be fool-proof about parsing the OpenGL
  1.3859 +	 * extensions string. Don't be fooled by sub-strings, etc.
  1.3860 +	 */
  1.3861  
  1.3862 -    start = extensions;
  1.3863 +	start = extensions;
  1.3864  
  1.3865 -    for (;;) {
  1.3866 -        where = SDL_strstr(start, extension);
  1.3867 -        if (!where)
  1.3868 -            break;
  1.3869 +	for (;;) {
  1.3870 +		where = SDL_strstr(start, extension);
  1.3871 +		if (!where)
  1.3872 +			break;
  1.3873  
  1.3874 -        terminator = where + SDL_strlen(extension);
  1.3875 -        if (where == start || *(where - 1) == ' ')
  1.3876 -            if (*terminator == ' ' || *terminator == '\0')
  1.3877 -                return SDL_TRUE;
  1.3878 +		terminator = where + SDL_strlen(extension);
  1.3879 +		if (where == start || *(where - 1) == ' ')
  1.3880 +			if (*terminator == ' ' || *terminator == '\0')
  1.3881 +				return SDL_TRUE;
  1.3882  
  1.3883 -        start = terminator;
  1.3884 -    }
  1.3885 -    return SDL_FALSE;
  1.3886 +		start = terminator;
  1.3887 +	}
  1.3888 +	return SDL_FALSE;
  1.3889  #else
  1.3890 -    return SDL_FALSE;
  1.3891 +	return SDL_FALSE;
  1.3892  #endif
  1.3893  }
  1.3894  
  1.3895 @@ -2341,316 +2257,318 @@
  1.3896  SDL_GL_SetAttribute(SDL_GLattr attr, int value)
  1.3897  {
  1.3898  #if SDL_VIDEO_OPENGL
  1.3899 -    int retval;
  1.3900 -
  1.3901 -    if (!_this) {
  1.3902 -        SDL_UninitializedVideo();
  1.3903 -        return -1;
  1.3904 -    }
  1.3905 +	int             retval;
  1.3906  
  1.3907 -    retval = 0;
  1.3908 -    switch (attr) {
  1.3909 -    case SDL_GL_RED_SIZE:
  1.3910 -        _this->gl_config.red_size = value;
  1.3911 -        break;
  1.3912 -    case SDL_GL_GREEN_SIZE:
  1.3913 -        _this->gl_config.green_size = value;
  1.3914 -        break;
  1.3915 -    case SDL_GL_BLUE_SIZE:
  1.3916 -        _this->gl_config.blue_size = value;
  1.3917 -        break;
  1.3918 -    case SDL_GL_ALPHA_SIZE:
  1.3919 -        _this->gl_config.alpha_size = value;
  1.3920 -        break;
  1.3921 -    case SDL_GL_DOUBLEBUFFER:
  1.3922 -        _this->gl_config.double_buffer = value;
  1.3923 -        break;
  1.3924 -    case SDL_GL_BUFFER_SIZE:
  1.3925 -        _this->gl_config.buffer_size = value;
  1.3926 -        break;
  1.3927 -    case SDL_GL_DEPTH_SIZE:
  1.3928 -        _this->gl_config.depth_size = value;
  1.3929 -        break;
  1.3930 -    case SDL_GL_STENCIL_SIZE:
  1.3931 -        _this->gl_config.stencil_size = value;
  1.3932 -        break;
  1.3933 -    case SDL_GL_ACCUM_RED_SIZE:
  1.3934 -        _this->gl_config.accum_red_size = value;
  1.3935 -        break;
  1.3936 -    case SDL_GL_ACCUM_GREEN_SIZE:
  1.3937 -        _this->gl_config.accum_green_size = value;
  1.3938 -        break;
  1.3939 -    case SDL_GL_ACCUM_BLUE_SIZE:
  1.3940 -        _this->gl_config.accum_blue_size = value;
  1.3941 -        break;
  1.3942 -    case SDL_GL_ACCUM_ALPHA_SIZE:
  1.3943 -        _this->gl_config.accum_alpha_size = value;
  1.3944 -        break;
  1.3945 -    case SDL_GL_STEREO:
  1.3946 -        _this->gl_config.stereo = value;
  1.3947 -        break;
  1.3948 -    case SDL_GL_MULTISAMPLEBUFFERS:
  1.3949 -        _this->gl_config.multisamplebuffers = value;
  1.3950 -        break;
  1.3951 -    case SDL_GL_MULTISAMPLESAMPLES:
  1.3952 -        _this->gl_config.multisamplesamples = value;
  1.3953 -        break;
  1.3954 -    case SDL_GL_ACCELERATED_VISUAL:
  1.3955 -        _this->gl_config.accelerated = value;
  1.3956 -        break;
  1.3957 -    default:
  1.3958 -        SDL_SetError("Unknown OpenGL attribute");
  1.3959 -        retval = -1;
  1.3960 -        break;
  1.3961 -    }
  1.3962 -    return retval;
  1.3963 +	if (!_this) {
  1.3964 +		SDL_UninitializedVideo();
  1.3965 +		return -1;
  1.3966 +	}
  1.3967 +	retval = 0;
  1.3968 +	switch (attr) {
  1.3969 +	case SDL_GL_RED_SIZE:
  1.3970 +		_this->gl_config.red_size = value;
  1.3971 +		break;
  1.3972 +	case SDL_GL_GREEN_SIZE:
  1.3973 +		_this->gl_config.green_size = value;
  1.3974 +		break;
  1.3975 +	case SDL_GL_BLUE_SIZE:
  1.3976 +		_this->gl_config.blue_size = value;
  1.3977 +		break;
  1.3978 +	case SDL_GL_ALPHA_SIZE:
  1.3979 +		_this->gl_config.alpha_size = value;
  1.3980 +		break;
  1.3981 +	case SDL_GL_DOUBLEBUFFER:
  1.3982 +		_this->gl_config.double_buffer = value;
  1.3983 +		break;
  1.3984 +	case SDL_GL_BUFFER_SIZE:
  1.3985 +		_this->gl_config.buffer_size = value;
  1.3986 +		break;
  1.3987 +	case SDL_GL_DEPTH_SIZE:
  1.3988 +		_this->gl_config.depth_size = value;
  1.3989 +		break;
  1.3990 +	case SDL_GL_STENCIL_SIZE:
  1.3991 +		_this->gl_config.stencil_size = value;
  1.3992 +		break;
  1.3993 +	case SDL_GL_ACCUM_RED_SIZE:
  1.3994 +		_this->gl_config.accum_red_size = value;
  1.3995 +		break;
  1.3996 +	case SDL_GL_ACCUM_GREEN_SIZE:
  1.3997 +		_this->gl_config.accum_green_size = value;
  1.3998 +		break;
  1.3999 +	case SDL_GL_ACCUM_BLUE_SIZE:
  1.4000 +		_this->gl_config.accum_blue_size = value;
  1.4001 +		break;
  1.4002 +	case SDL_GL_ACCUM_ALPHA_SIZE:
  1.4003 +		_this->gl_config.accum_alpha_size = value;
  1.4004 +		break;
  1.4005 +	case SDL_GL_STEREO:
  1.4006 +		_this->gl_config.stereo = value;
  1.4007 +		break;
  1.4008 +	case SDL_GL_MULTISAMPLEBUFFERS:
  1.4009 +		_this->gl_config.multisamplebuffers = value;
  1.4010 +		break;
  1.4011 +	case SDL_GL_MULTISAMPLESAMPLES:
  1.4012 +		_this->gl_config.multisamplesamples = value;
  1.4013 +		break;
  1.4014 +	case SDL_GL_ACCELERATED_VISUAL:
  1.4015 +		_this->gl_config.accelerated = value;
  1.4016 +		break;
  1.4017 +	default:
  1.4018 +		SDL_SetError("Unknown OpenGL attribute");
  1.4019 +		retval = -1;
  1.4020 +		break;
  1.4021 +	}
  1.4022 +	return retval;
  1.4023  #else
  1.4024 -    SDL_Unsupported();
  1.4025 -    return -1;
  1.4026 -#endif /* SDL_VIDEO_OPENGL */
  1.4027 +	SDL_Unsupported();
  1.4028 +	return -1;
  1.4029 +#endif				/* SDL_VIDEO_OPENGL */
  1.4030  }
  1.4031  
  1.4032  int
  1.4033  SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
  1.4034  {
  1.4035  #if SDL_VIDEO_OPENGL
  1.4036 -    void (APIENTRY * glGetIntegervFunc) (GLenum pname, GLint * params);
  1.4037 -    GLenum attrib = 0;
  1.4038 +	void            (APIENTRY * glGetIntegervFunc) (GLenum pname, GLint * params);
  1.4039 +	GLenum          attrib = 0;
  1.4040  
  1.4041 -    glGetIntegervFunc = SDL_GL_GetProcAddress("glGetIntegerv");
  1.4042 -    if (!glGetIntegervFunc) {
  1.4043 -        return -1;
  1.4044 -    }
  1.4045 -    switch (attr) {
  1.4046 -    case SDL_GL_RED_SIZE:
  1.4047 -        attrib = GL_RED_BITS;
  1.4048 -        break;
  1.4049 -    case SDL_GL_BLUE_SIZE:
  1.4050 -        attrib = GL_BLUE_BITS;
  1.4051 -        break;
  1.4052 -    case SDL_GL_GREEN_SIZE:
  1.4053 -        attrib = GL_GREEN_BITS;
  1.4054 -        break;
  1.4055 -    case SDL_GL_ALPHA_SIZE:
  1.4056 -        attrib = GL_ALPHA_BITS;
  1.4057 -        break;
  1.4058 -    case SDL_GL_DOUBLEBUFFER:
  1.4059 -        attrib = GL_DOUBLEBUFFER;
  1.4060 -        break;
  1.4061 -    case SDL_GL_DEPTH_SIZE:
  1.4062 -        attrib = GL_DEPTH_BITS;
  1.4063 -        break;
  1.4064 -    case SDL_GL_STENCIL_SIZE:
  1.4065 -        attrib = GL_STENCIL_BITS;
  1.4066 -        break;
  1.4067 -    case SDL_GL_ACCUM_RED_SIZE:
  1.4068 -        attrib = GL_ACCUM_RED_BITS;
  1.4069 -        break;
  1.4070 -    case SDL_GL_ACCUM_GREEN_SIZE:
  1.4071 -        attrib = GL_ACCUM_GREEN_BITS;
  1.4072 -        break;
  1.4073 -    case SDL_GL_ACCUM_BLUE_SIZE:
  1.4074 -        attrib = GL_ACCUM_BLUE_BITS;
  1.4075 -        break;
  1.4076 -    case SDL_GL_ACCUM_ALPHA_SIZE:
  1.4077 -        attrib = GL_ACCUM_ALPHA_BITS;
  1.4078 -        break;
  1.4079 -    case SDL_GL_STEREO:
  1.4080 -        attrib = GL_STEREO;
  1.4081 -        break;
  1.4082 -    case SDL_GL_MULTISAMPLEBUFFERS:
  1.4083 -        attrib = GL_SAMPLE_BUFFERS_ARB;
  1.4084 -        break;
  1.4085 -    case SDL_GL_MULTISAMPLESAMPLES:
  1.4086 -        attrib = GL_SAMPLES_ARB;
  1.4087 -        break;
  1.4088 -    case SDL_GL_BUFFER_SIZE:
  1.4089 -        {
  1.4090 -            GLint bits = 0;
  1.4091 -            GLint component;
  1.4092 +	glGetIntegervFunc = SDL_GL_GetProcAddress("glGetIntegerv");
  1.4093 +	if (!glGetIntegervFunc) {
  1.4094 +		return -1;
  1.4095 +	}
  1.4096 +	switch (attr) {
  1.4097 +	case SDL_GL_RED_SIZE:
  1.4098 +		attrib = GL_RED_BITS;
  1.4099 +		break;
  1.4100 +	case SDL_GL_BLUE_SIZE:
  1.4101 +		attrib = GL_BLUE_BITS;
  1.4102 +		break;
  1.4103 +	case SDL_GL_GREEN_SIZE:
  1.4104 +		attrib = GL_GREEN_BITS;
  1.4105 +		break;
  1.4106 +	case SDL_GL_ALPHA_SIZE:
  1.4107 +		attrib = GL_ALPHA_BITS;
  1.4108 +		break;
  1.4109 +	case SDL_GL_DOUBLEBUFFER:
  1.4110 +		attrib = GL_DOUBLEBUFFER;
  1.4111 +		break;
  1.4112 +	case SDL_GL_DEPTH_SIZE:
  1.4113 +		attrib = GL_DEPTH_BITS;
  1.4114 +		break;
  1.4115 +	case SDL_GL_STENCIL_SIZE:
  1.4116 +		attrib = GL_STENCIL_BITS;
  1.4117 +		break;
  1.4118 +	case SDL_GL_ACCUM_RED_SIZE:
  1.4119 +		attrib = GL_ACCUM_RED_BITS;
  1.4120 +		break;
  1.4121 +	case SDL_GL_ACCUM_GREEN_SIZE:
  1.4122 +		attrib = GL_ACCUM_GREEN_BITS;
  1.4123 +		break;
  1.4124 +	case SDL_GL_ACCUM_BLUE_SIZE:
  1.4125 +		attrib = GL_ACCUM_BLUE_BITS;
  1.4126 +		break;
  1.4127 +	case SDL_GL_ACCUM_ALPHA_SIZE:
  1.4128 +		attrib = GL_ACCUM_ALPHA_BITS;
  1.4129 +		break;
  1.4130 +	case SDL_GL_STEREO:
  1.4131 +		attrib = GL_STEREO;
  1.4132 +		break;
  1.4133 +	case SDL_GL_MULTISAMPLEBUFFERS:
  1.4134 +		attrib = GL_SAMPLE_BUFFERS_ARB;
  1.4135 +		break;
  1.4136 +	case SDL_GL_MULTISAMPLESAMPLES:
  1.4137 +		attrib = GL_SAMPLES_ARB;
  1.4138 +		break;
  1.4139 +	case SDL_GL_BUFFER_SIZE:
  1.4140 +		{
  1.4141 +			GLint           bits = 0;
  1.4142 +			GLint           component;
  1.4143  
  1.4144 -            /* there doesn't seem to be a single flag in OpenGL for this! */
  1.4145 -            glGetIntegervFunc(GL_RED_BITS, &component);
  1.4146 -            bits += component;
  1.4147 -            glGetIntegervFunc(GL_GREEN_BITS, &component);
  1.4148 -            bits += component;
  1.4149 -            glGetIntegervFunc(GL_BLUE_BITS, &component);
  1.4150 -            bits += component;
  1.4151 -            glGetIntegervFunc(GL_ALPHA_BITS, &component);
  1.4152 -            bits += component;
  1.4153 +			/*
  1.4154 +			 * there doesn't seem to be a single flag in OpenGL
  1.4155 +			 * for this!
  1.4156 +			 */
  1.4157 +			glGetIntegervFunc(GL_RED_BITS, &component);
  1.4158 +			bits += component;
  1.4159 +			glGetIntegervFunc(GL_GREEN_BITS, &component);
  1.4160 +			bits += component;
  1.4161 +			glGetIntegervFunc(GL_BLUE_BITS, &component);
  1.4162 +			bits += component;
  1.4163 +			glGetIntegervFunc(GL_ALPHA_BITS, &component);
  1.4164 +			bits += component;
  1.4165  
  1.4166 -            *value = bits;
  1.4167 -            return 0;
  1.4168 -        }
  1.4169 -    case SDL_GL_ACCELERATED_VISUAL:
  1.4170 -        {
  1.4171 -            /* FIXME: How do we get this information? */
  1.4172 -            *value = (_this->gl_config.accelerated != 0);
  1.4173 -            return 0;
  1.4174 -        }
  1.4175 -    default:
  1.4176 -        SDL_SetError("Unknown OpenGL attribute");
  1.4177 -        return -1;
  1.4178 -    }
  1.4179 +			*value = bits;
  1.4180 +			return 0;
  1.4181 +		}
  1.4182 +	case SDL_GL_ACCELERATED_VISUAL:
  1.4183 +		{
  1.4184 +			/* FIXME: How do we get this information? */
  1.4185 +			*value = (_this->gl_config.accelerated != 0);
  1.4186 +			return 0;
  1.4187 +		}
  1.4188 +	default:
  1.4189 +		SDL_SetError("Unknown OpenGL attribute");
  1.4190 +		return -1;
  1.4191 +	}
  1.4192  
  1.4193 -    glGetIntegervFunc(attrib, (GLint *) value);
  1.4194 -    return 0;
  1.4195 +	glGetIntegervFunc(attrib, (GLint *) value);
  1.4196 +	return 0;
  1.4197  #else
  1.4198 -    SDL_Unsupported();
  1.4199 -    return -1;
  1.4200 -#endif /* SDL_VIDEO_OPENGL */
  1.4201 +	SDL_Unsupported();
  1.4202 +	return -1;
  1.4203 +#endif				/* SDL_VIDEO_OPENGL */
  1.4204  }
  1.4205  
  1.4206  SDL_GLContext
  1.4207  SDL_GL_CreateContext(SDL_WindowID windowID)
  1.4208  {
  1.4209 -    SDL_Window *window = SDL_GetWindowFromID(windowID);
  1.4210 +	SDL_Window     *window = SDL_GetWindowFromID(windowID);
  1.4211  
  1.4212 -    if (!window) {
  1.4213 -        return NULL;
  1.4214 -    }
  1.4215 -    if (!(window->flags & SDL_WINDOW_OPENGL)) {
  1.4216 -        SDL_SetError("The specified window isn't an OpenGL window");
  1.4217 -        return NULL;
  1.4218 -    }
  1.4219 -    return _this->GL_CreateContext(_this, window);
  1.4220 +	if (!window) {
  1.4221 +		return NULL;
  1.4222 +	}
  1.4223 +	if (!(window->flags & SDL_WINDOW_OPENGL)) {
  1.4224 +		SDL_SetError("The specified window isn't an OpenGL window");
  1.4225 +		return NULL;
  1.4226 +	}
  1.4227 +	return _this->GL_CreateContext(_this, window);
  1.4228  }
  1.4229  
  1.4230  int
  1.4231  SDL_GL_MakeCurrent(SDL_WindowID windowID, SDL_GLContext context)
  1.4232  {
  1.4233 -    SDL_Window *window = SDL_GetWindowFromID(windowID);
  1.4234 +	SDL_Window     *window = SDL_GetWindowFromID(windowID);
  1.4235  
  1.4236 -    if (window && !(window->flags & SDL_WINDOW_OPENGL)) {
  1.4237 -        SDL_SetError("The specified window isn't an OpenGL window");
  1.4238 -        return -1;
  1.4239 -    }
  1.4240 -    if (!context) {
  1.4241 -        window = NULL;
  1.4242 -    }
  1.4243 -    return _this->GL_MakeCurrent(_this, window, context);
  1.4244 +	if (window && !(window->flags & SDL_WINDOW_OPENGL)) {
  1.4245 +		SDL_SetError("The specified window isn't an OpenGL window");
  1.4246 +		return -1;
  1.4247 +	}
  1.4248 +	if (!context) {
  1.4249 +		window = NULL;
  1.4250 +	}
  1.4251 +	return _this->GL_MakeCurrent(_this, window, context);
  1.4252  }
  1.4253  
  1.4254  int
  1.4255  SDL_GL_SetSwapInterval(int interval)
  1.4256  {
  1.4257 -    if (!_this) {
  1.4258 -        SDL_UninitializedVideo();
  1.4259 -        return -1;
  1.4260 -    }
  1.4261 -
  1.4262 -    if (_this->GL_SetSwapInterval) {
  1.4263 -        return _this->GL_SetSwapInterval(_this, interval);
  1.4264 -    } else {
  1.4265 -        SDL_SetError("Setting the swap interval is not supported");
  1.4266 -        return -1;
  1.4267 -    }
  1.4268 +	if (!_this) {
  1.4269 +		SDL_UninitializedVideo();
  1.4270 +		return -1;
  1.4271 +	}
  1.4272 +	if (_this->GL_SetSwapInterval) {
  1.4273 +		return _this->GL_SetSwapInterval(_this, interval);
  1.4274 +	} else {
  1.4275 +		SDL_SetError("Setting the swap interval is not supported");
  1.4276 +		return -1;
  1.4277 +	}
  1.4278  }
  1.4279  
  1.4280  int
  1.4281  SDL_GL_GetSwapInterval(void)
  1.4282  {
  1.4283 -    if (!_this) {
  1.4284 -        SDL_UninitializedVideo();
  1.4285 -        return -1;
  1.4286 -    }
  1.4287 -
  1.4288 -    if (_this->GL_GetSwapInterval) {
  1.4289 -        return _this->GL_GetSwapInterval(_this);
  1.4290 -    } else {
  1.4291 -        SDL_SetError("Getting the swap interval is not supported");
  1.4292 -        return -1;
  1.4293 -    }
  1.4294 +	if (!_this) {
  1.4295 +		SDL_UninitializedVideo();
  1.4296 +		return -1;
  1.4297 +	}
  1.4298 +	if (_this->GL_GetSwapInterval) {
  1.4299 +		return _this->GL_GetSwapInterval(_this);
  1.4300 +	} else {
  1.4301 +		SDL_SetError("Getting the swap interval is not supported");
  1.4302 +		return -1;
  1.4303 +	}
  1.4304  }
  1.4305  
  1.4306  void
  1.4307  SDL_GL_SwapWindow(SDL_WindowID windowID)
  1.4308  {
  1.4309 -    SDL_Window *window = SDL_GetWindowFromID(windowID);
  1.4310 +	SDL_Window     *window = SDL_GetWindowFromID(windowID);
  1.4311  
  1.4312 -    if (!window) {
  1.4313 -        return;
  1.4314 -    }
  1.4315 -    if (!(window->flags & SDL_WINDOW_OPENGL)) {
  1.4316 -        SDL_SetError("The specified window isn't an OpenGL window");
  1.4317 -        return;
  1.4318 -    }
  1.4319 -    _this->GL_SwapWindow(_this, window);
  1.4320 +	if (!window) {
  1.4321 +		return;
  1.4322 +	}
  1.4323 +	if (!(window->flags & SDL_WINDOW_OPENGL)) {
  1.4324 +		SDL_SetError("The specified window isn't an OpenGL window");
  1.4325 +		return;
  1.4326 +	}
  1.4327 +	_this->GL_SwapWindow(_this, window);
  1.4328  }
  1.4329  
  1.4330  void
  1.4331  SDL_GL_DeleteContext(SDL_GLContext context)
  1.4332  {
  1.4333 -    if (!_this || !context) {
  1.4334 -        return;
  1.4335 -    }
  1.4336 -    _this->GL_MakeCurrent(_this, NULL, NULL);
  1.4337 -    _this->GL_DeleteContext(_this, context);
  1.4338 +	if (!_this || !context) {
  1.4339 +		return;
  1.4340 +	}
  1.4341 +	_this->GL_MakeCurrent(_this, NULL, NULL);
  1.4342 +	_this->GL_DeleteContext(_this, context);
  1.4343  }
  1.4344  
  1.4345  #if 0                           // FIXME
  1.4346 -/* Utility function used by SDL_WM_SetIcon();
  1.4347 - * flags & 1 for color key, flags & 2 for alpha channel. */
  1.4348 +/*
  1.4349 + * Utility function used by SDL_WM_SetIcon(); flags & 1 for color key, flags
  1.4350 + * & 2 for alpha channel.
  1.4351 + */
  1.4352  static void
  1.4353  CreateMaskFromColorKeyOrAlpha(SDL_Surface * icon, Uint8 * mask, int flags)
  1.4354  {
  1.4355 -    int x, y;
  1.4356 -    Uint32 colorkey;
  1.4357 +	int             x, y;
  1.4358 +	Uint32          colorkey;
  1.4359  #define SET_MASKBIT(icon, x, y, mask) \
  1.4360  	mask[(y*((icon->w+7)/8))+(x/8)] &= ~(0x01<<(7-(x%8)))
  1.4361  
  1.4362 -    colorkey = icon->format->colorkey;
  1.4363 -    switch (icon->format->BytesPerPixel) {
  1.4364 -    case 1:
  1.4365 -        {
  1.4366 -            Uint8 *pixels;
  1.4367 -            for (y = 0; y < icon->h; ++y) {
  1.4368 -                pixels = (Uint8 *) icon->pixels + y * icon->pitch;
  1.4369 -                for (x = 0; x < icon->w; ++x) {
  1.4370 -                    if (*pixels++ == colorkey) {
  1.4371 -                        SET_MASKBIT(icon, x, y, mask);
  1.4372 -                    }
  1.4373 -                }
  1.4374 -            }
  1.4375 -        }
  1.4376 -        break;
  1.4377 +	colorkey = icon->format->colorkey;
  1.4378 +	switch (icon->format->BytesPerPixel) {
  1.4379 +	case 1:
  1.4380 +		{
  1.4381 +			Uint8          *pixels;
  1.4382 +			for (y = 0; y < icon->h; ++y) {
  1.4383 +				pixels = (Uint8 *) icon->pixels + y * icon->pitch;
  1.4384 +				for (x = 0; x < icon->w; ++x) {
  1.4385 +					if (*pixels++ == colorkey) {
  1.4386 +						SET_MASKBIT(icon, x, y, mask);
  1.4387 +					}
  1.4388 +				}
  1.4389 +			}
  1.4390 +		}
  1.4391 +		break;
  1.4392  
  1.4393 -    case 2:
  1.4394 -        {
  1.4395 -            Uint16 *pixels;
  1.4396 -            for (y = 0; y < icon->h; ++y) {
  1.4397 -                pixels = (Uint16 *) icon->pixels + y * icon->pitch / 2;
  1.4398 -                for (x = 0; x < icon->w; ++x) {
  1.4399 -                    if ((flags & 1) && *pixels == colorkey) {
  1.4400 -                        SET_MASKBIT(icon, x, y, mask);
  1.4401 -                    } else if ((flags & 2)
  1.4402 -                               && (*pixels & icon->format->Amask) == 0) {
  1.4403 -                        SET_MASKBIT(icon, x, y, mask);
  1.4404 -                    }
  1.4405 -                    pixels++;
  1.4406 -                }
  1.4407 -            }
  1.4408 -        }
  1.4409 -        break;
  1.4410 +	case 2:
  1.4411 +		{
  1.4412 +			Uint16         *pixels;
  1.4413 +			for (y = 0; y < icon->h; ++y) {
  1.4414 +				pixels = (Uint16 *) icon->pixels + y * icon->pitch / 2;
  1.4415 +				for (x = 0; x < icon->w; ++x) {
  1.4416 +					if ((flags & 1) && *pixels == colorkey) {
  1.4417 +						SET_MASKBIT(icon, x, y, mask);
  1.4418 +					} else if ((flags & 2)
  1.4419 +						   && (*pixels & icon->format->Amask) == 0) {
  1.4420 +						SET_MASKBIT(icon, x, y, mask);
  1.4421 +					}
  1.4422 +					pixels++;
  1.4423 +				}
  1.4424 +			}
  1.4425 +		}
  1.4426 +		break;
  1.4427  
  1.4428 -    case 4:
  1.4429 -        {
  1.4430 -            Uint32 *pixels;
  1.4431 -            for (y = 0; y < icon->h; ++y) {
  1.4432 -                pixels = (Uint32 *) icon->pixels + y * icon->pitch / 4;
  1.4433 -                for (x = 0; x < icon->w; ++x) {
  1.4434 -                    if ((flags & 1) && *pixels == colorkey) {
  1.4435 -                        SET_MASKBIT(icon, x, y, mask);
  1.4436 -                    } else if ((flags & 2)
  1.4437 -                               && (*pixels & icon->format->Amask) == 0) {
  1.4438 -                        SET_MASKBIT(icon, x, y, mask);
  1.4439 -                    }
  1.4440 -                    pixels++;
  1.4441 -                }
  1.4442 -            }
  1.4443 -        }
  1.4444 -        break;
  1.4445 -    }
  1.4446 +	case 4:
  1.4447 +		{
  1.4448 +			Uint32         *pixels;
  1.4449 +			for (y = 0; y < icon->h; ++y) {
  1.4450 +				pixels = (Uint32 *) icon->pixels + y * icon->pitch / 4;
  1.4451 +				for (x = 0; x < icon->w; ++x) {
  1.4452 +					if ((flags & 1) && *pixels == colorkey) {
  1.4453 +						SET_MASKBIT(icon, x, y, mask);
  1.4454 +					} else if ((flags & 2)
  1.4455 +						   && (*pixels & icon->format->Amask) == 0) {
  1.4456 +						SET_MASKBIT(icon, x, y, mask);
  1.4457 +					}
  1.4458 +					pixels++;
  1.4459 +				}
  1.4460 +			}
  1.4461 +		}
  1.4462 +		break;
  1.4463 +	}
  1.4464  }
  1.4465  
  1.4466  /*
  1.4467 @@ -2659,41 +2577,41 @@
  1.4468  void
  1.4469  SDL_WM_SetIcon(SDL_Surface * icon, Uint8 * mask)
  1.4470  {
  1.4471 -    if (icon && _this->SetIcon) {
  1.4472 -        /* Generate a mask if necessary, and create the icon! */
  1.4473 -        if (mask == NULL) {
  1.4474 -            int mask_len = icon->h * (icon->w + 7) / 8;
  1.4475 -            int flags = 0;
  1.4476 -            mask = (Uint8 *) SDL_malloc(mask_len);
  1.4477 -            if (mask == NULL) {
  1.4478 -                return;
  1.4479 -            }
  1.4480 -            SDL_memset(mask, ~0, mask_len);
  1.4481 -            if (icon->flags & SDL_SRCCOLORKEY)
  1.4482 -                flags |= 1;
  1.4483 -            if (icon->flags & SDL_SRCALPHA)
  1.4484 -                flags |= 2;
  1.4485 -            if (flags) {
  1.4486 -                CreateMaskFromColorKeyOrAlpha(icon, mask, flags);
  1.4487 -            }
  1.4488 -            _this->SetIcon(_this, icon, mask);
  1.4489 -            SDL_free(mask);
  1.4490 -        } else {
  1.4491 -            _this->SetIcon(_this, icon, mask);
  1.4492 -        }
  1.4493 -    }
  1.4494 +	if (icon && _this->SetIcon) {
  1.4495 +		/* Generate a mask if necessary, and create the icon! */
  1.4496 +		if (mask == NULL) {
  1.4497 +			int             mask_len = icon->h * (icon->w + 7) / 8;
  1.4498 +			int             flags = 0;
  1.4499 +			mask = (Uint8 *) SDL_malloc(mask_len);
  1.4500 +			if (mask == NULL) {
  1.4501 +				return;
  1.4502 +			}
  1.4503 +			SDL_memset(mask, ~0, mask_len);
  1.4504 +			if (icon->flags & SDL_SRCCOLORKEY)
  1.4505 +				flags |= 1;
  1.4506 +			if (icon->flags & SDL_SRCALPHA)
  1.4507 +				flags |= 2;
  1.4508 +			if (flags) {
  1.4509 +				CreateMaskFromColorKeyOrAlpha(icon, mask, flags);
  1.4510 +			}
  1.4511 +			_this->SetIcon(_this, icon, mask);
  1.4512 +			SDL_free(mask);
  1.4513 +		} else {
  1.4514 +			_this->SetIcon(_this, icon, mask);
  1.4515 +		}
  1.4516 +	}
  1.4517  }
  1.4518  #endif
  1.4519  
  1.4520  SDL_bool
  1.4521 -SDL_GetWindowWMInfo(SDL_WindowID windowID, struct SDL_SysWMinfo *info)
  1.4522 +SDL_GetWindowWMInfo(SDL_WindowID windowID, struct SDL_SysWMinfo * info)
  1.4523  {
  1.4524 -    SDL_Window *window = SDL_GetWindowFromID(windowID);
  1.4525 +	SDL_Window     *window = SDL_GetWindowFromID(windowID);
  1.4526  
  1.4527 -    if (!window || !_this->GetWindowWMInfo) {
  1.4528 -        return SDL_FALSE;
  1.4529 -    }
  1.4530 -    return (_this->GetWindowWMInfo(_this, window, info));
  1.4531 +	if (!window || !_this->GetWindowWMInfo) {
  1.4532 +		return SDL_FALSE;
  1.4533 +	}
  1.4534 +	return (_this->GetWindowWMInfo(_this, window, info));
  1.4535  }
  1.4536  
  1.4537  /* vi: set ts=4 sw=4 expandtab: */