Partager via


Depth Buffering State

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

Depth buffering is a method of removing hidden lines and surfaces. By default, Microsoft® Direct3D® Mobile does not use depth buffering.

For a conceptual overview of depth buffers, see Depth Buffers.

Applications update the depth-buffering state with the D3DRS_ZENABLE render state (see D3DMRENDERSTATETYPE), using a member of the D3DMZBUFFERTYPE enumeration to specify the new state value.

If your application needs to prevent Direct3D Mobile from writing to the depth buffer, it can use the D3DMRS_ZWRITEENABLE enumerated value, specifying D3DMZB_FALSE as the second parameter for the call to IDirect3DMobileDevice::SetRenderState.

The following code example shows how the depth-buffer state is set to enable z-buffering.

// This code example assumes that d3dmDevice is a 
// valid pointer to an IDirect3DMobileDevice interface.
 
// Enable z-buffering.
d3dmDevice->SetRenderState(D3DMRS_ZENABLE, D3DMZB_TRUE);

Your application can also use the D3DMRS_ZFUNC render state to control the comparison function that Direct3D Mobile uses when performing depth buffering.

Z-biasing is a method of displaying one surface in front of another, even if their depth values are the same. You can use this technique for a variety of effects. A common example is rendering shadows on walls. Both the shadow and the wall have the same depth value. However, you want your application to show the shadow on the wall. Giving a z-bias to the shadow makes Direct3D Mobile display them properly (see Using Z-Bias).

See Also

Concepts

Render States