Not rendering a certain color of a texture
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?
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))
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));
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
Popular Topics
Advertisement