DirectX managed framework: vertexBuffers, changing modes fails...  
Author Message
Neil Beresford





PostPosted: Game Technologies: DirectX 101, DirectX managed framework: vertexBuffers, changing modes fails... Top

Hi all,

I'm currently facing a slight problem where changing mode on my application causes an error with 'Failed Resetting the Direct3D device' message.

I'm using the managed direct3D framework and it currently works fine with line and sprite rendering. After added transparent boxes to the system, I got the above error, when mode changing. This I'm assuming is down to not disposing and resetting the vertexBuffer correctly.

After reading the help and searching online for examples, I can only see the following;

OnResetDevice(...) - Creates and setup the vertexBuffer.

I didn't see any other handling of the vertexBuffer, in any of the other calls, ie OnLostDevice() etc.

The code works fine and is happy with normal operation, ie opening the app, using it and then closing the app. However mode changes, ie screensavers, full screen etc calls this failed resetting the device error.

Therefore, please could soomeone clear this confusion I have, and explain how to actually handle a created vertexBuffer correctly in a managed framework application

many thanks in advance,

Neil Beresford



Game Technologies: DirectX, XNA, XACT, etc.16  
 
 
Neil Beresford





PostPosted: Game Technologies: DirectX 101, DirectX managed framework: vertexBuffers, changing modes fails... Top

Yet again I have to reply to myself... I do wonder at the commitment of the readers of this forum to actually helping people.

To response to myself asking how to handle vertexBuffers correctly... Here's the answer ...

* Create the new vertexBuffer in onResetDevice(). Set the vertexBuffer up here as well, keeps it tidy.

* Dispose of the vertexBuffer in onLostDevice().

Simple!

I feel that samples from Microsoft, even thou they are only there as examples, should show the correct usage of all device depentant objects. I realize most samples are generally fullscreen etc, but when a screen saver kicks in, its BOOM time! That expression comes to mind that my head master articulated to me on a number of occasions;

"It's not very professional, is it!"

Anyway, I hope this at least helps another,

many thanks - Neil