-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain-loop.h
102 lines (75 loc) · 1.71 KB
/
main-loop.h
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#ifndef MAIN_LOOP_H_DEF
#define MAIN_LOOP_H_DEF
#include "ccVector.h"
#include <GL/gl3w.h>
enum struct SineOffsetType
{
Diagonal,
Concentric
};
const int CHUNK_SIZE = 16;
struct TerrainChunk
{
int terrain_gen_id;
vec2 position;
float height_map[CHUNK_SIZE*CHUNK_SIZE];
};
struct GameState
{
GLint program_id;
GLint world_view_projection_matrix_uniform;
GLint model_matrix_uniform;
GLint light_position_uniform;
GLint light_colour_uniform;
GLint ambient_light_uniform;
GLint grass_texture_uniform;
GLint normal_map_texture_uniform;
GLuint index_buffer;
GLuint vertex_buffer;
GLuint color_buffer;
GLuint uv_buffer;
GLuint normal_buffer;
GLuint tangent_buffer;
GLuint bitangent_buffer;
GLuint grass_texture_id;
GLuint normal_map_texture_id;
int n_indices;
bool init;
bool capture_mouse;
bool debug_camera;
int fps;
uint64_t game_start_time;
float last_frame_delta;
float last_frame_total;
TerrainChunk terrain_chunk_hashmap[1024];
int terrain_gen_id;
vec2 current_terrain_dim;
vec2 user_terrain_dim;
int n_perlins;
int perlin_periods[16];
float perlin_amplitudes[16];
float fov;
vec3 terrain_rotation;
SineOffsetType sine_offset_type;
float bounces_per_second;
float bounce_height;
float oscillation_frequency;
vec4 colours[2];
int colour_picker_n;
vec3 light_position;
vec3 light_colour;
vec3 ambient_light_colour;
vec2 last_frame_mouse;
float player_speed;
float drag_radians_per_second;
float player_feet;
vec3 camera_velocity;
vec3 camera_position;
vec3 camera_direction_velocity;
vec3 camera_direction;
};
void
main_loop(GameState *game_state, vec2 mouse_delta);
void
shutdown(GameState *game_state);
#endif