Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Getting OpenGL information before initializing OpenGL ...
tmason101 last edited by
I am looking for a way to get the "state" of OpenGL on the system that is running my application to better optimize the OpenGL experience that my application creates.
So, take a look at the code below. With using GLFW, I can get the Major/Minor versions of OpenGL on the client system as well as the maximum number of samples that I can perform anti-aliasing on.
I do this so that I can dynamically choose, at runtime, which shaders I need to load as I have different shaders based on the OpenGL version that is on the client system.
What I am looking for is a pure Qt way of doing this; as it stands I have multiple unnecessary dependencies on GLFW and other libraries which creates bloat on my application.
Any help appreciated!
Thank you for your time.
fprintf(stderr, "GLFW failed to initialize.");
TempWindow = glfwCreateWindow(10, 10, "Checking OpenGL Version ...", NULL, NULL);
fprintf(stderr, "Could not determine OpenGL version; exiting.");
glewExperimental = GL_TRUE;
GLenum err = glewInit();
if (err != GLEW_OK)
fprintf(stderr, "Error: %s\n", glewGetErrorString(err));
fprintf(stderr, "Failed to initialize GLEW; exiting...");
You don't need a window for that. All you need is a valid OpenGL context. You can create a default one with "QOpenGLContext::create":http://doc.qt.io/qt-5/qopenglcontext.html#create, get a "format":http://doc.qt.io/qt-5/qopenglcontext.html#format of it and check "majorVersion":http://doc.qt.io/qt-5/qsurfaceformat.html#majorVersion and "minorVersion":http://doc.qt.io/qt-5/qsurfaceformat.html#minorVersion