Programmatically change resolution OS X

2020-06-06 20:13发布

My question is simple. I am developing a game and, as the title states, I want to be able to programmatically change the display resolution / refresh rate on OS X. I've been searching for this for hours and couldn't find anything. I already know how to create a full screen window.

I would also want to get the list of supported resolutions and refresh rates

1条回答
家丑人穷心不美
2楼-- · 2020-06-06 20:52

From Apple's OpenGL Programming Guide for Mac OS X: Drawing to the Full Screen:

Avoid changing the display resolution from that chosen by the user. If your application needs to render data at a lower resolution for performance reasons, you can explicitly create a back buffer at the desired resolution and allow OpenGL to scale those results to the display. See “Controlling the Back Buffer Size.”

That said, if you really want to do this, you can use Quartz Display Services. See "Changing Display Modes". You should really capture the display, as described elsewhere in that guide, before changing the display configuration or else other applications will have their windows moved and resized and your users will be annoyed. (For example, their desktop icons may get rearranged.)

查看更多
登录 后发表回答