public void BeginCustomDraw()
 {
     if (!_customPrimitiveBatch.IsReady())
     {
         _customPrimitiveBatch.Begin();
     }
     _primitiveBatch = _customPrimitiveBatch;
 }
Exemple #2
0
        public void LoadContent(GraphicsDevice device, ContentManager content)
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            _device         = device;
            _batch          = new SpriteBatch(_device);
            _primitiveBatch = new PrimitiveBatch(_device, 1000);
            //_font = content.Load<SpriteFont>("font");
            _stringData = new List <StringData>();

            _localProjection = Matrix.CreateOrthographicOffCenter(0f, _device.Viewport.Width, _device.Viewport.Height,
                                                                  0f, 0f, 1f);
            _localView = Matrix.Identity;
        }
        public void RenderDebugData()
        {
            if (!Enabled)
            {
                return;
            }

            //Nothing is enabled - don't draw the debug view.
            if (Flags == 0)
            {
                return;
            }

            _device.RasterizerState   = RasterizerState.CullNone;
            _device.DepthStencilState = DepthStencilState.Default;

            if (_customPrimitiveBatch.IsReady())
            {
                _customPrimitiveBatch.UpdateMatrix();
                _customPrimitiveBatch.End();
            }

            _primitiveBatch = _basicPrimitiveBatch;

            _primitiveBatch.Begin();
            DrawDebugData();
            _primitiveBatch.End();

            if ((Flags & DebugViewFlags.PerformanceGraph) == DebugViewFlags.PerformanceGraph)
            {
                _primitiveBatch.Begin();
                DrawPerformanceGraph();
                _primitiveBatch.End();
            }

            // begin the sprite batch effect
            _batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend);

            // draw any strings we have
            for (int i = 0; i < _stringData.Count; i++)
            {
                _batch.DrawString(_font, string.Format(_stringData[i].S, _stringData[i].Args),
                                  new Vector2(_stringData[i].X + 1f, _stringData[i].Y + 1f), Color.Black);
                _batch.DrawString(_font, string.Format(_stringData[i].S, _stringData[i].Args),
                                  new Vector2(_stringData[i].X, _stringData[i].Y), _stringData[i].Color);
            }
            // end the sprite batch effect
            _batch.End();

            _stringData.Clear();
        }