Details
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]