From e72ba1732d33721f4b67cc27ef9a275b6e30ddde Mon Sep 17 00:00:00 2001 From: Sukhoverkhaya <90982979+Sukhoverkhaya@users.noreply.github.com> Date: Wed, 19 Feb 2025 23:52:00 +0300 Subject: [PATCH] Added an option to use `WaitEvents()` instead of `PollEvents()` (#166) * added an option for using WaitEvents() instead of PullEvents() * new kwarg documented * add changelog and bump version * fix changelog * fix pr number in changelog * fix changelog and documentation --- Project.toml | 2 +- docs/src/_changelog.md | 6 ++++++ ext/GlfwOpenGLBackend.jl | 5 +++-- src/CImGui.jl | 2 ++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index 7e5cf40..3e041da 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "CImGui" uuid = "5d785b6c-b76f-510e-a07c-3070796c7e87" authors = ["Yupei Qi "] -version = "5.0.1" +version = "5.1.0" [deps] CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82" diff --git a/docs/src/_changelog.md b/docs/src/_changelog.md index 5937352..339b882 100644 --- a/docs/src/_changelog.md +++ b/docs/src/_changelog.md @@ -6,6 +6,12 @@ CurrentModule = CImGui This documents notable changes in CImGui.jl. The format is based on [Keep a Changelog](https://keepachangelog.com). +## [v5.1.0] - 2025-02-19 + +### Added +- Added an option to call WaitEvents() instead of PollEvents() in render loop ([#166]). + You can use it by passing keyword argument `wait_events=true` in function [`render()`](@ref) + ## [v5.0.1] - 2025-02-17 ### Changed diff --git a/ext/GlfwOpenGLBackend.jl b/ext/GlfwOpenGLBackend.jl index 6bcee85..585f9b3 100644 --- a/ext/GlfwOpenGLBackend.jl +++ b/ext/GlfwOpenGLBackend.jl @@ -60,7 +60,8 @@ function renderloop(ui, ctx::Ptr{lib.ImGuiContext}, ::Val{:GlfwOpenGL3}; window_size=(1280, 720), window_title="CImGui", engine=nothing, - opengl_version=v"3.2") + opengl_version=v"3.2", + wait_events=false) # Validate arguments if clear_color isa Ref && !isassigned(clear_color) throw(ArgumentError("'clear_color' is a unassigned reference, it must be initialized properly.")) @@ -98,7 +99,7 @@ function renderloop(ui, ctx::Ptr{lib.ImGuiContext}, ::Val{:GlfwOpenGL3}; try while !GLFW.WindowShouldClose(window) - GLFW.PollEvents() + wait_events ? GLFW.WaitEvents() : GLFW.PollEvents() # Start the Dear ImGui frame lib.ImGui_ImplOpenGL3_NewFrame() diff --git a/src/CImGui.jl b/src/CImGui.jl index e07556c..f129464 100644 --- a/src/CImGui.jl +++ b/src/CImGui.jl @@ -197,6 +197,8 @@ Keyword arguments: any tests registered with the test engine they will be queued and run automatically. - `opengl_version::VersionNumber=v"3.2"`: The OpenGL version to use. +- `wait_events=false`: Set to `true` to call `GLFW.WaitEvents()` instead of + `GLFW.PollEvents()` (only supported for the GLFW/OpenGL backend). - `spawn::Union{Bool, Integer, Symbol}=1`: How/where to spawn the renderloop. It defaults to thread 1 for safety, but note that currently Julia also uses thread 1 to run the libuv event loop: