GLFW cannot create a window: "GLX: Failed to create context: GLXBadFBConfig"
Asked Answered
G

1

10

I'm trying to create a glfw window in my Debian Stretch system.

The code for initialize 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);
    }
}

When I run the executable I get the messages above. Why?

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

Running with LIBGL_DEBUG=verbose I get this

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

Some useful infos:

$ 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

The initGLFW function is the first function called from main.

Grogram answered 29/8, 2016 at 19:29 Comment(1)
Perhaps the driver cannot handle opengl >= 4. lspci says "Max core profile version: 3.3" also "OpenGL version string: 3.0 Mesa 11.2.2" but in the code it says "OpenGL version string: 3.0 Mesa 11.2.2"Cuzco
C
12

You are trying to create an OpenGL 4.0 Core profile context:

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

Your driver/OpenGL implementation only supports up to 3.3:

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

Mesa 11.2.2 could support OpenGL 4.1 but only on certain drivers (from the release notes of 11.0.0):

OpenGL 4.1 on radeonsi, nvc0

Mesa 12.0.0 seems to support OpenGL 4.3 on i965:

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

The fix would be to update your graphics card, Mesa3D or to create a 3.3 context instead:

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
Carmine answered 29/8, 2016 at 19:57 Comment(2)
Thanks. Apparently the repository version of the mesa does not support 4.0 for my haswell. I will try to install mesa manually. The application will not work with the 3.3 because it is aimed to version 4.0Grogram
Well, Haswell is gen7, and even the most recent mesa code base does not yet support GL4.x on gen7, the 64bit floating point support is still lacking. But on the other hand, that faeture isn't used by many apps, and mesa does provide a great deal of 4.x functionality on haswell via the extenstions, which might or might not be enough for your needs.Zonate

© 2022 - 2024 — McMap. All rights reserved.