Sign in to follow this  

Lost devices with meshes and textures

This topic is 1796 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

Hi everyone,

 

I've managed to get some code running to handle lost devices - it works, in that the fullscreen program reloads and renders again, but it also causes the scene to look very strange (flat and disjointed with no alpha blending and a limited draw distance). So my question is - what exactly do I need to do with my mesh and texture resources when I reset the device? Fonts and things like that are OK because you can just use font->OnLostDevice() and font->OnResetDevice() to fix them. Do I need to release() the meshes and textures? How do I reload them?

 

Thanks a lot!

Share this post


Link to post
Share on other sites

OK, never mind - I don't think I was resetting enough stuff! I made it so that my onResetDevice() function resets everything to the state it's set to when the device is created in the first place. i.e. I release() all the textures, meshes, etc... and I reload them again, reset the render states, lighting and the projection matrix - it all works fine!

Share this post


Link to post
Share on other sites

Your solution is probably an overkill. You don't have to release and recreate any resource besides those placed in D3DPOOL_DEFAULT. Your meshes and textures will most probably be D3DPOOL_MANAGED and so you don't have to take care of them anyhow.

From your first post it's clear that your reset actually worked (in a way). That means you released all resources that had to be released, otherwise you wouldn't be able to reset the device at all, you would be getting errors.

 

From your explanation it's also quite clear that your only problem were transform matrices (SetTransform), which caused the geometry problems; and render states (SetRenderState) which caused non working alpha blending etc. And also lights (SetLight).

All these values must be set by you again because they are in the default state after device reset.

Setting these values after each device reset is very easy and fast. This hovewer isn't true for textures and models, creating them again can take a lot of time and IMHO it's not optimal to do it even if you really don't have to.

Edited by Tom KQT

Share this post


Link to post
Share on other sites
I agree on the possibility you're going in overkill.
I remember finding this ou and in the end all i had to do was;

When lost:
- release vertex declaration
- font.OnLostDevice
- d3dxeffects.OnLostDevice

Reset, and afterwards:
- Create and set vertex declaration
- recreate font
- d3dxeffects.OnResetDevice

Assuming your textures are in the managed pool.
I also first reloaded all my non d3d data/ objects of own classes which wasn't necessary.
Good luck,

Share this post


Link to post
Share on other sites

This topic is 1796 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this