DirectX SDK

Retrieving Material Properties

[C++]

You retrieve the material properties that the rendering device is currently using by calling the IDirect3DDevice7::GetMaterial method for the device. Unlike the IDirect3DDevice7::SetMaterial method, GetMaterial doesn't require preparation. The GetMaterial method accepts the address of a D3DMATERIAL7 structure, and fills the provided structure with information describing the current material properties before returning.

    // For this example, the lpd3dDev variable is assumed to 
    // be a valid pointer to an IDirect3DDevice7 interface.
    HRESULT hr;
    D3DMATERIAL7 mat;

    hr = lpd3dDev->GetMaterial(&mat);
    if(FAILED(hr))
    {
// Code to handle the error goes here.
    }
[Visual Basic]

You retrieve the material properties that the rendering device is currently using by calling the Direct3DDevice7.GetMaterial method for the device. Unlike the Direct3DDevice7.SetMaterial method, GetMaterial doesn't require preparation. The GetMaterial method accepts a variable of type D3DMATERIAL7, and fills it with information describing the current material properties before returning.

    ' For this example, the d3dDev variable is assumed to
    ' contain a valid reference to a Direct3DDevice7 object.
    On Local Error Resume Next
    Dim mat As D3DMATERIAL7

    Call d3dDev.GetMaterial(mat)
    If Err.Number <> DD_OK Then
' Code to handle the error goes here.
    End If