Get screen resolution programmatically in OS X

自古美人都是妖i 提交于 2020-01-02 01:30:09

问题


I'd like to launch a fullscreen 3D C++ application in native resolution on mac. How can I retrieve the native screen resolution ?


回答1:


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.



来源:https://stackoverflow.com/questions/4921817/get-screen-resolution-programmatically-in-os-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!