Not rendering a certain color of a texture

Started by
4 comments, last by Sfpiano 20 years, 3 months ago
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?
//------------------------------------------------------------------------------------------------------The great logician Bertrand Russell once claimed that he could prove anything if given that 1+1=1. So one day, some fool asked him, "Ok. Prove that you're the Pope." He thought for a while and proclaimed, "I am one. The Pope is one. Therefore, the Pope and I are one."
Advertisement
How are you loading the texture?
And the rockets' red glare, the bombs bursting in air,gave proof through the fight that our flag was still there.Oh say, does that star-spangled banner yet waveover the land of the free and the home of the brave?
Use the d3dx functions and supply a color key.
____________________________________________________________AAAAA: American Association Against Adobe AcrobatYou know you hate PDFs...
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)) 
//------------------------------------------------------------------------------------------------------The great logician Bertrand Russell once claimed that he could prove anything if given that 1+1=1. So one day, some fool asked him, "Ok. Prove that you're the Pope." He thought for a while and proclaimed, "I am one. The Pope is one. Therefore, the Pope and I are one."
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));


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

This topic is closed to new replies.

Advertisement