Clearing Depth Buffers

You should clear the depth buffer each time you render a new frame. You can explicitly clear the depth buffer through Direct3D by using the IDirect3DViewport3::Clear and IDirect3DViewport3::Clear2 methods. The Clear method always uses the "deepest" value, but Clear2 allows you to specify an arbitrary depth value.

You can also use DirectDraw to clear a depth buffer. Call the depth buffer surface's IDirectDrawSurface4::Blt method to clear it. The DDBLT_DEPTHFILL flag indicates that the blit is being used to a clear depth buffer. When this flag is specified, the DDBLTFX structure passed to the IDirectDrawSurface4::Blt method should be initialized and have its dwFillDepth member set to the required depth.

If the DirectDraw device driver for a 3-D accelerator is designed to provide support for depth buffer clearing in hardware, it will report the DDCAPS_BLTDEPTHFILL flag and should handle DDBLT_DEPTHFILL blits. The destination surface of a depth-fill blit must be a depth buffer surface.