Starting on the OpenGL renderer...
authorSam Lantinga <slouken@libsdl.org>
Wed, 19 Jul 2006 07:18:45 +0000
changeset 1918092bd3a019c5
parent 1917 3f54b3ec5a07
child 1919 00816063b9c9
Starting on the OpenGL renderer...
src/video/SDL_renderer_gl.c
src/video/SDL_renderer_gl.h
src/video/SDL_renderer_sw.c
src/video/SDL_renderer_sw.h
src/video/SDL_video.c
src/video/win32/SDL_d3drender.c
src/video/win32/SDL_gdirender.c
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/video/SDL_renderer_gl.c	Wed Jul 19 07:18:45 2006 +0000
     1.3 @@ -0,0 +1,544 @@
     1.4 +/*
     1.5 +    SDL - Simple DirectMedia Layer
     1.6 +    Copyright (C) 1997-2006 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 Lesser General Public
    1.10 +    License as published by the Free Software Foundation; either
    1.11 +    version 2.1 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 +    Lesser General Public License for more details.
    1.17 +
    1.18 +    You should have received a copy of the GNU Lesser General Public
    1.19 +    License along with this library; if not, write to the Free Software
    1.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    1.21 +
    1.22 +    Sam Lantinga
    1.23 +    slouken@libsdl.org
    1.24 +*/
    1.25 +#include "SDL_config.h"
    1.26 +
    1.27 +#if SDL_VIDEO_OPENGL
    1.28 +
    1.29 +#include "SDL_win32video.h"
    1.30 +
    1.31 +/* OpenGL renderer implementation */
    1.32 +
    1.33 +static SDL_Renderer *GL_CreateRenderer(SDL_Window * window, Uint32 flags);
    1.34 +static int GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
    1.35 +static int GL_SetTexturePalette(SDL_Renderer * renderer,
    1.36 +                                SDL_Texture * texture,
    1.37 +                                const SDL_Color * colors, int firstcolor,
    1.38 +                                int ncolors);
    1.39 +static int GL_GetTexturePalette(SDL_Renderer * renderer,
    1.40 +                                SDL_Texture * texture, SDL_Color * colors,
    1.41 +                                int firstcolor, int ncolors);
    1.42 +static int GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
    1.43 +                            const SDL_Rect * rect, const void *pixels,
    1.44 +                            int pitch);
    1.45 +static int GL_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
    1.46 +                          const SDL_Rect * rect, int markDirty,
    1.47 +                          void **pixels, int *pitch);
    1.48 +static void GL_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
    1.49 +static void GL_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
    1.50 +                            int numrects, const SDL_Rect * rects);
    1.51 +static int GL_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect,
    1.52 +                         Uint32 color);
    1.53 +static int GL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
    1.54 +                         const SDL_Rect * srcrect, const SDL_Rect * dstrect,
    1.55 +                         int blendMode, int scaleMode);
    1.56 +static void GL_RenderPresent(SDL_Renderer * renderer);
    1.57 +static void GL_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture);
    1.58 +static void GL_DestroyRenderer(SDL_Renderer * renderer);
    1.59 +
    1.60 +
    1.61 +SDL_RenderDriver GL_RenderDriver = {
    1.62 +    GL_CreateRenderer,
    1.63 +    {
    1.64 +     "opengl",
    1.65 +     (SDL_Renderer_PresentDiscard | SDL_Renderer_PresentVSync |
    1.66 +      SDL_Renderer_Accelerated),
    1.67 +     (SDL_TextureBlendMode_None | SDL_TextureBlendMode_Mask |
    1.68 +      SDL_TextureBlendMode_Blend | SDL_TextureBlendMode_Add |
    1.69 +      SDL_TextureBlendMode_Mod),
    1.70 +     (SDL_TextureScaleMode_None | SDL_TextureScaleMode_Fast |
    1.71 +      SDL_TextureScaleMode_Best),
    1.72 +     12,
    1.73 +     {
    1.74 +      SDL_PixelFormat_Index8,
    1.75 +      SDL_PixelFormat_RGB332,
    1.76 +      SDL_PixelFormat_RGB444,
    1.77 +      SDL_PixelFormat_RGB555,
    1.78 +      SDL_PixelFormat_ARGB4444,
    1.79 +      SDL_PixelFormat_ARGB1555,
    1.80 +      SDL_PixelFormat_RGB565,
    1.81 +      SDL_PixelFormat_RGB888,
    1.82 +      SDL_PixelFormat_ARGB8888,
    1.83 +      SDL_PixelFormat_ARGB2101010,
    1.84 +      SDL_PixelFormat_UYVY,
    1.85 +      SDL_PixelFormat_YUY2},
    1.86 +     0,
    1.87 +     0}
    1.88 +};
    1.89 +
    1.90 +typedef struct
    1.91 +{
    1.92 +    SDL_GLContext context;
    1.93 +    SDL_bool beginScene;
    1.94 +} GL_RenderData;
    1.95 +
    1.96 +typedef struct
    1.97 +{
    1.98 +    GLuint texture;
    1.99 +    GLfloat texw;
   1.100 +    GLfloat texh;
   1.101 +    void *pixels;
   1.102 +    int pitch;
   1.103 +} GL_TextureData;
   1.104 +
   1.105 +static GLFORMAT
   1.106 +PixelFormatToOpenGL(Uint32 format,)
   1.107 +{
   1.108 +    switch (format) {
   1.109 +    case SDL_PixelFormat_Index8:
   1.110 +        return GLFMT_P8;
   1.111 +    case SDL_PixelFormat_RGB332:
   1.112 +        return GLFMT_R3G3B2;
   1.113 +    case SDL_PixelFormat_RGB444:
   1.114 +        return GLFMT_X4R4G4B4;
   1.115 +    case SDL_PixelFormat_RGB555:
   1.116 +        return GLFMT_X1R5G5B5;
   1.117 +    case SDL_PixelFormat_ARGB4444:
   1.118 +        return GLFMT_A4R4G4B4;
   1.119 +    case SDL_PixelFormat_ARGB1555:
   1.120 +        return GLFMT_A1R5G5B5;
   1.121 +    case SDL_PixelFormat_RGB565:
   1.122 +        return GLFMT_R5G6B5;
   1.123 +    case SDL_PixelFormat_RGB888:
   1.124 +        return GLFMT_X8R8G8B8;
   1.125 +    case SDL_PixelFormat_ARGB8888:
   1.126 +        return GLFMT_A8R8G8B8;
   1.127 +    case SDL_PixelFormat_ARGB2101010:
   1.128 +        return GLFMT_A2R10G10B10;
   1.129 +    case SDL_PixelFormat_UYVY:
   1.130 +        return GLFMT_UYVY;
   1.131 +    case SDL_PixelFormat_YUY2:
   1.132 +        return GLFMT_YUY2;
   1.133 +    default:
   1.134 +        return GLFMT_UNKNOWN;
   1.135 +    }
   1.136 +}
   1.137 +
   1.138 +void
   1.139 +GL_AddRenderDriver(_THIS)
   1.140 +{
   1.141 +    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
   1.142 +
   1.143 +    if (data->d3d) {
   1.144 +        SDL_AddRenderDriver(0, &GL_RenderDriver);
   1.145 +    }
   1.146 +}
   1.147 +
   1.148 +SDL_Renderer *
   1.149 +GL_CreateRenderer(SDL_Window * window, Uint32 flags)
   1.150 +{
   1.151 +    SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
   1.152 +    SDL_VideoData *videodata = (SDL_VideoData *) display->device->driverdata;
   1.153 +    SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata;
   1.154 +    SDL_Renderer *renderer;
   1.155 +    GL_RenderData *data;
   1.156 +    HRESULT result;
   1.157 +    GLPRESENT_PARAMETERS pparams;
   1.158 +    IDirect3DSwapChain9 *chain;
   1.159 +
   1.160 +    if (!(window->flags & SDL_WINDOW_OPENGL)) {
   1.161 +        SDL_SetError
   1.162 +            ("The OpenGL renderer can only be used on OpenGL windows");
   1.163 +        return NULL;
   1.164 +    }
   1.165 +
   1.166 +    renderer = (SDL_Renderer *) SDL_malloc(sizeof(*renderer));
   1.167 +    if (!renderer) {
   1.168 +        SDL_OutOfMemory();
   1.169 +        return NULL;
   1.170 +    }
   1.171 +    SDL_zerop(renderer);
   1.172 +
   1.173 +    data = (GL_RenderData *) SDL_malloc(sizeof(*data));
   1.174 +    if (!data) {
   1.175 +        GL_DestroyRenderer(renderer);
   1.176 +        SDL_OutOfMemory();
   1.177 +        return NULL;
   1.178 +    }
   1.179 +    SDL_zerop(data);
   1.180 +
   1.181 +    renderer->CreateTexture = GL_CreateTexture;
   1.182 +    renderer->SetTexturePalette = GL_SetTexturePalette;
   1.183 +    renderer->GetTexturePalette = GL_GetTexturePalette;
   1.184 +    renderer->UpdateTexture = GL_UpdateTexture;
   1.185 +    renderer->LockTexture = GL_LockTexture;
   1.186 +    renderer->UnlockTexture = GL_UnlockTexture;
   1.187 +    renderer->DirtyTexture = GL_DirtyTexture;
   1.188 +    renderer->RenderFill = GL_RenderFill;
   1.189 +    renderer->RenderCopy = GL_RenderCopy;
   1.190 +    renderer->RenderPresent = GL_RenderPresent;
   1.191 +    renderer->DestroyTexture = GL_DestroyTexture;
   1.192 +    renderer->DestroyRenderer = GL_DestroyRenderer;
   1.193 +    renderer->info = GL_RenderDriver.info;
   1.194 +    renderer->window = window->id;
   1.195 +    renderer->driverdata = data;
   1.196 +
   1.197 +    renderer->info.flags =
   1.198 +        (SDL_Renderer_PresentDiscard | SDL_Renderer_Accelerated);
   1.199 +
   1.200 +    data->context = SDL_GL_CreateContext(window->id);
   1.201 +    if (!data->context) {
   1.202 +        GL_DestroyRenderer(renderer);
   1.203 +        return NULL;
   1.204 +    }
   1.205 +    if (SDL_GL_MakeCurrent(window->id, data->context) < 0) {
   1.206 +        GL_DestroyRenderer(renderer);
   1.207 +        return NULL;
   1.208 +    }
   1.209 +    data->beginScene = SDL_TRUE;
   1.210 +
   1.211 +    if (flags & SDL_Renderer_PresentVSync) {
   1.212 +        SDL_GL_SetSwapInterval(1);
   1.213 +    } else {
   1.214 +        SDL_GL_SetSwapInterval(0);
   1.215 +    }
   1.216 +    if (SDL_GL_GetSwapInterval() > 0) {
   1.217 +        renderer->info.flags |= SDL_Renderer_PresentVSync;
   1.218 +    }
   1.219 +
   1.220 +    /* Set up parameters for rendering */
   1.221 +    glDisable(GL_DEPTH_TEST);
   1.222 +    glDisable(GL_CULL_FACE);
   1.223 +    glEnable(GL_TEXTURE_2D);
   1.224 +    glMatrixMode(GL_PROJECTION);
   1.225 +    glLoadIdentity();
   1.226 +    glMatrixMode(GL_MODELVIEW);
   1.227 +    glLoadIdentity();
   1.228 +    glViewport(0, 0, window->w, window->h);
   1.229 +    glOrtho(0.0, (GLdouble) window->w, (GLdouble) window->h, 0.0, 0.0, 1.0);
   1.230 +    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
   1.231 +
   1.232 +    return renderer;
   1.233 +}
   1.234 +
   1.235 +/* Quick utility function for texture creation */
   1.236 +static int
   1.237 +power_of_two(int input)
   1.238 +{
   1.239 +    int value = 1;
   1.240 +
   1.241 +    while (value < input) {
   1.242 +        value <<= 1;
   1.243 +    }
   1.244 +    return value;
   1.245 +}
   1.246 +
   1.247 +static int
   1.248 +GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
   1.249 +{
   1.250 +    GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata;
   1.251 +    SDL_Window *window = SDL_GetWindowFromID(renderer->window);
   1.252 +    SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
   1.253 +    GL_TextureData *data;
   1.254 +    GLPOOL pool;
   1.255 +    HRESULT result;
   1.256 +
   1.257 +    data = (GL_TextureData *) SDL_malloc(sizeof(*data));
   1.258 +    if (!data) {
   1.259 +        SDL_OutOfMemory();
   1.260 +        return -1;
   1.261 +    }
   1.262 +    SDL_zerop(data);
   1.263 +
   1.264 +    texture->driverdata = data;
   1.265 +
   1.266 +    if (texture->access == SDL_TextureAccess_Local) {
   1.267 +        pool = GLPOOL_MANAGED;
   1.268 +    } else {
   1.269 +        pool = GLPOOL_DEFAULT;
   1.270 +    }
   1.271 +    result =
   1.272 +        IDirect3DDevice9_CreateTexture(renderdata->device, texture->w,
   1.273 +                                       texture->h, 1, 0,
   1.274 +                                       PixelFormatToGLFMT(texture->format),
   1.275 +                                       pool, &data->texture, NULL);
   1.276 +    if (FAILED(result)) {
   1.277 +        SDL_free(data);
   1.278 +        GL_SetError("CreateTexture()", result);
   1.279 +        return -1;
   1.280 +    }
   1.281 +
   1.282 +    return 0;
   1.283 +}
   1.284 +
   1.285 +static int
   1.286 +GL_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
   1.287 +                     const SDL_Color * colors, int firstcolor, int ncolors)
   1.288 +{
   1.289 +    GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata;
   1.290 +    GL_TextureData *data = (GL_TextureData *) texture->driverdata;
   1.291 +
   1.292 +    return 0;
   1.293 +}
   1.294 +
   1.295 +static int
   1.296 +GL_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
   1.297 +                     SDL_Color * colors, int firstcolor, int ncolors)
   1.298 +{
   1.299 +    GL_TextureData *data = (GL_TextureData *) texture->driverdata;
   1.300 +
   1.301 +    return 0;
   1.302 +}
   1.303 +
   1.304 +static int
   1.305 +GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
   1.306 +                 const SDL_Rect * rect, const void *pixels, int pitch)
   1.307 +{
   1.308 +    GL_TextureData *data = (GL_TextureData *) texture->driverdata;
   1.309 +    GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata;
   1.310 +    IDirect3DTexture9 *temp;
   1.311 +    RECT d3drect;
   1.312 +    GLLOCKED_RECT locked;
   1.313 +    const Uint8 *src;
   1.314 +    Uint8 *dst;
   1.315 +    int row, length;
   1.316 +    HRESULT result;
   1.317 +
   1.318 +    result =
   1.319 +        IDirect3DDevice9_CreateTexture(renderdata->device, texture->w,
   1.320 +                                       texture->h, 1, 0,
   1.321 +                                       PixelFormatToGLFMT(texture->format),
   1.322 +                                       GLPOOL_SYSTEMMEM, &temp, NULL);
   1.323 +    if (FAILED(result)) {
   1.324 +        GL_SetError("CreateTexture()", result);
   1.325 +        return -1;
   1.326 +    }
   1.327 +
   1.328 +    d3drect.left = rect->x;
   1.329 +    d3drect.right = rect->x + rect->w;
   1.330 +    d3drect.top = rect->y;
   1.331 +    d3drect.bottom = rect->y + rect->h;
   1.332 +
   1.333 +    result = IDirect3DTexture9_LockRect(temp, 0, &locked, &d3drect, 0);
   1.334 +    if (FAILED(result)) {
   1.335 +        IDirect3DTexture9_Release(temp);
   1.336 +        GL_SetError("LockRect()", result);
   1.337 +        return -1;
   1.338 +    }
   1.339 +
   1.340 +    src = pixels;
   1.341 +    dst = locked.pBits;
   1.342 +    length = rect->w * SDL_BYTESPERPIXEL(texture->format);
   1.343 +    for (row = 0; row < rect->h; ++row) {
   1.344 +        SDL_memcpy(dst, src, length);
   1.345 +        src += pitch;
   1.346 +        dst += locked.Pitch;
   1.347 +    }
   1.348 +    IDirect3DTexture9_UnlockRect(temp, 0);
   1.349 +
   1.350 +    result =
   1.351 +        IDirect3DDevice9_UpdateTexture(renderdata->device,
   1.352 +                                       (IDirect3DBaseTexture9 *) temp,
   1.353 +                                       (IDirect3DBaseTexture9 *) data->
   1.354 +                                       texture);
   1.355 +    IDirect3DTexture9_Release(temp);
   1.356 +    if (FAILED(result)) {
   1.357 +        GL_SetError("UpdateTexture()", result);
   1.358 +        return -1;
   1.359 +    }
   1.360 +    return 0;
   1.361 +}
   1.362 +
   1.363 +static int
   1.364 +GL_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
   1.365 +               const SDL_Rect * rect, int markDirty, void **pixels,
   1.366 +               int *pitch)
   1.367 +{
   1.368 +    GL_TextureData *data = (GL_TextureData *) texture->driverdata;
   1.369 +    RECT d3drect;
   1.370 +    GLLOCKED_RECT locked;
   1.371 +    HRESULT result;
   1.372 +
   1.373 +    if (texture->access != SDL_TextureAccess_Local) {
   1.374 +        SDL_SetError("Can't lock remote video memory");
   1.375 +        return -1;
   1.376 +    }
   1.377 +
   1.378 +    d3drect.left = rect->x;
   1.379 +    d3drect.right = rect->x + rect->w;
   1.380 +    d3drect.top = rect->y;
   1.381 +    d3drect.bottom = rect->y + rect->h;
   1.382 +
   1.383 +    result =
   1.384 +        IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect,
   1.385 +                                   markDirty ? 0 : GLLOCK_NO_DIRTY_UPDATE);
   1.386 +    if (FAILED(result)) {
   1.387 +        GL_SetError("LockRect()", result);
   1.388 +        return -1;
   1.389 +    }
   1.390 +    *pixels = locked.pBits;
   1.391 +    *pitch = locked.Pitch;
   1.392 +    return 0;
   1.393 +}
   1.394 +
   1.395 +static void
   1.396 +GL_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
   1.397 +{
   1.398 +    GL_TextureData *data = (GL_TextureData *) texture->driverdata;
   1.399 +
   1.400 +    IDirect3DTexture9_UnlockRect(data->texture, 0);
   1.401 +}
   1.402 +
   1.403 +static void
   1.404 +GL_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture, int numrects,
   1.405 +                const SDL_Rect * rects)
   1.406 +{
   1.407 +    GL_TextureData *data = (GL_TextureData *) texture->driverdata;
   1.408 +    RECT d3drect;
   1.409 +    int i;
   1.410 +
   1.411 +    for (i = 0; i < numrects; ++i) {
   1.412 +        const SDL_Rect *rect = &rects[i];
   1.413 +
   1.414 +        d3drect.left = rect->x;
   1.415 +        d3drect.right = rect->x + rect->w;
   1.416 +        d3drect.top = rect->y;
   1.417 +        d3drect.bottom = rect->y + rect->h;
   1.418 +
   1.419 +        IDirect3DTexture9_AddDirtyRect(data->texture, &d3drect);
   1.420 +    }
   1.421 +}
   1.422 +
   1.423 +static int
   1.424 +GL_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect, Uint32 color)
   1.425 +{
   1.426 +    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
   1.427 +    SDL_Window *window = SDL_GetWindowFromID(renderer->window);
   1.428 +    GLclampf r, g, b, a;
   1.429 +
   1.430 +    a = ((GLclampf) ((color >> 24) & 0xFF)) / 255.0f;
   1.431 +    r = ((GLclampf) ((color >> 16) & 0xFF)) / 255.0f;
   1.432 +    g = ((GLclampf) ((color >> 8) & 0xFF)) / 255.0f;
   1.433 +    b = ((GLclampf) (color & 0xFF)) / 255.0f;
   1.434 +
   1.435 +    glClearColor(r, g, b, a);
   1.436 +    glViewport(rect->x, window->h - rect->y, rect->w, rect->h);
   1.437 +    glClear(GL_COLOR_BUFFER_BIT);
   1.438 +    glViewport(0, 0, window->w, window->h);
   1.439 +    return 0;
   1.440 +}
   1.441 +
   1.442 +static int
   1.443 +GL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
   1.444 +              const SDL_Rect * srcrect, const SDL_Rect * dstrect,
   1.445 +              int blendMode, int scaleMode)
   1.446 +{
   1.447 +    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
   1.448 +    GL_TextureData *texturedata = (GL_TextureData *) texture->driverdata;
   1.449 +    int minx, miny, maxx, maxy;
   1.450 +    GLfloat minu, maxu, minv, maxv;
   1.451 +
   1.452 +    minx = dstrect->x;
   1.453 +    miny = dstrect->y;
   1.454 +    maxx = dstrect->x + dstrect->w;
   1.455 +    maxy = dstrect->y + dstrect->h;
   1.456 +
   1.457 +    minu = (GLfloat) srcrect->x / texture->w;
   1.458 +    maxu = (GLfloat) (srcrect->x + srcrect->w) / texture->w;
   1.459 +    minv = (GLfloat) srcrect->y / texture->h;
   1.460 +    maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h;
   1.461 +
   1.462 +    glBindTexture(GL_TEXTURE_2D, texturedata->texture);
   1.463 +
   1.464 +    switch (blendMode) {
   1.465 +    case SDL_TextureBlendMode_None:
   1.466 +        glDisable(GL_BLEND);
   1.467 +        break;
   1.468 +    case SDL_TextureBlendMode_Mask:
   1.469 +    case SDL_TextureBlendMode_Blend:
   1.470 +        glEnable(GL_BLEND);
   1.471 +        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
   1.472 +        break;
   1.473 +    case SDL_TextureBlendMode_Add:
   1.474 +        glEnable(GL_BLEND);
   1.475 +        glBlendFunc(GL_SRC_ALPHA, GL_ONE);
   1.476 +        break;
   1.477 +    case SDL_TextureBlendMode_Mod:
   1.478 +        glEnable(GL_BLEND);
   1.479 +        glBlendFunc(GL_ZERO, GL_SRC_COLOR);
   1.480 +        break;
   1.481 +    }
   1.482 +
   1.483 +    switch (scaleMode) {
   1.484 +    case SDL_TextureScaleMode_None:
   1.485 +    case SDL_TextureScaleMode_Fast:
   1.486 +        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
   1.487 +        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
   1.488 +        break;
   1.489 +    case SDL_TextureScaleMode_Slow:
   1.490 +    case SDL_TextureScaleMode_Best:
   1.491 +        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
   1.492 +        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
   1.493 +        break;
   1.494 +    }
   1.495 +
   1.496 +    glBegin(GL_TRIANGLE_STRIP);
   1.497 +    glTexCoord2f(minu, minv);
   1.498 +    glVertex2i(minx, miny);
   1.499 +    glTexCoord2f(maxu, minv);
   1.500 +    glVertex2i(maxx, miny);
   1.501 +    glTexCoord2f(minu, maxv);
   1.502 +    glVertex2i(miny, maxy);
   1.503 +    glTexCoord2f(maxu, maxv);
   1.504 +    glVertex2i(maxx, maxy);
   1.505 +    glEnd();
   1.506 +
   1.507 +    return 0;
   1.508 +}
   1.509 +
   1.510 +static void
   1.511 +GL_RenderPresent(SDL_Renderer * renderer)
   1.512 +{
   1.513 +    SDL_GL_SwapWindow(renderer->window);
   1.514 +}
   1.515 +
   1.516 +static void
   1.517 +GL_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
   1.518 +{
   1.519 +    GL_TextureData *data = (GL_TextureData *) texture->driverdata;
   1.520 +
   1.521 +    if (!data) {
   1.522 +        return;
   1.523 +    }
   1.524 +    if (data->texture) {
   1.525 +        IDirect3DTexture9_Release(data->texture);
   1.526 +    }
   1.527 +    SDL_free(data);
   1.528 +    texture->driverdata = NULL;
   1.529 +}
   1.530 +
   1.531 +void
   1.532 +GL_DestroyRenderer(SDL_Renderer * renderer)
   1.533 +{
   1.534 +    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
   1.535 +
   1.536 +    if (data) {
   1.537 +        if (data->device) {
   1.538 +            IDirect3DDevice9_Release(data->device);
   1.539 +        }
   1.540 +        SDL_free(data);
   1.541 +    }
   1.542 +    SDL_free(renderer);
   1.543 +}
   1.544 +
   1.545 +#endif /* SDL_VIDEO_OPENGL */
   1.546 +
   1.547 +/* vi: set ts=4 sw=4 expandtab: */
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/src/video/SDL_renderer_gl.h	Wed Jul 19 07:18:45 2006 +0000
     2.3 @@ -0,0 +1,28 @@
     2.4 +/*
     2.5 +    SDL - Simple DirectMedia Layer
     2.6 +    Copyright (C) 1997-2006 Sam Lantinga
     2.7 +
     2.8 +    This library is free software; you can redistribute it and/or
     2.9 +    modify it under the terms of the GNU Lesser General Public
    2.10 +    License as published by the Free Software Foundation; either
    2.11 +    version 2.1 of the License, or (at your option) any later version.
    2.12 +
    2.13 +    This library is distributed in the hope that it will be useful,
    2.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    2.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    2.16 +    Lesser General Public License for more details.
    2.17 +
    2.18 +    You should have received a copy of the GNU Lesser General Public
    2.19 +    License along with this library; if not, write to the Free Software
    2.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    2.21 +
    2.22 +    Sam Lantinga
    2.23 +    slouken@libsdl.org
    2.24 +*/
    2.25 +#include "SDL_config.h"
    2.26 +
    2.27 +/* OpenGL renderer implementation */
    2.28 +
    2.29 +extern SDL_RenderDriver GL_RenderDriver;
    2.30 +
    2.31 +/* vi: set ts=4 sw=4 expandtab: */
     3.1 --- a/src/video/SDL_renderer_sw.c	Wed Jul 19 05:45:42 2006 +0000
     3.2 +++ b/src/video/SDL_renderer_sw.c	Wed Jul 19 07:18:45 2006 +0000
     3.3 @@ -30,44 +30,41 @@
     3.4  
     3.5  /* SDL surface based renderer implementation */
     3.6  
     3.7 -static SDL_Renderer *SDL_SW_CreateRenderer(SDL_Window * window, Uint32 flags);
     3.8 -static int SDL_SW_CreateTexture(SDL_Renderer * renderer,
     3.9 -                                SDL_Texture * texture);
    3.10 -static int SDL_SW_QueryTexturePixels(SDL_Renderer * renderer,
    3.11 -                                     SDL_Texture * texture, void **pixels,
    3.12 -                                     int *pitch);
    3.13 -static int SDL_SW_SetTexturePalette(SDL_Renderer * renderer,
    3.14 -                                    SDL_Texture * texture,
    3.15 -                                    const SDL_Color * colors, int firstcolor,
    3.16 -                                    int ncolors);
    3.17 -static int SDL_SW_GetTexturePalette(SDL_Renderer * renderer,
    3.18 -                                    SDL_Texture * texture, SDL_Color * colors,
    3.19 -                                    int firstcolor, int ncolors);
    3.20 -static int SDL_SW_UpdateTexture(SDL_Renderer * renderer,
    3.21 -                                SDL_Texture * texture, const SDL_Rect * rect,
    3.22 -                                const void *pixels, int pitch);
    3.23 -static int SDL_SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
    3.24 -                              const SDL_Rect * rect, int markDirty,
    3.25 -                              void **pixels, int *pitch);
    3.26 -static void SDL_SW_UnlockTexture(SDL_Renderer * renderer,
    3.27 -                                 SDL_Texture * texture);
    3.28 -static void SDL_SW_DirtyTexture(SDL_Renderer * renderer,
    3.29 -                                SDL_Texture * texture, int numrects,
    3.30 -                                const SDL_Rect * rects);
    3.31 -static int SDL_SW_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect,
    3.32 -                             Uint32 color);
    3.33 -static int SDL_SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
    3.34 -                             const SDL_Rect * srcrect,
    3.35 -                             const SDL_Rect * dstrect, int blendMode,
    3.36 -                             int scaleMode);
    3.37 -static void SDL_SW_RenderPresent(SDL_Renderer * renderer);
    3.38 -static void SDL_SW_DestroyTexture(SDL_Renderer * renderer,
    3.39 -                                  SDL_Texture * texture);
    3.40 -static void SDL_SW_DestroyRenderer(SDL_Renderer * renderer);
    3.41 +static SDL_Renderer *SW_CreateRenderer(SDL_Window * window, Uint32 flags);
    3.42 +static int SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
    3.43 +static int SW_QueryTexturePixels(SDL_Renderer * renderer,
    3.44 +                                 SDL_Texture * texture, void **pixels,
    3.45 +                                 int *pitch);
    3.46 +static int SW_SetTexturePalette(SDL_Renderer * renderer,
    3.47 +                                SDL_Texture * texture,
    3.48 +                                const SDL_Color * colors, int firstcolor,
    3.49 +                                int ncolors);
    3.50 +static int SW_GetTexturePalette(SDL_Renderer * renderer,
    3.51 +                                SDL_Texture * texture, SDL_Color * colors,
    3.52 +                                int firstcolor, int ncolors);
    3.53 +static int SW_UpdateTexture(SDL_Renderer * renderer,
    3.54 +                            SDL_Texture * texture, const SDL_Rect * rect,
    3.55 +                            const void *pixels, int pitch);
    3.56 +static int SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
    3.57 +                          const SDL_Rect * rect, int markDirty,
    3.58 +                          void **pixels, int *pitch);
    3.59 +static void SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
    3.60 +static void SW_DirtyTexture(SDL_Renderer * renderer,
    3.61 +                            SDL_Texture * texture, int numrects,
    3.62 +                            const SDL_Rect * rects);
    3.63 +static int SW_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect,
    3.64 +                         Uint32 color);
    3.65 +static int SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
    3.66 +                         const SDL_Rect * srcrect,
    3.67 +                         const SDL_Rect * dstrect, int blendMode,
    3.68 +                         int scaleMode);
    3.69 +static void SW_RenderPresent(SDL_Renderer * renderer);
    3.70 +static void SW_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture);
    3.71 +static void SW_DestroyRenderer(SDL_Renderer * renderer);
    3.72  
    3.73  
    3.74 -SDL_RenderDriver SDL_SW_RenderDriver = {
    3.75 -    SDL_SW_CreateRenderer,
    3.76 +SDL_RenderDriver SW_RenderDriver = {
    3.77 +    SW_CreateRenderer,
    3.78      {
    3.79       "software",
    3.80       (SDL_Renderer_SingleBuffer | SDL_Renderer_PresentCopy |
    3.81 @@ -101,7 +98,7 @@
    3.82      SDL_Surface surface;
    3.83      SDL_Renderer *renderer;
    3.84      SDL_DirtyRectList dirty;
    3.85 -} SDL_SW_RenderData;
    3.86 +} SW_RenderData;
    3.87  
    3.88  static SDL_Texture *
    3.89  CreateTexture(SDL_Renderer * renderer, Uint32 format, int w, int h)
    3.90 @@ -138,7 +135,7 @@
    3.91  static int
    3.92  DisplayPaletteChanged(void *userdata, SDL_Palette * palette)
    3.93  {
    3.94 -    SDL_SW_RenderData *data = (SDL_SW_RenderData *) userdata;
    3.95 +    SW_RenderData *data = (SW_RenderData *) userdata;
    3.96      int i;
    3.97  
    3.98      for (i = 0; i < SDL_arraysize(data->texture); ++i) {
    3.99 @@ -153,12 +150,12 @@
   3.100  }
   3.101  
   3.102  SDL_Renderer *
   3.103 -SDL_SW_CreateRenderer(SDL_Window * window, Uint32 flags)
   3.104 +SW_CreateRenderer(SDL_Window * window, Uint32 flags)
   3.105  {
   3.106      SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
   3.107      SDL_DisplayMode *displayMode = &display->current_mode;
   3.108      SDL_Renderer *renderer;
   3.109 -    SDL_SW_RenderData *data;
   3.110 +    SW_RenderData *data;
   3.111      int i, n;
   3.112      int bpp;
   3.113      Uint32 Rmask, Gmask, Bmask, Amask;
   3.114 @@ -176,28 +173,28 @@
   3.115          return NULL;
   3.116      }
   3.117  
   3.118 -    data = (SDL_SW_RenderData *) SDL_malloc(sizeof(*data));
   3.119 +    data = (SW_RenderData *) SDL_malloc(sizeof(*data));
   3.120      if (!data) {
   3.121 -        SDL_SW_DestroyRenderer(renderer);
   3.122 +        SW_DestroyRenderer(renderer);
   3.123          SDL_OutOfMemory();
   3.124          return NULL;
   3.125      }
   3.126      SDL_zerop(data);
   3.127  
   3.128 -    renderer->CreateTexture = SDL_SW_CreateTexture;
   3.129 -    renderer->QueryTexturePixels = SDL_SW_QueryTexturePixels;
   3.130 -    renderer->SetTexturePalette = SDL_SW_SetTexturePalette;
   3.131 -    renderer->GetTexturePalette = SDL_SW_GetTexturePalette;
   3.132 -    renderer->UpdateTexture = SDL_SW_UpdateTexture;
   3.133 -    renderer->LockTexture = SDL_SW_LockTexture;
   3.134 -    renderer->UnlockTexture = SDL_SW_UnlockTexture;
   3.135 -    renderer->DirtyTexture = SDL_SW_DirtyTexture;
   3.136 -    renderer->RenderFill = SDL_SW_RenderFill;
   3.137 -    renderer->RenderCopy = SDL_SW_RenderCopy;
   3.138 -    renderer->RenderPresent = SDL_SW_RenderPresent;
   3.139 -    renderer->DestroyTexture = SDL_SW_DestroyTexture;
   3.140 -    renderer->DestroyRenderer = SDL_SW_DestroyRenderer;
   3.141 -    renderer->info = SDL_SW_RenderDriver.info;
   3.142 +    renderer->CreateTexture = SW_CreateTexture;
   3.143 +    renderer->QueryTexturePixels = SW_QueryTexturePixels;
   3.144 +    renderer->SetTexturePalette = SW_SetTexturePalette;
   3.145 +    renderer->GetTexturePalette = SW_GetTexturePalette;
   3.146 +    renderer->UpdateTexture = SW_UpdateTexture;
   3.147 +    renderer->LockTexture = SW_LockTexture;
   3.148 +    renderer->UnlockTexture = SW_UnlockTexture;
   3.149 +    renderer->DirtyTexture = SW_DirtyTexture;
   3.150 +    renderer->RenderFill = SW_RenderFill;
   3.151 +    renderer->RenderCopy = SW_RenderCopy;
   3.152 +    renderer->RenderPresent = SW_RenderPresent;
   3.153 +    renderer->DestroyTexture = SW_DestroyTexture;
   3.154 +    renderer->DestroyRenderer = SW_DestroyRenderer;
   3.155 +    renderer->info = SW_RenderDriver.info;
   3.156      renderer->window = window->id;
   3.157      renderer->driverdata = data;
   3.158  
   3.159 @@ -223,7 +220,7 @@
   3.160      }
   3.161      for (i = 0; i < display->num_render_drivers; ++i) {
   3.162          SDL_RenderDriver *driver = &display->render_drivers[i];
   3.163 -        if (driver->info.name != SDL_SW_RenderDriver.info.name) {
   3.164 +        if (driver->info.name != SW_RenderDriver.info.name) {
   3.165              data->renderer = driver->CreateRenderer(window, renderer_flags);
   3.166              if (data->renderer) {
   3.167                  break;
   3.168 @@ -231,7 +228,7 @@
   3.169          }
   3.170      }
   3.171      if (i == display->num_render_drivers) {
   3.172 -        SDL_SW_DestroyRenderer(renderer);
   3.173 +        SW_DestroyRenderer(renderer);
   3.174          SDL_SetError("Couldn't find display render driver");
   3.175          return NULL;
   3.176      }
   3.177 @@ -244,7 +241,7 @@
   3.178          data->texture[i] =
   3.179              CreateTexture(data->renderer, data->format, window->w, window->h);
   3.180          if (!data->texture[i]) {
   3.181 -            SDL_SW_DestroyRenderer(renderer);
   3.182 +            SW_DestroyRenderer(renderer);
   3.183              return NULL;
   3.184          }
   3.185      }
   3.186 @@ -254,7 +251,7 @@
   3.187      data->surface.flags = SDL_PREALLOC;
   3.188      data->surface.format = SDL_AllocFormat(bpp, Rmask, Gmask, Bmask, Amask);
   3.189      if (!data->surface.format) {
   3.190 -        SDL_SW_DestroyRenderer(renderer);
   3.191 +        SW_DestroyRenderer(renderer);
   3.192          return NULL;
   3.193      }
   3.194      SDL_SetSurfacePalette(&data->surface, display->palette);
   3.195 @@ -268,7 +265,7 @@
   3.196  }
   3.197  
   3.198  static int
   3.199 -SDL_SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
   3.200 +SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
   3.201  {
   3.202      if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
   3.203          texture->driverdata = SDL_SW_CreateYUVTexture(texture);
   3.204 @@ -294,8 +291,8 @@
   3.205  }
   3.206  
   3.207  static int
   3.208 -SDL_SW_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
   3.209 -                          void **pixels, int *pitch)
   3.210 +SW_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
   3.211 +                      void **pixels, int *pitch)
   3.212  {
   3.213      if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
   3.214          return SDL_SW_QueryYUVTexturePixels((SDL_SW_YUVTexture *) texture->
   3.215 @@ -310,9 +307,8 @@
   3.216  }
   3.217  
   3.218  static int
   3.219 -SDL_SW_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
   3.220 -                         const SDL_Color * colors, int firstcolor,
   3.221 -                         int ncolors)
   3.222 +SW_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
   3.223 +                     const SDL_Color * colors, int firstcolor, int ncolors)
   3.224  {
   3.225      if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
   3.226          SDL_SetError("YUV textures don't have a palette");
   3.227 @@ -326,8 +322,8 @@
   3.228  }
   3.229  
   3.230  static int
   3.231 -SDL_SW_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
   3.232 -                         SDL_Color * colors, int firstcolor, int ncolors)
   3.233 +SW_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
   3.234 +                     SDL_Color * colors, int firstcolor, int ncolors)
   3.235  {
   3.236      if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
   3.237          SDL_SetError("YUV textures don't have a palette");
   3.238 @@ -342,8 +338,8 @@
   3.239  }
   3.240  
   3.241  static int
   3.242 -SDL_SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
   3.243 -                     const SDL_Rect * rect, const void *pixels, int pitch)
   3.244 +SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
   3.245 +                 const SDL_Rect * rect, const void *pixels, int pitch)
   3.246  {
   3.247      if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
   3.248          return SDL_SW_UpdateYUVTexture((SDL_SW_YUVTexture *) texture->
   3.249 @@ -369,9 +365,9 @@
   3.250  }
   3.251  
   3.252  static int
   3.253 -SDL_SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
   3.254 -                   const SDL_Rect * rect, int markDirty, void **pixels,
   3.255 -                   int *pitch)
   3.256 +SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
   3.257 +               const SDL_Rect * rect, int markDirty, void **pixels,
   3.258 +               int *pitch)
   3.259  {
   3.260      if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
   3.261          return SDL_SW_LockYUVTexture((SDL_SW_YUVTexture *) texture->
   3.262 @@ -389,7 +385,7 @@
   3.263  }
   3.264  
   3.265  static void
   3.266 -SDL_SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
   3.267 +SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
   3.268  {
   3.269      if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
   3.270          SDL_SW_UnlockYUVTexture((SDL_SW_YUVTexture *) texture->driverdata);
   3.271 @@ -397,16 +393,15 @@
   3.272  }
   3.273  
   3.274  static void
   3.275 -SDL_SW_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
   3.276 -                    int numrects, const SDL_Rect * rects)
   3.277 +SW_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
   3.278 +                int numrects, const SDL_Rect * rects)
   3.279  {
   3.280  }
   3.281  
   3.282  static int
   3.283 -SDL_SW_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect,
   3.284 -                  Uint32 color)
   3.285 +SW_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect, Uint32 color)
   3.286  {
   3.287 -    SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata;
   3.288 +    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
   3.289      Uint8 r, g, b, a;
   3.290      void *pixels;
   3.291      int pitch;
   3.292 @@ -443,11 +438,11 @@
   3.293  }
   3.294  
   3.295  static int
   3.296 -SDL_SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
   3.297 -                  const SDL_Rect * srcrect, const SDL_Rect * dstrect,
   3.298 -                  int blendMode, int scaleMode)
   3.299 +SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
   3.300 +              const SDL_Rect * srcrect, const SDL_Rect * dstrect,
   3.301 +              int blendMode, int scaleMode)
   3.302  {
   3.303 -    SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata;
   3.304 +    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
   3.305      SDL_Window *window = SDL_GetWindowFromID(renderer->window);
   3.306      int status;
   3.307  
   3.308 @@ -501,9 +496,9 @@
   3.309  }
   3.310  
   3.311  static void
   3.312 -SDL_SW_RenderPresent(SDL_Renderer * renderer)
   3.313 +SW_RenderPresent(SDL_Renderer * renderer)
   3.314  {
   3.315 -    SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata;
   3.316 +    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
   3.317      SDL_Texture *texture = data->texture[data->current_texture];
   3.318  
   3.319      /* Send the data to the display */
   3.320 @@ -537,7 +532,7 @@
   3.321  }
   3.322  
   3.323  static void
   3.324 -SDL_SW_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
   3.325 +SW_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
   3.326  {
   3.327      if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
   3.328          SDL_SW_DestroyYUVTexture((SDL_SW_YUVTexture *) texture->driverdata);
   3.329 @@ -549,9 +544,9 @@
   3.330  }
   3.331  
   3.332  static void
   3.333 -SDL_SW_DestroyRenderer(SDL_Renderer * renderer)
   3.334 +SW_DestroyRenderer(SDL_Renderer * renderer)
   3.335  {
   3.336 -    SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata;
   3.337 +    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
   3.338      SDL_Window *window = SDL_GetWindowFromID(renderer->window);
   3.339      SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
   3.340      int i;
     4.1 --- a/src/video/SDL_renderer_sw.h	Wed Jul 19 05:45:42 2006 +0000
     4.2 +++ b/src/video/SDL_renderer_sw.h	Wed Jul 19 07:18:45 2006 +0000
     4.3 @@ -23,6 +23,6 @@
     4.4  
     4.5  /* SDL surface based renderer implementation */
     4.6  
     4.7 -extern SDL_RenderDriver SDL_SW_RenderDriver;
     4.8 +extern SDL_RenderDriver SW_RenderDriver;
     4.9  
    4.10  /* vi: set ts=4 sw=4 expandtab: */
     5.1 --- a/src/video/SDL_video.c	Wed Jul 19 05:45:42 2006 +0000
     5.2 +++ b/src/video/SDL_video.c	Wed Jul 19 07:18:45 2006 +0000
     5.3 @@ -27,6 +27,7 @@
     5.4  #include "SDL_sysvideo.h"
     5.5  #include "SDL_blit.h"
     5.6  #include "SDL_pixels_c.h"
     5.7 +#include "SDL_renderer_gl.h"
     5.8  #include "SDL_renderer_sw.h"
     5.9  #include "../events/SDL_sysevents.h"
    5.10  #include "../events/SDL_events_c.h"
    5.11 @@ -279,7 +280,10 @@
    5.12      /* The software renderer is always available */
    5.13      for (i = 0; i < _this->num_displays; ++i) {
    5.14          if (_this->displays[i].num_render_drivers > 0) {
    5.15 -            SDL_AddRenderDriver(i, &SDL_SW_RenderDriver);
    5.16 +#if SDL_VIDEO_OPENGL
    5.17 +            SDL_AddRenderDriver(i, &GL_RenderDriver);
    5.18 +#endif
    5.19 +            SDL_AddRenderDriver(i, &SW_RenderDriver);
    5.20          }
    5.21      }
    5.22  
     6.1 --- a/src/video/win32/SDL_d3drender.c	Wed Jul 19 05:45:42 2006 +0000
     6.2 +++ b/src/video/win32/SDL_d3drender.c	Wed Jul 19 07:18:45 2006 +0000
     6.3 @@ -62,9 +62,13 @@
     6.4       "d3d",
     6.5       (SDL_Renderer_SingleBuffer | SDL_Renderer_PresentCopy |
     6.6        SDL_Renderer_PresentFlip2 | SDL_Renderer_PresentFlip3 |
     6.7 -      SDL_Renderer_PresentDiscard | SDL_Renderer_PresentVSync),
     6.8 -     (SDL_TextureBlendMode_None | SDL_TextureBlendMode_Mask | SDL_TextureBlendMode_Blend),      /* FIXME */
     6.9 -     (SDL_TextureScaleMode_None | SDL_TextureScaleMode_Fast),   /* FIXME */
    6.10 +      SDL_Renderer_PresentDiscard | SDL_Renderer_PresentVSync |
    6.11 +      SDL_Renderer_Accelerated),
    6.12 +     (SDL_TextureBlendMode_None | SDL_TextureBlendMode_Mask |
    6.13 +      SDL_TextureBlendMode_Blend | SDL_TextureBlendMode_Add |
    6.14 +      SDL_TextureBlendMode_Mod),
    6.15 +     (SDL_TextureScaleMode_None | SDL_TextureScaleMode_Fast |
    6.16 +      SDL_TextureScaleMode_Best),
    6.17       12,
    6.18       {
    6.19        SDL_PixelFormat_Index8,
    6.20 @@ -353,6 +357,8 @@
    6.21          renderer->info.flags |= SDL_Renderer_PresentVSync;
    6.22      }
    6.23  
    6.24 +    /* FIXME: Query maximum texture size */
    6.25 +
    6.26      /* Set up parameters for rendering */
    6.27      IDirect3DDevice9_SetVertexShader(data->device, NULL);
    6.28      IDirect3DDevice9_SetFVF(data->device, D3DFVF_XYZRHW | D3DFVF_TEX1);
     7.1 --- a/src/video/win32/SDL_gdirender.c	Wed Jul 19 05:45:42 2006 +0000
     7.2 +++ b/src/video/win32/SDL_gdirender.c	Wed Jul 19 07:18:45 2006 +0000
     7.3 @@ -67,7 +67,7 @@
     7.4       "gdi",
     7.5       (SDL_Renderer_SingleBuffer | SDL_Renderer_PresentCopy |
     7.6        SDL_Renderer_PresentFlip2 | SDL_Renderer_PresentFlip3 |
     7.7 -      SDL_Renderer_PresentDiscard),
     7.8 +      SDL_Renderer_PresentDiscard | SDL_Renderer_Accelerated),
     7.9       (SDL_TextureBlendMode_None | SDL_TextureBlendMode_Mask |
    7.10        SDL_TextureBlendMode_Blend),
    7.11       (SDL_TextureScaleMode_None | SDL_TextureScaleMode_Fast),