Struct Viewport
Describes the view bounds for render-target surface.
[DataContract]
public struct Viewport
- Inherited Members
Constructors
Viewport(Rectangle)
Creates a new instance of Viewport struct.
public Viewport(Rectangle bounds)
Parameters
Viewport(int, int, int, int)
public Viewport(int x, int y, int width, int height)
Parameters
x
intThe x coordinate of the upper-left corner of the view bounds in pixels.
y
intThe y coordinate of the upper-left corner of the view bounds in pixels.
width
intThe width of the view bounds in pixels.
height
intThe height of the view bounds in pixels.
Viewport(int, int, int, int, float, float)
Constructs a viewport from the given values.
public Viewport(int x, int y, int width, int height, float minDepth, float maxDepth)
Parameters
x
intThe x coordinate of the upper-left corner of the view bounds in pixels.
y
intThe y coordinate of the upper-left corner of the view bounds in pixels.
width
intThe width of the view bounds in pixels.
height
intThe height of the view bounds in pixels.
minDepth
floatThe lower limit of depth.
maxDepth
floatThe upper limit of depth.
Properties
AspectRatio
Gets the aspect ratio of this Viewport, which is width / height.
public float AspectRatio { get; }
Property Value
Bounds
Gets or sets a boundary of this Viewport.
public Rectangle Bounds { get; set; }
Property Value
Height
The height of the bounds in pixels.
[DataMember]
public int Height { get; set; }
Property Value
MaxDepth
The upper limit of depth of this viewport.
[DataMember]
public float MaxDepth { get; set; }
Property Value
MinDepth
The lower limit of depth of this viewport.
[DataMember]
public float MinDepth { get; set; }
Property Value
TitleSafeArea
Returns the subset of the viewport that is guaranteed to be visible on a lower quality display.
public Rectangle TitleSafeArea { get; }
Property Value
Width
The width of the bounds in pixels.
[DataMember]
public int Width { get; set; }
Property Value
X
The x coordinate of the beginning of this viewport.
[DataMember]
public int X { get; set; }
Property Value
Y
The y coordinate of the beginning of this viewport.
[DataMember]
public int Y { get; set; }
Property Value
Methods
Project(Vector3, Matrix, Matrix, Matrix)
Projects a Vector3 from model space into screen space. The source point is transformed from model space to world space by the world matrix, then from world space to view space by the view matrix, and finally from view space to screen space by the projection matrix.
public Vector3 Project(Vector3 source, Matrix projection, Matrix view, Matrix world)
Parameters
source
Vector3The Vector3 to project.
projection
MatrixThe projection Matrix.
view
MatrixThe view Matrix.
world
MatrixThe world Matrix.
Returns
ToString()
Returns a string representation of this Viewport in the format: {X:[X] Y:[Y] Width:[Width] Height:[Height] MinDepth:[MinDepth] MaxDepth:[MaxDepth]}
public override string ToString()
Returns
Unproject(Vector3, Matrix, Matrix, Matrix)
Unprojects a Vector3 from screen space into model space. The source point is transformed from screen space to view space by the inverse of the projection matrix, then from view space to world space by the inverse of the view matrix, and finally from world space to model space by the inverse of the world matrix. Note source.Z must be less than or equal to MaxDepth.
public Vector3 Unproject(Vector3 source, Matrix projection, Matrix view, Matrix world)
Parameters
source
Vector3The Vector3 to unproject.
projection
MatrixThe projection Matrix.
view
MatrixThe view Matrix.
world
MatrixThe world Matrix.