Jump to content
  • Advertisement
Sign in to follow this  
utilae

Alt Tab + Restoring Textures

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

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:
////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();
}	

So how do you restore textures?

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!