Skip to content

Commit

Permalink
Added an option to use WaitEvents() instead of PollEvents() (#166)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Sukhoverkhaya authored Feb 19, 2025
1 parent 1b33891 commit e72ba17
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "CImGui"
uuid = "5d785b6c-b76f-510e-a07c-3070796c7e87"
authors = ["Yupei Qi <[email protected]>"]
version = "5.0.1"
version = "5.1.0"

[deps]
CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82"
Expand Down
6 changes: 6 additions & 0 deletions docs/src/_changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions ext/GlfwOpenGLBackend.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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."))
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions src/CImGui.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

2 comments on commit e72ba17

@JamesWrigley
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/125450

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v5.1.0 -m "<description of version>" e72ba1732d33721f4b67cc27ef9a275b6e30ddde
git push origin v5.1.0

Please sign in to comment.