Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Lost devices with meshes and textures


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 george7378   Members   -  Reputation: 1254

Like
0Likes
Like

Posted 14 February 2013 - 03:08 PM

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!



Sponsor:

#2 george7378   Members   -  Reputation: 1254

Like
0Likes
Like

Posted 14 February 2013 - 07:58 PM

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!



#3 Tom KQT   Members   -  Reputation: 1612

Like
3Likes
Like

Posted 15 February 2013 - 01:38 AM

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, 15 February 2013 - 03:40 AM.


#4 george7378   Members   -  Reputation: 1254

Like
0Likes
Like

Posted 15 February 2013 - 05:36 AM

Thanks for the advice - I changed it as you suggested and it still works fine. Anything to increase efficiency! Thanks!



#5 cozzie   Members   -  Reputation: 1659

Like
0Likes
Like

Posted 15 February 2013 - 01:55 PM

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,




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS