game.h (1166B)
1 #pragma once 2 3 // TODO: this whole file blows 4 #include "intrinsics.h" 5 #include "linear_algebra.h" 6 #include "heightmap.h" 7 #include "bsp.h" 8 #include "bsp_renderer.h" 9 #include "skybox.h" 10 #include "work_queue.h" 11 #include "memory_arena.h" 12 #include "keys.h" 13 14 const float NEAR_PLANE_DEPTH = 0.1f; 15 const float FAR_PLANE_DEPTH = 10000.0f; 16 17 const float VERTICAL_FOV = 120.0f; 18 19 struct GameState { 20 NONCOPYABLE( GameState ); 21 GameState() { } 22 23 v3 pos, velocity; 24 bool on_ground; 25 bool noclip; 26 float pitch, yaw; 27 28 BSP bsp; 29 BSPRenderer bspr; 30 31 bool frozen; 32 v3 frozen_pos; 33 34 WorkQueue background_tasks; 35 36 Skybox skybox; 37 38 float sun_angle; 39 40 bool draw_wireframe; 41 bool draw_quadtree; 42 }; 43 44 struct GameMemory { 45 MemoryArena persistent_arena; 46 GameState * state; 47 }; 48 49 struct GameInput { 50 StaticArray< bool, KEY_COUNT > keys; 51 StaticArray< bool, KEY_COUNT > key_edges; 52 double mouse_dx, mouse_dy; 53 bool resized; 54 }; 55 56 #define GAME_INIT( name ) void name( GameState * game, GameMemory * mem ) 57 typedef GAME_INIT( GameInit ); 58 59 #define GAME_FRAME( name ) void name( GameState * game, GameMemory * mem, const GameInput * input, double current_time, float dt ) 60 typedef GAME_FRAME( GameFrame );