engine

game engine on C
git clone git://git.evenfri.pw/engine.git
Log | Files | Refs | README

dat.h (1608B)


      1 #ifndef DAT_H
      2 #define DAT_H
      3 
      4 #include "engine.h"
      5 
      6 typedef unsigned int uint;
      7 
      8 #define PI 3.14159265358979323846f
      9 
     10 typedef struct { float x, y, z; } vec3;
     11 typedef struct { float m[16]; } mat4;
     12 
     13 /* dynamic array */
     14 typedef struct {
     15   void *data;
     16   size_t elem_size;
     17   size_t count;
     18   size_t capacity;
     19 } Array_t;
     20 
     21 typedef struct {
     22   uint vao, vbo, ebo;
     23   int vertex_count;
     24   uint texture;
     25 } Mesh_t;
     26 
     27 typedef struct { float x, y, z; } TempVec3_t;
     28 typedef struct { float x, y; } TempVec2_t;
     29 
     30 /* components */
     31 typedef struct {
     32   uint32_t type_id;
     33   void *data;
     34   size_t size;
     35 } component_t;
     36 
     37 typedef struct {
     38   vec3 pos;
     39   vec3 rot;
     40   vec3 scl;
     41 } transform_t;
     42 
     43 typedef struct {
     44   float fov;
     45   float near_plane;
     46   float far_plane;
     47 } camera_comp_t;
     48 
     49 typedef struct {
     50   Mesh_t *mesh;
     51   uint texture;
     52 } mesh_comp_t;
     53 
     54 typedef struct {
     55   vec3 position;
     56   vec3 front;
     57   vec3 up;
     58   vec3 right;
     59   vec3 scene_up;
     60   float yaw;
     61   float pitch;
     62   float speed;
     63   float sensitivity;
     64   float fov;
     65   float near_plane;
     66   float far_plane;
     67 } editor_camera_t;
     68 
     69 typedef enum {
     70   CAMERA_EDITOR,
     71   CAMERA_GAME,
     72 } camera_kind_t;
     73 
     74 /* component type ids */
     75 #define COMP_TRANSFORM 0x01u
     76 #define COMP_CAMERA 0x02u
     77 #define COMP_MESH 0x03u
     78 
     79 typedef struct {
     80   Array_t components;
     81   int active;
     82 } game_obj_t;
     83 
     84 typedef struct {
     85   Array_t objects;
     86 } scene_t;
     87 
     88 typedef struct {
     89   camera_kind_t kind;
     90   union {
     91     editor_camera_t *editor;
     92     struct {
     93       game_obj_t *obj;
     94       camera_comp_t *comp;
     95     } game;
     96   } impl;
     97 } active_camera_t;
     98 
     99 
    100 extern GLFWwindow *Window;
    101 extern uint Shader;
    102 extern active_camera_t active_camera;
    103 
    104 #endif /* DAT_H */