diff --git a/backends/implot_impl_opengl3.cpp b/backends/implot_impl_opengl3.cpp index 9eb7e84..d572ead 100644 --- a/backends/implot_impl_opengl3.cpp +++ b/backends/implot_impl_opengl3.cpp @@ -53,8 +53,8 @@ struct HeatmapData HeatmapShader* ShaderProgram; ///< Shader to be used by this heatmap (either ShaderInt or ShaderFloat) GLuint HeatmapTexID; ///< Texture ID of the heatmap 2D texture GLuint ColormapTexID; ///< Texture ID of the colormap 1D texture - ImVec2 MinBounds; ///< Minimum bounds of the heatmap - ImVec2 MaxBounds; ///< Maximum bounds of the heatmap + ImPlotPoint MinBounds; ///< Minimum bounds of the heatmap + ImPlotPoint MaxBounds; ///< Maximum bounds of the heatmap float MinValue; ///< Minimum value of the colormap float MaxValue; ///< Maximum value of the colormap bool AxisLogX; ///< Whether the X axis is logarithmic or not @@ -332,19 +332,19 @@ void SetHeatmapData(int itemID, const ImU64* values, int rows, int cols) SetTextureData(itemID, Context.temp3.Data, rows, cols, GL_R32UI, GL_RED_INTEGER, GL_UNSIGNED_INT); } -void SetAxisLog(int itemID, bool x_is_log, bool y_is_log, const ImVec2& bounds_min, const ImVec2& bounds_max) +void SetAxisLog(int itemID, bool x_is_log, bool y_is_log, const ImPlotPoint& bounds_min, const ImPlotPoint& bounds_max) { ContextData& Context = *((ContextData*)GImPlot->backendCtx); int idx = Context.ItemIDs.GetInt(itemID, -1); HeatmapData& data = Context.HeatmapDataList[idx]; data.AxisLogX = x_is_log; - data.AxisLogY =y_is_log; + data.AxisLogY = y_is_log; data.MinBounds = bounds_min; data.MaxBounds = bounds_max; } -void RenderHeatmap(int itemID, ImDrawList& DrawList, const ImVec2& bounds_min, const ImVec2& bounds_max, float scale_min, float scale_max, ImPlotColormap colormap) +void RenderHeatmap(int itemID, ImDrawList& DrawList, const ImVec2& bounds_min, const ImVec2& bounds_max, float scale_min, float scale_max, ImPlotColormap colormap, bool reverse_y) { ContextData& Context = *((ContextData*)GImPlot->backendCtx); int idx = Context.ItemIDs.GetInt(itemID, Context.HeatmapDataList.Size); @@ -367,7 +367,7 @@ void RenderHeatmap(int itemID, ImDrawList& DrawList, const ImVec2& bounds_min, c DrawList.AddCallback(RenderCallback, (void*)(intptr_t)itemID); DrawList.PrimReserve(6, 4); - DrawList.PrimRectUV(bounds_min, bounds_max, ImVec2(0.0f, 1.0f), ImVec2(1.0f, 0.0f), 0); + DrawList.PrimRectUV(bounds_min, bounds_max, ImVec2(0.0f, reverse_y ? 1.0f : 0.0f), ImVec2(1.0f, reverse_y ? 0.0f : 1.0f), 0); DrawList.AddCallback(ResetState, nullptr); } diff --git a/backends/implot_impl_opengl3.h b/backends/implot_impl_opengl3.h index 8efbd52..34695cc 100644 --- a/backends/implot_impl_opengl3.h +++ b/backends/implot_impl_opengl3.h @@ -188,7 +188,7 @@ IMPLOT_API void SetHeatmapData(int itemID, const ImU64* values, int rows, int c */ IMPLOT_API void RenderHeatmap( int itemID, ImDrawList& DrawList, const ImVec2& bounds_min, const ImVec2& bounds_max, - float scale_min, float scale_max, ImPlotColormap colormap); + float scale_min, float scale_max, ImPlotColormap colormap, bool reverse_y); /** * @brief Set logarithmic axis @@ -202,7 +202,7 @@ IMPLOT_API void RenderHeatmap( * @param bounds_min Minimum bounds (for X & Y) of the heatmap * @param bounds_min Maximum bounds (for X & Y) of the heatmap */ -void SetAxisLog(int itemID, bool x_is_log, bool y_is_log, const ImVec2& bounds_min, const ImVec2& bounds_max); +void SetAxisLog(int itemID, bool x_is_log, bool y_is_log, const ImPlotPoint& bounds_min, const ImPlotPoint& bounds_max); } } diff --git a/implot_items.cpp b/implot_items.cpp index 7441066..c6d081a 100644 --- a/implot_items.cpp +++ b/implot_items.cpp @@ -1895,15 +1895,14 @@ void RenderHeatmap(Transformer transformer, ImDrawList& DrawList, const T* value #ifdef IMPLOT_BACKEND_HAS_HEATMAP ImVec2 bmin = transformer(bounds_min); ImVec2 bmax = transformer(bounds_max); - ImPlotScale scale = GetCurrentScale(); // NOTE: Order is important! - Backend::RenderHeatmap(gp.CurrentItem->ID, DrawList, bmin, bmax, scale_min, scale_max, gp.Style.Colormap); + Backend::RenderHeatmap(gp.CurrentItem->ID, DrawList, bmin, bmax, scale_min, scale_max, gp.Style.Colormap, reverse_y); Backend::SetAxisLog(gp.CurrentItem->ID, scale == ImPlotScale_LogLin || scale == ImPlotScale_LogLog, scale == ImPlotScale_LinLog || scale == ImPlotScale_LogLog, - ImVec2(bounds_min.x, bounds_min.y), ImVec2(bounds_max.x, bounds_max.y)); + bounds_min, bounds_max); Backend::SetHeatmapData(gp.CurrentItem->ID, values, rows, cols); #else GetterHeatmap getter(values, rows, cols, scale_min, scale_max, (bounds_max.x - bounds_min.x) / cols, (bounds_max.y - bounds_min.y) / rows, bounds_min.x, yref, ydir);