Fading in DirectDraw

Started by
2 comments, last by CutterSlade 22 years, 2 months ago
Hello. I''m desperatly looking for a fast and smooth way to perform fade-in and out operations in a 640x480 16 bit screen. I''ve just read an article on how to do that using gamma controls, but I think it performs a fade too jerkly (if that''s a word...). Any leads on articles or websites would be greatly appreciated!
--------------------------------------------------------- There are 10 kinds of people: those who know binary and those who don't
Advertisement
Using the gamma controls would be the fastest and simplest way to do it (Are you sure you''re doing it right, I''ve seen gamma adjustment fadeouts before and they looked fine). The only other way of doing it in 16bit is by modifying all the pixels on the screen. Just lock the surface and get, modify and set each pixel on the screen. I''ve found that (R-Amount,G-Amount,B-Amount) is actually very good (visually) approximation instead of doing (L-Amount,Cr,Cb) which requires a 2 conversions (RGB-YUV, YUV-RGB) for each pixel.
The code I have goes like this:
  for(int blackloop=0;blackloop<255;blackloop++){	if(DDGammaRamp.red[blackloop] > 0) 	{ 	    DDGammaRamp.red[blackloop]=0; 	    lpDDGammaControl->SetGammaRamp(DDSGR_CALIBRATE, &DDGammaRamp);         }	Sleep(1); 	if(DDGammaRamp.green[blackloop] > 0)	{	    DDGammaRamp.green[blackloop]=0; 	    lpDDGammaControl->SetGammaRamp(DDSGR_CALIBRATE, &DDGammaRamp);        }	Sleep(1);   	if(DDGammaRamp.blue[blackloop] > 0) 	{	    DDGammaRamp. blue [blackloop]=0; 	    lpDDGammaControl->SetGammaRamp(DDSGR_CALIBRATE, &DDGammaRamp);	} 	Sleep(1);}  


Any tips on how I can improve this?

--------------------------------------------------------- There are 10 kinds of people: those who know binary and those who don't
If that''s the way you''re doing it, then I''m quite surprised you even got it to do a fade if you''re using a backbuffer.

Instead of doing everything in a for loop, you do it every frame in your main loop. Then use a sleep of 10-20 for each frame. That should give you a nice fade.

This topic is closed to new replies.

Advertisement