0
votes

I am trying to compile my application with OpenGL 3.3. I've searched my graphics card online and it supports up to 4.4.

Here is the return of glxinfo | grep OpenGL

OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) HD Graphics 520 (Skylake GT2) 
OpenGL core profile version string: 4.5 (Core Profile) Mesa 17.2.3
OpenGL core profile shading language version string: 4.50
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 3.0 Mesa 17.2.3
OpenGL shading language version string: 1.30
OpenGL context flags: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.2 Mesa 17.2.3
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
OpenGL ES profile extensions:

I am telling GLFW to use major version 3 minor version 3

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

and do use core profile:

glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

I built glad pointing to version 3.3 and core profile:

python -m glad --api "gl=3.3" --generator c --out-path ./output --profile core --spec gl

But when I call

glGetString(GL_VERSION)

I get back

3.0 Mesa 17.2.3

I cannot for the life of me figure out what i'm missing.

Section running this code

{
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
    glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
    glfwWindowHint(GLFW_FLOATING, GL_TRUE);
    glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);

    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

    if (!glfwInit()) {
        std::cout << "glfw not inited" << std::endl;
    }

    glfwSetErrorCallback(error_callback);
    m_game_window = glfwCreateWindow(800, 600, "window", NULL, NULL);

    if (!m_game_window) {
        std::cout << "window creation failed" << std::endl;
        glfwTerminate();
        //crash
    }

    glfwMakeContextCurrent(m_game_window);
    gladLoadGLLoader((GLADloadproc) glfwGetProcAddress);

    glViewport(0, 0, 800, 600);

    char *version = (char*)glGetString(GL_VERSION);
    std::cout << version;
}
1
Please show the full source code that produces this output. - BDL
What i gave was really all the code related. But i edited my post to include the block of code running this section during application startup. - Dylan Dodds
If you look at derhass answer, then you know why it is so important to provide a complete example. - BDL

1 Answers

2
votes

You must not call any GLFW functions before glfwInit(). In your case, the window hints will be completely reset by the glfwInit().