mirror of
https://github.com/gwm17/implot.git
synced 2024-11-22 18:28:53 -05:00
add UseGpuAcceleration
This commit is contained in:
commit
e4805f629b
|
@ -233,8 +233,8 @@ static void RenderCallback(const ImDrawList*, const ImDrawCmd* cmd)
|
|||
glUniform1f(data.ShaderProgram->AttribLocationMinValue, data.MinValue); // Set minimum range
|
||||
glUniform1f(data.ShaderProgram->AttribLocationMaxValue, data.MaxValue); // Set maximum range
|
||||
glUniform2i(data.ShaderProgram->AttribLocationAxisLog, data.AxisLogX, data.AxisLogY); // Logarithmic axis
|
||||
glUniform2f(data.ShaderProgram->AttribLocationMinBounds, data.MinBounds.x, data.MinBounds.y); // Set minimum bounds
|
||||
glUniform2f(data.ShaderProgram->AttribLocationMaxBounds, data.MaxBounds.x, data.MaxBounds.y); // Set maximum bounds
|
||||
glUniform2f(data.ShaderProgram->AttribLocationMinBounds, (float)data.MinBounds.x, (float)data.MinBounds.y); // Set minimum bounds
|
||||
glUniform2f(data.ShaderProgram->AttribLocationMaxBounds, (float)data.MaxBounds.x, (float)data.MaxBounds.y); // Set maximum bounds
|
||||
}
|
||||
|
||||
static void ResetState(const ImDrawList*, const ImDrawCmd*)
|
||||
|
|
11
implot.cpp
11
implot.cpp
|
@ -145,10 +145,16 @@ ImPlotStyle::ImPlotStyle() {
|
|||
|
||||
Colormap = ImPlotColormap_Deep;
|
||||
|
||||
AntiAliasedLines = false;
|
||||
UseLocalTime = false;
|
||||
Use24HourClock = false;
|
||||
UseISO8601 = false;
|
||||
|
||||
AntiAliasedLines = false;
|
||||
#ifdef IMPLOT_BACKEND_ENABLED
|
||||
UseGpuAacceleration = true;
|
||||
#else
|
||||
UseGpuAacceleration = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
ImPlotItem* ImPlotPlot::GetLegendItem(int i) {
|
||||
|
@ -3678,6 +3684,9 @@ void ShowStyleEditor(ImPlotStyle* ref) {
|
|||
float indent = ImGui::CalcItemWidth() - ImGui::GetFrameHeight();
|
||||
ImGui::Indent(ImGui::CalcItemWidth() - ImGui::GetFrameHeight());
|
||||
ImGui::Checkbox("AntiAliasedLines", &style.AntiAliasedLines);
|
||||
#ifdef IMPLOT_BACKEND_ENABLED
|
||||
ImGui::Checkbox("UseGpuAacceleration", &style.UseGpuAacceleration);
|
||||
#endif
|
||||
ImGui::Unindent(indent);
|
||||
ImGui::Text("Plot Styling");
|
||||
ImGui::SliderFloat("PlotBorderSize", &style.PlotBorderSize, 0.0f, 2.0f, "%.0f");
|
||||
|
|
3
implot.h
3
implot.h
|
@ -307,10 +307,11 @@ struct ImPlotStyle {
|
|||
// colormap
|
||||
ImPlotColormap Colormap; // The current colormap. Set this to either an ImPlotColormap_ enum or an index returned by AddColormap.
|
||||
// settings/flags
|
||||
bool AntiAliasedLines; // = false, enable global anti-aliasing on plot lines (overrides ImPlotFlags_AntiAliased)
|
||||
bool UseLocalTime; // = false, axis labels will be formatted for your timezone when ImPlotAxisFlag_Time is enabled
|
||||
bool UseISO8601; // = false, dates will be formatted according to ISO 8601 where applicable (e.g. YYYY-MM-DD, YYYY-MM, --MM-DD, etc.)
|
||||
bool Use24HourClock; // = false, times will be formatted using a 24 hour clock
|
||||
bool AntiAliasedLines; // = false, enable global anti-aliasing on plot lines (overrides ImPlotFlags_AntiAliased)
|
||||
bool UseGpuAacceleration; // = true*, GPU acceleration will be enabled where your backend supports it (*only true if a backend is enabled, false otherwise)
|
||||
IMPLOT_API ImPlotStyle();
|
||||
};
|
||||
|
||||
|
|
|
@ -1893,21 +1893,25 @@ void RenderHeatmap(Transformer transformer, ImDrawList& DrawList, const T* value
|
|||
const double yref = reverse_y ? bounds_max.y : bounds_min.y;
|
||||
const double ydir = reverse_y ? -1 : 1;
|
||||
#ifdef IMPLOT_BACKEND_HAS_HEATMAP
|
||||
ImVec2 bmin = transformer(bounds_min);
|
||||
ImVec2 bmax = transformer(bounds_max);
|
||||
ImPlotScale scale = GetCurrentScale();
|
||||
if (GImPlot->Style.UseGpuAacceleration) {
|
||||
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, reverse_y);
|
||||
Backend::SetAxisLog(gp.CurrentItem->ID,
|
||||
scale == ImPlotScale_LogLin || scale == ImPlotScale_LogLog,
|
||||
scale == ImPlotScale_LinLog || scale == ImPlotScale_LogLog,
|
||||
bounds_min, bounds_max);
|
||||
Backend::SetHeatmapData(gp.CurrentItem->ID, values, rows, cols);
|
||||
#else
|
||||
GetterHeatmap<T> 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);
|
||||
RenderPrimitives(RectRenderer<GetterHeatmap<T>, Transformer>(getter, transformer), DrawList, gp.CurrentPlot->PlotRect);
|
||||
// NOTE: Order is important!
|
||||
Backend::RenderHeatmap(gp.CurrentItem->ID, DrawList, bmin, bmax, (float)scale_min, (float)scale_max, gp.Style.Colormap, reverse_y);
|
||||
Backend::SetAxisLog(gp.CurrentItem->ID,
|
||||
scale == ImPlotScale_LogLin || scale == ImPlotScale_LogLog,
|
||||
scale == ImPlotScale_LinLog || scale == ImPlotScale_LogLog,
|
||||
bounds_min, bounds_max);
|
||||
Backend::SetHeatmapData(gp.CurrentItem->ID, values, rows, cols);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
GetterHeatmap<T> 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);
|
||||
RenderPrimitives(RectRenderer<GetterHeatmap<T>, Transformer>(getter, transformer), DrawList, gp.CurrentPlot->PlotRect);
|
||||
}
|
||||
if (fmt != NULL) {
|
||||
const double w = (bounds_max.x - bounds_min.x) / cols;
|
||||
const double h = (bounds_max.y - bounds_min.y) / rows;
|
||||
|
|
Loading…
Reference in New Issue
Block a user