src/video/win32/SDL_d3drender.c
author Bob Pendleton <bob@pendleton.com>
Fri, 09 Jan 2009 20:43:30 +0000
changeset 3011 8f4ed5ec2b06
parent 2990 502adab079a4
child 3013 8cc00819c8d6
permissions -rw-r--r--
I ran a global "make indent" it modified the following files.
slouken@1895
     1
/*
slouken@1895
     2
    SDL - Simple DirectMedia Layer
slouken@2859
     3
    Copyright (C) 1997-2009 Sam Lantinga
slouken@1895
     4
slouken@1895
     5
    This library is free software; you can redistribute it and/or
slouken@1895
     6
    modify it under the terms of the GNU Lesser General Public
slouken@1895
     7
    License as published by the Free Software Foundation; either
slouken@1895
     8
    version 2.1 of the License, or (at your option) any later version.
slouken@1895
     9
slouken@1895
    10
    This library is distributed in the hope that it will be useful,
slouken@1895
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@1895
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@1895
    13
    Lesser General Public License for more details.
slouken@1895
    14
slouken@1895
    15
    You should have received a copy of the GNU Lesser General Public
slouken@1895
    16
    License along with this library; if not, write to the Free Software
slouken@1895
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@1895
    18
slouken@1895
    19
    Sam Lantinga
slouken@1895
    20
    slouken@libsdl.org
slouken@1895
    21
*/
slouken@1895
    22
#include "SDL_config.h"
slouken@1895
    23
slouken@1895
    24
#if SDL_VIDEO_RENDER_D3D
slouken@1895
    25
slouken@1895
    26
#include "SDL_win32video.h"
slouken@2973
    27
#include "../SDL_yuv_sw_c.h"
slouken@1895
    28
slouken@1895
    29
/* Direct3D renderer implementation */
slouken@1895
    30
slouken@2786
    31
#if 1                           /* This takes more memory but you won't lose your texture data */
slouken@2932
    32
#define D3DPOOL_SDL    D3DPOOL_MANAGED
slouken@2783
    33
#define SDL_MEMORY_POOL_MANAGED
slouken@2783
    34
#else
slouken@2932
    35
#define D3DPOOL_SDL    D3DPOOL_DEFAULT
slouken@2783
    36
#define SDL_MEMORY_POOL_DEFAULT
slouken@2783
    37
#endif
slouken@2783
    38
slouken@1913
    39
static SDL_Renderer *D3D_CreateRenderer(SDL_Window * window, Uint32 flags);
slouken@1975
    40
static int D3D_DisplayModeChanged(SDL_Renderer * renderer);
slouken@1913
    41
static int D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
slouken@2990
    42
static int D3D_QueryTexturePixels(SDL_Renderer * renderer,
slouken@2990
    43
                                  SDL_Texture * texture, void **pixels,
slouken@2990
    44
                                  int *pitch);
slouken@1913
    45
static int D3D_SetTexturePalette(SDL_Renderer * renderer,
slouken@1913
    46
                                 SDL_Texture * texture,
slouken@1913
    47
                                 const SDL_Color * colors, int firstcolor,
slouken@1913
    48
                                 int ncolors);
slouken@1913
    49
static int D3D_GetTexturePalette(SDL_Renderer * renderer,
slouken@1913
    50
                                 SDL_Texture * texture, SDL_Color * colors,
slouken@1913
    51
                                 int firstcolor, int ncolors);
slouken@1985
    52
static int D3D_SetTextureColorMod(SDL_Renderer * renderer,
slouken@1985
    53
                                  SDL_Texture * texture);
slouken@1985
    54
static int D3D_SetTextureAlphaMod(SDL_Renderer * renderer,
slouken@1985
    55
                                  SDL_Texture * texture);
slouken@1985
    56
static int D3D_SetTextureBlendMode(SDL_Renderer * renderer,
slouken@1985
    57
                                   SDL_Texture * texture);
slouken@1985
    58
static int D3D_SetTextureScaleMode(SDL_Renderer * renderer,
slouken@1985
    59
                                   SDL_Texture * texture);
slouken@1913
    60
static int D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
slouken@1913
    61
                             const SDL_Rect * rect, const void *pixels,
slouken@1913
    62
                             int pitch);
slouken@1913
    63
static int D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
slouken@1913
    64
                           const SDL_Rect * rect, int markDirty,
slouken@1913
    65
                           void **pixels, int *pitch);
slouken@1913
    66
static void D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
slouken@1913
    67
static void D3D_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
slouken@1913
    68
                             int numrects, const SDL_Rect * rects);
slouken@2932
    69
static int D3D_RenderPoint(SDL_Renderer * renderer, int x, int y);
slouken@2932
    70
static int D3D_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2,
slouken@2932
    71
                          int y2);
slouken@2919
    72
static int D3D_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect);
slouken@1913
    73
static int D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
slouken@1985
    74
                          const SDL_Rect * srcrect, const SDL_Rect * dstrect);
slouken@1913
    75
static void D3D_RenderPresent(SDL_Renderer * renderer);
slouken@1913
    76
static void D3D_DestroyTexture(SDL_Renderer * renderer,
slouken@1913
    77
                               SDL_Texture * texture);
slouken@1913
    78
static void D3D_DestroyRenderer(SDL_Renderer * renderer);
slouken@1895
    79
slouken@1895
    80
slouken@1913
    81
SDL_RenderDriver D3D_RenderDriver = {
slouken@1913
    82
    D3D_CreateRenderer,
slouken@1895
    83
    {
slouken@1895
    84
     "d3d",
slouken@1965
    85
     (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY |
slouken@1975
    86
      SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
slouken@1965
    87
      SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_PRESENTVSYNC |
slouken@1965
    88
      SDL_RENDERER_ACCELERATED),
slouken@1985
    89
     (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR |
slouken@1985
    90
      SDL_TEXTUREMODULATE_ALPHA),
slouken@2884
    91
     (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK |
slouken@2884
    92
      SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD),
slouken@1965
    93
     (SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_FAST |
slouken@1965
    94
      SDL_TEXTURESCALEMODE_SLOW | SDL_TEXTURESCALEMODE_BEST),
slouken@2972
    95
     0,
slouken@2972
    96
     {0},
slouken@1895
    97
     0,
slouken@1895
    98
     0}
slouken@1895
    99
};
slouken@1895
   100
slouken@1895
   101
typedef struct
slouken@1895
   102
{
slouken@2973
   103
    IDirect3D9 *d3d;
slouken@1895
   104
    IDirect3DDevice9 *device;
slouken@1975
   105
    D3DPRESENT_PARAMETERS pparams;
slouken@1900
   106
    SDL_bool beginScene;
slouken@1913
   107
} D3D_RenderData;
slouken@1895
   108
slouken@1895
   109
typedef struct
slouken@1895
   110
{
slouken@2973
   111
    SDL_SW_YUVTexture *yuv;
slouken@2973
   112
    Uint32 format;
slouken@1903
   113
    IDirect3DTexture9 *texture;
slouken@1913
   114
} D3D_TextureData;
slouken@1895
   115
slouken@1903
   116
typedef struct
slouken@1903
   117
{
slouken@1903
   118
    float x, y, z;
slouken@1904
   119
    float rhw;
slouken@1987
   120
    DWORD color;
slouken@1904
   121
    float u, v;
slouken@1903
   122
} Vertex;
slouken@1903
   123
slouken@1895
   124
static void
slouken@1900
   125
