blob: 5fc319721cf2296edbcf8c1be922fb6a74f2ebd6 (
plain)
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
|
#pragma once
#include <GLFW/glfw3.h>
#include <threads.h>
#include "voxel.h"
#define WINDOW_WIDTH 640
#define WINDOW_HEIGHT 480
#define WINDOW_TITLE "Voxel Engine"
typedef struct {
// screen size
u32 width;
u32 height;
// input
bool key_down[GLFW_KEY_LAST];
bool key_pressed[GLFW_KEY_LAST];
bool btn_down[GLFW_MOUSE_BUTTON_LAST];
bool btn_pressed[GLFW_MOUSE_BUTTON_LAST];
// cursor
double mouse_x;
double mouse_y;
double mouse_x_last;
double moues_y_last;
// time
double last_time;
// glfw
GLFWwindow *window;
// sync
mtx_t lock;
// flags
_Atomic bool close;
_Atomic bool resize;
} Window;
extern Window window;
extern _Atomic double delta_time;
VOXEL_RESULT window_init(void);
VOXEL_RESULT window_init_gl(void);
bool window_closed(void);
void window_update(void);
void window_swap(void);
void window_close(void);
bool key_down(i32 key);
bool key_pressed(i32 key);
bool btn_down(i32 button);
bool btn_pressed(i32 button);
|