Lost Device

I'm using managed directx 2.0 and the sample framework and there's a couple of things that i cannot understand concerning lost devices. My main problem is, where should i put the creation of objects. For instance in the sample framework a sprite is created in OnResetDevice, my question is why in here and not in OnCreateDevice When should i create resources with Pool.Default And when i'm using directx objects how could i know where i put the creation call It's on the OnCreateDevice or on the OnResetDevice

This is very confuse, and there's no documentation ( i have not found none ) that answers my questions.

Tnks for any help


Answer this question

Lost Device

  • ananasgroup

    Yes i mean OnResetDevice, i'm sorry (I have edited the post). Thank you for your answer i will follow your advice i was just trying to define a pattern for my objects.
  • jjjames

    Thank you for your answer but how do i know that a Sprite for example needs to be created in the OnResetDevice method When i create a VertexBuffer, i choose the pool type and in that situation i know where i should put the call, but when i use a directx object how can i know it It's always in the OnResetDevice And why
  • arianraj

    As MDX 2 is still in Beta you should post such question in the beta newsgroups. See http://msdn.com/directx/beta for details.

    But as your question applies even to MDX 1 I am think it is ok to answer it here.

    Create all your managed resource in OnCreateDevice.

    Create your default pool resource in OnResetDevice.

    Dispose your default pool resource in OnLostDevice.

    Dispose your managed resource in OnDestroyDevice.



  • AndyB C#

    You should never create any object in lost device. I am sure you mean OnResetDevice. The functions were you should create your objects depends only on the pool.

    With “Sprite” you mean the Sprite class from the framework All this helper classes are a little bit tricky because they create other DirectX objects internal and you don’t know the pool for these objects. In this case you should go the save way and create them in OnDeviceReset and dispose them in OnLostDevice. Most of this helpers use a default pool resource anywhere.



  • Lost Device