mirror of
https://github.com/gwm17/implot.git
synced 2024-11-22 18:28:53 -05:00
Backends: change header setup to avoid leaking backend implementation details into implot cpp files (#262)
This commit is contained in:
parent
e4805f629b
commit
4371c2d200
|
@ -25,25 +25,49 @@
|
|||
#pragma once
|
||||
|
||||
#if defined(IMPLOT_BACKEND_ENABLE_OPENGL3)
|
||||
#include "implot_impl_opengl3.h"
|
||||
#define IMPLOT_BACKEND_ENABLED
|
||||
#define IMPLOT_BACKEND_HAS_HEATMAP
|
||||
#define IMPLOT_BACKEND_HAS_COLORMAP
|
||||
#elif defined(IMPLOT_BACKEND_ENABLE_METAL)
|
||||
#include "implot_impl_metal.h"
|
||||
#endif
|
||||
|
||||
namespace ImPlot {
|
||||
namespace Backend {
|
||||
|
||||
#ifndef IMPLOT_BACKEND_ENABLED
|
||||
#ifdef IMPLOT_BACKEND_ENABLED
|
||||
void* CreateContext();
|
||||
void DestroyContext();
|
||||
void BustPlotCache();
|
||||
void BustItemCache();
|
||||
#else
|
||||
inline void* CreateContext() { return nullptr; }
|
||||
inline void DestroyContext() {}
|
||||
|
||||
inline void BustPlotCache() {}
|
||||
inline void BustItemCache() {}
|
||||
#endif
|
||||
|
||||
#ifndef IMPLOT_BACKEND_HAS_COLORMAP
|
||||
#ifdef IMPLOT_BACKEND_HAS_COLORMAP
|
||||
void AddColormap(const ImU32*, int, bool);
|
||||
#else
|
||||
inline void AddColormap(const ImU32*, int, bool) {}
|
||||
#endif
|
||||
|
||||
#ifdef IMPLOT_BACKEND_HAS_HEATMAP
|
||||
void SetHeatmapData(int itemID, const ImS16* values, int rows, int cols);
|
||||
void SetHeatmapData(int itemID, const ImS32* values, int rows, int cols);
|
||||
void SetHeatmapData(int itemID, const ImS64* values, int rows, int cols);
|
||||
void SetHeatmapData(int itemID, const ImS8* values, int rows, int cols);
|
||||
void SetHeatmapData(int itemID, const ImU16* values, int rows, int cols);
|
||||
void SetHeatmapData(int itemID, const ImU32* values, int rows, int cols);
|
||||
void SetHeatmapData(int itemID, const ImU64* values, int rows, int cols);
|
||||
void SetHeatmapData(int itemID, const ImU8* values, int rows, int cols);
|
||||
void SetHeatmapData(int itemID, const double* values, int rows, int cols);
|
||||
void SetHeatmapData(int itemID, const float* values, int rows, int cols);
|
||||
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);
|
||||
void SetAxisLog(int itemID, bool x_is_log, bool y_is_log, const ImPlotPoint& bounds_min, const ImPlotPoint& bounds_max);
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#ifdef IMPLOT_BACKEND_ENABLE_OPENGL3
|
||||
|
||||
#include "../implot.h"
|
||||
#include "../implot_internal.h"
|
||||
#include "implot_backend.h"
|
||||
|
@ -388,5 +386,3 @@ void BustItemCache() {}
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -24,10 +24,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#define IMPLOT_BACKEND_ENABLED
|
||||
#define IMPLOT_BACKEND_HAS_HEATMAP
|
||||
#define IMPLOT_BACKEND_HAS_COLORMAP
|
||||
|
||||
#if !defined(IMGUI_IMPL_OPENGL_ES2) \
|
||||
&& !defined(IMGUI_IMPL_OPENGL_ES3) \
|
||||
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GL3W) \
|
||||
|
@ -69,140 +65,3 @@
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
namespace ImPlot {
|
||||
namespace Backend {
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Misc backend functions
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @brief Struct to hold backend-related context data
|
||||
*
|
||||
* A backend may store in this struct any data it needs, with no constraints. A
|
||||
* pointer to this struct will be stored inside ImPlot's context and can be
|
||||
* accessed at any time. This pointer will be set to the returned value of @ref
|
||||
* CreateContext(). All resources held by this struct must be freed inside @ref
|
||||
* DestroyContext().
|
||||
*/
|
||||
struct ContextData;
|
||||
|
||||
/**
|
||||
* @brief Create backend context
|
||||
*
|
||||
* Creates and intializes the backend context. The returned pointer will be saved
|
||||
* in ImPlot's context and can be accessed later.
|
||||
*/
|
||||
IMPLOT_API void* CreateContext();
|
||||
|
||||
/**
|
||||
* @brief Destroy backend context
|
||||
*
|
||||
* Destroys and frees any memory or resources needed by the backend. After this
|
||||
* call returns, no more calls to any backend function can be performed.
|
||||
*/
|
||||
IMPLOT_API void DestroyContext();
|
||||
|
||||
/** @brief Bust plot cache. Called from @ref ImPlot::BustPlotCache() */
|
||||
IMPLOT_API void BustPlotCache();
|
||||
|
||||
/** @brief Bust item cache. Called from @ref ImPlot::BustItemCache() */
|
||||
IMPLOT_API void BustItemCache();
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Colormap functions
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @brief Add a colormap
|
||||
*
|
||||
* Adds a colormap to be handled by the backend.
|
||||
*
|
||||
* @param keys Colors for this colormap, in RGBA format
|
||||
* @param count Number of colors in this colormap
|
||||
* @param qual Qualitative: whether the colormap is continuous (`false`) or
|
||||
* not (`true`)
|
||||
*/
|
||||
IMPLOT_API void AddColormap(const ImU32* keys, int count, bool qual);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Heatmap functions
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @brief Set heatmap data
|
||||
*
|
||||
* Sets the data of the heatmap with the given plot ID.
|
||||
*
|
||||
* @param itemID ID of the heatmap to update.
|
||||
* @param values Data of the heatmap to be set.`values[0]` corresponds with the
|
||||
* top-left corner of the data.
|
||||
* @param rows Number of rows of this heatmap
|
||||
* @param cols Number of columns of this heatmap
|
||||
*/
|
||||
IMPLOT_API void SetHeatmapData(int itemID, const ImS8* values, int rows, int cols);
|
||||
|
||||
/** @copydoc SetHeatmapData(int,const ImU8*,int,int) */
|
||||
IMPLOT_API void SetHeatmapData(int itemID, const ImU8* values, int rows, int cols);
|
||||
|
||||
/** @copydoc SetHeatmapData(int,const ImS16*,int,int) */
|
||||
IMPLOT_API void SetHeatmapData(int itemID, const ImS16* values, int rows, int cols);
|
||||
|
||||
/** @copydoc SetHeatmapData(int,const ImU16*,int,int) */
|
||||
IMPLOT_API void SetHeatmapData(int itemID, const ImU16* values, int rows, int cols);
|
||||
|
||||
/** @copydoc SetHeatmapData(int,const ImS32*,int,int) */
|
||||
IMPLOT_API void SetHeatmapData(int itemID, const ImS32* values, int rows, int cols);
|
||||
|
||||
/** @copydoc SetHeatmapData(int,const ImU32*,int,int) */
|
||||
IMPLOT_API void SetHeatmapData(int itemID, const ImU32* values, int rows, int cols);
|
||||
|
||||
/** @copydoc SetHeatmapData(int,const float*,int,int) */
|
||||
IMPLOT_API void SetHeatmapData(int itemID, const float* values, int rows, int cols);
|
||||
|
||||
/** @copydoc SetHeatmapData(int,const double*,int,int) */
|
||||
IMPLOT_API void SetHeatmapData(int itemID, const double* values, int rows, int cols);
|
||||
|
||||
/** @copydoc SetHeatmapData(int,const ImS64*,int,int) */
|
||||
IMPLOT_API void SetHeatmapData(int itemID, const ImS64* values, int rows, int cols);
|
||||
|
||||
/** @copydoc SetHeatmapData(int,const ImU64*,int,int) */
|
||||
IMPLOT_API void SetHeatmapData(int itemID, const ImU64* values, int rows, int cols);
|
||||
|
||||
/**
|
||||
* @brief Render heatmap
|
||||
*
|
||||
* Renders the heatmap using OpenGL acceleration
|
||||
*
|
||||
* @param itemID ID of the heatmap to be rendered
|
||||
* @param DrawList Draw list where to submit the render commands
|
||||
* @param bounds_min Minimum bounds of the heatmap (without clipping)
|
||||
* @param bounds_max Maximum bounds of the heatmap (without clipping)
|
||||
* @param scale_min Minimum value of the heatmap
|
||||
* @param scale_max Maximum value of the heatmap
|
||||
* @param colormap Colormap to be used when rendering this heatmap
|
||||
*
|
||||
* @note There might be values greater than `scale_max` or lower than `scale_min`.
|
||||
* The shader used for rendering will clamp this values.
|
||||
*/
|
||||
IMPLOT_API 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);
|
||||
|
||||
/**
|
||||
* @brief Set logarithmic axis
|
||||
*
|
||||
* Sets whether the X and Y axis are logarithmic or not, and their bounds. This
|
||||
* function only has to be called if either the axis change state or if the bounds
|
||||
* change.
|
||||
*
|
||||
* @param x_is_log Whether the X axis is logarithmic or not
|
||||
* @param y_is_log Whether the Y axis is logarithmic or not
|
||||
* @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 ImPlotPoint& bounds_min, const ImPlotPoint& bounds_max);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user