diff --git a/.idea/editor.xml b/.idea/editor.xml
index 5fff85e..b0d69ef 100644
--- a/.idea/editor.xml
+++ b/.idea/editor.xml
@@ -240,5 +240,244 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index 97695cc..92fb85a 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -28,8 +28,17 @@
+
+
+
+
+
+
+
+
+
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6780d58..355f39c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.25)
-project(COSC-4P80-Assignment-3 VERSION 0.0.33)
+project(COSC-4P80-Assignment-3 VERSION 0.0.34)
include(FetchContent)
option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF)
diff --git a/include/assign3/manager.h b/include/assign3/manager.h
index 56a6276..93dbd65 100644
--- a/include/assign3/manager.h
+++ b/include/assign3/manager.h
@@ -87,6 +87,8 @@ namespace assign3
void draw_debug(const data_file_t& file);
void render();
+
+ void draw_calls();
void regenerate_network()
{
@@ -95,6 +97,11 @@ namespace assign3
distance_function.get(), topology_function.get(), static_cast(selected_som_mode),
static_cast(selected_init_type), normalize_init);
}
+
+ blt::gfx::batch_renderer_2d& get_renderer()
+ {
+ return br2d;
+ }
private:
motor_data_t& motor_data;
diff --git a/src/main.cpp b/src/main.cpp
index 690b09b..46c8acf 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -23,7 +23,7 @@ void plot_heatmap(const std::string& path, const std::string& activations_csv, c
const std::string command = "cd '" + path + "' && python3 '" + pwd + "../plot_heatmap.py' '" + activations_csv + "' '" + std::to_string(bin_size)
+
"' '" + subtitle + "'";
- BLT_TRACE(command);
+ BLT_TRACE(command);g
std::system(command.c_str());
#endif
}
@@ -50,6 +50,8 @@ blt::gfx::first_person_camera_2d camera;
assign3::motor_data_t data{};
assign3::renderer_t renderer{data, resources, global_matrices};
+bool silly = false;
+
void init(const blt::gfx::window_data&)
{
using namespace blt::gfx;
@@ -62,6 +64,8 @@ void init(const blt::gfx::window_data&)
ImPlot::CreateContext();
}
+#define as_float(x) static_cast(x)
+
void update(const blt::gfx::window_data& window_data)
{
using namespace blt::gfx;
@@ -75,7 +79,41 @@ void update(const blt::gfx::window_data& window_data)
camera.update_view(global_matrices);
global_matrices.update();
- renderer.render();
+ if (silly)
+ {
+ auto& rend = renderer.get_renderer();
+
+ std::vector> points;
+
+ float window_width = as_float(window_data.width);
+ float window_height = as_float(window_data.height);
+
+ constexpr int num_of_points = 1000;
+ constexpr float min = -10;
+ constexpr float max = 10;
+
+ constexpr float distance = max - min;
+ constexpr float step = distance / as_float(num_of_points);
+ for (int i = 0; i < num_of_points; i++)
+ {
+ const float x_value = min + step * as_float(i);
+ const float y_value = std::sin(x_value);
+
+ // scales the x range of the function down to 1...1, then blows it up to -window_width/2...window_width/2, then centers it to the window
+ const float scaled_x = ((x_value / (distance / 2)) * (window_width / 2)) + (window_width / 2);
+ // similar to x, except y values are already between -1 and 1
+ const float scaled_y = (y_value * (window_height / 2)) + (window_height / 2);
+
+ points.emplace_back(scaled_x, scaled_y);
+ }
+ for (const auto& [i, point] : blt::enumerate(points).rev().skip(1).rev())
+ {
+ rend.drawLineInternal(blt::make_color(1, 0, 0), {point.first, point.second, points[i+1].first, points[i+1].second});
+ }
+
+ renderer.draw_calls();
+ } else
+ renderer.render();
}
void destroy(const blt::gfx::window_data&)
@@ -105,10 +143,14 @@ void action_start_graphics(const std::vector& argv_vector)
.setDefault("../data")
.setHelp("Path to data files").build());
+ parser.addArgument(blt::arg_builder{"--silly"}.setAction(blt::arg_action_t::STORE_TRUE).setDefault(false).build());
+
auto args = parser.parse_args(argv_vector);
load_data_files(args.get("file"));
+ silly = args.get("silly");
+
blt::gfx::init(blt::gfx::window_data{"My Sexy Window", init, update, destroy}.setSyncInterval(1).setMaximized(true));
}
@@ -760,7 +802,10 @@ int main(int argc, const char** argv)
.setAction(blt::arg_action_t::SUBCOMMAND)
.setHelp("Action to run. Can be: [graphics, test, convert]").build());
- auto args = parser.parse_args(argv_vector);
+ auto copy = argv_vector;
+ copy.erase(copy.begin() + 2, copy.end());
+
+ auto args = parser.parse_args(copy);
if (!args.contains("action"))
{
diff --git a/src/manager.cpp b/src/manager.cpp
index 4275916..f098296 100644
--- a/src/manager.cpp
+++ b/src/manager.cpp
@@ -293,6 +293,11 @@ namespace assign3
else
draw_debug(current_data_file);
+ draw_calls();
+ }
+
+ void renderer_t::draw_calls()
+ {
br2d.render(0, 0);
fr2d.render();
}