QRhiViewport Class

Specifies a viewport rectangle. More...

Header: #include <QRhiViewport>
qmake: QT += rhi

Public Functions

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
uint qHash(const QRhiViewport &v, uint seed = 0)
bool operator!=(const QRhiViewport &a, const QRhiViewport &b)
bool operator==(const QRhiViewport &a, const QRhiViewport &b)

Detailed Description

Specifies a viewport rectangle.

Used with QRhiCommandBuffer::setViewport().

Note: QRhi assumes OpenGL-style viewport coordinates, meaning x and y are bottom-left.

Typical usage is like the following:


  const QSize outputSizeInPixels = swapchain->currentPixelSize();
  const QRhiViewport viewport(0, 0, outputSizeInPixels.width(), outputSizeInPixels.height());
  cb->beginPass(swapchain->currentFrameRenderTarget(), { 0, 0, 0, 1 }, { 1, 0 });
  cb->setGraphicsPipeline(ps);
  cb->setViewport(viewport);
  ...

See also QRhiCommandBuffer::setViewport(), QRhi::clipSpaceCorrMatrix(), and QRhiScissor.

Member Type Documentation

Property Documentation

Member Function Documentation

QRhiViewport::QRhiViewport()

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

See also 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.

Note: x and y are assumed to be the bottom-left position.

See also QRhi::clipSpaceCorrMatrix().

float QRhiViewport::maxDepth() const

See also setMaxDepth().

float QRhiViewport::minDepth() const

See also setMinDepth().

void QRhiViewport::setMaxDepth(float maxDepth)

See also maxDepth().

void QRhiViewport::setMinDepth(float minDepth)

See also minDepth().

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

See also viewport().

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

See also setViewport().

Member Variable Documentation

Related Non-Members

uint qHash(const QRhiViewport &v, uint seed = 0)

Returns the hash value for v, using seed to seed the calculation.

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.

bool operator==(const QRhiViewport &a, const QRhiViewport &b)

Returns true if the values in the two QRhiViewport objects a and b are equal.

Macro Documentation