#### Archived

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

# there's something wrong with my D3DGAMMARAMP..., :(

## Recommended Posts

i''ve tried lots of stuffs with it already, and this one here is the last code i tried, for(DWORD i = 0; i < 255; i++) { d3dRamp.red = gamma*256; d3dRamp.green[i] = gamma*256; d3dRamp.blue[i] = gamma*256; } where gamma is from 1 to 256, this thing achieve the fadein/out i want, but first, it changes the color of my screen to say, for example, pink, before it applies the fade.., also one more thing, i thought these ramps contains WORD? i do not understand, when i output say, d3dRamp.red[150], i also get the value 150?? thanks!

anyone plz?

thanks,

##### Share on other sites
hi, i still haven''t solved my problem here..,

thanks,

##### Share on other sites
Hi, I had to deal with gamma ramps few weeks ago, and I would like to help you:

to understand you have first to build a default gammaramp that will not modify
the colors of your scene at all!
->that''s the code

D3DGAMMARAMP *pGammaRamp;
for(int i=0; i<256; i++) { pGammaRamp->red=257*i; pGammaRamp->green[i]=257*i; pGammaRamp->blue[i]=257*i; }
d3ddevice->SetGammaRamp(D3DSGR_NO_CALIBRATION, pGammaRamp);

after doing that you will not notice any color change.
you should notice that the values in pGammaRamp->red[i] are not equal to i! ie pGammaRamp->red[255]=65535

Ok, now you have to play with the r/g/b channels, assigning them values from 0 to 65535 (not 65536 !)

this is an example of how to fade your scene from normal colors to red shaded color:

// set the default ramp at the beginning
D3DGAMMARAMP *pGammaRamp;
for(int i=0; i<256; i++) { pGammaRamp->red[i]=257*i; pGammaRamp->green[i]=257*i; pGammaRamp->blue[i]=257*i; }

{
for(int i=0; i<256; i++) { if(pGammaRamp->red[i]+1000<65535) { pGammaRamp->red[i]+=1000; } }
cdx8->d3ddevice->SetGammaRamp(D3DSGR_NO_CALIBRATION, pGammaRamp);
}

// restore the gamma ramp
for(int i=0; i<256; i++) { pGammaRamp->red[i]=257*i; pGammaRamp->green[i]=257*i; pGammaRamp->blue[i]=257*i; }
cdx8->d3ddevice->SetGammaRamp(D3DSGR_NO_CALIBRATION, pGammaRamp);

##### Share on other sites
hi, thanks pal, it's been quite a well this post was, and thanks a lot and i've finally got an answer,

but plz, before you go, i got a few more questions,

what does this D3DSGR_NO_CALIBRATION and this D3DSGR_CALIBRATION really do? or mean(i didn't really quite understand the MSDN)?

if(pGammaRamp->red+1000<65535)
what does that line really mean? i get strange result if i commented out that statement, same results i get before,

also i can't perform the fade to black? this is what i did,

    for(int i = 0; i < 256; i++){if(m_d3dRamp.red[i]+1000<65535){	m_d3dRamp.red[i]-=1000;}if(m_d3dRamp.blue[i]+1000<65535){	m_d3dRamp.blue[i]-=1000;}if(m_d3dRamp.green[i]+1000<65535){	m_d3dRamp.green[i]-=1000;}}

again, thanks!!

[edited by - mickey on June 18, 2002 12:48:57 PM]

[edited by - mickey on June 18, 2002 12:50:32 PM]

• ### Forum Statistics

• Total Topics
628318
• Total Posts
2982043

• 9
• 9
• 13
• 11
• 15