The QOpenGLPaintDevice class enables painting to an OpenGL context using QPainter. More...
Header: | #include <QOpenGLPaintDevice> |
qmake: | QT += gui |
Since: | Qt 5.0 |
Inherits: | QPaintDevice |
QOpenGLPaintDevice() | |
QOpenGLPaintDevice(const QSize &size) | |
QOpenGLPaintDevice(int width, int height) | |
virtual | ~QOpenGLPaintDevice() |
QOpenGLContext * | context() const |
qreal | dotsPerMeterX() const |
qreal | dotsPerMeterY() const |
virtual void | ensureActiveTarget() |
bool | paintFlipped() const |
void | setDevicePixelRatio(qreal devicePixelRatio) |
void | setDotsPerMeterX(qreal dpmx) |
void | setDotsPerMeterY(qreal dpmy) |
void | setPaintFlipped(bool flipped) |
void | setSize(const QSize &size) |
QSize | size() const |
virtual QPaintEngine * | paintEngine() const override |
QOpenGLPaintDevice(const QOpenGLPaintDevice &) | |
QOpenGLPaintDevice & | operator=(const QOpenGLPaintDevice &) |
virtual int | metric(QPaintDevice::PaintDeviceMetric metric) const override |
The QOpenGLPaintDevice class enables painting to an OpenGL context using QPainter.
The QOpenGLPaintDevice uses the current QOpenGL context to render QPainter draw commands. The context is captured upon construction. It requires support for OpenGL (ES) 2.0 or higher.
The QOpenGLPaintDevice is almost always hardware accelerated and has the potential of being much faster than software rasterization. However, it is more sensitive to state changes, and therefore requires the drawing commands to be carefully ordered to achieve optimal performance.
Antialiasing in the OpenGL paint engine is done using multisampling. Most hardware require significantly more memory to do multisampling and the resulting quality is not on par with the quality of the software paint engine. The OpenGL paint engine's strength lies in its performance, not its visual rendering quality.
When painting to a QOpenGLPaintDevice using QPainter, the state of the current OpenGL context will be altered by the paint engine to reflect its needs. Applications should not rely upon the OpenGL state being reset to its original conditions, particularly the current shader program, OpenGL viewport, texture units, and drawing modes.
When intermixing QPainter and OpenGL, it is important to notify QPainter that the OpenGL state may have been cluttered so it can restore its internal state. This is achieved by calling QPainter::beginNativePainting() before starting the OpenGL rendering and calling QPainter::endNativePainting() after finishing.
See also OpenGL Window Example.
Constructs a QOpenGLPaintDevice.
The QOpenGLPaintDevice is only valid for the current context.
See also QOpenGLContext::currentContext().
Constructs a QOpenGLPaintDevice with the given size.
The QOpenGLPaintDevice is only valid for the current context.
See also QOpenGLContext::currentContext().
Constructs a QOpenGLPaintDevice with the given width and height.
The QOpenGLPaintDevice is only valid for the current context.
See also QOpenGLContext::currentContext().
[protected]
QOpenGLPaintDevice::QOpenGLPaintDevice(const QOpenGLPaintDevice
&)Default constructs an instance of QOpenGLPaintDevice.
[virtual]
QOpenGLPaintDevice::~QOpenGLPaintDevice()Destroys the QOpenGLPaintDevice.
Returns the OpenGL context associated with the paint device.
Returns the number of pixels per meter horizontally.
See also setDotsPerMeterX().
Returns the number of pixels per meter vertically.
See also setDotsPerMeterY().
[virtual]
void QOpenGLPaintDevice::ensureActiveTarget()This virtual method is provided as a callback to allow re-binding a target frame buffer object or context when different QOpenGLPaintDevice instances are issuing draw calls alternately.
beginNativePainting() will also trigger this method.
The default implementation does nothing.
[override virtual protected]
int QOpenGLPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) constReimplemented from QPaintDevice::metric().
[override virtual]
QPaintEngine *QOpenGLPaintDevice::paintEngine() constReimplemented from QPaintDevice::paintEngine().
Returns true
if painting is flipped around the Y-axis.
See also setPaintFlipped().
Sets the device pixel ratio for the paint device to devicePixelRatio.
Sets the number of pixels per meter horizontally to dpmx.
See also dotsPerMeterX().
Sets the number of pixels per meter vertically to dpmy.
See also dotsPerMeterY().
Sets whether painting should be flipped around the Y-axis or not to flipped.
See also paintFlipped().
Sets the pixel size of the paint device to size.
See also size().
Returns the pixel size of the paint device.
See also setSize().
[protected]
QOpenGLPaintDevice
&QOpenGLPaintDevice::operator=(const QOpenGLPaintDevice &)Copy-assignment operator.