Better bound finding

This commit is contained in:
Vicente Ferrari Smith 2024-12-18 17:38:16 +01:00
parent ce61ac812d
commit 74525e08ac

View File

@ -25,16 +25,15 @@ draw_plot :: (key: string, size: Vector2, xdata: []float64, yarrays: [][]float64
if data_style == .ONCE {
plot.xfloat = NewArray(xdata.count, float);
for xdata {
plot.xfloat[it_index] = cast(float) it;
}
plot.xmin = 0.0;
plot.xmax = 0.0;
x_acc : float;
for xdata {
plot.xfloat[it_index] = cast(float) it;
plot.xfloat[it_index] = cast(float) it;
if it > plot.xmax plot.xmax = xx it;
if it < plot.xmin plot.xmin = xx it;
@ -88,16 +87,14 @@ draw_plot :: (key: string, size: Vector2, xdata: []float64, yarrays: [][]float64
if data_style == .EVERY_FRAME {
plot.xfloat = NewArray(xdata.count, float);
for xdata {
plot.xfloat[it_index] = cast(float) it;
}
plot.xmin = 0.0;
plot.xmax = 0.0;
plot.xmin = FLOAT32_MAX;
plot.xmax = -FLOAT32_MAX;
x_acc : float;
for xdata {
plot.xfloat[it_index] = cast(float) it;
if it > plot.xmax plot.xmax = xx it;
if it < plot.xmin plot.xmin = xx it;
@ -145,12 +142,15 @@ draw_plot :: (key: string, size: Vector2, xdata: []float64, yarrays: [][]float64
}
}
ImGui.RadioButton("Tick marks", xx *plot.plot_style, 0); ImGui.SameLine();
ImGui.RadioButton("Tick marks", xx *plot.plot_style, 0);
ImGui.SameLine();
ImGui.RadioButton("Scale marker", xx *plot.plot_style, 1);
child_size := ImGui.GetContentRegionAvail();
child_size.y = 260;
child_pos := ImGui.GetCursorScreenPos();
if ImGui.BeginChild(key.data, child_size, ImGui.ChildFlags.None, ImGui.WindowFlags.HorizontalScrollbar) {
if plot.plot_style == {
@ -163,7 +163,9 @@ draw_plot :: (key: string, size: Vector2, xdata: []float64, yarrays: [][]float64
plot.bottom_bearing = 20;
}
child_pos := ImGui.GetCursorScreenPos();
child_size = ImGui.GetContentRegionAvail();
child_pos = ImGui.GetCursorScreenPos();
plot.x = xx child_pos.x;
plot.y = xx child_pos.y;
@ -250,6 +252,7 @@ draw_plot :: (key: string, size: Vector2, xdata: []float64, yarrays: [][]float64
glUniform4f(glGetUniformLocation(data_shader, "data_color"), color.x, color.y, color.z, color.w);
glDrawArrays(GL_LINE_STRIP, 0, xx (plot.xfloat.count));
primitives_rendered_this_frame += plot.xfloat.count - 1;
//glBindFramebuffer(GL_READ_FRAMEBUFFER, plot.msfbo);
//glBindFramebuffer(GL_DRAW_FRAMEBUFFER, plot.fbo);
@ -262,18 +265,17 @@ draw_plot :: (key: string, size: Vector2, xdata: []float64, yarrays: [][]float64
plot.last_frame = frame;
}
if data_style == .EVERY_FRAME {
array_free(plot.xfloat);
for plot.yfloats {
array_free(it);
remove it;
}
}
}
ImGui.EndChild();
if data_style == .EVERY_FRAME {
array_reset(*plot.xfloat);
for * plot.yfloats {
array_reset(it);
remove it;
}
}
}
free_old_plots :: () {
@ -302,6 +304,11 @@ init :: (_win_width: s32, _win_height: s32) {
window_projection_matrix = orthographic_projection_matrix(0.0, xx win_width, xx win_height, 0.0, -1.0, 1.0);
init_font(*JetBrainsMonoRegular, "JetBrainsMono-Regular.ttf", 12);
glEnable(GL_MULTISAMPLE);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
glEnable(GL_LINE_SMOOTH);
glLineWidth(1.5);
}
window_resize :: (_win_width: s32, _win_height: s32) {
@ -317,6 +324,12 @@ new_frame :: (_mouse: Vector2, _mouse_delta: Vector2, _mouse_wheel_delta: float,
mouse_delta = _mouse_delta;
mouse_wheel_delta = _mouse_wheel_delta;
mouse_left = _mouse_left;
primitives_rendered_this_frame = 0;
}
get_primitives_rendered :: () -> int {
return primitives_rendered_this_frame;
}
#scope_file
@ -333,6 +346,8 @@ mouse_delta : Vector2;
mouse_wheel_delta : float;
mouse_left : bool;
primitives_rendered_this_frame : int;
win_width : s32;
win_height : s32;
@ -565,6 +580,7 @@ draw_axis :: (using plot: Plot, style: PLOT_STYLE, colors: PlotColors) {
glUniform4f(glGetUniformLocation(line_shader, "data_color"), colors.lines.x, colors.lines.y, colors.lines.z, 1.0);
glDrawArrays(GL_LINES, 0, xx positions.count);
primitives_rendered_this_frame += positions.count / 2;
glDeleteBuffers(1, *axis_vbo);
glDeleteVertexArrays(1, *axis_vao);
@ -640,6 +656,7 @@ draw_scale :: (using plot: Plot, colors: PlotColors) {
glUniform4f(glGetUniformLocation(line_shader, "data_color"), 1.0, 0.0, 0.0, 1.0);
glDrawArrays(GL_LINES, 0, xx positions.count);
primitives_rendered_this_frame += positions.count / 2;
glDeleteBuffers(1, *scale_vbo);
glDeleteVertexArrays(1, *scale_vao);
@ -1008,6 +1025,7 @@ graphics_render_font :: (graphics_font: *GraphicsFont, vertices: []Vector2, tex:
glUniform3fv(glGetUniformLocation(text_shader, "data_color"), 1, *color.x);
glDrawArrays(GL_TRIANGLES, 0, cast(u32) vertices.count);
primitives_rendered_this_frame += vertices.count / 3;
glDeleteBuffers(1, *posvbo);
glDeleteBuffers(1, *texvbo);