SaschaWillems / glCapsViewer

C++ port of the OpenGL hardware capability viewer
GNU Lesser General Public License v3.0
103 stars 28 forks source link

Failure to create core context on Intel Sandybridge with Mesa #4

Closed horazont closed 1 week ago

horazont commented 9 years ago

On my Intel Sandybridge GPU, glCapsViewer fails to read the OpenGL Core Profile properties. GLFW reports that a Core Profile context is only available with OpenGL 3.2+. However, I am able to create a Core Profile context with version 3.3 from Qt using QSurfaceFormat and QOpenGLContext. Also, glxinfo also states that version 3.3 should be possible for Core:

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

Not so, however, for non-core:

OpenGL version string: 3.0 Mesa 10.4.3

I suspect that this might in fact be a GLFW bug.

fredericomba commented 9 years ago

Thanks for your bug report. I have successfully queried a OpenGL core context on Linux with Mesa: http://opengl.gpuinfo.org/gl_generatereport.php?reportID=1123

GLFW is working properly. I also had problems when it came to getting a core context. There was always a popup window warning about context creation failure (which gave a very useful error message: "Context profiles are only defined for OpenGL version 3.2 and above", See: http://imgur.com/xwswYKSl.png), but there's a workaround (which is not a fix, it's a workaround). The real reason for this bug resides on the following lines of the file "glCapsViewer.cpp"

401                         if (item == "OpenGL core context") {
 ...
405                                 GLint glVersionMajor, glVersionMinor;
406                                 glGetIntegerv(GL_MAJOR_VERSION, &glVersionMajor);
407                                 glGetIntegerv(GL_MINOR_VERSION, &glVersionMinor);
408                                 // Create core context
409                                 glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, glVersionMajor);
410                                 glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, glVersionMinor);
 ...

If you change lines 409 and 410 to:

409                                 glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
410                                 glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);

You'll get a core context under Linux. The command "glxinfo" outputs this on my computer:

(...) OpenGL vendor string: X.Org OpenGL renderer string: Gallium 0.4 on AMD CEDAR (DRM 2.43.0, LLVM 3.7.0) OpenGL core profile version string: 3.3 (Core Profile) Mesa 11.0.3 (git-b4bfea0) OpenGL core profile shading language version string: 3.30 OpenGL core profile context flags: (none) OpenGL core profile profile mask: core profile (...) OpenGL version string: 3.0 Mesa 11.0.3 (git-b4bfea0) OpenGL shading language version string: 1.30 OpenGL context flags: (none)

Pay attention that there is no core context that targets OpenGL 3.0 (although there is a compability one). I've also visited the OpenGL's wiki about that: https://www.opengl.org/wiki/Core_And_Compatibility_in_Contexts

But the code seems to be following the guidelines there, so there isn't a definitively fix yet (and maybe there will never be one. Maybe this is an issue with Mesa refusing to ship core contexts before the breakage point, which is OpenGL 3.2. The error message the popup window gave hinted that way).

jf99 commented 8 years ago

I have created a pull request that should fix the issue:

15