Gorgon
Show / Hide Table of Contents

Class GorgonRenderTarget2DView

A view to allow 2D texture based render targets to be bound to the pipeline.

Inheritance
object
GorgonResourceView
GorgonRenderTargetView
GorgonRenderTarget2DView
Implements
IDisposable
IGorgonGraphicsObject
IEquatable<GorgonResourceView>
IGorgonTexture2DInfo
IGorgonNamedObject
IGorgonImageInfo
Inherited Members
GorgonRenderTargetView.Format
GorgonRenderTargetView.FormatInformation
GorgonRenderTargetView.Clear(in GorgonColor)
GorgonResourceView.IsDisposed
GorgonResourceView.Resource
GorgonResourceView.Usage
GorgonResourceView.Graphics
GorgonResourceView.Equals(GorgonResourceView)
GorgonResourceView.Equals(object)
GorgonResourceView.GetHashCode()
object.ToString()
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetType()
Namespace: Gorgon.Graphics.Core
Assembly: Gorgon.Graphics.Core.dll
Syntax
public sealed class GorgonRenderTarget2DView : GorgonRenderTargetView, IDisposable, IGorgonGraphicsObject, IEquatable<GorgonResourceView>, IGorgonTexture2DInfo, IGorgonNamedObject, IGorgonImageInfo
Remarks

