TextureLoader.FillTexture(Texture,Fill2DTextureCallback) Method (Microsoft.DirectX.Direct3D)

Uses a user-provided function or a compiled high-level shader language (HLSL) function to fill each texel of each mip level of a given texture.

Definition

Visual Basic Public Shared Sub FillTexture( _
    ByVal texture As Texture, _
    ByVal callbackFunction As Fill2DTextureCallback _
)
C# public static void FillTexture(
    Texture texture,
    Fill2DTextureCallback callbackFunction
);
C++ public:
static void FillTexture(
    Texturetexture,
    Fill2DTextureCallbackcallbackFunction
);
JScript public static function FillTexture(
    texture : Texture,
    callbackFunction : Fill2DTextureCallback
);

Parameters

texture Microsoft.DirectX.Direct3D.Texture
A Texture object that represents the filled texture.
callbackFunction Microsoft.DirectX.Direct3D.Fill2DTextureCallback
User-provided Fill2DTextureCallback delegate that is used to compute the value of each texel.

Remarks

If the param_GraphicsStream_compiledCode parameter is used, the HLSL function must contain the following semantics:

  • One input parameter must use a POSITION semantic.
  • One input parameter must use a PSIZE semantic.
  • The function must return a parameter that uses the COLOR semantic.

The following is a C# code example of such an HLSL function:

[C#]float4 TextureGradientFill(
  float2 vTexCoord : POSITION, 
  float2 vTexelSize : PSIZE) : COLOR 
  {
    float r,g, b, xSq,ySq, a;
    xSq = 2.f*vTexCoord.x-1.f; xSq *= xSq;
    ySq = 2.f*vTexCoord.y-1.f; ySq *= ySq;
    a = sqrt(xSq+ySq);
    if (a > 1.0f) {
        a = 1.0f-(a-1.0f);
    }
    else if (a < 0.2f) {
        a = 0.2f;
    }
    r = 1-vTexCoord.x;
    g = 1-vTexCoord.y;
    b = vTexCoord.x;
    return float4(r, g, b, a);

  };

Note that the input parameters can be in any order, but both input semantics must be represented.

Exceptions

InvalidCallException

The method call is invalid. For example, a method's parameter might contain an invalid value.

NotAvailableException

This device does not support the queried technique.