[solved] black screen with drape mode in a QOpenGLWidget

classic Classic list List threaded Threaded
4 messages Options
boy2melo boy2melo
Reply | Threaded
Open this post in threaded view
|

[solved] black screen with drape mode in a QOpenGLWidget

This post was updated on .
Hi all,

I am reopening the thread black screen with drape mode in a QOpenGLWidget.

Has anybody found a solution yet without using QtQuick?

The way I understand it is that QOpenGLWidget renders its scene into a FramebufferObject:

"All rendering happens into an OpenGL framebuffer object. [...] Keep this in mind when creating and binding additional framebuffer objects in the rendering code in paintGL(). Never re-bind the framebuffer with ID 0. Instead, call defaultFramebufferObject() to get the ID that should be bound." - https://doc.qt.io/qt-5/qopenglwidget.html

The Drape-Mode of osgEarth also uses one or more FramebufferObjects. This clashes with the way QOpenGLWidget uses the FramebufferObjects. Either they both use the same objects or, osgEarth accidentally releases the ones from QOpenGLWidgets.

Is there any possibility to inject the default FramebufferObject ID for the osgEarth rendering?

Thanks in advance...
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: [reopen] black screen with drape mode in a QOpenGLWidget

I (vaguely) recall that the issue here was OSG binding the FBO to zero after completing the render stage, instead of reinstating Qt's FBO that it uses for it's surface rendering. Right?

IIRC the method osg::GraphicsContext::setDefaultFboId was added for this type of scenario, where the external renderer uses RTT. Maybe that would work with QtOpenGLWidget.

Just guessing, but worth a try? :)
Glenn Waldron / Pelican Mapping
boy2melo boy2melo
Reply | Threaded
Open this post in threaded view
|

Re: [solved] black screen with drape mode in a QOpenGLWidget

Thanks gwaldron. That did the trick.

Here is what I did: In the first run of QOpenGLWidget::paintGL() I captured the default FBO ID from the QOpenGLWidget with defaultFramebufferObject(). I then used this ID and passed it on to the osg::GraphicsContext.

class WidgetRenderer : public QOpenGLWidget, public osgViewer::Viewer
{
  ...

  void paintGL() override
  {
    if(mIsFirstRenderRun)
    {
      // set set the default FBO-id.
      // this id will be used when the rendering-backend is finished with RTT FBOs
      GLuint defaultFboId = this->defaultFramebufferObject();
      mpGraphicsContext->setDefaultFboId(defaultFboId);

      mIsFirstRenderRun = false;
    }

    this->frame();
  }

  ...
}
Blanky Blanky
Reply | Threaded
Open this post in threaded view
|

Re: [solved] black screen with drape mode in a QOpenGLWidget

Hey,

Great job! I was trying to figure that out for the longest time. In my paintGL call I did something very similar on my graphics context, but didn't only do it for the first render call, but for every frame call. This fixed it!

- Blanky