private void RenderLoop() { MakeCurrent(); Stopwatch chrono = new Stopwatch(); chrono.Start(); long ticksPerFrame = Stopwatch.Frequency / TargetFps; long ticks = 0; while (Exists && !IsExiting) { if (_device.WaitFifo()) { _device.ProcessFrame(); } _renderer.RunActions(); if (_resizeEvent) { _resizeEvent = false; _renderer.RenderTarget.SetWindowSize(Width, Height); } ticks += chrono.ElapsedTicks; chrono.Restart(); if (ticks >= ticksPerFrame) { RenderFrame(); // Queue max. 1 vsync ticks = Math.Min(ticks - ticksPerFrame, ticksPerFrame); } } }
private void RenderLoop() { MakeCurrent(); Stopwatch Chrono = new Stopwatch(); Chrono.Start(); long TicksPerFrame = Stopwatch.Frequency / TargetFPS; long Ticks = 0; while (Exists && !IsExiting) { if (Ns.WaitFifo()) { Ns.ProcessFrame(); } Renderer.RunActions(); if (ResizeEvent) { ResizeEvent = false; Renderer.FrameBuffer.SetWindowSize(Width, Height); } Ticks += Chrono.ElapsedTicks; Chrono.Restart(); if (Ticks >= TicksPerFrame) { RenderFrame(); //Queue max. 1 vsync Ticks = Math.Min(Ticks - TicksPerFrame, TicksPerFrame); } } }