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 Using Metal Feature Set Tables.

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 an array of length 1 is equivalent to calling the setViewport: method. Calling setViewport: after calling setViewports:count:, and vice versa, overrides previously set viewports.

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. The number of scissor rectangles must match the number of viewports.

See Also

Setting Viewport and Scissor Behavior

Rendering to Multiple Viewports in a Draw Command

Select viewports and their corresponding scissor rectangles in your vertex shader.

- setViewport:

Sets the viewport used for transformations and clipping.

Required.

- setScissorRect:

Sets the scissor rectangle for a fragment scissor test.

Required.

- setScissorRects:count:

Sets an array of scissor rectangles.

Required.

MTLViewport

A 3D rectangular region for the viewport clipping.

MTLScissorRect

A rectangle for the scissor fragment test.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software