protected override void Draw(GameTime gameTime)
        {
            Profiler.Start("Game Draw");
            GraphicsDevice.SetRenderTarget(null);
            GraphicsDevice.Viewport = Viewport;
            GraphicsDevice.Clear(Color.CornflowerBlue);
            Scene?.Draw(_spriteBatch, gameTime);
            Profiler.Stop("Game Draw");
            _spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, null);
            string  text     = string.Format("FPS: {0}", Math.Floor(1 / gameTime.ElapsedGameTime.TotalSeconds));
            Vector2 textSize = Font.MeasureString(text);

            _spriteBatch.DrawString(Font, text, new Vector2((Viewport.Width - textSize.X - 3), 5), Color.Black, 0, Vector2.Zero, 1, SpriteEffects.None, 1);
            _spriteBatch.DrawString(Font, text, new Vector2((Viewport.Width - textSize.X - 4), 4), Color.White, 0, Vector2.Zero, 1, SpriteEffects.None, 0);
//#if DEBUG
//            text = string.Format("Game\n  Draw Count: {0}\n  Texture Count: {1}\n  Sprite Count: {2}\n  Primitive Count: {3}\n  Target Count: {4}\n\nWorld Bake\n  Draw Count: {5}\n  Texture Count: {6}\n  Sprite Count: {7}\n  Primitive Count: {8}\n  Target Count: {9}", GraphicsDevice.Metrics.DrawCount, GraphicsDevice.Metrics.TextureCount, GraphicsDevice.Metrics.SpriteCount, GraphicsDevice.Metrics.PrimitiveCount, GraphicsDevice.Metrics.TargetCount, WorldBakeDrawCount, WorldBakeTextureCount, WorldBakeSpriteCount, WorldBakePrimitiveCount, WorldBakeTargetCount);
//            _spriteBatch.DrawString(Font, text, new Vector2(5, 5), Color.Black, 0, Vector2.Zero, 1, SpriteEffects.None, 1);
//            _spriteBatch.DrawString(Font, text, new Vector2(4, 4), Color.White, 0, Vector2.Zero, 1, SpriteEffects.None, 0);
//#endif
            _spriteBatch.End();
            if (DebugMenu.Groups["D2D"].Items["Profiler"].SelectedOption?.Text == "On")
            {
                Profiler.Draw(_spriteBatch, Font, Viewport.Width, Viewport.Height);
            }
            if (DebugDraw)
            {
                _spriteBatch.Begin();
                DebugMenu.Draw(_spriteBatch, Font, new Vector2(8), 200);
                _spriteBatch.End();
            }
            base.Draw(gameTime);
        }
Ejemplo n.º 2
0
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            spriteBatch.Begin(_camera);

            _currentMap.Draw(gameTime, spriteBatch, _player);

            spriteBatch.End();

            spriteBatch.Begin();
            if (_debug.Equals(true))
            {
                _debugMenu.Draw(gameTime, spriteBatch);
            }
            spriteBatch.End();
        }