Game Development Reference
In-Depth Information
i!=m_ScreenElements.end(); ++i)
{
V_RETURN ( (*i)->VOnRestore() );
}
return hr;
}
void HumanView::VOnLostDevice()
{
HRESULT hr;
for(ScreenElementList::iterator i=m_ScreenElements.begin();
i!=m_ScreenElements.end(); ++i)
{
V_RETURN ( (*i)->VOnLostDevice() );
}
}
The HumanView::VOnRestore() method is responsible for re-creating anything
that might be lost while the game is running. This kind of thing typically happens
as a result of the operating system responding to something application wide, such
as restoring the application from a sleep mode or changing the screen resolution
while the game is running. Also remember that VOnRestore() gets called just
after the class is instantiated, so this method is just as useful for initialization as it is
for restoring lost objects. These objects include all of the attached screens. The
HumanView::VOnLostDevice() method will be called prior to VOnRestore() ,
so it is used to chain the
on lost device
event to other objects or simply release
the objects so they
ll be re-created in the call to VOnRestore() . This is a common
theme in DirectX applications on the PC, since any number of things can get in the
way of a game, such as a change of video resolution or even Alt-Tabbing away to
another application that makes exclusive use of DirectX objects. Being able to reini-
tialize your UI could come in extremely handy, no matter what operating system or
platform your game uses. For example, smart phone and tablet games might need to
completely change their UI layout when players reorient their devices from a land-
scape format to a portrait style format.
The view is called once per frame by the application layer so that it can perform non-
rendering update tasks. The VOnUpdate() chain is called as quickly as the game
loops and is used to update any object attached to the human view. In this case, the
Process Manager is updated, as well as any of the screen elements attached to
the human view. As you will see in Chapter 16,
'
3D Scenes,
this includes updating
the objects in the 3D scene, which is itself a screen element.
Search WWH ::




Custom Search