Get screen resolution programmatically in OS X

If you are looking for a multiplatform solution for both mac and windows

#include "ScreenSize.h"

#if WIN32
#include <windows.h>
#else
#include <CoreGraphics/CGDisplayConfiguration.h>
#endif

void ScreenSize::getScreenResolution(unsigned int& width, unsigned int& height) {
#if WIN32
    width = (int)GetSystemMetrics(SM_CXSCREEN);
    height = (int)GetSystemMetrics(SM_CYSCREEN);
#else
    auto mainDisplayId = CGMainDisplayID();
    width = CGDisplayPixelsWide(mainDisplayId);
    height = CGDisplayPixelsHigh(mainDisplayId);
#endif
}

Note: You also need to link the CoreGraphics framework to your project. If you are using cmake, link your needed framework like the following:

    target_link_libraries(${PROJECT_NAME}
        "-framework CoreGraphics"
        "-framework Foundation"
    )

If you don't wish to use Objective C, get the display ID that you wish to display on (using e.g. CGMainDisplayID), then use CGDisplayPixelsWide and CGDisplayPixelsHigh to get the screen width and height, in pixels. See "Getting Information About Displays" for how to get other display information.

If you're willing to use a bit of Objective-C, simply use [[NSScreen mainScreen] frame].

Note that there are other concerns with full screen display, namely ensuring other applications don't do the same. Read "Drawing to the Full Screen" in Apple's OpenGL Programming Guide for more.