protected override void Draw(GameTime gameTime)
{
if (pauseOnFocusLost && !IsActive)
{
return;
}
#if DEBUG
TimeRuler.instance.beginMark("draw", Color.Gold);
// fps counter
_frameCounter++;
_frameCounterElapsedTime += gameTime.ElapsedGameTime;
if (_frameCounterElapsedTime >= TimeSpan.FromSeconds(1))
{
var totalMemory = (GC.GetTotalMemory(false) / 1048576f).ToString("F");
Window.Title = string.Format("{0} {1} fps - {2} MB", _windowTitle, _frameCounter, totalMemory);
_frameCounter = 0;
_frameCounterElapsedTime -= TimeSpan.FromSeconds(1);
}
#endif
if (_sceneTransition != null)
{
_sceneTransition.preRender(Graphics.instance);
}
if (_scene != null)
{
_scene.render();
#if DEBUG
if (debugRenderEnabled)
{
Debug.render();
}
#endif
// render as usual if we dont have an active SceneTransition
if (_sceneTransition == null)
{
_scene.postRender();
}
}
// special handling of SceneTransition if we have one
if (_sceneTransition != null)
{
if (_scene != null && _sceneTransition.wantsPreviousSceneRender && !_sceneTransition.hasPreviousSceneRender)
{
_scene.postRender(_sceneTransition.previousSceneRender);
if (_sceneTransition._loadsNewScene)
{
scene = null;
}
startCoroutine(_sceneTransition.onBeginTransition());
}
else if (_scene != null)
{
_scene.postRender();
}
_sceneTransition.render(Graphics.instance);
}
#if DEBUG
TimeRuler.instance.endMark("draw");
DebugConsole.instance.render();
// the TimeRuler only needs to render when the DebugConsole is not open
if (!DebugConsole.instance.isOpen)
{
TimeRuler.instance.render();
}
#if !FNA
drawCalls = graphicsDevice.Metrics.DrawCount;
#endif
#endif
}