Microsoft DirectX 8.1 (Visual Basic)

Recording State Blocks

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

When you are done recording the state block, notify the system to stop recording by calling the Direct3DDevice8.EndStateBlock method. The EndStateBlock method places the handle of the state block in the method's return value. Your application uses 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 a BeginStateBlock and EndStateBlock pair.

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