D3D_SetError(const char *prefix, HRESULT result)
slouken@1900
   126
{
slouken@1900
   127
    const char *error;
slouken@1900
   128
slouken@1900
   129
    switch (result) {
slouken@1900
   130
    case D3DERR_WRONGTEXTUREFORMAT:
slouken@1900
   131
        error = "WRONGTEXTUREFORMAT";
slouken@1900
   132
        break;
slouken@1900
   133
    case D3DERR_UNSUPPORTEDCOLOROPERATION:
slouken@1900
   134
        error = "UNSUPPORTEDCOLOROPERATION";
slouken@1900
   135
        break;
slouken@1900
   136
    case D3DERR_UNSUPPORTEDCOLORARG:
slouken@1900
   137
        error = "UNSUPPORTEDCOLORARG";
slouken@1900
   138
        break;
slouken@1900
   139
    case D3DERR_UNSUPPORTEDALPHAOPERATION:
slouken@1900
   140
        error = "UNSUPPORTEDALPHAOPERATION";
slouken@1900
   141
        break;
slouken@1900
   142
    case D3DERR_UNSUPPORTEDALPHAARG:
slouken@1900
   143
        error = "UNSUPPORTEDALPHAARG";
slouken@1900
   144
        break;
slouken@1900
   145
    case D3DERR_TOOMANYOPERATIONS:
slouken@1900
   146
        error = "TOOMANYOPERATIONS";
slouken@1900
   147
        break;
slouken@1900
   148
    case D3DERR_CONFLICTINGTEXTUREFILTER:
slouken@1900
   149
        error = "CONFLICTINGTEXTUREFILTER";
slouken@1900
   150
        break;
slouken@1900
   151
    case D3DERR_UNSUPPORTEDFACTORVALUE:
slouken@1900
   152
        error = "UNSUPPORTEDFACTORVALUE";
slouken@1900
   153
        break;
slouken@1900
   154
    case D3DERR_CONFLICTINGRENDERSTATE:
slouken@1900
   155
        error = "CONFLICTINGRENDERSTATE";
slouken@1900
   156
        break;
slouken@1900
   157
    case D3DERR_UNSUPPORTEDTEXTUREFILTER:
slouken@1900
   158
        error = "UNSUPPORTEDTEXTUREFILTER";
slouken@1900
   159
        break;
slouken@1900
   160
    case D3DERR_CONFLICTINGTEXTUREPALETTE:
slouken@1900
   161
        error = "CONFLICTINGTEXTUREPALETTE";
slouken@1900
   162
        break;
slouken@1900
   163
    case D3DERR_DRIVERINTERNALERROR:
slouken@1900
   164
        error = "DRIVERINTERNALERROR";
slouken@1900
   165
        break;
slouken@1900
   166
    case D3DERR_NOTFOUND:
slouken@1900
   167
        error = "NOTFOUND";
slouken@1900
   168
        break;
slouken@1900
   169
    case D3DERR_MOREDATA:
slouken@1900
   170
        error = "MOREDATA";
slouken@1900
   171
        break;
slouken@1900
   172
    case D3DERR_DEVICELOST:
slouken@1900
   173
        error = "DEVICELOST";
slouken@1900
   174
        break;
slouken@1900
   175
    case D3DERR_DEVICENOTRESET:
slouken@1900
   176
        error = "DEVICENOTRESET";
slouken@1900
   177
        break;
slouken@1900
   178
    case D3DERR_NOTAVAILABLE:
slouken@1900
   179
        error = "NOTAVAILABLE";
slouken@1900
   180
        break;
slouken@1900
   181
    case D3DERR_OUTOFVIDEOMEMORY:
slouken@1900
   182
        error = "OUTOFVIDEOMEMORY";
slouken@1900
   183
        break;
slouken@1900
   184
    case D3DERR_INVALIDDEVICE:
slouken@1900
   185
        error = "INVALIDDEVICE";
slouken@1900
   186
        break;
slouken@1900
   187
    case D3DERR_INVALIDCALL:
slouken@1900
   188
        error = "INVALIDCALL";
slouken@1900
   189
        break;
slouken@1900
   190
    case D3DERR_DRIVERINVALIDCALL:
slouken@1900
   191
        error = "DRIVERINVALIDCALL";
slouken@1900
   192
        break;
slouken@1900
   193
    case D3DERR_WASSTILLDRAWING:
slouken@1900
   194
        error = "WASSTILLDRAWING";
slouken@1900
   195
        break;
slouken@1900
   196
    default:
slouken@1900
   197
        error = "UNKNOWN";
slouken@1900
   198
        break;
slouken@1900
   199
    }
slouken@1900
   200
    SDL_SetError("%s: %s", prefix, error);
slouken@1900
   201
}
slouken@1900
   202
slouken@1903
   203
static D3DFORMAT
slouken@1903
   204
PixelFormatToD3DFMT(Uint32 format)
slouken@1895
   205
{
slouken@1903
   206
    switch (format) {
slouken@1965
   207
    case SDL_PIXELFORMAT_INDEX8:
slouken@1903
   208
        return D3DFMT_P8;
slouken@1965
   209
    case SDL_PIXELFORMAT_RGB332:
slouken@1903
   210
        return D3DFMT_R3G3B2;
slouken@1965
   211
    case SDL_PIXELFORMAT_RGB444:
slouken@1903
   212
        return D3DFMT_X4R4G4B4;
slouken@1965
   213
    case SDL_PIXELFORMAT_RGB555:
slouken@1903
   214
        return D3DFMT_X1R5G5B5;
slouken@1965
   215
    case SDL_PIXELFORMAT_ARGB4444:
slouken@1903
   216
        return D3DFMT_A4R4G4B4;
slouken@1965
   217
    case SDL_PIXELFORMAT_ARGB1555:
slouken@1903
   218
        return D3DFMT_A1R5G5B5;
slouken@1965
   219
    case SDL_PIXELFORMAT_RGB565:
slouken@1903
   220
        return D3DFMT_R5G6B5;
slouken@1965
   221
    case SDL_PIXELFORMAT_RGB888:
slouken@1903
   222
        return D3DFMT_X8R8G8B8;
slouken@1965
   223
    case SDL_PIXELFORMAT_ARGB8888:
slouken@1903
   224
        return D3DFMT_A8R8G8B8;
slouken@1965
   225
    case SDL_PIXELFORMAT_ARGB2101010:
slouken@1903
   226
        return D3DFMT_A2R10G10B10;
slouken@1965
   227
    case SDL_PIXELFORMAT_UYVY:
slouken@1903
   228
        return D3DFMT_UYVY;
slouken@1965
   229
    case SDL_PIXELFORMAT_YUY2:
slouken@1903
   230
        return D3DFMT_YUY2;
slouken@1903
   231
    default:
slouken@1903
   232
        return D3DFMT_UNKNOWN;
slouken@1903
   233
    }
slouken@1895
   234
}
slouken@1895
   235
slouken@2973
   236
static SDL_bool
slouken@2990
   237
D3D_IsTextureFormatAvailable(IDirect3D9 * d3d, Uint32 display_format,
slouken@2990
   238
                             Uint32 texture_format)
slouken@2973
   239
{
slouken@2973
   240
    HRESULT result;
slouken@2973
   241
slouken@2990
   242
    result = IDirect3D9_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT,      /* FIXME */
slouken@2973
   243
                                          D3DDEVTYPE_HAL,
slouken@2973
   244
                                          PixelFormatToD3DFMT(display_format),
slouken@2973
   245
                                          0,
slouken@2973
   246
                                          D3DRTYPE_TEXTURE,
slouken@2990
   247
                                          PixelFormatToD3DFMT
slouken@2990
   248
                                          (texture_format));
slouken@2973
   249
    return FAILED(result) ? SDL_FALSE : SDL_TRUE;
slouken@2973
   250
}
slouken@2973
   251
slouken@2973
   252
static void
slouken@2973
   253
UpdateYUVTextureData(SDL_Texture * texture)
slouken@2973
   254
{
slouken@2973
   255
    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
slouken@2973
   256
    SDL_Rect rect;
slouken@2973
   257
    RECT d3drect;
slouken@2973
   258
    D3DLOCKED_RECT locked;
slouken@2973
   259
    HRESULT result;
slouken@2973
   260
slouken@2973
   261
    d3drect.left = 0;
slouken@2973
   262
    d3drect.right = texture->w;
slouken@2973
   263
    d3drect.top = 0;
slouken@2973
   264
    d3drect.bottom = texture->h;
slouken@2973
   265
slouken@2990
   266
    result =
slouken@2990
   267
        IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect, 0);
slouken@2973
   268
    if (FAILED(result)) {
slouken@2973
   269
        return;
slouken@2973
   270
    }
slouken@2973
   271
slouken@2973
   272
    rect.x = 0;
slouken@2973
   273
    rect.y = 0;
slouken@2973
   274
    rect.w = texture->w;
slouken@2973
   275
    rect.h = texture->h;
slouken@2973
   276
    SDL_SW_CopyYUVToRGB(data->yuv, &rect, data->format, texture->w,
slouken@2973
   277
                        texture->h, locked.pBits, locked.Pitch);
slouken@2973
   278
slouken@2973
   279
    IDirect3DTexture9_UnlockRect(data->texture, 0);
slouken@2973
   280
}
slouken@2973
   281
slouken@1895
   282
void
slouken@1895
   283
