CGDisplay problems

peacha
Unregistered
 
Post: #1
Hi all,
when I run a skeleton full screen app which switches res all the windows mess up once the app is done... I know it is normal if you do not capture the display... but I do

Code:
////////////////////////////////
typedef unsigned int uint;

int main ()
{
CFDictionaryRef originalMode;

originalMode = CGDisplayCurrentMode (kCGDirectMainDisplay);
CGDisplayCapture (kCGDirectMainDisplay);
CGDisplayHideCursor (kCGDirectMainDisplay);

if (!switchToMode (640, 480, 32))
{
// no error check yet!
}

CGDisplaySwitchToMode (kCGDirectMainDisplay, originalMode);
CFRelease (originalMode);
CGDisplayRelease (kCGDirectMainDisplay);
CGDisplayShowCursor (kCGDirectMainDisplay);

return 0;
}

bool switchToMode (uint newWidth, uint newHeight, uint newColorDepth)
{
    CFDictionaryRef newMode;
    boolean_t result;

    newMode = CGDisplayBestModeForParameters (kCGDirectMainDisplay, newColorDepth, newWidth, newHeight, &result);

    if (result)
        result = (CGDisplaySwitchToMode (kCGDirectMainDisplay, newMode) == kCGErrorSuccess);

    CFRelease (newMode);
    return result;
}
//////////////////////////////////
Any help??? Thx
Quote this message in a reply
Unregistered
Unregistered
 
Post: #2
You should not CFRelease() the display mode. Only CFRelease() things that you CFCreate*() or CFRetain()
Quote this message in a reply
peacha
Unregistered
 
Post: #3
Thanx you're right!Grin
Quote this message in a reply
Post Reply