ocornut / imgui

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
MIT License
59.47k stars 10.14k forks source link

Frame rate control for individual windows #7792

Open Augenstern-create opened 2 months ago

Augenstern-create commented 2 months ago

Version/Branch of Dear ImGui:

Version 1.90.1, Branch: docking

Back-ends:

imgui_impl_win32.cpp + imgui_impl_dx12.cpp

Compiler, OS:

MSVC 2022 + Windows10 x64

Full config/build information:

No response

Details:

My Issue/Question: I try to create two imgui sub-forms in Windows form ImGui::Begin1 ImGui::Begin2, ImGui::Begin2 Do not need too high frame rate, because it will waste extra resources, I want to control the frame rate of ImGui::Begin2 separately. The first attempt is to use the std::this_thread::sleep_for method to add a suitable delay when drawing, but this method will also affect the frame rate of ImGui::Begin1, and the second attempt is to add the if judgment. When the current frame rate exceeds the preset frame rate, the contents of ImGui::Begin2 will not be drawn, but this method will cause the problem of flickering drawn contents. I want to control the frame rate of ImGui::Begin2 subform separately without affecting the frame rate of ImGui::Begin1. How can I solve this problem?

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

// Here's some code anyone can copy and paste to reproduce your issue
ImGui::Begin("Example Bug");
MoreCodeToExplainMyIssue();
ImGui::End();
ocornut commented 2 months ago

Generally the right answer is "find a way to make Begin2 not costly". It is actually very slow / expensive ? Or you are just doing a theoretical optimization?

There is an undocumented feature SetNextWindowRefreshPolicy() (#3515) in imgui_internal.h, but honestly I am not sure this is a problem you need to solve this way.