Game Development Reference
In-Depth Information
The application layer will delete things in the reverse order in which they were cre-
ated. The creation order was resource cache first, the game window second, and the
game logic object third. We
'
ll release them in the reverse order.
LRESULT GameCodeApp::OnClose()
{
// release all the game systems in reverse order from which they
// were created
SAFE_DELETE(m_pGame);
DestroyWindow(GetHwnd());
VDestroyNetworkEventForwarder();
SAFE_DELETE(m_pBaseSocketManager);
SAFE_DELETE(m_pEventManager);
ScriptExports::Unregister();
LuaStateManager::Destroy();
SAFE_DELETE(m_ResCache);
return 0;
}
If you extended the GameCodeApp application layer into your own class, you
ll want
to do exactly the same thing with the custom objects there and release them in the
reverse order. When the game logic is deleted, it will run a destructor that releases its
objects, including its process manager and all the views attached to it.
After the WM_CLOSE message is processed, the main message pump exits, and control
will eventually return to the WinMain function, which calls DXUTShutdown() to
release the DirectX Framework.
'
What About Consoles?
This topic has a decidedly Windows bend, mostly because Windows is a very acces-
sible programming platform. But that doesn
t be exposed to some
discussion about how to perform certain tasks with the constraints imposed by con-
sole and mobile platforms
'
t mean you can
'
and shutdown is no exception.
Consoles run one program at a time and essentially don ' t have to worry about being
left in a weird state. The shutdown solution used on Thief: Deadly Shadows could
have been documented in a single page
we simply rebooted the machine. Is this a
good idea or not?
From the player
t have to take any
time whatsoever, simply unrolling the data structures and cleaning up allocated
memory. It just exits
'
s point of view, it
'
s a great idea. Shutdown doesn
'
and BAM!
you are back to the launch window.
 
 
Search WWH ::




Custom Search