Skip to content

OpenGL context 3.3+ not found unless requesting 3.3 version #659

@tho-

Description

@tho-

Hi,

Using gz-gui 9.0.0 / gz-rendering 9.0.0 / ogre2.3.3 all built from source on NetBSD 10.1, amd64/intel with graphics hardware as reported by this glxinfo excerpt:

OpenGL renderer string: Mesa DRI Intel(R) HD Graphics 4600 (HSW GT2)
OpenGL core profile version string: 4.5 (Core Profile) Mesa 21.3.7
   Max core profile version: 4.5
   Max compat profile version: 3.0

ogre2 fails to initialize its context with the message:
OGRE EXCEPTION(3:RenderingAPIException): OpenGL 3.3 is not supported. Please update your graphics card drivers.
and ogre2.log shows

GL_VERSION = 3.0 Mesa 21.3.7

(it then segfaults later, by the way, but that's a different issue)

If I apply this small patch right after the QApplication constructor then it works perfectly fine:

--- src/Application.cc~	2024-09-27 01:38:17.000000000 +0200
+++ src/Application.cc	2025-03-10 01:16:16.297511872 +0100
@@ -96,6 +96,9 @@
 {
   gzdbg << "Initializing application." << std::endl;
 
+  QSurfaceFormat format;
+  format.setVersion(3, 3);
+  QSurfaceFormat::setDefaultFormat(format);
   this->setOrganizationName("Gazebo");
   this->setOrganizationDomain("gazebosim.org");
   this->setApplicationName("Gazebo GUI");

And in .gz/rendering/ogre2.log there is the expected message

Driver Version: 4.5.0.0

I'm not sure wether this fix is correct in terms of genericity, e.g. if it should rather belong to gz-rendering/ogre2, or at least be protected by an 'OGRE2' ifdef or something. I tried various different tricks, patching in different places near or around ogre2 initialization but the above solution was the only one that actually worked.

Let me know if that makes sense to you,
Cheers
Anthony

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Inbox

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions