Platform SDK: DirectX

Using Texture Wrapping

[C++]

In a C++ application, the process of enabling texture wrapping differs across versions the Direct3D device interfaces. If your application uses the IDirect3DDevice7 interface, you enable texture wrapping for texture coordinate sets used by vertices, not for the texture stages themselves. In this case, call the IDirect3DDevice7::SetRenderState method to enable texture wrapping, passing one of the D3DRENDERSTATE_WRAP0 through D3DRENDERSTATE_WRAP7 enumerated values as the first parameter to identify which texture coordinate set will receive wrapping. Specify the D3DWRAPCOORD_0 through D3DWRAPCOORD_3 flags in the second parameter to enable texture wrapping in the corresponding direction, or combine them to enable wrapping in multiple directions. If you omit a flag, texture wrapping in the corresponding direction is disabled. To disable texture wrapping for a particular set of texture coordinates, set the value for the corresponding render state to 0.

If your application uses the legacy IDirect3DDevice2 interface, you still enable texture wrapping by calling the SetRenderState method; however, these interface versions do not support D3DRENDERSTATE_WRAP0 through D3DRENDERSTATE_WRAP7. Instead, use the D3DRENDERSTATE_WRAPU or D3DRENDERSTATE_WRAPV value in the first parameter. Specify TRUE as in the second parameter to enable wrapping, or FALSE to disable it.

Note  The IDirect3DDevice7 interface does recognize the legacy D3DRENDERSTATE_WRAPU and D3DRENDERSTATE_WRAPV render states, even though they were superseded by D3DRENDERSTATE_WRAP0 through D3DRENDERSTATE_WRAP7. These older render states, when passed to the IDirect3DDevice7 version of SetRenderState, affect u- and v-texture wrapping for the first set of texture coordinates.

[Visual Basic]

In Visual Basic, you enable texture wrapping for texture coordinate sets used by vertices. Call the Direct3DDevice7.SetRenderState method to enable texture wrapping, passing one of the D3DRENDERSTATE_WRAP0 through D3DRENDERSTATE_WRAP7 enumerated values as the first parameter to identify which texture coordinate set will receive wrapping. Use the D3DWRAPCOORD_0 through D3DWRAPCOORD_3 flags (from the CONST_D3D enumeration) in the second parameter to enable texture wrapping in the corresponding direction, or use combinations to enable wrapping in multiple directions. If you omit a flag, texture wrapping in the corresponding direction is disabled. To disable texture wrapping for a particular set of texture coordinates, set the value for the corresponding render state to 0.