Search code examples
javalwjgl

Wrong OpenGL Version Is Being Reported


I am posting here because I am very new to LWJGL and I am experiencing some issues with it. According to Apple, the computer I am using should work with OpenGL 4.1, however when I ask for the version, it says OpenGL: 2.1 INTEL-10.6.31, and then I get an error for trying to use functions that are only available with OpenGL 3.0.

Here is the link to Apple's page, stating that the computer I am using, a 2014 MacBook Air, should have OpenGL 4.1

The code I am using to find the version is:

GL.createCapabilities();
System.out.println("OpenGL: " + glGetString(GL_VERSION));

Hopefully someone knows what is happening here.


Solution

  • Ok, so I did a bunch more digging and found that OSx defaults to using GL 2.1, even if it has newer software installed. Seems kinda silly, however it is how it works.

    If any of you guys ran into this problem as well, the solution I found was to put these lines of code in before you create the window. I am not certain that you have to do it then, however that is what works for me:

    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
    glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
    

    Hope this helped anyone else out there dealing with this.

    Link to where I found this solution.

    If anyone has a better solution, or a clarification on how it works, I would be interested in hearing from you.

    Cheers!