Pass:setViewport

Edit

Sets the viewport. Everything rendered will get mapped to the rectangle defined by the viewport. More specifically, this defines the transformation from normalized device coordinates to pixel coordinates.



Arguments

NameTypeDefaultDescription
xnumber The x coordinate of the upper-left corner of the viewport.
ynumber The y coordinate of the upper-left corner of the viewport.
wnumber The width of the viewport. Must be positive.
hnumber The height of the viewport. May be negative.
dminnumber0.0 The min component of the depth range, between 0 and 1.
dmaxnumber1.0 The max component of the depth range, between 0 and 1.

Returns

Nothing

Disable the viewport.

Arguments

None

Returns

Nothing

Notes

The viewport rectangle can use floating point numbers.

A negative viewport height (with a y coordinate equal to the bottom of the viewport) can be used to flip the rendering vertically.

The default viewport extends from (0, 0) to the dimensions of the canvas, with min depth and max depth respectively set to 0 and 1.

See also