QOpenGLPaintDevice Class
QOpenGLPaintDevice クラスは、QPainter を使用して OpenGL コンテキストへの描画を可能にします。詳細...
| ヘッダー: | #include <QOpenGLPaintDevice> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS OpenGL) target_link_libraries(mytarget PRIVATE Qt6::OpenGL) |
| qmake: | QT += opengl |
| 継承元: | QPaintDevice |
- 継承されたメンバーを含むすべてのメンバーの一覧
- QOpenGLPaintDevice は、3D レンダリングの一部です。
パブリック関数
| 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 |
詳細な説明
QOpenGLPaintDevice は、現在のQOpenGL コンテキストを使用して、QPainter の描画コマンドをレンダリングします。コンテキストはインスタンス化時に取得されます。OpenGL (ES) 2.0 以降のサポートが必要です。
パフォーマンス
QOpenGLPaintDevice はほぼ常にハードウェアアクセラレーションが適用され、ソフトウェアによるラスタライズよりもはるかに高速になる可能性があります。ただし、状態の変化に対してより敏感であるため、最適なパフォーマンスを得るには、描画コマンドの順序を慎重に決定する必要があります。
アンチエイリアシングと画質
OpenGLペイントエンジンにおけるアンチエイリアシングは、マルチサンプリングを使用して行われます。ほとんどのハードウェアでは、マルチサンプリングを行うためにかなり多くのメモリを必要とし、その結果得られる品質はソフトウェアペイントエンジンの品質には及びません。OpenGLペイントエンジンの強みは、視覚的なレンダリング品質ではなく、そのパフォーマンスにあります。
状態の変更
QPainter を使用して QOpenGLPaintDevice へ描画する場合、現在の OpenGL コンテキストの状態は、ペイントエンジンの要件に合わせて変更されます。アプリケーションは、OpenGL 状態(特に現在のシェーダープログラム、OpenGL ビューポート、テクスチャユニット、および描画モード)が元の状態にリセットされることを期待してはなりません。
QPainterとOpenGLの併用
QPainter とOpenGLを併用する場合、OpenGLの状態が乱れている可能性があることをQPainter に通知し、内部状態を復元できるようにすることが重要です。これを行うには、OpenGLレンダリングを開始する前にQPainter::beginNativePainting()を呼び出し、終了後にQPainter::endNativePainting()を呼び出します。
セキュリティ上の考慮事項
警告: QOpenGLPaintDevice を通じてレンダリングされるすべてのコンテンツは 、信頼できるものであることが前提となります。ベクトルジオメトリ、画像、その他の描画データは処理され、場合によっては変更された上で、基盤となる OpenGL 実装に渡されます。アプリケーション開発者は、ユーザーが提供したコンテンツをレンダリング(引き渡し)する前に、潜在的な影響を慎重に検討することをお勧めします。
「OpenGL ウィンドウの例」も参照してください 。
メンバ関数のドキュメント
QOpenGLPaintDevice::QOpenGLPaintDevice()
QOpenGLPaintDevice を生成します。
QOpenGLPaintDevice は、現在のコンテキストでのみ有効です。
QOpenGLContext::currentContext()も参照してください 。
[explicit] QOpenGLPaintDevice::QOpenGLPaintDevice(const QSize &size)
指定されたsize を使用して、QOpenGLPaintDeviceを構築します。
QOpenGLPaintDevice は、現在のコンテキストでのみ有効です。
QOpenGLContext::currentContext()も参照してください 。
QOpenGLPaintDevice::QOpenGLPaintDevice(int width, int height)
指定されたwidth およびheight を使用して、QOpenGLPaintDeviceを構築します。
この QOpenGLPaintDevice は、現在のコンテキストでのみ有効です。
QOpenGLContext::currentContext()も参照してください 。
[protected delete] QOpenGLPaintDevice::QOpenGLPaintDevice(const QOpenGLPaintDevice &)
QOpenGLPaintDevice のインスタンスをコピーして生成します。この関数は削除されます。
[virtual noexcept] QOpenGLPaintDevice::~QOpenGLPaintDevice()
QOpenGLPaintDevice を破棄します。
QOpenGLContext *QOpenGLPaintDevice::context() const
ペイントデバイスに関連付けられた OpenGL コンテキストを返します。
qreal QOpenGLPaintDevice::dotsPerMeterX() const
水平方向の1メートルあたりのピクセル数を返します。
setDotsPerMeterX()も参照してください 。
qreal QOpenGLPaintDevice::dotsPerMeterY() const
垂直方向の1メートルあたりのピクセル数を返します。
setDotsPerMeterY()も参照してください 。
[virtual] void QOpenGLPaintDevice::ensureActiveTarget()
この仮想メソッドは、異なるQOpenGLPaintDevice インスタンスが交互に描画呼び出しを発行する場合に、ターゲットとなるフレームバッファオブジェクトまたはコンテキストの再バインドを可能にするためのコールバックとして提供されています。
beginNativePainting() もこのメソッドを呼び出します。
デフォルトの実装では、何もしません。
[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
painting が Y 軸を中心に反転している場合、true を返します。
setPaintFlipped()も参照してください 。
void QOpenGLPaintDevice::setDevicePixelRatio(qreal devicePixelRatio)
ペイントデバイスのデバイスピクセル比をdevicePixelRatio に設定します。
void QOpenGLPaintDevice::setDotsPerMeterX(qreal dpmx)
水平方向の1メートルあたりのピクセル数をdpmx に設定します。
dotsPerMeterX()も参照してください 。
void QOpenGLPaintDevice::setDotsPerMeterY(qreal dpmy)
垂直方向の1メートルあたりのピクセル数をdpmy に設定します。
dotsPerMeterY()も参照してください 。
void QOpenGLPaintDevice::setPaintFlipped(bool flipped)
flipped に対して、描画を Y 軸を中心に反転させるかどうかを設定します。
paintFlipped()も参照してください 。
void QOpenGLPaintDevice::setSize(const QSize &size)
ペイントデバイスのピクセルサイズをsize に設定します。
size()も参照してください 。
QSize QOpenGLPaintDevice::size() const
ペイントデバイスのピクセルサイズを返します。
setSize()も参照してください 。
[protected delete] QOpenGLPaintDevice &QOpenGLPaintDevice::operator=(const QOpenGLPaintDevice &)
other をこのQOpenGLPaintDevice インスタンスにコピー代入します。この関数は削除されます。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.