Table of Contents

Class Texture2D

Namespace
SharpDX.Toolkit.Graphics
Assembly
HelixToolkit.SharpDX.dll

A Texture 2D front end to SharpDX.Direct3D11.Texture2D.

public class Texture2D : Texture2DBase, IComponent, INotifyPropertyChanged, IDisposable, IComparable<Texture>
Inheritance
Texture2D
Implements
Inherited Members

Methods

Clone()

Makes a copy of this texture.

public override Texture Clone()

Returns

Texture

A copy of this texture.

Remarks

This method doesn't copy the content of the texture.

Load(Device, Stream, TextureFlags, ResourceUsage)

Loads a 2D texture from a stream.

public static Texture2D Load(Device device, Stream stream, TextureFlags flags = TextureFlags.ShaderResource, ResourceUsage usage = ResourceUsage.Immutable)

Parameters

device Device

The SharpDX.Direct3D11.Device.

stream Stream

The stream to load the texture from.

flags TextureFlags

Sets the texture flags (for unordered access...etc.)

usage ResourceUsage

Usage of the resource. Default is SharpDX.Direct3D11.ResourceUsage.Immutable

Returns

Texture2D

A texture

Exceptions

ArgumentException

If the texture is not of type 2D

Load(Device, string, TextureFlags, ResourceUsage)

Loads a 2D texture from a stream.

public static Texture2D Load(Device device, string filePath, TextureFlags flags = TextureFlags.ShaderResource, ResourceUsage usage = ResourceUsage.Immutable)

Parameters

device Device

The SharpDX.Direct3D11.Device.

filePath string

The file to load the texture from.

flags TextureFlags

Sets the texture flags (for unordered access...etc.)

usage ResourceUsage

Usage of the resource. Default is SharpDX.Direct3D11.ResourceUsage.Immutable

Returns

Texture2D

A texture

Exceptions

ArgumentException

If the texture is not of type 2D

New(Device, Texture2D)

Creates a new texture from a SharpDX.Direct3D11.Texture2D.

public static Texture2D New(Device device, Texture2D texture)

Parameters

device Device

The SharpDX.Direct3D11.Device.

texture Texture2D

The native texture SharpDX.Direct3D11.Texture2D.

Returns

Texture2D

A new instance of Texture2D class.

New(Device, Texture2DDescription)

Creates a new texture from a SharpDX.Direct3D11.Texture2DDescription.

public static Texture2D New(Device device, Texture2DDescription description)

Parameters

device Device

The SharpDX.Direct3D11.Device.

description Texture2DDescription

The description.

Returns

Texture2D

A new instance of Texture2D class.

New(Device, Image, TextureFlags, ResourceUsage)

Creates a new Texture2D directly from an Image.

public static Texture2D New(Device device, Image image, TextureFlags flags = TextureFlags.ShaderResource, ResourceUsage usage = ResourceUsage.Immutable)

Parameters

device Device

The SharpDX.Direct3D11.Device.

image Image

An image in CPU memory.

flags TextureFlags

Sets the texture flags (for unordered access...etc.)

usage ResourceUsage

The usage.

Returns

Texture2D

A new instance of Texture2D class.

New(Device, int, int, MipMapCount, PixelFormat, DataBox[], TextureFlags, int, ResourceUsage)

Creates a new Texture2D.

public static Texture2D New(Device device, int width, int height, MipMapCount mipCount, PixelFormat format, DataBox[] textureData, TextureFlags flags = TextureFlags.ShaderResource, int arraySize = 1, ResourceUsage usage = ResourceUsage.Default)

Parameters

device Device

The SharpDX.Direct3D11.Device.

width int

The width.

height int

The height.

mipCount MipMapCount

Number of mipmaps, set to true to have all mipmaps, set to an int >=1 for a particular mipmap count.

format PixelFormat

Describes the format to use.

textureData DataBox[]

Texture data through an array of SharpDX.DataBox

flags TextureFlags

Sets the texture flags (for unordered access...etc.)

arraySize int

Size of the texture 2D array, default to 1.

usage ResourceUsage

The usage.

Returns

Texture2D

A new instance of Texture2D class.

New(Device, int, int, MipMapCount, PixelFormat, TextureFlags, int, ResourceUsage)

Creates a new Texture2D.

public static Texture2D New(Device device, int width, int height, MipMapCount mipCount, PixelFormat format, TextureFlags flags = TextureFlags.ShaderResource, int arraySize = 1, ResourceUsage usage = ResourceUsage.Default)

Parameters

device Device

The SharpDX.Direct3D11.Device.

width int

The width.

height int

The height.

mipCount MipMapCount

Number of mipmaps, set to true to have all mipmaps, set to an int >=1 for a particular mipmap count.

format PixelFormat

Describes the format to use.

flags TextureFlags

Sets the texture flags (for unordered access...etc.)

arraySize int

Size of the texture 2D array, default to 1.

usage ResourceUsage

The usage.

Returns

Texture2D

A new instance of Texture2D class.

New(Device, int, int, PixelFormat, TextureFlags, int, ResourceUsage)

Creates a new Texture2D with a single mipmap.

public static Texture2D New(Device device, int width, int height, PixelFormat format, TextureFlags flags = TextureFlags.ShaderResource, int arraySize = 1, ResourceUsage usage = ResourceUsage.Default)

Parameters

device Device

The SharpDX.Direct3D11.Device.

width int

The width.

height int

The height.

format PixelFormat

Describes the format to use.

flags TextureFlags

Sets the texture flags (for unordered access...etc.)

arraySize int

Size of the texture 2D array, default to 1.

usage ResourceUsage

The usage.

Returns

Texture2D

A new instance of Texture2D class.

New<T>(Device, int, int, PixelFormat, T[], TextureFlags, ResourceUsage)

Creates a new Texture2D with a single level of mipmap.

public static Texture2D New<T>(Device device, int width, int height, PixelFormat format, T[] textureData, TextureFlags flags = TextureFlags.ShaderResource, ResourceUsage usage = ResourceUsage.Immutable) where T : unmanaged

Parameters

device Device

The SharpDX.Direct3D11.Device.

width int

The width.

height int

The height.

format PixelFormat

Describes the format to use.

textureData T[]

The texture data for a single mipmap and a single array slice. See remarks

flags TextureFlags

Sets the texture flags (for unordered access...etc.)

usage ResourceUsage

The usage.

Returns

Texture2D

A new instance of Texture2D class.

Type Parameters

T

Type of the pixel data to upload to the texture.

Remarks

Each value in textureData is a pixel in the destination texture.

Operators

implicit operator Resource?(Texture2D)

Implicit casting operator to SharpDX.Direct3D11.Resource

public static implicit operator Resource?(Texture2D from)

Parameters

from Texture2D

The GraphicsResource to convert from.

Returns

Resource