QOpenGLPaintDevice¶
The
QOpenGLPaintDevice
class enables painting to an OpenGL context usingQPainter
. More…
New in version 5.0.
Synopsis¶
Functions¶
def
context
()def
dotsPerMeterX
()def
dotsPerMeterY
()def
paintFlipped
()def
setDevicePixelRatio
(devicePixelRatio)def
setDotsPerMeterX
(arg__1)def
setDotsPerMeterY
(arg__1)def
setPaintFlipped
(flipped)def
setSize
(size)def
size
()
Virtual functions¶
def
ensureActiveTarget
()
Detailed Description¶
The
QOpenGLPaintDevice
uses the current QOpenGL context to renderQPainter
draw commands. The context is captured upon construction. It requires support for OpenGL (ES) 2.0 or higher.
Performance¶
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 and Quality¶
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.
State Changes¶
When painting to a
QOpenGLPaintDevice
usingQPainter
, 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.
Mixing QPainter and OpenGL¶
When intermixing
QPainter
and OpenGL, it is important to notifyQPainter
that the OpenGL state may have been cluttered so it can restore its internal state. This is achieved by callingbeginNativePainting()
before starting the OpenGL rendering and callingendNativePainting()
after finishing.See also
- class PySide2.QtGui.QOpenGLPaintDevice¶
PySide2.QtGui.QOpenGLPaintDevice(size)
PySide2.QtGui.QOpenGLPaintDevice(width, height)
- param size:
- param width:
int
- param height:
int
Constructs a
QOpenGLPaintDevice
.The
QOpenGLPaintDevice
is only valid for the current context.See also
Constructs a
QOpenGLPaintDevice
with the givenwidth
andheight
.The
QOpenGLPaintDevice
is only valid for the current context.See also
- PySide2.QtGui.QOpenGLPaintDevice.context()¶
- Return type:
Returns the OpenGL context associated with the paint device.
- PySide2.QtGui.QOpenGLPaintDevice.dotsPerMeterX()¶
- Return type:
float
Returns the number of pixels per meter horizontally.
See also
- PySide2.QtGui.QOpenGLPaintDevice.dotsPerMeterY()¶
- Return type:
float
Returns the number of pixels per meter vertically.
See also
- PySide2.QtGui.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.
- PySide2.QtGui.QOpenGLPaintDevice.paintFlipped()¶
- Return type:
bool
Returns
true
if painting is flipped around the Y-axis.See also
- PySide2.QtGui.QOpenGLPaintDevice.setDevicePixelRatio(devicePixelRatio)¶
- Parameters:
devicePixelRatio – float
Sets the device pixel ratio for the paint device to
devicePixelRatio
.
- PySide2.QtGui.QOpenGLPaintDevice.setDotsPerMeterX(arg__1)¶
- Parameters:
arg__1 – float
Sets the number of pixels per meter horizontally to
dpmx
.See also
- PySide2.QtGui.QOpenGLPaintDevice.setDotsPerMeterY(arg__1)¶
- Parameters:
arg__1 – float
Sets the number of pixels per meter vertically to
dpmy
.See also
- PySide2.QtGui.QOpenGLPaintDevice.setPaintFlipped(flipped)¶
- Parameters:
flipped – bool
Sets whether painting should be flipped around the Y-axis or not to
flipped
.See also
- PySide2.QtGui.QOpenGLPaintDevice.setSize(size)¶
- Parameters:
size –
PySide2.QtCore.QSize
Sets the pixel size of the paint device to
size
.See also
- PySide2.QtGui.QOpenGLPaintDevice.size()¶
- Return type:
Returns the pixel size of the paint device.
See also
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.