From d0cb042ff4b5fbf795de1feff4d8de73d3d41ff1 Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Mon, 25 Jun 2018 23:48:28 -0300 Subject: [PATCH] Naive limiter, VSync disabled --- Ryujinx/Ui/GLScreen.cs | 39 +++++++++++++++++++++++++++++++++++---- Ryujinx/Ui/Program.cs | 2 +- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/Ryujinx/Ui/GLScreen.cs b/Ryujinx/Ui/GLScreen.cs index ab5eaa0f52..67cea2c6b1 100644 --- a/Ryujinx/Ui/GLScreen.cs +++ b/Ryujinx/Ui/GLScreen.cs @@ -5,6 +5,7 @@ using Ryujinx.Graphics.Gal; using Ryujinx.HLE; using Ryujinx.HLE.Input; using System; +using Stopwatch = System.Diagnostics.Stopwatch; namespace Ryujinx { @@ -38,14 +39,44 @@ namespace Ryujinx (DisplayDevice.Default.Height / 2) - (Height / 2)); } - protected override void OnLoad(EventArgs e) + public void MainLoop() { - VSync = VSyncMode.On; + Load(); + + Visible = true; + + Stopwatch Chrono = new Stopwatch(); + + Chrono.Start(); + + long TicksPerFrame = Stopwatch.Frequency / 60; + + while (Exists && !IsExiting) + { + ProcessEvents(); + + if (!IsExiting) + { + if (Chrono.ElapsedTicks > TicksPerFrame) + { + UpdateFrame(); + + RenderFrame(); + + Chrono.Restart(); + } + } + } + } + + private new void Load() + { + //VSync = VSyncMode.On; Renderer.FrameBuffer.SetWindowSize(Width, Height); } - protected override void OnUpdateFrame(FrameEventArgs e) + private new void UpdateFrame() { HidControllerButtons CurrentButton = 0; HidJoystickPosition LeftJoystick; @@ -185,7 +216,7 @@ namespace Ryujinx Renderer.RunActions(); } - protected override void OnRenderFrame(FrameEventArgs e) + private new void RenderFrame() { Renderer.FrameBuffer.Render(); diff --git a/Ryujinx/Ui/Program.cs b/Ryujinx/Ui/Program.cs index b14897695d..5cacc6228b 100644 --- a/Ryujinx/Ui/Program.cs +++ b/Ryujinx/Ui/Program.cs @@ -67,7 +67,7 @@ namespace Ryujinx Screen.Exit(); }; - Screen.Run(0.0, 60.0); + Screen.MainLoop(); } Environment.Exit(0);