Best way to switch screen res?

Member
Posts: 110
Joined: 2002.04
Post: #1
Hi

What is the best way to switch screen res for a game that does not use opengl?

Im using CoreGraphics right now....
Which moves the users windows a round. Mad

Other ideas?

- Mac Lead ZeniMax Online Studios
- Owner Plaid World Studios
- Resume: http://www.chrisdillman.com
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
Always capture the display before changing resolution.
Quote this message in a reply
Member
Posts: 110
Joined: 2002.04
Post: #3
Quote:Originally posted by OneSadCookie
Always capture the display before changing resolution.


And how would one go about this?

AKA... what API etc am I looking for?

- Mac Lead ZeniMax Online Studios
- Owner Plaid World Studios
- Resume: http://www.chrisdillman.com
Quote this message in a reply
Member
Posts: 156
Joined: 2002.11
Post: #4
Had you downloaded the source, you would have known it by now. Smile

Code:
void SwitchMainDisplayResolution()
{
    CGDisplayCapture( kCGDirectMainDisplay );
    
    //----------------------------------------------------------------------
    // Try to switch to a display mode with resolution 640 x 480,
    // depth 32 bpp, and refresh rate 60 hertz:

    CFDictionaryRef    displayMode;

    //----------------------------------------------------------------------

    displayMode = CGDisplayBestModeForParametersAndRefreshRate(
                                                               kCGDirectMainDisplay,
                                                               32,
                                                               640, 480,
                                                               60,
                                                               NULL
                                                               );

    //----------------------------------------------------------------------

    CGDisplaySwitchToMode( kCGDirectMainDisplay, displayMode );

    //----------------------------------------------------------------------

    CGDisplayRelease ( kCGDirectMainDisplay );
}
Quote this message in a reply
Member
Posts: 110
Joined: 2002.04
Post: #5
Quote:Originally posted by FCCovett
Had you downloaded the source, you would have known it by now. Smile


You mean...
If I had bothered to actually look at the source Wink
Had not the time yet...
On phone with apple trying to get a iBook fixed. ugg

Any how thanks much... will try this tonight.

- Mac Lead ZeniMax Online Studios
- Owner Plaid World Studios
- Resume: http://www.chrisdillman.com
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #6
There is a problem on Panther with capturing a single display (search mac-opengl and/or mac-games-dev for the thread).

I've always used CGCaptureAllDisplays anyway -- I think it's a better user experience.
Quote this message in a reply
Moderator
Posts: 3,577
Joined: 2003.06
Post: #7
Yeah, and it STILL doesn't work right 100% of the time with multiple monitors. Grrrrr...
Quote this message in a reply
Moderator
Posts: 522
Joined: 2002.04
Post: #8
Alternatively, check out ModeWhacker. I modified the main like this to capture the displays. It leaves your windows alone!

-Jon

Code:
int
main(int argc, const char *argv[])
{
    CGDirectDisplayID display[kMaxDisplays];
    CGDisplayCount numDisplays;
    CGDisplayCount i;
    CGDisplayErr err;

    err = CGGetActiveDisplayList(kMaxDisplays,
                                 display,
                                 &numDisplays);
    if ( err != CGDisplayNoErr )
    {
        printf("Cannot get displays (%d)\n", err);
        exit( 1 );
    }
    printf( "%d displays found\n", (int)numDisplays );
    
    err = CGCaptureAllDisplays();
    if ( err != CGDisplayNoErr )
    {
    printf("Cannot capture all displays (%d)\n", err);
    exit( 1 );
    }
    
    for ( i = 0; i < numDisplays; ++i )
    {
        modewhacker(display[i]);
    }
    
    err = CGReleaseAllDisplays();
    if ( err != CGDisplayNoErr )
    {
    printf("Cannot release all displays (%d)\n", err);
    exit( 1 );
    }
    
    exit(0);
}
Quote this message in a reply
Moderator
Posts: 522
Joined: 2002.04
Post: #9
Quote:Originally posted by FCCovett
Check out the source from this thread (make sure to use the most recent link - the web-site with the source has moved):

http://www.idevgames.com/forum/showthrea...#post51277


I tried that out, and I uncommented all the screen changing stuff from your main to try that out. It didn't work. (Windows got resized and for some reason the menu bar in Xcode got screwed up and I had to relaunch Xcode) If you plan on updating MyGame, I'd suggest putting in a Fullscreen menu option.

