Game Development Reference
In-Depth Information
}
if(FAILED(hr))
{
::MessageBox(0, "D3DXCompileShaderFromFile() - FAILED", 0, 0);
return false;
}
//
// Create shader
//
hr = Device->CreateVertexShader(
(DWORD*)shader->GetBufferPointer(),
&DiffuseShader);
if(FAILED(hr))
{
::MessageBox(0, "CreateVertexShader - FAILED", 0, 0);
return false;
}
d3d::Release<ID3DXBuffer*>(shader);
//
// Get Handles
//
ViewMatrixHandle = DiffuseConstTable->GetConstantByName(
0, "ViewMatrix");
ViewProjMatrixHandle = DiffuseConstTable->GetConstantByName(
0, "ViewProjMatrix");
AmbientMtrlHandle = DiffuseConstTable->GetConstantByName(
0, "AmbientMtrl");
DiffuseMtrlHandle = DiffuseConstTable->GetConstantByName(
0, "DiffuseMtrl");
LightDirHandle
= DiffuseConstTable->GetConstantByName(
0, "LightDirection");
//
// Set shader constants:
//
// Light direction:
D3DXVECTOR4 directionToLight(-0.57f, 0.57f, -0.57f, 0.0f);
DiffuseConstTable->SetVector(Device, LightDirHandle,
&directionToLight);
// Materials:
D3DXVECTOR4 ambientMtrl(0.0f, 0.0f, 1.0f, 1.0f);
D3DXVECTOR4 diffuseMtrl(0.0f, 0.0f, 1.0f, 1.0f);
DiffuseConstTable->SetVector(Device,AmbientMtrlHandle,&ambientMtrl);
DiffuseConstTable->SetVector(Device,DiffuseMtrlHandle,&diffuseMtrl);
DiffuseConstTable->SetDefaults(Device);
Search WWH ::




Custom Search