设置 Direct3D 9 (着色模式)

Direct3D 允许一次选择一种着色模式。 默认情况下,已选择“Gouraud 着色”。 在 C++ 中,可以通过调用 IDirect3DDevice9::SetRenderState 方法更改着色模式。 将 State 参数设置为 D3DRS_SHADEMODE。 State 参数必须设置为 D3DSHADEMODE 枚举的成员。 以下示例代码示例演示了如何将 Direct3D 应用程序的当前着色模式设置为平面着色模式或 Gouraud 着色模式。

// Set to flat shading.
// This code example assumes that pDev is a valid pointer to 
// an IDirect3DDevice9 interface.
hr = pDev->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_FLAT);
if(FAILED(hr))
{
    // Code to handle the error goes here.
}

// Set to Gouraud shading. This is the default for Direct3D.
hr = pDev->SetRenderState(D3DRS_SHADEMODE,
                            D3DSHADE_GOURAUD);
if(FAILED(hr))
{
    // Code to handle the error goes here.
}

明暗度