QOpenGLPaintDevice 类

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 和 OpenGL

当混合 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:: QOpenGLPaintDevice ( int width , int height )

构造 QOpenGLPaintDevice 采用给定 width and height .

QOpenGLPaintDevice 仅对当前上下文有效。

另请参阅 QOpenGLContext::currentContext ().

QOpenGLPaintDevice:: QOpenGLPaintDevice (const QSize & size )

构造 QOpenGLPaintDevice 采用给定 size .

QOpenGLPaintDevice 仅对当前上下文有效。

另请参阅 QOpenGLContext::currentContext ().

QOpenGLPaintDevice:: QOpenGLPaintDevice ()

构造 QOpenGLPaintDevice。

QOpenGLPaintDevice 仅对当前上下文有效。

另请参阅 QOpenGLContext::currentContext ().

[虚拟] QOpenGLPaintDevice:: ~QOpenGLPaintDevice ()

销毁 QOpenGLPaintDevice .

QOpenGLContext *QOpenGLPaintDevice:: context () const

Returns the OpenGL context associated with the paint device.

qreal QOpenGLPaintDevice:: dotsPerMeterX () const

返回水平每米的像素数。

另请参阅 setDotsPerMeterX ().

qreal QOpenGLPaintDevice:: dotsPerMeterY () const

返回垂直每米的像素数。

另请参阅 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.

bool QOpenGLPaintDevice:: paintFlipped () const

返回 true 若描绘是围绕 Y 轴翻转。

另请参阅 setPaintFlipped ().

void QOpenGLPaintDevice:: setDevicePixelRatio ( qreal devicePixelRatio )

Sets the device pixel ratio for the paint device to devicePixelRatio .

void QOpenGLPaintDevice:: setDotsPerMeterX ( qreal dpmx )

Sets the number of pixels per meter horizontally to dpmx .

另请参阅 dotsPerMeterX ().

void QOpenGLPaintDevice:: setDotsPerMeterY ( qreal dpmy )

Sets the number of pixels per meter vertically to dpmy .

另请参阅 dotsPerMeterY ().

void QOpenGLPaintDevice:: setPaintFlipped ( bool flipped )

Sets whether painting should be flipped around the Y-axis or not to flipped .

另请参阅 paintFlipped ().

void QOpenGLPaintDevice:: setSize (const QSize & size )

Sets the pixel size of the paint device to size .

另请参阅 size ().

QSize QOpenGLPaintDevice:: size () const

返回描绘设备的像素尺寸。

另请参阅 setSize ().