コード例 #1
0
ファイル: Primitives.cs プロジェクト: tmp7701/Gorgon
        public void TestPolygon()
        {
            _form.Show();
            _form.ClientSize = new Size(1280, 800);
            _form.Location   = new Point(Screen.PrimaryScreen.WorkingArea.Width / 2 - 640, Screen.PrimaryScreen.WorkingArea.Height / 2 - 400);
            _form.BringToFront();
            _form.WindowState = FormWindowState.Minimized;
            _form.WindowState = FormWindowState.Normal;

            GorgonPolygon polygon = _renderer.Renderables.CreatePolygon("Test", new Vector2(320, 240), Color.RosyBrown);

            polygon.SetVertexData(new GorgonPolygonPoint[]
            {
                new GorgonPolygonPoint(new Vector2(0, 20), GorgonColor.White),
                new GorgonPolygonPoint(new Vector2(20, 0), GorgonColor.White),
                new GorgonPolygonPoint(new Vector2(40, 20), GorgonColor.White),
                new GorgonPolygonPoint(new Vector2(10, 40), GorgonColor.White),
                new GorgonPolygonPoint(new Vector2(30, 40), GorgonColor.White)
            });

            polygon.SetIndexData(new []
            {
                0, 1, 2,
                2, 3, 0,
                3, 2, 4
            });

            GorgonPolygon polygon2 = _renderer.Renderables.CreatePolygon("Test", new Vector2(320, 240), Color.GreenYellow);

            polygon2.PolygonType = PolygonType.Line;
            polygon2.SetVertexData(new GorgonPolygonPoint[]
            {
                new GorgonPolygonPoint(new Vector2(0, 20), GorgonColor.White),
                new GorgonPolygonPoint(new Vector2(20, 0), GorgonColor.White),
                new GorgonPolygonPoint(new Vector2(40, 20), GorgonColor.White),
                new GorgonPolygonPoint(new Vector2(10, 40), GorgonColor.White),
                new GorgonPolygonPoint(new Vector2(30, 40), GorgonColor.White)
            });

            polygon2.SetIndexData(new[]
            {
                0, 1,
                1, 2,
                2, 4,
                4, 3,
                3, 0
            });

            Gorgon.Run(_form, () =>
            {
                _renderer.Clear(Color.Black);

                polygon.Draw();
                polygon2.Draw();

                _renderer.Render();

                return(true);
            });

            Assert.IsTrue(_form.TestResult == DialogResult.Yes);
        }