src/video/win32/SDL_d3drender.c
changeset 1913 83420da906a5
parent 1907 06c27a737b7a
child 1916 c773b0c0ac89
     1.1 --- a/src/video/win32/SDL_d3drender.c	Sun Jul 16 09:34:01 2006 +0000
     1.2 +++ b/src/video/win32/SDL_d3drender.c	Mon Jul 17 06:47:33 2006 +0000
     1.3 @@ -27,43 +27,37 @@
     1.4  
     1.5  /* Direct3D renderer implementation */
     1.6  
     1.7 -static SDL_Renderer *SDL_D3D_CreateRenderer(SDL_Window * window,
     1.8 -                                            Uint32 flags);
     1.9 -static int SDL_D3D_CreateTexture(SDL_Renderer * renderer,
    1.10 -                                 SDL_Texture * texture);
    1.11 -static int SDL_D3D_SetTexturePalette(SDL_Renderer * renderer,
    1.12 -                                     SDL_Texture * texture,
    1.13 -                                     const SDL_Color * colors, int firstcolor,
    1.14 -                                     int ncolors);
    1.15 -static int SDL_D3D_GetTexturePalette(SDL_Renderer * renderer,
    1.16 -                                     SDL_Texture * texture,
    1.17 -                                     SDL_Color * colors, int firstcolor,
    1.18 -                                     int ncolors);
    1.19 -static int SDL_D3D_UpdateTexture(SDL_Renderer * renderer,
    1.20 -                                 SDL_Texture * texture, const SDL_Rect * rect,
    1.21 -                                 const void *pixels, int pitch);
    1.22 -static int SDL_D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
    1.23 -                               const SDL_Rect * rect, int markDirty,
    1.24 -                               void **pixels, int *pitch);
    1.25 -static void SDL_D3D_UnlockTexture(SDL_Renderer * renderer,
    1.26 -                                  SDL_Texture * texture);
    1.27 -static void SDL_D3D_DirtyTexture(SDL_Renderer * renderer,
    1.28 -                                 SDL_Texture * texture, int numrects,
    1.29 -                                 const SDL_Rect * rects);
    1.30 -static int SDL_D3D_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect,
    1.31 -                              Uint32 color);
    1.32 -static int SDL_D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
    1.33 -                              const SDL_Rect * srcrect,
    1.34 -                              const SDL_Rect * dstrect, int blendMode,
    1.35 -                              int scaleMode);
    1.36 -static void SDL_D3D_RenderPresent(SDL_Renderer * renderer);
    1.37 -static void SDL_D3D_DestroyTexture(SDL_Renderer * renderer,
    1.38 -                                   SDL_Texture * texture);
    1.39 -static void SDL_D3D_DestroyRenderer(SDL_Renderer * renderer);
    1.40 +static SDL_Renderer *D3D_CreateRenderer(SDL_Window * window, Uint32 flags);
    1.41 +static int D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
    1.42 +static int D3D_SetTexturePalette(SDL_Renderer * renderer,
    1.43 +                                 SDL_Texture * texture,
    1.44 +                                 const SDL_Color * colors, int firstcolor,
    1.45 +                                 int ncolors);
    1.46 +static int D3D_GetTexturePalette(SDL_Renderer * renderer,
    1.47 +                                 SDL_Texture * texture, SDL_Color * colors,
    1.48 +                                 int firstcolor, int ncolors);
    1.49 +static int D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
    1.50 +                             const SDL_Rect * rect, const void *pixels,
    1.51 +                             int pitch);
    1.52 +static int D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
    1.53 +                           const SDL_Rect * rect, int markDirty,
    1.54 +                           void **pixels, int *pitch);
    1.55 +static void D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
    1.56 +static void D3D_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
    1.57 +                             int numrects, const SDL_Rect * rects);
    1.58 +static int D3D_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect,
    1.59 +                          Uint32 color);
    1.60 +static int D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
    1.61 +                          const SDL_Rect * srcrect, const SDL_Rect * dstrect,
    1.62 +                          int blendMode, int scaleMode);
    1.63 +static void D3D_RenderPresent(SDL_Renderer * renderer);
    1.64 +static void D3D_DestroyTexture(SDL_Renderer * renderer,
    1.65 +                               SDL_Texture * texture);
    1.66 +static void D3D_DestroyRenderer(SDL_Renderer * renderer);
    1.67  
    1.68  
    1.69 -SDL_RenderDriver SDL_D3D_RenderDriver = {
    1.70 -    SDL_D3D_CreateRenderer,
    1.71 +SDL_RenderDriver D3D_RenderDriver = {
    1.72 +    D3D_CreateRenderer,
    1.73      {
    1.74       "d3d",
    1.75       (SDL_Renderer_SingleBuffer | SDL_Renderer_PresentCopy |
    1.76 @@ -93,12 +87,12 @@
    1.77  {
    1.78      IDirect3DDevice9 *device;
    1.79      SDL_bool beginScene;
    1.80 -} SDL_D3D_RenderData;
    1.81 +} D3D_RenderData;
    1.82  
    1.83  typedef struct
    1.84  {
    1.85      IDirect3DTexture9 *texture;
    1.86 -} SDL_D3D_TextureData;
    1.87 +} D3D_TextureData;
    1.88  
    1.89  typedef struct
    1.90  {
    1.91 @@ -225,18 +219,18 @@
    1.92      SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
    1.93  
    1.94      if (data->d3d) {
    1.95 -        SDL_AddRenderDriver(0, &SDL_D3D_RenderDriver);
    1.96 +        SDL_AddRenderDriver(0, &D3D_RenderDriver);
    1.97      }
    1.98  }
    1.99  
   1.100  SDL_Renderer *
   1.101 -SDL_D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
   1.102 +D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
   1.103  {
   1.104      SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
   1.105      SDL_VideoData *videodata = (SDL_VideoData *) display->device->driverdata;
   1.106      SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata;
   1.107      SDL_Renderer *renderer;
   1.108 -    SDL_D3D_RenderData *data;
   1.109 +    D3D_RenderData *data;
   1.110      HRESULT result;
   1.111      D3DPRESENT_PARAMETERS pparams;
   1.112      IDirect3DSwapChain9 *chain;
   1.113 @@ -248,27 +242,27 @@
   1.114      }
   1.115      SDL_zerop(renderer);
   1.116  
   1.117 -    data = (SDL_D3D_RenderData *) SDL_malloc(sizeof(*data));
   1.118 +    data = (D3D_RenderData *) SDL_malloc(sizeof(*data));
   1.119      if (!data) {
   1.120 -        SDL_D3D_DestroyRenderer(renderer);
   1.121 +        D3D_DestroyRenderer(renderer);
   1.122          SDL_OutOfMemory();
   1.123          return NULL;
   1.124      }
   1.125      SDL_zerop(data);
   1.126  
   1.127 -    renderer->CreateTexture = SDL_D3D_CreateTexture;
   1.128 -    renderer->SetTexturePalette = SDL_D3D_SetTexturePalette;
   1.129 -    renderer->GetTexturePalette = SDL_D3D_GetTexturePalette;
   1.130 -    renderer->UpdateTexture = SDL_D3D_UpdateTexture;
   1.131 -    renderer->LockTexture = SDL_D3D_LockTexture;
   1.132 -    renderer->UnlockTexture = SDL_D3D_UnlockTexture;
   1.133 -    renderer->DirtyTexture = SDL_D3D_DirtyTexture;
   1.134 -    renderer->RenderFill = SDL_D3D_RenderFill;
   1.135 -    renderer->RenderCopy = SDL_D3D_RenderCopy;
   1.136 -    renderer->RenderPresent = SDL_D3D_RenderPresent;
   1.137 -    renderer->DestroyTexture = SDL_D3D_DestroyTexture;
   1.138 -    renderer->DestroyRenderer = SDL_D3D_DestroyRenderer;
   1.139 -    renderer->info = SDL_D3D_RenderDriver.info;
   1.140 +    renderer->CreateTexture = D3D_CreateTexture;
   1.141 +    renderer->SetTexturePalette = D3D_SetTexturePalette;
   1.142 +    renderer->GetTexturePalette = D3D_GetTexturePalette;
   1.143 +    renderer->UpdateTexture = D3D_UpdateTexture;
   1.144 +    renderer->LockTexture = D3D_LockTexture;
   1.145 +    renderer->UnlockTexture = D3D_UnlockTexture;
   1.146 +    renderer->DirtyTexture = D3D_DirtyTexture;
   1.147 +    renderer->RenderFill = D3D_RenderFill;
   1.148 +    renderer->RenderCopy = D3D_RenderCopy;
   1.149 +    renderer->RenderPresent = D3D_RenderPresent;
   1.150 +    renderer->DestroyTexture = D3D_DestroyTexture;
   1.151 +    renderer->DestroyRenderer = D3D_DestroyRenderer;
   1.152 +    renderer->info = D3D_RenderDriver.info;
   1.153      renderer->window = window->id;
   1.154      renderer->driverdata = data;
   1.155  
   1.156 @@ -316,7 +310,7 @@
   1.157                                       D3DCREATE_SOFTWARE_VERTEXPROCESSING,
   1.158                                       &pparams, &data->device);
   1.159      if (FAILED(result)) {
   1.160 -        SDL_D3D_DestroyRenderer(renderer);
   1.161 +        D3D_DestroyRenderer(renderer);
   1.162          D3D_SetError("CreateDevice()", result);
   1.163          return NULL;
   1.164      }
   1.165 @@ -325,14 +319,14 @@
   1.166      /* Get presentation parameters to fill info */
   1.167      result = IDirect3DDevice9_GetSwapChain(data->device, 0, &chain);
   1.168      if (FAILED(result)) {
   1.169 -        SDL_D3D_DestroyRenderer(renderer);
   1.170 +        D3D_DestroyRenderer(renderer);
   1.171          D3D_SetError("GetSwapChain()", result);
   1.172          return NULL;
   1.173      }
   1.174      result = IDirect3DSwapChain9_GetPresentParameters(chain, &pparams);
   1.175      if (FAILED(result)) {
   1.176          IDirect3DSwapChain9_Release(chain);
   1.177 -        SDL_D3D_DestroyRenderer(renderer);
   1.178 +        D3D_DestroyRenderer(renderer);
   1.179          D3D_SetError("GetPresentParameters()", result);
   1.180          return NULL;
   1.181      }
   1.182 @@ -376,17 +370,16 @@
   1.183  }
   1.184  
   1.185  static int
   1.186 -SDL_D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
   1.187 +D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
   1.188  {
   1.189 -    SDL_D3D_RenderData *renderdata =
   1.190 -        (SDL_D3D_RenderData *) renderer->driverdata;
   1.191 +    D3D_RenderData *renderdata = (D3D_RenderData *) renderer->driverdata;
   1.192      SDL_Window *window = SDL_GetWindowFromID(renderer->window);
   1.193      SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
   1.194 -    SDL_D3D_TextureData *data;
   1.195 +    D3D_TextureData *data;
   1.196      D3DPOOL pool;
   1.197      HRESULT result;
   1.198  
   1.199 -    data = (SDL_D3D_TextureData *) SDL_malloc(sizeof(*data));
   1.200 +    data = (D3D_TextureData *) SDL_malloc(sizeof(*data));
   1.201      if (!data) {
   1.202          SDL_OutOfMemory();
   1.203          return -1;
   1.204 @@ -415,33 +408,30 @@
   1.205  }
   1.206  
   1.207  static int
   1.208 -SDL_D3D_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
   1.209 -                          const SDL_Color * colors, int firstcolor,
   1.210 -                          int ncolors)
   1.211 +D3D_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
   1.212 +                      const SDL_Color * colors, int firstcolor, int ncolors)
   1.213  {
   1.214 -    SDL_D3D_RenderData *renderdata =
   1.215 -        (SDL_D3D_RenderData *) renderer->driverdata;
   1.216 -    SDL_D3D_TextureData *data = (SDL_D3D_TextureData *) texture->driverdata;
   1.217 +    D3D_RenderData *renderdata = (D3D_RenderData *) renderer->driverdata;
   1.218 +    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
   1.219  
   1.220      return 0;
   1.221  }
   1.222  
   1.223  static int
   1.224 -SDL_D3D_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
   1.225 -                          SDL_Color * colors, int firstcolor, int ncolors)
   1.226 +D3D_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
   1.227 +                      SDL_Color * colors, int firstcolor, int ncolors)
   1.228  {
   1.229 -    SDL_D3D_TextureData *data = (SDL_D3D_TextureData *) texture->driverdata;
   1.230 +    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
   1.231  
   1.232      return 0;
   1.233  }
   1.234  
   1.235  static int
   1.236 -SDL_D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
   1.237 -                      const SDL_Rect * rect, const void *pixels, int pitch)
   1.238 +D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
   1.239 +                  const SDL_Rect * rect, const void *pixels, int pitch)
   1.240  {
   1.241 -    SDL_D3D_TextureData *data = (SDL_D3D_TextureData *) texture->driverdata;
   1.242 -    SDL_D3D_RenderData *renderdata =
   1.243 -        (SDL_D3D_RenderData *) renderer->driverdata;
   1.244 +    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
   1.245 +    D3D_RenderData *renderdata = (D3D_RenderData *) renderer->driverdata;
   1.246      IDirect3DTexture9 *temp;
   1.247      RECT d3drect;
   1.248      D3DLOCKED_RECT locked;
   1.249 @@ -496,11 +486,11 @@
   1.250  }
   1.251  
   1.252  static int
   1.253 -SDL_D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
   1.254 -                    const SDL_Rect * rect, int markDirty, void **pixels,
   1.255 -                    int *pitch)
   1.256 +D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
   1.257 +                const SDL_Rect * rect, int markDirty, void **pixels,
   1.258 +                int *pitch)
   1.259  {
   1.260 -    SDL_D3D_TextureData *data = (SDL_D3D_TextureData *) texture->driverdata;
   1.261 +    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
   1.262      RECT d3drect;
   1.263      D3DLOCKED_RECT locked;
   1.264      HRESULT result;
   1.265 @@ -528,18 +518,18 @@
   1.266  }
   1.267  
   1.268  static void
   1.269 -SDL_D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
   1.270 +D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
   1.271  {
   1.272 -    SDL_D3D_TextureData *data = (SDL_D3D_TextureData *) texture->driverdata;
   1.273 +    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
   1.274  
   1.275      IDirect3DTexture9_UnlockRect(data->texture, 0);
   1.276  }
   1.277  
   1.278  static void
   1.279 -SDL_D3D_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
   1.280 -                     int numrects, const SDL_Rect * rects)
   1.281 +D3D_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture, int numrects,
   1.282 +                 const SDL_Rect * rects)
   1.283  {
   1.284 -    SDL_D3D_TextureData *data = (SDL_D3D_TextureData *) texture->driverdata;
   1.285 +    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
   1.286      RECT d3drect;
   1.287      int i;
   1.288  
   1.289 @@ -556,10 +546,9 @@
   1.290  }
   1.291  
   1.292  static int
   1.293 -SDL_D3D_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect,
   1.294 -                   Uint32 color)
   1.295 +D3D_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect, Uint32 color)
   1.296  {
   1.297 -    SDL_D3D_RenderData *data = (SDL_D3D_RenderData *) renderer->driverdata;
   1.298 +    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
   1.299      D3DRECT d3drect;
   1.300      HRESULT result;
   1.301  
   1.302 @@ -584,13 +573,12 @@
   1.303  }
   1.304  
   1.305  static int
   1.306 -SDL_D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
   1.307 -                   const SDL_Rect * srcrect, const SDL_Rect * dstrect,
   1.308 -                   int blendMode, int scaleMode)
   1.309 +D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
   1.310 +               const SDL_Rect * srcrect, const SDL_Rect * dstrect,
   1.311 +               int blendMode, int scaleMode)
   1.312  {
   1.313 -    SDL_D3D_RenderData *data = (SDL_D3D_RenderData *) renderer->driverdata;
   1.314 -    SDL_D3D_TextureData *texturedata =
   1.315 -        (SDL_D3D_TextureData *) texture->driverdata;
   1.316 +    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
   1.317 +    D3D_TextureData *texturedata = (D3D_TextureData *) texture->driverdata;
   1.318      float minx, miny, maxx, maxy;
   1.319      float minu, maxu, minv, maxv;
   1.320      Vertex vertices[4];
   1.321 @@ -658,9 +646,9 @@
   1.322  }
   1.323  
   1.324  static void
   1.325 -SDL_D3D_RenderPresent(SDL_Renderer * renderer)
   1.326 +D3D_RenderPresent(SDL_Renderer * renderer)
   1.327  {
   1.328 -    SDL_D3D_RenderData *data = (SDL_D3D_RenderData *) renderer->driverdata;
   1.329 +    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
   1.330      HRESULT result;
   1.331  
   1.332      if (!data->beginScene) {
   1.333 @@ -675,9 +663,9 @@
   1.334  }
   1.335  
   1.336  static void
   1.337 -SDL_D3D_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
   1.338 +D3D_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
   1.339  {
   1.340 -    SDL_D3D_TextureData *data = (SDL_D3D_TextureData *) texture->driverdata;
   1.341 +    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
   1.342  
   1.343      if (!data) {
   1.344          return;
   1.345 @@ -690,9 +678,9 @@
   1.346  }
   1.347  
   1.348  void
   1.349 -SDL_D3D_DestroyRenderer(SDL_Renderer * renderer)
   1.350 +D3D_DestroyRenderer(SDL_Renderer * renderer)
   1.351  {
   1.352 -    SDL_D3D_RenderData *data = (SDL_D3D_RenderData *) renderer->driverdata;
   1.353 +    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
   1.354  
   1.355      if (data) {
   1.356          if (data->device) {