[Interest] QOpenGLContext::currentContext() returning nullptr (in some cases)

Andy asmaloney at gmail.com
Wed Dec 28 14:45:33 CET 2016


(Ping) Does anybody have any insight into QOpenGLContext::currentContext()
and why it might return nullptr on some machines?

(Aside: Is there something about the way I ask questions that make them
confusing and/or difficult to answer? Too long? Not enough info? I find my
"response received" rate is low and would like to improve it :-)  Any
suggestions welcome!)

Thank you for your time.

---
Andy Maloney  //  https://asmaloney.com
twitter ~ @asmaloney <https://twitter.com/asmaloney>


On Wed, Dec 21, 2016 at 10:00 AM, Andy <asmaloney at gmail.com> wrote:

> 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/20161228/3a1e55da/attachment.html>


More information about the Interest mailing list