Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-53880

qt3d QOpenGLContext should get format from Qt3DWindow

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.7.1
    • 5.7.0 RC, 5.7.0
    • Qt3D
    • None
    • OSX 10.11.5 latest xcode, qt 5.7.0rc git
    • b656d9c426fb36220538d656b99d01f1ea161824, dc51c6e005d285c71923f0a346ac8d0fa9837184

    Description

      As noted in a comment in renderer.cpp, the QOpenGLContext in the initialize() method does not have any kind of format specification – it is left entirely to the default format. Ideally, it should get the format information from the Qt3DWindow (or actual rendering surface) but it doesn't look like this info is available in this context? Not on the renderer object itself directly at least.

      In any case, in the meantime it would be highly preferable to use the format logic from Qt3DWindow to ensure that the best GL version is used. As it is now, it falls back on 2.1 at least on OSX, instead of using gl3. Here is a patch that does this:

      diff --git a/src/render/backend/renderer.cpp b/src/render/backend/renderer.cpp
      index 825dfe9..d1ecdf2 100644
      --- a/src/render/backend/renderer.cpp
      +++ b/src/render/backend/renderer.cpp
      @@ -350,6 +350,20 @@ void Renderer::initialize()
               ctx = new QOpenGLContext;
               ctx->setShareContext(qt_gl_global_share_context());
       
      +        QSurfaceFormat format;
      +#ifdef QT_OPENGL_ES_2
      +        format.setRenderableType(QSurfaceFormat::OpenGLES);
      +#else
      +        if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL) {
      +            format.setVersion(4, 3);
      +            format.setProfile(QSurfaceFormat::CoreProfile);
      +        }
      +#endif
      +        format.setDepthBufferSize(24);
      +        format.setSamples(4);
      +        format.setStencilBufferSize(8);
      +        ctx->setFormat(format);
      +        
               // TO DO: Shouldn't we use the highest context available and trust
               // QOpenGLContext to fall back on the best lowest supported ?
               const QByteArray debugLoggingMode = qgetenv("QT3DRENDER_DEBUG_LOGGING");
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            seanharmer Sean Harmer
            rcoreilly Randall O'Reilly
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes