Share via


Border Color Texture Address Mode

The border color texture address mode is identified by the TextureAddress.Border enumerated value. It causes Microsoft Direct3D to use an arbitrary color, known as the border color, for any texture coordinates outside of the range of 0.0 through 1.0, inclusive.

In the following illustration, the application specifies that the texture be applied to the primitive using a red border.

Red border

Applications set the border color by setting the SamplerStateManager object returned in the SamplerStateManagerCollection.SamplerState property, which is retrieved from the Device.SamplerState property. In the following C# code example, the SamplerStateManagerCollection.SamplerState index parameter is set to the desired texture stage identifier, and the SamplerStateManager.BorderColor property is set to the new RGBA border color.

          [C#]
          

// For this example, device is a valid Device object.

using System;
using Microsoft.DirectX.Direct3D;

// Load a texture.
Texture tx = new Texture(device, 4, 4, 0, 0, Format.X8R8G8B8, Pool.Managed);

// Set the texture in stage 0.
device.SetTexture(0, tx);

// Set the address mode for the u-coord.
device.SamplerState[0].AddressU = TextureAddress.Border;

// Set the border color.
device.SamplerState[0].BorderColor = System.Drawing.Color.Blue.ToArgb();

// Get the border color.
int color = device.SamplerState[0].BorderColor;