Skip to main content
GameDev.net gamedev.net
🔒 Locked

Color formats

Started by Weston Jul 22, 2003 at 12:06 AM 1 replies 300+ views
Original Post
Weston
Weston
Heyo! I''d like to stop bothering people about Direct3D, but I''m one to understand my programs all the way through to ensure compatibility and correct syntax. Right now, I have a DirectX 8.0 program running in fullscreen mode in 16 bit 565 format. I also want to do alpha testing for transparencies on some textures. When I want to load a bitmap texture using D3DXCreateTextureFromFileEx(), there is a format parameter that from what I read needs to have an alpha channel in it, such as D3DFMT_A1R5G5B5. This format doesn''t match my display format. I would assume it doesn''t really matter now. So: 1) Does it matter if these formats don''t match? The program runs fine either way. I just want to make sure I am doing this correctly. 2) Does the format parameter require an alpha channel? I can still use alpha tansparencies with a format of D3DFMT_R5G6B5. What is going on? 3) Why can I not use D3DFMT_A1R5G5B5 as a display format? The program only seems to run with D3DFMT_R5G6B5 for the display. And this is probably an over asked question, but why is it that when I load a texture, it is reversed and upside down? Thanks in advance! I''ll bet DirectSound is going to be just as bad to learn.
---Will DDR for food.
Namethatnobodyelsetook
Namethatnobodyelsetook
1. The formats don''t have to match, but they must be supported on the user''s card. CheckDeviceFormat() can be used to check if a mode works on a user''s hardware. CheckDeviceType() can be used to check if a combination of a displaymode, a back buffer format, and windowed is acceptable on this card.

Basically you need to be able to fall back on other formats if your preferred format isn''t available.

2. You don''t need alpha on your display format unless you want to use "destination alpha". Usually you use D3DBLEND_SRCALPHA, which would be alpha from the texture you''re rendering, your material, your vertices, your shaders, etc. D3DBLEND_DESTALPHA would mean to use the alpha stored in the back buffer, which is a pretty rare thing to do.

You don''t need alpha on your texture format unless you want to use it. You can still blend with materials, vertices, and shaders producing alpha.

Alpha in your texture allows seemingly complex geometry without all the extra polys. For example, a quad with a maple leaf shaped alpha texture will look like a leaf rather than a quad, but doesn''t require nearly as much vertex processing, or artist time.

3. Most cards limit the display modes to a few standardized modes. Using the caps viewer (start/programs/dx9 sdk/dx utility/caps viewer), go to "dx graphics / yourcardname / d3d dev types / hal / adapter formats" to see what formats your card likes. In each of those formats you can see what backbuffer and render target formats your card likes. This list is determined using CheckDeviceType() and CheckDeviceFormat(). If you''re using EnumAdapterModes(), it only lists valid resolutions and formats, so these don''t really need to be checked. If you''re just picking a mode, you must check it before using it and have some way to fallback to an accepted mode.
Weston
Weston
Thank you very much!
---Will DDR for food.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.