summaryrefslogtreecommitdiff
path: root/all.h
diff options
context:
space:
mode:
Diffstat (limited to 'all.h')
-rw-r--r--all.h117
1 files changed, 117 insertions, 0 deletions
diff --git a/all.h b/all.h
new file mode 100644
index 0000000..40a19f1
--- /dev/null
+++ b/all.h
@@ -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
20typedef struct {
21 Vector3 p[3];
22 char texture[64];
23 float shift[2];
24 float rotate;
25 float scale[2];
26} MapPlane;
27
28typedef struct {
29 MapPlane *planes;
30 int plane_count;
31} MapBrush;
32
33typedef struct {
34 char key[64];
35 char value[256];
36} MapProperty;
37
38typedef struct {
39 MapProperty *properties;
40 int property_count;
41 MapBrush *brushes;
42 int brush_count;
43} MapEntity;
44
45typedef struct {
46 MapEntity *entities;
47 int entity_count;
48} Map;
49
50typedef struct {
51 const char *data;
52 size_t length;
53 size_t pos;
54} MapParser;
55
56typedef struct {
57 Vector3 normal;
58 float dist;
59} Plane;
60
61typedef struct {
62 Vector3 *verts;
63 int count;
64} Polygon;
65
66typedef struct {
67 char texture[64];
68 array(float) vertices;
69 array(float) texcoords;
70 array(float) normals;
71} TextureGroup;
72
73typedef struct {
74 char name[64];
75 Texture2D tex;
76} CachedTexture;
77
78// --- Game State ---
79
80typedef struct {
81 Camera camera;
82 Model *world_models;
83 int world_model_count;
84 bool cursor_captured;
85 bool vsync;
86} GameState;
87
88extern GameState game;
89
90// --- Prototypes ---
91
92// Map
93char map_peek(MapParser *p);
94char map_get(MapParser *p);
95void map_skip_whitespace(MapParser *p);
96bool map_expect(MapParser *p, char expected);
97void map_parse_token(MapParser *p, char *buffer, int size);
98Vector3 map_parse_vector(MapParser *p);
99Map ParseMap(const char *filename);
100void FreeMap(Map map);
101
102// Geometry
103Plane PlaneFromPoints(Vector3 p1, Vector3 p2, Vector3 p3);
104void PolyFree(Polygon p);
105Polygon PolyClip(Polygon poly, Plane plane);
106Polygon CreateLargeQuad(Plane plane);
107Vector2 GetUV(Vector3 p, MapPlane *mp, Plane plane);
108
109// Game
110Texture2D GetTexture(const char *name);
111void InitGame(void);
112void UpdateGame(void);
113void DrawGame(void);
114bool LoadMap(const char *filename);
115void UnloadMap(void);
116
117#endif