Class Texture3D
Represents a 3D volume of texels.
public class Texture3D : Texture, IDisposable
- Inheritance
-
Texture3D
- Implements
- Inherited Members
Remarks
A texel represents the smallest unit of a texture that can be read from or written to by the GPU. A texel is composed of 1 to 4 components. Specifically, a texel may be any one of the available texture formats represented in the SurfaceFormat enumeration.
A Texture3D resource (also known as a volume texture) contains a 3D volume of texels. Since it is a texture resource, it may contain mipmap levels.
When a Texture3D mipmap slice is bound as a render target output (by creating a RenderTargetCube), the Texture3D behaves identically to an array of Texture2D objects with n array slices, where n is the depth (third dimension) of the Texture3D.
Constructors
Texture3D(GraphicsDevice, int, int, int, bool, SurfaceFormat)
Creates an uninitialized Texture3D resource with the specified parameters.
public Texture3D(GraphicsDevice graphicsDevice, int width, int height, int depth, bool mipMap, SurfaceFormat format)
Parameters
graphicsDeviceGraphicsDeviceThe graphics device used to display the texture.
widthintThe width, in pixels, of the texture.
heightintThe height, in pixels, of the texture.
depthintThe depth, in pixels, of the texture.
mipMapbooltrue if mimapping is enabled for the texture; otherwise, false.
formatSurfaceFormatThe surface format of the texture.
Remarks
To initialize the texture with data after creating, you can use one of the SetData methods.
To initialize a Texture3D from an existing file use the ContentManager.Load method if loading a pipeline preprocessed Texture3D from an .xnb file.
Exceptions
- ArgumentNullException
The
graphicsDeviceparameter is null.- ArgumentOutOfRangeException
The
width,height, and/ordepthparameters are less than or equal to zero.
Texture3D(GraphicsDevice, int, int, int, bool, SurfaceFormat, bool)
protected Texture3D(GraphicsDevice graphicsDevice, int width, int height, int depth, bool mipMap, SurfaceFormat format, bool renderTarget)
Parameters
graphicsDeviceGraphicsDevicewidthintheightintdepthintmipMapboolformatSurfaceFormatrenderTargetbool
Properties
Depth
Gets the depth, in pixels, of this texture resource.
public int Depth { get; }
Property Value
Height
Gets the height, in pixels, of this texture resource.
public int Height { get; }
Property Value
Width
Gets the width, in pixels, of this texture resource.
public int Width { get; }
Property Value
Methods
GetData<T>(int, int, int, int, int, int, int, T[], int, int)
Copies texture data into an array.
public void GetData<T>(int level, int left, int top, int right, int bottom, int front, int back, T[] data, int startIndex, int elementCount) where T : struct
Parameters
levelintThe mipmap level where the data will be placed.
leftintPosition of the left side of the box on the x-axis.
topintPosition of the top of the box on the y-axis.
rightintPosition of the right side of the box on the x-axis.
bottomintPosition of the bottom of the box on the y-axis.
frontintPosition of the front of the box on the z-axis.
backintPosition of the back of the box on the z-axis.
dataT[]The array of data to copy.
startIndexintThe index of the element in the array at which to start copying.
elementCountintThe number of elements to copy.
Type Parameters
TThe type of the elements in the array.
Exceptions
- ArgumentException
One of the following conditions is true:
-
The
levelparameter is larger than the number of levels in this texture. -
The
Ttype size is invalid for the format of this texture. -
The
startIndexparameter is less than zero or is greater than or equal to the length of the data array. -
The
dataarray parameter is too small. -
The
left,top,back, and/orrightparameters are less than zero. -
The
rightparameter is greater than the width of the texture. -
The
bottomparameter is greater than the height of the texture. -
The
topparameter is greater than the depth of the texture. -
The
elementCountparameter is the incorrect size.
-
The
- ArgumentNullException
The
dataparameter is null.
GetData<T>(T[])
Copies texture data into an array.
public void GetData<T>(T[] data) where T : struct
Parameters
dataT[]The array of data to copy.
Type Parameters
TThe type of the elements in the array.
Exceptions
- ArgumentException
One of the following conditions is true:
-
The
Ttype size is invalid for the format of this texture. -
The
dataarray parameter is too small.
-
The
- ArgumentNullException
The
dataparameter is null.
GetData<T>(T[], int, int)
Copies texture data into an array.
public void GetData<T>(T[] data, int startIndex, int elementCount) where T : struct
Parameters
dataT[]The array of data to copy.
startIndexintThe index of the element in the array at which to start copying.
elementCountintThe number of elements to copy.
Type Parameters
TThe type of the elements in the array.
Exceptions
- ArgumentException
One of the following conditions is true:
-
The
Ttype size is invalid for the format of this texture. -
The
startIndexparameter is less than zero or is greater than or equal to the length of the data array. -
The
dataarray parameter is too small. -
The
elementCountparameter is the incorrect size.
-
The
- ArgumentNullException
The
dataparameter is null.
SetData<T>(int, int, int, int, int, int, int, T[], int, int)
Copies an array of data to the texture.
public void SetData<T>(int level, int left, int top, int right, int bottom, int front, int back, T[] data, int startIndex, int elementCount) where T : struct
Parameters
levelintThe mipmap level where the data will be placed.
leftintPosition of the left side of the box on the x-axis.
topintPosition of the top of the box on the y-axis.
rightintPosition of the right side of the box on the x-axis.
bottomintPosition of the bottom of the box on the y-axis.
frontintPosition of the front of the box on the z-axis.
backintPosition of the back of the box on the z-axis.
dataT[]The array of data to copy.
startIndexintThe index of the element in the array at which to start copying.
elementCountintThe number of elements to copy.
Type Parameters
TThe type of the elements in the array.
Exceptions
- ArgumentException
One of the following conditions is true:
-
The
levelparameter is larger than the number of levels in this texture. -
The
Ttype size is invalid for the format of this texture. -
The
startIndexparameter is less than zero or is greater than or equal to the length of the data array. -
The
dataarray parameter is too small. -
The
left,top,back, and/orrightparameters are less than zero. -
The
rightparameter is greater than the width of the texture. -
The
bottomparameter is greater than the height of the texture. -
The
topparameter is greater than the depth of the texture. -
The
elementCountparameter is the incorrect size.
-
The
- ArgumentNullException
The
dataparameter is null.
SetData<T>(T[])
Copies an array of data to the texture.
public void SetData<T>(T[] data) where T : struct
Parameters
dataT[]The array of data to copy.
Type Parameters
TThe type of the elements in the array.
Exceptions
- ArgumentException
One of the following conditions is true:
-
The
Ttype size is invalid for the format of this texture. -
The
dataarray parameter is too small.
-
The
- ArgumentNullException
The
dataparameter is null.
SetData<T>(T[], int, int)
Copies an array of data to the texture.
public void SetData<T>(T[] data, int startIndex, int elementCount) where T : struct
Parameters
dataT[]The array of data to copy.
startIndexintThe index of the element in the array at which to start copying.
elementCountintThe number of elements to copy.
Type Parameters
TThe type of the elements in the array.
Exceptions
- ArgumentException
One of the following conditions is true:
-
The
Ttype size is invalid for the format of this texture. -
The
startIndexparameter is less than zero or is greater than or equal to the length of the data array. -
The
dataarray parameter is too small.
-
The
- ArgumentNullException
The
dataparameter is null.