在OS X中以编程方式获取屏幕分辨率 [英] Get screen resolution programmatically in OS X

查看:279
本文介绍了在OS X中以编程方式获取屏幕分辨率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Mac上以原生分辨率启动全屏3D C ++应用程序。
如何检索原生屏幕分辨率?

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

推荐答案

如果你不想使用Objective C,get您希望在其上显示的显示ID(使用例如 CGMainDisplayID ),然后使用 CGDisplayPixelsWide CGDisplayPixelsHigh 来获取屏幕宽度和高度,以像素为单位。请参阅获取有关显示的信息了解如何获取其他显示信息。

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.

如果你愿意使用一点Objective-C,只需使用 [[NSScreen mainScreen] frame]

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

请注意,全屏显示还有其他问题,即确保其他应用程序不会这样做。阅读绘制全屏 Apple's OpenGL Programming Guide for more。

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.

这篇关于在OS X中以编程方式获取屏幕分辨率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