-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
54 lines (46 loc) · 1.64 KB
/
main.cpp
File metadata and controls
54 lines (46 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <iostream>
#include <SDL2/SDL.h>
#include "include/formats.hpp"
#include "include/raytracing_simulation.hpp"
#include "include/error_management.hpp"
int windows_width;
int windows_height;
size_t rows;
size_t columns;
double cell_size;
static void show_simulation_updates(Raytracing raytracing, SDL_Surface * surface);
int main(void) {
std::cout << "Hello ray!\n";
CHECKERROR(SDL_Init(SDL_INIT_VIDEO) != SUCCESS, SDL_GetError());
SDL_Window * window = SDL_CreateWindow("Interactive raytracing",
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
0, 0, /* Window height and width are irrelevant since we are using fullscreen */
SDL_WINDOW_FULLSCREEN_DESKTOP);
CHECKERROR(window == NULL, SDL_GetError());
SDL_GetWindowSize(window, &windows_width, &windows_height);
SDL_Surface * window_surface = SDL_GetWindowSurface(window);
CHECKERROR(window_surface == NULL, SDL_GetError());
Raytracing raytracing = Raytracing();
raytracing.start_simulation();
SDL_Event current_event;
while (raytracing.get_status() != END_SIMULATION) {
while (SDL_PollEvent(¤t_event)) {
raytracing.manage_event(current_event);
}
raytracing.render_frame(window_surface);
SDL_UpdateWindowSurface(window);
}
SDL_DestroyWindowSurface(window);
SDL_DestroyWindow(window);
SDL_Quit();
std::cout << "Bye ray!\n";
return 0;
}
static void show_simulation_updates(Raytracing raytracing, SDL_Surface * surface) {
for (int i = 0; i < rows; ++i) {
for (int j = 0; j < columns; ++j) {
// Show each cell. Probably multiple states are going to be settled
}
}
return;
}