From d65e051a0769f69235a65cbb29ee38db5f71bc7c Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 11 Feb 2015 18:14:39 +0000 Subject: [PATCH] Minor formatting tweaks, comments --- examples/directx11_example/main.cpp | 8 ++++---- examples/directx9_example/main.cpp | 8 ++++---- examples/opengl3_example/main.cpp | 8 ++++---- examples/opengl_example/main.cpp | 8 ++++---- imgui.cpp | 2 ++ 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/examples/directx11_example/main.cpp b/examples/directx11_example/main.cpp index ce6fbb23..c07aa9ab 100644 --- a/examples/directx11_example/main.cpp +++ b/examples/directx11_example/main.cpp @@ -570,14 +570,14 @@ int WINAPI wWinMain(HINSTANCE hInst, HINSTANCE, LPWSTR, int) if (ImGui::Button("Another Window")) show_another_window ^= 1; // Calculate and show frame rate - static float ms_per_frame[120] = { 0 }; - static int ms_per_frame_idx = 0; + static int ms_per_frame_idx = 0; + static float ms_per_frame[60] = { 0 }; static float ms_per_frame_accum = 0.0f; ms_per_frame_accum -= ms_per_frame[ms_per_frame_idx]; ms_per_frame[ms_per_frame_idx] = ImGui::GetIO().DeltaTime * 1000.0f; ms_per_frame_accum += ms_per_frame[ms_per_frame_idx]; - ms_per_frame_idx = (ms_per_frame_idx + 1) % 120; - const float ms_per_frame_avg = ms_per_frame_accum / 120; + ms_per_frame_idx = (ms_per_frame_idx + 1) % 60; + const float ms_per_frame_avg = ms_per_frame_accum / 60; ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", ms_per_frame_avg, 1000.0f / ms_per_frame_avg); } diff --git a/examples/directx9_example/main.cpp b/examples/directx9_example/main.cpp index 1c5e630e..752e2570 100644 --- a/examples/directx9_example/main.cpp +++ b/examples/directx9_example/main.cpp @@ -336,14 +336,14 @@ int WINAPI wWinMain(HINSTANCE hInst, HINSTANCE, LPWSTR, int) if (ImGui::Button("Another Window")) show_another_window ^= 1; // Calculate and show frame rate - static float ms_per_frame[120] = { 0 }; - static int ms_per_frame_idx = 0; + static int ms_per_frame_idx = 0; + static float ms_per_frame[60] = { 0 }; static float ms_per_frame_accum = 0.0f; ms_per_frame_accum -= ms_per_frame[ms_per_frame_idx]; ms_per_frame[ms_per_frame_idx] = ImGui::GetIO().DeltaTime * 1000.0f; ms_per_frame_accum += ms_per_frame[ms_per_frame_idx]; - ms_per_frame_idx = (ms_per_frame_idx + 1) % 120; - const float ms_per_frame_avg = ms_per_frame_accum / 120; + ms_per_frame_idx = (ms_per_frame_idx + 1) % 60; + const float ms_per_frame_avg = ms_per_frame_accum / 60; ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", ms_per_frame_avg, 1000.0f / ms_per_frame_avg); } diff --git a/examples/opengl3_example/main.cpp b/examples/opengl3_example/main.cpp index 8ee8c8cb..a9a2716e 100644 --- a/examples/opengl3_example/main.cpp +++ b/examples/opengl3_example/main.cpp @@ -348,14 +348,14 @@ int main(int argc, char** argv) if (ImGui::Button("Another Window")) show_another_window ^= 1; // Calculate and show frame rate - static float ms_per_frame[120] = { 0 }; - static int ms_per_frame_idx = 0; + static int ms_per_frame_idx = 0; + static float ms_per_frame[60] = { 0 }; static float ms_per_frame_accum = 0.0f; ms_per_frame_accum -= ms_per_frame[ms_per_frame_idx]; ms_per_frame[ms_per_frame_idx] = ImGui::GetIO().DeltaTime * 1000.0f; ms_per_frame_accum += ms_per_frame[ms_per_frame_idx]; - ms_per_frame_idx = (ms_per_frame_idx + 1) % 120; - const float ms_per_frame_avg = ms_per_frame_accum / 120; + ms_per_frame_idx = (ms_per_frame_idx + 1) % 60; + const float ms_per_frame_avg = ms_per_frame_accum / 60; ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", ms_per_frame_avg, 1000.0f / ms_per_frame_avg); } diff --git a/examples/opengl_example/main.cpp b/examples/opengl_example/main.cpp index e589981f..b69507ec 100644 --- a/examples/opengl_example/main.cpp +++ b/examples/opengl_example/main.cpp @@ -257,14 +257,14 @@ int main(int argc, char** argv) if (ImGui::Button("Another Window")) show_another_window ^= 1; // Calculate and show frame rate - static float ms_per_frame[120] = { 0 }; - static int ms_per_frame_idx = 0; + static int ms_per_frame_idx = 0; + static float ms_per_frame[60] = { 0 }; static float ms_per_frame_accum = 0.0f; ms_per_frame_accum -= ms_per_frame[ms_per_frame_idx]; ms_per_frame[ms_per_frame_idx] = ImGui::GetIO().DeltaTime * 1000.0f; ms_per_frame_accum += ms_per_frame[ms_per_frame_idx]; - ms_per_frame_idx = (ms_per_frame_idx + 1) % 120; - const float ms_per_frame_avg = ms_per_frame_accum / 120; + ms_per_frame_idx = (ms_per_frame_idx + 1) % 60; + const float ms_per_frame_avg = ms_per_frame_accum / 60; ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", ms_per_frame_avg, 1000.0f / ms_per_frame_avg); } diff --git a/imgui.cpp b/imgui.cpp index f03b1ab1..e12d2611 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -956,6 +956,7 @@ struct ImGuiTextEditState static void RenderTextScrolledClipped(ImFont* font, float font_size, const char* text, ImVec2 pos_base, float width, float scroll_x); }; +// Data saved in imgui.ini file struct ImGuiIniData { char* Name; @@ -967,6 +968,7 @@ struct ImGuiIniData ~ImGuiIniData() { if (Name) { ImGui::MemFree(Name); Name = NULL; } } }; +// Main state for ImGui struct ImGuiState { bool Initialized;