Microsoft DirectX 9.0 SDK Update (October 2004)

Changing Depth Buffer Comparison Functions

Language:

Note: This documentation is preliminary and is subject to change.

By default, when depth testing is performed on a rendering surface, the Microsoft® Direct3D® system updates the render target surface if the corresponding depth value (z or w) for each point is less than the value in the depth buffer. In a C# application, changes to how the system performs comparisons on depth values are made by setting the RenderStateManager.ZBufferFunction property of the Device.RenderState property to a value of the Compare enumerated type. This is illustrated in the following C# code example.

          [C#]
          
using System; using Microsoft.DirectX.Direct3D; // Declare a rendering device. Device device = null; // Initialize the device. . . . // Get the device's render state object. RenderStates rs = device.RenderState; // Set the ZBuffer comparison function. rs.ZBufferFunction = Compare.Greater; // Render the scene. . . . // Change the comparison function to some other value // (note the different syntax; both forms are acceptable) device.RenderState.ZBufferFunction = Compare.LessEqual;

© 2004 Microsoft Corporation. All rights reserved. Terms of use.

Feedback? Please provide us with your comments on this topic.
For more help, visit the DirectX Developer Center