Going cpu idle / Redisplay when using glfwWaitEvents() in main loop? #1206

Closed
opened 2017-06-28 18:24:25 +00:00 by jdumas · 7 comments
jdumas commented 2017-06-28 18:24:25 +00:00 (Migrated from github.com)

Hi there,

I have a question about using ImGui + Glfw when the application is not permanently refreshed, i.e. when there is a glfwWaitEvents() in the main loop. Let's say we take the opengl3_example app, and add a glfwWaitEvents(); after L89.

Now, if you launch the app, the FPS is only updated when you move the mouse, which makes sense. However, if I click on the color picker (to switch between RGB/HSV/Hex), but don't move the move, then things are updated only when I move the mouse again.

I was wondering if it was a limitation of ImGui's immediate mode, a problem in the ColorEdit widget, or something more general that should be done in the glfw main loop of this example?

Hi there, I have a question about using ImGui + Glfw when the application is not permanently refreshed, i.e. when there is a `glfwWaitEvents()` in the main loop. Let's say we take the `opengl3_example` app, and add a `glfwWaitEvents();` after [L89](https://github.com/ocornut/imgui/blob/d3f4309491517a4412b6738063ded96f61fa020f/examples/opengl3_example/main.cpp#L89). Now, if you launch the app, the FPS is only updated when you move the mouse, which makes sense. However, if I click on the color picker (to switch between RGB/HSV/Hex), but don't move the move, then things are updated only when I move the mouse again. I was wondering if it was a limitation of ImGui's immediate mode, a problem in the ColorEdit widget, or something more general that should be done in the glfw main loop of this example?
ocornut commented 2017-06-28 18:32:34 +00:00 (Migrated from github.com)

Always update for 1-2 extra frames after mouse is moved and it should be ok.

Always update for 1-2 extra frames after mouse is moved and it should be ok.
ocornut commented 2017-06-28 19:32:46 +00:00 (Migrated from github.com)

To clarify, several types of actions incur a frame of delay. For example when you open a popup, the first frame is used for a dry run to compute an initial size for the popup.

Ideally, imgui should expose a flag/timer to express that sort of thing optimally and reliably, and also allow you to e.g. refresh on a cursor blink if you desire so (probably unlikely).

To clarify, several types of actions incur a frame of delay. For example when you open a popup, the first frame is used for a dry run to compute an initial size for the popup. Ideally, imgui should expose a flag/timer to express that sort of thing optimally and reliably, and also allow you to e.g. refresh on a cursor blink if you desire so (probably unlikely).
jdumas commented 2017-06-28 21:22:27 +00:00 (Migrated from github.com)

Thanks for the answer, I see your point. I'll to modify my main loop accordingly, even though it gets a bit more cumbersome to do so.

Thanks for the answer, I see your point. I'll to modify my main loop accordingly, even though it gets a bit more cumbersome to do so.
ocornut commented 2017-07-21 06:59:03 +00:00 (Migrated from github.com)

@jdumas Let me know if this is working out for now, and if the issue can be closed! Thanks.

@jdumas Let me know if this is working out for now, and if the issue can be closed! Thanks.
jdumas commented 2017-07-24 04:38:50 +00:00 (Migrated from github.com)

@ocornut Sure. Right now I'm refreshing the display constantly to make the UI is responsive. Would still be nice to have bool ImGui::NeedRedraw() callback or something.

@ocornut Sure. Right now I'm refreshing the display constantly to make the UI is responsive. Would still be nice to have `bool ImGui::NeedRedraw()` callback or something.
ocornut commented 2017-07-24 08:28:50 +00:00 (Migrated from github.com)

Why not just doing this in the meanwhile?

Always update for 1-2 extra frames after mouse is moved [or keyboard is pressed].

It should be a matter of just adding a counter on your side and resetting it on any input event.

Why not just doing this in the meanwhile? > Always update for 1-2 extra frames after mouse is moved [or keyboard is pressed]. It should be a matter of just adding a counter on your side and resetting it on any input event.
jdumas commented 2017-07-24 13:49:56 +00:00 (Migrated from github.com)

I just didn't get around to do that yet, since I have something that works already :p.
Feel free to close the issue if you like, and I'll reopen it if I have further questions =)

I just didn't get around to do that yet, since I have something that works already :p. Feel free to close the issue if you like, and I'll reopen it if I have further questions =)
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ocornut/imgui#1206
No description provided.