Microsoft DirectX 8.1 (C++)

Capturing State Blocks

The IDirect3DDevice8::CaptureStateBlock method updates the values within an existing state block to reflect the current state of the device. The method accepts a single parameter, Token, that identifies the state block that will receive the current state of the device if the call succeeds.

The CaptureStateBlock method is especially useful to update a state block that your application has already recorded to include slightly different state settings. To do so, apply the existing state block, change the necessary settings, then capture the state of the system back to the state block, as shown in the following code example.

// The token variable contains a handle to a device-state block for 
// a previously recorded set of device states.

// Set the current state block.
d3dDevice->ApplyStateBlock(token);

// Change device states as needed.
.
.
.

// Capture the modified device state data back to the existing block.
d3dDevice->CaptureStateBlock(token);

The CaptureStateBlock method doesn't capture the entire state of the device; it only updates the values for the states already in the state block. For example, imagine a state block that contains the two operations shown in the following code example.

d3dDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD);
d3dDevice->SetTexture(0, pTexture);
 

If your application changed either of these settings since the state block was originally recorded, the CaptureStateBlock method will update the states within the block—and only those states—to their new values.