Instance Method

setViewport(_:)

Sets the viewport used for transformations and clipping.

Required.

Declaration

func setViewport(_ viewport: MTLViewport)

Parameters

viewport

The viewport used for transformations and clipping.

Discussion

The viewport transforms vertices from normalized device coordinates to window coordinates. It also clips fragments that lie outside of its boundaries.

The x/y rectangle of the viewport must lie entirely within the current attachment size. The values for znear and zfar must be between 0.0 and 1.0, respectively. Flipping is allowed.

The default values for the viewport are originX = 0.0; originY = 0.0; width = w; height = h; znear = 0.0; and zfar = 1.0, where w and h are the x and y dimensions of the attachment, respectively.

Calling setViewport(_:) after calling setViewports(_:count:) overrides previously set viewports, and vice versa.

See Also

Setting Viewport and Scissor Behavior

func setViewports([MTLViewport])

Sets an array of viewports.

struct MTLViewport

A 3D rectangular region for the viewport clipping.

func setScissorRect(MTLScissorRect)

Sets the scissor rectangle for a fragment scissor test.

Required.

struct MTLScissorRect

A rectangle for the scissor fragment test.