Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Implemented color modulation in the D3D renderer.

FIXME: Why doesn't alpha modulation appear to work?
  • Loading branch information
slouken committed Aug 28, 2006
1 parent b2bba02 commit 25a1ff408dd5e2893bdf1a7a848f245a600159b9
Showing with 14 additions and 6 deletions.
  1. +14 −6 src/video/win32/SDL_d3drender.c
@@ -113,6 +113,7 @@ typedef struct
{
float x, y, z;
float rhw;
DWORD color;
float u, v;
} Vertex;

@@ -379,7 +380,8 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags)

/* Set up parameters for rendering */
IDirect3DDevice9_SetVertexShader(data->device, NULL);
IDirect3DDevice9_SetFVF(data->device, D3DFVF_XYZRHW | D3DFVF_TEX1);
IDirect3DDevice9_SetFVF(data->device,
D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1);
IDirect3DDevice9_SetRenderState(data->device, D3DRS_CULLMODE,
D3DCULL_NONE);
IDirect3DDevice9_SetRenderState(data->device, D3DRS_LIGHTING, FALSE);
@@ -404,7 +406,8 @@ D3D_Reset(SDL_Renderer * renderer)
}
}
IDirect3DDevice9_SetVertexShader(data->device, NULL);
IDirect3DDevice9_SetFVF(data->device, D3DFVF_XYZRHW | D3DFVF_TEX1);
IDirect3DDevice9_SetFVF(data->device,
D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1);
IDirect3DDevice9_SetRenderState(data->device, D3DRS_CULLMODE,
D3DCULL_NONE);
IDirect3DDevice9_SetRenderState(data->device, D3DRS_LIGHTING, FALSE);
@@ -493,15 +496,13 @@ D3D_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
static int
D3D_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture)
{
/* FIXME: implement vertex coloring */
return -1;
return 0;
}

static int
D3D_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture)
{
/* FIXME: implement vertex coloring */
return -1;
return 0;
}

static int
@@ -693,6 +694,7 @@ D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
D3D_TextureData *texturedata = (D3D_TextureData *) texture->driverdata;
float minx, miny, maxx, maxy;
float minu, maxu, minv, maxv;
DWORD color;
Vertex vertices[4];
HRESULT result;

@@ -711,31 +713,37 @@ D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
minv = (float) srcrect->y / texture->h;
maxv = (float) (srcrect->y + srcrect->h) / texture->h;

color = D3DCOLOR_ARGB(texture->a, texture->r, texture->g, texture->b);

vertices[0].x = minx;
vertices[0].y = miny;
vertices[0].z = 0.0f;
vertices[0].rhw = 1.0f;
vertices[0].color = color;
vertices[0].u = minu;
vertices[0].v = minv;

vertices[1].x = maxx;
vertices[1].y = miny;
vertices[1].z = 0.0f;
vertices[1].rhw = 1.0f;
vertices[1].color = color;
vertices[1].u = maxu;
vertices[1].v = minv;

vertices[2].x = maxx;
vertices[2].y = maxy;
vertices[2].z = 0.0f;
vertices[2].rhw = 1.0f;
vertices[2].color = color;
vertices[2].u = maxu;
vertices[2].v = maxv;

vertices[3].x = minx;
vertices[3].y = maxy;
vertices[3].z = 0.0f;
vertices[3].rhw = 1.0f;
vertices[3].color = color;
vertices[3].u = minu;
vertices[3].v = maxv;

0 comments on commit 25a1ff4

Please sign in to comment.