SDL2 - 如何获得适当的显示分辨率

时间:2016-11-07 13:00:33

标签: sdl-2

我正在尝试使用SDL2打开全屏窗口。我已经彻底查看了关于显示和窗口管理(https://wiki.libsdl.org/CategoryVideo)的文档......但是我不明白获得我实际工作的显示分辨率的最佳实践。

我有以下示例代码:

SDL_DisplayMode mMode;
SDL_Rect mRect;

int ret0 = SDL_GetDisplayBounds(0, &mRect);
std::cout << "bounds w and h are: " << mRect.w << " x " << mRect.h << std::endl;
int ret2 = SDL_GetCurrentDisplayMode(0, &mMode);
std::cout << "current display res w and h are: " << mMode.w << " x " << mMode.h << std::endl;
int ret3 = SDL_GetDisplayMode(0, 0, &mMode);
std::cout << "display mode res w and h are: " << mMode.w << " x " << mMode.h << std::endl;

我正在制作一台分辨率为1920x1080的显示器。但是,打印结果如下:

program output

似乎SDL_GetDisplayMode()是唯一显示正确分辨率的函数,所以我倾向于使用那个。但是,我已经读过,当涉及到SDL_GetDisplayMode()时,显示模式会根据某个优先级进行排序,因此使用0调用它会返回显示的最大支持分辨率,这不一定是实际的分辨率(请参阅还有:SDL desktop resolution detection in Linux)。

我的问题是:获得正确分辨率的最佳做法是什么?

0 个答案:

没有答案
相关问题