tags:

views:

134

answers:

2

I have a sprite of my main character. I normally draw it with a color modulus of ARGB(255,255,255,255). However, I would like my sprite to be drawn more white. I can make the sprite be drawn any color by changing the color modulus, except for white. What can I do? I am using C++ with DirectX9 and using an LPD3DXSPRITE to draw my textures.

+1  A: 

There are 2 way that I know, one inefficient, one more efficient :

Inefficient ) Draw another semitranparent white sprite using alphablending.

Efficient ) Use a shader to draw the quad. (a simple shader that add a value over the actual return value of the texture sample instead of multiplying it)

feal87
A: 

Try this:

IDirect3DDevice9* device = your_device;
LPD3DXSPRITE sprite = your_sprite;
LPDIRECT3DTEXTURE9 texture = your_texture;
D3DXVECTOR3 center;
D3DXVECTOR3 position;
unsigned char c = how_white_you_want;


sprite->Begin(D3DXSPRITE_ALPHABLEND);

device->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_ADD );
device->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
device->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );

sprite->Draw(texture, NULL, &center, &sprite, D3DCOLOR_RGBA(c,c,c,255));

sprite->End();

I think it's simple and efficient.

h00w