DirectX SDK

Enabling Texture Coordinate Transformations

[C++]

The D3DTSS_TEXTURETRANSFORMFLAGS texture stage state controls the application of texture coordinate transformations. Values for this texture stage state are defined by the D3DTEXTURETRANSFORMFLAGS enumerated type.

Texture coordinate transformations are disabled when D3DTSS_TEXTURETRANSFORMFLAGS is set to D3DTTFF_DISABLE (the default value). Assuming that texture coordinate transformations were enabled for stage 0, the following code disables them:

// For this example, the lpd3dDevice variable contains a 
// valid pointer to an IDirect3DDevice7 interface.

lpd3dDevice->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE);

The other values defined in D3DTEXTURETRANSFORMFLAGS are used to enable texture coordinate transformations, and to control how many of the resulting texture coordinate elements are to be passed to the rasterizer. For example, take the following code:

// For this example, the lpd3dDevice variable contains a 
// valid pointer to an IDirect3DDevice7 interface.

lpd3dDevice->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2);

The D3DTTFF_COUNT2 value instructs the system to apply the transformation matrix set for texture stage 0, then pass the first two elements of the modified texture coordinates to the rasterizer.

The D3DTTFF_PROJECTED texture transformation flag indicates coordinates for a projected texture. When this flag is specified, the rasterizer divides the elements passed-in by the last element. Take the following code, for example:

// For this example, the lpd3dDevice variable contains a 
// valid pointer to an IDirect3DDevice7 interface.

lpd3dDevice->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, 
                                   D3DTTFF_COUNT3 | D3DTTFF_PROJECTED );

The preceding code informs the system to pass three texture coordinate elements to the rasterizer, and the rasterizer is to divide first two elements by the third, producing the 2-D texture coordinates needed to address the texture.

[Visual Basic]

The D3DTSS_TEXTURETRANSFORMFLAGS texture stage state controls the application of texture coordinate transformations. Values for this texture stage state are defined by the CONST_D3DTEXTURETRANSFORMFLAGS enumeration.

Texture coordinate transformations are disabled when D3DTSS_TEXTURETRANSFORMFLAGS is set to D3DTTFF_DISABLE (the default value). Assuming that texture coordinate transformations were enabled for stage 0, the following code disables them:

' For this example, the d3dDevice variable contains a
' valid reference to a Direct3DDevice7 object

Call d3dDevice.SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, _
                                    D3DTTFF_DISABLE)

The other values defined in CONST_D3DTEXTURETRANSFORMFLAGS are used to enable texture coordinate transformations, and to control how many of the resulting texture coordinate elements are to be passed to the rasterizer. For example, take the following code:

' For this example, the d3dDevice variable contains a 
' valid reference to a Direct3DDevice7 object.

Call d3dDevice.SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, _ 
                                    D3DTTFF_COUNT2)

The D3DTTFF_COUNT2 value instructs the system to apply the transformation matrix set for texture stage 0, then pass the first two elements of the modified texture coordinates to the rasterizer.

The D3DTTFF_PROJECTED texture transformation flag indicates coordinates for a projected texture. When this flag is specified, the rasterizer divides the elements passed-in by the last element. Take the following code, for example:

' For this example, the d3dDevice variable contains a 
' valid pointer to an IDirect3DDevice7 interface.

Call d3dDevice.SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, _ 
                                    D3DTTFF_COUNT3 | D3DTTFF_PROJECTED)

The preceding code informs the system to pass three texture coordinate elements to the rasterizer, and the rasterizer is to divide first two elements by the third, producing the 2-D texture coordinates needed to address the texture.