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
graphicsDevice
GraphicsDeviceThe graphics device used to display the texture.
width
intThe width, in pixels, of the texture.
height
intThe height, in pixels, of the texture.
depth
intThe depth, in pixels, of the texture.
mipMap
booltrue if mimapping is enabled for the texture; otherwise, false.
format
SurfaceFormatThe 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
graphicsDevice
parameter is null.- ArgumentOutOfRangeException
The
width
,height
, and/ordepth
parameters 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
graphicsDevice
GraphicsDevicewidth
intheight
intdepth
intmipMap
boolformat
SurfaceFormatrenderTarget
bool
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
level
intThe mipmap level where the data will be placed.
left
intPosition of the left side of the box on the x-axis.
top
intPosition of the top of the box on the y-axis.
right
intPosition of the right side of the box on the x-axis.
bottom
intPosition of the bottom of the box on the y-axis.
front
intPosition of the front of the box on the z-axis.
back
intPosition of the back of the box on the z-axis.
data
T[]The array of data to copy.
startIndex
intThe index of the element in the array at which to start copying.
elementCount
intThe number of elements to copy.
Type Parameters
T
The type of the elements in the array.
Exceptions
- ArgumentException
One of the following conditions is true:
-
The
level
parameter is larger than the number of levels in this texture. -
The
T
type size is invalid for the format of this texture. -
The
startIndex
parameter is less than zero or is greater than or equal to the length of the data array. -
The
data
array parameter is too small. -
The
left
,top
,back
, and/orright
parameters are less than zero. -
The
right
parameter is greater than the width of the texture. -
The
bottom
parameter is greater than the height of the texture. -
The
top
parameter is greater than the depth of the texture. -
The
elementCount
parameter is the incorrect size.
-
The
- ArgumentNullException
The
data
parameter is null.
GetData<T>(T[])
Copies texture data into an array.
public void GetData<T>(T[] data) where T : struct
Parameters
data
T[]The array of data to copy.
Type Parameters
T
The type of the elements in the array.
Exceptions
- ArgumentException
One of the following conditions is true:
-
The
T
type size is invalid for the format of this texture. -
The
data
array parameter is too small.
-
The
- ArgumentNullException
The
data
parameter 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
data
T[]The array of data to copy.
startIndex
intThe index of the element in the array at which to start copying.
elementCount
intThe number of elements to copy.
Type Parameters
T
The type of the elements in the array.
Exceptions
- ArgumentException
One of the following conditions is true:
-
The
T
type size is invalid for the format of this texture. -
The
startIndex
parameter is less than zero or is greater than or equal to the length of the data array. -
The
data
array parameter is too small. -
The
elementCount
parameter is the incorrect size.
-
The
- ArgumentNullException
The
data
parameter 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
level
intThe mipmap level where the data will be placed.
left
intPosition of the left side of the box on the x-axis.
top
intPosition of the top of the box on the y-axis.
right
intPosition of the right side of the box on the x-axis.
bottom
intPosition of the bottom of the box on the y-axis.
front
intPosition of the front of the box on the z-axis.
back
intPosition of the back of the box on the z-axis.
data
T[]The array of data to copy.
startIndex
intThe index of the element in the array at which to start copying.
elementCount
intThe number of elements to copy.
Type Parameters
T
The type of the elements in the array.
Exceptions
- ArgumentException
One of the following conditions is true:
-
The
level
parameter is larger than the number of levels in this texture. -
The
T
type size is invalid for the format of this texture. -
The
startIndex
parameter is less than zero or is greater than or equal to the length of the data array. -
The
data
array parameter is too small. -
The
left
,top
,back
, and/orright
parameters are less than zero. -
The
right
parameter is greater than the width of the texture. -
The
bottom
parameter is greater than the height of the texture. -
The
top
parameter is greater than the depth of the texture. -
The
elementCount
parameter is the incorrect size.
-
The
- ArgumentNullException
The
data
parameter is null.
SetData<T>(T[])
Copies an array of data to the texture.
public void SetData<T>(T[] data) where T : struct
Parameters
data
T[]The array of data to copy.
Type Parameters
T
The type of the elements in the array.
Exceptions
- ArgumentException
One of the following conditions is true:
-
The
T
type size is invalid for the format of this texture. -
The
data
array parameter is too small.
-
The
- ArgumentNullException
The
data
parameter 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
data
T[]The array of data to copy.
startIndex
intThe index of the element in the array at which to start copying.
elementCount
intThe number of elements to copy.
Type Parameters
T
The type of the elements in the array.
Exceptions
- ArgumentException
One of the following conditions is true:
-
The
T
type size is invalid for the format of this texture. -
The
startIndex
parameter is less than zero or is greater than or equal to the length of the data array. -
The
data
array parameter is too small.
-
The
- ArgumentNullException
The
data
parameter is null.