QOpenGLPaintDevice 类

The QOpenGLPaintDevice class enables painting to an OpenGL context using QPainter . 更多...

头: #include <QOpenGLPaintDevice>
qmake: QT += gui
Since: Qt 5.0
继承: 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

保护变量

QScopedPointer<QOpenGLPaintDevicePrivate> d_ptr

详细描述

The QOpenGLPaintDevice class enables painting to an OpenGL context using QPainter .

The QOpenGLPaintDevice 使用 current QOpenGL 上下文来渲染 QPainter 绘制命令。上下文是构造时捕获的。它要求支持 OpenGL (ES) 2.0 或更高版本。

性能

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.

抗锯齿和品质

OpenGL 描绘引擎中的抗锯齿是使用多重采样完成的。大多数硬件显著要求更多内存来做多重采样,且结果的品质与软件描绘引擎的品质不相上下。OpenGL 描绘引擎的优势在于它的性能,而不是它的视觉渲染品质。

状态变化

When painting to a 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 ()

构造 QOpenGLPaintDevice .

The QOpenGLPaintDevice is only valid for the current context.

另请参阅 QOpenGLContext::currentContext ().

QOpenGLPaintDevice:: QOpenGLPaintDevice (const QSize & size )

构造 QOpenGLPaintDevice 采用给定 size .

The QOpenGLPaintDevice is only valid for the current context.

另请参阅 QOpenGLContext::currentContext ().

QOpenGLPaintDevice:: QOpenGLPaintDevice ( int width , int height )

构造 QOpenGLPaintDevice 采用给定 width and height .

The QOpenGLPaintDevice is only valid for the current context.

另请参阅 QOpenGLContext::currentContext ().

[protected] QOpenGLPaintDevice:: QOpenGLPaintDevice ( const QOpenGLPaintDevice & )

Default constructs an instance of QOpenGLPaintDevice.

[虚拟] 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 ().

[override virtual] QPaintEngine *QOpenGLPaintDevice:: paintEngine () const

重实现自 QPaintDevice::paintEngine ().

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 ().

[protected] QOpenGLPaintDevice &QOpenGLPaintDevice:: operator= ( const QOpenGLPaintDevice & )

拷贝赋值运算符。