SDL 2.0 retina mac

主宰稳场 提交于 2019-12-09 15:42:12

问题


I have been playing around with SDL 2.0 but after searching I haven't found anything online about how to support retina macs. When creating a window using the following code.

gWindow = SDL_CreateWindow("SDL Tutorial", SDL_WINDOWPOS_UNDEFINED,
          SDL_WINDOWPOS_UNDEFINED, 500, 500, SDL_WINDOW_SHOWN);

It creates a window that has an actual size of 1000 * 1000. This isn't really an issue because it's how apps are supposed to work using a hidpi screen. However, when loading images I can't seem to find a way to load images that are 2x as big for retina screens and my images always look blurry.


回答1:


Current versions of SDL2 have support for retina.

To create a retina window, pass a flag SDL_WINDOW_ALLOW_HIGHDPI into SDL_CreateWindow().

After a resize event, you can check the actual buffer resolution with the API call SDL_GL_GetDrawableSize().




回答2:


Right now, SDL doesn't support retina displays on Macs (or High-DPI displays on Windows machines).

There is discussion about how best to add these features, and a few prototype patches on SDL's bug tracker, here: https://bugzilla.libsdl.org/show_bug.cgi?id=1934

Presumably we'll see official retina support in a future release of SDL2. Or if you're willing to compile your own SDL libraries, those patches work for me.



来源:https://stackoverflow.com/questions/18544881/sdl-2-0-retina-mac

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