本文整理汇总了C++中IDirect3DDevice9::SetMaterial方法的典型用法代码示例。如果您正苦于以下问题:C++ IDirect3DDevice9::SetMaterial方法的具体用法?C++ IDirect3DDevice9::SetMaterial怎么用?C++ IDirect3DDevice9::SetMaterial使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDirect3DDevice9
的用法示例。
在下文中一共展示了IDirect3DDevice9::SetMaterial方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: vEyePt
bool CScreen::SetDefaultGraphicsSettings3D()
{
HRESULT hr;
D3DXMATRIX identityTransform, projTransform;
D3DXMatrixIdentity(&identityTransform);
D3DXMatrixPerspectiveFovLH(&projTransform, D3DX_PI / 4, 1.0f, 1.0f, 100.0f);
D3DXVECTOR3 vEyePt(-10.0f, -10.0f, 10.0f);
D3DXVECTOR3 vLookatPt(0.0f, 0.0f, 0.0f);
D3DXVECTOR3 vUpVec(0.0f, 0.0f, 1.0f);
D3DXMATRIXA16 matView;
D3DXMatrixLookAtLH(&matView, &vEyePt, &vLookatPt, &vUpVec);
D3DCOLORVALUE lightColor = {1.0f, 1.0f, 1.0f, 1.0f};
D3DXVECTOR3 lightDir(-1.0f, 0.7f, -0.2f);
D3DLIGHT9 light;
setupDirectionalLight(light, lightColor, lightDir);
D3DMATERIAL9 mtrl;
ZeroMemory( &mtrl, sizeof( D3DMATERIAL9 ) );
mtrl.Diffuse = lightColor;
mtrl.Ambient = lightColor;
mtrl.Ambient.g = 0.0f;
CGraphicsManager *pGraphicsManager = CGraphicsManager::GetInstance();
IDirect3DDevice9 *pDevice = pGraphicsManager->GetDevice();
CCamera * pCamera = CCamera::GetInstance();
hr = pDevice->SetTransform(D3DTS_WORLD, &identityTransform);
if(FAILED(hr))
{
LogErrorHr("Failed to set world transform", hr);
return false;
}
D3DXMATRIX camViewMat = pCamera->GetViewMatrix();
hr = pDevice->SetTransform(D3DTS_VIEW, &camViewMat);
if(FAILED(hr))
{
LogErrorHr("Failed to set view transform", hr);
return false;
}
D3DXMATRIX camProjMat = pCamera->GetProjectionMatrix();
hr = pDevice->SetTransform(D3DTS_PROJECTION, &camProjMat);
if(FAILED(hr))
{
LogErrorHr("Failed to set projection transform", hr);
return false;
}
hr = pDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
if(FAILED(hr))
{
LogErrorHr("Failed to set cull mode render state", hr);
return false;
}
hr = pDevice->SetLight(0, &light);
if(FAILED(hr))
{
LogErrorHr("Failed to set light 0", hr);
return false;
}
hr = pDevice->SetMaterial(&mtrl);
if(FAILED(hr))
{
LogErrorHr("Failed to set material", hr);
return false;
}
hr = pDevice->LightEnable(0, TRUE);
if(FAILED(hr))
{
LogErrorHr("Failed to enable light", hr);
return false;
}
hr = pDevice->SetRenderState(D3DRS_AMBIENT, 0x00202020);
if(FAILED(hr))
{
LogErrorHr("Failed to set ambient color", hr);
return false;
}
hr = pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
if(FAILED(hr))
{
LogErrorHr("Failed to enable z", hr);
return false;
}
hr = pDevice->SetRenderState(D3DRS_ZWRITEENABLE , TRUE);
if(FAILED(hr))
{
LogErrorHr("Failed to set z write enabled", hr);
return false;
//.........这里部分代码省略.........