Initialize(), LoadAllGraphicsContent(), Unload()?

Hi Guys,

Just wondering if anyone could explain to me what is meant to happen in the Initialize and LoadAllGraphicsContent() methods in the skeleton source code. In particular I am unsure about what goes into the normal constructor and what goes into these two methods and what is the difference between each of those methods. Are these methods called only once at the start of the program or are there many calls to these methods?

Thanks for any help offered

[524 byte] By [ParadigmShift] at [2007-12-27]
# 1
Initialize is called once at program startup. You can load any non-graphics content there - sounds, data, etc. LoadAllGraphicsContent is called whenever it's needed, when the graphics device is recreated for some reason, which means your graphics are no longer valid and have to be reloaded. You can put whatever you want in the constructor, but normally I limit it to code that creates objects that are needed before the game is initialized - wave and soundbank objects in addition to the content manager object that gets inserted by the Starter Kit, if you use that.
JimPerry at 2007-9-4 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 2
Jim Perry wrote:
Initialize is called once at program startup. You can load any non-graphics content there - sounds, data, etc. LoadAllGraphicsContent is called whenever it's needed, when the graphics device is recreated for some reason, which means your graphics are no longer valid and have to be reloaded. You can put whatever you want in the constructor, but normally I limit it to code that creates objects that are needed before the game is initialized - wave and soundbank objects in addition to the content manager object that gets inserted by the Starter Kit, if you use that.

LoadAllGraphicsContent does not get recalled when my graphic device is reset through an alt-tab. I know this for sure.

vidalsasoon at 2007-9-4 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 3
Is the graphics device reset? How do you know?
JimPerry at 2007-9-4 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 4

When the device is created/recreated, LoadAllGraphicsContent is called with an argument of true. When the device is reset, LoadAllGraphicsContent is called with an argument of false.

Alt-tab typically only causes a reset if running in fullscreen mode.

ProfEclipse at 2007-9-4 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 5
ProfEclipse wrote:

When the device is created/recreated, LoadAllGraphicsContent is called with an argument of true. When the device is reset, LoadAllGraphicsContent is called with an argument of false.

Alt-tab typically only causes a reset if running in fullscreen mode.

you're right. my debug output was inside the true/false condition so I never noticed it.
what determines a true or false value anyway?

vidalsasoon at 2007-9-4 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 6
XNA determines that for you. If the graphics device has been recreated all the assets in the content manager are no longer valid and need to be reloaded.
JimPerry at 2007-9-4 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...