Nick Gravelyn

Trying to figure out where <a href="http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=1212399&SiteID=1">my problem</a> lies with recreating/resetting the graphics device and the weird effects, I began to wonder if I had tied into the proper event handlers. So I was wondering if someone could tell me if this is the correct way to set up event handlers for a custom game component:


                graphicsDeviceService.DeviceCreated += new EventHandler(loadAllContent);
                graphicsDeviceService.DeviceDisposing += new EventHandler(unloadAllContent);
                graphicsDeviceService.DeviceResetting += new EventHandler(unloadContent);
                graphicsDeviceService.DeviceReset += new EventHandler(loadContent);


public void loadContent(Object obj, EventArgs args) { LoadGraphicsContent(false); }
public void loadAllContent(Object obj, EventArgs args) { LoadGraphicsContent(true); }
public void unloadContent(Object obj, EventArgs args) { UnloadGraphicsContent(false); }
public void unloadAllContent(Object obj, EventArgs args) { UnloadGraphicsContent(true); }


Re: XNA Framework Responding To Graphics Device Events

Kyle_W

I posted a reply on your other thread. If you are loading all of your models and textures through the Content Pipeline, my understanding is that either the ContentManager or the GraphicsDeviceManager for the game should take care of re-initializing all those resources during a device reset as long as you are following the conventions here:

http://msdn2.microsoft.com/en-us/library/bb203875.aspx

Since you are only having problems with one of your models and not the others, I think trying to hook into the events is probably not the right way to tackle the problem, although I don't know if things are different when you are using a game component.





Re: XNA Framework Responding To Graphics Device Events

Kyle_W

I found the following forum post that might address your problem:

http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=1050454&SiteId=1





Re: XNA Framework Responding To Graphics Device Events

Nick Gravelyn

Thanks for the links. I do understand both of those pages. This isn't directly related to my problem in the other thread; I simply wondered if this part was correct or not and figured it may trigger problems elsewhere if it was incorrect.

My post here is mainly because I'm not using the XNA defined GameComponent class because 1) I wanted experience in designing the class and I have a liking for being able to see everything that's going on and 2) I wanted to extend the functionalities in a way that would be easier if I were to replicate the class rather than extend XNA's. I simply want to know if my assumptions of where the true's and false's come from (as far as the event handlers) is correct. I believe I have them correct, but if anyone knows for sure, I'd appreciate it.




Re: XNA Framework Responding To Graphics Device Events

Shawn Hargreaves - MSFT

Yes, that's correct.