| Platform SDK: DirectX |
Direct3D allows one shading mode to be selected at a time. By default, Gouraud shading is selected. In C++, the shading mode can be changed by calling the IDirect3DDevice7::SetRenderState method. Set the dwRenderStateType parameter 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 shading mode of a Direct3D application can be set to flat or Gouraud shading mode.
// Set to flat shading.
// This code fragment assumes that lpDev is a valid pointer to
// an IDirect3DDevice7 interface.
hr = lpDev->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 = lpDev->SetRenderState(D3DRENDERSTATE_SHADEMODE,
D3DSHADE_GOURAUD);
if(FAILED(hr))
{
// Code to handle the error goes here.
}
Direct3D allows one shading mode to be selected at a time. By default, Gouraud shading is selected. In Visual Basic, the shading mode can be changed by calling the Direct3DDevice7.SetRenderState method. Set the state parameter to D3DRENDERSTATE_SHADEMODE. The renderstate parameter must be set to a member of the CONST_D3DSHADEMODE enumeration. The following code fragment illustrates how the current shading mode of a Direct3D application can be set to flat or Gouraud shading mode.
' Set to flat shading.
' This code fragment assumes that d3dDev is a valid reference to
' a Direct3DDevice7 object.
On Local Error Resume Next
Call d3dDev.SetRenderState(D3DRENDERSTATE_SHADEMODE, _
D3DSHADE_FLAT)
' Check for an error.
If Err.Number <> DD_OK Then
' Handle the error.
End If
' Set to Gouraud shading (this is the default for Direct3D).
Call d3dDev.SetRenderState(D3DRENDERSTATE_SHADEMODE, _
D3DSHADE_GOURAUD)
If Err.Number <> DD_OK Then
' Handle the error.
End If