using StgSharp; using StgSharp.Logic; using System; using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; namespace StgSharp.Graphics { public partial class Form { private bool isFullyRendered = false; internal class FrameUpdateTimer { internal Bool2 alignSign; private float frameLength; private double frameBegin; private bool refreshed; private Counter tickCounter; public double timeAfterFrame { get { return InternalIO.glfwGetTime() - frameBegin; } } public uint totalFrame { get { return tickCounter; } } internal void Refresh() { refreshed = false; } internal bool WaitNextFrame() { try { while (refreshed) { } refreshed = true; return true; } catch (Exception ex) { InternalIO.InternalWriteLog(ex.Message, LogType.Error); return false; } } } } /// /// A timer counting frames after its construction. /// public class FrameTimer { internal readonly uint bornTick; private Form timeProvider; public FrameTimer(Form provaider) { timeProvider = provaider; bornTick = timeProvider.timer.totalFrame; } /// /// Frames after this timer created. /// public uint Time { get { return timeProvider.timer.totalFrame - bornTick; } } /// /// Convert a into uint value. /// this will get total frames since the timer was created. /// /// to be converted [MethodImpl(MethodImplOptions.AggressiveInlining)] public static implicit operator uint(FrameTimer timer) { return timer.Time; } } }