Question

I have a graphical app that needs to test the resolution of the display it is starting up on in Mac OS X to ensure it is not larger than the resolution. This is done before the window itself is initialized.

If there is more than one display, it needs to be the primary display. This is the display that hardware accelerated (OpenGL) apps will start up on in Full Screen, and is typically the display that has the menu bar at the top.

In Windows, I can successfully use GetSystemMetrics(). How can I do this on OS X?

Was it helpful?

Solution

Using CoreGraphics:

CGRect mainMonitor = CGDisplayBounds(CGMainDisplayID());
CGFloat monitorHeight = CGRectGetHeight(mainMonitor);
CGFloat monitorWidth = CGRectGetWidth(mainMonitor);

More information at Apple's Quartz Display Services Reference.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top