Jump to content
  • Advertisement
Sign in to follow this  
andyb716

Picture Loading

This topic is 5411 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

Hi I'm new to directx and I tried to load a gif with a transparent background and it doesn't show up transparent in directx. My question is, I've seen some tutorials on how to make a transparent pixel, so do I have to write my own loader to make it transparent. And also what type of picture format is good. Like tga or jpg? I want the size of it in memory to be small but I want to have good quality textures too? If anybody has any ideas about tutorials on making a loader or what kind of format is good would be appreciated thanks.

Share this post


Link to post
Share on other sites
Advertisement
2 common errors.
  • Do you have alpha testing enabled?
  • Are you using a backbuffer format that supports alpha values? (not X)?

Share this post


Link to post
Share on other sites
which version of DirectX ?
are you using DirectDraw or Direct3D ?

PNG and TGA are good formats that have an alpha channel
JPG is good but no alpha channel

Share this post


Link to post
Share on other sites
I enabled alpha testing and my back buffer format is the format that comes from the D3DDISPLAYMODE struct so I guess its my default adapter format. Do i have to do something else in order to have the transparent pixels transparent?

Share this post


Link to post
Share on other sites
The backbuffer format doesn't need alpha unless your blend requires D3DBLEND_DESTALPHA or D3DBLEND_INVDESTALPHA, which is very, very, unlikely.

Your texture format needs alpha though. I have no idea if the DirectX texture loading functions use the transparency information in a gif file. Try a tga or a png file with transparency to be sure it's not a problem with gif transparency.

Also, how did you enable alpha testing? For example, you'll want something like this:

D3DRS_ALPHATEST, true
D3DRS_ALPHAREF, 0x80
D3DRS_ALPHAFUNC, D3DCMP_GREATER

which says, I want to keep pixels with alpha > 128.

Share this post


Link to post
Share on other sites
thanks Namethatnobodyelsetook I was only using D3DRS_ALPHATESTENABLE and not those other render states. By the way I am using textured quads. Is there a difference in using sprites rather than quads?

Share this post


Link to post
Share on other sites
ID3DXSprite is basically just an interface that does textured quads for you, the difference is to do transparency with ID3DXSPRITE you can just call Begin( D3DXSPRITE_ALPHABLEND );

In 9.0c it's generally better than textured quads (easier to manage, more efficient). There were some speed issues in earlier versions of DX though they're fixed now.

Share this post


Link to post
Share on other sites
Quote:
Original post by andyb716
...And also what type of picture format is good. Like tga or jpg?...

DDS is another good format. It is direct X's format and it stores EVERYTHING (color format, transparency if the color format includes alpha, mip maps, etc., and I think it is supposed to have some compression). The only thing about it is that you probably won't be able to find anything that edits it directly. Make images with a drawing program and then use DXTex (with the DirectX SDK) to add the alpha channel and save it as a DDS file.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!