Original Post
Can anyone offer an explanation on the difference between the different game loops such as OnPaint vs OnIdle, or link to an article that does? Thanks.
Quote:
Simple, elegant, effective. No extra allocations, no extra collections, it just works
internal sealed class NativeMethods{ [StructLayout(LayoutKind.Sequential)] public struct Message { public IntPtr hWnd; public IntPtr msg; public IntPtr wParam; public IntPtr lParam; public uint time; public System.Drawing.Point p; } [System.Security.SuppressUnmanagedCodeSecurity] [DllImport("User32.dll", CharSet = CharSet.Auto)] public static extern bool PeekMessage(out Message msg, IntPtr hWnd, uint messageFilterMin, uint messageFilterMax, uint flags);}public sealed class Window: Form{ #region members private Game game; #endregion #region properties public bool AppStillIdle { get { NativeMethods.Message msg; return !NativeMethods.PeekMessage(out msg, IntPtr.Zero, 0, 0, 0); } } #endregion #region methods public Window(DeviceSettings settings) { game= new game(settings, this); Application.Idle += new EventHandler(OnApplicationIdle); } public void OnApplicationIdle(object sender, EventArgs e) { while (AppStillIdle) { } } internal void Run() { Application.Run(this); } #endregion}This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more