Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Sharing between QOpenGLContext and QGLWidget

    General and Desktop
    1
    4
    2238
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • W
      wrosecrans last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • W
        wrosecrans last edited by

        (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.)

        1 Reply Last reply Reply Quote 0
        • W
          wrosecrans last edited by

          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.

          1 Reply Last reply Reply Quote 0
          • W
            wrosecrans last edited by

            http://stackoverflow.com/questions/19329888/sharing-between-qopenglcontext-and-qglwidget/19330014?noredirect=1

            1 Reply Last reply Reply Quote 0
            • First post
              Last post