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. Using `QOpenGLFramebufferObject` with `QGraphicsView`
Forum Updated to NodeBB v4.3 + New Features

Using `QOpenGLFramebufferObject` with `QGraphicsView`

Scheduled Pinned Locked Moved Unsolved General and Desktop
qopenglframebufqgraphicsview
2 Posts 2 Posters 1.3k Views 2 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.
  • T Offline
    T Offline
    tfm123
    wrote on last edited by tfm123
    #1

    The QOpenGLWidget has a GL framebuffer in which it expects everything to be rendered. This framebuffer is not the system's default framebuffer.

    QOpenGLContext::defaultFramebufferObject() returns the default framebuffer. This function is used in QOpenGLFramebufferObject::release() to rebind the default framebuffer after one is done with using one's own.

    Now, for this to work with QOpenGLWidget it is necessary for defaultFramebufferObject() to return not the system's default, but the framebuffer used by the widget.

    Otherwise calling QOpenGLFramebufferObject::bind() and subsequently release() will leave you rendering into the system's default framebuffer 0 while the widget expects you to render to, say, framebuffer 3.

    Looking at the sources shows that QOpenGLWidget, before calling a virtual paintGL() method, sets a flag on QOpenGLContext to make its defaultFramebufferObject() method return the correct framebuffer. QOpenGLFramebufferObject::bind() and release() inside the paintGL() method do therefore work as expected.

    So far so good. This is also all documented like this.

    We are, however, using QOpenGLWidget as viewport for QGraphicsView. When using QOpenGLFramebufferObject inside QGraphicsEffect::draw() the aformentioned intialization step that modifies QOpenGLContext::defaultFramebufferObject()'s behaviour seems to be missing. A call to QOpenGLFramebufferObject::release() leaves you with the wrong framebuffer bound. We have to manually save the framebuffer id before QOpenGLFramebufferObject::bind() and restore it later.

    Now my question is: Are we misusing QOpenGLFramebufferObject or is there an oversight in QGraphicsView, failing to set the correct default framebuffer before calling any user-overriden draw() methods?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      I wouldn't say an oversight but likely you have a use case that has not happened before. Also QOpenGLFramebufferObject is a pretty new class compared to QGraphicsView.

      I'd recommend brining this to the interest mailing list. You'll find there Qt's developers/maintainers.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      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