From 4125be49f916c3cfbf1f3173b8bd99887bbbd6ea Mon Sep 17 00:00:00 2001 From: Bruno Cabral Date: Mon, 21 Apr 2025 13:10:50 -0700 Subject: [PATCH] some fixes to make the demos compile or work properly benchmak needs https://github.com/epezent/implot/pull/619 solution to work --- common/App.cpp | 3 +++ demos/filter.cpp | 2 +- demos/maps.cpp | 6 +++--- tests/benchmark.cpp | 8 +++++--- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/common/App.cpp b/common/App.cpp index 3f18023..1aa57cb 100644 --- a/common/App.cpp +++ b/common/App.cpp @@ -12,6 +12,9 @@ #if defined(_WIN32) extern "C" __declspec(dllexport) unsigned long NvOptimusEnablement = 0; extern "C" __declspec(dllexport) unsigned long AmdPowerXpressRequestHighPerformance = 0; +#else + unsigned long NvOptimusEnablement = 0; + unsigned long AmdPowerXpressRequestHighPerformance = 0; #endif void StyeColorsApp() diff --git a/demos/filter.cpp b/demos/filter.cpp index c5628de..06adeeb 100644 --- a/demos/filter.cpp +++ b/demos/filter.cpp @@ -70,7 +70,7 @@ struct ImFilter : public App { ImGui::SetNextWindowPos(ImVec2(0,0), ImGuiCond_Always); ImGui::SetNextWindowSize(GetWindowSize(), ImGuiCond_Always); ImGui::Begin("Filter",nullptr, ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoTitleBar); - ImGui::BeginChild("ChildL", ImVec2(ImGui::GetWindowContentRegionWidth() * 0.5f, -1)); + ImGui::BeginChild("ChildL", ImVec2(ImGui::GetWindowWidth() * 0.5f, -1)); ImGui::Text("Input: x(t) = A1*sin(2*pi*F1*t) + A2*sin(2*pi*F1*t) + noise"); ImGui::Separator(); diff --git a/demos/maps.cpp b/demos/maps.cpp index 89840b5..65a4029 100644 --- a/demos/maps.cpp +++ b/demos/maps.cpp @@ -273,7 +273,7 @@ class TileManager { long rc = 0; curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &rc); if (!((rc == 200 || rc == 201) && rc != CURLE_ABORTED_BY_CALLBACK)) - printf("TileManager[%02d]: Response code: %d\n",thrd,rc); + printf("TileManager[%02d]: Response code: %ld\n",thrd,rc); fs::remove(coord.path()); success = false; } @@ -319,7 +319,7 @@ struct ImMaps : public App { void Update() override { static int renders = 0; static bool debug = false; - if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_A))) + if (ImGui::IsKeyPressed(ImGuiKey_A)) debug = !debug; ImGui::SetNextWindowPos({0,0}); @@ -355,7 +355,7 @@ struct ImMaps : public App { auto [bmin,bmax] = coord.bounds(); if (tile != nullptr) { auto col = debug ? ((coord.x % 2 == 0 && coord.y % 2 != 0) || (coord.x % 2 != 0 && coord.y % 2 == 0))? ImVec4(1,0,1,1) : ImVec4(1,1,0,1) : ImVec4(1,1,1,1); - ImPlot::PlotImage("##Tiles",(void*)(intptr_t)tile->image.ID,bmin,bmax,{0,0},{1,1},col); + ImPlot::PlotImage("##Tiles",tile->image.ID,bmin,bmax,{0,0},{1,1},col); } if (debug) ImPlot::PlotText(coord.label().c_str(),(bmin.x+bmax.x)/2,(bmin.y+bmax.y)/2); diff --git a/tests/benchmark.cpp b/tests/benchmark.cpp index cb3aae2..62e9d47 100644 --- a/tests/benchmark.cpp +++ b/tests/benchmark.cpp @@ -580,7 +580,7 @@ struct ImPlotBench : App running = false; run_t2 = Clock::now(); size_t run_span = (size_t)std::chrono::duration_cast(run_t2 - run_t1).count(); - printf("Run completed in %u us (%.3f s)\n", run_span, run_span / 1000000.0f); + printf("Run completed in %zu us (%.3f s)\n", run_span, run_span / 1000000.0f); } } } @@ -645,7 +645,7 @@ struct ImPlotBench : App } ImGui::SameLine(); static char start_str[32]; - sprintf(start_str, running ? "Stop (%u)" : "Start (%u)", m_queue.size()); + sprintf(start_str, running ? "Stop (%zu)" : "Start (%zu)", m_queue.size()); if (ImGui::Button(start_str, ImVec2(-1, 0))) { running = !running; @@ -747,10 +747,12 @@ struct ImPlotBench : App ImPlot::SetupAxis(ImAxis_Y1, "Time [ms]"); ImPlot::SetupAxesLimits(0, kMaxElems, 0, 50); ImPlot::SetupAxisFormat(ImAxis_X1, fmtr); - ImPlot::SetupAxisLimits(ImAxis_Y2, 0, 500, ImPlotCond_Once); ImPlot::SetupLegend(ImPlotLocation_East, ImPlotLegendFlags_Outside); if (show_fps) + { ImPlot::SetupAxis(ImAxis_Y2, "FPS [Hz]", ImPlotAxisFlags_Opposite); + ImPlot::SetupAxisLimits(ImAxis_Y2, 0, 500, ImPlotCond_Once); + } for (auto &collection : m_records[selected_branch]) {