Viewport Struct
Namespace: Stride.GraphicsAssembly: Stride.Graphics.dll
Defines the window dimensions of a render-target surface onto which a 3D volume projects.
public struct Viewport : IEquatable<Viewport>
| Name | Description | |
|---|---|---|
| Constructors | ||
| Viewport(Rectangle) | Initializes a new instance of the Viewport struct. |
|
| Viewport(Int32, Int32, Int32, Int32) | Initializes a new instance of the Viewport struct. |
|
| Viewport(Single, Single, Single, Single) | Initializes a new instance of the Viewport struct. |
|
| Fields | ||
| Empty | Empty value for an undefined viewport. |
|
| Height | Gets or sets the height dimension of the viewport on the render-target surface, in pixels. |
|
| MaxDepth | Gets or sets the maximum depth of the clip volume. |
|
| MinDepth | Gets or sets the minimum depth of the clip volume. |
|
| Width | Gets or sets the width dimension of the viewport on the render-target surface, in pixels. |
|
| X | Gets or sets the pixel coordinate of the upper-left corner of the viewport on the render-target surface. |
|
| Y | Gets or sets the pixel coordinate of the upper-left corner of the viewport on the render-target surface. |
|
| Properties | ||
| AspectRatio | Gets the aspect ratio used by the viewport |
|
| Bounds | Gets the size of this resource. |
|
| Size | Gets the size of the viewport (Width, Height). |
|
| Methods | ||
| Equals(Viewport) | ||
| Equals(Object) | ||
| GetHashCode() | ||
| Project(Vector3, Matrix, Matrix, Matrix) | Projects a 3D vector from object space into screen space. |
|
| ToString() | Retrieves a string representation of this object. |
|
| Unproject(Vector3, Matrix, Matrix, Matrix) | Converts a screen space point into a corresponding point in world space. |
|
| Unproject(Vector3, ref Matrix) | Converts a screen space point into a corresponding point in world space. |
|
| Operators | ||
| Equality(Viewport, Viewport) | ||
| Inequality(Viewport, Viewport) | ||
Constructors
Viewport(Rectangle)
Initializes a new instance of the Viewport struct.
public Viewport(Rectangle bounds)
Parameters
| Type | Name | Description |
|---|---|---|
| Rectangle | bounds | A bounding box that defines the location and size of the viewport in a render target. |
Viewport(Int32, Int32, Int32, Int32)
Initializes a new instance of the Viewport struct.
public Viewport(int x, int y, int width, int height)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | x | The x coordinate of the upper-left corner of the viewport in pixels. |
| System.Int32 | y | The y coordinate of the upper-left corner of the viewport in pixels. |
| System.Int32 | width | The width of the viewport in pixels. |
| System.Int32 | height | The height of the viewport in pixels. |
Viewport(Single, Single, Single, Single)
Initializes a new instance of the Viewport struct.
public Viewport(float x, float y, float width, float height)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Single | x | The x coordinate of the upper-left corner of the viewport in pixels. |
| System.Single | y | The y coordinate of the upper-left corner of the viewport in pixels. |
| System.Single | width | The width of the viewport in pixels. |
| System.Single | height | The height of the viewport in pixels. |
Fields
Empty
Empty value for an undefined viewport.
public static readonly Viewport Empty
Field Value
| Type | Description |
|---|---|
| Viewport |
Height
Gets or sets the height dimension of the viewport on the render-target surface, in pixels.
public float Height
Field Value
| Type | Description |
|---|---|
| System.Single |
MaxDepth
Gets or sets the maximum depth of the clip volume.
public float MaxDepth
Field Value
| Type | Description |
|---|---|
| System.Single |
MinDepth
Gets or sets the minimum depth of the clip volume.
public float MinDepth
Field Value
| Type | Description |
|---|---|
| System.Single |
Width
Gets or sets the width dimension of the viewport on the render-target surface, in pixels.
public float Width
Field Value
| Type | Description |
|---|---|
| System.Single |
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
| Type | Description |
|---|---|
| System.Single |
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
| Type | Description |
|---|---|
| System.Single |
Properties
AspectRatio
Gets the aspect ratio used by the viewport
public readonly float AspectRatio { get; }
Property Value
| Type | Description |
|---|---|
| System.Single |
Bounds
Gets the size of this resource.
public Rectangle Bounds { get; set; }
Property Value
| Type | Description |
|---|---|
| Rectangle |
Size
Gets the size of the viewport (Width, Height).
public readonly Vector2 Size { get; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
Methods
Equals(Viewport)
public bool Equals(Viewport other)
Parameters
| Type | Name | Description |
|---|---|---|
| Viewport | other |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Equals(Object)
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | obj |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Overrides
GetHashCode()
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| System.Int32 |
Overrides
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
| Type | Name | Description |
|---|---|---|
| Vector3 | source | The vector to project. |
| Matrix | projection | The projection matrix. |
| Matrix | view | The view matrix. |
| Matrix | world | The world matrix. |
Returns
| Type | Description |
|---|---|
| Vector3 |
ToString()
Retrieves a string representation of this object.
public override string ToString()
Returns
| Type | Description |
|---|---|
| System.String |
Overrides
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
| Type | Name | Description |
|---|---|---|
| Vector3 | source | The vector to project. |
| Matrix | projection | The projection matrix. |
| Matrix | view | The view matrix. |
| Matrix | world | The world matrix. |
Returns
| Type | Description |
|---|---|
| Vector3 |
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
| Type | Name | Description |
|---|---|---|
| Vector3 | source | The vector to project. |
| Matrix | worldViewProjection | The World-View-Projection matrix. |
Returns
| Type | Description |
|---|---|
| Vector3 |
Operators
Equality(Viewport, Viewport)
public static bool operator ==(Viewport left, Viewport right)
Parameters
| Type | Name | Description |
|---|---|---|
| Viewport | left | |
| Viewport | right |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Inequality(Viewport, Viewport)
public static bool operator !=(Viewport left, Viewport right)
Parameters
| Type | Name | Description |
|---|---|---|
| Viewport | left | |
| Viewport | right |
Returns
| Type | Description |
|---|---|
| System.Boolean |