Platform SDK: DirectX

Clearing Depth Buffers

[C++]

Many C++ applications clear the depth buffer prior to rendering each new frame. You can explicitly clear the depth buffer through Direct3D by using the IDirect3DDevice7::Clear method. The Clear method allows you to specify an arbitrary depth value in the dvZ parameter.

You can also use DirectDraw to clear a depth buffer. Call the depth buffer surface's IDirectDrawSurface7::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 IDirectDrawSurface7::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.

[Visual Basic]

Many Visual Basic applications clear the depth buffer prior to rendering each new frame. You can explicitly clear the depth buffer through Direct3D by using the Direct3DDevice7.Clear method. The Clear method allows you to specify an arbitrary depth value in the z parameter.

You can also use DirectDraw to clear a depth buffer. Call the depth buffer surface's DirectDrawSurface7.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 type passed to the DirectDrawSurface7.Blt method have its lFill 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.