Partager via


Clearing Depth Buffers

Many C# applications clear the depth buffer before rendering each new frame. Through Microsoft Direct3D, the depth buffer can be cleared explicitly by calling Device.Clear and specifying ClearFlags.ZBuffer for the flags parameter. The Device.Clear method allows specification of an arbitrary depth value in the zdepth parameter.

The following C# code example demonstrates how to clear the depth buffer.

          [C#]
          

using Microsoft.DirectX.Direct3D;

Device device = null;

// Create a rendering device.
.
.
.

// Clear the depth buffer.
device.Clear(ClearFlags.ZBuffer, 0, 0.5f, 0);