A render target view allows a render target (such as a GorgonSwapChain or a texture to be bound to the GPU pipeline as a render target resource.

The view can bind the entire resource, or a sub section of the resource as required. It will also allow for casting of the format to allow for reinterpreting the data stored within the the render target.

Properties

| Edit this page View Source

ArrayCount

Property to return the number of array indices to use in the view.

Declaration
public int ArrayCount { get; }
Property Value
Type Description
int
See Also
GorgonSwapChain
GorgonTexture2D
GorgonTexture3D
| Edit this page View Source

ArrayIndex

Property to return the first array index to use in the view.

Declaration
public int ArrayIndex { get; }
Property Value
Type Description
int
See Also
GorgonSwapChain
GorgonTexture2D
GorgonTexture3D
| Edit this page View Source

Binding

Property to return the flags to determine how the texture will be bound with the pipeline when rendering.

Declaration
public override TextureBinding Binding { get; }
Property Value
Type Description
TextureBinding
Overrides
GorgonRenderTargetView.Binding
See Also
GorgonSwapChain
GorgonTexture2D
GorgonTexture3D
| Edit this page View Source

Bounds

Property to return the bounding rectangle for the render target view.

Declaration
public Rectangle Bounds { get; }
Property Value
Type Description
Rectangle
Remarks

This value is the full bounding rectangle of the first mip map level for the texture associated with the render target.

See Also
GorgonSwapChain
GorgonTexture2D
GorgonTexture3D
| Edit this page View Source

Height

Property to return the height of the render target in pixels.

Declaration
public override int Height { get; }
Property Value
Type Description
int
Overrides
GorgonRenderTargetView.Height
Remarks

This value is the full width of the first mip map level for the texture associated with the render target.

See Also
GorgonSwapChain
GorgonTexture2D
GorgonTexture3D
| Edit this page View Source

IsCubeMap

Property to return whether the 2D texture is a cube map.

Declaration
public bool IsCubeMap { get; }
Property Value
Type Description
bool
See Also
GorgonSwapChain
GorgonTexture2D
GorgonTexture3D
| Edit this page View Source

MipHeight

Property to return the height of the render target at the current MipSlice in pixels.

Declaration
public int MipHeight { get; }
Property Value
Type Description
int
Remarks

This value is the height of the mip map level assigned to MipSlice for the texture associated with the render target.

See Also
GorgonSwapChain
GorgonTexture2D
GorgonTexture3D
| Edit this page View Source

MipSlice

Property to return the mip slice to use for the view.

Declaration
public int MipSlice { get; }
Property Value
Type Description
int
See Also
GorgonSwapChain
GorgonTexture2D
GorgonTexture3D
| Edit this page View Source

MipWidth

Property to return the width of the render target at the current MipSlice in pixels.

Declaration
public int MipWidth { get; }
Property Value
Type Description
int
Remarks

This value is the width of the mip map level assigned to MipSlice for the texture associated with the render target.

See Also
GorgonSwapChain
GorgonTexture2D
GorgonTexture3D
| Edit this page View Source

MultisampleInfo

Property to return the multisample quality and count for the texture.

Declaration
public GorgonMultisampleInfo MultisampleInfo { get; }
Property Value
Type Description
GorgonMultisampleInfo
See Also
GorgonSwapChain
GorgonTexture2D
GorgonTexture3D
| Edit this page View Source

Shared

Property to return whether the resource used by this view can be shared or not.

Declaration
public TextureSharingOptions Shared { get; }
Property Value
Type Description
TextureSharingOptions
See Also
GorgonSwapChain
GorgonTexture2D
GorgonTexture3D
| Edit this page View Source

Texture

Property to return the texture bound to this render target view.

Declaration
public GorgonTexture2D Texture { get; }
Property Value
Type Description
GorgonTexture2D
See Also
GorgonSwapChain
GorgonTexture2D
GorgonTexture3D
| Edit this page View Source

Width

Property to return the width of the render target in pixels.

Declaration
public override int Width { get; }
Property Value
Type Description
int
Overrides
GorgonRenderTargetView.Width
Remarks

This value is the full width of the first mip map level for the texture associated with the render target.

See Also
GorgonSwapChain
GorgonTexture2D
GorgonTexture3D

Methods

| Edit this page View Source

Clear(in GorgonColor, ReadOnlySpan<Rectangle>)

Function to clear the contents of the render target for this view.

Declaration
public void Clear(in GorgonColor color, ReadOnlySpan<Rectangle> rectangles)
Parameters
Type Name Description
GorgonColor color

Color to use when clearing the render target view.

ReadOnlySpan<Rectangle> rectangles

[Optional] Specifies which regions on the view to clear.

Remarks

This will clear the render target view to the specified color. If a specific region should be cleared, one or more rectangles should be passed to the method.

If the rectangles parameter is null, or has a zero length, the entirety of the view is cleared.

See Also
GorgonSwapChain
GorgonTexture2D
GorgonTexture3D
| Edit this page View Source

CreateInteropRenderTarget(GorgonGraphics, nint, string)

Function to create a render target used to interoperate with external rendering systems (e.g. WPF).

Declaration
public static GorgonRenderTarget2DView CreateInteropRenderTarget(GorgonGraphics graphics, nint surface, string name)
Parameters
Type Name Description
GorgonGraphics graphics

The graphics interface used to create the objects for the render target view.

nint surface

A pointer to a surface that Gorgon can render into.

string name

[Optional] The name to use for the render target texture resource.

Returns
Type Description
GorgonRenderTarget2DView

The new render target view.

Remarks

This method is used to wrap a surface from an external rendering system such as WPF (which is based on Direct3D 9) into a Gorgon render target view. This allows Gorgon to render into the external surface.

important

This render target view takes ownership of its underlying texture. Disposal of the render target view will also dispose the underlying texture resource.

Exceptions
Type Condition
ArgumentNullException

Thrown when the graphics, or the surface parameter is null.

GorgonException

Thrown if the surface pointer could not be interpreted as a 2D Texture.

See Also
GorgonSwapChain
GorgonTexture2D
GorgonTexture3D
| Edit this page View Source

CreateRenderTarget(GorgonGraphics, IGorgonTexture2DInfo, int, int?)

Function to create a new render target that is bindable to the GPU.

Declaration
public static GorgonRenderTarget2DView CreateRenderTarget(GorgonGraphics graphics, IGorgonTexture2DInfo info, int arrayIndex = 0, int? arrayCount = null)
Parameters
Type Name Description
GorgonGraphics graphics

The graphics interface to use when creating the target.

IGorgonTexture2DInfo info

The information about the texture.

int arrayIndex

[Optional] The index of a texture array to slice the view at.

int? arrayCount

[Optioanl] The number of array indices to view.

Returns
Type Description
GorgonRenderTarget2DView

A new GorgonRenderTarget2DView.

Remarks

This is a convenience method that will create a GorgonTexture2D and a GorgonRenderTarget2DView as a single object that users can use to apply a render target texture. This helps simplify creation of a render target by executing some prerequisite steps on behalf of the user.

Since the GorgonTexture2D created by this method is linked to the GorgonRenderTarget2DView returned, disposal of either one will dispose of the other on your behalf. If the user created a GorgonRenderTarget2DView from the GetRenderTargetView(BufferFormat, int, int, int) method on the GorgonTexture2D, then it's assumed the user knows what they are doing and will handle the disposal of the texture and view on their own.

Exceptions
Type Condition
ArgumentNullException

Thrown when the graphics, or info parameter is null.

See Also
GorgonTexture2D
| Edit this page View Source

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Declaration
public override void Dispose()
Overrides
GorgonResourceView.Dispose()
See Also
GorgonSwapChain
GorgonTexture2D
GorgonTexture3D
| Edit this page View Source

GetShaderResourceView(BufferFormat)

Function to create a new GorgonTexture2DView for this texture.

Declaration
public GorgonTexture2DView GetShaderResourceView(BufferFormat format = BufferFormat.Unknown)
Parameters
Type Name Description
BufferFormat format

[Optional] The format for the view.

Returns
Type Description
GorgonTexture2DView

A GorgonTexture2DView used to bind the texture to a shader.

Remarks

This will create a view that makes a texture accessible to shaders. This allows viewing of the texture data in a different format, or even a subsection of the texture from within the shader.

The format parameter is used present the texture data as another format type to the shader. If this value is left at the default of Unknown, then the format from the this texture is used. The format must be castable to the format of this texture. If it is not, an exception will be thrown.

Exceptions
Type Condition
ArgumentException

Thrown if the format is a typeless format.

GorgonException

Thrown when this texture does not have a TextureBinding of ShaderResource.

-or-

Thrown when this texture has a usage of Staging.

-or-

Thrown if the texture Format is not typeless, and the Binding is set to DepthStencil.

See Also
GorgonSwapChain
GorgonTexture2D
GorgonTexture3D
| Edit this page View Source

ToPixel(RectangleF)

Function to convert a rectangle of texel coordinates to pixel space.

Declaration
public Rectangle ToPixel(RectangleF texelCoordinates)
Parameters
Type Name Description
RectangleF texelCoordinates

The texel coordinates to convert.

Returns
Type Description
Rectangle

A rectangle containing the pixel space coordinates.

See Also
GorgonSwapChain
GorgonTexture2D
GorgonTexture3D
| Edit this page View Source

ToPixel(Size2F)

Function to convert a size value from texel coordinates to pixel space.

Declaration
public Size2 ToPixel(Size2F texelSize)
Parameters
Type Name Description
Size2F texelSize

The texel size to convert.

Returns
Type Description
Size2

A size value containing the texel space coordinates.

See Also
GorgonSwapChain
GorgonTexture2D
GorgonTexture3D
| Edit this page View Source

ToPixel(Vector2)

Function to convert a 2D vector value from texel coordinates to pixel space.

Declaration
public Vector2 ToPixel(Vector2 texelVector)
Parameters
Type Name Description
Vector2 texelVector

The texel size to convert.

Returns
Type Description
Vector2

A 2D vector containing the pixel space coordinates.

See Also
GorgonSwapChain
GorgonTexture2D
GorgonTexture3D
| Edit this page View Source

ToTexel(Rectangle)

Function to convert a rectangle of pixel coordinates to texel space.

Declaration
public RectangleF ToTexel(Rectangle pixelCoordinates)
Parameters
Type Name Description
Rectangle pixelCoordinates

The pixel coordinates to convert.

Returns
Type Description
RectangleF

A rectangle containing the texel space coordinates.

See Also
GorgonSwapChain
GorgonTexture2D
GorgonTexture3D
| Edit this page View Source

ToTexel(Size2)

Function to convert a size value from pixel coordinates to texel space.

Declaration
public Size2F ToTexel(Size2 pixelSize)
Parameters
Type Name Description
Size2 pixelSize

The pixel size to convert.

Returns
Type Description
Size2F

A size value containing the texel space coordinates.

See Also
GorgonSwapChain
GorgonTexture2D
GorgonTexture3D
| Edit this page View Source

ToTexel(Vector2)

Function to convert a 2D vector value from pixel coordinates to texel space.

Declaration
public Vector2 ToTexel(Vector2 pixelVector)
Parameters
Type Name Description
Vector2 pixelVector

The pixel size to convert.

Returns
Type Description
Vector2

A 2D vector containing the texel space coordinates.

See Also
GorgonSwapChain
GorgonTexture2D
GorgonTexture3D

Implements

IDisposable
IGorgonGraphicsObject
IEquatable<T>
IGorgonTexture2DInfo
IGorgonNamedObject
IGorgonImageInfo

Extension Methods

GorgonDebugExtensions.ValidateObject<T>(T, string)
GorgonNullExtensions.AsNullable<T>(object)
GorgonNullExtensions.IfNull<T>(object, T)
GorgonNullExtensions.IsNull(object)

See Also

GorgonSwapChain
GorgonTexture2D
GorgonTexture3D
  • Edit this page
  • View Source
In this article
Back to top Copyright 2023 - Licensed under the MIT license by Michael Winsor (Tape_Worm).
Send comments on this topic to the author