Instance Method

setViewports:count:

Sets an array of viewports.

Required.

Declaration

- (void)setViewports:(const MTLViewport *)viewports count:(NSUInteger)count;

Parameters

viewports

An array of viewports.

count

The number of viewports in the array.

Discussion

Use this method to specify multiple active viewports and corresponding scissor rectangles, enabling you to draw into separate areas of an image using a single draw call.

The maximum number of supported viewports and scissor rectangles varies by device. For more information, see Metal Feature Sets.

The rendering pipeline uses only one of the viewports to transform and clip vertices. You select this viewport per primitive by specifying a [[viewport_array_index]] attribute on an output value from your vertex function.

Calling this method with a single-viewport array is equivalent to calling the setViewport: method. Calling setViewport: after calling setViewports:count: overrides previously set viewports, and vice versa.

You can call the setScissorRect: method to set a single scissor rectangle for all viewports. Otherwise, you can call the setScissorRects:count: method to set different scissor rectangles for different viewports, as long as the number of scissor rectangles matches the number of viewports.

The number of scissor rectangles must match the number of viewports.

See Also

Setting Viewport and Scissor Behavior

setViewport:

Sets the viewport used for transformations and clipping.

Required.

MTLViewport

A 3D rectangular region for the viewport clipping.

setScissorRect:

Sets the scissor rectangle for a fragment scissor test.

Required.

setScissorRects:count:

Sets an array of scissor rectangles.

Required.

MTLScissorRect

A rectangle for the scissor fragment test.