Advertisement

Gamma problems

Started by January 24, 2000 11:22 PM
2 comments, last by Armera 25 years, 1 month ago
I read Fernalds article on the setting the gamma ramp values using the GAMMARAMP struct in DirectDraw. I am in 640 by 480 mode at 32 bpp.I used the code in the article and when I tried to perform a simple fade on the primary surface, it was very horrible looking and eventually went to pure red. I dont thinkmy card supports it and I dont think that should make a difference since the article said it would simulate it. Thanks for any help.
It's not reverse engineering, unless you get caught.
I also had problems with this function. But on my computer it only returns errors.
Write your code down here so I can compare my code with it.
Advertisement
This here is global data.
//initialize the gamma control so that we can use it.
LPDIRECTDRAWGAMMACONTROL lpDDGammaControl = NULL;

//this structure will be the ramp value that we modify
DDGAMMARAMP DDGammaRamp;

//this structure will hold the old gamma values so that we can reset our video card after our fade is complete.
DDGAMMARAMP DDGammaOld;


And this is in my WinMain function.

lpddsprimary->QueryInterface(IID_IDirectDrawGammaControl,(void **)&lpDDGammaControl);

Next we need to find out what the current gamma settings are on your video card right now and store it in our DDGAMMAOLD structure:

lpDDGammaControl->GetGammaRamp(0, &DDGammaOld);

Let's perform that task one more time and save the values to our DDGAMMARAMP structure so that we can modify the values:

lpDDGammaControl->GetGammaRamp(0, &DDGammaRamp);

for(int blackloop=0;blackloop<256;blackloop++)
{

//we wouldn't want to decrement a value unless it's greater than 0
if(DDGammaRamp.red[blackloop] > 0)
{
//set the current value of DDGammaRamp.Red to 0.
DDGammaRamp.red[blackloop]=0;
//now let's update our primary
lpDDGammaControl->SetGammaRamp(0, &DDGammaRamp);
// Set the surface with the new gamma setting

} //end if

//the routine was a little too fast so this slows it down a bit….
Sleep(1);

//we wouldn't want to decrement a value unless it's greater than 0
if(DDGammaRamp.green[blackloop] > 0)
{
//set the current value of DDGammaRamp.yellow to 0.
DDGammaRamp.green[blackloop]=0;
lpDDGammaControl->SetGammaRamp(DDSGR_CALIBRATE, &DDGammaRamp);
} //end if

//the routine was a little too fast so this slows it down a bit….
Sleep(1);

//we wouldn't want to decrement a value unless it's greater than 0
if(DDGammaRamp.blue[blackloop] > 0)
{
//set the current value of DDGammaRamp.Blue to 0.
DDGammaRamp. blue [blackloop]=0;
lpDDGammaControl->SetGammaRamp(DDSGR_CALIBRATE, &DDGammaRamp);

} //end if

//the routine was a little too fast so this slows it down a bit….
Sleep(1);

} //end for


After the bitmap loads on the screen it disintegrates very horribly and then eventually to red.

Edited by - Armera on 1/25/00 9:56:15 AM
It's not reverse engineering, unless you get caught.
Well, my code looks exactly the same.
Does the functions Get and SetGammaRamp return DDERR_INVALIDPARAMS errors on your computer as well?

This topic is closed to new replies.

Advertisement