D3D_AddRenderDriver(_THIS)
slouken@1895
   284
{
slouken@1895
   285
    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
slouken@2972
   286
    SDL_RendererInfo *info = &D3D_RenderDriver.info;
slouken@2972
   287
    SDL_DisplayMode *mode = &SDL_CurrentDisplay.desktop_mode;
slouken@1895
   288
slouken@1895
   289
    if (data->d3d) {
slouken@2972
   290
        int i;
slouken@2972
   291
        int formats[] = {
slouken@2990
   292
            SDL_PIXELFORMAT_INDEX8,
slouken@2990
   293
            SDL_PIXELFORMAT_RGB332,
slouken@2990
   294
            SDL_PIXELFORMAT_RGB444,
slouken@2990
   295
            SDL_PIXELFORMAT_RGB555,
slouken@2990
   296
            SDL_PIXELFORMAT_ARGB4444,
slouken@2990
   297
            SDL_PIXELFORMAT_ARGB1555,
slouken@2990
   298
            SDL_PIXELFORMAT_RGB565,
slouken@2990
   299
            SDL_PIXELFORMAT_RGB888,
slouken@2990
   300
            SDL_PIXELFORMAT_ARGB8888,
slouken@2990
   301
            SDL_PIXELFORMAT_ARGB2101010,
slouken@2972
   302
        };
slouken@2972
   303
slouken@2972
   304
        for (i = 0; i < SDL_arraysize(formats); ++i) {
slouken@2990
   305
            if (D3D_IsTextureFormatAvailable
slouken@2990
   306
                (data->d3d, mode->format, formats[i])) {
slouken@2990
   307
                info->texture_formats[info->num_texture_formats++] =
slouken@2990
   308
                    formats[i];
slouken@2972
   309
            }
slouken@2972
   310
        }
slouken@2990
   311
        info->texture_formats[info->num_texture_formats++] =
slouken@2990
   312
            SDL_PIXELFORMAT_YV12;
slouken@2990
   313
        info->texture_formats[info->num_texture_formats++] =
slouken@2990
   314
            SDL_PIXELFORMAT_IYUV;
slouken@2990
   315
        info->texture_formats[info->num_texture_formats++] =
slouken@2990
   316
            SDL_PIXELFORMAT_YUY2;
slouken@2990
   317
        info->texture_formats[info->num_texture_formats++] =
slouken@2990
   318
            SDL_PIXELFORMAT_UYVY;
slouken@2990
   319
        info->texture_formats[info->num_texture_formats++] =
slouken@2990
   320
            SDL_PIXELFORMAT_YVYU;
slouken@2972
   321
slouken@1913
   322
        SDL_AddRenderDriver(0, &D3D_RenderDriver);
slouken@1895
   323
    }
slouken@1895
   324
}
slouken@1895
   325
slouken@1895
   326
SDL_Renderer *
slouken@1913
   327
D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
slouken@1895
   328
{
slouken@1895
   329
    SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
slouken@1895
   330
    SDL_VideoData *videodata = (SDL_VideoData *) display->device->driverdata;
slouken@1895
   331
    SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata;
slouken@1895
   332
    SDL_Renderer *renderer;
slouken@1913
   333
    D3D_RenderData *data;
slouken@1900
   334
    HRESULT result;
slouken@1900
   335
    D3DPRESENT_PARAMETERS pparams;
slouken@1907
   336
    IDirect3DSwapChain9 *chain;
slouken@1925
   337
    D3DCAPS9 caps;
slouken@1895
   338
slouken@1920
   339
    renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
slouken@1895
   340
    if (!renderer) {
slouken@1895
   341
        SDL_OutOfMemory();
slouken@1895
   342
        return NULL;
slouken@1895
   343
    }
slouken@1895
   344
slouken@1920
   345
    data = (D3D_RenderData *) SDL_calloc(1, sizeof(*data));
slouken@1895
   346
    if (!data) {
slouken@1913
   347
        D3D_DestroyRenderer(renderer);
slouken@1895
   348
        SDL_OutOfMemory();
slouken@1895
   349
        return NULL;
slouken@1895
   350
    }
slouken@2973
   351
    data->d3d = videodata->d3d;
slouken@1895
   352
slouken@1975
   353
    renderer->DisplayModeChanged = D3D_DisplayModeChanged;
slouken@1913
   354
    renderer->CreateTexture = D3D_CreateTexture;
slouken@2973
   355
    renderer->QueryTexturePixels = D3D_QueryTexturePixels;
slouken@1913
   356
    renderer->SetTexturePalette = D3D_SetTexturePalette;
slouken@1913
   357
    renderer->GetTexturePalette = D3D_GetTexturePalette;
slouken@1985
   358
    renderer->SetTextureColorMod = D3D_SetTextureColorMod;
slouken@1985
   359
    renderer->SetTextureAlphaMod = D3D_SetTextureAlphaMod;
slouken@1985
   360
    renderer->SetTextureBlendMode = D3D_SetTextureBlendMode;
slouken@1985
   361
    renderer->SetTextureScaleMode = D3D_SetTextureScaleMode;
slouken@1913
   362
    renderer->UpdateTexture = D3D_UpdateTexture;
slouken@1913
   363
    renderer->LockTexture = D3D_LockTexture;
slouken@1913
   364
    renderer->UnlockTexture = D3D_UnlockTexture;
slouken@1913
   365
    renderer->DirtyTexture = D3D_DirtyTexture;
slouken@2932
   366
    renderer->RenderPoint = D3D_RenderPoint;
slouken@2932
   367
    renderer->RenderLine = D3D_RenderLine;
slouken@1913
   368
    renderer->RenderFill = D3D_RenderFill;
slouken@1913
   369
    renderer->RenderCopy = D3D_RenderCopy;
slouken@1913
   370
    renderer->RenderPresent = D3D_RenderPresent;
slouken@1913
   371
    renderer->DestroyTexture = D3D_DestroyTexture;
slouken@1913
   372
    renderer->DestroyRenderer = D3D_DestroyRenderer;
slouken@1913
   373
    renderer->info = D3D_RenderDriver.info;
slouken@1895
   374
    renderer->window = window->id;
slouken@1895
   375
    renderer->driverdata = data;
slouken@1895
   376
slouken@1965
   377
    renderer->info.flags = SDL_RENDERER_ACCELERATED;
slouken@1895
   378
slouken@1900
   379
    SDL_zero(pparams);
slouken@1900
   380
    pparams.BackBufferWidth = window->w;
slouken@1900
   381
    pparams.BackBufferHeight = window->h;
slouken@1903
   382
    if (window->flags & SDL_WINDOW_FULLSCREEN) {
slouken@1903
   383
        pparams.BackBufferFormat =
slouken@1975
   384
            PixelFormatToD3DFMT(display->fullscreen_mode.format);
slouken@1903
   385
    } else {
slouken@1903
   386
        pparams.BackBufferFormat = D3DFMT_UNKNOWN;
slouken@1903
   387
    }
slouken@1965
   388
    if (flags & SDL_RENDERER_PRESENTFLIP2) {
slouken@1900
   389
        pparams.BackBufferCount = 2;
slouken@1900
   390
        pparams.SwapEffect = D3DSWAPEFFECT_FLIP;
slouken@1965
   391
    } else if (flags & SDL_RENDERER_PRESENTFLIP3) {
slouken@1900
   392
        pparams.BackBufferCount = 3;
slouken@1900
   393
        pparams.SwapEffect = D3DSWAPEFFECT_FLIP;
slouken@1965
   394
    } else if (flags & SDL_RENDERER_PRESENTCOPY) {
slouken@1900
   395
        pparams.BackBufferCount = 1;
slouken@1900
   396
        pparams.SwapEffect = D3DSWAPEFFECT_COPY;
slouken@1900
   397
    } else {
slouken@1900
   398
        pparams.BackBufferCount = 1;
slouken@1900
   399
        pparams.SwapEffect = D3DSWAPEFFECT_DISCARD;
slouken@1900
   400
    }
slouken@1900
   401
    if (window->flags & SDL_WINDOW_FULLSCREEN) {
slouken@1900
   402
        pparams.Windowed = FALSE;
slouken@1903
   403
        pparams.FullScreen_RefreshRateInHz =
slouken@1975
   404
            display->fullscreen_mode.refresh_rate;
slouken@1900
   405
    } else {
slouken@1900
   406
        pparams.Windowed = TRUE;
slouken@1903
   407
        pparams.FullScreen_RefreshRateInHz = 0;
slouken@1900
   408
    }
slouken@1965
   409
    if (flags & SDL_RENDERER_PRESENTVSYNC) {
slouken@1907
   410
        pparams.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
slouken@1907
   411
    } else {
slouken@1907
   412
        pparams.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
slouken@1907
   413
    }
slouken@1900
   414
slouken@1900
   415
    result = IDirect3D9_CreateDevice(videodata->d3d, D3DADAPTER_DEFAULT,        /* FIXME */
slouken@1900
   416
                                     D3DDEVTYPE_HAL,
slouken@1900
   417
                                     windowdata->hwnd,
slouken@1900
   418
                                     D3DCREATE_SOFTWARE_VERTEXPROCESSING,
slouken@1900
   419
                                     &pparams, &data->device);
slouken@1900
   420
    if (FAILED(result)) {
slouken@1913
   421
        D3D_DestroyRenderer(renderer);
slouken@1900
   422
        D3D_SetError("CreateDevice()", result);
slouken@1900
   423
        return NULL;
slouken@1900
   424
    }
slouken@1900
   425
    data->beginScene = SDL_TRUE;
slouken@1900
   426
slouken@1907
   427
    /* Get presentation parameters to fill info */
slouken@1907
   428
    result = IDirect3DDevice9_GetSwapChain(data->device, 0, &chain);
slouken@1907
   429
    if (FAILED(result)) {
slouken@1913
   430
        D3D_DestroyRenderer(renderer);
slouken@1907
   431
        D3D_SetError("GetSwapChain()", result);
slouken@1907
   432
        return NULL;
slouken@1907
   433
    }
slouken@1907
   434
    result = IDirect3DSwapChain9_GetPresentParameters(chain, &pparams);
slouken@1907
   435
    if (FAILED(result)) {
slouken@1907
   436
        IDirect3DSwapChain9_Release(chain);
slouken@1913
   437
        D3D_DestroyRenderer(renderer);
slouken@1907
   438
        D3D_SetError("GetPresentParameters()", result);
slouken@1907
   439
        return NULL;
slouken@1907
   440
    }
slouken@1907
   441
    IDirect3DSwapChain9_Release(chain);
slouken@1907
   442
    switch (pparams.SwapEffect) {
slouken@1907
   443
    case D3DSWAPEFFECT_COPY:
slouken@1965
   444
        renderer->info.flags |= SDL_RENDERER_PRESENTCOPY;
slouken@1907
   445
        break;
slouken@1907
   446
    case D3DSWAPEFFECT_FLIP:
slouken@1907
   447
        switch (pparams.BackBufferCount) {
slouken@1907
   448
        case 2:
slouken@1965
   449
            renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2;
slouken@1907
   450
            break;
slouken@1907
   451
        case 3:
slouken@1965
   452
            renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3;
slouken@1907
   453
            break;
slouken@1907
   454
        }
slouken@1907
   455
        break;
slouken@1907
   456
    case D3DSWAPEFFECT_DISCARD:
slouken@1965
   457
        renderer->info.flags |= SDL_RENDERER_PRESENTDISCARD;
slouken@1907
   458
        break;
slouken@1907
   459
    }
slouken@1907
   460
    if (pparams.PresentationInterval == D3DPRESENT_INTERVAL_ONE) {
slouken@1965
   461
        renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
slouken@1907
   462
    }
slouken@1975
   463
    data->pparams = pparams;
slouken@1907
   464
slouken@1925
   465
    IDirect3DDevice9_GetDeviceCaps(data->device, &caps);
slouken@1925
   466
    renderer->info.max_texture_width = caps.MaxTextureWidth;
slouken@1925
   467
    renderer->info.max_texture_height = caps.MaxTextureHeight;
slouken@1918
   468
slouken@1903
   469
    /* Set up parameters for rendering */
slouken@1904
   470
    IDirect3DDevice9_SetVertexShader(data->device, NULL);
slouken@1987
   471
    IDirect3DDevice9_SetFVF(data->device,
slouken@1987
   472
                            D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1);
slouken@1988
   473
    IDirect3DDevice9_SetRenderState(data->device, D3DRS_ZENABLE, D3DZB_FALSE);
slouken@1903
   474
    IDirect3DDevice9_SetRenderState(data->device, D3DRS_CULLMODE,
slouken@1903
   475
                                    D3DCULL_NONE);
slouken@1904
   476
    IDirect3DDevice9_SetRenderState(data->device, D3DRS_LIGHTING, FALSE);
slouken@1988
   477
    /* Enable color modulation by diffuse color */
slouken@1988
   478
    IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_COLOROP,
slouken@1988
   479
                                          D3DTOP_MODULATE);
