# Gaining focus and state blocks

This topic is 4718 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi :) I'm happily using IDirect3DStateBlock9 to handle states in my system - but I've come across something that just feels clunky in the code. Whenever my full-screen application loses focus and then regains it - the data in state blocks is lost, thus I have to explicitly recreate the state block. Isn't there a convenient dump-to-main-memory or something from which I can recover the state block without major effort? Something that requires one line of code, rather then a full state recoding. thanks

##### Share on other sites
hey, i didnt come across the State block thing, but i think its the same concept as other Direct3D objects, you have to recreate it on ur own.

that is as far as i know.

##### Share on other sites
That's kind of interesting - I would have thought that state blocks were natively allocated in system memory, not video memory. However, it doesn't look like you can choose a specific pool, so you can't really control where it is created. I suggest that you code your state block creation routine(s) in a specific function, so that it doesn't have to be copied.

For example:
HRESULT CreateStateBlocks(){   if( FAILED( d3dDevice->CreateStateBlock( D3DSBT_ALL, &block ) ) )   {      return E_FAIL;   }   d3dDevice->BeginStateBlock();   // Set all the states   .   .   .   block->Capture();   d3dDevice->EndStateBlock();   return S_OK;}

##### Share on other sites
I didn't verify this - but I suppose that setting up the DX Device as D3DPOOL_MANAGED would automatically save and recover the state-block. I work without the DX management though... alas. Thanks :)

• 19
• 10
• 19
• 14
• 20