Jump to content
  • Advertisement

Archived

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

Sfpiano

Not rendering a certain color of a texture

This topic is 5414 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
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
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
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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!