Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jdumas opened this issue Jun 28, 2017 · 7 comments
Closed

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

jdumas opened this issue Jun 28, 2017 · 7 comments
Labels

Comments

@jdumas
Copy link
Contributor

jdumas commented Jun 28, 2017

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?

@ocornut
Copy link
Owner

ocornut commented Jun 28, 2017

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

@ocornut
Copy link
Owner

ocornut commented Jun 28, 2017

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
Copy link
Contributor Author

jdumas commented Jun 28, 2017

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 ocornut changed the title Redisplay when using glfwWaitEvents() in main loop? Going cpu idle / Redisplay when using glfwWaitEvents() in main loop? Jul 1, 2017
@ocornut
Copy link
Owner

ocornut commented Jul 21, 2017

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

@jdumas
Copy link
Contributor Author

jdumas commented Jul 24, 2017

@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
Copy link
Owner

ocornut commented Jul 24, 2017

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
Copy link
Contributor Author

jdumas commented Jul 24, 2017

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 up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants