• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: CGDisplaySetDisplayMode only working properly after calling twice in a row
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CGDisplaySetDisplayMode only working properly after calling twice in a row


  • Subject: Re: CGDisplaySetDisplayMode only working properly after calling twice in a row
  • From: Matthias Dörfelt <email@hidden>
  • Date: Wed, 21 May 2014 15:45:59 -0700

Okay,

I just investigated this issue a little more. It only happens under one condition for me, which is that I created an NSOpenGLPixelFormat before the CGDisplay calls, i.e. this does not work as expected:


#import "AppDelegate.h"
#include <CoreGraphics/CoreGraphics.h>

@implementation AppDelegate

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    // Insert code here to initialize your application

    NSOpenGLPixelFormatAttribute attrs[] =
    {
        NSOpenGLPFADoubleBuffer,
        0
    };
    NSOpenGLPixelFormat* pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs];


    CFArrayRef allModes = CGDisplayCopyAllDisplayModes(CGMainDisplayID(), NULL);
    if(allModes)
    {
        for(int i = 0; i < CFArrayGetCount(allModes); i++)
        {
            CGDisplayModeRef mode = (CGDisplayModeRef)CFArrayGetValueAtIndex(allModes, i);

            Size width = CGDisplayModeGetWidth(mode);
            Size height = CGDisplayModeGetHeight(mode);

            if(width == 800 && height == 600)
            {
                CGDisplaySetDisplayMode(CGMainDisplayID(), mode, NULL);
                //CGDisplaySetDisplayMode((CGDirectDisplayID)_id, mode, NULL);
                break;
            }
        }

        CFRelease(allModes);
    }
}

@end


while the same code without the creation of the NSOpenGLPixelFormat does. this is really really odd, is there any way to fix this? Bug?

Best,
Matthias

Am 21.05.2014 um 14:05 schrieb Matthias Dörfelt <email@hidden>:

> Hey,
>
> I am experiencing some really weird behavior with CGDisplaySetDisplayMode behavior on osx 10.9.3 on a late 2013 retina mbp.
>
> if I call CGDisplaySetDisplayMode only once, it seems to end up in weird display modes, that are not even listed through CGDisplayCopyAllDisplayModes i.e. oftentimes 16 bit modes. If I call CGDisplaySetDisplayMode again right afterwards, it goes to the desired mode. Here is a very simple example:
>
> if I do:
>
> GDisplayModeRef originalMode = CGDisplayCopyDisplayMode(CGMainDisplayID());
> CGDisplaySetDisplayMode(CGMainDisplayID(), originalMode, NULL);
> CGDisplayModeRelease(originalMode);
>
> It goes from the current mode (1440x900,32 bit hidpi) to the same mode in 16 bit!!
>
> If I do:
>
> GDisplayModeRef originalMode = CGDisplayCopyDisplayMode(CGMainDisplayID());
> CGDisplaySetDisplayMode(CGMainDisplayID(), originalMode, NULL);
> CGDisplaySetDisplayMode(CGMainDisplayID(), originalMode, NULL);
> CGDisplayModeRelease(originalMode);
>
> it arrives at the correct mode.
>
> This is the simplest test case I could come up with as I was getting similar garbage when using CGDisplayCopyAllDisplayModes
> to select a specific mode, i.e:
>
>
>                CFArrayRef allModes = CGDisplayCopyAllDisplayModes(_id, NULL);
>                if(allModes)
>                {
>                    for(int i = 0; i < CFArrayGetCount(allModes); i++)
>                    {
>                        CGDisplayModeRef mode = (CGDisplayModeRef)CFArrayGetValueAtIndex(allModes, i);
>
>                        Size width = CGDisplayModeGetWidth(mode);
>                        Size height = CGDisplayModeGetHeight(mode);
>
>                        if(width == 800 && height == 600)
>                        {
>                            CGDisplaySetDisplayMode((CGDirectDisplayID)_id, mode, NULL);
>                            //CGDisplaySetDisplayMode((CGDirectDisplayID)_id, mode, NULL);
>                            break;
>                        }
>                    }
>
>                    CFRelease(allModes);
>                }
>
> Only properly goes to 800x600 if I uncomment the second call to CGDisplaySetDisplayMode this seems really odd…
> Any ideas?
>
> thanks,
> Matthias
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: CGDisplaySetDisplayMode only working properly after calling twice in a row
      • From: Ken Thomases <email@hidden>
References: 
 >CGDisplaySetDisplayMode only working properly after calling twice in a row (From: Matthias Dörfelt <email@hidden>)

  • Prev by Date: CGDisplaySetDisplayMode only working properly after calling twice in a row
  • Next by Date: NSOpenGLView and setNeedsDisplayInRect()...
  • Previous by thread: CGDisplaySetDisplayMode only working properly after calling twice in a row
  • Next by thread: Re: CGDisplaySetDisplayMode only working properly after calling twice in a row
  • Index(es):
    • Date
    • Thread