An Introduction to Lighting in Direct3D
with Examples in C++ |
Prof. David Bernstein
|
Computer Science Department |
bernstdh@jmu.edu |
struct
:
D3DXVECTOR3
struct CUSTOMVERTEX
{
D3DXVECTOR3 position;
D3DXVECTOR3 normal;
};
D3DFVF_NORMAL
D3DMATERIAL9
:
typedef struct D3DMATERIAL9
{
D3DCOLORVALUE diffuse;
D3DCOLORVALUE ambient;
D3DCOLORVALUE specular;
D3DCOLORVALUE emissive;
float exponent;
}
D3DCOLORVALUE
:
typedef struct D3DCOLORVALUE
{
float r;
float g;
float b;
float alpha;
}
D3DLIGHT9
:
typedef struct D3DLIGHT9
{
D3DLIGHTTYPE type;
D3DCOLORVALUE diffuse;
D3DCOLORVALUE specular;
D3DCOLORVALUE ambient;
D3DVECTOR position;
D3DVECTOR direction;
float range;
float falloff;
float attenuation0;
float attenuation1;
float attenuation2;
float theta;
float phi;
}
HRESULT IDirect3DDevice9::SetRenderState(D3DRENDERSTATETYPE name, DWORD value);
D3DRS_AMBIENT
HRESULT IDirect3DDevice9::SetRenderState(D3DRENDERSTATETYPE type, DWORD value)
type
is D3DRS_LIGHTING
and the value
is TRUE
HRESULT IDirect3DDevice9::LightEnable(DWORD index, BOOL enable)
index
is the ID of the lightenable
is TRUE
or FALSE