<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLViewport",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:@SA@MTLViewport"
  },
  "title" : "MTLViewport"
}
-->

# MTLViewport

A 3D rectangular region for the viewport clipping.

```
struct MTLViewport
```

## Topics

### Creating a viewport

[`init()`](/documentation/Metal/MTLViewport/init())

Returns a new viewport.

[`init(originX:originY:width:height:znear:zfar:)`](/documentation/Metal/MTLViewport/init(originX:originY:width:height:znear:zfar:))

Returns a new viewport of a specified size at a specified origin.

### Specifying viewport boundaries

[`originX`](/documentation/Metal/MTLViewport/originX)

The x coordinate of the upper-left corner of the viewport.

[`originY`](/documentation/Metal/MTLViewport/originY)

The y coordinate of the upper-left corner of the viewport.

[`width`](/documentation/Metal/MTLViewport/width)

The width of the viewport, in pixels.

[`height`](/documentation/Metal/MTLViewport/height)

The height of the viewport, in pixels.

[`znear`](/documentation/Metal/MTLViewport/znear)

The z coordinate of the near clipping plane of the viewport.

[`zfar`](/documentation/Metal/MTLViewport/zfar)

The z coordinate of the far clipping plane of the viewport.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)