Platform SDK: DirectX

Recording State Blocks

[C++]

The IDirect3DDevice7 interface offers the IDirect3DDevice7::BeginStateBlock method to record device states into a state block, as your application calls for them. The BeginStateBlock method causes the system to start recording device state changes into a state block, rather than applying them to the device. After you call BeginStateBlock, calls to any of the following methods will be recorded into a device state block.

When you're done recording the state block, notify the system to stop recording by calling the IDirect3DDevice7::EndStateBlock method. The EndStateBlock method places the handle of the state block you recorded into the variable whose address you pass in the lpdwBlockHandle parameter. Your application will use this handle to apply the state block to the device as needed, to capture new state data into the block, and to delete the state block when it is no longer required.

[Visual Basic]

The Direct3DDevice7 object offers the Direct3DDevice7.BeginStateBlock method to record device states into a state block, as your application calls for them. The BeginStateBlock method causes the system to start recording device state changes into a state block, rather than applying them to the device. After you call BeginStateBlock, calls to any of the following methods will be recorded into a device state block.

When you're done recording the state block, notify the system to stop recording by calling the Direct3DDevice7.EndStateBlock method. The EndStateBlock method places the handle of the state block you recorded into the variable you pass in the blockHandle parameter. Your application will use this handle to apply the state block to the device as needed, to capture new state data into the block, and to delete the state block when it is no longer required.

Performance Note  For best results, group all state changes tightly between an BeginStateBlock/EndStateBlock pair.

It is important to check the error code from the EndStateBlock method. If it fails, it is most likely because the display mode has changed (error code DDERR_SURFACELOST). Design your application to recover from this type of failure by recreating its surfaces and recording the state block again.