QRhiViewport Class

Specifies a viewport rectangle. 更多...

头: #include <QRhiViewport>
CMake: find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui
Since: 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 & v , size_t seed = 0)
bool operator!= (const QRhiViewport & a , const QRhiViewport & b )
bool operator== (const QRhiViewport & a , const QRhiViewport & b )

详细描述

Used with QRhiCommandBuffer::setViewport ().

QRhi assumes OpenGL-style viewport coordinates, meaning x and y are bottom-left. Negative width or height are not allowed.

Typical usage is like the following:

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);
// ...
					

注意: This is a RHI API with limited compatibility guarantees, see QRhi 了解细节。

另请参阅 QRhiCommandBuffer::setViewport (), QRhi::clipSpaceCorrMatrix (),和 QRhiScissor .

成员函数文档编制

[constexpr noexcept] QRhiViewport:: QRhiViewport ()

Constructs a viewport description with an empty rectangle and a depth range of 0.0f - 1.0f.

另请参阅 QRhi::clipSpaceCorrMatrix ().

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

Constructs a viewport description with the rectangle specified by x , y , w , h and the depth range minDepth and maxDepth .

注意: x and y are assumed to be the bottom-left position. w and h should not be negative, the viewport will be ignored by QRhiCommandBuffer::setViewport () otherwise.

另请参阅 QRhi::clipSpaceCorrMatrix ().

float QRhiViewport:: maxDepth () const

Returns the maxDepth value of the depth range of the viewport.

另请参阅 setMaxDepth ().

float QRhiViewport:: minDepth () const

Returns the minDepth value of the depth range of the viewport.

另请参阅 setMinDepth ().

void QRhiViewport:: setMaxDepth ( float maxDepth )

设置 maxDepth of the depth range of the viewport. By default this is set to 1.0f.

另请参阅 maxDepth ().

void QRhiViewport:: setMinDepth ( float minDepth )

设置 minDepth of the depth range of the viewport. By default this is set to 0.0f.

另请参阅 minDepth ().

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

Sets the viewport's position and size to x , y , w ,和 h .

注意: Viewports are specified in a coordinate system that has its origin in the bottom-left.

另请参阅 viewport ().

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

Returns the viewport x, y, width, and height.

另请参阅 setViewport ().

相关非成员

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

返回哈希值为 v ,使用 seed 做计算种子。

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

返回 false if the values in the two QRhiViewport 对象 a and b 相等;否则返回 true .

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

返回 true if the values in the two QRhiViewport 对象 a and b 相等。