2016-08-29 163 views
2

我試圖在我的Debian Stretch系統中創建一個glfw窗口。GLFW無法創建窗口:「GLX:無法創建上下文:GLXBadFBConfig」

的代碼初始化GLFW:

// Initialize GLFW 
void initGLFW() 
{ 
    if (!glfwInit()) 
    { 
     exit(EXIT_FAILURE); 
    } 

    glfwSetErrorCallback(errorCallback); 
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); 
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); 
    glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_FALSE); 
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); 
    glfwWindowHint(GLFW_RESIZABLE, GL_FALSE); 
    glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE); 

    window = glfwCreateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, "GLSL4.3 + GLM + VBO + VAO", NULL, NULL); 
    if (!window) 
    { 
     fprintf(stderr, "Failed to open GLFW window.\n"); 
     glfwTerminate(); 
     //system("pause"); 
     exit(EXIT_FAILURE); 
    } 
} 

當我運行的可執行文件,我得到上面的消息。爲什麼?

GLX: Failed to create context: GLXBadFBConfig 
Failed to open GLFW window. 

LIBGL_DEBUG=verbose運行我得到這個

libGL: Can't open configuration file /home/rafael/.drirc: No such file or directory. 
libGL: pci id for fd 5: 8086:0a16, driver i965 
libGL: OpenDriver: trying /usr/lib/x86_64-linux-gnu/dri/tls/i965_dri.so 
libGL: OpenDriver: trying /usr/lib/x86_64-linux-gnu/dri/i965_dri.so 
libGL: Can't open configuration file /home/rafael/.drirc: No such file or directory. 
libGL: Using DRI3 for screen 0 

一些有用的相關信息:

$ lspci | grep VGA 
00:02.0 VGA compatible controller: Intel Corporation Haswell-ULT Integrated Graphics Controller (rev 0b) 

$ glxinfo | grep version 
server glx version string: 1.4 
client glx version string: 1.4 
GLX version: 1.4 
    Max core profile version: 3.3 
    Max compat profile version: 3.0 
    Max GLES1 profile version: 1.1 
    Max GLES[23] profile version: 3.0 
OpenGL core profile version string: 3.3 (Core Profile) Mesa 11.2.2 
OpenGL core profile shading language version string: 3.30 
OpenGL version string: 3.0 Mesa 11.2.2 
OpenGL shading language version string: 1.30 
OpenGL ES profile version string: OpenGL ES 3.0 Mesa 11.2.2 
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.00 

initGLFW功能從主調用的第一個函數。

+1

也許驅動程序無法處理opengl> = 4。lspci說:「最大核心輪廓e版本:3.3「也是」OpenGL版本字符串:3.0 Mesa 11.2.2「,但在代碼中顯示」OpenGL version string:3.0 Mesa 11.2.2「 – robor78

回答

5

您要創建一個OpenGL 4.0核心配置方面:

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); 
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); 
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); 

你的驅動器/ OpenGL實現最多隻支持3.3:

OpenGL core profile version string: 3.3 (Core Profile) Mesa 11.2.2 
Max core profile version: 3.3 

梅薩11.2.2 could support的OpenGL 4.1,但只有在某些驅動程序上(來自發行說明11.0.0):

radeonsi,nvc0上的OpenGL 4.1

梅薩12.0.0 seems to support的OpenGL 4.3 i965的:

的OpenGL 4.3 nvc0,radeonsi,i965的(Gen8 +)

的解決將是更新您的顯卡,Mesa3D或者創建一個3.3上下文來代替:

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); 
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); 
+0

謝謝。顯然,mesa的版本庫不支持4.0版本。我會嘗試手動安裝mesa。 該應用程序不會與3.3工作,因爲它的目標是版本4.0 – 648trindade

+2

嗯,Haswell是gen7,甚至最近的mesa代碼庫還不支持gen4.GL4.x上的64位浮點支持仍然缺乏。但另一方面,許多應用程序並沒有使用這個方法,而且mesa通過擴展提供了很多haswell的4.x功能,這可能會或可能不足以滿足您的需求。 – derhass