Table of Contents

Struct Viewport

Namespace
Stride.Graphics
Assembly
Stride.Graphics.dll

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 Rectangle

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

x int

The x coordinate of the upper-left corner of the viewport in pixels.

y int

The y coordinate of the upper-left corner of the viewport in pixels.

width int

The width of the viewport in pixels.

height int

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

x float

The x coordinate of the upper-left corner of the viewport in pixels.

y float

The y coordinate of the upper-left corner of the viewport in pixels.

width float

The width of the viewport in pixels.

height float

The height of the viewport in pixels.

Fields

Empty

Empty value for an undefined viewport.

public static readonly Viewport Empty

Field Value

Viewport

Height

Gets or sets the height dimension of the viewport on the render-target surface, in pixels.

public float Height

Field Value

float

MaxDepth

Gets or sets the maximum depth of the clip volume.

public float MaxDepth

Field Value

float

MinDepth

Gets or sets the minimum depth of the clip volume.

public float MinDepth

Field Value

float

Width

Gets or sets the width dimension of the viewport on the render-target surface, in pixels.

public float Width

Field Value

float

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

float

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

float

Properties

AspectRatio

Gets the aspect ratio used by the viewport

public float AspectRatio { get; }

Property Value

float

Bounds

Gets the size of this resource.

public Rectangle Bounds { get; set; }

Property Value

Rectangle

Size

Gets the size of the viewport (Width, Height).

public Vector2 Size { get; }

Property Value

Vector2

Methods

Equals(Viewport)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(Viewport other)

Parameters

other Viewport

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object)

Indicates whether this instance and a specified object are equal.

public override bool Equals(object obj)

Parameters

obj object

The 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 Vector3

The vector to project.

projection Matrix

The projection matrix.

view Matrix

The view matrix.

world Matrix

The world matrix.

Returns

Vector3

ToString()

Retrieves a string representation of this object.

public override string ToString()

Returns

string

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 Vector3

The vector to project.

projection Matrix

The projection matrix.

view Matrix

The view matrix.

world Matrix

The world matrix.

Returns

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

source Vector3

The vector to project.

worldViewProjection Matrix

The World-View-Projection matrix.

Returns

Vector3

Operators

operator ==(Viewport, Viewport)

public static bool operator ==(Viewport left, Viewport right)

Parameters

left Viewport
right Viewport

Returns

bool

operator !=(Viewport, Viewport)

public static bool operator !=(Viewport left, Viewport right)

Parameters

left Viewport
right Viewport

Returns

bool