Stride

OPEN / CLOSE
  • Features
  • Blog
  • Documentation
  • Community
(icon) Download

  • Discord
  • Facebook
  • Twitter
  • YouTube

LANGUAGE

OPEN / CLOSE
  • English
  • 日本語
    Show / Hide Table of Contents

    Viewport Struct

    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>
    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)
    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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
    | Improve this Doc View Source

    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
    | Improve this Doc View Source

    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
    System.ValueType.Equals(System.Object)

    GetHashCode()

    public override int GetHashCode()
    Returns
    Type Description
    System.Int32
    Overrides
    System.ValueType.GetHashCode()

    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
    System.ValueType.ToString()

    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
    | Improve this Doc View Source

    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

    Extension Methods

    ComponentBaseExtensions.DisposeBy<T>(T, ICollectorHolder)
    ComponentBaseExtensions.RemoveDisposeBy<T>(T, ICollectorHolder)
    • Improve this Doc
    • View Source
    In This Article

    Back to top

    Copyright © 2019-2021 .NET Foundation and Contributors
    Supported by the .NET Foundation