BlosSOM
Interactive dimensionality reduction on large datasets (EmbedSOM and FLOWER combined)
main.cpp
Go to the documentation of this file.
1/* This file is part of BlosSOM.
2 *
3 * Copyright (C) 2021 Sona Molnarova
4 *
5 * BlosSOM is free software: you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free
7 * Software Foundation, either version 3 of the License, or (at your option)
8 * any later version.
9 *
10 * BlosSOM is distributed in the hope that it will be useful, but WITHOUT ANY
11 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * BlosSOM. If not, see <https://www.gnu.org/licenses/>.
17 */
18
19#include <iostream>
20
21#include "input_handler.h"
22#include "renderer.h"
23#include "state.h"
24#include "timer.h"
25#include "view.h"
26#include "wrapper_glad.h"
27#include "wrapper_glfw.h"
28#include "wrapper_imgui.h"
29
30int
32{
33 GlfwWrapper glfw;
34 GladWrapper glad;
35 ImGuiWrapper imgui;
36 InputHandler input_handler;
37 Renderer renderer;
38 Timer timer;
39 View view;
40 State state;
41
42 if (!glfw.init("BlosSOM", input_handler.input)) {
43 std::cout << "GLFW initialization failed." << std::endl;
44 return -1;
45 }
46
47 if (!glad.init()) {
48 std::cout << "GLAD initialization failed." << std::endl;
49 return -1;
50 }
51
52 if (!imgui.init(glfw.window)) {
53 std::cout << "Dear ImGui initialization failed." << std::endl;
54 return -1;
55 }
56
57 if (!renderer.init()) {
58 std::cout << "Renderer initialization failed." << std::endl;
59 return -1;
60 }
61
62 while (!glfw.window_should_close()) {
63 timer.tick();
65
66 input_handler.update(view, renderer, state);
67
68 view.update(timer.frametime,
69 input_handler.input.fb_width,
70 input_handler.input.fb_height);
71
72 state.update(timer.frametime,
73 renderer.get_vert_pressed(),
74 renderer.get_vert_ind());
75
76 renderer.render(glm::vec2(input_handler.input.fb_width,
77 input_handler.input.fb_height),
78 state,
79 view);
80
81 imgui.render(
82 input_handler.input.fb_width, input_handler.input.fb_height, state);
83
84 input_handler.reset();
85 glfw.end_frame(state.frame_stats);
86 state.frame_stats.end_frame();
87 }
88
89 return 0;
90}
Wrapper of the GLAD library.
Definition: wrapper_glad.h:27
Wrapper of the Glfw library.
Definition: wrapper_glfw.h:39
bool init(const std::string &window_name, InputData &input)
GLFWwindow * window
Definition: wrapper_glfw.h:48
bool window_should_close()
void end_frame(FrameStats &fs)
Wrapper of the ImGui.
Definition: wrapper_imgui.h:34
void render(int w, int h, State &state)
Render UI.
bool init(GLFWwindow *window)
Initialize ImGui and load fonts.
Handler of input events.
Definition: input_handler.h:36
void update(View &view, Renderer &renderer, State &state)
InputData input
Definition: input_handler.h:38
Handles rendering of the graph and scatter plot and handles IO.
Definition: renderer.h:33
void render(const glm::vec2 &fb_size, const State &state, const View &view)
Render graph and scatterplot.
Definition: renderer.cpp:42
size_t get_vert_ind()
Definition: renderer.cpp:77
bool init()
Definition: renderer.cpp:29
bool get_vert_pressed()
Definition: renderer.cpp:71
A small utility class that manages the viewport coordinates, together with the virtual "camera" posit...
Definition: view.h:37
void update(float dt, int w, int h)
Move the current position and zoom a bit closer to the target position and zoom.
Definition: view.h:80
int main()
Definition: main.cpp:31
void end_frame()
Definition: frame_stats.h:64
void start_frame()
Definition: frame_stats.h:58
int fb_width
Definition: input_data.h:36
int fb_height
Definition: input_data.h:37
Storage of data of used algorithms and input events.
Definition: state.h:50
void update(float time, bool vert_pressed, int vert_ind)
Performs simulation steps of all active algorithms and updates data according to the user interaction...
Definition: state.cpp:26
FrameStats frame_stats
Definition: state.h:66
Handler for frametime computation.
Definition: timer.h:29
void tick()
Counts frametime and sets last_tick variable to current time.
Definition: timer.h:52
float frametime
Duration of the last frame (in seconds).
Definition: timer.h:33