Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-20080 Qt 5 refactor
  3. QTBUG-21263

Make a proper interface for using QPainter to render into a GL context

    XMLWordPrintable

Details

    • Sub-task
    • Resolution: Done
    • P3: Somewhat important
    • 5.0.0
    • Other
    • None
    • 1b1831500142c995137f5e4b1bc03d21aa08e1e1

    Description

      The OpenGL 2 paint engine can now only be used to render into a QOpenGLFramebufferObject, which is a QPaintDevice. We should instead introduce a public QOpenGLPaintDevice class, which can wrap any context, and let the user be responsible for whether to bind an FBO or render directly to a QWindow. The QOpenGLPaintDevice class needs some way to set a viewport and the other QPaintDevice metric options (at least the DPI might be necessary to have). This should simplify the paint engine as it no longer needs to know about current FBOs etc. QOpenGLFramebufferObject will no longer be a QPaintDevice sub-class.

      Example code:

      [code]
      context->makeCurrent();

      // drawing into a window
      QOpenGLPaintDevice device(QRect(0, 0, width(), height())); // creates a paint device valid for the current context
      QPainter painter(&device);
      ...
      painter.end();

      // drawing into an FBO
      device.setViewport(QRect(0, 0, fbo->width(), fbo->height()));
      fbo->bind();
      painter.begin(&device);
      ...
      painter.end();
      fbo->release();

      context->swapBuffers(this);
      [/code]

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            rodal Samuel Rødal
            rodal Samuel Rødal
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes