From e966e0d2bc94a3d7d42c97e3f087ab99d436b61a Mon Sep 17 00:00:00 2001 From: Evan Pezent Date: Sun, 6 Jun 2021 16:03:41 -0700 Subject: [PATCH] add warning to demo about 16-bit indices --- README.md | 4 ++-- implot_demo.cpp | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index eb75ded..ea80b72 100644 --- a/README.md +++ b/README.md @@ -96,10 +96,10 @@ If you want to test ImPlot quickly, consider trying [mahi-gui](https://github.co ## Extremely Important Note -Dear ImGui uses **16-bit indexing by default**, so high-density ImPlot widgets like `ImPlot::PlotHeatmap()` may produce too many vertices into `ImDrawList`, which causes an assertion failure. This will result in data truncation and/or visual glitches. Therefore, it is **HIGHLY** recommended that you EITHER: +Dear ImGui uses **16-bit indexing by default**, so high-density ImPlot widgets like `ImPlot::PlotHeatmap()` may produce too many vertices into `ImDrawList`, which causes an assertion failure and will result in data truncation and/or visual glitches. Therefore, it is **HIGHLY** recommended that you EITHER: - **Option 1:** Enable 32-bit indices by uncommenting `#define ImDrawIdx unsigned int` in your ImGui [`imconfig.h`](https://github.com/ocornut/imgui/blob/master/imconfig.h#L89) file. -- **Option 2:** Handle the `ImGuiBackendFlags_RendererHasVtxOffset` flag in your renderer when using 16-bit indices and use an ImGui version with patch [imgui@f6120f8](https://github.com/ocornut/imgui/commit/f6120f8e16eefcdb37b63974e6915a3dd35414be). +- **Option 2:** Handle the `ImGuiBackendFlags_RendererHasVtxOffset` flag in your renderer if you must use 16-bit indices. Many of the default ImGui rendering backends already support `ImGuiBackendFlags_RendererHasVtxOffset`. Refer to [this issue](https://github.com/ocornut/imgui/issues/2591) for more information. ## FAQ diff --git a/implot_demo.cpp b/implot_demo.cpp index 53989df..8e0f2fb 100644 --- a/implot_demo.cpp +++ b/implot_demo.cpp @@ -221,6 +221,13 @@ void ShowDemoWindow(bool* p_open) { } //------------------------------------------------------------------------- ImGui::Text("ImPlot says hello. (%s)", IMPLOT_VERSION); + // display warning about 16-bit indices + if (sizeof(ImDrawIdx)*8 == 16 && (ImGui::GetIO().BackendFlags & ImGuiBackendFlags_RendererHasVtxOffset) == false) { + ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1,1,0,1)); + ImGui::TextWrapped("WARNING: ImDrawIdx is 16-bit and ImGuiBackendFlags_RendererHasVtxOffset is false. Expect visual glitches and artifacts! See README for more information."); + ImGui::PopStyleColor(); + } + ImGui::Spacing(); if (ImGui::CollapsingHeader("Help")) {