////RECOVER FROM ALT TAB
HRESULT hr;
hr=g_pD3DDevice9->TestCooperativeLevel();
if(hr == D3DERR_DEVICELOST)
{ //Device is lost and cannot be reset yet
Sleep(500); //Wait a bit so we don't burn through cycles for no reason
FreeVolatileResources();
}
else if(hr == D3DERR_DEVICENOTRESET)
{ //Lost but we can reset it now
hr=g_pD3DDevice9->Reset(&g_d3dpp);
if(SUCCEEDED(hr))
InitVolatileResources();
}
Alt Tab + Restoring Textures
I am using C++ and Direct3D9.
My textures load fine, etc. But when I alt tab (minimize) and the go back into my game, I get an error (program not responding as well).
my restore code is like this:
So how do you restore textures?
What exactly is your error? Does the debug runtime give you anything?
I use the SDK framework atm - OnLostDevice( ) SAFE_RELEASE()'s all my volatile resources and OnResetDevice( ) creates all of the textures by loading back from the disk as if they were brand-new.
Jack
I use the SDK framework atm - OnLostDevice( ) SAFE_RELEASE()'s all my volatile resources and OnResetDevice( ) creates all of the textures by loading back from the disk as if they were brand-new.
Jack
I'm getting a "memory could not be written" error. The game minimizes fine, but it's when I go back into the game that the error comes up.
I believe you have to release all things in the default pool (if you haven't already) before you reset.
release all textues an meshes with SAFE_RELEASE(pointer) then you need to reload them all when you get the device back. from what i understand of DX.
everything [smile].
Resources in D3DPOOL_SYSMEM and D3DPOOL_MANAGED will be looked after for you; All resources of any type in D3DPOOL_DEFAULT should be released when you minimize and re-created again when you get focus (recreate the device) again.
hth
Jack
Resources in D3DPOOL_SYSMEM and D3DPOOL_MANAGED will be looked after for you; All resources of any type in D3DPOOL_DEFAULT should be released when you minimize and re-created again when you get focus (recreate the device) again.
hth
Jack
There is an excellent article in Wolfgang Engel's ShaderX 3 book about managing Resources for exactly this purpose... Definitely worth every buck!
Amazon.com:
http://www.amazon.com/exec/obidos/tg/detail/-/1584503572/qid=1108417751/sr=8-1/ref=sr_8_xs_ap_i1_xgl14/102-0480439-8120967?v=glance&s=books&n=507846
ISBN: 1584503572
Amazon.com:
http://www.amazon.com/exec/obidos/tg/detail/-/1584503572/qid=1108417751/sr=8-1/ref=sr_8_xs_ap_i1_xgl14/102-0480439-8120967?v=glance&s=books&n=507846
ISBN: 1584503572
Quote:Original post by mattayers
http://www.amazon.com/exec/obidos/tg/detail/-/1584503572/qid=1108417751/sr=8-1/ref=sr_8_xs_ap_i1_xgl14/102-0480439-8120967?v=glance&s=books&n=507846
I don't think I've seen a URL that ugly in years [smile].
Clicky for the lazy..
Cheers,
Jack
jollyjeffers:
So what would be the purpose of ever using D3DPOOL_DEFAULT, if D3DPOOL_SYSMEM and D3DPOOL_MANAGED take care of all the resource releasing/reaquiring for you? Is there some advantage (speed?) by releasing and restoring by yourself?
So what would be the purpose of ever using D3DPOOL_DEFAULT, if D3DPOOL_SYSMEM and D3DPOOL_MANAGED take care of all the resource releasing/reaquiring for you? Is there some advantage (speed?) by releasing and restoring by yourself?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement