Releasing the Objects in the Scene

The ReleaseScene function releases all the objects making up the 3-D scene.

static HRESULT

ReleaseScene(void)

{

if (NULL != lpd3dExecuteBuffer)

{

lpd3dExecuteBuffer->lpVtbl->Release(lpd3dExecuteBuffer);

lpd3dExecuteBuffer = NULL;

}

if (NULL != lpd3dBackgroundMaterial)

{

lpd3dBackgroundMaterial->

lpVtbl->Release(lpd3dBackgroundMaterial);

lpd3dBackgroundMaterial = NULL;

}

if (NULL != lpd3dMaterial)

{

lpd3dMaterial->lpVtbl->Release(lpd3dMaterial);

lpd3dMaterial = NULL;

}

if (0 != hd3dWorldMatrix)

{

lpd3dDevice->lpVtbl->DeleteMatrix(lpd3dDevice, hd3dWorldMatrix);

hd3dWorldMatrix = 0;

}

if (0 != hd3dViewMatrix)

{

lpd3dDevice->lpVtbl->DeleteMatrix(lpd3dDevice, hd3dViewMatrix);

hd3dViewMatrix = 0;

}

if (0 != hd3dProjMatrix)

{

lpd3dDevice->lpVtbl->DeleteMatrix(lpd3dDevice, hd3dProjMatrix);

hd3dProjMatrix = 0;

}

if (NULL != lpd3dLight)

{

lpd3dLight->lpVtbl->Release(lpd3dLight);

lpd3dLight = NULL;

}

if (NULL != lpd3dViewport)

{

lpd3dViewport->lpVtbl->Release(lpd3dViewport);

lpd3dViewport = NULL;

}

return DD_OK;

}