このページでは

QRhiViewport Class

ビューポートの矩形を指定します。詳細...

ヘッダー: #include <rhi/qrhi.h>
CMake: find_package(Qt6 REQUIRED COMPONENTS GuiPrivate)
target_link_libraries(mytarget PRIVATE Qt6::GuiPrivate)
qmake: QT += gui-private
以下のように: Qt 6.6 以降

パブリック関数

QRhiViewport()
QRhiViewport(float x, float y, float w, float h, float minDepth = 0.0f, float maxDepth = 1.0f)
float maxDepth() const
float minDepth() const
void setMaxDepth(float maxDepth)
void setMinDepth(float minDepth)
void setViewport(float x, float y, float w, float h)
std::array<float, 4> viewport() const
size_t qHash(const QRhiViewport &key, size_t seed = 0)
bool operator!=(const QRhiViewport &a, const QRhiViewport &b)
bool operator==(const QRhiViewport &a, const QRhiViewport &b)

詳細な説明

QRhiCommandBuffer::setViewport() とともに使用します。

QRhi OpenGL 形式のビューポート座標を前提としています。つまり、x および y は左下を起点とします。幅または高さが負の値になることは許されません。

一般的な使用例は以下の通りです:

const QSize outputSizeInPixels = swapchain->currentPixelSize();
const QRhiViewport viewport(0, 0, outputSizeInPixels.width(), outputSizeInPixels.height());
cb->beginPass(swapchain->currentFrameRenderTarget(), Qt::black, { 1.0f, 0 });
cb->setGraphicsPipeline(ps);
cb->setViewport(viewport);
// ...

注:これは 互換性の保証が限定的な RHI API です。詳細については、QRhi を参照してください。

関連項目: QRhiCommandBuffer::setViewport()、QRhi::clipSpaceCorrMatrix()、QRhiScissor 。

メンバ関数のドキュメント

[constexpr noexcept default] QRhiViewport::QRhiViewport()

空の矩形と、深度範囲 0.0f ~ 1.0f を持つビューポート記述を構築します。

QRhi::clipSpaceCorrMatrix()も参照してください 。

QRhiViewport::QRhiViewport(float x, float y, float w, float h, float minDepth = 0.0f, float maxDepth = 1.0f)

x 、y 、w 、h で指定された矩形と、minDepth およびmaxDepth で指定された深度範囲を用いて、ビューポート記述を生成します。

注: x およびy は左下隅の位置であるとみなされます。w およびh は負の値にしてはいけません。負の値の場合、QRhiCommandBuffer::setViewport() によってビューポートは無視されます。

QRhi::clipSpaceCorrMatrix()も参照してください 。

float QRhiViewport::maxDepth() const

ビューポートの深度範囲の maxDepth 値を返します。

setMaxDepth()も参照してください 。

float QRhiViewport::minDepth() const

ビューポートの深度範囲の minDepth 値を返します。

setMinDepth()も参照してください 。

void QRhiViewport::setMaxDepth(float maxDepth)

ビューポートの深度範囲のmaxDepth を設定します。デフォルトでは、これは1.0fに設定されています。

maxDepth()も参照してください 。

void QRhiViewport::setMinDepth(float minDepth)

ビューポートの深度範囲のminDepth を設定します。デフォルトでは、これは0.0fに設定されています。

minDepth()も参照してください 。

void QRhiViewport::setViewport(float x, float y, float w, float h)

ビューポートの位置とサイズを、x 、y 、w 、およびh に設定します。

注:ビューポートは 、左下を原点とする座標系で指定されます。

viewport()も参照してください 。

std::array<float, 4> QRhiViewport::viewport() const

ビューポートの x、y、幅、高さを返します。

setViewport()も参照してください 。

関連する非メンバー関数

[noexcept] size_t qHash(const QRhiViewport &key, size_t seed = 0)

`key` のハッシュ値を返します。計算のシードには `seed ` を使用します。

[noexcept] bool operator!=(const QRhiViewport &a, const QRhiViewport &b)

2つのQRhiViewport オブジェクトa とb の値が等しい場合はfalse を返し、そうでない場合はtrue を返します。

[noexcept] bool operator==(const QRhiViewport &a, const QRhiViewport &b)

2つのQRhiViewport オブジェクトa とb の値が等しい場合、true を返します。

© 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.