polyadvent

A game engine from scratch in C
git clone git://jb55.com/polyadvent
Log | Files | Refs | README

geometry.h (1468B)


      1 
      2 #ifndef GEOMETRY_H
      3 #define GEOMETRY_H
      4 
      5 #include "common.h"
      6 #include "vbo.h"
      7 #include "shader.h"
      8 #include "resource.h"
      9 #include "mkgeom.h"
     10 
     11 #define DEF_NUM_GEOMETRY 64
     12 #define MAX_GEOMETRY 1024
     13 
     14 // -1 is uninitialized
     15 struct geometry_id {
     16 	struct resource_id id;
     17 };
     18 
     19 struct geometry {
     20     struct vbo vbos[MAX_VERTEX_ATTRS];
     21     float min[3];
     22     float max[3];
     23 
     24     int has_vbos;
     25     int num_uv_components;
     26     int num_indices;
     27     int num_verts;
     28 };
     29 
     30 struct geometry_manager {
     31     struct geometry geoms[MAX_GEOMETRY];
     32     int num_geometry;
     33 };
     34 
     35 void render_geometry(struct geometry *geom, struct gpu_program *current_program);
     36 void bind_geometry(struct geometry *geom, struct gpu_program *program);
     37 void init_geometry(struct geometry *geom);
     38 void make_buffer_geometry(struct make_geometry *mkgeom, struct geometry *geom);
     39 void destroy_buffer_geometry(struct geometry_id *geom);
     40 void geometry_centroid(struct geometry *geom, float *v3);
     41 void init_geometry_manager();
     42 void init_geometry_id(struct geometry_id *);
     43 struct geometry *new_geometry(struct geometry_id *);
     44 struct geometry *get_geometry(struct geometry_id *);
     45 struct geometry *get_all_geometry(u32 *count, struct geometry_id **ids);
     46 void destroy_geometry(struct geometry_id *geom_id);
     47 struct resource_manager *get_geometry_manager();
     48 
     49 extern struct resource_manager geom_manager;
     50 
     51 static inline struct geometry *static_geometry()
     52 {
     53     return (struct geometry *)geom_manager.resources;
     54 }
     55 
     56 #endif /* GEOMETRY_H */