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

重實現保護函數

virtual int metric (QPaintDevice::PaintDeviceMetric metric ) const override

詳細描述

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

[虛擬] 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 ().