QOpenGLPaintDevice 类启用描绘到 OpenGL 上下文使用 QPainter . 更多...
头: | #include <QOpenGLPaintDevice> |
CMake: |
find_package(Qt6 COMPONENTS OpenGL REQUIRED)
target_link_libraries(mytarget PRIVATE Qt6::OpenGL) |
qmake: | QT += opengl |
Since: | Qt 5.0 |
继承: | QPaintDevice |
QOpenGLPaintDevice (int width , int height ) | |
QOpenGLPaintDevice (const QSize & size ) | |
QOpenGLPaintDevice () | |
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 |
virtual int | metric (QPaintDevice::PaintDeviceMetric metric ) const override |
QOpenGLPaintDevice 使用 current QOpenGL 上下文来渲染 QPainter 绘制命令。上下文是构造时捕获的。它要求支持 OpenGL (ES) 2.0 或更高版本。
QOpenGLPaintDevice 几乎始终硬件加速且拥有比软件光栅化快得多的潜力。不管怎样,它对状态变化更敏感,因此要求小心谨慎排序绘制命令以实现最优性能。
OpenGL 描绘引擎中的抗锯齿是使用多重采样完成的。大多数硬件显著要求更多内存来做多重采样,且结果的品质与软件描绘引擎的品质不相上下。OpenGL 描绘引擎的优势在于它的性能,而不是它的视觉渲染品质。
当描绘到 QOpenGLPaintDevice 使用 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.
当混合 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.
另请参阅 OpenGL 窗口范例 .
构造 QOpenGLPaintDevice 采用给定 width and height .
QOpenGLPaintDevice 仅对当前上下文有效。
另请参阅 QOpenGLContext::currentContext ().
构造 QOpenGLPaintDevice 采用给定 size .
QOpenGLPaintDevice 仅对当前上下文有效。
另请参阅 QOpenGLContext::currentContext ().
构造 QOpenGLPaintDevice。
QOpenGLPaintDevice 仅对当前上下文有效。
另请参阅 QOpenGLContext::currentContext ().
[虚拟]
QOpenGLPaintDevice::
~QOpenGLPaintDevice
()
销毁 QOpenGLPaintDevice .
Returns the OpenGL context associated with the paint device.
返回水平每米的像素数。
另请参阅 setDotsPerMeterX ().
返回垂直每米的像素数。
另请参阅 setDotsPerMeterY ().
[虚拟]
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.
默认实现什么都不做。
[override virtual protected]
int
QOpenGLPaintDevice::
metric
(
QPaintDevice::PaintDeviceMetric
metric
) const
重实现: QPaintDevice::metric (QPaintDevice::PaintDeviceMetric metric) const.
[override virtual]
QPaintEngine
*QOpenGLPaintDevice::
paintEngine
() const
重实现: QPaintDevice::paintEngine () const.
返回
true
若描绘是围绕 Y 轴翻转。
另请参阅 setPaintFlipped ().
Sets the device pixel ratio for the paint device to devicePixelRatio .
Sets the number of pixels per meter horizontally to dpmx .
另请参阅 dotsPerMeterX ().
Sets the number of pixels per meter vertically to dpmy .
另请参阅 dotsPerMeterY ().
Sets whether painting should be flipped around the Y-axis or not to flipped .
另请参阅 paintFlipped ().
Sets the pixel size of the paint device to size .
另请参阅 size ().
返回描绘设备的像素尺寸。
另请参阅 setSize ().