Struct Viewport
Defines the window dimensions of a render-target surface onto which a 3D volume projects.
public struct Viewport : IEquatable<Viewport>- Implements
Constructors
Viewport(Rectangle)
Initializes a new instance of the Viewport struct.
public Viewport(Rectangle bounds)Parameters
- boundsRectangle
- A bounding box 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
- xint
- The x coordinate of the upper-left corner of the viewport in pixels. 
- yint
- The y coordinate of the upper-left corner of the viewport in pixels. 
- widthint
- The width of the viewport in pixels. 
- heightint
- The 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
- xfloat
- The x coordinate of the upper-left corner of the viewport in pixels. 
- yfloat
- The y coordinate of the upper-left corner of the viewport in pixels. 
- widthfloat
- The width of the viewport in pixels. 
- heightfloat
- The height of the viewport in pixels. 
Fields
Empty
Empty value for an undefined viewport.
public static readonly Viewport EmptyField Value
Height
Gets or sets the height dimension of the viewport on the render-target surface, in pixels.
public float HeightField Value
MaxDepth
Gets or sets the maximum depth of the clip volume.
public float MaxDepthField Value
MinDepth
Gets or sets the minimum depth of the clip volume.
public float MinDepthField Value
Width
Gets or sets the width dimension of the viewport on the render-target surface, in pixels.
public float WidthField Value
X
Gets or sets the pixel coordinate of the upper-left corner of the viewport on the render-target surface.
public float XField Value
Y
Gets or sets the pixel coordinate of the upper-left corner of the viewport on the render-target surface.
public float YField Value
Properties
AspectRatio
Gets the aspect ratio used by the viewport
public float AspectRatio { get; }Property Value
Bounds
Gets the size of this resource.
public Rectangle Bounds { get; set; }Property Value
Size
Gets the size of the viewport (Width, Height).
public Vector2 Size { get; }Property Value
Methods
Equals(Viewport)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(Viewport other)Parameters
- otherViewport
- An object to compare with this object. 
Returns
Equals(object)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object obj)Parameters
- objobject
- The 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 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 Vector3 Project(Vector3 source, Matrix projection, Matrix view, Matrix world)Parameters
- sourceVector3
- The vector to project. 
- projectionMatrix
- The projection matrix. 
- viewMatrix
- The view matrix. 
- worldMatrix
- The world matrix. 
Returns
ToString()
Retrieves a string representation of this object.
public override 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
- sourceVector3
- The vector to project. 
- projectionMatrix
- The projection matrix. 
- viewMatrix
- The view matrix. 
- worldMatrix
- The world matrix. 
Returns
Unproject(Vector3, ref Matrix)
Converts a screen space point into a corresponding point in world space.
public Vector3 Unproject(Vector3 source, ref Matrix worldViewProjection)Parameters
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)