slouken@1988
   480
    IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_COLORARG1,
slouken@1988
   481
                                          D3DTA_TEXTURE);
slouken@1988
   482
    IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_COLORARG2,
slouken@1988
   483
                                          D3DTA_DIFFUSE);
slouken@1988
   484
    /* Enable alpha modulation by diffuse alpha */
slouken@1988
   485
    IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_ALPHAOP,
slouken@1988
   486
                                          D3DTOP_MODULATE);
slouken@1988
   487
    IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_ALPHAARG1,
slouken@1988
   488
                                          D3DTA_TEXTURE);
slouken@1988
   489
    IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_ALPHAARG2,
slouken@1988
   490
                                          D3DTA_DIFFUSE);
slouken@1991
   491
    /* Disable second texture stage, since we're done */
slouken@1991
   492
    IDirect3DDevice9_SetTextureStageState(data->device, 1, D3DTSS_COLOROP,
slouken@1991
   493
                                          D3DTOP_DISABLE);
slouken@1991
   494
    IDirect3DDevice9_SetTextureStageState(data->device, 1, D3DTSS_ALPHAOP,
slouken@1991
   495
                                          D3DTOP_DISABLE);
slouken@1903
   496
slouken@1895
   497
    return renderer;
slouken@1895
   498
}
slouken@1895
   499
slouken@1895
   500
static int
slouken@1975
   501
D3D_Reset(SDL_Renderer * renderer)
slouken@1975
   502
{
slouken@1975
   503
    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
slouken@1975
   504
    HRESULT result;
slouken@1975
   505
slouken@1975
   506
    result = IDirect3DDevice9_Reset(data->device, &data->pparams);
slouken@1975
   507
    if (FAILED(result)) {
slouken@1975
   508
        if (result == D3DERR_DEVICELOST) {
slouken@1975
   509
            /* Don't worry about it, we'll reset later... */
slouken@1975
   510
            return 0;
slouken@1975
   511
        } else {
slouken@1975
   512
            D3D_SetError("Reset()", result);
slouken@1975
   513
            return -1;
slouken@1975
   514
        }
slouken@1975
   515
    }
slouken@1975
   516
    IDirect3DDevice9_SetVertexShader(data->device, NULL);
slouken@1987
   517
    IDirect3DDevice9_SetFVF(data->device,
slouken@1987
   518
                            D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1);
slouken@1975
   519
    IDirect3DDevice9_SetRenderState(data->device, D3DRS_CULLMODE,
slouken@1975
   520
                                    D3DCULL_NONE);
slouken@1975
   521
    IDirect3DDevice9_SetRenderState(data->device, D3DRS_LIGHTING, FALSE);
slouken@1975
   522
    return 0;
slouken@1975
   523
}
slouken@1975
   524
slouken@1975
   525
static int
slouken@1975
   526
D3D_DisplayModeChanged(SDL_Renderer * renderer)
slouken@1975
   527
{
slouken@1975
   528
    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
slouken@1975
   529
    SDL_Window *window = SDL_GetWindowFromID(renderer->window);
slouken@1975
   530
    SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
slouken@1975
   531
slouken@1975
   532
    data->pparams.BackBufferWidth = window->w;
slouken@1975
   533
    data->pparams.BackBufferHeight = window->h;
slouken@1975
   534
    if (window->flags & SDL_WINDOW_FULLSCREEN) {
slouken@1975
   535
        data->pparams.BackBufferFormat =
slouken@1975
   536
            PixelFormatToD3DFMT(display->fullscreen_mode.format);
slouken@1975
   537
    } else {
slouken@1975
   538
        data->pparams.BackBufferFormat = D3DFMT_UNKNOWN;
slouken@1975
   539
    }
slouken@1975
   540
    return D3D_Reset(renderer);
slouken@1975
   541
}
slouken@1975
   542
slouken@1975
   543
static int
slouken@1913
   544
