pthom / hello_imgui

Hello, Dear ImGui: unleash your creativity in app development and prototyping
https://pthom.github.io/hello_imgui
MIT License
606 stars 91 forks source link

Dynamic FPS #22

Closed ConcurrentState closed 1 year ago

ConcurrentState commented 1 year ago

Hello phtom,

thanks for hello imgui.

My project could benefit from having a parameter for FPS. I do not need full FPS all the time. Would be good on accu powered devices or when having other resource hungry apps running, to lower the FPS when not needed. Since imgui has the trickling input queue, this could be possible, I think. What do you think about a parameter for FPS, which the app can set dynamically at runtime?

Best regards

pthom commented 1 year ago

Hello,

This is a somewhat difficult subject.

HelloImGui can include a specific mode for power save, which will reduce the FPS when not in use. It is based on a PR to imgui https://github.com/ocornut/imgui/pull/4076 that was not accepted in the main ImGui repo. Furthermore, I had to rebase this PR onto the docking branch.

So, this feature is quite advanced, and I cannot guarantee that the API for it will be stable in the HelloImGui repo.

However, if you want to try it, the usage would be:

  1. Clone my fork of imgui that includes this PR, rebased on the docking branch: https://github.com/pthom/imgui/tree/docking_powersave

  2. Tell HelloImGui to use this version of imgui and to use the power save mode:

    cmake .. -DHELLOIMGUI_USE_POWERSAVE=IN -DHELLOIMGUI_BUILD_IMGUI=OFF -DHELLOIMGUI_IMGUI_SOURCE_DIR=path/to/imgui/fork 

https://github.com/pthom/hello_imgui/blob/master/CMakeLists.txt#L36

This mode works only with SDL and GLFW.

Best of luck !

pthom commented 1 year ago

Note : it is likely that I will work on this subject in the near future in order to build a more consistent API for this.

ConcurrentState commented 1 year ago

That would be very much appreciated. 👍🏼 This topic is not on top of my prioritylist, but sooner or later I will have to deal with it anyway.

pthom commented 1 year ago

Hi,

The latest version includes support for FPS throttling.

See https://github.com/pthom/hello_imgui/blob/master/src/hello_imgui/hello_imgui_api.md#runnerparams

ConcurrentState commented 1 year ago

Hello.

Awesome! Very much appreciated. Will prob. start a development based on this in 01/2023.

Many tanks once again for this project.

Cheers!