QOpenGLPaintDevice 類

QOpenGLPaintDevice 類啓用描繪到 OpenGL 上下文使用 QPainter . 更多...

頭: #include <QOpenGLPaintDevice>
qmake: QT += gui
Since: Qt 5.0
繼承: QPaintDevice

該類在 Qt 5.0 引入。

公共函數

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