D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
slouken@1895
   545
{
slouken@1913
   546
    D3D_RenderData *renderdata = (D3D_RenderData *) renderer->driverdata;
slouken@1895
   547
    SDL_Window *window = SDL_GetWindowFromID(renderer->window);
slouken@1895
   548
    SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
slouken@2973
   549
    Uint32 display_format = display->current_mode.format;
slouken@1913
   550
    D3D_TextureData *data;
slouken@1903
   551
    HRESULT result;
slouken@1895
   552
slouken@1920
   553
    data = (D3D_TextureData *) SDL_calloc(1, sizeof(*data));
slouken@1895
   554
    if (!data) {
slouken@1895
   555
        SDL_OutOfMemory();
slouken@1895
   556
        return -1;
slouken@1895
   557
    }
slouken@1895
   558
slouken@1895
   559
    texture->driverdata = data;
slouken@1895
   560
slouken@2973
   561
    if (SDL_ISPIXELFORMAT_FOURCC(texture->format) &&
slouken@2973
   562
        (texture->format != SDL_PIXELFORMAT_YUY2 ||
slouken@2990
   563
         !D3D_IsTextureFormatAvailable(renderdata->d3d, display_format,
slouken@2990
   564
                                       texture->format))
slouken@2990
   565
        && (texture->format != SDL_PIXELFORMAT_YVYU
slouken@2990
   566
            || !D3D_IsTextureFormatAvailable(renderdata->d3d, display_format,
slouken@2990
   567
                                             texture->format))) {
slouken@2973
   568
        data->yuv =
slouken@2973
   569
            SDL_SW_CreateYUVTexture(texture->format, texture->w, texture->h);
slouken@2973
   570
        if (!data->yuv) {
slouken@2973
   571
            return -1;
slouken@2973
   572
        }
slouken@2973
   573
        data->format = display->current_mode.format;
slouken@2973
   574
    } else {
slouken@2973
   575
        data->format = texture->format;
slouken@2973
   576
    }
slouken@2973
   577
slouken@1903
   578
    result =
slouken@1903
   579
        IDirect3DDevice9_CreateTexture(renderdata->device, texture->w,
slouken@1903
   580
                                       texture->h, 1, 0,
slouken@2973
   581
                                       PixelFormatToD3DFMT(data->format),
slouken@2783
   582
                                       D3DPOOL_SDL, &data->texture, NULL);
slouken@1903
   583
    if (FAILED(result)) {
slouken@1903
   584
        D3D_SetError("CreateTexture()", result);
slouken@1903
   585
        return -1;
slouken@1903
   586
    }
slouken@1903
   587
slouken@1895
   588
    return 0;
slouken@1895
   589
}
slouken@1895
   590
slouken@1895
   591
static int
slouken@2973
   592
D3D_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
slouken@2973
   593
                       void **pixels, int *pitch)
slouken@2973
   594
{
slouken@2973
   595
    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
slouken@2973
   596
slouken@2973
   597
    if (data->yuv) {
slouken@2973
   598
        return SDL_SW_QueryYUVTexturePixels(data->yuv, pixels, pitch);
slouken@2973
   599
    } else {
slouken@2973
   600
        /* D3D textures don't have their pixels hanging out */
slouken@2973
   601
        return -1;
slouken@2973
   602
    }
slouken@2973
   603
}
slouken@2973
   604
slouken@2973
   605
static int
slouken@1913
   606
D3D_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
slouken@1913
   607
                      const SDL_Color * colors, int firstcolor, int ncolors)
slouken@1895
   608
{
slouken@1913
   609
    D3D_RenderData *renderdata = (D3D_RenderData *) renderer->driverdata;
slouken@1913
   610
    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
slouken@1895
   611
slouken@1903
   612
    return 0;
slouken@1895
   613
}
slouken@1895
   614
slouken@1895
   615
static int
slouken@1913
   616
D3D_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
slouken@1913
   617
                      SDL_Color * colors, int firstcolor, int ncolors)
slouken@1895
   618
{
slouken@1913
   619
    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
slouken@1895
   620
slouken@1903
   621
    return 0;
slouken@1895
   622
}
slouken@1895
   623
slouken@1895
   624
static int
slouken@1985
   625
D3D_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture)
slouken@1985
   626
{
slouken@1987
   627
    return 0;
slouken@1985
   628
}
slouken@1985
   629
slouken@1985
   630
static int
slouken@1985
   631
D3D_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture)
slouken@1985
   632
{
slouken@1987
   633
    return 0;
slouken@1985
   634
}
slouken@1985
   635
slouken@1985
   636
static int
slouken@1985
   637
D3D_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
slouken@1985
   638
{
slouken@1985
   639
    switch (texture->blendMode) {
slouken@2884
   640
    case SDL_BLENDMODE_NONE:
slouken@2884
   641
    case SDL_BLENDMODE_MASK:
slouken@2884
   642
    case SDL_BLENDMODE_BLEND:
slouken@2884
   643
    case SDL_BLENDMODE_ADD:
slouken@2884
   644
    case SDL_BLENDMODE_MOD:
slouken@1985
   645
        return 0;
slouken@1985
   646
    default:
slouken@1985
   647
        SDL_Unsupported();
slouken@2884
   648
        texture->blendMode = SDL_BLENDMODE_NONE;
slouken@1985
   649
        return -1;
slouken@1985
   650
    }
slouken@1985
   651
}
slouken@1985
   652
slouken@1985
   653
static int
slouken@1985
   654
D3D_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
slouken@1985
   655
{
slouken@1985
   656
    switch (texture->scaleMode) {
slouken@1985
   657
    case SDL_TEXTURESCALEMODE_NONE:
slouken@1985
   658
    case SDL_TEXTURESCALEMODE_FAST:
slouken@1985
   659
    case SDL_TEXTURESCALEMODE_SLOW:
slouken@1985
   660
    case SDL_TEXTURESCALEMODE_BEST:
slouken@1985
   661
        return 0;
slouken@1985
   662
    default:
slouken@1985
   663
        SDL_Unsupported();
slouken@1985
   664
        texture->scaleMode = SDL_TEXTURESCALEMODE_NONE;
slouken@1985
   665
        return -1;
slouken@1985
   666
    }
slouken@1985
   667
    return 0;
slouken@1985
   668
}
slouken@1985
   669
slouken@1985
   670
static int
slouken@1913
   671
D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
slouken@1913
   672
                  const SDL_Rect * rect, const void *pixels, int pitch)
slouken@1895
   673
{
slouken@1913
   674
    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
slouken@1913
   675
    D3D_RenderData *renderdata = (D3D_RenderData *) renderer->driverdata;
slouken@1895
   676
slouken@2973
   677
    if (data->yuv) {
slouken@2973
   678
        if (SDL_SW_UpdateYUVTexture(data->yuv, rect, pixels, pitch) < 0) {
slouken@2973
   679
            return -1;
slouken@2973
   680
        }
slouken@2973
   681
        UpdateYUVTextureData(texture);
slouken@2973
   682
        return 0;
slouken@2973
   683
    } else {
slouken@2973
   684
#ifdef SDL_MEMORY_POOL_DEFAULT
slouken@2973
   685
        IDirect3DTexture9 *temp;
slouken@2973
   686
        RECT d3drect;
slouken@2973
   687
        D3DLOCKED_RECT locked;
slouken@2973
   688
        const Uint8 *src;
slouken@2973
   689
        Uint8 *dst;
slouken@2973
   690
        int row, length;
slouken@2973
   691
        HRESULT result;
slouken@2973
   692
slouken@2973
   693
        result =
slouken@2973
   694
            IDirect3DDevice9_CreateTexture(renderdata->device, texture->w,
slouken@2973
   695
                                           texture->h, 1, 0,
bob@3011
   696
                                           PixelFormatToD3DFMT
bob@3011
   697
                                           (texture->format),
slouken@2973
   698
                                           D3DPOOL_SYSTEMMEM, &temp, NULL);
slouken@2973
   699
        if (FAILED(result)) {
slouken@2973
   700
            D3D_SetError("CreateTexture()", result);
slouken@2973
   701
            return -1;
slouken@2973
   702
        }
slouken@2973
   703
slouken@2973
   704
        d3drect.left = rect->x;
slouken@2973
   705
        d3drect.right = rect->x + rect->w;
slouken@2973
   706
        d3drect.top = rect->y;
slouken@2973
   707
        d3drect.bottom = rect->y + rect->h;
slouken@2973
   708
slouken@2973
   709
        result = IDirect3DTexture9_LockRect(temp, 0, &locked, &d3drect, 0);
slouken@2973
   710
        if (FAILED(result)) {
slouken@2973
   711
            IDirect3DTexture9_Release(temp);
slouken@2973
   712
            D3D_SetError("LockRect()", result);
slouken@2973
   713
            return -1;
slouken@2973
   714
        }
slouken@2973
   715
slouken@2973
   716
        src = pixels;
slouken@2973
   717
        dst = locked.pBits;
slouken@2973
   718
        length = rect->w * SDL_BYTESPERPIXEL(texture->format);
slouken@2973
   719
        for (row = 0; row < rect->h; ++row) {
slouken@2973
   720
            SDL_memcpy(dst, src, length);
slouken@2973
   721
            src += pitch;
slouken@2973
   722
            dst += locked.Pitch;
slouken@2973
   723
        }
slouken@2973
   724
        IDirect3DTexture9_UnlockRect(temp, 0);
slouken@2973
   725
slouken@2973
   726
        result =
slouken@2973
   727
            IDirect3DDevice9_UpdateTexture(renderdata->device,
slouken@2973
   728
                                           (IDirect3DBaseTexture9 *) temp,
slouken@2973
   729
                                           (IDirect3DBaseTexture9 *)
slouken@2973
   730
                                           data->texture);
slouken@2973
   731
        IDirect3DTexture9_Release(temp);
slouken@2973
   732
        if (FAILED(result)) {
slouken@2973
   733
            D3D_SetError("UpdateTexture()", result);
slouken@2973
   734
            return -1;
slouken@2973
   735
        }
slouken@2973
   736
#else
slouken@2973
   737
        RECT d3drect;
slouken@2973
   738
        D3DLOCKED_RECT locked;
slouken@2973
   739
        const Uint8 *src;
slouken@2973
   740
        Uint8 *dst;
slouken@2973
   741
        int row, length;
slouken@2973
   742
        HRESULT result;
slouken@2973
   743
slouken@2973
   744
        d3drect.left = rect->x;
slouken@2973
   745
        d3drect.right = rect->x + rect->w;
slouken@2973
   746
        d3drect.top = rect->y;
slouken@2973
   747
        d3drect.bottom = rect->y + rect->h;
slouken@2973
   748
slouken@2973
   749
        result =
slouken@2990
   750
            IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect,
slouken@2990
   751
                                       0);
slouken@2973
   752
        if (FAILED(result)) {
slouken@2973
   753
            D3D_SetError("LockRect()", result);
slouken@2973
   754
            return -1;
slouken@2973
   755
        }
slouken@2973
   756
slouken@2973
   757
        src = pixels;
slouken@2973
   758
        dst = locked.pBits;
slouken@2973
   759
        length = rect->w * SDL_BYTESPERPIXEL(texture->format);
slouken@2973
   760
        for (row = 0; row < rect->h; ++row) {
slouken@2973
   761
            SDL_memcpy(dst, src, length);
slouken@2973
   762
            src += pitch;
slouken@2973
   763
            dst += locked.Pitch;
slouken@2973
   764
        }
slouken@2973
   765
        IDirect3DTexture9_UnlockRect(data->texture, 0);
slouken@2973
   766
#endif // SDL_MEMORY_POOL_DEFAULT
slouken@2973
   767
slouken@2973
   768
        return 0;
slouken@1903
   769
    }