-Jon
Quote this message in a reply
Moderator
Posts: 3,577
Joined: 2003.06
Post: #10
Quote:Originally posted by aarku
Alternatively, check out ModeWhacker. I modified the main like this to capture the displays. It leaves your windows alone!

-Jon
It works perfectly so far! You get a star!

I'm still skeptical though... I just KNOW I'll find more junk if I beat it up enough.Smile

Thank you.
Quote this message in a reply
Member
Posts: 110
Joined: 2002.04
Post: #11
Modewhacker

Ah perfect I never noticed the screen capture part of that app.

I think my code was based on it

- Mac Lead ZeniMax Online Studios
- Owner Plaid World Studios
- Resume: http://www.chrisdillman.com
Quote this message in a reply
Member
Posts: 110
Joined: 2002.04
Post: #12
Ok another issue

calling CGCaptureAllDisplays();

Works fine.

Except that none of my previouse window code seems to work at all... windows do not draw etc...
or in this case dialogs read from res files.

Any thought?

Do I need to some how bless the current window.

Im looking through code and not noticing anything.

- Mac Lead ZeniMax Online Studios
- Owner Plaid World Studios
- Resume: http://www.chrisdillman.com
Quote this message in a reply
Moderator
Posts: 3,577
Joined: 2003.06
Post: #13
Okay, after all these years of programming on Macs since system 7, I'm going to just blow a gasket on this one. ENOUGH!!! This screen/pixel/capturing/context/port thing has gone on long enough! When will they (Apple) put somebody in the seat that can make it simple and straight-forward? Why do we constantly have to fight with this? I can't possibly count the number of different hoops I've had to jump through with every single fudsing release FOR THIRTEEN YEARS to get this simple task accomplished! End gasket blowing. Sorry.

Should we start a petition?
Quote this message in a reply
Member
Posts: 110
Joined: 2002.04
Post: #14
Quote:Originally posted by AnotherJake
Okay, after all these years of programming on Macs since system 7, I'm going to just blow a gasket on this one. ENOUGH!!! This screen/pixel/capturing/context/port thing has gone on long enough! When will they (Apple) put somebody in the seat that can make it simple and straight-forward? Why do we constantly have to fight with this? I can't possibly count the number of different hoops I've had to jump through with every single fudsing release FOR THIRTEEN YEARS to get this simple task accomplished! End gasket blowing. Sorry.

Should we start a petition?


No No it is perfectly fine to feel that way...
Im on liek 10+ years of mac game programming and damn if that was not always one of the biggest pain in the ass issues I ever had to deal with on the mac :-)
So I feel your pain...

- Mac Lead ZeniMax Online Studios
- Owner Plaid World Studios
- Resume: http://www.chrisdillman.com
Quote this message in a reply
Member
Posts: 446
Joined: 2002.09
Post: #15
Quote:Originally posted by ChrisD
Except that none of my previouse window code seems to work at all... windows do not draw etc...
or in this case dialogs read from res files.

They're drawing just fine, they're just _under_ the CoreGraphics blanking window.

I hacked around this in a REALBasic plugin: <http://webhome.idirect.com/~frankco/rb/d..._v10b1.sit> full source is included (it's CFM Carbon but will work in Macho as-is - just ignore the runtime glue). One problem I haven't been able to solve is that Carbon has no concept "menu" windows, so they still draw under the blanking window (if you can avoid popup menus in your GUI you should be fine, otherwise you might need to use Cocoa).
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  OpenGL full screen mode leaves garbage on screen when exiting app Malarkey 5 5,290 Nov 19, 2008 12:51 PM
Last Post: Malarkey
  Fullscreen/resolution switch causes texture loss IBethune 4 4,294 Feb 21, 2008 01:37 PM
Last Post: OneSadCookie
  fullscreen-window mode switch NYGhost 10 5,471 Feb 10, 2005 09:52 AM
Last Post: NYGhost
  Switch Between Fullscreen and Windowed Modes - Again... thaeez 2 2,972 Jul 9, 2004 02:49 AM
Last Post: thaeez
  OpenGL CGL Switch Between Fullscreen and Windowed Mode thaeez 1 3,309 Jun 30, 2004 04:29 AM
Last Post: OneSadCookie