Jump to content
  • Advertisement

Archived

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

Helius

DDraw Fade function in 16 bit color ??

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

Does anyone knows how can I implement a fade in/out function with Direct Draw in 16 bit color?

Share this post


Link to post
Share on other sites
Advertisement
If you have an alpha blending routine, you could take a surface that''s the size of your display surface and blend the two together.

If you don''t have an alpha blending routine, check out the MMX alpha blending article in the programming section here at GameDev.Net. You could also do some research and use Direct3D to implement 3D hardware accelerated alpha blending.

Josh
http://www.jh-software.com

Share this post


Link to post
Share on other sites
Another (much faster) way is to use the Gamma Control to fade out the screen. I don''t know if all monitors support this, though...

/ LC

Share this post


Link to post
Share on other sites
Not all video cards allow for gamma fading. There fore it's not the best alternative to fading pixel by pixel. The routine is fairly simple.

While (all pixels aren't black)
{
destination pixel red value = source pixel red value /2;
destination pixel green value = source pixel green value /2;
destination pixel blue value = source pixel blue value /2;
}

(note this is just a deriavation of a software alpha blending routine. Because the goal is to fade to black (RGB 0,0,0) we can change the formula from destination pixel = source pixel+alpha pixel/2 to destination pixel=source pixel/2 because the alpha pixel is 0!)

Edited by - evaclear on 3/7/00 10:32:59 PM

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Thank you all !!!

Nacho.

Share this post


Link to post
Share on other sites
Go there, a great tutorial on how to fade 16bit surface.
You can fade to black, fade to surface and Alpha Transition between to surfaces.

http://www4.netease.com/~codingboy/gpfan/stunt/ddfade.html

Share this post


Link to post
Share on other sites
If you really wanna do it fast, you can use D3D to set the material color and fade it that way...but that would be a little too much work. This would work on all computers, as long as you''ve got DirectX installed.

You can detect gamma support with IDirectDraw7::GetCaps.

============================
Daniel Netz, Sentinel Design

"I'm not stupid, I'm from Sweden" - Unknown

Share this post


Link to post
Share on other sites
For fast software alpha-blending I am using some kind of look-up table with precomputed values for every possible color and every alpha value. Something like this:

// alpha map for 32 alpha shades
WORD AlphaMap[32][65536];

It takes 4MB of RAM! But it is very fast, so who cares.

Share this post


Link to post
Share on other sites
Hey - that''s a good idea!

I think the fades in "Age of Empires 2" are done that way. They were too fast to be real-time calculations on my old Pentium 166.

And what''s 4 Megs today ?!

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!