Gamma/brightness in Carbon
I use drawsprocket to change the brightness levels in OS 9, but the same call in X seems to work on every other frame or so, causing seizure-inducing flickering. Is there any way to fix this, or another way to change gamma?
There is a way to change the gamma by formula and/or restoring Colorsync settings.
The source code from this address comes with a working example of how to do it in Carbon (not sure whether it supports OS 9.0):
http://webpages.charter.net/fccovett/MyGameSource.dmg
The source code from this address comes with a working example of how to do it in Carbon (not sure whether it supports OS 9.0):
http://webpages.charter.net/fccovett/MyGameSource.dmg
I'd just use RezLib for your gamma stuff. I've had no problems with it. Unless there is a reason you're not using it?
-Jon
-Jon
Ack, dmg
Can't open in 9
Would it be possible to use both Rezlib and Drawsprocket happily in the same program?
Can't open in 9Would it be possible to use both Rezlib and Drawsprocket happily in the same program?
Code:
typedef struct
{
CGDirectDisplayID displayID;
CGRect displayBounds;
CGGammaValue redMin, redMax, redGamma, greenMin, greenMax, greenGamma, blueMin, blueMax, blueGamma;
}
DisplaySettings;
DisplaySettings dispSettings = {};
void GetCurrentDisplayGammaSettings()
{
//----------------------------------------------------------------------
// Fill out dispSettings with a display ID and the current gamma settings:
dispSettings.displayID = kCGDirectMainDisplay;
//----------------------------------------------------------------------
CGGetDisplayTransferByFormula(
dispSettings.displayID,
&dispSettings.redMin, &dispSettings.redMax, &dispSettings.redGamma,
&dispSettings.greenMin, &dispSettings.greenMax, &dispSettings.greenGamma,
&dispSettings.blueMin, &dispSettings.blueMax, &dispSettings.blueGamma
);
//----------------------------------------------------------------------
// Get main display bounds:
dispSettings.displayBounds = CGDisplayBounds( kCGDirectMainDisplay );
}
/----------------------------------------------------------------------
void FadeDisplayToBlack()
{
//----------------------------------------------------------------------
double fadeValue;
//----------------------------------------------------------------------
for( fadeValue = 1.0; fadeValue >= 0.0; fadeValue -= 0.01 )
{
CGSetDisplayTransferByFormula(
dispSettings.displayID,
dispSettings.redMin, fadeValue * dispSettings.redMax, dispSettings.redGamma,
dispSettings.greenMin, fadeValue * dispSettings.greenMax, dispSettings.greenGamma,
dispSettings.blueMin, fadeValue * dispSettings.blueMax, dispSettings.blueGamma
);
}
}
//----------------------------------------------------------------------
void FadeDisplayFromBlack()
{
//----------------------------------------------------------------------
double fadeValue;
//----------------------------------------------------------------------
for( fadeValue = 0.0; fadeValue <= 1.0; fadeValue += 0.01 )
{
CGSetDisplayTransferByFormula(
dispSettings.displayID,
dispSettings.redMin, fadeValue * dispSettings.redMax, dispSettings.redGamma,
dispSettings.greenMin, fadeValue * dispSettings.greenMax, dispSettings.greenGamma,
dispSettings.blueMin, fadeValue * dispSettings.blueMax, dispSettings.blueGamma
);
}
//----------------------------------------------------------------------
// Restore the user's ColorSync settings, just to be sure:
CGDisplayRestoreColorSyncSettings();
}Quote:Originally posted by David
Would it be possible to use both Rezlib and Drawsprocket happily in the same program?
It *should* work since RezLib uses DisplayManager in Classic so there won't be any API conflicts, but you might run into other problems.
But - I'm assuming you want to use DSp in classic and RezLib in X? Why not just use CGDirectDisplay in X (like RezLib does) and forget RezLib, or just use RezLib for both 9 & X and forget about DrawSprocket?
I will mention that RezLib has it's faults though. One being that it doesn't support "overbright" gamma ramps in Classic (like setting DrawSprocket's gamma over 100), and the second problem is that it doesn't capture the screen when switching resolutions, so all other applications will be affected (often to the dismay of your users).
I have a Carbon REALbasic plugin that provides a common API for DrawSprocket/CGDirectDisplay (here - full C source included). You're welcome to swipe any code ya like from that.

