DirectDraw fade in/out

Started by
4 comments, last by alnite 21 years, 5 months ago
OK, I know to google this one. I tried, and the #1 result is one of the GameDev.net article. I followed the article exactly, but the result did not quite as I expected. Other results are useless..broken links...just explain what gamma is...etc. It does not work on bright colors. I have a logo, and I want that logo to disappear using fade out effect. That logo has only two colors, pure green and black (RGB(0,255,0) and RGB(0,0,0)). The result? The logo (the green part) suddenly turned to black, instead of fading to black. Oh, I have white background also, the background also stayed at white. I tried on other surfaces with thousands of colors...worked quite good. You can see it fades, but it fades the way I don''t want to. It fades according to color values, not the entire screen. Does any of you have a good sample program for this? My compiler generates one error message: "does not compile."
Advertisement
I know, Gamma makes the colours go weird before the screen fades out... I want to know the secret behind brightness too!
nm this post. I got it working. Stupid gamedev.net article, the author did it in the wrong way.

My compiler generates one error message: "does not compile."
if you want to fade color out/in try this:

red, green, and blue are the color components

multiply each pixels color component by a Brightness factor from 0 to 100. where 100 is original brightest and 0 is blacked out

component = (component * brightnessfactor)/100;


if you want to white out/in color:

by inverting the color component (255 would be for 8 bit components, 31 for 5 bit, and 63 for 6 bit) in the formula from the above and adding the result back to the component

component += ((255-component)* brightnessfactor)/100;


that will work or are you looking for something fancier?

If you want realtime performance you will have to highly optimize the process because this is a per component level operation. 640 x 480 pixels x 3 components = over 900,000 operations for a full screen frame and of course even more at higher resolutions

I would try to find a hardware accelerated option!!

[edited by - CodeJunkie on November 9, 2002 10:22:44 AM]

[edited by - CodeJunkie on November 9, 2002 10:26:41 AM]

[edited by - CodeJunkie on November 9, 2002 10:28:17 AM]

[edited by - CodeJunkie on November 9, 2002 11:16:31 AM]
Wow just read the article!!

that gamma ramp stuff is cool. you could do a lot of Full screen effects in real time with that.

quote:Original post by alnite
I have a logo, and I want that logo to disappear using fade out effect.


There´s a very nice article that explains how to achieve that effect using DirectDraw in the companion CD of Tricks of the Windows Game Programming Gurus. If you don´t have the book or the CD, then e-mail me at iliverotti@hotmail.com and I´ll send you the html file of the article (I´m afraid that the site that it was taken from is no longer available on the net).

This topic is closed to new replies.

Advertisement