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

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

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

现在我必须将它移植到 Linux 所以我想使用 "FREEGLUT" 这样我就可以使用相同的方法获取 Linux 和 windows 的监视器相关信息代码。

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

我希望我们可以利用免费的过剩来做到这一点..

Linux 本身没有图形系统。您必须依赖 X11 或 Wayland 之类的东西。目前,X11 是最常见的系统,用于枚举和配置监视器的 X11-API 称为 XRandR。 FreeGLUT 并没有真正公开这个功能。所以要么使用一个框架,要么自己实现它。

请注意,在涉及多显示器环境时,Window 经理也对 window 放置有发言权。

我正在使用 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---------------------------------------------------------");
}