【发布时间】:2015-01-05 08:02:45
【问题描述】:
我有创建多台显示器可用分辨率列表的 Windows 代码。
现在我必须将它移植到 Linux 上,所以我正在考虑使用“FREEGLUT”,这样我就可以使用相同的代码获取 Linux 和 Windows 的监视器相关信息。
我需要帮助以获得一些指针以获取多台显示器的所有支持分辨率..?
我希望我们可以使用免费的过剩来做到这一点..
【问题讨论】:
标签: c++ linux winapi opengl glut
我有创建多台显示器可用分辨率列表的 Windows 代码。
现在我必须将它移植到 Linux 上,所以我正在考虑使用“FREEGLUT”,这样我就可以使用相同的代码获取 Linux 和 Windows 的监视器相关信息。
我需要帮助以获得一些指针以获取多台显示器的所有支持分辨率..?
我希望我们可以使用免费的过剩来做到这一点..
【问题讨论】:
标签: c++ linux winapi opengl glut
Linux 本身没有图形系统。你必须依赖像 X11 或 Wayland 这样的东西。现在 X11 是常用的系统,用于枚举和配置监视器的 X11-API 称为 XRandR。 FreeGLUT 并没有真正公开这个功能。所以要么使用一个框架,要么自己实现它。
请注意,当涉及到多监视器环境时,窗口管理器也对窗口放置有发言权。
【讨论】:
我正在使用 GLFW 3.0.4 来获得支持的多显示器分辨率。 我更喜欢使用特定于平台的功能来应用显示器分辨率。
// Get Resolution of Multimonitor
int totalMonitor;
GLFWmonitor** monitors = glfwGetMonitors(&totalMonitor);
printf("\n\n---------------------------------------------------------");
printf("\n Total monitor [%d]",totalMonitor);
printf("\n primary monitor [%s]",glfwGetMonitorName(glfwGetPrimaryMonitor()));
printf("\n\n---------------------------------------------------------");
for(int currMonitor=0;currMonitor<totalMonitor;currMonitor++)
{
printf("\n monitor name: [%s]",glfwGetMonitorName(monitors[currMonitor]));
int count;
const GLFWvidmode* modes = glfwGetVideoModes(monitors[currMonitor], &count);
for (int i = 0; i < count; i++)
{
printf("\n %d : [%d X %d]~[%d]",i,modes[i].width,modes[i].height,modes[i].refreshRate);
}
printf("\n---------------------------------------------------------");
}
【讨论】: