From 11a7084b909c94ee220aa7433ddc7a20b7b9dcd9 Mon Sep 17 00:00:00 2001 From: Evan Pezent Date: Sat, 3 Jul 2021 11:46:29 -0700 Subject: [PATCH] add ImGuiDataTypeGetter --- implot_items.cpp | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/implot_items.cpp b/implot_items.cpp index 8ca84d9..25c3de3 100644 --- a/implot_items.cpp +++ b/implot_items.cpp @@ -56,6 +56,26 @@ namespace ImPlot { +// Calculates maximum index size of ImDrawIdx without integer overflow issues +template +struct MaxIdx { static const unsigned int Value; }; +template <> const unsigned int MaxIdx::Value = 65535; +template <> const unsigned int MaxIdx::Value = 4294967295; + +// Gets ImGuiDataType for T +template +struct ImGuiDataTypeGetter { static const ImGuiDataType Value; }; +template <> const ImGuiDataType ImGuiDataTypeGetter::Value = ImGuiDataType_Float; +template <> const ImGuiDataType ImGuiDataTypeGetter::Value = ImGuiDataType_Double; +template <> const ImGuiDataType ImGuiDataTypeGetter::Value = ImGuiDataType_U8; +template <> const ImGuiDataType ImGuiDataTypeGetter::Value = ImGuiDataType_S8; +template <> const ImGuiDataType ImGuiDataTypeGetter::Value = ImGuiDataType_U16; +template <> const ImGuiDataType ImGuiDataTypeGetter::Value = ImGuiDataType_S16; +template <> const ImGuiDataType ImGuiDataTypeGetter::Value = ImGuiDataType_U32; +template <> const ImGuiDataType ImGuiDataTypeGetter::Value = ImGuiDataType_S32; +template <> const ImGuiDataType ImGuiDataTypeGetter::Value = ImGuiDataType_U64; +template <> const ImGuiDataType ImGuiDataTypeGetter::Value = ImGuiDataType_S64; + //----------------------------------------------------------------------------- // Item Utils //----------------------------------------------------------------------------- @@ -697,12 +717,6 @@ struct ShadedRenderer { static const int VtxConsumed = 5; }; -// Stupid way of calculating maximum index size of ImDrawIdx without integer overflow issues -template -struct MaxIdx { static const unsigned int Value; }; -template <> const unsigned int MaxIdx::Value = 65535; -template <> const unsigned int MaxIdx::Value = 4294967295; - /// Renders primitive shapes in bulk as efficiently as possible. template inline void RenderPrimitives(const Renderer& renderer, ImDrawList& DrawList, const ImRect& cull_rect) {