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 @@
+#ifndef ALL_H
+#define ALL_H
+
+#include "raylib.h"
+#include "raymath.h"
+#include "rlgl.h"
+#include "config.h"
+
+// Resolve conflicts between Raylib and nonstd.h
+#define Color NS_Color
+#include "libraries/nonstd.h"
+#undef Color
+
+#include "libraries/vfs.h"
+#include <stdbool.h>
+#include <stddef.h>
+
+// --- Map Structures ---
+
+typedef struct {
+ Vector3 p[3];
+ char texture[64];
+ float shift[2];
+ float rotate;
+ float scale[2];
+} MapPlane;
+
+typedef struct {
+ MapPlane *planes;
+ int plane_count;
+} MapBrush;
+
+typedef struct {
+ char key[64];
+ char value[256];
+} MapProperty;
+
+typedef struct {
+ MapProperty *properties;
+ int property_count;
+ MapBrush *brushes;
+ int brush_count;
+} MapEntity;
+
+typedef struct {
+ MapEntity *entities;
+ int entity_count;
+} Map;
+
+typedef struct {
+ const char *data;
+ size_t length;
+ size_t pos;
+} MapParser;
+
+typedef struct {
+ Vector3 normal;
+ float dist;
+} Plane;
+
+typedef struct {
+ Vector3 *verts;
+ int count;
+} Polygon;
+
+typedef struct {
+ char texture[64];
+ array(float) vertices;
+ array(float) texcoords;
+ array(float) normals;
+} TextureGroup;
+
+typedef struct {
+ char name[64];
+ Texture2D tex;
+} CachedTexture;
+
+// --- Game State ---
+
+typedef struct {
+ Camera camera;
+ Model *world_models;
+ int world_model_count;
+ bool cursor_captured;
+ bool vsync;
+} GameState;
+
+extern GameState game;
+
+// --- Prototypes ---
+
+// Map
+char map_peek(MapParser *p);
+char map_get(MapParser *p);
+void map_skip_whitespace(MapParser *p);
+bool map_expect(MapParser *p, char expected);
+void map_parse_token(MapParser *p, char *buffer, int size);
+Vector3 map_parse_vector(MapParser *p);
+Map ParseMap(const char *filename);
+void FreeMap(Map map);
+
+// Geometry
+Plane PlaneFromPoints(Vector3 p1, Vector3 p2, Vector3 p3);
+void PolyFree(Polygon p);
+Polygon PolyClip(Polygon poly, Plane plane);
+Polygon CreateLargeQuad(Plane plane);
+Vector2 GetUV(Vector3 p, MapPlane *mp, Plane plane);
+
+// Game
+Texture2D GetTexture(const char *name);
+void InitGame(void);
+void UpdateGame(void);
+void DrawGame(void);
+bool LoadMap(const char *filename);
+void UnloadMap(void);
+
+#endif