Platform SDK: DirectX |
It's important to remember that clip planes are not automatically enabled when you call the IDirect3DDevice7::SetClipPlane method. Use the D3DRENDERSTATE_CLIPPLANEENABLE render state to enable or disable the clip planes currently set for the device. This render state accepts a DWORD value, where each bit starting with the least significant bit corresponds to a clip plane. If a bit is set, the clip plane is enabled; if the bit is cleared, the corresponding plane is disabled. In the value, bit 0 enables and disables clip plane at index zero, bit 1 controls clip plane one, and so on to bit 31. (Direct3D can clip with up to 32 planes at once, but device support can vary.) These semantics allow applications to enable or disable every clip plane in a single call.
The d3dtypes.h header file defines the D3DCLIPPLANEn macros to create patterns that you can combine and pass as values for the D3DRENDERSTATE_CLIPPLANEENABLE render state. The following C++ code uses this macro.
// For this example, the pd3dDevice variable is a valid // pointer to an IDirect3DDevice7 interface. // Enable clip plane 0 and 1, while implicitly disabling // all other user-defined clip planes. pd3dDevice->SetRenderState( D3DRENDERSTATE_CLIPPLANEENABLE, D3DCLIPPLANE0 | D3DCLIPPLANE1);
It's important to remember that clip planes are not automatically enabled when you call the Direct3DDevice7.SetClipPlane method. Use the D3DRENDERSTATE_CLIPPLANEENABLE render state to enable or disable the clip planes currently set for the device. This render state values from the CONST_D3DCLIPPLANEFLAGS enumeration. Combine values from this enumeration to enable the corresponding clip plane, or omit them to disable the corresponding clip plane. (Use the D3DCPF_DISABLEALL value to disable all clip planes.) These semantics allow applications to enable or disable every clip plane in a single call.
The following Visual Basic code shows how this method is used.
' For this example, the d3dDevice variable is a valid ' reference to a Direct3DDevice7 object. ' Enable clip plane 0 and 1, while implicitly disabling ' all other user-defined clip planes. Call d3dDevice.SetRenderState(D3DRENDERSTATE_CLIPPLANEENABLE, _ (D3DCPF_ENABLEPLANE0 Or D3DCPF_ENABLEPLANE1))