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

public TextureCollection Textures { get; }

Property Value

The texture collection.

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.
At draw time, a texture cannot be simultaneously set as a render target and a texture at a stage.

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);

Xbox 360, Windows 7, Windows Vista, Windows XP

Community Additions