Game Development Reference
In-Depth Information
::MessageBox(0, "D3DXCreateEffectFromFile() - FAILED", 0, 0);
return false;
}
//
// Save Frequently Accessed Parameter Handles
//
WorldMatrixHandle=LightTexEffect->GetParameterByName(0,
"WorldMatrix");
ViewMatrixHandle =LightTexEffect->GetParameterByName(0, "ViewMatrix");
ProjMatrixHandle =LightTexEffect->GetParameterByName(0, "ProjMatrix");
TexHandle
=LightTexEffect->GetParameterByName(0, "Tex");
LightTexTechHandle =
LightTexEffect->GetTechniqueByName("LightAndTexture");
//
// Set effect parameters
//
// Matrices
D3DXMATRIX W, P;
D3DXMatrixIdentity(&W);
LightTexEffect->SetMatrix( WorldMatrixHandle, &W);
D3DXMatrixPerspectiveFovLH(
&P, D3DX_PI * 0.25f, // 45 - degree
(float)Width / (float)Height,
1.0f, 1000.0f);
LightTexEffect->SetMatrix( ProjMatrixHandle, &P);
// Texture:
IDirect3DTexture9* tex = 0;
D3DXCreateTextureFromFile(Device, "Terrain_3x_diffcol.jpg", &tex);
LightTexEffect->SetTexture(TexHandle, tex);
d3d::Release<IDirect3DTexture9*>(tex);
return true;
}
The Display function is straightforward and performs the steps out-
lined in section 19.6:
bool Display(float timeDelta)
{
if( Device )
{
//
// ...[Camera update snipped]
//
// set the new updated view matrix
Search WWH ::




Custom Search