2015-01-05 36 views
0

我有Windows代碼,它爲多個顯示器創建可用分辨率的列表。如何使用FREEGLUT獲得所有支持的多顯示器分辨率?

現在我必須在Linux上移植它,所以我想使用「FREEGLUT」,這樣我就可以使用相同的代碼獲取Linux和Windows的顯示器相關信息。

我需要幫助來獲得一些指針,以獲得多個顯示器的所有支持的分辨率..?

我希望我們可以使用免費的過剩。

回答

0

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

Linux本身沒有圖形系統。你必須依靠X11或Wayland之類的東西。現在X11是通常找到的系統,用於枚舉和配置監視器的X11-API被稱爲XRandR。 FreeGLUT並沒有真正公開這個功能。所以要麼使用一個自己實現或實現的框架。

請注意,當涉及到多顯示器環境時,窗口管理器也有關於窗口放置的說法。

+0

GLFW庫幫我提取顯示器可用的分辨率,如你所說,我會使用特定於平臺的庫,用於進一步的操作。 – Mozfox

相關問題