Finding and setting supported opengl version for QOpenGLWidget
-
Hello,
i have a ui with a QOpenGLWidget.
On my default machine it runs as it should. However on another machine (with odler graphics card) it just shows a black screen.
I guess because there the maximum opengl version that is supported is 3.1
How can i determine inside Qt which version is supported on a machine and then set the QOpenGLWidget to work with that one? -
I have the same question. Surprisingly difficult to find the answer.
-
I have the same question. Surprisingly difficult to find the answer.
@Jeremy-Walker Try it out to find the version of OpenGL.
#include <QGuiApplication> #include <QDebug> #include <QOpenGLContext> #include <QSurfaceFormat> int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QOpenGLContext context; if ( context.create() ) { QSurfaceFormat format = context.format(); int majorVersion = format.majorVersion(); int minorVersion = format.minorVersion(); qDebug() << "Supported OpenGL version: " << majorVersion << "." << minorVersion; } else { qDebug() << "OpenGL creation failed: "; } return app.exec(); }
-
Try to set openGL version:
// Set OpenGL version and profile
QSurfaceFormat format;
format.setVersion(3, 3); // Set OpenGL version (e.g., 3.3)
format.setProfile(QSurfaceFormat::CoreProfile); // Set OpenGL core profile