iDevGames Forums
CGDisplay problems - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: CGDisplay problems (/thread-7764.html)



CGDisplay problems - peacha - May 14, 2002 02:53 AM

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


CGDisplay problems - Unregistered - May 17, 2002 06:55 AM

You should not CFRelease() the display mode. Only CFRelease() things that you CFCreate*() or CFRetain()


CGDisplay problems - peacha - May 18, 2002 01:35 PM

Thanx you're right!Grin