Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Sharing between QOpenGLContext and QGLWidget
Forum Updated to NodeBB v4.3 + New Features

Sharing between QOpenGLContext and QGLWidget

Scheduled Pinned Locked Moved General and Desktop
4 Posts 1 Posters 2.7k Views 1 Watching
  • 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 Offline
    W Offline
    wrosecrans
    wrote on last edited by
    #1

    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
    0
    • W Offline
      W Offline
      wrosecrans
      wrote on last edited by
      #2

      (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
      0
      • W Offline
        W Offline
        wrosecrans
        wrote on last edited by
        #3

        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
        0
        • W Offline
          W Offline
          wrosecrans
          wrote on last edited by
          #4

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

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved