Sharing between QOpenGLContext and QGLWidget



  • I have a "compositor" class which uses a QOffscreenSurface, with a QOpenGLContext, and a QOpenGLFramebufferObject. It renders some things to the FBO. If the app is running in a render only mode, the result will get written to a file. Run interactively, it gets shown on my subclass of QGLWidget the "viewer."

    If I make a QImage from the FBO and draw that to the viewer, it works. However, this requires round-tripping from GPU-> QImage-> Back to the GPU as a texture. In theory, I should be able to use the FBO as a texture directly, which is what I want.

    I am trying to share between my QOpenGLContext and the QGLWidget's QGLContext like so:

    viewport = new tl::ui::glViewPort(this);
    compositor = new tl::playback::glCompositor(1280, 720, this);
    viewer->context()->contextHandle()->setShareContext(compositor->context);

    Is it possible to share between the two types of contexts? Is this the way to do it? Do I need to do something else to draw in the viewer using the FBO in the compositor? I'm just getting solid white when I draw the FBO directly instead of the QImage, so I'm clearly doing something wrong.



  • (And just realized that I double posted this question. For some reason, the original wasn't showing up in my 'latest posts' so I though it had never gotten posted. Sorry for the extra noise.)



  • I finally figured out what I was doing wrong with sharing between the contexts. I also asked about this on stackoverflow, and posted the solution there.

    Basically, the docs on QOpenGLContext's setShareContext could be clearer about how you actually have to use it. I was misunderstanding and doing things out of order.




Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.