slouken@1895
   770
}
slouken@1895
   771
slouken@1895
   772
static int
slouken@1913
   773
D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
slouken@1913
   774
                const SDL_Rect * rect, int markDirty, void **pixels,
slouken@1913
   775
                int *pitch)
slouken@1895
   776
{
slouken@1913
   777
    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
slouken@1895
   778
slouken@2973
   779
    if (data->yuv) {
slouken@2973
   780
        return SDL_SW_LockYUVTexture(data->yuv, rect, markDirty, pixels,
slouken@2973
   781
                                     pitch);
slouken@2973
   782
    } else {
slouken@2973
   783
        RECT d3drect;
slouken@2973
   784
        D3DLOCKED_RECT locked;
slouken@2973
   785
        HRESULT result;
slouken@1903
   786
slouken@2973
   787
        d3drect.left = rect->x;
slouken@2973
   788
        d3drect.right = rect->x + rect->w;
slouken@2973
   789
        d3drect.top = rect->y;
slouken@2973
   790
        d3drect.bottom = rect->y + rect->h;
slouken@2973
   791
slouken@2973
   792
        result =
slouken@2973
   793
            IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect,
slouken@2990
   794
                                       markDirty ? 0 :
slouken@2990
   795
                                       D3DLOCK_NO_DIRTY_UPDATE);
slouken@2973
   796
        if (FAILED(result)) {
slouken@2973
   797
            D3D_SetError("LockRect()", result);
slouken@2973
   798
            return -1;
slouken@2973
   799
        }
slouken@2973
   800
        *pixels = locked.pBits;
slouken@2973
   801
        *pitch = locked.Pitch;
slouken@2973
   802
        return 0;
slouken@1903
   803
    }
slouken@1895
   804
}
slouken@1895
   805
slouken@1895
   806
static void
slouken@1913
   807
D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
slouken@1895
   808
{
slouken@1913
   809
    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
slouken@1895
   810
slouken@2973
   811
    if (data->yuv) {
slouken@2973
   812
        SDL_SW_UnlockYUVTexture(data->yuv);
slouken@2973
   813
        UpdateYUVTextureData(texture);
slouken@2973
   814
    } else {
slouken@2973
   815
        IDirect3DTexture9_UnlockRect(data->texture, 0);
slouken@2973
   816
    }
slouken@1895
   817
}
slouken@1895
   818
slouken@1895
   819
static void
slouken@1913
   820
D3D_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture, int numrects,
slouken@1913
   821
                 const SDL_Rect * rects)
slouken@1895
   822
{
slouken@1913
   823
    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
slouken@1903
   824
    RECT d3drect;
slouken@1903
   825
    int i;
slouken@1903
   826
slouken@1903
   827
    for (i = 0; i < numrects; ++i) {
slouken@1903
   828
        const SDL_Rect *rect = &rects[i];
slouken@1903
   829
slouken@1903
   830
        d3drect.left = rect->x;
slouken@1903
   831
        d3drect.right = rect->x + rect->w;
slouken@1903
   832
        d3drect.top = rect->y;
slouken@1903
   833
        d3drect.bottom = rect->y + rect->h;
slouken@1903
   834
slouken@1903
   835
        IDirect3DTexture9_AddDirtyRect(data->texture, &d3drect);
slouken@1903
   836
    }
slouken@1895
   837
}
slouken@1895
   838
slouken@2932
   839
static void
slouken@2933
   840
D3D_SetBlendMode(D3D_RenderData * data, int blendMode)
slouken@2932
   841
{
slouken@2932
   842
    switch (blendMode) {
slouken@2932
   843
    case SDL_BLENDMODE_NONE:
slouken@2932
   844
        IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE,
slouken@2932
   845
                                        FALSE);
slouken@2932
   846
        break;
slouken@2932
   847
    case SDL_BLENDMODE_MASK:
slouken@2932
   848
    case SDL_BLENDMODE_BLEND:
slouken@2932
   849
        IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE,
slouken@2932
   850
                                        TRUE);
slouken@2932
   851
        IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND,
slouken@2932
   852
                                        D3DBLEND_SRCALPHA);
slouken@2932
   853
        IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND,
slouken@2932
   854
                                        D3DBLEND_INVSRCALPHA);
slouken@2932
   855
        break;
slouken@2932
   856
    case SDL_BLENDMODE_ADD:
slouken@2932
   857
        IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE,
slouken@2932
   858
                                        TRUE);
slouken@2932
   859
        IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND,
slouken@2932
   860
                                        D3DBLEND_SRCALPHA);
slouken@2932
   861
        IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND,
slouken@2932
   862
                                        D3DBLEND_ONE);
slouken@2932
   863
        break;
slouken@2932
   864
    case SDL_BLENDMODE_MOD:
slouken@2932
   865
        IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE,
slouken@2932
   866
                                        TRUE);
slouken@2932
   867
        IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND,
slouken@2932
   868
                                        D3DBLEND_ZERO);
slouken@2932
   869
        IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND,
slouken@2932
   870
                                        D3DBLEND_SRCCOLOR);
slouken@2932
   871
        break;
slouken@2932
   872
    }
slouken@2932
   873
}
slouken@2932
   874
slouken@1895
   875
static int
slouken@2932
   876
D3D_RenderPoint(SDL_Renderer * renderer, int x, int y)
slouken@1895
   877
{
slouken@1913
   878
    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
slouken@2932
   879
    DWORD color;
slouken@2932
   880
    Vertex vertices[1];
slouken@1900
   881
    HRESULT result;
slouken@1895
   882
slouken@1900
   883
    if (data->beginScene) {
slouken@1900
   884
        IDirect3DDevice9_BeginScene(data->device);
slouken@1900
   885
        data->beginScene = SDL_FALSE;
slouken@1900
   886
    }
slouken@1895
   887
slouken@2932
   888
    color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b);
slouken@1901
   889
slouken@2932
   890
    vertices[0].x = (float) x - 0.5f;
slouken@2932
   891
    vertices[0].y = (float) y - 0.5f;
