diff options
Diffstat (limited to 'all.h')
| -rw-r--r-- | all.h | 117 |
1 files changed, 117 insertions, 0 deletions
| @@ -0,0 +1,117 @@ | |||
| 1 | #ifndef ALL_H | ||
| 2 | #define ALL_H | ||
| 3 | |||
| 4 | #include "raylib.h" | ||
| 5 | #include "raymath.h" | ||
| 6 | #include "rlgl.h" | ||
| 7 | #include "config.h" | ||
| 8 | |||
| 9 | // Resolve conflicts between Raylib and nonstd.h | ||
| 10 | #define Color NS_Color | ||
| 11 | #include "libraries/nonstd.h" | ||
| 12 | #undef Color | ||
| 13 | |||
| 14 | #include "libraries/vfs.h" | ||
| 15 | #include <stdbool.h> | ||
| 16 | #include <stddef.h> | ||
| 17 | |||
| 18 | // --- Map Structures --- | ||
| 19 | |||
| 20 | typedef struct { | ||
| 21 | Vector3 p[3]; | ||
| 22 | char texture[64]; | ||
| 23 | float shift[2]; | ||
| 24 | float rotate; | ||
| 25 | float scale[2]; | ||
| 26 | } MapPlane; | ||
| 27 | |||
| 28 | typedef struct { | ||
| 29 | MapPlane *planes; | ||
| 30 | int plane_count; | ||
| 31 | } MapBrush; | ||
| 32 | |||
| 33 | typedef struct { | ||
| 34 | char key[64]; | ||
| 35 | char value[256]; | ||
| 36 | } MapProperty; | ||
| 37 | |||
| 38 | typedef struct { | ||
| 39 | MapProperty *properties; | ||
| 40 | int property_count; | ||
| 41 | MapBrush *brushes; | ||
| 42 | int brush_count; | ||
| 43 | } MapEntity; | ||
| 44 | |||
| 45 | typedef struct { | ||
| 46 | MapEntity *entities; | ||
| 47 | int entity_count; | ||
| 48 | } Map; | ||
| 49 | |||
| 50 | typedef struct { | ||
| 51 | const char *data; | ||
| 52 | size_t length; | ||
| 53 | size_t pos; | ||
| 54 | } MapParser; | ||
| 55 | |||
| 56 | typedef struct { | ||
| 57 | Vector3 normal; | ||
| 58 | float dist; | ||
| 59 | } Plane; | ||
| 60 | |||
| 61 | typedef struct { | ||
| 62 | Vector3 *verts; | ||
| 63 | int count; | ||
| 64 | } Polygon; | ||
| 65 | |||
| 66 | typedef struct { | ||
| 67 | char texture[64]; | ||
| 68 | array(float) vertices; | ||
| 69 | array(float) texcoords; | ||
| 70 | array(float) normals; | ||
| 71 | } TextureGroup; | ||
| 72 | |||
| 73 | typedef struct { | ||
| 74 | char name[64]; | ||
| 75 | Texture2D tex; | ||
| 76 | } CachedTexture; | ||
| 77 | |||
| 78 | // --- Game State --- | ||
| 79 | |||
| 80 | typedef struct { | ||
| 81 | Camera camera; | ||
| 82 | Model *world_models; | ||
| 83 | int world_model_count; | ||
| 84 | bool cursor_captured; | ||
| 85 | bool vsync; | ||
| 86 | } GameState; | ||
| 87 | |||
| 88 | extern GameState game; | ||
| 89 | |||
| 90 | // --- Prototypes --- | ||
| 91 | |||
| 92 | // Map | ||
| 93 | char map_peek(MapParser *p); | ||
| 94 | char map_get(MapParser *p); | ||
| 95 | void map_skip_whitespace(MapParser *p); | ||
| 96 | bool map_expect(MapParser *p, char expected); | ||
| 97 | void map_parse_token(MapParser *p, char *buffer, int size); | ||
| 98 | Vector3 map_parse_vector(MapParser *p); | ||
| 99 | Map ParseMap(const char *filename); | ||
| 100 | void FreeMap(Map map); | ||
| 101 | |||
| 102 | // Geometry | ||
| 103 | Plane PlaneFromPoints(Vector3 p1, Vector3 p2, Vector3 p3); | ||
| 104 | void PolyFree(Polygon p); | ||
| 105 | Polygon PolyClip(Polygon poly, Plane plane); | ||
| 106 | Polygon CreateLargeQuad(Plane plane); | ||
| 107 | Vector2 GetUV(Vector3 p, MapPlane *mp, Plane plane); | ||
| 108 | |||
| 109 | // Game | ||
| 110 | Texture2D GetTexture(const char *name); | ||
| 111 | void InitGame(void); | ||
| 112 | void UpdateGame(void); | ||
| 113 | void DrawGame(void); | ||
| 114 | bool LoadMap(const char *filename); | ||
| 115 | void UnloadMap(void); | ||
| 116 | |||
| 117 | #endif | ||
