preRender() public méthode

called before the Scene is rendered. This allows a transition to render to a RenderTarget if needed and avoids issues with MonoGame clearing the framebuffer when a RenderTarget is used.
public preRender ( Graphics graphics ) : void
graphics Graphics Graphics.
Résultat void
Exemple #1
0
        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
        }
Exemple #2
0
        protected override void Draw(GameTime gameTime)
        {
            if (pauseOnFocusLost && !IsActive)
            {
                return;
            }

                        #if DEBUG
            TimeRuler.instance.beginMark("draw", Color.Gold);
                        #endif

            if (_sceneTransition != null)
            {
                _sceneTransition.preRender(Graphics.instance);
            }

            if (_scene != null)
            {
                _scene.preRender();
                _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);
                    scene = null;
                    startCoroutine(_sceneTransition.onBeginTransition());
                }
                else
                {
                    if (_scene != null)
                    {
                        _scene.postRender();
                    }
                }

                _sceneTransition.render(Graphics.instance);
            }

                        #if DEBUG
            TimeRuler.instance.endMark("draw");

            if (DebugConsole.instance.isOpen)
            {
                DebugConsole.instance.render();
            }
            else
            {
                TimeRuler.instance.render();
            }

            drawCalls = graphicsDevice.Metrics.DrawCount;
                        #endif
        }