Does transparency mean color loss?

Started by
7 comments, last by Oddball 22 years, 8 months ago
I''m attempting to create a 2D tile-based game using DirectX 8. I was loading the textures like this: 3DXCreateTextureFromFileEx( g_pd3dDevice, filename, 0, 0, 1, 0, D3DFMT_X8R8G8B8 , D3DPOOL_MANAGED,D3DX_FILTER_NONE, D3DX_FILTER_NONE , 0, &SrcInfo , NULL, &pd3dTexture); Since I had the D3DFMT_X8R8G8B8 value, transparency was not working. So I changed it to D3DFMT_A8R8G8B8, and transparency worked perfectly. However, once I changed it to D3DFMT_A8R8G8B8, the color depth seemed to decrease. For example, I had a nice texture of grass, but when loaded using D3DFMT_A8R8G8B8, it looked just plain green with a few dots in it. Why won''t my textures appear as I want them to? Please help, this issue has been driving me crazy. Thanks.
Advertisement
Check out what type of texture surface is really being created, the d3dx library does not always create what you tell it to. sometimes it is best fit. Use texture->GetLevelDesc(0, &D3DSURFACE_DESC structure) to find out what it really is.
I have 16 bit card (voodoo3) and it''s very ugly when using alpha. The format is then either FMT_A4R4G4B4 or FMT_A1R5G5B6.
You''re right, I checked, and it''s using D3DFMT_A1R5G5B5. Is there any way I can possibly get around this? I''ve worked very hard on my graphics, and I''d like them to be shown in their full color.

I was thinking, maybe it''s possible to load them as D3DFMT_X8R8G8B8 to get full color information, and then somehow apply the transparency afterwards. Is that at all possible?

Any suggestions or possible solutions would be appreciated.
Thanks.
One solution for this problem that I''ve used before is just to use two textures through multitexturing. Load only the alpha component into one and only the color into the other, then using the fixed function texture pipeline to set it to take the appropriate values from each.
This idea sounds promising. However, I''m pretty much a newbie to DirectX, and I don''t know anything about the fixed function texture pipeline. I looked up pipelines in the SDK, but didn''t find anything that looks like it would be useful. Could you please elaborate on that topic, and possibly tell me how to implement it? Thanks.
Look up the IDirect3DDevice8::SetTextureStageState(...) method. Also, I believe there''s a multitexturing tutorial in the SDK, but I just reinstalled Windows and am yet to install the SDK, so I can''t verify that for you.
I think I should have mentioned that I am using the ID3DXSprite::Draw() method to display my graphics to the screen. From what I''ve seen in the documentation, it looks like your multitexturing advice can''t be used when using the ID3DXSprite interface, since I''m never even using the IDirect3DDevice8::SetTexture() method to set my textures. Or is there some way to do multitexturing with this interface?

If there''s no way to do multitexturing, would it be worth it to change my tile engine from using the ID3DXSprite interface to drawing each tile as a primitive, so that I could apply multitexturing? Please give me suggestions, you''ve been a great help.

I don''t believe there''s any way to do it easily with the ID3DXSprite interface. Even if there is it''d be best to make your own sprite class for the added control it gives you, in this very situation and other similar situations you might encounter in the future. Although, if you really want to I''m sure you can hack out a method still using ID3DXSprite.

PS - AP was me

-------------------------------
NeXe: NeHe DirectX-style.

Follow the orange rabbit.

This topic is closed to new replies.

Advertisement