Platform SDK: DirectX

Setting Transformations

[C++]

In C++, transformations are applied by using the IDirect3DDevice7::SetTransform method. For example, you can use code like the following to set the view transformation.

    HRESULT hr
    D3DMATRIX  view;
     
    // Fill in the view matrix. 
     
    hr = lpDev->SetTransform(D3DTRANSFORMSTATE_VIEW, &view);
 
    if(FAILED(hr)){
        // Code to handle the error goes here.
    }

There are several possible settings for the first parameter in a call to IDirect3DDevice7::SetTransform. The most common are D3DTRANSFORMSTATE_WORLD, D3DTRANSFORMSTATE_VIEW, and D3DTRANSFORMSTATE_PROJECTION. These transformation states are defined in the D3DTRANSFORMSTATETYPE enumerated type. This enumeration also contains values to set transformations to be applied to texture coordinates: the D3DTRANSFORMSTATE_TEXTURE1 through D3DTRANSFORMSTATE_TEXTURE7 states.

[Visual Basic]

In Visual Basic, transformations are applied by using the Direct3DDevice7.SetTransform method. For example, you could use code like the following to set the view transformation.

    On Local Error Resume Next
    Dim view As D3DMATRIX
     
    ' Fill in the view matrix.
    Call d3dDev.SetTransform(D3DTRANSFORMSTATE_VIEW, view)
 
    If Err.Number <> DD_OK Then
        ' Code to handle the error goes here.
    End If

There are several possible settings for the first parameter in a call to Direct3DDevice7.SetTransform. The most common are D3DTRANSFORMSTATE_WORLD, D3DTRANSFORMSTATE_VIEW, and D3DTRANSFORMSTATE_PROJECTION. These transformation states are defined in the CONST_D3DTRANSFORMSTATETYPE enumeration. This enumeration also contains values to set transformations to be applied to texture coordinates: the D3DTRANSFORMSTATE_TEXTURE1 through D3DTRANSFORMSTATE_TEXTURE7 states.