Ejemplo n.º 1
0
        public MainApp()
        {
            WinForm_ = new Form
            {
                ClientSize      = new Size(Width, Height),
                StartPosition   = FormStartPosition.CenterScreen,
                MaximizeBox     = false,
                FormBorderStyle = FormBorderStyle.FixedSingle,
                Text            = "Orz App",
                KeyPreview      = true,
            };

            Surface_ = new PictureBox
            {
                Location   = Point.Empty,
                ClientSize = WinForm_.ClientSize,
            };
            WinForm_.Controls.Add(Surface_);

            WinForm_.KeyDown   += OnKeyDown;
            WinForm_.KeyUp     += OnKeyUp;
            Surface_.MouseDown += OnMouseDown;
            Surface_.MouseUp   += OnMouseUp;
            Surface_.MouseMove += OnMouseMove;

            TextFont_ = new Font("Arial", 10);

            FileHelper.AddSearchPath(Application.StartupPath + "/../../Res/");
            FileHelper.AddSearchPath(Application.StartupPath + "/../../../Res/");

            Device_ = RasterizerEngine.CreateDevice(WinForm_.Handle, Width, Height);
            Obj_    = new TestObject(Device_);
        }
Ejemplo n.º 2
0
        public void Run()
        {
            WinForm_.Show();

            var PreviousFrameTicks = 0L;
            var Watch = new Stopwatch();

            Watch.Start();

            while (!WinForm_.IsDisposed)
            {
                var CurrentFrameTicks = Watch.ElapsedTicks;
                DeltaTime_         = (CurrentFrameTicks - PreviousFrameTicks) / (double)Stopwatch.Frequency;
                PreviousFrameTicks = CurrentFrameTicks;

                MainLoop();
                Application.DoEvents();
            }

            RasterizerEngine.DestroyDevice(Device_);
        }