The following illustration shows a common creation path of a material in Direct3D.
You create a material by calling the IDirect3D3::CreateMaterial method. The first parameter is the address of the variable that will contain a valid IDirect3DMaterial3 interface pointer if the call succeeds. The method's second parameter is unused and should be set to NULL. The following example shows how this call can be made:
//
// The g_lpD3D variable is a global variable that
// contains a pointer to an IDirect3D3 interface.
//
LPDIRECT3DMATERIAL3 lpMat3;
HRESULT hr;
hr = g_lpD3D->CreateMaterial(&lpMat3, NULL);
if(SUCCEEDED(hr))
{
// Set the material properties.
}
Before using the material, you must set its properties. For more information, see Setting Material Properties.