Game Development Reference
In-Depth Information
{
// Render the scene
if(g_pApp->m_Renderer->VPreRender())
{
VRenderText();
m_ScreenElements.sort(
SortBy_SharedPtr_Content<IScreenElement>());
for(ScreenElementList::iterator i=m_ScreenElements.begin();
i!=m_ScreenElements.end(); ++i)
{
if ( (*i)->VIsVisible() )
{
(*i)->VOnRender(fTime, fElapsedTime);
}
}
// record the last successful paint
m_lastDraw = m_currTick;
}
g_pApp->m_Renderer->VPostRender();
}
}
If the view is ready to draw,
s
VPreRender()
method, which is called to get the Direct3D 11 device ready for rendering. The
VRenderText()
method is next, which will render any text applied directly to the
screen. In this class, the method has a null implementation. In Chapter 21, a human
view class will overload this to display some debug text.
The
for
loop iterates through the screen layers one-by-one, and if it is visible, it calls
IScreenElement::VOnRender()
. This implies that the only thing the view really
draws for itself is the text in
VRenderText()
, and that
it calls the application renderer
'
s exactly correct. Everything
else should be drawn because it belongs to the list of screens. The last thing that hap-
pens is a call to the renderer
'
s
VPostRender()
method, which finalizes the render
and presents the screen to the viewer.
Notice that the screen list is drawn from the beginning of the list to the end of the
list. That
'
s important because screens can draw on top of one another in layers, such
as when a modal dialog box draws on top of everything else in your game.
'
HRESULT HumanView::VOnRestore()
{
HRESULT hr;
for(ScreenElementList::iterator i=m_ScreenElements.begin();