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
bounds
RectangleA 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
x
intThe x coordinate of the upper-left corner of the viewport in pixels.
y
intThe y coordinate of the upper-left corner of the viewport in pixels.
width
intThe width of the viewport in pixels.
height
intThe 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
x
floatThe x coordinate of the upper-left corner of the viewport in pixels.
y
floatThe y coordinate of the upper-left corner of the viewport in pixels.
width
floatThe width of the viewport in pixels.
height
floatThe height of the viewport in pixels.
Fields
Empty
Empty value for an undefined viewport.
public static readonly Viewport Empty
Field Value
Height
Gets or sets the height dimension of the viewport on the render-target surface, in pixels.
public float Height
Field Value
MaxDepth
Gets or sets the maximum depth of the clip volume.
public float MaxDepth
Field Value
MinDepth
Gets or sets the minimum depth of the clip volume.
public float MinDepth
Field Value
Width
Gets or sets the width dimension of the viewport on the render-target surface, in pixels.
public float Width
Field Value
X
Gets or sets the pixel coordinate of the upper-left corner of the viewport on the render-target surface.
public float X
Field Value
Y
Gets or sets the pixel coordinate of the upper-left corner of the viewport on the render-target surface.
public float Y
Field 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
other
ViewportAn 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
obj
objectThe object to compare with the current instance.
Returns
- bool
true if
obj
and 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
source
Vector3The vector to project.
projection
MatrixThe projection matrix.
view
MatrixThe view matrix.
world
MatrixThe 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
source
Vector3The vector to project.
projection
MatrixThe projection matrix.
view
MatrixThe view matrix.
world
MatrixThe 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)