[Interest] QOpenGLContext::currentContext() returning nullptr (in some cases)
Andy
asmaloney at gmail.com
Wed Dec 21 16:00:34 CET 2016
I have some code in my application to get information about the machine's
OpenGL. For most of my customers I'm getting useful, reasonable info from
it.
For example:
"opengl": {
"format": {
"received": {
"profile": "1 [core]",
"version": "3.3"
},
"requested": {
"profile": "1 [core]",
"version": "3.3"
}
},
"vendor": "Intel",
"version": "3.3.0 - Build 20.19.15.4531",
"renderer": "Intel(R) Iris(TM) Pro Graphics 5200",
"shadingLanguage": "3.30 - Build 20.19.15.4531"
And:
"opengl": {
"format": {
"received": {
"profile": "0 [none]",
"version": "3.0"
},
"requested": {
"profile": "1 [core]",
"version": "3.3"
}
},
"vendor": "Google Inc.",
"version": "OpenGL ES 3.0 (ANGLE 2.1.99f075dade7c)",
"renderer": "ANGLE ( Direct3D11 vs_5_0 ps_5_0)",
"shadingLanguage": "OpenGL ES GLSL ES 3.00 (ANGLE
2.1.99f075dade7c)"
For some though, it's failing to get a context at all. Here's roughly what
I'm doing:
QString openGLInfoString()
{
QGLFormat requestedFormat;
requestedFormat.setVersion( 3, 3 );
requestedFormat.setProfile( QGLFormat::CoreProfile );
QGLWidget widget( requestedFormat );
widget.makeCurrent();
QOpenGLFunctions *glFuncs = nullptr;
if ( QOpenGLContext::currentContext() == nullptr )
{
return "OpenGL Info Error: Could not get current context";
}
glFuncs = QOpenGLContext::currentContext()->functions();
// ... do some stuff to get some nice OpenGL info about what is
actually available
return infoString;
}
I'm using a downloaded Qt 5.6.2 (MinGW) installer.
In what situations should I expect QOpenGLContext::currentContext() to
return a nullptr? I thought with the fallback/ANGLE stuff I could always
expect at least the ANGLE stuff to kick in - as in the second example.
Thanks for any insight!
---
Andy Maloney // https://asmaloney.com
twitter ~ @asmaloney <https://twitter.com/asmaloney>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20161221/ad6e64f4/attachment.html>
More information about the Interest
mailing list