src/video/win32/SDL_gdirender.c
author Sam Lantinga <slouken@libsdl.org>
Sat, 08 Jul 2006 18:06:02 +0000
branchSDL-1.3
changeset 1730 e70477157db9
child 1897 c2a27da60b18
permissions -rw-r--r--
Starting support for Direct3D render driver.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1730
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     1
/*
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     2
    SDL - Simple DirectMedia Layer
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     3
    Copyright (C) 1997-2006 Sam Lantinga
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     4
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     5
    This library is free software; you can redistribute it and/or
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     6
    modify it under the terms of the GNU Lesser General Public
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     7
    License as published by the Free Software Foundation; either
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     8
    version 2.1 of the License, or (at your option) any later version.
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     9
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    10
    This library is distributed in the hope that it will be useful,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    13
    Lesser General Public License for more details.
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    14
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    15
    You should have received a copy of the GNU Lesser General Public
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    16
    License along with this library; if not, write to the Free Software
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    18
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    19
    Sam Lantinga
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    20
    slouken@libsdl.org
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    21
*/
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    22
#include "SDL_config.h"
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    23
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    24
#if SDL_VIDEO_RENDER_GDI
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    25
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    26
#include "SDL_win32video.h"
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    27
#include "../SDL_yuv_sw_c.h"
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    28
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    29
/* GDI renderer implementation */
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    30
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    31
static SDL_Renderer *SDL_GDI_CreateRenderer(SDL_Window * window,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    32
                                            Uint32 flags);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    33
static int SDL_GDI_CreateTexture(SDL_Renderer * renderer,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    34
                                 SDL_Texture * texture);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    35
static int SDL_GDI_QueryTexturePixels(SDL_Renderer * renderer,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    36
                                      SDL_Texture * texture, void **pixels,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    37
                                      int *pitch);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    38
static int SDL_GDI_SetTexturePalette(SDL_Renderer * renderer,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    39
                                     SDL_Texture * texture,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    40
                                     const SDL_Color * colors, int firstcolor,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    41
                                     int ncolors);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    42
static int SDL_GDI_GetTexturePalette(SDL_Renderer * renderer,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    43
                                     SDL_Texture * texture,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    44
                                     SDL_Color * colors, int firstcolor,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    45
                                     int ncolors);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    46
static int SDL_GDI_UpdateTexture(SDL_Renderer * renderer,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    47
                                 SDL_Texture * texture, const SDL_Rect * rect,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    48
                                 const void *pixels, int pitch);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    49
static int SDL_GDI_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    50
                               const SDL_Rect * rect, int markDirty,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    51
                               void **pixels, int *pitch);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    52
static void SDL_GDI_UnlockTexture(SDL_Renderer * renderer,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    53
                                  SDL_Texture * texture);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    54
static void SDL_GDI_DirtyTexture(SDL_Renderer * renderer,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    55
                                 SDL_Texture * texture, int numrects,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    56
                                 const SDL_Rect * rects);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    57
static void SDL_GDI_SelectRenderTexture(SDL_Renderer * renderer,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    58
                                        SDL_Texture * texture);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    59
static int SDL_GDI_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    60
                              Uint32 color);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    61
static int SDL_GDI_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    62
                              const SDL_Rect * srcrect,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    63
                              const SDL_Rect * dstrect, int blendMode,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    64
                              int scaleMode);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    65
static int SDL_GDI_RenderReadPixels(SDL_Renderer * renderer,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    66
                                    const SDL_Rect * rect, void *pixels,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    67
                                    int pitch);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    68
static int SDL_GDI_RenderWritePixels(SDL_Renderer * renderer,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    69
                                     const SDL_Rect * rect,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    70
                                     const void *pixels, int pitch);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    71
static void SDL_GDI_RenderPresent(SDL_Renderer * renderer);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    72
static void SDL_GDI_DestroyTexture(SDL_Renderer * renderer,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    73
                                   SDL_Texture * texture);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    74
