Export (0) Print
Expand All

Matrix.CreatePerspective Method (Single, Single, Single, Single, Matrix)

Builds a perspective projection matrix and returns the result by reference.

Namespace: Microsoft.Xna.Framework
Assembly: Microsoft.Xna.Framework (in microsoft.xna.framework.dll)

public static void CreatePerspective (
         float width,
         float height,
         float nearPlaneDistance,
         float farPlaneDistance,
         out Matrix result


Type: Single
Width of the view volume at the near view plane.
Type: Single
Height of the view volume at the near view plane.
Type: Single
Distance to the near view plane.
Type: Single
Distance to the far view plane.
Type: Matrix
[OutAttribute] The projection matrix.

Exception typeCondition

One of the following conditions is true:

  • nearPlaneDistance or farPlaneDistance is a negative value. Specify a positive value for nearPlaneDistance or farPlaneDistance.
  • nearPlaneDistance is larger than farPlaneDistance. nearPlaneDistance must be smaller than farPlaneDistance.

Projection space refers to the space after applying projection transformation from view space. After the projection transformation, visible content has x- and y-coordinates ranging from −1 to 1, and a z-coordinate ranging from 0 to 1.

To obtain the viewable area (in world space) of a scene, create a BoundingFrustum and pass the combined view and projection matrix to the constructor.

Xbox 360, Windows 7, Windows Vista, Windows XP, Windows Phone

Community Additions

© 2014 Microsoft