slouken@2932
   892
    vertices[0].z = 0.0f;
slouken@2932
   893
    vertices[0].rhw = 1.0f;
slouken@2932
   894
    vertices[0].color = color;
slouken@2932
   895
    vertices[0].u = 0.0f;
slouken@2932
   896
    vertices[0].v = 0.0f;
slouken@2932
   897
slouken@2932
   898
    D3D_SetBlendMode(data, renderer->blendMode);
slouken@2932
   899
slouken@2933
   900
    result =
slouken@2933
   901
        IDirect3DDevice9_SetTexture(data->device, 0,
slouken@2933
   902
                                    (IDirect3DBaseTexture9 *) 0);
slouken@2932
   903
    if (FAILED(result)) {
slouken@2932
   904
        D3D_SetError("SetTexture()", result);
slouken@2932
   905
        return -1;
slouken@2932
   906
    }
slouken@1903
   907
    result =
slouken@2932
   908
        IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_POINTLIST, 1,
slouken@2932
   909
                                         vertices, sizeof(*vertices));
slouken@1900
   910
    if (FAILED(result)) {
slouken@2932
   911
        D3D_SetError("DrawPrimitiveUP()", result);
slouken@2932
   912
        return -1;
slouken@2932
   913
    }
slouken@2932
   914
    return 0;
slouken@2932
   915
}
slouken@2932
   916
slouken@2932
   917
static int
slouken@2932
   918
D3D_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2)
slouken@2932
   919
{
slouken@2932
   920
    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
slouken@2932
   921
    DWORD color;
slouken@2932
   922
    Vertex vertices[2];
slouken@2932
   923
    HRESULT result;
slouken@2932
   924
slouken@2932
   925
    if (data->beginScene) {
slouken@2932
   926
        IDirect3DDevice9_BeginScene(data->device);
slouken@2932
   927
        data->beginScene = SDL_FALSE;
slouken@2932
   928
    }
slouken@2932
   929
slouken@2932
   930
    color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b);
slouken@2932
   931
slouken@2932
   932
    vertices[0].x = (float) x1 - 0.5f;
slouken@2932
   933
    vertices[0].y = (float) y1 - 0.5f;
slouken@2932
   934
    vertices[0].z = 0.0f;
slouken@2932
   935
    vertices[0].rhw = 1.0f;
slouken@2932
   936
    vertices[0].color = color;
slouken@2932
   937
    vertices[0].u = 0.0f;
slouken@2932
   938
    vertices[0].v = 0.0f;
slouken@2932
   939
slouken@2932
   940
    vertices[1].x = (float) x2 - 0.5f;
slouken@2932
   941
    vertices[1].y = (float) y2 - 0.5f;
slouken@2932
   942
    vertices[1].z = 0.0f;
slouken@2932
   943
    vertices[1].rhw = 1.0f;
slouken@2932
   944
    vertices[1].color = color;
slouken@2932
   945
    vertices[1].u = 0.0f;
slouken@2932
   946
    vertices[1].v = 0.0f;
slouken@2932
   947
slouken@2932
   948
    D3D_SetBlendMode(data, renderer->blendMode);
slouken@2932
   949
slouken@2933
   950
    result =
slouken@2933
   951
        IDirect3DDevice9_SetTexture(data->device, 0,
slouken@2933
   952
                                    (IDirect3DBaseTexture9 *) 0);
slouken@2932
   953
    if (FAILED(result)) {
slouken@2932
   954
        D3D_SetError("SetTexture()", result);
slouken@2932
   955
        return -1;
slouken@2932
   956
    }
slouken@2932
   957
    result =
slouken@2932
   958
        IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_LINELIST, 1,
slouken@2932
   959
                                         vertices, sizeof(*vertices));
slouken@2932
   960
    if (FAILED(result)) {
slouken@2932
   961
        D3D_SetError("DrawPrimitiveUP()", result);
slouken@2932
   962
        return -1;
slouken@2932
   963
    }
slouken@2932
   964
    return 0;
slouken@2932
   965
}
slouken@2932
   966
slouken@2932
   967
static int
slouken@2932
   968
D3D_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect)
slouken@2932
   969
{
slouken@2932
   970
    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
slouken@2932
   971
    float minx, miny, maxx, maxy;
slouken@2932
   972
    DWORD color;
slouken@2932
   973
    Vertex vertices[4];
slouken@2932
   974
    HRESULT result;
slouken@2932
   975
slouken@2932
   976
    if (data->beginScene) {
slouken@2932
   977
        IDirect3DDevice9_BeginScene(data->device);
slouken@2932
   978
        data->beginScene = SDL_FALSE;
slouken@2932
   979
    }
slouken@2932
   980
slouken@2932
   981
    minx = (float) rect->x - 0.5f;
slouken@2932
   982
    miny = (float) rect->y - 0.5f;
slouken@2932
   983
    maxx = (float) rect->x + rect->w - 0.5f;
slouken@2932
   984
    maxy = (float) rect->y + rect->h - 0.5f;
slouken@2932
   985
slouken@2932
   986
    color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b);
slouken@2932
   987
slouken@2932
   988
    vertices[0].x = minx;
slouken@2932
   989
    vertices[0].y = miny;
slouken@2932
   990
    vertices[0].z = 0.0f;
slouken@2932
   991
    vertices[0].rhw = 1.0f;
slouken@2932
   992
    vertices[0].color = color;
slouken@2932
   993
    vertices[0].u = 0.0f;
slouken@2932
   994
    vertices[0].v = 0.0f;
slouken@2932
   995
slouken@2932
   996
    vertices[1].x = maxx;
slouken@2932
   997
    vertices[1].y = miny;
slouken@2932
   998
    vertices[1].z = 0.0f;
slouken@2932
   999
    vertices[1].rhw = 1.0f;
slouken@2932
  1000
    vertices[1].color = color;
slouken@2932
  1001
    vertices[1].u = 0.0f;
slouken@2932
  1002
    vertices[1].v = 0.0f;
slouken@2932
  1003
slouken@2932
  1004
    vertices[2].x = maxx;
slouken@2932
  1005
    vertices[2].y = maxy;
slouken@2932
  1006
    vertices[2].z = 0.0f;
slouken@2932
  1007
    vertices[2].rhw = 1.0f;
slouken@2932
  1008
    vertices[2].color = color;
slouken@2932
  1009
    vertices[2].u = 0.0f;
slouken@2932
  1010
    vertices[2].v = 0.0f;
slouken@2932
  1011
slouken@2932
  1012
    vertices[3].x = minx;
slouken@2932
  1013
    vertices[3].y = maxy;
slouken@2932
  1014
    vertices[3].z = 0.0f;
slouken@2932
  1015
    vertices[3].rhw = 1.0f;
slouken@2932
  1016
    vertices[3].color = color;
slouken@2932
  1017
    vertices[3].u = 0.0f;
slouken@2932
  1018
    vertices[3].v = 0.0f;
slouken@2932
  1019
slouken@2932
  1020
    D3D_SetBlendMode(data, renderer->blendMode);
slouken@2932
  1021
slouken@2933
  1022
    result =
slouken@2933
  1023
        IDirect3DDevice9_SetTexture(data->device, 0,
slouken@2933
  1024
                                    (IDirect3DBaseTexture9 *) 0);
slouken@2932
  1025
    if (FAILED(result)) {
slouken@2932
  1026
        D3D_SetError("SetTexture()", result);
slouken@2932
  1027
        return -1;
slouken@2932
  1028
    }
slouken@2932
  1029
    result =
slouken@2932
  1030
        IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_TRIANGLEFAN, 2,
slouken@2932
  1031
                                         vertices, sizeof(*vertices));
slouken@2932
  1032
    if (FAILED(result)) {
slouken@2932
  1033
        D3D_SetError("DrawPrimitiveUP()", result);
slouken@1900
  1034
        return -1;
slouken@1900
  1035
    }
slouken@1895
  1036
    return 0;
slouken@1895
  1037
}
slouken@1895
  1038
slouken@1895
  1039
static int
slouken@1913
  1040
D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
slouken@1985
  1041
               const SDL_Rect * srcrect, const SDL_Rect * dstrect)
