Exemplo n.º 1
0
        /// <summary>
        /// Called to actually render the game content to the backbuffer, which will be flipped with
        /// the currently displayed buffer to show the next frame.
        /// </summary>
        /// <param name="gameTime">Current time information of the application</param>
        protected override void Draw(GameTime gameTime)
        {
            Rectangle      CircleDest;
            int            nVertCtr, nPolyCtr;
            List <Vector2> VertList = new List <Vector2>();
            List <Vector2> CurveVerts;
            Rectangle      rectCurveBounds;
            Texture2D      LineTexture = new Texture2D(GraphicsDevice, 1, 1);

            LineTexture.SetData(new[] { Color.Cyan });

            cGraphDevMgr.GraphicsDevice.Clear(Color.Black);
            cDrawBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied);

            for (nPolyCtr = 0; nPolyCtr < cPolyList.Count; nPolyCtr++)
            {
                VertList.Clear();
                VertList.AddRange(cPolyList[nPolyCtr].GetVertexes(false));

                //Draw circles at each vertex
                for (nVertCtr = 0; nVertCtr < VertList.Count; nVertCtr++)
                {
                    CircleDest.X      = (int)(VertList[nVertCtr].X - CIRCLERADIUS);
                    CircleDest.Y      = (int)(VertList[nVertCtr].Y - CIRCLERADIUS);
                    CircleDest.Height = CIRCLERADIUS * 2;
                    CircleDest.Width  = CIRCLERADIUS * 2;

                    cDrawBatch.Draw(cCircleTexture, CircleDest, Color.Gray);
                }

                //Draw the polygons
                cPolyList[nPolyCtr].Draw();
            }

            VertList.Clear();
            VertList.AddRange(cPolyList[1].GetVertexes(false));
            MGMath.CubicBezierCurvePoints(VertList[0], VertList[3], VertList[1], VertList[2], 10, out CurveVerts);

            MGMath.CubicBezierCurveBoundaries(VertList[0], VertList[3], VertList[1], VertList[2], out rectCurveBounds);

            DrawTools.DrawLineSeries(GraphicsDevice, cDrawBatch, Color.LightYellow, 2, CurveVerts);
            DrawTools.DrawRectangle(GraphicsDevice, cDrawBatch, Color.RosyBrown, 2, rectCurveBounds);

            //Always draw console last
            cDevConsole.Draw(cDrawBatch);

            cDrawBatch.End();

            //Use monogame draw
            base.Draw(gameTime);
        }