Deep Learning Visualizer
Interactive visualization of basic applications of deep learning
Loading...
Searching...
No Matches
pixel_grid_view_gl.h
Go to the documentation of this file.
1#pragma once
2
7#include <functional>
8
9namespace views {
10
12public:
14 : renderer_(renderer) {
15 }
16
17 void draw_grid(
18 const std::array<float, shared::TOTAL_PIXELS> &image_data) override {
19 for (int x{0}; x < shared::GRID_SIZE; x++) {
20 for (int y{0}; y < shared::GRID_SIZE; y++) {
21 const auto value{image_data.at(x + y * shared::GRID_SIZE)};
22 draw_square(x, y, value);
23 }
24 }
25 }
26
27private:
28 void draw_square(int x, int y, float value) {
29 const Eigen::Vector2f anchor{
30 static_cast<float>(x) * 2 / shared::GRID_SIZE - 1.0f,
31 static_cast<float>(y) * 2 / shared::GRID_SIZE - 1.0f};
32 const float size{2.0f / shared::GRID_SIZE};
33
34 renderer_.get().set_color(Eigen::Vector3f{1.0f, 1.0f, 1.0f} * value);
35 renderer_.get().draw_quad(anchor + Eigen::Vector2f{0, 0},
36 anchor + Eigen::Vector2f{0, size},
37 anchor + Eigen::Vector2f{size, size},
38 anchor + Eigen::Vector2f{size, 0});
39 }
40
41 std::reference_wrapper<engine::graphics::renderer> renderer_;
42};
43
44} // namespace views
OpenGL renderer that uses batch rendering.
Definition renderer.h:18
Definition pixel_grid_view_gl.h:11
Definition pixel_grid_view.h:11