如何使用FREEGLUT获得多显示器的所有支持分辨率

how to get all supported resolution for multi monitor using FREEGLUT?

本文关键字:支持 分辨率 显示器 何使用 FREEGLUT      更新时间:2023-10-16

我有Windows代码,可以为多个显示器创建可用分辨率列表。

现在我必须将其移植到 Linux 上,所以我正在考虑使用"FREEGLUT",以便我可以使用相同的代码获取 Linux 和 Windows 的监视器相关信息。

我需要帮助来获取一些指针来获取多个显示器的所有支持分辨率..?

我希望我们能用免费的过剩来做到这一点。

Linux 本身没有图形系统。你必须依靠像X11或Wayland这样的东西。现在X11是通常发现的系统,用于枚举和配置监视器的X11-API称为XRandR。FreeGLUT并没有真正公开这个功能。因此,要么使用可以执行的框架,要么自己实现它。

请注意,当涉及到多显示器环境时,窗口管理器对窗口放置也有发言权。

我正在使用GLFW 3.0.4来获得多显示器支持的分辨率。我更喜欢使用特定于平台的功能来应用显示器分辨率。

// Get Resolution of Multimonitor
int totalMonitor;
GLFWmonitor** monitors = glfwGetMonitors(&totalMonitor);

printf("nn---------------------------------------------------------");
printf("n Total monitor [%d]",totalMonitor);
printf("n primary monitor [%s]",glfwGetMonitorName(glfwGetPrimaryMonitor()));
printf("nn---------------------------------------------------------");
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---------------------------------------------------------");
}