static void SDL_GDI_DestroyRenderer(SDL_Renderer * renderer);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    75
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    76
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    77
SDL_RenderDriver SDL_GDI_RenderDriver = {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    78
    SDL_GDI_CreateRenderer,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    79
    {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    80
     "gdi",
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    81
     (SDL_Renderer_PresentDiscard |
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    82
      SDL_Renderer_PresentCopy | SDL_Renderer_RenderTarget),
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    83
     (SDL_TextureBlendMode_None |
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    84
      SDL_TextureBlendMode_Mask | SDL_TextureBlendMode_Blend),
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    85
     (SDL_TextureScaleMode_None | SDL_TextureScaleMode_Fast),
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    86
     11,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    87
     {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    88
      SDL_PixelFormat_Index8,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    89
      SDL_PixelFormat_RGB555,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    90
      SDL_PixelFormat_RGB565,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    91
      SDL_PixelFormat_RGB888,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    92
      SDL_PixelFormat_BGR888,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    93
      SDL_PixelFormat_ARGB8888,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    94
      SDL_PixelFormat_RGBA8888,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    95
      SDL_PixelFormat_ABGR8888,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    96
      SDL_PixelFormat_BGRA8888,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    97
      SDL_PixelFormat_YUY2,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    98
      SDL_PixelFormat_UYVY},
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    99
     0,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   100
     0}
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   101
};
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   102
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   103
typedef struct
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   104
{
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   105
    HWND hwnd;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   106
    HDC window_hdc;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   107
    HDC render_hdc;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   108
    HDC memory_hdc;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   109
    HDC current_hdc;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   110
    LPBITMAPINFO bmi;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   111
    HBITMAP window_bmp;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   112
    void *window_pixels;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   113
    int window_pitch;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   114
} SDL_GDI_RenderData;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   115
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   116
typedef struct
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   117
{
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   118
    SDL_SW_YUVTexture *yuv;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   119
    Uint32 format;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   120
    HPALETTE hpal;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   121
    HBITMAP hbm;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   122
    void *pixels;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   123
    int pitch;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   124
} SDL_GDI_TextureData;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   125
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   126
static void
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   127
UpdateYUVTextureData(SDL_Texture * texture)
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   128
{
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   129
    SDL_GDI_TextureData *data = (SDL_GDI_TextureData *) texture->driverdata;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   130
    SDL_Rect rect;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   131
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   132
    rect.x = 0;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   133
    rect.y = 0;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   134
    rect.w = texture->w;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   135
    rect.h = texture->h;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   136
    SDL_SW_CopyYUVToRGB(data->yuv, &rect, data->format, texture->w,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   137
                        texture->h, data->pixels, data->pitch);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   138
}
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   139
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   140
void
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   141
GDI_AddRenderDriver(_THIS)
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   142
{
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   143
    SDL_AddRenderDriver(0, &SDL_GDI_RenderDriver);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   144
}
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   145
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   146
SDL_Renderer *
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   147
SDL_GDI_CreateRenderer(SDL_Window * window, Uint32 flags)
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   148
{
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   149
    SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   150
    SDL_Renderer *renderer;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   151
    SDL_GDI_RenderData *data;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   152
    int bmi_size;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   153
    HBITMAP hbm;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   154
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   155
    renderer = (SDL_Renderer *) SDL_malloc(sizeof(*renderer));
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   156
    if (!renderer) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   157
        SDL_OutOfMemory();
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   158
        return NULL;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   159
    }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   160
    SDL_zerop(renderer);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   161
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   162
    data = (SDL_GDI_RenderData *) SDL_malloc(sizeof(*data));
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   163
    if (!data) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   164
        SDL_GDI_DestroyRenderer(renderer);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   165
        SDL_OutOfMemory();
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   166
        return NULL;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   167
    }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   168
    SDL_zerop(data);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   169
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   170
    data->hwnd = windowdata->hwnd;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   171
    data->window_hdc = GetDC(data->hwnd);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   172
    data->render_hdc = CreateCompatibleDC(data->window_hdc);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   173
    data->memory_hdc = CreateCompatibleDC(data->window_hdc);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   174
    data->current_hdc = data->window_hdc;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   175
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   176
    /* Fill in the compatible bitmap info */
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   177
    bmi_size = sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   178
    data->bmi = (LPBITMAPINFO) SDL_malloc(bmi_size);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   179
    if (!data->bmi) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   180
        SDL_GDI_DestroyRenderer(renderer);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   181
        SDL_OutOfMemory();
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   182
        return NULL;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   183
    }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   184
    SDL_memset(data->bmi, 0, bmi_size);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   185
    data->bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   186
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   187
    hbm = CreateCompatibleBitmap(data->window_hdc, 1, 1);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   188
    GetDIBits(data->window_hdc, hbm, 0, 1, NULL, data->bmi, DIB_RGB_COLORS);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   189
    GetDIBits(data->window_hdc, hbm, 0, 1, NULL, data->bmi, DIB_RGB_COLORS);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   190
    DeleteObject(hbm);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   191
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   192
    renderer->CreateTexture = SDL_GDI_CreateTexture;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   193
    renderer->QueryTexturePixels = SDL_GDI_QueryTexturePixels;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   194
    renderer->SetTexturePalette = SDL_GDI_SetTexturePalette;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   195
    renderer->GetTexturePalette = SDL_GDI_GetTexturePalette;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   196
    renderer->UpdateTexture = SDL_GDI_UpdateTexture;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   197
    renderer->LockTexture = SDL_GDI_LockTexture;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   198
    renderer->UnlockTexture = SDL_GDI_UnlockTexture;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   199
    renderer->DirtyTexture = SDL_GDI_DirtyTexture;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   200
    renderer->SelectRenderTexture = SDL_GDI_SelectRenderTexture;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   201
    renderer->RenderFill = SDL_GDI_RenderFill;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   202
    renderer->RenderCopy = SDL_GDI_RenderCopy;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   203
    renderer->RenderReadPixels = SDL_GDI_RenderReadPixels;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   204
    renderer->RenderWritePixels = SDL_GDI_RenderWritePixels;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   205
    renderer->RenderPresent = SDL_GDI_RenderPresent;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   206
    renderer->DestroyTexture = SDL_GDI_DestroyTexture;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   207
    renderer->DestroyRenderer = SDL_GDI_DestroyRenderer;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   208
    renderer->info = SDL_GDI_RenderDriver.info;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   209
    renderer->window = window->id;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   210
    renderer->driverdata = data;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   211
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   212
    renderer->info.flags = SDL_Renderer_RenderTarget;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   213
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   214
    return renderer;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   215
}
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   216
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   217
static int
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   218
SDL_GDI_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   219
{
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   220
    SDL_GDI_RenderData *renderdata =
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   221
        (SDL_GDI_RenderData *) renderer->driverdata;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   222
    SDL_Window *window = SDL_GetWindowFromID(renderer->window);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   223
    SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   224
    SDL_GDI_TextureData *data;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   225
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   226
    data = (SDL_GDI_TextureData *) SDL_malloc(sizeof(*data));
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   227
    if (!data) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   228
        SDL_OutOfMemory();
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   229
        return -1;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   230
    }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   231
    SDL_zerop(data);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   232
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   233
    texture->driverdata = data;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   234
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   235
    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   236
        if (texture->access == SDL_TextureAccess_Render) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   237
            SDL_SetError("Rendering to YUV format textures is not supported");
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   238
            return -1;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   239
        }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   240
        data->yuv = SDL_SW_CreateYUVTexture(texture);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   241
        if (!data->yuv) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   242
            SDL_GDI_DestroyTexture(renderer, texture);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   243
            return -1;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   244
        }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   245
        data->format = display->current_mode.format;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   246
    } else {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   247
        data->format = texture->format;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   248
    }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   249
    data->pitch = (texture->w * SDL_BYTESPERPIXEL(data->format));
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   250
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   251
    if (data->yuv || texture->access == SDL_TextureAccess_Local
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   252
        || texture->format != SDL_GetCurrentDisplayMode()->format) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   253
        int bmi_size;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   254
        LPBITMAPINFO bmi;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   255
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   256
        bmi_size = sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   257
        bmi = (LPBITMAPINFO) SDL_malloc(bmi_size);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   258
        if (!bmi) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   259
            SDL_GDI_DestroyTexture(renderer, texture);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   260
            SDL_OutOfMemory();
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   261
            return -1;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   262
        }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   263
        SDL_memset(bmi, 0, bmi_size);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   264
        bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   265
        bmi->bmiHeader.biWidth = texture->w;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   266
        bmi->bmiHeader.biHeight = -texture->h;  /* topdown bitmap */
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   267
        bmi->bmiHeader.biPlanes = 1;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   268
        bmi->bmiHeader.biSizeImage = texture->h * data->pitch;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   269
        bmi->bmiHeader.biXPelsPerMeter = 0;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   270
        bmi->bmiHeader.biYPelsPerMeter = 0;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   271
        bmi->bmiHeader.biClrUsed = 0;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   272
        bmi->bmiHeader.biClrImportant = 0;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   273
        bmi->bmiHeader.biBitCount = SDL_BYTESPERPIXEL(data->format) * 8;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   274
        if (SDL_ISPIXELFORMAT_INDEXED(data->format)) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   275
            int i, ncolors;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   276
            LOGPALETTE *palette;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   277
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   278
            bmi->bmiHeader.biCompression = BI_RGB;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   279
            ncolors = (1 << SDL_BITSPERPIXEL(data->format));
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   280
            palette =
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   281
                (LOGPALETTE *) SDL_malloc(sizeof(*palette) +
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   282
                                          ncolors * sizeof(PALETTEENTRY));
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   283
            if (!palette) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   284
                SDL_free(bmi);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   285
                SDL_GDI_DestroyTexture(renderer, texture);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   286
                SDL_OutOfMemory();
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   287
                return -1;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   288
            }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   289
            palette->palVersion = 0x300;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   290
            palette->palNumEntries = ncolors;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   291
            for (i = 0; i < ncolors; ++i) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   292
                palette->palPalEntry[i].peRed = 0xFF;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   293
                palette->palPalEntry[i].peGreen = 0xFF;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   294
                palette->palPalEntry[i].peBlue = 0xFF;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   295
                palette->palPalEntry[i].peFlags = 0;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   296
            }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   297
            data->hpal = CreatePalette(palette);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   298
            SDL_free(palette);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   299
        } else {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   300
            int bpp;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   301
            Uint32 Rmask, Gmask, Bmask, Amask;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   302
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   303
            bmi->bmiHeader.biCompression = BI_BITFIELDS;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   304
            SDL_PixelFormatEnumToMasks(data->format, &bpp, &Rmask, &Gmask,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   305
                                       &Bmask, &Amask);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   306
            ((Uint32 *) bmi->bmiColors)[0] = Rmask;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   307
            ((Uint32 *) bmi->bmiColors)[1] = Gmask;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   308
            ((Uint32 *) bmi->bmiColors)[2] = Bmask;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   309
            data->hpal = NULL;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   310
        }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   311
        data->hbm =
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   312
            CreateDIBSection(renderdata->memory_hdc, bmi, DIB_RGB_COLORS,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   313
                             &data->pixels, NULL, 0);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   314
    } else {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   315
        data->hbm =
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   316
            CreateCompatibleBitmap(renderdata->window_hdc, texture->w,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   317
                                   texture->h);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   318
        data->pixels = NULL;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   319
    }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   320
    if (!data->hbm) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   321
        SDL_GDI_DestroyTexture(renderer, texture);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   322
        WIN_SetError("Couldn't create bitmap");
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   323
        return -1;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   324
    }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   325
    return 0;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   326
}
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   327
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   328
static int
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   329
SDL_GDI_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   330
                           void **pixels, int *pitch)
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   331
{
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   332
    SDL_GDI_TextureData *data = (SDL_GDI_TextureData *) texture->driverdata;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   333
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   334
    if (data->yuv) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   335
        return SDL_SW_QueryYUVTexturePixels(data->yuv, pixels, pitch);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   336
    } else {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   337
        *pixels = data->pixels;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   338
        *pitch = texture->w * SDL_BYTESPERPIXEL(texture->format);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   339
        return 0;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   340
    }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   341
}
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   342
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   343
static int
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   344
SDL_GDI_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   345
                          const SDL_Color * colors, int firstcolor,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   346
                          int ncolors)
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   347
{
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   348
    SDL_GDI_RenderData *renderdata =
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   349
        (SDL_GDI_RenderData *) renderer->driverdata;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   350
    SDL_GDI_TextureData *data = (SDL_GDI_TextureData *) texture->driverdata;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   351
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   352
    if (data->yuv) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   353
        SDL_SetError("YUV textures don't have a palette");
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   354
        return -1;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   355
    } else {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   356
        PALETTEENTRY entries[256];
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   357
        int i;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   358
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   359
        for (i = 0; i < ncolors; ++i) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   360
            entries[i].peRed = colors[i].r;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   361
            entries[i].peGreen = colors[i].g;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   362
            entries[i].peBlue = colors[i].b;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   363
            entries[i].peFlags = 0;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   364
        }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   365
        if (!SetPaletteEntries(data->hpal, firstcolor, ncolors, entries)) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   366
            WIN_SetError("SetPaletteEntries()");
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   367
            return -1;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   368
        }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   369
        return 0;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   370
    }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   371
}
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   372
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   373
static int
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   374
SDL_GDI_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   375
                          SDL_Color * colors, int firstcolor, int ncolors)
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   376
{
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   377
    SDL_GDI_TextureData *data = (SDL_GDI_TextureData *) texture->driverdata;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   378
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   379
    if (data->yuv) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   380
        SDL_SetError("YUV textures don't have a palette");
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   381
        return -1;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   382
    } else {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   383
        PALETTEENTRY entries[256];
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   384
        int i;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   385
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   386
        if (!GetPaletteEntries(data->hpal, firstcolor, ncolors, entries)) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   387
            WIN_SetError("GetPaletteEntries()");
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   388
            return -1;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   389
        }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   390
        for (i = 0; i < ncolors; ++i) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   391
            colors[i].r = entries[i].peRed;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   392
            colors[i].g = entries[i].peGreen;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   393
            colors[i].b = entries[i].peBlue;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   394
        }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   395
        return 0;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   396
    }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   397
}
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   398
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   399
static int
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   400
SDL_GDI_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   401
                      const SDL_Rect * rect, const void *pixels, int pitch)
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   402
{
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   403
    SDL_GDI_TextureData *data = (SDL_GDI_TextureData *) texture->driverdata;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   404
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   405
    if (data->yuv) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   406
        if (SDL_SW_UpdateYUVTexture(data->yuv, rect, pixels, pitch) < 0) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   407
            return -1;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   408
        }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   409
        UpdateYUVTextureData(texture);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   410
        return 0;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   411
    } else {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   412
        SDL_GDI_RenderData *renderdata =
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   413
            (SDL_GDI_RenderData *) renderer->driverdata;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   414
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   415
        if (data->pixels) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   416
            Uint8 *src, *dst;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   417
            int row;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   418
            size_t length;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   419
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   420
            src = (Uint8 *) pixels;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   421
            dst =
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   422
                (Uint8 *) data->pixels + rect->y * data->pitch +
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   423
                rect->x * SDL_BYTESPERPIXEL(texture->format);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   424
            length = rect->w * SDL_BYTESPERPIXEL(texture->format);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   425
            for (row = 0; row < rect->h; ++row) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   426
                SDL_memcpy(dst, src, length);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   427
                src += pitch;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   428
                dst += data->pitch;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   429
            }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   430
        } else if (rect->w == texture->w && pitch == data->pitch) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   431
            if (!SetDIBits
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   432
                (renderdata->window_hdc, data->hbm, rect->y, rect->h, pixels,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   433
                 renderdata->bmi, DIB_RGB_COLORS)) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   434
                WIN_SetError("SetDIBits()");
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   435
                return -1;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   436
            }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   437
        } else {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   438
            SDL_SetError
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   439
                ("FIXME: Need to allocate temporary memory and do GetDIBits() followed by SetDIBits(), since we can only set blocks of scanlines at a time");
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   440
            return -1;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   441
        }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   442
        return 0;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   443
    }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   444
}
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   445
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   446
static int
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   447
SDL_GDI_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   448
                    const SDL_Rect * rect, int markDirty, void **pixels,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   449
                    int *pitch)
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   450
{
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   451
    SDL_GDI_TextureData *data = (SDL_GDI_TextureData *) texture->driverdata;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   452
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   453
    if (data->yuv) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   454
        return SDL_SW_LockYUVTexture(data->yuv, rect, markDirty, pixels,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   455
                                     pitch);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   456
    } else {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   457
        GdiFlush();
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   458
        *pixels =
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   459
            (void *) ((Uint8 *) data->pixels + rect->y * data->pitch +
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   460
                      rect->x * SDL_BYTESPERPIXEL(texture->format));
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   461
        *pitch = data->pitch;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   462
        return 0;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   463
    }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   464
}
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   465
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   466
static void
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   467
SDL_GDI_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   468
{
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   469
    SDL_GDI_TextureData *data = (SDL_GDI_TextureData *) texture->driverdata;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   470
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   471
    if (data->yuv) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   472
        SDL_SW_UnlockYUVTexture(data->yuv);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   473
        UpdateYUVTextureData(texture);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   474
    }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   475
}
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   476
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   477
static void
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   478
SDL_GDI_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   479
                     int numrects, const SDL_Rect * rects)
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   480
{
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   481
}
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   482
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   483
static void
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   484
SDL_GDI_SelectRenderTexture(SDL_Renderer * renderer, SDL_Texture * texture)
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   485
{
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   486
    SDL_GDI_RenderData *data = (SDL_GDI_RenderData *) renderer->driverdata;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   487
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   488
    if (texture) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   489
        SDL_GDI_TextureData *texturedata =
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   490
            (SDL_GDI_TextureData *) texture->driverdata;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   491
        SelectObject(data->render_hdc, texturedata->hbm);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   492
        if (texturedata->hpal) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   493
            SelectPalette(data->render_hdc, texturedata->hpal, TRUE);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   494
            RealizePalette(data->render_hdc);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   495
        }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   496
        data->current_hdc = data->render_hdc;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   497
    } else {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   498
        data->current_hdc = data->current_hdc;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   499
    }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   500
}
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   501
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   502
static int
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   503
SDL_GDI_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   504
                   Uint32 color)
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   505
{
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   506
    SDL_GDI_RenderData *data = (SDL_GDI_RenderData *) renderer->driverdata;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   507
    Uint8 r, g, b;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   508
    RECT rc;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   509
    static HBRUSH brush;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   510
    int status;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   511
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   512
    r = (Uint8) ((color >> 16) & 0xFF);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   513
    g = (Uint8) ((color >> 8) & 0xFF);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   514
    b = (Uint8) (color & 0xFF);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   515
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   516
    rc.left = rect->x;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   517
    rc.top = rect->y;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   518
    rc.right = rect->x + rect->w + 1;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   519
    rc.bottom = rect->y + rect->h + 1;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   520
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   521
    /* Should we cache the brushes? .. it looks like GDI does for us. :) */
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   522
    brush = CreateSolidBrush(RGB(r, g, b));
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   523
    SelectObject(data->current_hdc, brush);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   524
    status = FillRect(data->current_hdc, &rc, brush);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   525
    DeleteObject(brush);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   526
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   527
    if (!status) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   528
        WIN_SetError("FillRect()");
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   529
        return -1;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   530
    }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   531
    return 0;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   532
}
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   533
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   534
static int
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   535
SDL_GDI_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   536
                   const SDL_Rect * srcrect, const SDL_Rect * dstrect,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   537
                   int blendMode, int scaleMode)
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   538
{
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   539
    SDL_GDI_RenderData *data = (SDL_GDI_RenderData *) renderer->driverdata;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   540
    SDL_GDI_TextureData *texturedata =
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   541
        (SDL_GDI_TextureData *) texture->driverdata;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   542
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   543
    SelectObject(data->memory_hdc, texturedata->hbm);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   544
    if (texturedata->hpal) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   545
        SelectPalette(data->memory_hdc, texturedata->hpal, TRUE);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   546
        RealizePalette(data->memory_hdc);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   547
    }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   548
    if (blendMode & (SDL_TextureBlendMode_Mask | SDL_TextureBlendMode_Blend)) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   549
        static BLENDFUNCTION blendFunc = {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   550
            AC_SRC_OVER,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   551
            0,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   552
            255,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   553
            AC_SRC_ALPHA
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   554
        };
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   555
        /* FIXME: GDI uses premultiplied alpha! */
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   556
        if (!AlphaBlend
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   557
            (data->current_hdc, dstrect->x, dstrect->y, dstrect->w,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   558
             dstrect->h, data->memory_hdc, srcrect->x, srcrect->y, srcrect->w,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   559
             srcrect->h, blendFunc)) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   560
            WIN_SetError("AlphaBlend()");
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   561
            return -1;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   562
        }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   563
    } else {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   564
        if (srcrect->w == dstrect->w && srcrect->h == dstrect->h) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   565
            if (!BitBlt
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   566
                (data->current_hdc, dstrect->x, dstrect->y, dstrect->w,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   567
                 srcrect->h, data->memory_hdc, srcrect->x, srcrect->y,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   568
                 SRCCOPY)) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   569
                WIN_SetError("BitBlt()");
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   570
                return -1;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   571
            }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   572
        } else {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   573
            if (!StretchBlt
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   574
                (data->current_hdc, dstrect->x, dstrect->y, dstrect->w,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   575
                 dstrect->h, data->memory_hdc, srcrect->x, srcrect->y,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   576
                 srcrect->w, srcrect->h, SRCCOPY)) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   577
                WIN_SetError("StretchBlt()");
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   578
                return -1;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   579
            }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   580
        }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   581
    }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   582
    return 0;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   583
}
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   584
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   585
static int
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   586
CreateWindowDIB(SDL_GDI_RenderData * data, SDL_Window * window)
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   587
{
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   588
    data->window_pitch = window->w * (data->bmi->bmiHeader.biBitCount / 8);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   589
    data->bmi->bmiHeader.biWidth = window->w;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   590
    data->bmi->bmiHeader.biHeight = -window->h;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   591
    data->bmi->bmiHeader.biSizeImage =
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   592
        window->h * (data->bmi->bmiHeader.biBitCount / 8);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   593
    data->window_bmp =
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   594
        CreateDIBSection(data->window_hdc, data->bmi, DIB_RGB_COLORS,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   595
                         &data->window_pixels, NULL, 0);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   596
    if (!data->window_bmp) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   597
        WIN_SetError("CreateDIBSection()");
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   598
        return -1;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   599
    }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   600
    return 0;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   601
}
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   602
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   603
static int
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   604
SDL_GDI_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   605
                         void *pixels, int pitch)
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   606
{
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   607
    SDL_Window *window = SDL_GetWindowFromID(renderer->window);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   608
    SDL_GDI_RenderData *data = (SDL_GDI_RenderData *) renderer->driverdata;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   609
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   610
    if (!data->window_bmp) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   611
        if (CreateWindowDIB(data, window) < 0) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   612
            return -1;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   613
        }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   614
    }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   615
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   616
    SelectObject(data->memory_hdc, data->window_bmp);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   617
    BitBlt(data->memory_hdc, rect->x, rect->y, rect->w, rect->h,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   618
           data->window_hdc, rect->x, rect->y, SRCCOPY);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   619
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   620
    {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   621
        int bpp = data->bmi->bmiHeader.biBitCount / 8;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   622
        Uint8 *src =
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   623
            (Uint8 *) data->window_pixels + rect->y * data->window_pitch +
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   624
            rect->x * bpp;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   625
        Uint8 *dst = (Uint8 *) pixels;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   626
        int row;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   627
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   628
        for (row = 0; row < rect->h; ++row) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   629
            SDL_memcpy(dst, src, rect->w * bpp);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   630
            src += data->window_pitch;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   631
            dst += pitch;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   632
        }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   633
    }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   634
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   635
    return 0;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   636
}
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   637
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   638
static int
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   639
SDL_GDI_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   640
                          const void *pixels, int pitch)
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   641
{
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   642
    SDL_Window *window = SDL_GetWindowFromID(renderer->window);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   643
    SDL_GDI_RenderData *data = (SDL_GDI_RenderData *) renderer->driverdata;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   644
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   645
    if (!data->window_bmp) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   646
        if (CreateWindowDIB(data, window) < 0) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   647
            return -1;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   648
        }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   649
    }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   650
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   651
    {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   652
        int bpp = data->bmi->bmiHeader.biBitCount / 8;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   653
        Uint8 *src = (Uint8 *) pixels;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   654
        Uint8 *dst =
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   655
            (Uint8 *) data->window_pixels + rect->y * data->window_pitch +
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   656
            rect->x * bpp;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   657
        int row;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   658
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   659
        for (row = 0; row < rect->h; ++row) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   660
            SDL_memcpy(dst, src, rect->w * bpp);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   661
            src += pitch;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   662
            dst += data->window_pitch;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   663
        }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   664
    }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   665
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   666
    SelectObject(data->memory_hdc, data->window_bmp);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   667
    BitBlt(data->window_hdc, rect->x, rect->y, rect->w, rect->h,
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   668
           data->memory_hdc, rect->x, rect->y, SRCCOPY);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   669
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   670
    return 0;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   671
}
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   672
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   673
static void
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   674
SDL_GDI_RenderPresent(SDL_Renderer * renderer)
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   675
{
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   676
}
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   677
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   678
static void
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   679
SDL_GDI_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   680
{
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   681
    SDL_GDI_TextureData *data = (SDL_GDI_TextureData *) texture->driverdata;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   682
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   683
    if (!data) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   684
        return;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   685
    }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   686
    if (data->yuv) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   687
        SDL_SW_DestroyYUVTexture(data->yuv);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   688
    }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   689
    if (data->hpal) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   690
        DeleteObject(data->hpal);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   691
    }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   692
    if (data->hbm) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   693
        DeleteObject(data->hbm);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   694
    }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   695
    SDL_free(data);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   696
    texture->driverdata = NULL;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   697
}
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   698
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   699
void
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   700
SDL_GDI_DestroyRenderer(SDL_Renderer * renderer)
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   701
{
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   702
    SDL_GDI_RenderData *data = (SDL_GDI_RenderData *) renderer->driverdata;
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   703
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   704
    if (data) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   705
        ReleaseDC(data->hwnd, data->window_hdc);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   706
        DeleteDC(data->render_hdc);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   707
        DeleteDC(data->memory_hdc);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   708
        if (data->bmi) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   709
            SDL_free(data->bmi);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   710
        }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   711
        if (data->window_bmp) {
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   712
            DeleteObject(data->window_bmp);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   713
        }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   714
        SDL_free(data);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   715
    }
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   716
    SDL_free(renderer);
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   717
}
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   718
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   719
#endif /* SDL_VIDEO_RENDER_GDI */
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   720
e70477157db9 Starting support for Direct3D render driver.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   721
/* vi: set ts=4 sw=4 expandtab: */