コード例 #1
0
        public void Run()
        {
            long      previousFrameTicks = 0;
            Stopwatch sw = new Stopwatch();

            sw.Start();
            while (_window.Exists)
            {
                long   currentFrameTicks = sw.ElapsedTicks;
                double deltaSeconds      = (currentFrameTicks - previousFrameTicks) / (double)Stopwatch.Frequency;

                while (_limitFrameRate && deltaSeconds < _desiredFrameLengthSeconds)
                {
                    currentFrameTicks = sw.ElapsedTicks;
                    deltaSeconds      = (currentFrameTicks - previousFrameTicks) / (double)Stopwatch.Frequency;
                }

                previousFrameTicks = currentFrameTicks;

                InputSnapshot snapshot = null;
                Sdl2Events.ProcessEvents();
                snapshot = _window.PumpEvents();
                InputTracker.UpdateFrameInput(snapshot, _window);
                Update((float)deltaSeconds);
                if (!_window.Exists)
                {
                    break;
                }

                Draw();
            }

            DestroyAllObjects();
            _gd.Dispose();
        }
コード例 #2
0
 public void Run()
 {
     while (_window.Exists)
     {
         InputTracker.UpdateFrameInput(_window.PumpEvents());
         Update(1f / 60f);
         Draw();
     }
 }