slouken@1895
  1042
{
slouken@1913
  1043
    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
slouken@1913
  1044
    D3D_TextureData *texturedata = (D3D_TextureData *) texture->driverdata;
slouken@1903
  1045
    float minx, miny, maxx, maxy;
slouken@1904
  1046
    float minu, maxu, minv, maxv;
slouken@1987
  1047
    DWORD color;
slouken@1903
  1048
    Vertex vertices[4];
slouken@1903
  1049
    HRESULT result;
slouken@1895
  1050
slouken@1900
  1051
    if (data->beginScene) {
slouken@1900
  1052
        IDirect3DDevice9_BeginScene(data->device);
slouken@1900
  1053
        data->beginScene = SDL_FALSE;
slouken@1900
  1054
    }
slouken@1903
  1055
slouken@1904
  1056
    minx = (float) dstrect->x - 0.5f;
slouken@1904
  1057
    miny = (float) dstrect->y - 0.5f;
slouken@1904
  1058
    maxx = (float) dstrect->x + dstrect->w - 0.5f;
slouken@1904
  1059
    maxy = (float) dstrect->y + dstrect->h - 0.5f;
slouken@1903
  1060
slouken@1904
  1061
    minu = (float) srcrect->x / texture->w;
slouken@1904
  1062
    maxu = (float) (srcrect->x + srcrect->w) / texture->w;
slouken@1904
  1063
    minv = (float) srcrect->y / texture->h;
slouken@1904
  1064
    maxv = (float) (srcrect->y + srcrect->h) / texture->h;
slouken@1903
  1065
slouken@1987
  1066
    color = D3DCOLOR_ARGB(texture->a, texture->r, texture->g, texture->b);
slouken@1987
  1067
slouken@1903
  1068
    vertices[0].x = minx;
slouken@1903
  1069
    vertices[0].y = miny;
slouken@1903
  1070
    vertices[0].z = 0.0f;
slouken@1904
  1071
    vertices[0].rhw = 1.0f;
slouken@1987
  1072
    vertices[0].color = color;
slouken@1904
  1073
    vertices[0].u = minu;
slouken@1904
  1074
    vertices[0].v = minv;
slouken@1904
  1075
slouken@1903
  1076
    vertices[1].x = maxx;
slouken@1903
  1077
    vertices[1].y = miny;
slouken@1903
  1078
    vertices[1].z = 0.0f;
slouken@1904
  1079
    vertices[1].rhw = 1.0f;
slouken@1987
  1080
    vertices[1].color = color;
slouken@1904
  1081
    vertices[1].u = maxu;
slouken@1904
  1082
    vertices[1].v = minv;
slouken@1904
  1083
slouken@1903
  1084
    vertices[2].x = maxx;
slouken@1903
  1085
    vertices[2].y = maxy;
slouken@1903
  1086
    vertices[2].z = 0.0f;
slouken@1904
  1087
    vertices[2].rhw = 1.0f;
slouken@1987
  1088
    vertices[2].color = color;
slouken@1904
  1089
    vertices[2].u = maxu;
slouken@1904
  1090
    vertices[2].v = maxv;
slouken@1904
  1091
slouken@1903
  1092
    vertices[3].x = minx;
slouken@1903
  1093
    vertices[3].y = maxy;
slouken@1903
  1094
    vertices[3].z = 0.0f;
slouken@1904
  1095
    vertices[3].rhw = 1.0f;
slouken@1987
  1096
    vertices[3].color = color;
slouken@1904
  1097
    vertices[3].u = minu;
slouken@1904
  1098
    vertices[3].v = maxv;
slouken@1903
  1099
slouken@2932
  1100
    D3D_SetBlendMode(data, texture->blendMode);
slouken@1916
  1101
slouken@1985
  1102
    switch (texture->scaleMode) {
slouken@1965
  1103
    case SDL_TEXTURESCALEMODE_NONE:
slouken@1965
  1104
    case SDL_TEXTURESCALEMODE_FAST:
slouken@1917
  1105
        IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MINFILTER,
slouken@1917
  1106
                                         D3DTEXF_POINT);
slouken@1917
  1107
        IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MAGFILTER,
slouken@1917
  1108
                                         D3DTEXF_POINT);
slouken@1917
  1109
        break;
slouken@1965
  1110
    case SDL_TEXTURESCALEMODE_SLOW:
slouken@1917
  1111
        IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MINFILTER,
slouken@1917
  1112
                                         D3DTEXF_LINEAR);
slouken@1917
  1113
        IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MAGFILTER,
slouken@1917
  1114
                                         D3DTEXF_LINEAR);
slouken@1917
  1115
        break;
slouken@1965
  1116
    case SDL_TEXTURESCALEMODE_BEST:
slouken@1917
  1117
        IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MINFILTER,
slouken@1917
  1118
                                         D3DTEXF_GAUSSIANQUAD);
slouken@1917
  1119
        IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MAGFILTER,
slouken@1917
  1120
                                         D3DTEXF_GAUSSIANQUAD);
slouken@1917
  1121
        break;
slouken@1917
  1122
    }
slouken@1917
  1123
slouken@1903
  1124
    result =
slouken@2735
  1125
        IDirect3DDevice9_SetTexture(data->device, 0, (IDirect3DBaseTexture9 *)
slouken@2735
  1126
                                    texturedata->texture);
slouken@1903
  1127
    if (FAILED(result)) {
slouken@1903
  1128
        D3D_SetError("SetTexture()", result);
slouken@1903
  1129
        return -1;
slouken@1903
  1130
    }
slouken@1903
  1131
    result =
slouken@1903
  1132
        IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_TRIANGLEFAN, 2,
slouken@1903
  1133
                                         vertices, sizeof(*vertices));
slouken@1903
  1134
    if (FAILED(result)) {
slouken@1903
  1135
        D3D_SetError("DrawPrimitiveUP()", result);
slouken@1903
  1136
        return -1;
slouken@1903
  1137
    }
slouken@1895
  1138
    return 0;
slouken@1895
  1139
}
slouken@1895
  1140
slouken@1895
  1141
static void
slouken@1913
  1142
D3D_RenderPresent(SDL_Renderer * renderer)
slouken@1895
  1143
{
slouken@1913
  1144
    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
slouken@1900
  1145
    HRESULT result;
slouken@1900
  1146
slouken@1900
  1147
    if (!data->beginScene) {
slouken@1900
  1148
        IDirect3DDevice9_EndScene(data->device);
slouken@1900
  1149
        data->beginScene = SDL_TRUE;
slouken@1900
  1150
    }
slouken@1900
  1151
slouken@1975
  1152
    result = IDirect3DDevice9_TestCooperativeLevel(data->device);
slouken@1975
  1153
    if (result == D3DERR_DEVICELOST) {
slouken@1975
  1154
        /* We'll reset later */
slouken@1975
  1155
        return;
slouken@1975
  1156
    }
slouken@1975
  1157
    if (result == D3DERR_DEVICENOTRESET) {
slouken@1975
  1158
        D3D_Reset(renderer);
slouken@1975
  1159
    }
slouken@1900
  1160
    result = IDirect3DDevice9_Present(data->device, NULL, NULL, NULL, NULL);
slouken@1900
  1161
    if (FAILED(result)) {
slouken@1900
  1162
        D3D_SetError("Present()", result);
slouken@1900
  1163
    }
slouken@1895
  1164
}
slouken@1895
  1165
slouken@1895
  1166
static void
slouken@1913
  1167
D3D_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
slouken@1895
  1168
{
slouken@1913
  1169
    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
slouken@1895
  1170
slouken@1895
  1171
    if (!data) {
slouken@1895
  1172
        return;
slouken@1895
  1173
    }
slouken@2973
  1174
    if (data->yuv) {
slouken@2973
  1175
        SDL_SW_DestroyYUVTexture(data->yuv);
slouken@2973
  1176
    }
slouken@1903
  1177
    if (data->texture) {
slouken@1903
  1178
        IDirect3DTexture9_Release(data->texture);
slouken@1903
  1179
    }
slouken@1895
  1180
    SDL_free(data);
slouken@1895
  1181
    texture->driverdata = NULL;
slouken@1895
  1182
}
slouken@1895
  1183
slouken@1975
  1184
static void
slouken@1913
  1185
D3D_DestroyRenderer(SDL_Renderer * renderer)
slouken@1895
  1186
{
slouken@1913
  1187
    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
slouken@1895
  1188
slouken@1895
  1189
    if (data) {
slouken@1900
  1190
        if (data->device) {
slouken@1900
  1191
            IDirect3DDevice9_Release(data->device);
slouken@1900
  1192
        }
slouken@1895
  1193
        SDL_free(data);
slouken@1895
  1194
    }
slouken@1895
  1195
    SDL_free(renderer);
slouken@1895
  1196
}
slouken@1895
  1197
slouken@1895
  1198
#endif /* SDL_VIDEO_RENDER_D3D */
slouken@1895
  1199
slouken@1895
  1200
/* vi: set ts=4 sw=4 expandtab: */