-
Notifications
You must be signed in to change notification settings - Fork 0
/
minimal.c
59 lines (44 loc) · 1.26 KB
/
minimal.c
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
55
56
57
58
59
#define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h>
#include <assert.h>
#include <string.h>
#include <math.h>
#include "glad/gl.h"
#include "pgrid/pgrid.h"
struct pgrid_grid grid;
struct pgrid pgrid;
int
main(void)
{
static const int width = 1280;
static const int height = 720;
static const float fov = M_PI_2;
static const size_t threads_ln = 1;
static const size_t cache_ln = 1;
static const char *input_path = "img/map.txt";
vec3 pos = {0, 0, 0};
versor rot = {0, 0, 0, 1};
pthread_t threads[threads_ln];
pgrid_grid_init(&grid, cache_ln);
assert(pgrid_grid_load(&grid, input_path, strlen(input_path)));
pgrid_threads_init(&grid, threads, threads_ln);
assert(glfwInit());
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 6);
GLFWwindow* window = glfwCreateWindow(width, height, "Pgrid", NULL, NULL);
assert(window);
glfwMakeContextCurrent(window);
gladLoadGL(glfwGetProcAddress);
pgrid_init(&pgrid, &grid, width, height, fov);
while (!glfwWindowShouldClose(window)) {
pgrid_render(&pgrid, pos, rot);
glfwSwapBuffers(window);
glfwWaitEvents();
}
pgrid_finish(&pgrid);
glfwDestroyWindow(window);
glfwTerminate();
pgrid_threads_finish(&grid, threads, threads_ln);
pgrid_grid_finish(&grid);
return 0;
}