I’m porting my Cocos2d-x app (runs on iOS & Android) to Mac.
I notice that the window that is created is hardcoded to 960x640.
As it’s a desktop, there could be a huge range in resolutions. 960x640 would be tiny on a 4K monitor for example.
So I’d like to base my window size on something that would be a reasonable size, how do I get the actual desktop resolution?
Thanks,
John.
In case anyone wants to know…
(hash)include < CoreGraphics/CGDirectDisplay.h >
int width = CGDisplayPixelsWide( kCGDirectMainDisplay );
int height = CGDisplayPixelsHigh( kCGDirectMainDisplay );

You should also be able to use GLFW for the same info.
auto screenSize = Size(960, 640);
glfwInit();
auto monitor = glfwGetPrimaryMonitor();
auto mode = glfwGetVideoMode(monitor);
if(mode) { screenSize.setSize(mode->width, mode->height); }
Edit: note that one may want to make sure they understand the init process for GLFW before using this :]
1 Like