Setting the Shade Mode

Direct3D allows one shade mode to be selected at a time. By default, Gouraud shading is selected. The shade mode can be changed by calling the IDirect3DDevice3::SetRenderState method. The dwRenderStateType parameter should be set to D3DRENDERSTATE_SHADEMODE. The dwRenderState parameter must be set to a member of the D3DSHADEMODE enumeration. The following sample code fragments illustrate how the current shade mode of a Direct3D application can be set to flat or Gouraud shading mode.

// Set to flat shading.
// This code fragment assumes that lpDev3 is a valid pointer to 
// an IDirect3DDevice3 interface.
hr = lpDev3->SetRenderState(D3DRENDERSTATE_SHADEMODE, D3DSHADE_FLAT);
if(FAILED(hr))
{
    // Code to handle the error goes here.
}
 
// Set to Gouraud shading (this is the default for Direct3D).
hr = lpDev3->SetRenderState(D3DRENDERSTATE_SHADEMODE,
                            D3DSHADE_GOURAUD);
if(FAILED(hr))
{
    // Code to handle the error goes here.
}