More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
authorSam Lantinga <slouken@libsdl.org>
Fri, 14 Jul 2006 06:40:53 +0000
changeset 1903f132024010be
parent 1902 eb2891493b66
child 1904 1a713f9d1f71
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
include/SDL_config_win32.h
include/SDL_stdinc.h
src/audio/SDL_audio.c
src/stdlib/SDL_string.c
src/video/win32/SDL_d3drender.c
src/video/win32/SDL_gdirender.c
test/testsprite2.c
     1.1 --- a/include/SDL_config_win32.h	Thu Jul 13 08:15:35 2006 +0000
     1.2 +++ b/include/SDL_config_win32.h	Fri Jul 14 06:40:53 2006 +0000
     1.3 @@ -64,7 +64,7 @@
     1.4  #define SDL_HAS_64BIT_TYPE	1
     1.5  
     1.6  /* Enabled for SDL 1.2 (binary compatibility) */
     1.7 -//#define HAVE_LIBC	1
     1.8 +//#define HAVE_LIBC     1
     1.9  #ifdef HAVE_LIBC
    1.10  /* Useful headers */
    1.11  #define HAVE_STDIO_H 1
     2.1 --- a/include/SDL_stdinc.h	Thu Jul 13 08:15:35 2006 +0000
     2.2 +++ b/include/SDL_stdinc.h	Fri Jul 14 06:40:53 2006 +0000
     2.3 @@ -416,7 +416,7 @@
     2.4  #ifdef HAVE_WCSLEN
     2.5  #define SDL_wcslen      wcslen
     2.6  #else
     2.7 -extern DECLSPEC size_t SDLCALL SDL_wcslen(const wchar_t *string);
     2.8 +extern DECLSPEC size_t SDLCALL SDL_wcslen(const wchar_t * string);
     2.9  #endif
    2.10  
    2.11  #ifdef HAVE_STRLCPY
     3.1 --- a/src/audio/SDL_audio.c	Thu Jul 13 08:15:35 2006 +0000
     3.2 +++ b/src/audio/SDL_audio.c	Fri Jul 14 06:40:53 2006 +0000
     3.3 @@ -497,7 +497,7 @@
     3.4      if (desired->channels == 0) {
     3.5          env = SDL_getenv("SDL_AUDIO_CHANNELS");
     3.6          if (env) {
     3.7 -            desired->channels = (Uint8)SDL_atoi(env);
     3.8 +            desired->channels = (Uint8) SDL_atoi(env);
     3.9          }
    3.10      }
    3.11      if (desired->channels == 0) {
    3.12 @@ -517,7 +517,7 @@
    3.13      if (desired->samples == 0) {
    3.14          env = SDL_getenv("SDL_AUDIO_SAMPLES");
    3.15          if (env) {
    3.16 -            desired->samples = (Uint16)SDL_atoi(env);
    3.17 +            desired->samples = (Uint16) SDL_atoi(env);
    3.18          }
    3.19      }
    3.20      if (desired->samples == 0) {
     4.1 --- a/src/stdlib/SDL_string.c	Thu Jul 13 08:15:35 2006 +0000
     4.2 +++ b/src/stdlib/SDL_string.c	Fri Jul 14 06:40:53 2006 +0000
     4.3 @@ -338,7 +338,7 @@
     4.4  
     4.5  #ifndef HAVE_WCSLEN
     4.6  size_t
     4.7 -SDL_wcslen(const wchar_t *string)
     4.8 +SDL_wcslen(const wchar_t * string)
     4.9  {
    4.10      size_t len = 0;
    4.11      while (*string++) {
     5.1 --- a/src/video/win32/SDL_d3drender.c	Thu Jul 13 08:15:35 2006 +0000
     5.2 +++ b/src/video/win32/SDL_d3drender.c	Fri Jul 14 06:40:53 2006 +0000
     5.3 @@ -24,7 +24,6 @@
     5.4  #if SDL_VIDEO_RENDER_D3D
     5.5  
     5.6  #include "SDL_win32video.h"
     5.7 -#include "../SDL_yuv_sw_c.h"
     5.8  
     5.9  /* Direct3D renderer implementation */
    5.10  
    5.11 @@ -32,9 +31,6 @@
    5.12                                              Uint32 flags);
    5.13  static int SDL_D3D_CreateTexture(SDL_Renderer * renderer,
    5.14                                   SDL_Texture * texture);
    5.15 -static int SDL_D3D_QueryTexturePixels(SDL_Renderer * renderer,
    5.16 -                                      SDL_Texture * texture, void **pixels,
    5.17 -                                      int *pitch);
    5.18  static int SDL_D3D_SetTexturePalette(SDL_Renderer * renderer,
    5.19                                       SDL_Texture * texture,
    5.20                                       const SDL_Color * colors, int firstcolor,
    5.21 @@ -85,19 +81,20 @@
    5.22       (SDL_TextureBlendMode_None |
    5.23        SDL_TextureBlendMode_Mask | SDL_TextureBlendMode_Blend),
    5.24       (SDL_TextureScaleMode_None | SDL_TextureScaleMode_Fast),
    5.25 -     11,
    5.26 +     12,
    5.27       {
    5.28        SDL_PixelFormat_Index8,
    5.29 +      SDL_PixelFormat_RGB332,
    5.30 +      SDL_PixelFormat_RGB444,
    5.31        SDL_PixelFormat_RGB555,
    5.32 +      SDL_PixelFormat_ARGB4444,
    5.33 +      SDL_PixelFormat_ARGB1555,
    5.34        SDL_PixelFormat_RGB565,
    5.35        SDL_PixelFormat_RGB888,
    5.36 -      SDL_PixelFormat_BGR888,
    5.37        SDL_PixelFormat_ARGB8888,
    5.38 -      SDL_PixelFormat_RGBA8888,
    5.39 -      SDL_PixelFormat_ABGR8888,
    5.40 -      SDL_PixelFormat_BGRA8888,
    5.41 -      SDL_PixelFormat_YUY2,
    5.42 -      SDL_PixelFormat_UYVY},
    5.43 +      SDL_PixelFormat_ARGB2101010,
    5.44 +      SDL_PixelFormat_UYVY,
    5.45 +      SDL_PixelFormat_YUY2},
    5.46       0,
    5.47       0}
    5.48  };
    5.49 @@ -110,9 +107,15 @@
    5.50  
    5.51  typedef struct
    5.52  {
    5.53 -    SDL_SW_YUVTexture *yuv;
    5.54 +    IDirect3DTexture9 *texture;
    5.55  } SDL_D3D_TextureData;
    5.56  
    5.57 +typedef struct
    5.58 +{
    5.59 +    float x, y, z;
    5.60 +    float tu, tv;
    5.61 +} Vertex;
    5.62 +
    5.63  static void
    5.64  D3D_SetError(const char *prefix, HRESULT result)
    5.65  {
    5.66 @@ -192,18 +195,37 @@
    5.67      SDL_SetError("%s: %s", prefix, error);
    5.68  }
    5.69  
    5.70 -static void
    5.71 -UpdateYUVTextureData(SDL_Texture * texture)
    5.72 +static D3DFORMAT
    5.73 +PixelFormatToD3DFMT(Uint32 format)
    5.74  {
    5.75 -    SDL_D3D_TextureData *data = (SDL_D3D_TextureData *) texture->driverdata;
    5.76 -    SDL_Rect rect;
    5.77 -
    5.78 -    rect.x = 0;
    5.79 -    rect.y = 0;
    5.80 -    rect.w = texture->w;
    5.81 -    rect.h = texture->h;
    5.82 -    //SDL_SW_CopyYUVToRGB(data->yuv, &rect, data->format, texture->w,
    5.83 -    //                    texture->h, data->pixels, data->pitch);
    5.84 +    switch (format) {
    5.85 +    case SDL_PixelFormat_Index8:
    5.86 +        return D3DFMT_P8;
    5.87 +    case SDL_PixelFormat_RGB332:
    5.88 +        return D3DFMT_R3G3B2;
    5.89 +    case SDL_PixelFormat_RGB444:
    5.90 +        return D3DFMT_X4R4G4B4;
    5.91 +    case SDL_PixelFormat_RGB555:
    5.92 +        return D3DFMT_X1R5G5B5;
    5.93 +    case SDL_PixelFormat_ARGB4444:
    5.94 +        return D3DFMT_A4R4G4B4;
    5.95 +    case SDL_PixelFormat_ARGB1555:
    5.96 +        return D3DFMT_A1R5G5B5;
    5.97 +    case SDL_PixelFormat_RGB565:
    5.98 +        return D3DFMT_R5G6B5;
    5.99 +    case SDL_PixelFormat_RGB888:
   5.100 +        return D3DFMT_X8R8G8B8;
   5.101 +    case SDL_PixelFormat_ARGB8888:
   5.102 +        return D3DFMT_A8R8G8B8;
   5.103 +    case SDL_PixelFormat_ARGB2101010:
   5.104 +        return D3DFMT_A2R10G10B10;
   5.105 +    case SDL_PixelFormat_UYVY:
   5.106 +        return D3DFMT_UYVY;
   5.107 +    case SDL_PixelFormat_YUY2:
   5.108 +        return D3DFMT_YUY2;
   5.109 +    default:
   5.110 +        return D3DFMT_UNKNOWN;
   5.111 +    }
   5.112  }
   5.113  
   5.114  void
   5.115 @@ -243,7 +265,6 @@
   5.116      SDL_zerop(data);
   5.117  
   5.118      renderer->CreateTexture = SDL_D3D_CreateTexture;
   5.119 -    renderer->QueryTexturePixels = SDL_D3D_QueryTexturePixels;
   5.120      renderer->SetTexturePalette = SDL_D3D_SetTexturePalette;
   5.121      renderer->GetTexturePalette = SDL_D3D_GetTexturePalette;
   5.122      renderer->UpdateTexture = SDL_D3D_UpdateTexture;
   5.123 @@ -267,7 +288,12 @@
   5.124      SDL_zero(pparams);
   5.125      pparams.BackBufferWidth = window->w;
   5.126      pparams.BackBufferHeight = window->h;
   5.127 -    pparams.BackBufferFormat = D3DFMT_UNKNOWN;  /* FIXME */
   5.128 +    if (window->flags & SDL_WINDOW_FULLSCREEN) {
   5.129 +        pparams.BackBufferFormat =
   5.130 +            PixelFormatToD3DFMT(display->fullscreen_mode->format);
   5.131 +    } else {
   5.132 +        pparams.BackBufferFormat = D3DFMT_UNKNOWN;
   5.133 +    }
   5.134      if (flags & SDL_Renderer_PresentFlip2) {
   5.135          pparams.BackBufferCount = 2;
   5.136          pparams.SwapEffect = D3DSWAPEFFECT_FLIP;
   5.137 @@ -283,10 +309,12 @@
   5.138      }
   5.139      if (window->flags & SDL_WINDOW_FULLSCREEN) {
   5.140          pparams.Windowed = FALSE;
   5.141 +        pparams.FullScreen_RefreshRateInHz =
   5.142 +            display->fullscreen_mode->refresh_rate;
   5.143      } else {
   5.144          pparams.Windowed = TRUE;
   5.145 +        pparams.FullScreen_RefreshRateInHz = 0;
   5.146      }
   5.147 -    pparams.FullScreen_RefreshRateInHz = 0;     /* FIXME */
   5.148      pparams.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
   5.149  
   5.150      result = IDirect3D9_CreateDevice(videodata->d3d, D3DADAPTER_DEFAULT,        /* FIXME */
   5.151 @@ -301,6 +329,11 @@
   5.152      }
   5.153      data->beginScene = SDL_TRUE;
   5.154  
   5.155 +    /* Set up parameters for rendering */
   5.156 +    IDirect3DDevice9_SetRenderState(data->device, D3DRS_CULLMODE,
   5.157 +                                    D3DCULL_NONE);
   5.158 +    IDirect3DDevice9_SetFVF(data->device, D3DFVF_XYZ | D3DFVF_TEX1);
   5.159 +
   5.160      return renderer;
   5.161  }
   5.162  
   5.163 @@ -312,6 +345,8 @@
   5.164      SDL_Window *window = SDL_GetWindowFromID(renderer->window);
   5.165      SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
   5.166      SDL_D3D_TextureData *data;
   5.167 +    D3DPOOL pool;
   5.168 +    HRESULT result;
   5.169  
   5.170      data = (SDL_D3D_TextureData *) SDL_malloc(sizeof(*data));
   5.171      if (!data) {
   5.172 @@ -322,23 +357,26 @@
   5.173  
   5.174      texture->driverdata = data;
   5.175  
   5.176 +    if (texture->access == SDL_TextureAccess_Local) {
   5.177 +        pool = D3DPOOL_MANAGED;
   5.178 +    } else {
   5.179 +        pool = D3DPOOL_DEFAULT;
   5.180 +    }
   5.181 +    result =
   5.182 +        IDirect3DDevice9_CreateTexture(renderdata->device, texture->w,
   5.183 +                                       texture->h, 1, 0,
   5.184 +                                       PixelFormatToD3DFMT(texture->format),
   5.185 +                                       pool, &data->texture, NULL);
   5.186 +    if (FAILED(result)) {
   5.187 +        SDL_free(data);
   5.188 +        D3D_SetError("CreateTexture()", result);
   5.189 +        return -1;
   5.190 +    }
   5.191 +
   5.192      return 0;
   5.193  }
   5.194  
   5.195  static int
   5.196 -SDL_D3D_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
   5.197 -                           void **pixels, int *pitch)
   5.198 -{
   5.199 -    SDL_D3D_TextureData *data = (SDL_D3D_TextureData *) texture->driverdata;
   5.200 -
   5.201 -    if (data->yuv) {
   5.202 -        return SDL_SW_QueryYUVTexturePixels(data->yuv, pixels, pitch);
   5.203 -    } else {
   5.204 -        return 0;
   5.205 -    }
   5.206 -}
   5.207 -
   5.208 -static int
   5.209  SDL_D3D_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
   5.210                            const SDL_Color * colors, int firstcolor,
   5.211                            int ncolors)
   5.212 @@ -347,12 +385,7 @@
   5.213          (SDL_D3D_RenderData *) renderer->driverdata;
   5.214      SDL_D3D_TextureData *data = (SDL_D3D_TextureData *) texture->driverdata;
   5.215  
   5.216 -    if (data->yuv) {
   5.217 -        SDL_SetError("YUV textures don't have a palette");
   5.218 -        return -1;
   5.219 -    } else {
   5.220 -        return 0;
   5.221 -    }
   5.222 +    return 0;
   5.223  }
   5.224  
   5.225  static int
   5.226 @@ -361,12 +394,7 @@
   5.227  {
   5.228      SDL_D3D_TextureData *data = (SDL_D3D_TextureData *) texture->driverdata;
   5.229  
   5.230 -    if (data->yuv) {
   5.231 -        SDL_SetError("YUV textures don't have a palette");
   5.232 -        return -1;
   5.233 -    } else {
   5.234 -        return 0;
   5.235 -    }
   5.236 +    return 0;
   5.237  }
   5.238  
   5.239  static int
   5.240 @@ -374,19 +402,59 @@
   5.241                        const SDL_Rect * rect, const void *pixels, int pitch)
   5.242  {
   5.243      SDL_D3D_TextureData *data = (SDL_D3D_TextureData *) texture->driverdata;
   5.244 +    SDL_D3D_RenderData *renderdata =
   5.245 +        (SDL_D3D_RenderData *) renderer->driverdata;
   5.246 +    IDirect3DTexture9 *temp;
   5.247 +    RECT d3drect;
   5.248 +    D3DLOCKED_RECT locked;
   5.249 +    const Uint8 *src;
   5.250 +    Uint8 *dst;
   5.251 +    int row, length;
   5.252 +    HRESULT result;
   5.253  
   5.254 -    if (data->yuv) {
   5.255 -        if (SDL_SW_UpdateYUVTexture(data->yuv, rect, pixels, pitch) < 0) {
   5.256 -            return -1;
   5.257 -        }
   5.258 -        UpdateYUVTextureData(texture);
   5.259 -        return 0;
   5.260 -    } else {
   5.261 -        SDL_D3D_RenderData *renderdata =
   5.262 -            (SDL_D3D_RenderData *) renderer->driverdata;
   5.263 +    result =
   5.264 +        IDirect3DDevice9_CreateTexture(renderdata->device, texture->w,
   5.265 +                                       texture->h, 1, 0,
   5.266 +                                       PixelFormatToD3DFMT(texture->format),
   5.267 +                                       D3DPOOL_SYSTEMMEM, &temp, NULL);
   5.268 +    if (FAILED(result)) {
   5.269 +        D3D_SetError("CreateTexture()", result);
   5.270 +        return -1;
   5.271 +    }
   5.272  
   5.273 -        return 0;
   5.274 +    d3drect.left = rect->x;
   5.275 +    d3drect.right = rect->x + rect->w;
   5.276 +    d3drect.top = rect->y;
   5.277 +    d3drect.bottom = rect->y + rect->h;
   5.278 +
   5.279 +    result = IDirect3DTexture9_LockRect(temp, 0, &locked, &d3drect, 0);
   5.280 +    if (FAILED(result)) {
   5.281 +        IDirect3DTexture9_Release(temp);
   5.282 +        D3D_SetError("LockRect()", result);
   5.283 +        return -1;
   5.284      }
   5.285 +
   5.286 +    src = pixels;
   5.287 +    dst = locked.pBits;
   5.288 +    length = rect->w * SDL_BYTESPERPIXEL(texture->format);
   5.289 +    for (row = 0; row < rect->h; ++row) {
   5.290 +        SDL_memcpy(dst, src, length);
   5.291 +        src += pitch;
   5.292 +        dst += locked.Pitch;
   5.293 +    }
   5.294 +    IDirect3DTexture9_UnlockRect(temp, 0);
   5.295 +
   5.296 +    result =
   5.297 +        IDirect3DDevice9_UpdateTexture(renderdata->device,
   5.298 +                                       (IDirect3DBaseTexture9 *) temp,
   5.299 +                                       (IDirect3DBaseTexture9 *) data->
   5.300 +                                       texture);
   5.301 +    IDirect3DTexture9_Release(temp);
   5.302 +    if (FAILED(result)) {
   5.303 +        D3D_SetError("UpdateTexture()", result);
   5.304 +        return -1;
   5.305 +    }
   5.306 +    return 0;
   5.307  }
   5.308  
   5.309  static int
   5.310 @@ -395,13 +463,30 @@
   5.311                      int *pitch)
   5.312  {
   5.313      SDL_D3D_TextureData *data = (SDL_D3D_TextureData *) texture->driverdata;
   5.314 +    RECT d3drect;
   5.315 +    D3DLOCKED_RECT locked;
   5.316 +    HRESULT result;
   5.317  
   5.318 -    if (data->yuv) {
   5.319 -        return SDL_SW_LockYUVTexture(data->yuv, rect, markDirty, pixels,
   5.320 -                                     pitch);
   5.321 -    } else {
   5.322 +    if (texture->access != SDL_TextureAccess_Local) {
   5.323 +        SDL_SetError("Can't lock remote video memory");
   5.324          return -1;
   5.325      }
   5.326 +
   5.327 +    d3drect.left = rect->x;
   5.328 +    d3drect.right = rect->x + rect->w;
   5.329 +    d3drect.top = rect->y;
   5.330 +    d3drect.bottom = rect->y + rect->h;
   5.331 +
   5.332 +    result =
   5.333 +        IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect,
   5.334 +                                   markDirty ? 0 : D3DLOCK_NO_DIRTY_UPDATE);
   5.335 +    if (FAILED(result)) {
   5.336 +        D3D_SetError("LockRect()", result);
   5.337 +        return -1;
   5.338 +    }
   5.339 +    *pixels = locked.pBits;
   5.340 +    *pitch = locked.Pitch;
   5.341 +    return 0;
   5.342  }
   5.343  
   5.344  static void
   5.345 @@ -409,16 +494,27 @@
   5.346  {
   5.347      SDL_D3D_TextureData *data = (SDL_D3D_TextureData *) texture->driverdata;
   5.348  
   5.349 -    if (data->yuv) {
   5.350 -        SDL_SW_UnlockYUVTexture(data->yuv);
   5.351 -        UpdateYUVTextureData(texture);
   5.352 -    }
   5.353 +    IDirect3DTexture9_UnlockRect(data->texture, 0);
   5.354  }
   5.355  
   5.356  static void
   5.357  SDL_D3D_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
   5.358                       int numrects, const SDL_Rect * rects)
   5.359  {
   5.360 +    SDL_D3D_TextureData *data = (SDL_D3D_TextureData *) texture->driverdata;
   5.361 +    RECT d3drect;
   5.362 +    int i;
   5.363 +
   5.364 +    for (i = 0; i < numrects; ++i) {
   5.365 +        const SDL_Rect *rect = &rects[i];
   5.366 +
   5.367 +        d3drect.left = rect->x;
   5.368 +        d3drect.right = rect->x + rect->w;
   5.369 +        d3drect.top = rect->y;
   5.370 +        d3drect.bottom = rect->y + rect->h;
   5.371 +
   5.372 +        IDirect3DTexture9_AddDirtyRect(data->texture, &d3drect);
   5.373 +    }
   5.374  }
   5.375  
   5.376  static void
   5.377 @@ -441,11 +537,13 @@
   5.378      }
   5.379  
   5.380      d3drect.x1 = rect->x;
   5.381 -    d3drect.x2 = rect->x+rect->w;
   5.382 +    d3drect.x2 = rect->x + rect->w;
   5.383      d3drect.y1 = rect->y;
   5.384 -    d3drect.y2 = rect->y+rect->h;
   5.385 +    d3drect.y2 = rect->y + rect->h;
   5.386  
   5.387 -    result = IDirect3DDevice9_Clear(data->device, 1, &d3drect, D3DCLEAR_TARGET, (D3DCOLOR) color, 1.0f, 0);
   5.388 +    result =
   5.389 +        IDirect3DDevice9_Clear(data->device, 1, &d3drect, D3DCLEAR_TARGET,
   5.390 +                               (D3DCOLOR) color, 1.0f, 0);
   5.391      if (FAILED(result)) {
   5.392          D3D_SetError("Clear()", result);
   5.393          return -1;
   5.394 @@ -461,11 +559,62 @@
   5.395      SDL_D3D_RenderData *data = (SDL_D3D_RenderData *) renderer->driverdata;
   5.396      SDL_D3D_TextureData *texturedata =
   5.397          (SDL_D3D_TextureData *) texture->driverdata;
   5.398 +    float minx, miny, maxx, maxy;
   5.399 +    float mintu, maxtu, mintv, maxtv;
   5.400 +    Vertex vertices[4];
   5.401 +    HRESULT result;
   5.402  
   5.403      if (data->beginScene) {
   5.404          IDirect3DDevice9_BeginScene(data->device);
   5.405          data->beginScene = SDL_FALSE;
   5.406      }
   5.407 +
   5.408 +    minx = (float) dstrect->x;
   5.409 +    miny = (float) dstrect->y;
   5.410 +    maxx = (float) dstrect->x + dstrect->w;
   5.411 +    maxy = (float) dstrect->y + dstrect->h;
   5.412 +
   5.413 +    mintu = (float) srcrect->x / texture->w;
   5.414 +    maxtu = (float) (srcrect->x + srcrect->w) / texture->w;
   5.415 +    mintv = (float) srcrect->y / texture->h;
   5.416 +    maxtv = (float) (srcrect->y + srcrect->h) / texture->h;
   5.417 +
   5.418 +    vertices[0].x = minx;
   5.419 +    vertices[0].y = miny;
   5.420 +    vertices[0].z = 0.0f;
   5.421 +    vertices[0].tu = mintu;
   5.422 +    vertices[0].tv = mintv;
   5.423 +    vertices[1].x = maxx;
   5.424 +    vertices[1].y = miny;
   5.425 +    vertices[1].z = 0.0f;
   5.426 +    vertices[1].tu = maxtu;
   5.427 +    vertices[1].tv = mintv;
   5.428 +    vertices[2].x = maxx;
   5.429 +    vertices[2].y = maxy;
   5.430 +    vertices[2].z = 0.0f;
   5.431 +    vertices[2].tu = maxtu;
   5.432 +    vertices[2].tv = maxtv;
   5.433 +    vertices[3].x = minx;
   5.434 +    vertices[3].y = maxy;
   5.435 +    vertices[3].z = 0.0f;
   5.436 +    vertices[3].tu = mintu;
   5.437 +    vertices[3].tv = maxtv;
   5.438 +
   5.439 +    result =
   5.440 +        IDirect3DDevice9_SetTexture(data->device, 0,
   5.441 +                                    (IDirect3DBaseTexture9 *) texturedata->
   5.442 +                                    texture);
   5.443 +    if (FAILED(result)) {
   5.444 +        D3D_SetError("SetTexture()", result);
   5.445 +        return -1;
   5.446 +    }
   5.447 +    result =
   5.448 +        IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_TRIANGLEFAN, 2,
   5.449 +                                         vertices, sizeof(*vertices));
   5.450 +    if (FAILED(result)) {
   5.451 +        D3D_SetError("DrawPrimitiveUP()", result);
   5.452 +        return -1;
   5.453 +    }
   5.454      return 0;
   5.455  }
   5.456  
   5.457 @@ -512,6 +661,9 @@
   5.458      if (!data) {
   5.459          return;
   5.460      }
   5.461 +    if (data->texture) {
   5.462 +        IDirect3DTexture9_Release(data->texture);
   5.463 +    }
   5.464      SDL_free(data);
   5.465      texture->driverdata = NULL;
   5.466  }
     6.1 --- a/src/video/win32/SDL_gdirender.c	Thu Jul 13 08:15:35 2006 +0000
     6.2 +++ b/src/video/win32/SDL_gdirender.c	Fri Jul 14 06:40:53 2006 +0000
     6.3 @@ -80,9 +80,9 @@
     6.4      {
     6.5       "gdi",
     6.6       (SDL_Renderer_Minimal |
     6.7 -         SDL_Renderer_SingleBuffer | SDL_Renderer_PresentCopy |
     6.8 -         SDL_Renderer_PresentFlip2 | SDL_Renderer_PresentFlip3 |
     6.9 -         SDL_Renderer_PresentDiscard | SDL_Renderer_RenderTarget),
    6.10 +      SDL_Renderer_SingleBuffer | SDL_Renderer_PresentCopy |
    6.11 +      SDL_Renderer_PresentFlip2 | SDL_Renderer_PresentFlip3 |
    6.12 +      SDL_Renderer_PresentDiscard | SDL_Renderer_RenderTarget),
    6.13       (SDL_TextureBlendMode_None | SDL_TextureBlendMode_Mask |
    6.14        SDL_TextureBlendMode_Blend),
    6.15       (SDL_TextureScaleMode_None | SDL_TextureScaleMode_Fast),
     7.1 --- a/test/testsprite2.c	Thu Jul 13 08:15:35 2006 +0000
     7.2 +++ b/test/testsprite2.c	Fri Jul 14 06:40:53 2006 +0000
     7.3 @@ -5,7 +5,7 @@
     7.4  
     7.5  #include "SDL.h"
     7.6  
     7.7 -#define NUM_WINDOWS 4
     7.8 +#define NUM_WINDOWS 1
     7.9  #define WINDOW_W    640
    7.10  #define WINDOW_H    480
    7.11  #define NUM_SPRITES	100
    7.12 @@ -91,10 +91,13 @@
    7.13  
    7.14      /* Move the sprite, bounce at the wall, and draw */
    7.15      n = 0;
    7.16 -    for (i = 0; i < num_sprites; ++i) {
    7.17 -        position = &positions[i];
    7.18 -        SDL_RenderFill(position, BACKGROUND);
    7.19 -    }
    7.20 +    SDL_RenderFill(NULL, BACKGROUND);
    7.21 +    /*
    7.22 +       for (i = 0; i < num_sprites; ++i) {
    7.23 +       position = &positions[i];
    7.24 +       SDL_RenderFill(position, BACKGROUND);
    7.25 +       }
    7.26 +     */
    7.27      for (i = 0; i < num_sprites; ++i) {
    7.28          position = &positions[i];
    7.29          velocity = &velocities[i];
    7.30 @@ -237,7 +240,8 @@
    7.31                  }
    7.32                  break;
    7.33              case SDL_KEYDOWN:
    7.34 -                /* Any keypress quits the app... */
    7.35 +                ///* Any keypress quits the app... */
    7.36 +                break;
    7.37              case SDL_QUIT:
    7.38                  done = 1;
    7.39                  break;