Specifies a viewport rectangle. More...
| Header: | #include <rhi/qrhi.h> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Gui)target_link_libraries(mytarget PRIVATE Qt6::GuiPrivate) |
| qmake: | QT += gui-private |
| 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 &key, 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); // ...
Note: This is a RHI API with limited compatibility guarantees, see QRhi for details.
See also QRhiCommandBuffer::setViewport(), QRhi::clipSpaceCorrMatrix(), and QRhiScissor.
[constexpr noexcept] QRhiViewport::QRhiViewport()Constructs a viewport description with an empty rectangle and a depth range of 0.0f - 1.0f.
See also QRhi::clipSpaceCorrMatrix().
Constructs a viewport description with the rectangle specified by x, y, w, h and the depth range minDepth and maxDepth.
Note: 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.
See also QRhi::clipSpaceCorrMatrix().
Returns the maxDepth value of the depth range of the viewport.
See also setMaxDepth().
Returns the minDepth value of the depth range of the viewport.
See also setMinDepth().
Sets the maxDepth of the depth range of the viewport. By default this is set to 1.0f.
See also maxDepth().
Sets the minDepth of the depth range of the viewport. By default this is set to 0.0f.
See also minDepth().
Sets the viewport's position and size to x, y, w, and h.
Note: Viewports are specified in a coordinate system that has its origin in the bottom-left.
See also viewport().
Returns the viewport x, y, width, and height.
See also setViewport().
[noexcept] size_t qHash(const QRhiViewport &key, size_t seed = 0)Returns the hash value for key, using seed to seed the calculation.
[noexcept] bool operator!=(const QRhiViewport &a, const QRhiViewport &b)Returns false if the values in the two QRhiViewport objects a and b are equal; otherwise returns true.
[noexcept] bool operator==(const QRhiViewport &a, const QRhiViewport &b)Returns true if the values in the two QRhiViewport objects a and b are equal.