aboutsummaryrefslogtreecommitdiff
path: root/src/types.h
diff options
context:
space:
mode:
authortaw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5>2008-04-16 16:57:56 +0000
committertaw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5>2008-04-16 16:57:56 +0000
commitf0a0118393a3d121bcb83047b5b9ac95eb0621ba (patch)
treecfc4f3f7955b4829317fa9b7865e328ccabfb129 /src/types.h
Initial import
git-svn-id: svn://cook.msm.cam.ac.uk:745/thrust3d/thrust3d@1 84d2e878-0bd5-11dd-ad15-13eda11d74c5
Diffstat (limited to 'src/types.h')
-rw-r--r--src/types.h174
1 files changed, 174 insertions, 0 deletions
diff --git a/src/types.h b/src/types.h
new file mode 100644
index 0000000..78864a9
--- /dev/null
+++ b/src/types.h
@@ -0,0 +1,174 @@
+/*
+ * types.h
+ *
+ * All the data types - avoid circular reference silliness
+ *
+ * (c) 2008 Thomas White <taw27@cam.ac.uk>
+ *
+ * thrust3d - a silly game
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifndef TYPES_H
+#define TYPES_H
+
+#include <gl.h>
+#include <SDL.h>
+
+/* Maximum number of individual textures */
+#define MAX_TEXTURES 128
+
+/* Maximum number of rooms which can be "seen" at once */
+#define MAX_ROOMS 64
+
+/* Maximum number of lights per room */
+#define MAX_LIGHTS 4
+
+typedef enum {
+ ATTRIB_NONE = 0,
+ ATTRIB_COLOUR = 1<<0, /* Colour specified? */
+ ATTRIB_PULSE = 1<<1, /* Pulsating colour */
+} PrimitiveAttrib;
+
+typedef struct {
+
+ GLenum type;
+ int num_vertices;
+ GLfloat *vertices;
+ GLfloat *normals;
+ GLfloat *texcoords;
+
+ PrimitiveAttrib attribs;
+ GLfloat col_r;
+ GLfloat col_g;
+ GLfloat col_b;
+ char *texture;
+
+} Primitive;
+
+typedef struct {
+
+ char *name; /* Identifier */
+
+ int num_primitives;
+ Primitive **primitives; /* Geometry */
+
+ PrimitiveAttrib attrib_total;
+
+} Model;
+
+typedef struct {
+ int num_models;
+ Model **models;
+} ModelContext;
+
+typedef enum {
+ OBJ_NONE = 0,
+ OBJ_GRAVITY = 1<<0, /* Object is subject to gravity */
+} ObjectAttrib;
+
+typedef struct {
+
+ Model *model;
+
+ GLfloat x;
+ GLfloat y;
+ GLfloat z;
+
+ ObjectAttrib attribs;
+ GLfloat vx;
+ GLfloat vy;
+ GLfloat vz;
+
+ float yaw;
+ float yawspeed;
+
+} ModelInstance;
+
+typedef struct {
+ char *name;
+ GLuint *data;
+ GLuint texname;
+} Texture;
+
+typedef struct {
+
+ /* Lighting shaders */
+ GLhandleARB lighting_vert;
+ GLhandleARB lighting_frag;
+ GLhandleARB lighting_program;
+
+ /* Textures */
+ Texture textures[MAX_TEXTURES];
+ unsigned int num_textures;
+
+ int frames;
+ Uint32 t_fps;
+ int fps;
+
+} RenderContext;
+
+typedef struct {
+ int rx;
+ int ry;
+ int rz;
+} Connection;
+
+typedef struct {
+ GLfloat x;
+ GLfloat y;
+ GLfloat z;
+} Light;
+
+typedef struct {
+
+ ModelInstance **objects;
+ int num_objects;
+
+ int rx;
+ int ry;
+ int rz;
+
+ int needed_this_time;
+ Connection connected[MAX_ROOMS];
+ int num_connected;
+
+ Light lights[MAX_LIGHTS];
+ int num_lights;
+
+} Room;
+
+typedef struct {
+
+ unsigned int thrusting;
+ unsigned int turn_left;
+ unsigned int turn_right;
+ unsigned int forward;
+ unsigned int reverse;
+
+ Uint32 tlast; /* Time at which the last physics step was performed */
+
+ ModelInstance *lander;
+
+ ModelContext *models;
+ RenderContext *render;
+
+ int cur_room_x;
+ int cur_room_y;
+ int cur_room_z;
+
+ Room *rooms[MAX_ROOMS];
+ int num_rooms;
+
+ float view_angle;
+ int paused;
+ int pause_rel;
+
+} Game;
+
+#endif /* TYPES_H */
+