Exemplo n.º 1
0
        private void MainLoop()
        {
            while (!Glfw3.WindowShouldClose(this.window))
            {
                this.DrawFrame();

                Glfw3.PollEvents();
            }
        }
Exemplo n.º 2
0
        public void Update()
        {
            Glfw3.PollEvents();

            if (Glfw3.WindowShouldClose(this.WindowHandle))
            {
                this.game.SignalStop();
            }

            this.IsResized = this.isResizeSignalled;

            this.isResizeSignalled = false;
        }
Exemplo n.º 3
0
        /// <summary>
        /// main window loop, exits on GLFW3 exit event. Before entering the rendering loop, the following methods are called:
        /// - initVulkan (device, queues and swapchain creations).
        /// - OnResize (create there your frame buffers couple to the swapchain and trigger the recording of your command buffers for the presentation.
        /// - UpdateView (generaly used when the camera setup has changed to update MVP matrices)
        /// The rendering loop consist of the following steps:
        /// - render (the default one will submit the default command buffers to the presentQueue and trigger a queue present for each swapchain images.
        /// - if the `updateViewRequested` field is set to 'true', call the `UpdateView` method.
        /// - frame counting and chrono.
        /// - if elapsed time reached `UpdateFrequency` value, the `Update` method is called and the elapsed time chrono is reseet.
        /// - GLFW events are polled at the end of the loop.
        /// </summary>
        public virtual void Run()
        {
            initVulkan();

            OnResize();
            UpdateView();

            frameChrono = Stopwatch.StartNew();
            long totTime = 0;

            while (!Glfw3.WindowShouldClose(hWin))
            {
                render();

                if (updateViewRequested)
                {
                    UpdateView();
                }

                frameCount++;

                if (frameChrono.ElapsedMilliseconds > UpdateFrequency)
                {
                    Update();

                    frameChrono.Stop();
                    totTime += frameChrono.ElapsedMilliseconds;
                    fps      = (uint)((double)frameCount / (double)totTime * 1000.0);
                    Glfw3.SetWindowTitle(hWin, "FPS: " + fps.ToString());
                    if (totTime > 2000)
                    {
                        frameCount = 0;
                        totTime    = 0;
                    }
                    frameChrono.Restart();
                }
                Glfw3.PollEvents();
            }
        }
Exemplo n.º 4
0
        private unsafe void Run()
        {
            var extensions = Instance.EnumerateExtensionProperties(null);

            var instance = Instance.Create(null, Glfw3.GetRequiredInstanceExtensions());

            var device = instance.EnumeratePhysicalDevices().First().CreateDevice(new DeviceQueueCreateInfo {
                QueueFamilyIndex = 0, QueuePriorities = new[] { 0f }
            }, null, null);

            device.GetQueue(0, 0);

            try
            {
                Glfw3.Init();

                using (var window = new Window(1920, 1080, "Test"))
                {
                    SetCallbacks(window);

                    while (!window.ShouldClose)
                    {
                        Glfw3.PollEvents();
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.ReadLine();
            }
            finally
            {
                Glfw3.Terminate();
            }
        }
Exemplo n.º 5
0
        public void Render()
        {
            this.DrawFrame();

            Glfw3.PollEvents();
        }
Exemplo n.º 6
0
 public void AlwaysRun()
 {
     Glfw3.PollEvents();
 }