English 中文(简体)
Turning a DirectX sprite Solid White
原标题:

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.

最佳回答

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)

问题回答

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.





相关问题
Prerequisite for learning directx

I am from .net C# background and I want to learn DirectX. I have knowledge of C++ but I am fairly new to graphic world. I am little confused about how to start learning directx, should I start ...

How to programmatically disable the auto-focus of a webcam?

I am trying to do computer vision using a webcam (the model is Hercules Dualpix). I know it is not the ideal camera to use, but I have no choice here. The problem is the auto-focus makes it hard/...

Making an object orbit a fixed point in directx?

I am trying to make a very simple object rotate around a fixed point in 3dspace. Basically my object is created from a single D3DXVECTOR3, which indicates the current position of the object, ...

3d Alternative for D3DXSPRITE for billboarding

I am looking to billboard a sun image in my 3d world (directx 9). Creating a D3DXSPRITE is great in some cases, but it is only a 2d object and can not exist in my "world" as a 3d object. What is ...

热门标签