Fix flickering problem when dynamically adjusting gamma with GUI.

This commit is contained in:
Joe Hager 2007-10-18 03:44:59 +00:00
parent af99d82411
commit a0415fa3d4
2 changed files with 31 additions and 15 deletions

View File

@ -70,6 +70,7 @@ osxGraphicsStateGuardian(GraphicsPipe *pipe,
_aglcontext(NULL)
{
SharedBuffer = 1011;
get_gamma_table();
}
////////////////////////////////////////////////////////////////////
@ -379,6 +380,16 @@ describe_pixel_format(FrameBufferProperties &fb_props) {
}
}
}
////////////////////////////////////////////////////////////////////
// Function: osxGraphicsStateGuardian::get_gamma_table
// Access: Public, Static
// Description: Static function for getting the orig gamma tables
////////////////////////////////////////////////////////////////////
bool osxGraphicsStateGuardian::get_gamma_table(void) {
CGDisplayRestoreColorSyncSettings();
_cgErr = CGGetDisplayTransferByTable( 0, 256, _gOriginalRedTable, _gOriginalGreenTable, _gOriginalBlueTable, &_sampleCount);
}
////////////////////////////////////////////////////////////////////
// Function: osxGraphicsStateGuardian::static_set_gamma
@ -397,16 +408,16 @@ static_set_gamma(bool restore, float gamma) {
set = true;
return set;
}
CGDisplayRestoreColorSyncSettings();
// CGDisplayRestoreColorSyncSettings();
CGGammaValue gOriginalRedTable[ 256 ];
CGGammaValue gOriginalGreenTable[ 256 ];
CGGammaValue gOriginalBlueTable[ 256 ];
// CGGammaValue gOriginalRedTable[ 256 ];
// CGGammaValue gOriginalGreenTable[ 256 ];
// CGGammaValue gOriginalBlueTable[ 256 ];
CGTableCount sampleCount;
CGDisplayErr cgErr;
// CGTableCount sampleCount;
// CGDisplayErr cgErr;
cgErr = CGGetDisplayTransferByTable( 0, 256, gOriginalRedTable, gOriginalGreenTable, gOriginalBlueTable, &sampleCount);
// cgErr = CGGetDisplayTransferByTable( 0, 256, _gOriginalRedTable, _gOriginalGreenTable, _gOriginalBlueTable, &_sampleCount);
CGGammaValue redTable[ 256 ];
CGGammaValue greenTable[ 256 ];
@ -426,13 +437,13 @@ static_set_gamma(bool restore, float gamma) {
for (i = 0; i < 256; i++)
{
redTable[i] = gOriginalRedTable[ i ] * (y[ 0 ] ) / 256;
greenTable[ i ] = gOriginalGreenTable[ i ] * (y[ 1 ] ) / 256;
blueTable[ i ] = gOriginalBlueTable[ i ] * (y[ 2 ] ) / 256;
redTable[i] = _gOriginalRedTable[ i ] * (y[ 0 ] ) / 256;
greenTable[ i ] = _gOriginalGreenTable[ i ] * (y[ 1 ] ) / 256;
blueTable[ i ] = _gOriginalBlueTable[ i ] * (y[ 2 ] ) / 256;
};
cgErr = CGSetDisplayTransferByTable( 0, 256, redTable, greenTable, blueTable);
_cgErr = CGSetDisplayTransferByTable( 0, 256, redTable, greenTable, blueTable);
if (cgErr == 0){
if (_cgErr == 0){
set = true;
}

View File

@ -44,10 +44,10 @@ public:
void draw_resize_box();
// static bool get_gamma_table(void);
static bool static_set_gamma(bool restore, float gamma);
bool get_gamma_table(void);
bool static_set_gamma(bool restore, float gamma);
bool set_gamma(float gamma);
static void atexit_function(void);
void atexit_function(void);
void restore_gamma();
protected:
@ -69,6 +69,11 @@ private:
PT(osxGraphicsStateGuardian) _share_with;
AGLPixelFormat _aglPixFmt;
AGLContext _aglcontext;
CGGammaValue _gOriginalRedTable[ 256 ];
CGGammaValue _gOriginalGreenTable[ 256 ];
CGGammaValue _gOriginalBlueTable[ 256 ];
CGTableCount _sampleCount;
CGDisplayErr _cgErr;
public:
GLint SharedBuffer;