コード例 #1
0
        /// <summary>
        /// Infinitely renders the over (and execute co-routines) till it's closed.
        /// </summary>
        public static void RunInfiniteLoop()
        {
            DateTime previous = DateTime.Now;
            DateTime current;
            TimeSpan interval;
            float    sec;

            while (window.Exists && !Close)
            {
                InputSnapshot snapshot = window.PumpEvents();
                if (!window.Exists)
                {
                    break;
                }
                current  = DateTime.Now;
                interval = current - previous;
                sec      = (float)interval.TotalSeconds;
                previous = current;
                imController.Update(sec > 0 ? sec : 0.001f, snapshot, window.Handle);
                CoroutineHandler.Tick(interval.TotalSeconds);
                if (Visible)
                {
                    CoroutineHandler.RaiseEvent(OnRender);
                }

                commandList.Begin();
                commandList.SetFramebuffer(graphicsDevice.MainSwapchain.Framebuffer);
                commandList.ClearColorTarget(0, new RgbaFloat(clearColor.X, clearColor.Y, clearColor.Z, clearColor.W));
                imController.Render(graphicsDevice, commandList);
                commandList.End();
                graphicsDevice.SubmitCommands(commandList);
                graphicsDevice.SwapBuffers(graphicsDevice.MainSwapchain);
            }

            Dispose();
        }
コード例 #2
0
        /// <summary>
        /// Infinite While Loop to render the ImGui.
        /// </summary>
        private void WhileLoop()
        {
            while (window.Exists)
            {
                if (requireResize)
                {
                    Sdl2Native.SDL_SetWindowPosition(window.SdlWindowHandle, (int)futurePos.X, (int)futurePos.Y);
                    Sdl2Native.SDL_SetWindowSize(window.SdlWindowHandle, (int)futureSize.X, (int)futureSize.Y);
                    window.PumpEvents();
                    continue;
                }

                if (!window.Visible)
                {
                    window.PumpEvents();
                    Thread.Sleep(10);
                    continue;
                }

                hookController.PopMessages();
                if (!window.Exists)
                {
                    break;
                }

                imController.InitlizeFrame(1f / myFps);
                this.SubmitUI?.Invoke(this, new EventArgs());
                commandList.Begin();
                commandList.SetFramebuffer(graphicsDevice.MainSwapchain.Framebuffer);
                commandList.ClearColorTarget(0, new RgbaFloat(clearColor.X, clearColor.Y, clearColor.Z, clearColor.W));
                imController.Render(graphicsDevice, commandList);
                commandList.End();
                graphicsDevice.SubmitCommands(commandList);
                graphicsDevice.SwapBuffers(graphicsDevice.MainSwapchain);
            }
        }