src/video/win32/SDL_d3drender.c
changeset 1985 8055185ae4ed
parent 1976 b1620a317791
child 1987 36a08379b3f2
     1.1 --- a/src/video/win32/SDL_d3drender.c	Thu Aug 24 12:49:59 2006 +0000
     1.2 +++ b/src/video/win32/SDL_d3drender.c	Mon Aug 28 03:17:39 2006 +0000
     1.3 @@ -37,6 +37,14 @@
     1.4  static int D3D_GetTexturePalette(SDL_Renderer * renderer,
     1.5                                   SDL_Texture * texture, SDL_Color * colors,
     1.6                                   int firstcolor, int ncolors);
     1.7 +static int D3D_SetTextureColorMod(SDL_Renderer * renderer,
     1.8 +                                  SDL_Texture * texture);
     1.9 +static int D3D_SetTextureAlphaMod(SDL_Renderer * renderer,
    1.10 +                                  SDL_Texture * texture);
    1.11 +static int D3D_SetTextureBlendMode(SDL_Renderer * renderer,
    1.12 +                                   SDL_Texture * texture);
    1.13 +static int D3D_SetTextureScaleMode(SDL_Renderer * renderer,
    1.14 +                                   SDL_Texture * texture);
    1.15  static int D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
    1.16                               const SDL_Rect * rect, const void *pixels,
    1.17                               int pitch);
    1.18 @@ -46,11 +54,10 @@
    1.19  static void D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
    1.20  static void D3D_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
    1.21                               int numrects, const SDL_Rect * rects);
    1.22 -static int D3D_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect,
    1.23 -                          Uint32 color);
    1.24 +static int D3D_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g, Uint8 b,
    1.25 +                          Uint8 a, const SDL_Rect * rect);
    1.26  static int D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
    1.27 -                          const SDL_Rect * srcrect, const SDL_Rect * dstrect,
    1.28 -                          int blendMode, int scaleMode);
    1.29 +                          const SDL_Rect * srcrect, const SDL_Rect * dstrect);
    1.30  static void D3D_RenderPresent(SDL_Renderer * renderer);
    1.31  static void D3D_DestroyTexture(SDL_Renderer * renderer,
    1.32                                 SDL_Texture * texture);
    1.33 @@ -65,6 +72,8 @@
    1.34        SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
    1.35        SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_PRESENTVSYNC |
    1.36        SDL_RENDERER_ACCELERATED),
    1.37 +     (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR |
    1.38 +      SDL_TEXTUREMODULATE_ALPHA),
    1.39       (SDL_TEXTUREBLENDMODE_NONE | SDL_TEXTUREBLENDMODE_MASK |
    1.40        SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD |
    1.41        SDL_TEXTUREBLENDMODE_MOD),
    1.42 @@ -259,6 +268,10 @@
    1.43      renderer->CreateTexture = D3D_CreateTexture;
    1.44      renderer->SetTexturePalette = D3D_SetTexturePalette;
    1.45      renderer->GetTexturePalette = D3D_GetTexturePalette;
    1.46 +    renderer->SetTextureColorMod = D3D_SetTextureColorMod;
    1.47 +    renderer->SetTextureAlphaMod = D3D_SetTextureAlphaMod;
    1.48 +    renderer->SetTextureBlendMode = D3D_SetTextureBlendMode;
    1.49 +    renderer->SetTextureScaleMode = D3D_SetTextureScaleMode;
    1.50      renderer->UpdateTexture = D3D_UpdateTexture;
    1.51      renderer->LockTexture = D3D_LockTexture;
    1.52      renderer->UnlockTexture = D3D_UnlockTexture;
    1.53 @@ -478,6 +491,54 @@
    1.54  }
    1.55  
    1.56  static int
    1.57 +D3D_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture)
    1.58 +{
    1.59 +    /* FIXME: implement vertex coloring */
    1.60 +    return -1;
    1.61 +}
    1.62 +
    1.63 +static int
    1.64 +D3D_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture)
    1.65 +{
    1.66 +    /* FIXME: implement vertex coloring */
    1.67 +    return -1;
    1.68 +}
    1.69 +
    1.70 +static int
    1.71 +D3D_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
    1.72 +{
    1.73 +    switch (texture->blendMode) {
    1.74 +    case SDL_TEXTUREBLENDMODE_NONE:
    1.75 +    case SDL_TEXTUREBLENDMODE_MASK:
    1.76 +    case SDL_TEXTUREBLENDMODE_BLEND:
    1.77 +    case SDL_TEXTUREBLENDMODE_ADD:
    1.78 +    case SDL_TEXTUREBLENDMODE_MOD:
    1.79 +        return 0;
    1.80 +    default:
    1.81 +        SDL_Unsupported();
    1.82 +        texture->blendMode = SDL_TEXTUREBLENDMODE_NONE;
    1.83 +        return -1;
    1.84 +    }
    1.85 +}
    1.86 +
    1.87 +static int
    1.88 +D3D_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
    1.89 +{
    1.90 +    switch (texture->scaleMode) {
    1.91 +    case SDL_TEXTURESCALEMODE_NONE:
    1.92 +    case SDL_TEXTURESCALEMODE_FAST:
    1.93 +    case SDL_TEXTURESCALEMODE_SLOW:
    1.94 +    case SDL_TEXTURESCALEMODE_BEST:
    1.95 +        return 0;
    1.96 +    default:
    1.97 +        SDL_Unsupported();
    1.98 +        texture->scaleMode = SDL_TEXTURESCALEMODE_NONE;
    1.99 +        return -1;
   1.100 +    }
   1.101 +    return 0;
   1.102 +}
   1.103 +
   1.104 +static int
   1.105  D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
   1.106                    const SDL_Rect * rect, const void *pixels, int pitch)
   1.107  {
   1.108 @@ -597,7 +658,8 @@
   1.109  }
   1.110  
   1.111  static int
   1.112 -D3D_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect, Uint32 color)
   1.113 +D3D_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g, Uint8 b, Uint8 a,
   1.114 +               const SDL_Rect * rect)
   1.115  {
   1.116      D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
   1.117      D3DRECT d3drect;
   1.118 @@ -615,7 +677,7 @@
   1.119  
   1.120      result =
   1.121          IDirect3DDevice9_Clear(data->device, 1, &d3drect, D3DCLEAR_TARGET,
   1.122 -                               (D3DCOLOR) color, 1.0f, 0);
   1.123 +                               D3DCOLOR_ARGB(a, r, g, b), 1.0f, 0);
   1.124      if (FAILED(result)) {
   1.125          D3D_SetError("Clear()", result);
   1.126          return -1;
   1.127 @@ -625,8 +687,7 @@
   1.128  
   1.129  static int
   1.130  D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
   1.131 -               const SDL_Rect * srcrect, const SDL_Rect * dstrect,
   1.132 -               int blendMode, int scaleMode)
   1.133 +               const SDL_Rect * srcrect, const SDL_Rect * dstrect)
   1.134  {
   1.135      D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
   1.136      D3D_TextureData *texturedata = (D3D_TextureData *) texture->driverdata;
   1.137 @@ -678,7 +739,7 @@
   1.138      vertices[3].u = minu;
   1.139      vertices[3].v = maxv;
   1.140  
   1.141 -    switch (blendMode) {
   1.142 +    switch (texture->blendMode) {
   1.143      case SDL_TEXTUREBLENDMODE_NONE:
   1.144          IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE,
   1.145                                          FALSE);
   1.146 @@ -710,7 +771,7 @@
   1.147          break;
   1.148      }
   1.149  
   1.150 -    switch (scaleMode) {
   1.151 +    switch (texture->scaleMode) {
   1.152      case SDL_TEXTURESCALEMODE_NONE:
   1.153      case SDL_TEXTURESCALEMODE_FAST:
   1.154          IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MINFILTER,