Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

supagu

transparency/alpha in d3d8

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

hey im making a little propram, i load a bitmap and coppied into a surface using.... D3DXLoadSurfaceFromFile when it wants a colour key, i put in the right value, but instead of going transparent it goes black, how do i make it transparent without having to copy the surface manually? or is that the only way in d3d8?

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
I encountered the same problem, try to activate alphablending and include a alpha channel for transparency in your bitmap. It''s the only way I found (under DX8 with the D3DX8 helpers library)... If anyone has another idea I take it immediatly...

Share this post


Link to post
Share on other sites
so this is what i have done to try to enable alpha....

g_pd3dDevice->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE);
g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
g_pd3dDevice->SetRenderState(D3DRS_ALPHAREF, (DWORD)0x000000FF);
g_pd3dDevice->SetRenderState(D3DRS_ALPHAFUNC,D3DCMP_GREATEREQUAL);

i added an alpha channel in my bitmap in photoshop, but it doesnt seem to work, i dont know if the problem is with the bitmap - the alpha channel or if its the code...

Share this post


Link to post
Share on other sites
er, apparently u cant use alpha channels in BMP''s....can i load png''s or ene file format in dx8, using the function

D3DXLoadSurfaceFromFile()

???

whould that be y my alpha aint loading from the BMP?

Share this post


Link to post
Share on other sites

What value are you passing in for the ColorKey? The alpha-alue in the colour-key is used when processing the image so you''ll need to make sure that you have it set to 255 when your loading from a BMP. Probably.

As for file-formats that you can use with, here''s what the DX help say for D3DXLoadSurfaceFromFile :

quote:
This function supports the following file formats: .bmp, .dds, .dib, .jpg, .png, and .tga.


Iain

Share this post


Link to post
Share on other sites
I recommend using TGA files and alpha channels as they look soooooo much better than colorkeyed bmps etc.

and loading TGA files is easy becuase they have an 18 byte header and then raw data which can be written straight to the surface.

Post if you want code for a TGA file loader (32 bit)

Robin

Share this post


Link to post
Share on other sites
yesss please.....

thanks man, you can meail it to me at supagu@hotmail.com
if you like
or post it in here

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!