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

transparency/alpha in d3d8

Started by supagu Apr 17, 2002 at 6:42 AM 6 replies 400+ views
Original Post
supagu
supagu
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?
supagu
supagu
er
supagu
supagu
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...
supagu
supagu
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?
pieman
pieman

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
Iain HutchisonProgrammer, Silicon DreamsThe views expressed here are my own, not those of my employer.
RobinMessage
RobinMessage
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
supagu
supagu
yesss please.....

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

Topic Locked

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

Sign in to reply to this topic.