//开启光照,默认为开启状态 Device->SetRenderState(D3DRS_LIGHTING, true); //创建材质,设置材质 D3DMATERIAL9 mtrl; mtrl.Ambient = d3d::WHITE; mtrl.Diffuse = d3d::WHITE; mtrl.Specular = d3d::WHITE; mtrl.Emissive = d3d::BLACK; mtrl.Power = 5.0f; Device->SetMaterial(&mtrl); //创建光照 D3DLIGHT9 dir; ::ZeroMemory(&dir, sizeof(dir)); dir.Type = D3DLIGHT_DIRECTIONAL; dir.Diffuse = d3d::WHITE; dir.Specular = d3d::WHITE * 0.6f; dir.Ambient = d3d::WHITE * 0.3f; dir.Direction = D3DXVECTOR3(1.0f, 0.0f, 0.0f); //注册光源,开启光源 Device->SetLight(0, &dir); Device->LightEnable(0, true); //开启镜面光效果,开启规格化法向量 Device->SetRenderState(D3DRS_NORMALIZENORMALS, true); Device->SetRenderState(D3DRS_SPECULARENABLE, true);