Implemented color modulation in the D3D renderer.
authorSam Lantinga <slouken@libsdl.org>
Mon, 28 Aug 2006 04:03:32 +0000
changeset 198736a08379b3f2
parent 1986 f4c65e3bfaed
child 1988 1ee02169bbb0
Implemented color modulation in the D3D renderer.
FIXME: Why doesn't alpha modulation appear to work?
src/video/win32/SDL_d3drender.c
     1.1 --- a/src/video/win32/SDL_d3drender.c	Mon Aug 28 03:27:59 2006 +0000
     1.2 +++ b/src/video/win32/SDL_d3drender.c	Mon Aug 28 04:03:32 2006 +0000
     1.3 @@ -113,6 +113,7 @@
     1.4  {
     1.5      float x, y, z;
     1.6      float rhw;
     1.7 +    DWORD color;
     1.8      float u, v;
     1.9  } Vertex;
    1.10  
    1.11 @@ -379,7 +380,8 @@
    1.12  
    1.13      /* Set up parameters for rendering */
    1.14      IDirect3DDevice9_SetVertexShader(data->device, NULL);
    1.15 -    IDirect3DDevice9_SetFVF(data->device, D3DFVF_XYZRHW | D3DFVF_TEX1);
    1.16 +    IDirect3DDevice9_SetFVF(data->device,
    1.17 +                            D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1);
    1.18      IDirect3DDevice9_SetRenderState(data->device, D3DRS_CULLMODE,
    1.19                                      D3DCULL_NONE);
    1.20      IDirect3DDevice9_SetRenderState(data->device, D3DRS_LIGHTING, FALSE);
    1.21 @@ -404,7 +406,8 @@
    1.22          }
    1.23      }
    1.24      IDirect3DDevice9_SetVertexShader(data->device, NULL);
    1.25 -    IDirect3DDevice9_SetFVF(data->device, D3DFVF_XYZRHW | D3DFVF_TEX1);
    1.26 +    IDirect3DDevice9_SetFVF(data->device,
    1.27 +                            D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1);
    1.28      IDirect3DDevice9_SetRenderState(data->device, D3DRS_CULLMODE,
    1.29                                      D3DCULL_NONE);
    1.30      IDirect3DDevice9_SetRenderState(data->device, D3DRS_LIGHTING, FALSE);
    1.31 @@ -493,15 +496,13 @@
    1.32  static int
    1.33  D3D_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture)
    1.34  {
    1.35 -    /* FIXME: implement vertex coloring */
    1.36 -    return -1;
    1.37 +    return 0;
    1.38  }
    1.39  
    1.40  static int
    1.41  D3D_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture)
    1.42  {
    1.43 -    /* FIXME: implement vertex coloring */
    1.44 -    return -1;
    1.45 +    return 0;
    1.46  }
    1.47  
    1.48  static int
    1.49 @@ -693,6 +694,7 @@
    1.50      D3D_TextureData *texturedata = (D3D_TextureData *) texture->driverdata;
    1.51      float minx, miny, maxx, maxy;
    1.52      float minu, maxu, minv, maxv;
    1.53 +    DWORD color;
    1.54      Vertex vertices[4];
    1.55      HRESULT result;
    1.56  
    1.57 @@ -711,10 +713,13 @@
    1.58      minv = (float) srcrect->y / texture->h;
    1.59      maxv = (float) (srcrect->y + srcrect->h) / texture->h;
    1.60  
    1.61 +    color = D3DCOLOR_ARGB(texture->a, texture->r, texture->g, texture->b);
    1.62 +
    1.63      vertices[0].x = minx;
    1.64      vertices[0].y = miny;
    1.65      vertices[0].z = 0.0f;
    1.66      vertices[0].rhw = 1.0f;
    1.67 +    vertices[0].color = color;
    1.68      vertices[0].u = minu;
    1.69      vertices[0].v = minv;
    1.70  
    1.71 @@ -722,6 +727,7 @@
    1.72      vertices[1].y = miny;
    1.73      vertices[1].z = 0.0f;
    1.74      vertices[1].rhw = 1.0f;
    1.75 +    vertices[1].color = color;
    1.76      vertices[1].u = maxu;
    1.77      vertices[1].v = minv;
    1.78  
    1.79 @@ -729,6 +735,7 @@
    1.80      vertices[2].y = maxy;
    1.81      vertices[2].z = 0.0f;
    1.82      vertices[2].rhw = 1.0f;
    1.83 +    vertices[2].color = color;
    1.84      vertices[2].u = maxu;
    1.85      vertices[2].v = maxv;
    1.86  
    1.87 @@ -736,6 +743,7 @@
    1.88      vertices[3].y = maxy;
    1.89      vertices[3].z = 0.0f;
    1.90      vertices[3].rhw = 1.0f;
    1.91 +    vertices[3].color = color;
    1.92      vertices[3].u = minu;
    1.93      vertices[3].v = maxv;
    1.94