Example #1
0
        private void PrerenderSourceAndTargetAndMakeTransition(Screen oldScreen, Screen currentScreen, Type transition)
        {
            _executingScreenTransition = true;
            var currentRenderTarget = GameInstance.GraphicsDevice.GetRenderTargets();

            GameInstance.GraphicsDevice.SetRenderTarget(_sourceRenderTarget);
            oldScreen.OnEarlyDraw(new GameTime());
            oldScreen.OnLateDraw(new GameTime());

            GameInstance.GraphicsDevice.SetRenderTarget(_targetRenderTarget);
            currentScreen.OnUpdate(new GameTime());
            currentScreen.OnEarlyDraw(new GameTime());
            GameInstance.GetService <SceneRenderer>().Draw();
            currentScreen.OnLateDraw(new GameTime());

            GameInstance.GraphicsDevice.SetRenderTargets(currentRenderTarget);
            _currentTransition = _screenTransitionsByType[transition];
            _currentTransition.StartTransition(_sourceRenderTarget, _targetRenderTarget);
        }