transparency in DDraw

Started by
5 comments, last by da_cobra 22 years, 4 months ago
can any1 pls explain me how that KeyColor works, because I have the following : I have a tetris game and when I press "P" it should display the menu, but I can''t figure out how to make my meny transparent so it''ll only display the words and not the black background of my menu My code works (I get no errors or such) but I just can''t get that black away here''s my code
  
// setup de color for transparency

	G.ddpf.dwSize = sizeof(G.ddpf) ;
	G.lpDDSMenu->GetPixelFormat(&G.ddpf) ; // should I place my menu surface here?

	DWORD KeyColor = 0 ; // keycolor = black

	G.key.dwColorSpaceLowValue = KeyColor ;
	G.key.dwColorSpaceHighValue = KeyColor ;
	G.lpDDSBackground->SetColorKey(DDCKEY_SRCBLT, &G.key) ; // or here?

  
I have the following surfaces G.lpDDSPrimary = primary surface G.lpDDSBack = back surface G.lpDDSBuffer = surface with my blocks G.lpDDSBackground = surface with background for game G.lpDDSMenu = surface where I store my words for my menu now which surface should I use where in my code? thanx in advance for any help
Advertisement
The pixelformat is not important for transparency.

Your error is that you have to set the colorkey for the menu, not the background.
Kill mages first!
so I should place my menu surface here :

G.lpDDSMenu->SetColorKey(DDCKEY_SRCBLT, &G.key) ; // or here?

and delete this line :

G.lpDDSMenu->GetPixelFormat(&G.ddpf) ; // should I place my menu surface here?


well, this doesn''t work my menu still isn''t transparent...

but still thanx for your effort
any1 pls help me....
Mhhh... It should work though.

I can think of two problems right now. Either you are in palletized mode and black is not index 0, or you are forgetting to specify the right flag while blitting. You have to specify DDBLT_KEYSRC when you are blitting transparent surfaces.
Kill mages first!
While on the topic of transparency, if you wanted a color other than black to be transparent in a non-palettized mode, how exactly would you do that? How do you find the numerical value of the color? Using a RGB macro?

-Yoshi
XGXCX ''''99
-YoshiXGXCX ''99
Exactly that. Which macro to use depends on the bpp.
Kill mages first!

This topic is closed to new replies.

Advertisement