2

I need help doing some OpenGL 3.3 programming with core profile. I'm running on an Arch Linux OS with the packages xf86-video-intel and mesa-libgl installed. I have Intel HD 4400 built into my CPU

When I enter glxinfo | grep OpenGL into terminal, It shows I can support OpenGL 3.3

OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) Haswell Mobile 
OpenGL core profile version string: 3.3 (Core Profile) Mesa 12.0.3
OpenGL core profile shading language version string: 3.30
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 3.0 Mesa 12.0.3
OpenGL shading language version string: 1.30
OpenGL context flags: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.0 Mesa 12.0.3
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.00
OpenGL ES profile extensions:

I'm using GLFW3 and GLEW to setup OpenGL

if(!glfwInit()) {
    return -1;
}
GLFWwindow* window = glfwCreateWindow(800, 600, "Hello Guys", NULL, NULL);
if(!window) {
    glfwTerminate();
    return -1;
}

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);

glfwMakeContextCurrent(window);

if(glewInit() != GLEW_OK) {
    printf("GLEW did not initialize\n");
    glfwTerminate();
    return -1;
}

However, when I try to compile shaders, I get the error GLSL 3.30 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, and 3.00 ES

It seems Mesa or GLFW3 is making my PC use the forward compatible profile instead of the core profile. How can I fix this?

Streak324
  • 153
  • 1
  • 3
  • 12

1 Answers1

3

From the docs (emphasis mine):

void glfwWindowHint( int hint, int value )        

This function sets hints for the next call to glfwCreateWindow. ...

So: unless you want the defaults make sure to set hints before you create the window:

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);

GLFWwindow* window = glfwCreateWindow(800, 600, "Hello Guys", NULL, NULL);
if(!window) {
    glfwTerminate();
    return -1;
}
genpfault
  • 51,148
  • 11
  • 85
  • 139
  • Thank you. Didn't realize the hints had to be called before window creation. – Streak324 Oct 17 '16 at 15:15
  • @Streak324: Window creation implies GL context creation. Since Intel explicitly only supports GL 3.1+ when explicitly requesting a core context (they don't implement ´GL_ARB_compatibility` or the compatibility profile), you have to tell GLFW that *before* creating the window. The behavior you saw is the Intel implementation reverting to its compatibility path, which then only goes as high as GL 3.0 (and GLSL 1.30). – thokra Oct 18 '16 at 11:07