diff --git a/panda/src/osxdisplay/osxGraphicsStateGuardian.cxx b/panda/src/osxdisplay/osxGraphicsStateGuardian.cxx index dbb133452d..e27f1ae3e3 100644 --- a/panda/src/osxdisplay/osxGraphicsStateGuardian.cxx +++ b/panda/src/osxdisplay/osxGraphicsStateGuardian.cxx @@ -379,3 +379,75 @@ describe_pixel_format(FrameBufferProperties &fb_props) { } } } + +//////////////////////////////////////////////////////////////////// +// Function: osxGraphicsStateGuardian::static_set_gamma +// Access: Public, Static +// Description: Static function for setting gamma which is needed +// for atexit. +//////////////////////////////////////////////////////////////////// +bool osxGraphicsStateGuardian:: +static_set_gamma(float gamma) { + bool set; + + set = false; + + CGGammaValue gOriginalRedTable[ 256 ]; + CGGammaValue gOriginalGreenTable[ 256 ]; + CGGammaValue gOriginalBlueTable[ 256 ]; + + CGTableCount sampleCount; + CGDisplayErr cgErr; + + cgErr = CGGetDisplayTransferByTable( 0, 256, gOriginalRedTable, gOriginalGreenTable, gOriginalBlueTable, &sampleCount); + + CGGammaValue redTable[ 256 ]; + CGGammaValue greenTable[ 256 ]; + CGGammaValue blueTable[ 256 ]; + + short j, i; + short y[3]; + + y[0] = 256 * gamma; + y[1] = 256 * gamma; + y[2] = 256 * gamma; + + 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); + + if (cgErr == 0){ + set = true; + } + + return set; +} + +//////////////////////////////////////////////////////////////////// +// Function: osxGraphicsStateGuardian::set_gamma +// Access: Published +// Description: Non static version of setting gamma. Returns true +// on success. +//////////////////////////////////////////////////////////////////// +bool osxGraphicsStateGuardian:: +set_gamma(float gamma) { + bool set; + + set = static_set_gamma(gamma); + + return set; +} + +//////////////////////////////////////////////////////////////////// +// Function: osxGraphicsStateGuardian::atexit_function +// Access: Public, Static +// Description: This function is passed to the atexit function. +//////////////////////////////////////////////////////////////////// +void osxGraphicsStateGuardian:: +atexit_function(void) { + static_set_gamma(1.0); +} + + diff --git a/panda/src/osxdisplay/osxGraphicsStateGuardian.h b/panda/src/osxdisplay/osxGraphicsStateGuardian.h index 7908ad3015..3bd988b119 100644 --- a/panda/src/osxdisplay/osxGraphicsStateGuardian.h +++ b/panda/src/osxdisplay/osxGraphicsStateGuardian.h @@ -16,6 +16,7 @@ #ifndef OSXGRAPHICSSTATEGUARDIAN_H #define OSXGRAPHICSSTATEGUARDIAN_H #include +#include #define __glext_h_ #include @@ -42,6 +43,11 @@ public: virtual void reset(); void draw_resize_box(); + +// static bool get_gamma_table(void); + static bool static_set_gamma(float gamma); + bool set_gamma(float gamma); + static void atexit_function(void); protected: virtual void *get_extension_func(const char *prefix, const char *name); diff --git a/panda/src/osxdisplay/osxGraphicsWindow.mm b/panda/src/osxdisplay/osxGraphicsWindow.mm index 7aa9d638a0..ceaed4d291 100644 --- a/panda/src/osxdisplay/osxGraphicsWindow.mm +++ b/panda/src/osxdisplay/osxGraphicsWindow.mm @@ -315,7 +315,7 @@ static pascal OSStatus windowEvtHndlr(EventHandlerCallRef myHandler, EventRef ev void osxGraphicsWindow::DoResize(void) { - osxdisplay_cat.debug() << "In Resize Out....." << _properties << "\n"; + osxdisplay_cat.info() << "In Resize....." << _properties << "\n"; // only in window mode .. not full screen if(_osx_window != NULL && _is_fullscreen == false && _properties.has_size()) @@ -958,6 +958,8 @@ bool osxGraphicsWindow::OSOpenWindow(WindowProperties &req_properties) if (req_properties.has_fullscreen() && req_properties.get_fullscreen()) { + osxdisplay_cat.info() << "Creating full screen\n"; + // capture the main display CGDisplayCapture( kCGDirectMainDisplay ); // if sized try and switch it.. @@ -1035,6 +1037,8 @@ bool osxGraphicsWindow::OSOpenWindow(WindowProperties &req_properties) NSRect aRect = [aView frame]; NSPoint origin = [parentWindow convertBaseToScreen:aRect.origin]; + osxdisplay_cat.info() << "Creating child window\n"; + CreateNewWindow(kSimpleWindowClass, kWindowNoAttributes, &r, &_osx_window); NSWindow* childWindow = [[NSWindow alloc] initWithWindowRef:_osx_window]; @@ -1051,6 +1055,8 @@ bool osxGraphicsWindow::OSOpenWindow(WindowProperties &req_properties) if (req_properties.has_undecorated() && req_properties.get_undecorated()) { // create a unmovable .. no edge window.. + osxdisplay_cat.info() << "Creating undecorated window\n"; + CreateNewWindow(kDocumentWindowClass, kWindowStandardDocumentAttributes | kWindowNoTitleBarAttribute, &r, &_osx_window); } else @@ -1066,6 +1072,7 @@ bool osxGraphicsWindow::OSOpenWindow(WindowProperties &req_properties) r.top = max(r.top, bounds.top); r.bottom = min(r.bottom, bounds.bottom); + osxdisplay_cat.info() << "Creating standard window\n"; CreateNewWindow(kDocumentWindowClass, kWindowStandardDocumentAttributes | kWindowStandardHandlerAttribute, &r, &_osx_window); } } @@ -1638,6 +1645,8 @@ if (osxdisplay_cat.is_debug()) bool osxGraphicsWindow::do_reshape_request(int x_origin, int y_origin, bool has_origin,int x_size, int y_size) { + osxdisplay_cat.info() << "Do Reshape\n"; + if (_properties.get_fullscreen()) { // Can't resize fullscreen windows that easily. return false;