/* * types.h * * All the data types - avoid circular reference silliness * * (c) 2008 Thomas White * * thrust3d - a silly game * */ #ifdef HAVE_CONFIG_H #include #endif #ifndef TYPES_H #define TYPES_H #include #include /* 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 */ ATTRIB_RADIUS = 1<<2, /* Radius is set */ ATTRIB_SHINY = 1<<3, /* Primitive is shiny */ ATTRIB_SWIRLY = 1<<4, /* Primitive is texture with swirlyness */ } PrimitiveAttrib; typedef enum { PRIMITIVE_QUADS, PRIMITIVE_TRIANGLES, PRIMITIVE_HEMISPHERE } PrimitiveType; typedef struct { GLenum type; int num_vertices; GLfloat *vertices; GLfloat *normals; GLfloat *texcoords; GLuint vertices_buffer; GLuint normals_buffer; GLuint texcoords_buffer; PrimitiveAttrib attribs; GLfloat col_r; GLfloat col_g; GLfloat col_b; char *texture; GLfloat radius; GLfloat shininess; } 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; int landed; } ModelInstance; typedef struct { char *name; GLuint *data; GLuint texname; } Texture; typedef struct { int shaders; int vbos; int fbos; /* Lighting shaders */ GLuint lighting_vert; GLuint lighting_frag; GLuint lighting_program; /* Textures */ Texture textures[MAX_TEXTURES]; unsigned int num_textures; /* Swirlyness stuff */ GLuint swirly_vert; GLuint swirly_frag; GLuint swirly_program; GLuint swirly_fbo; GLuint swirly_texture; GLfloat aspect; int width; int height; GLfloat *hemisphere_v; GLfloat *hemisphere_n; GLfloat *hemisphere_t; } RenderContext; #define AUDIO_MAX_SOUNDS 16 typedef struct { struct sound { Uint8 *data; int dpos; int dlen; int inuse; int repeat; } sounds[AUDIO_MAX_SOUNDS]; } AudioContext; 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; char *comment; 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; AudioContext *audio; int cur_room_x; int cur_room_y; int cur_room_z; Room *rooms[MAX_ROOMS]; int num_rooms; float view_angle; float view_dist; int paused; int pause_rel; int frames; Uint32 t_fps; int fps; GLfloat radiation; GLfloat fuel; } Game; #endif /* TYPES_H */