Lighting with TnL
Cheers,
Martin
Also I believe that a material has to be set to even enable D3D lighting.
The function below takes a material struct that defines the ambient,diffuse,specular and power vales creates a material and returns a handle - minus any type of error checking.
D3DMATERIALHANDLE CreateMaterial(LPDIRECT3DDEVICE3 lpD3DDevice3,D3DMATERIAL Material)
{
LPDIRECT3D3 lpDirect3D3;
LPDIRECT3DMATERIAL3 lpMaterial3;
lpD3DDevice3->GetDirect3D(&lpDirect3D3);
lpDirect3D3 -> CreateMaterial(lpMaterial3, NULL);
lpMaterial3->SetMaterial(&Material);
lpMaterial3->GetHandle(lpD3DDevice3,&MatHandle);
return MatHandle;
}
The way I have it set up is that every texture on every model has its own material. Then just before I call DrawPrim on a object (or section of an object - if it has multiple textures) I set the material and texture.
This is how to set the material:
lpD3DDevice3->SetLightState(D3DLIGHTSTATE_MATERIAL,Object_MatHandle);
In the end though…D3D lighting only looks good with a high poly count scene.
Good Luck!
"You know you're obsessed with computer graphics when you're outside and you look up at the trees and think, "Wow! That's spectacular resolution!""