How to get the resolution of the main monitor in Mac OS X in C ++?

I have a graphics application that needs to test the resolution of the display that it runs on Mac OS X to make sure that it is not larger than the resolution. This is done before the window itself is initialized.

If there is more than one display, this should be the primary display. This shows that applications with hardware acceleration (OpenGL) will start in full screen mode and, as a rule, will be displayed with the top menu bar.

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

+3
source share
1 answer

Using CoreGraphics:

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

Apple .

+6

Source: https://habr.com/ru/post/1697630/


All Articles