src/video/ataricommon/SDL_atarigl.c
changeset 3283 1ed5d432e468
parent 3282 10a12f77f597
child 3284 2b95b2c0b6d4
     1.1 --- a/src/video/ataricommon/SDL_atarigl.c	Sun Sep 20 04:13:23 2009 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,1127 +0,0 @@
     1.4 -/*
     1.5 -    SDL - Simple DirectMedia Layer
     1.6 -    Copyright (C) 1997-2009 Sam Lantinga
     1.7 -
     1.8 -    This library is free software; you can redistribute it and/or
     1.9 -    modify it under the terms of the GNU Library General Public
    1.10 -    License as published by the Free Software Foundation; either
    1.11 -    version 2 of the License, or (at your option) any later version.
    1.12 -
    1.13 -    This library is distributed in the hope that it will be useful,
    1.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1.16 -    Library General Public License for more details.
    1.17 -
    1.18 -    You should have received a copy of the GNU Library General Public
    1.19 -    License along with this library; if not, write to the Free
    1.20 -    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    1.21 -
    1.22 -    Sam Lantinga
    1.23 -    slouken@libsdl.org
    1.24 -*/
    1.25 -#include "SDL_config.h"
    1.26 -
    1.27 -/* Atari OSMesa.ldg implementation of SDL OpenGL support */
    1.28 -
    1.29 -/*--- Includes ---*/
    1.30 -
    1.31 -#if SDL_VIDEO_OPENGL
    1.32 -#include <GL/osmesa.h>
    1.33 -#endif
    1.34 -
    1.35 -#include <mint/osbind.h>
    1.36 -
    1.37 -#include "SDL_endian.h"
    1.38 -#include "SDL_video.h"
    1.39 -#include "SDL_atarigl_c.h"
    1.40 -#if SDL_VIDEO_OPENGL_OSMESA_DYNAMIC
    1.41 -#include "SDL_loadso.h"
    1.42 -#endif
    1.43 -
    1.44 -/*--- Defines ---*/
    1.45 -
    1.46 -#define PATH_OSMESA_LDG	"osmesa.ldg"
    1.47 -#define PATH_MESAGL_LDG	"mesa_gl.ldg"
    1.48 -#define PATH_TINYGL_LDG	"tiny_gl.ldg"
    1.49 -
    1.50 -#define VDI_RGB	0xf
    1.51 -
    1.52 -/*--- Functions prototypes ---*/
    1.53 -
    1.54 -static void SDL_AtariGL_UnloadLibrary(_THIS);
    1.55 -
    1.56 -#if SDL_VIDEO_OPENGL
    1.57 -static void CopyShadowNull(_THIS, SDL_Surface * surface);
    1.58 -static void CopyShadowDirect(_THIS, SDL_Surface * surface);
    1.59 -static void CopyShadowRGBTo555(_THIS, SDL_Surface * surface);
    1.60 -static void CopyShadowRGBTo565(_THIS, SDL_Surface * surface);
    1.61 -static void CopyShadowRGBSwap(_THIS, SDL_Surface * surface);
    1.62 -static void CopyShadowRGBToARGB(_THIS, SDL_Surface * surface);
    1.63 -static void CopyShadowRGBToABGR(_THIS, SDL_Surface * surface);
    1.64 -static void CopyShadowRGBToBGRA(_THIS, SDL_Surface * surface);
    1.65 -static void CopyShadowRGBToRGBA(_THIS, SDL_Surface * surface);
    1.66 -static void CopyShadow8888To555(_THIS, SDL_Surface * surface);
    1.67 -static void CopyShadow8888To565(_THIS, SDL_Surface * surface);
    1.68 -
    1.69 -static void ConvertNull(_THIS, SDL_Surface * surface);
    1.70 -static void Convert565To555be(_THIS, SDL_Surface * surface);
    1.71 -static void Convert565To555le(_THIS, SDL_Surface * surface);
    1.72 -static void Convert565le(_THIS, SDL_Surface * surface);
    1.73 -static void ConvertBGRAToABGR(_THIS, SDL_Surface * surface);
    1.74 -
    1.75 -static int InitNew(_THIS, SDL_Surface * current);
    1.76 -static int InitOld(_THIS, SDL_Surface * current);
    1.77 -#endif
    1.78 -
    1.79 -/*--- Public functions ---*/
    1.80 -
    1.81 -int
    1.82 -SDL_AtariGL_Init(_THIS, SDL_Surface * current)
    1.83 -{
    1.84 -#if SDL_VIDEO_OPENGL
    1.85 -    if (gl_oldmesa) {
    1.86 -        gl_active = InitOld(_this, current);
    1.87 -    } else {
    1.88 -        gl_active = InitNew(_this, current);
    1.89 -    }
    1.90 -#endif
    1.91 -
    1.92 -    return (gl_active);
    1.93 -}
    1.94 -
    1.95 -void
    1.96 -SDL_AtariGL_Quit(_THIS, SDL_bool unload)
    1.97 -{
    1.98 -#if SDL_VIDEO_OPENGL
    1.99 -    if (gl_oldmesa) {
   1.100 -        /* Old mesa implementations */
   1.101 -        if (_this->gl_data->OSMesaDestroyLDG) {
   1.102 -            _this->gl_data->OSMesaDestroyLDG();
   1.103 -        }
   1.104 -        if (gl_shadow) {
   1.105 -            Mfree(gl_shadow);
   1.106 -            gl_shadow = NULL;
   1.107 -        }
   1.108 -    } else {
   1.109 -        /* New mesa implementation */
   1.110 -        if (gl_ctx) {
   1.111 -            if (_this->gl_data->OSMesaDestroyContext) {
   1.112 -                _this->gl_data->OSMesaDestroyContext(gl_ctx);
   1.113 -            }
   1.114 -            gl_ctx = NULL;
   1.115 -        }
   1.116 -    }
   1.117 -
   1.118 -    if (unload) {
   1.119 -        SDL_AtariGL_UnloadLibrary(_this);
   1.120 -    }
   1.121 -#endif /* SDL_VIDEO_OPENGL */
   1.122 -    gl_active = 0;
   1.123 -}
   1.124 -
   1.125 -int
   1.126 -SDL_AtariGL_LoadLibrary(_THIS, const char *path)
   1.127 -{
   1.128 -#if SDL_VIDEO_OPENGL
   1.129 -
   1.130 -#if SDL_VIDEO_OPENGL_OSMESA_DYNAMIC
   1.131 -    void *handle;
   1.132 -    SDL_bool cancel_load;
   1.133 -
   1.134 -    if (gl_active) {
   1.135 -        SDL_SetError("OpenGL context already created");
   1.136 -        return -1;
   1.137 -    }
   1.138 -
   1.139 -    /* Unload previous driver */
   1.140 -    SDL_AtariGL_UnloadLibrary(_this);
   1.141 -
   1.142 -    /* Load library given by path */
   1.143 -    handle = SDL_LoadObject(path);
   1.144 -    if (handle == NULL) {
   1.145 -        /* Try to load another one */
   1.146 -        path = SDL_getenv("SDL_VIDEO_GL_DRIVER");
   1.147 -        if (path != NULL) {
   1.148 -            handle = SDL_LoadObject(path);
   1.149 -        }
   1.150 -
   1.151 -        /* If it does not work, try some other */
   1.152 -        if (handle == NULL) {
   1.153 -            path = PATH_OSMESA_LDG;
   1.154 -            handle = SDL_LoadObject(path);
   1.155 -        }
   1.156 -
   1.157 -        if (handle == NULL) {
   1.158 -            path = PATH_MESAGL_LDG;
   1.159 -            handle = SDL_LoadObject(path);
   1.160 -        }
   1.161 -
   1.162 -        if (handle == NULL) {
   1.163 -            path = PATH_TINYGL_LDG;
   1.164 -            handle = SDL_LoadObject(path);
   1.165 -        }
   1.166 -    }
   1.167 -
   1.168 -    if (handle == NULL) {
   1.169 -        SDL_SetError("Could not load OpenGL library");
   1.170 -        return -1;
   1.171 -    }
   1.172 -
   1.173 -    _this->gl_data->glGetIntegerv = SDL_LoadFunction(handle, "glGetIntegerv");
   1.174 -    _this->gl_data->glFinish = SDL_LoadFunction(handle, "glFinish");
   1.175 -    _this->gl_data->glFlush = SDL_LoadFunction(handle, "glFlush");
   1.176 -
   1.177 -    cancel_load = SDL_FALSE;
   1.178 -    if (_this->gl_data->glGetIntegerv == NULL) {
   1.179 -        cancel_load = SDL_TRUE;
   1.180 -    } else {
   1.181 -        /* We need either glFinish (OSMesa) or glFlush (TinyGL) */
   1.182 -        if ((_this->gl_data->glFinish == NULL) &&
   1.183 -            (_this->gl_data->glFlush == NULL)) {
   1.184 -            cancel_load = SDL_TRUE;
   1.185 -        }
   1.186 -    }
   1.187 -    if (cancel_load) {
   1.188 -        SDL_SetError("Could not retrieve OpenGL functions");
   1.189 -        SDL_UnloadObject(handle);
   1.190 -        /* Restore pointers to static library */
   1.191 -        SDL_AtariGL_InitPointers(this);
   1.192 -        return -1;
   1.193 -    }
   1.194 -
   1.195 -    /* Load functions pointers (osmesa.ldg) */
   1.196 -    _this->gl_data->OSMesaCreateContextExt =
   1.197 -        SDL_LoadFunction(handle, "OSMesaCreateContextExt");
   1.198 -    _this->gl_data->OSMesaDestroyContext =
   1.199 -        SDL_LoadFunction(handle, "OSMesaDestroyContext");
   1.200 -    _this->gl_data->OSMesaMakeCurrent =
   1.201 -        SDL_LoadFunction(handle, "OSMesaMakeCurrent");
   1.202 -    _this->gl_data->OSMesaPixelStore =
   1.203 -        SDL_LoadFunction(handle, "OSMesaPixelStore");
   1.204 -    _this->gl_data->OSMesaGetProcAddress =
   1.205 -        SDL_LoadFunction(handle, "OSMesaGetProcAddress");
   1.206 -
   1.207 -    /* Load old functions pointers (mesa_gl.ldg, tiny_gl.ldg) */
   1.208 -    _this->gl_data->OSMesaCreateLDG =
   1.209 -        SDL_LoadFunction(handle, "OSMesaCreateLDG");
   1.210 -    _this->gl_data->OSMesaDestroyLDG =
   1.211 -        SDL_LoadFunction(handle, "OSMesaDestroyLDG");
   1.212 -
   1.213 -    gl_oldmesa = 0;
   1.214 -
   1.215 -    if ((_this->gl_data->OSMesaCreateContextExt == NULL) ||
   1.216 -        (_this->gl_data->OSMesaDestroyContext == NULL) ||
   1.217 -        (_this->gl_data->OSMesaMakeCurrent == NULL) ||
   1.218 -        (_this->gl_data->OSMesaPixelStore == NULL) ||
   1.219 -        (_this->gl_data->OSMesaGetProcAddress == NULL)) {
   1.220 -        /* Hum, maybe old library ? */
   1.221 -        if ((_this->gl_data->OSMesaCreateLDG == NULL) ||
   1.222 -            (_this->gl_data->OSMesaDestroyLDG == NULL)) {
   1.223 -            SDL_SetError("Could not retrieve OSMesa functions");
   1.224 -            SDL_UnloadObject(handle);
   1.225 -            /* Restore pointers to static library */
   1.226 -            SDL_AtariGL_InitPointers(_this);
   1.227 -            return -1;
   1.228 -        } else {
   1.229 -            gl_oldmesa = 1;
   1.230 -        }
   1.231 -    }
   1.232 -
   1.233 -    _this->gl_config.dll_handle = handle;
   1.234 -    if (path) {
   1.235 -        SDL_strlcpy(_this->gl_config.driver_path, path,
   1.236 -                    SDL_arraysize(_this->gl_config.driver_path));
   1.237 -    } else {
   1.238 -        *this->gl_config.driver_path = '\0';
   1.239 -    }
   1.240 -
   1.241 -#endif
   1.242 -    _this->gl_config.driver_loaded = 1;
   1.243 -
   1.244 -    return 0;
   1.245 -#else
   1.246 -    return -1;
   1.247 -#endif
   1.248 -}
   1.249 -
   1.250 -void *
   1.251 -SDL_AtariGL_GetProcAddress(_THIS, const char *proc)
   1.252 -{
   1.253 -    void *func = NULL;
   1.254 -#if SDL_VIDEO_OPENGL
   1.255 -
   1.256 -    if (_this->gl_config.dll_handle) {
   1.257 -        func = SDL_LoadFunction(this->gl_config.dll_handle, (void *) proc);
   1.258 -    } else if (_this->gl_data->OSMesaGetProcAddress) {
   1.259 -        func = _this->gl_data->OSMesaGetProcAddress(proc);
   1.260 -    }
   1.261 -#endif
   1.262 -    return func;
   1.263 -}
   1.264 -
   1.265 -int
   1.266 -SDL_AtariGL_GetAttribute(_THIS, SDL_GLattr attrib, int *value)
   1.267 -{
   1.268 -#if SDL_VIDEO_OPENGL
   1.269 -    GLenum mesa_attrib;
   1.270 -    SDL_Surface *surface;
   1.271 -
   1.272 -    if (!gl_active) {
   1.273 -        return -1;
   1.274 -    }
   1.275 -
   1.276 -    switch (attrib) {
   1.277 -    case SDL_GL_RED_SIZE:
   1.278 -        mesa_attrib = GL_RED_BITS;
   1.279 -        break;
   1.280 -    case SDL_GL_GREEN_SIZE:
   1.281 -        mesa_attrib = GL_GREEN_BITS;
   1.282 -        break;
   1.283 -    case SDL_GL_BLUE_SIZE:
   1.284 -        mesa_attrib = GL_BLUE_BITS;
   1.285 -        break;
   1.286 -    case SDL_GL_ALPHA_SIZE:
   1.287 -        mesa_attrib = GL_ALPHA_BITS;
   1.288 -        break;
   1.289 -    case SDL_GL_DOUBLEBUFFER:
   1.290 -        surface = _this->screen;
   1.291 -        *value = ((surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF);
   1.292 -        return 0;
   1.293 -    case SDL_GL_DEPTH_SIZE:
   1.294 -        mesa_attrib = GL_DEPTH_BITS;
   1.295 -        break;
   1.296 -    case SDL_GL_STENCIL_SIZE:
   1.297 -        mesa_attrib = GL_STENCIL_BITS;
   1.298 -        break;
   1.299 -    case SDL_GL_ACCUM_RED_SIZE:
   1.300 -        mesa_attrib = GL_ACCUM_RED_BITS;
   1.301 -        break;
   1.302 -    case SDL_GL_ACCUM_GREEN_SIZE:
   1.303 -        mesa_attrib = GL_ACCUM_GREEN_BITS;
   1.304 -        break;
   1.305 -    case SDL_GL_ACCUM_BLUE_SIZE:
   1.306 -        mesa_attrib = GL_ACCUM_BLUE_BITS;
   1.307 -        break;
   1.308 -    case SDL_GL_ACCUM_ALPHA_SIZE:
   1.309 -        mesa_attrib = GL_ACCUM_ALPHA_BITS;
   1.310 -        break;
   1.311 -    default:
   1.312 -        return -1;
   1.313 -    }
   1.314 -
   1.315 -    _this->gl_data->glGetIntegerv(mesa_attrib, value);
   1.316 -    return 0;
   1.317 -#else
   1.318 -    return -1;
   1.319 -#endif
   1.320 -}
   1.321 -
   1.322 -int
   1.323 -SDL_AtariGL_MakeCurrent(_THIS)
   1.324 -{
   1.325 -#if SDL_VIDEO_OPENGL
   1.326 -    SDL_Surface *surface;
   1.327 -    GLenum type;
   1.328 -
   1.329 -    if (gl_oldmesa && gl_active) {
   1.330 -        return 0;
   1.331 -    }
   1.332 -
   1.333 -    if (_this->gl_config.dll_handle) {
   1.334 -        if ((_this->gl_data->OSMesaMakeCurrent == NULL) ||
   1.335 -            (_this->gl_data->OSMesaPixelStore == NULL)) {
   1.336 -            return -1;
   1.337 -        }
   1.338 -    }
   1.339 -
   1.340 -    if (!gl_active) {
   1.341 -        SDL_SetError("Invalid OpenGL context");
   1.342 -        return -1;
   1.343 -    }
   1.344 -
   1.345 -    surface = _this->screen;
   1.346 -
   1.347 -    if ((surface->format->BitsPerPixel == 15)
   1.348 -        || (surface->format->BitsPerPixel == 16)) {
   1.349 -        type = GL_UNSIGNED_SHORT_5_6_5;
   1.350 -    } else {
   1.351 -        type = GL_UNSIGNED_BYTE;
   1.352 -    }
   1.353 -
   1.354 -    if (!
   1.355 -        (_this->
   1.356 -         gl_data->OSMesaMakeCurrent(gl_ctx, surface->pixels, type, surface->w,
   1.357 -                                    surface->h))) {
   1.358 -        SDL_SetError("Can not make OpenGL context current");
   1.359 -        return -1;
   1.360 -    }
   1.361 -
   1.362 -    /* OSMesa draws upside down */
   1.363 -    _this->gl_data->OSMesaPixelStore(OSMESA_Y_UP, 0);
   1.364 -
   1.365 -    return 0;
   1.366 -#else
   1.367 -    return -1;
   1.368 -#endif
   1.369 -}
   1.370 -
   1.371 -void
   1.372 -SDL_AtariGL_SwapBuffers(_THIS)
   1.373 -{
   1.374 -#if SDL_VIDEO_OPENGL
   1.375 -    if (gl_active) {
   1.376 -        if (_this->gl_config.dll_handle) {
   1.377 -            if (_this->gl_data->glFinish) {
   1.378 -                _this->gl_data->glFinish();
   1.379 -            } else if (_this->gl_data->glFlush) {
   1.380 -                _this->gl_data->glFlush();
   1.381 -            }
   1.382 -        } else {
   1.383 -            _this->gl_data->glFinish();
   1.384 -        }
   1.385 -        gl_copyshadow(_this, _this->screen);
   1.386 -        gl_convert(_this, _this->screen);
   1.387 -    }
   1.388 -#endif
   1.389 -}
   1.390 -
   1.391 -void
   1.392 -SDL_AtariGL_InitPointers(_THIS)
   1.393 -{
   1.394 -#if SDL_VIDEO_OPENGL
   1.395 -    _this->gl_data->OSMesaCreateContextExt = OSMesaCreateContextExt;
   1.396 -    _this->gl_data->OSMesaDestroyContext = OSMesaDestroyContext;
   1.397 -    _this->gl_data->OSMesaMakeCurrent = OSMesaMakeCurrent;
   1.398 -    _this->gl_data->OSMesaPixelStore = OSMesaPixelStore;
   1.399 -    _this->gl_data->OSMesaGetProcAddress = OSMesaGetProcAddress;
   1.400 -
   1.401 -    _this->gl_data->glGetIntegerv = glGetIntegerv;
   1.402 -    _this->gl_data->glFinish = glFinish;
   1.403 -    _this->gl_data->glFlush = glFlush;
   1.404 -
   1.405 -    _this->gl_data->OSMesaCreateLDG = NULL;
   1.406 -    _this->gl_data->OSMesaDestroyLDG = NULL;
   1.407 -#endif
   1.408 -}
   1.409 -
   1.410 -/*--- Private functions ---*/
   1.411 -
   1.412 -static void
   1.413 -SDL_AtariGL_UnloadLibrary(_THIS)
   1.414 -{
   1.415 -#if SDL_VIDEO_OPENGL
   1.416 -    if (_this->gl_config.dll_handle) {
   1.417 -        SDL_UnloadObject(_this->gl_config.dll_handle);
   1.418 -        _this->gl_config.dll_handle = NULL;
   1.419 -
   1.420 -        /* Restore pointers to static library */
   1.421 -        SDL_AtariGL_InitPointers(_this);
   1.422 -    }
   1.423 -#endif
   1.424 -}
   1.425 -
   1.426 -/*--- Creation of an OpenGL context using new/old functions ---*/
   1.427 -
   1.428 -#if SDL_VIDEO_OPENGL
   1.429 -static int
   1.430 -InitNew(_THIS, SDL_Surface * current)
   1.431 -{
   1.432 -    GLenum osmesa_format;
   1.433 -    SDL_PixelFormat *pixel_format;
   1.434 -    Uint32 redmask;
   1.435 -    int recreatecontext;
   1.436 -    GLint newaccumsize;
   1.437 -
   1.438 -    if (_this->gl_config.dll_handle) {
   1.439 -        if (_this->gl_data->OSMesaCreateContextExt == NULL) {
   1.440 -            return 0;
   1.441 -        }
   1.442 -    }
   1.443 -
   1.444 -    /* Init OpenGL context using OSMesa */
   1.445 -    gl_convert = ConvertNull;
   1.446 -    gl_copyshadow = CopyShadowNull;
   1.447 -    gl_upsidedown = SDL_FALSE;
   1.448 -
   1.449 -    pixel_format = current->format;
   1.450 -    redmask = pixel_format->Rmask;
   1.451 -    switch (pixel_format->BitsPerPixel) {
   1.452 -    case 15:
   1.453 -        /* 1555, big and little endian, unsupported */
   1.454 -        gl_pixelsize = 2;
   1.455 -        osmesa_format = OSMESA_RGB_565;
   1.456 -        if (redmask == 31 << 10) {
   1.457 -            gl_convert = Convert565To555be;
   1.458 -        } else {
   1.459 -            gl_convert = Convert565To555le;
   1.460 -        }
   1.461 -        break;
   1.462 -    case 16:
   1.463 -        gl_pixelsize = 2;
   1.464 -        if (redmask == 31 << 11) {
   1.465 -            osmesa_format = OSMESA_RGB_565;
   1.466 -        } else {
   1.467 -            /* 565, little endian, unsupported */
   1.468 -            osmesa_format = OSMESA_RGB_565;
   1.469 -            gl_convert = Convert565le;
   1.470 -        }
   1.471 -        break;
   1.472 -    case 24:
   1.473 -        gl_pixelsize = 3;
   1.474 -        if (redmask == 255 << 16) {
   1.475 -            osmesa_format = OSMESA_RGB;
   1.476 -        } else {
   1.477 -            osmesa_format = OSMESA_BGR;
   1.478 -        }
   1.479 -        break;
   1.480 -    case 32:
   1.481 -        gl_pixelsize = 4;
   1.482 -        if (redmask == 255 << 16) {
   1.483 -            osmesa_format = OSMESA_ARGB;
   1.484 -        } else if (redmask == 255 << 8) {
   1.485 -            osmesa_format = OSMESA_BGRA;
   1.486 -        } else if (redmask == 255 << 24) {
   1.487 -            osmesa_format = OSMESA_RGBA;
   1.488 -        } else {
   1.489 -            /* ABGR format unsupported */
   1.490 -            osmesa_format = OSMESA_BGRA;
   1.491 -            gl_convert = ConvertBGRAToABGR;
   1.492 -        }
   1.493 -        break;
   1.494 -    default:
   1.495 -        gl_pixelsize = 1;
   1.496 -        osmesa_format = OSMESA_COLOR_INDEX;
   1.497 -        break;
   1.498 -    }
   1.499 -
   1.500 -    /* Try to keep current context if possible */
   1.501 -    newaccumsize =
   1.502 -        _this->gl_config.accum_red_size +
   1.503 -        _this->gl_config.accum_green_size +
   1.504 -        _this->gl_config.accum_blue_size + _this->gl_config.accum_alpha_size;
   1.505 -    recreatecontext = 1;
   1.506 -    if (gl_ctx &&
   1.507 -        (gl_curformat == osmesa_format) &&
   1.508 -        (gl_curdepth == _this->gl_config.depth_size) &&
   1.509 -        (gl_curstencil == _this->gl_config.stencil_size) &&
   1.510 -        (gl_curaccum == newaccumsize)) {
   1.511 -        recreatecontext = 0;
   1.512 -    }
   1.513 -    if (recreatecontext) {
   1.514 -        SDL_AtariGL_Quit(this, SDL_FALSE);
   1.515 -
   1.516 -        gl_ctx =
   1.517 -            _this->gl_data->OSMesaCreateContextExt(osmesa_format,
   1.518 -                                                   _this->
   1.519 -                                                   gl_config.depth_size,
   1.520 -                                                   _this->
   1.521 -                                                   gl_config.stencil_size,
   1.522 -                                                   newaccumsize, NULL);
   1.523 -
   1.524 -        if (gl_ctx) {
   1.525 -            gl_curformat = osmesa_format;
   1.526 -            gl_curdepth = _this->gl_config.depth_size;
   1.527 -            gl_curstencil = _this->gl_config.stencil_size;
   1.528 -            gl_curaccum = newaccumsize;
   1.529 -        } else {
   1.530 -            gl_curformat = 0;
   1.531 -            gl_curdepth = 0;
   1.532 -            gl_curstencil = 0;
   1.533 -            gl_curaccum = 0;
   1.534 -        }
   1.535 -    }
   1.536 -
   1.537 -    return (gl_ctx != NULL);
   1.538 -}
   1.539 -
   1.540 -
   1.541 -static int
   1.542 -InitOld(_THIS, SDL_Surface * current)
   1.543 -{
   1.544 -    GLenum osmesa_format;
   1.545 -    SDL_PixelFormat *pixel_format;
   1.546 -    Uint32 redmask;
   1.547 -    int recreatecontext, tinygl_present;
   1.548 -
   1.549 -    if (_this->gl_config.dll_handle) {
   1.550 -        if (_this->gl_data->OSMesaCreateLDG == NULL) {
   1.551 -            return 0;
   1.552 -        }
   1.553 -    }
   1.554 -
   1.555 -    /* TinyGL only supports VDI_RGB (OSMESA_RGB) */
   1.556 -    tinygl_present = 0;
   1.557 -    if (_this->gl_config.dll_handle) {
   1.558 -        if (_this->gl_data->glFinish == NULL) {
   1.559 -            tinygl_present = 1;
   1.560 -        }
   1.561 -    }
   1.562 -
   1.563 -    /* Init OpenGL context using OSMesa */
   1.564 -    gl_convert = ConvertNull;
   1.565 -    gl_copyshadow = CopyShadowNull;
   1.566 -    gl_upsidedown = SDL_FALSE;
   1.567 -
   1.568 -    pixel_format = current->format;
   1.569 -    redmask = pixel_format->Rmask;
   1.570 -    switch (pixel_format->BitsPerPixel) {
   1.571 -    case 15:
   1.572 -        /* 15 bits unsupported */
   1.573 -        if (tinygl_present) {
   1.574 -            gl_pixelsize = 3;
   1.575 -            osmesa_format = VDI_RGB;
   1.576 -            if (redmask == 31 << 10) {
   1.577 -                gl_copyshadow = CopyShadowRGBTo555;
   1.578 -            } else {
   1.579 -                gl_copyshadow = CopyShadowRGBTo565;
   1.580 -                gl_convert = Convert565To555le;
   1.581 -            }
   1.582 -        } else {
   1.583 -            gl_pixelsize = 4;
   1.584 -            gl_upsidedown = SDL_TRUE;
   1.585 -            osmesa_format = OSMESA_ARGB;
   1.586 -            if (redmask == 31 << 10) {
   1.587 -                gl_copyshadow = CopyShadow8888To555;
   1.588 -            } else {
   1.589 -                gl_copyshadow = CopyShadow8888To565;
   1.590 -                gl_convert = Convert565To555le;
   1.591 -            }
   1.592 -        }
   1.593 -        break;
   1.594 -    case 16:
   1.595 -        /* 16 bits unsupported */
   1.596 -        if (tinygl_present) {
   1.597 -            gl_pixelsize = 3;
   1.598 -            osmesa_format = VDI_RGB;
   1.599 -            gl_copyshadow = CopyShadowRGBTo565;
   1.600 -            if (redmask != 31 << 11) {
   1.601 -                /* 565, little endian, unsupported */
   1.602 -                gl_convert = Convert565le;
   1.603 -            }
   1.604 -        } else {
   1.605 -            gl_pixelsize = 4;
   1.606 -            gl_upsidedown = SDL_TRUE;
   1.607 -            osmesa_format = OSMESA_ARGB;
   1.608 -            gl_copyshadow = CopyShadow8888To565;
   1.609 -            if (redmask != 31 << 11) {
   1.610 -                /* 565, little endian, unsupported */
   1.611 -                gl_convert = Convert565le;
   1.612 -            }
   1.613 -        }
   1.614 -        break;
   1.615 -    case 24:
   1.616 -        gl_pixelsize = 3;
   1.617 -        if (tinygl_present) {
   1.618 -            osmesa_format = VDI_RGB;
   1.619 -            gl_copyshadow = CopyShadowDirect;
   1.620 -            if (redmask != 255 << 16) {
   1.621 -                gl_copyshadow = CopyShadowRGBSwap;
   1.622 -            }
   1.623 -        } else {
   1.624 -            gl_copyshadow = CopyShadowDirect;
   1.625 -            gl_upsidedown = SDL_TRUE;
   1.626 -            if (redmask == 255 << 16) {
   1.627 -                osmesa_format = OSMESA_RGB;
   1.628 -            } else {
   1.629 -                osmesa_format = OSMESA_BGR;
   1.630 -            }
   1.631 -        }
   1.632 -        break;
   1.633 -    case 32:
   1.634 -        if (tinygl_present) {
   1.635 -            gl_pixelsize = 3;
   1.636 -            osmesa_format = VDI_RGB;
   1.637 -            gl_copyshadow = CopyShadowRGBToARGB;
   1.638 -            if (redmask == 255) {
   1.639 -                gl_convert = CopyShadowRGBToABGR;
   1.640 -            } else if (redmask == 255 << 8) {
   1.641 -                gl_convert = CopyShadowRGBToBGRA;
   1.642 -            } else if (redmask == 255 << 24) {
   1.643 -                gl_convert = CopyShadowRGBToRGBA;
   1.644 -            }
   1.645 -        } else {
   1.646 -            gl_pixelsize = 4;
   1.647 -            gl_upsidedown = SDL_TRUE;
   1.648 -            gl_copyshadow = CopyShadowDirect;
   1.649 -            if (redmask == 255 << 16) {
   1.650 -                osmesa_format = OSMESA_ARGB;
   1.651 -            } else if (redmask == 255 << 8) {
   1.652 -                osmesa_format = OSMESA_BGRA;
   1.653 -            } else if (redmask == 255 << 24) {
   1.654 -                osmesa_format = OSMESA_RGBA;
   1.655 -            } else {
   1.656 -                /* ABGR format unsupported */
   1.657 -                osmesa_format = OSMESA_BGRA;
   1.658 -                gl_convert = ConvertBGRAToABGR;
   1.659 -            }
   1.660 -        }
   1.661 -        break;
   1.662 -    default:
   1.663 -        if (tinygl_present) {
   1.664 -            SDL_AtariGL_Quit(_this, SDL_FALSE);
   1.665 -            return 0;
   1.666 -        }
   1.667 -        gl_pixelsize = 1;
   1.668 -        gl_copyshadow = CopyShadowDirect;
   1.669 -        osmesa_format = OSMESA_COLOR_INDEX;
   1.670 -        break;
   1.671 -    }
   1.672 -
   1.673 -    /* Try to keep current context if possible */
   1.674 -    recreatecontext = 1;
   1.675 -    if (gl_shadow &&
   1.676 -        (gl_curformat == osmesa_format) &&
   1.677 -        (gl_curwidth == current->w) && (gl_curheight == current->h)) {
   1.678 -        recreatecontext = 0;
   1.679 -    }
   1.680 -    if (recreatecontext) {
   1.681 -        SDL_AtariGL_Quit(_this, SDL_FALSE);
   1.682 -
   1.683 -        gl_shadow =
   1.684 -            _this->gl_data->OSMesaCreateLDG(osmesa_format, GL_UNSIGNED_BYTE,
   1.685 -                                            current->w, current->h);
   1.686 -
   1.687 -        if (gl_shadow) {
   1.688 -            gl_curformat = osmesa_format;
   1.689 -            gl_curwidth = current->w;
   1.690 -            gl_curheight = current->h;
   1.691 -        } else {
   1.692 -            gl_curformat = 0;
   1.693 -            gl_curwidth = 0;
   1.694 -            gl_curheight = 0;
   1.695 -        }
   1.696 -    }
   1.697 -
   1.698 -    return (gl_shadow != NULL);
   1.699 -}
   1.700 -
   1.701 -/*--- Conversions routines from shadow buffer to the screen ---*/
   1.702 -
   1.703 -static void
   1.704 -CopyShadowNull(_THIS, SDL_Surface * surface)
   1.705 -{
   1.706 -}
   1.707 -
   1.708 -static void
   1.709 -CopyShadowDirect(_THIS, SDL_Surface * surface)
   1.710 -{
   1.711 -    int y, srcpitch, dstpitch;
   1.712 -    Uint8 *srcline, *dstline;
   1.713 -
   1.714 -    srcline = gl_shadow;
   1.715 -    srcpitch = surface->w * gl_pixelsize;
   1.716 -    dstline = surface->pixels;
   1.717 -    dstpitch = surface->pitch;
   1.718 -    if (gl_upsidedown) {
   1.719 -        srcline += (surface->h - 1) * srcpitch;
   1.720 -        srcpitch = -srcpitch;
   1.721 -    }
   1.722 -
   1.723 -    for (y = 0; y < surface->h; y++) {
   1.724 -        SDL_memcpy(dstline, srcline, srcpitch);
   1.725 -
   1.726 -        srcline += srcpitch;
   1.727 -        dstline += dstpitch;
   1.728 -    }
   1.729 -}
   1.730 -
   1.731 -static void
   1.732 -CopyShadowRGBTo555(_THIS, SDL_Surface * surface)
   1.733 -{
   1.734 -    int x, y, srcpitch, dstpitch;
   1.735 -    Uint16 *dstline, *dstcol;
   1.736 -    Uint8 *srcline, *srccol;
   1.737 -
   1.738 -    srcline = (Uint8 *) gl_shadow;
   1.739 -    srcpitch = surface->w * gl_pixelsize;
   1.740 -    dstline = surface->pixels;
   1.741 -    dstpitch = surface->pitch >> 1;
   1.742 -    if (gl_upsidedown) {
   1.743 -        srcline += (surface->h - 1) * srcpitch;
   1.744 -        srcpitch = -srcpitch;
   1.745 -    }
   1.746 -
   1.747 -    for (y = 0; y < surface->h; y++) {
   1.748 -        srccol = srcline;
   1.749 -        dstcol = dstline;
   1.750 -        for (x = 0; x < surface->w; x++) {
   1.751 -            Uint16 dstcolor;
   1.752 -
   1.753 -            dstcolor = ((*srccol++) << 7) & (31 << 10);
   1.754 -            dstcolor |= ((*srccol++) << 2) & (31 << 5);
   1.755 -            dstcolor |= ((*srccol++) >> 3) & 31;
   1.756 -            *dstcol++ = dstcolor;
   1.757 -        }
   1.758 -
   1.759 -        srcline += srcpitch;
   1.760 -        dstline += dstpitch;
   1.761 -    }
   1.762 -}
   1.763 -
   1.764 -static void
   1.765 -CopyShadowRGBTo565(_THIS, SDL_Surface * surface)
   1.766 -{
   1.767 -    int x, y, srcpitch, dstpitch;
   1.768 -    Uint16 *dstline, *dstcol;
   1.769 -    Uint8 *srcline, *srccol;
   1.770 -
   1.771 -    srcline = (Uint8 *) gl_shadow;
   1.772 -    srcpitch = surface->w * gl_pixelsize;
   1.773 -    dstline = surface->pixels;
   1.774 -    dstpitch = surface->pitch >> 1;
   1.775 -    if (gl_upsidedown) {
   1.776 -        srcline += (surface->h - 1) * srcpitch;
   1.777 -        srcpitch = -srcpitch;
   1.778 -    }
   1.779 -
   1.780 -    for (y = 0; y < surface->h; y++) {
   1.781 -        srccol = srcline;
   1.782 -        dstcol = dstline;
   1.783 -
   1.784 -        for (x = 0; x < surface->w; x++) {
   1.785 -            Uint16 dstcolor;
   1.786 -
   1.787 -            dstcolor = ((*srccol++) << 8) & (31 << 11);
   1.788 -            dstcolor |= ((*srccol++) << 3) & (63 << 5);
   1.789 -            dstcolor |= ((*srccol++) >> 3) & 31;
   1.790 -            *dstcol++ = dstcolor;
   1.791 -        }
   1.792 -
   1.793 -        srcline += srcpitch;
   1.794 -        dstline += dstpitch;
   1.795 -    }
   1.796 -}
   1.797 -
   1.798 -static void
   1.799 -CopyShadowRGBSwap(_THIS, SDL_Surface * surface)
   1.800 -{
   1.801 -    int x, y, srcpitch, dstpitch;
   1.802 -    Uint8 *dstline, *dstcol;
   1.803 -    Uint8 *srcline, *srccol;
   1.804 -
   1.805 -    srcline = (Uint8 *) gl_shadow;
   1.806 -    srcpitch = surface->w * gl_pixelsize;
   1.807 -    dstline = surface->pixels;
   1.808 -    dstpitch = surface->pitch;
   1.809 -    if (gl_upsidedown) {
   1.810 -        srcline += (surface->h - 1) * srcpitch;
   1.811 -        srcpitch = -srcpitch;
   1.812 -    }
   1.813 -
   1.814 -    for (y = 0; y < surface->h; y++) {
   1.815 -        srccol = srcline;
   1.816 -        dstcol = dstline;
   1.817 -
   1.818 -        for (x = 0; x < surface->w; x++) {
   1.819 -            *dstcol++ = srccol[2];
   1.820 -            *dstcol++ = srccol[1];
   1.821 -            *dstcol++ = srccol[0];
   1.822 -            srccol += 3;
   1.823 -        }
   1.824 -
   1.825 -        srcline += srcpitch;
   1.826 -        dstline += dstpitch;
   1.827 -    }
   1.828 -}
   1.829 -
   1.830 -static void
   1.831 -CopyShadowRGBToARGB(_THIS, SDL_Surface * surface)
   1.832 -{
   1.833 -    int x, y, srcpitch, dstpitch;
   1.834 -    Uint32 *dstline, *dstcol;
   1.835 -    Uint8 *srcline, *srccol;
   1.836 -
   1.837 -    srcline = (Uint8 *) gl_shadow;
   1.838 -    srcpitch = surface->w * gl_pixelsize;
   1.839 -    dstline = surface->pixels;
   1.840 -    dstpitch = surface->pitch >> 2;
   1.841 -    if (gl_upsidedown) {
   1.842 -        srcline += (surface->h - 1) * srcpitch;
   1.843 -        srcpitch = -srcpitch;
   1.844 -    }
   1.845 -
   1.846 -    for (y = 0; y < surface->h; y++) {
   1.847 -        srccol = srcline;
   1.848 -        dstcol = dstline;
   1.849 -
   1.850 -        for (x = 0; x < surface->w; x++) {
   1.851 -            Uint32 dstcolor;
   1.852 -
   1.853 -            dstcolor = (*srccol++) << 16;
   1.854 -            dstcolor |= (*srccol++) << 8;
   1.855 -            dstcolor |= *srccol++;
   1.856 -
   1.857 -            *dstcol++ = dstcolor;
   1.858 -        }
   1.859 -
   1.860 -        srcline += srcpitch;
   1.861 -        dstline += dstpitch;
   1.862 -    }
   1.863 -}
   1.864 -
   1.865 -static void
   1.866 -CopyShadowRGBToABGR(_THIS, SDL_Surface * surface)
   1.867 -{
   1.868 -    int x, y, srcpitch, dstpitch;
   1.869 -    Uint32 *dstline, *dstcol;
   1.870 -    Uint8 *srcline, *srccol;
   1.871 -
   1.872 -    srcline = (Uint8 *) gl_shadow;
   1.873 -    srcpitch = surface->w * gl_pixelsize;
   1.874 -    dstline = surface->pixels;
   1.875 -    dstpitch = surface->pitch >> 2;
   1.876 -    if (gl_upsidedown) {
   1.877 -        srcline += (surface->h - 1) * srcpitch;
   1.878 -        srcpitch = -srcpitch;
   1.879 -    }
   1.880 -
   1.881 -    for (y = 0; y < surface->h; y++) {
   1.882 -        srccol = srcline;
   1.883 -        dstcol = dstline;
   1.884 -
   1.885 -        for (x = 0; x < surface->w; x++) {
   1.886 -            Uint32 dstcolor;
   1.887 -
   1.888 -            dstcolor = *srccol++;
   1.889 -            dstcolor |= (*srccol++) << 8;
   1.890 -            dstcolor |= (*srccol++) << 16;
   1.891 -
   1.892 -            *dstcol++ = dstcolor;
   1.893 -        }
   1.894 -
   1.895 -        srcline += srcpitch;
   1.896 -        dstline += dstpitch;
   1.897 -    }
   1.898 -}
   1.899 -
   1.900 -static void
   1.901 -CopyShadowRGBToBGRA(_THIS, SDL_Surface * surface)
   1.902 -{
   1.903 -    int x, y, srcpitch, dstpitch;
   1.904 -    Uint32 *dstline, *dstcol;
   1.905 -    Uint8 *srcline, *srccol;
   1.906 -
   1.907 -    srcline = (Uint8 *) gl_shadow;
   1.908 -    srcpitch = surface->w * gl_pixelsize;
   1.909 -    dstline = surface->pixels;
   1.910 -    dstpitch = surface->pitch >> 2;
   1.911 -    if (gl_upsidedown) {
   1.912 -        srcline += (surface->h - 1) * srcpitch;
   1.913 -        srcpitch = -srcpitch;
   1.914 -    }
   1.915 -
   1.916 -    for (y = 0; y < surface->h; y++) {
   1.917 -        srccol = srcline;
   1.918 -        dstcol = dstline;
   1.919 -
   1.920 -        for (x = 0; x < surface->w; x++) {
   1.921 -            Uint32 dstcolor;
   1.922 -
   1.923 -            dstcolor = (*srccol++) << 8;
   1.924 -            dstcolor |= (*srccol++) << 16;
   1.925 -            dstcolor |= (*srccol++) << 24;
   1.926 -
   1.927 -            *dstcol++ = dstcolor;
   1.928 -        }
   1.929 -
   1.930 -        srcline += srcpitch;
   1.931 -        dstline += dstpitch;
   1.932 -    }
   1.933 -}
   1.934 -
   1.935 -static void
   1.936 -CopyShadowRGBToRGBA(_THIS, SDL_Surface * surface)
   1.937 -{
   1.938 -    int x, y, srcpitch, dstpitch;
   1.939 -    Uint32 *dstline, *dstcol;
   1.940 -    Uint8 *srcline, *srccol;
   1.941 -
   1.942 -    srcline = (Uint8 *) gl_shadow;
   1.943 -    srcpitch = surface->w * gl_pixelsize;
   1.944 -    dstline = surface->pixels;
   1.945 -    dstpitch = surface->pitch >> 2;
   1.946 -    if (gl_upsidedown) {
   1.947 -        srcline += (surface->h - 1) * srcpitch;
   1.948 -        srcpitch = -srcpitch;
   1.949 -    }
   1.950 -
   1.951 -    for (y = 0; y < surface->h; y++) {
   1.952 -        srccol = srcline;
   1.953 -        dstcol = dstline;
   1.954 -
   1.955 -        for (x = 0; x < surface->w; x++) {
   1.956 -            Uint32 dstcolor;
   1.957 -
   1.958 -            dstcolor = (*srccol++) << 24;
   1.959 -            dstcolor |= (*srccol++) << 16;
   1.960 -            dstcolor |= (*srccol++) << 8;
   1.961 -
   1.962 -            *dstcol++ = dstcolor;
   1.963 -        }
   1.964 -
   1.965 -        srcline += srcpitch;
   1.966 -        dstline += dstpitch;
   1.967 -    }
   1.968 -}
   1.969 -
   1.970 -static void
   1.971 -CopyShadow8888To555(_THIS, SDL_Surface * surface)
   1.972 -{
   1.973 -    int x, y, srcpitch, dstpitch;
   1.974 -    Uint16 *dstline, *dstcol;
   1.975 -    Uint32 *srcline, *srccol;
   1.976 -
   1.977 -    srcline = (Uint32 *) gl_shadow;
   1.978 -    srcpitch = (surface->w * gl_pixelsize) >> 2;
   1.979 -    dstline = surface->pixels;
   1.980 -    dstpitch = surface->pitch >> 1;
   1.981 -    if (gl_upsidedown) {
   1.982 -        srcline += (surface->h - 1) * srcpitch;
   1.983 -        srcpitch = -srcpitch;
   1.984 -    }
   1.985 -
   1.986 -    for (y = 0; y < surface->h; y++) {
   1.987 -        srccol = srcline;
   1.988 -        dstcol = dstline;
   1.989 -        for (x = 0; x < surface->w; x++) {
   1.990 -            Uint32 srccolor;
   1.991 -            Uint16 dstcolor;
   1.992 -
   1.993 -            srccolor = *srccol++;
   1.994 -            dstcolor = (srccolor >> 9) & (31 << 10);
   1.995 -            dstcolor |= (srccolor >> 6) & (31 << 5);
   1.996 -            dstcolor |= (srccolor >> 3) & 31;
   1.997 -            *dstcol++ = dstcolor;
   1.998 -        }
   1.999 -
  1.1000 -        srcline += srcpitch;
  1.1001 -        dstline += dstpitch;
  1.1002 -    }
  1.1003 -}
  1.1004 -
  1.1005 -static void
  1.1006 -CopyShadow8888To565(_THIS, SDL_Surface * surface)
  1.1007 -{
  1.1008 -    int x, y, srcpitch, dstpitch;
  1.1009 -    Uint16 *dstline, *dstcol;
  1.1010 -    Uint32 *srcline, *srccol;
  1.1011 -
  1.1012 -    srcline = (Uint32 *) gl_shadow;
  1.1013 -    srcpitch = (surface->w * gl_pixelsize) >> 2;
  1.1014 -    dstline = surface->pixels;
  1.1015 -    dstpitch = surface->pitch >> 1;
  1.1016 -    if (gl_upsidedown) {
  1.1017 -        srcline += (surface->h - 1) * srcpitch;
  1.1018 -        srcpitch = -srcpitch;
  1.1019 -    }
  1.1020 -
  1.1021 -    for (y = 0; y < surface->h; y++) {
  1.1022 -        srccol = srcline;
  1.1023 -        dstcol = dstline;
  1.1024 -
  1.1025 -        for (x = 0; x < surface->w; x++) {
  1.1026 -            Uint32 srccolor;
  1.1027 -            Uint16 dstcolor;
  1.1028 -
  1.1029 -            srccolor = *srccol++;
  1.1030 -            dstcolor = (srccolor >> 8) & (31 << 11);
  1.1031 -            dstcolor |= (srccolor >> 5) & (63 << 5);
  1.1032 -            dstcolor |= (srccolor >> 3) & 31;
  1.1033 -            *dstcol++ = dstcolor;
  1.1034 -        }
  1.1035 -
  1.1036 -        srcline += srcpitch;
  1.1037 -        dstline += dstpitch;
  1.1038 -    }
  1.1039 -}
  1.1040 -
  1.1041 -/*--- Conversions routines in the screen ---*/
  1.1042 -
  1.1043 -static void
  1.1044 -ConvertNull(_THIS, SDL_Surface * surface)
  1.1045 -{
  1.1046 -}
  1.1047 -
  1.1048 -static void
  1.1049 -Convert565To555be(_THIS, SDL_Surface * surface)
  1.1050 -{
  1.1051 -    int x, y, pitch;
  1.1052 -    unsigned short *line, *pixel;
  1.1053 -
  1.1054 -    line = surface->pixels;
  1.1055 -    pitch = surface->pitch >> 1;
  1.1056 -    for (y = 0; y < surface->h; y++) {
  1.1057 -        pixel = line;
  1.1058 -        for (x = 0; x < surface->w; x++) {
  1.1059 -            unsigned short color = *pixel;
  1.1060 -
  1.1061 -            *pixel++ = (color & 0x1f) | ((color >> 1) & 0xffe0);
  1.1062 -        }
  1.1063 -
  1.1064 -        line += pitch;
  1.1065 -    }
  1.1066 -}
  1.1067 -
  1.1068 -static void
  1.1069 -Convert565To555le(_THIS, SDL_Surface * surface)
  1.1070 -{
  1.1071 -    int x, y, pitch;
  1.1072 -    unsigned short *line, *pixel;
  1.1073 -
  1.1074 -    line = surface->pixels;
  1.1075 -    pitch = surface->pitch >> 1;
  1.1076 -    for (y = 0; y < surface->h; y++) {
  1.1077 -        pixel = line;
  1.1078 -        for (x = 0; x < surface->w; x++) {
  1.1079 -            unsigned short color = *pixel;
  1.1080 -
  1.1081 -            color = (color & 0x1f) | ((color >> 1) & 0xffe0);
  1.1082 -            *pixel++ = SDL_Swap16(color);
  1.1083 -        }
  1.1084 -
  1.1085 -        line += pitch;
  1.1086 -    }
  1.1087 -}
  1.1088 -
  1.1089 -static void
  1.1090 -Convert565le(_THIS, SDL_Surface * surface)
  1.1091 -{
  1.1092 -    int x, y, pitch;
  1.1093 -    unsigned short *line, *pixel;
  1.1094 -
  1.1095 -    line = surface->pixels;
  1.1096 -    pitch = surface->pitch >> 1;
  1.1097 -    for (y = 0; y < surface->h; y++) {
  1.1098 -        pixel = line;
  1.1099 -        for (x = 0; x < surface->w; x++) {
  1.1100 -            unsigned short color = *pixel;
  1.1101 -
  1.1102 -            *pixel++ = SDL_Swap16(color);
  1.1103 -        }
  1.1104 -
  1.1105 -        line += pitch;
  1.1106 -    }
  1.1107 -}
  1.1108 -
  1.1109 -static void
  1.1110 -ConvertBGRAToABGR(_THIS, SDL_Surface * surface)
  1.1111 -{
  1.1112 -    int x, y, pitch;
  1.1113 -    unsigned long *line, *pixel;
  1.1114 -
  1.1115 -    line = surface->pixels;
  1.1116 -    pitch = surface->pitch >> 2;
  1.1117 -    for (y = 0; y < surface->h; y++) {
  1.1118 -        pixel = line;
  1.1119 -        for (x = 0; x < surface->w; x++) {
  1.1120 -            unsigned long color = *pixel;
  1.1121 -
  1.1122 -            *pixel++ = (color << 24) | (color >> 8);
  1.1123 -        }
  1.1124 -
  1.1125 -        line += pitch;
  1.1126 -    }
  1.1127 -}
  1.1128 -
  1.1129 -#endif /* SDL_VIDEO_OPENGL */
  1.1130 -/* vi: set ts=4 sw=4 expandtab: */