Platform SDK: DirectX

Using Direct3DX to Clear Surfaces

Many C++ applications clear the depth buffer prior to rendering each new frame. You can explicitly clear the depth buffer with the Direct3DX utility library by using the ID3DXContext::Clear method.

    hr = g_pD3DX->Clear(D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER);
    if (FAILED(hr))
        return hr;

The Clear method allows you to specify which surfaces should be cleared. The preceding code fragment clears both the rendering target and the depth-buffer.