GraphicsDevice.Textures Property

Returns the collection of textures that have been assigned to the texture stages of the device.

Namespace: Microsoft.Xna.Framework.Graphics
Assembly: Microsoft.Xna.Framework.Graphics (in microsoft.xna.framework.graphics.dll)

Syntax

public TextureCollection Textures { get; }

Property Value

The texture collection.

Remarks

The collection of texture stage on the device contains one or more textures (all of the same type and dimensions) that can be accessed by shaders.

Note

At draw time, a texture cannot be simultaneously set as a render target and a texture at a stage.

Example

This C# code demonstrates the setting two elements of the Textures collection to two user-created Texture2D objects named firstTexture and secondTexture.

graphics.GraphicsDevice.Textures[0] = firstTexture;
graphics.GraphicsDevice.Textures[1] = secondTexture;
      

In the effect file, these textures can be accessed by declaring two sampler variables and setting them to the sampler register numbers that correspond to the index in the texture collection.

sampler firstSampler : register(s0);
sampler secondSampler : register(s1);
      

See Also

Reference

GraphicsDevice Class
GraphicsDevice Members
Microsoft.Xna.Framework.Graphics Namespace

Platforms

Xbox 360, Windows 7, Windows Vista, Windows XP