summaryrefslogtreecommitdiff
path: root/src/window.h
blob: 3690781b90541a56810316cda7703fbbc86ab083 (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
#pragma once

#include <GLFW/glfw3.h>

#define WINDOW_WIDTH  640
#define WINDOW_HEIGHT 480
#define WINDOW_TITLE  "Voxel Engine"

typedef struct {
	// screen size
	int width;
	int 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;
	GLFWmonitor *monitor;
} Window;

extern Window window;
extern double delta_time;

int window_init(void);
bool window_closed(void);
void window_update(void);
void window_swap(void);
void window_close(void);

int window_grab_cursor(void);
int window_release_cursor(void);

bool key_down(int key);
bool key_pressed(int key);

bool btn_down(int button);
bool btn_pressed(int button);