Struct Viewport
Defines the viewport dimensions of a render-target surface onto which a 3D volume projects.
public struct Viewport : IEquatable<Viewport>
- Implements
- Extension Methods
Constructors
Viewport(Rectangle)
Initializes a new instance of the Viewport struct.
public Viewport(Rectangle bounds)
Parameters
boundsRectangleA rectangle that defines the location and size of the viewport in a render target.
Viewport(int, int, int, int)
Initializes a new instance of the Viewport struct.
public Viewport(int x, int y, int width, int height)
Parameters
xintThe X coordinate of the upper-left corner of the viewport in pixels.
yintThe Y coordinate of the upper-left corner of the viewport in pixels.
widthintThe width of the viewport in pixels.
heightintThe height of the viewport in pixels.
Viewport(float, float, float, float)
Initializes a new instance of the Viewport struct.
public Viewport(float x, float y, float width, float height)
Parameters
xfloatThe X coordinate of the upper-left corner of the viewport in pixels.
yfloatThe Y coordinate of the upper-left corner of the viewport in pixels.
widthfloatThe width of the viewport in pixels.
heightfloatThe height of the viewport in pixels.
Fields
Empty
Empty value for an undefined viewport.
public static readonly Viewport Empty
Field Value
Height
Height dimension of the viewport on the render-target surface, in pixels.
public float Height
Field Value
MaxDepth
Maximum depth of the clip volume.
public float MaxDepth
Field Value
MinDepth
Minimum depth of the clip volume.
public float MinDepth
Field Value
Width
Width dimension of the viewport on the render-target surface, in pixels.
public float Width
Field Value
X
X coordinate of the upper-left corner of the viewport on the render-target surface, in pixels.
public float X
Field Value
Y
Y coordinate of the upper-left corner of the viewport on the render-target surface, in pixels.
public float Y
Field Value
Properties
AspectRatio
Gets the aspect ratio of the viewport, i.e. Width / Height.
public readonly float AspectRatio { get; }
Property Value
Bounds
Gets a rectangle with the location and size of the viewport.
public Rectangle Bounds { readonly get; set; }
Property Value
Size
Gets the size of the viewport.
public readonly Vector2 Size { get; }
Property Value
Methods
Equals(Viewport)
Indicates whether the current object is equal to another object of the same type.
public readonly bool Equals(Viewport other)
Parameters
otherViewportAn object to compare with this object.
Returns
Equals(object)
Indicates whether this instance and a specified object are equal.
public override readonly bool Equals(object obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand this instance are the same type and represent the same value; otherwise, false.
GetHashCode()
Returns the hash code for this instance.
public override readonly int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
Project(Vector3, Matrix, Matrix, Matrix)
Projects a 3D vector from object space into screen space.
public readonly Vector3 Project(Vector3 source, Matrix projection, Matrix view, Matrix world)
Parameters
sourceVector3The vector to project.
projectionMatrixThe projection matrix.
viewMatrixThe view matrix.
worldMatrixThe world matrix.
Returns
ToString()
Returns a string representation of this viewport.
public override readonly string ToString()
Returns
Unproject(Vector3, Matrix, Matrix, Matrix)
Converts a screen space point into a corresponding point in world space.
public Vector3 Unproject(Vector3 source, Matrix projection, Matrix view, Matrix world)
Parameters
sourceVector3The vector to unproject.
projectionMatrixThe projection matrix.
viewMatrixThe view matrix.
worldMatrixThe world matrix.
Returns
Unproject(Vector3, ref readonly Matrix)
Converts a screen space point into a corresponding point in world space.
public readonly Vector3 Unproject(Vector3 source, ref readonly Matrix worldViewProjection)
Parameters
sourceVector3The vector to unproject.
worldViewProjectionMatrixThe World-View-Projection matrix.
Returns
Operators
operator ==(Viewport, Viewport)
public static bool operator ==(Viewport left, Viewport right)
Parameters
Returns
operator !=(Viewport, Viewport)
public static bool operator !=(Viewport left, Viewport right)