Archived

This topic is now archived and is closed to further replies.

Sfpiano

Not rendering a certain color of a texture

Recommended Posts

Sfpiano    126
I know this is a dumb question, but I can''t remember how to do it. Say I have my a white background on my texture, and I want to render just the image, not the white background part, how do I do that?

Share this post


Link to post
Share on other sites
Sfpiano    126
I tried that:

D3DXCreateTextureFromFileEx(g_pD3DDevice, "reticule.png", D3DX_DEFAULT, D3DX_DEFAULT,
D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED,
D3DX_DEFAULT, D3DX_DEFAULT, D3DCOLOR_XRGB(255, 255, 255), NULL, NULL, &p_ReticuleTex))

Share this post


Link to post
Share on other sites
Programmer16    2321
When supplying the colorkey, use D3DCOLOR_ARGB() and supply zero for the alpha bit. So, in your example you would use this:

D3DXCreateTextureFromFileEx(g_pD3DDevice, "reticule.png", D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, D3DCOLOR_ARGB(0, 255, 255, 255), NULL, NULL, &p_ReticuleTex));


Share this post


Link to post
Share on other sites
xyzzy00    307
quote:
Original post by Programmer16
When supplying the colorkey, use D3DCOLOR_ARGB() and supply zero for the alpha bit.


Actually, what you are specifying is the color you want D3DX to replace with transparent black. Usually the color you are replacing is opaque. So you should specify 255 for the alpha (or use the D3DCOLOR_XRGB macro).

xyzzy

Share this post


Link to post
Share on other sites