geometry.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #ifndef GEOMETRY_H
  2. #define GEOMETRY_H
  3. #include <glplatform/glplatform-glcore.h>
  4. #include <stdint.h>
  5. #include "lua.h"
  6. #define MAX_VERTEX_WEIGHTS 6
  7. #define MAX_UV_LAYERS 16
  8. #define MAX_VERTEX_ATTRIB_BINDINGS 64
  9. enum attributes {
  10. ATTRIBUTE_VERTEX,
  11. ATTRIBUTE_NORMAL,
  12. ATTRIBUTE_UV,
  13. ATTRIBUTE_TANGENT,
  14. ATTRIBUTE_WEIGHT0,
  15. ATTRIBUTE_WEIGHT1,
  16. ATTRIBUTE_WEIGHT2,
  17. ATTRIBUTE_WEIGHT3,
  18. ATTRIBUTE_WEIGHT4,
  19. ATTRIBUTE_WEIGHT5,
  20. NUM_ATTRIBUTES
  21. };
  22. struct attribute {
  23. int binding_index;
  24. bool integer;
  25. GLint size;
  26. GLenum type;
  27. GLuint offset;
  28. };
  29. struct buffer_type {
  30. GLuint vao;
  31. int valid;
  32. size_t element_size[MAX_VERTEX_ATTRIB_BINDINGS];
  33. };
  34. struct geometry {
  35. struct buffer_type *type;
  36. int num_verticies;
  37. int num_triangles;
  38. GLuint vertex_array;
  39. GLuint index_array;
  40. const char *material_name;
  41. int triangle_count;
  42. int triangle_no;
  43. };
  44. struct submesh {
  45. const char *material_name;
  46. int triangle_count;
  47. int triangle_no;
  48. };
  49. void buffer_type_init(struct buffer_type *t, struct attribute *attribute, int num_attributes);
  50. void create_geometry_begin(struct geometry *g, void ** const vertex_buffer, uint16_t ** const index_buffer);
  51. void create_geometry_end(struct geometry *g);
  52. void create_cylinder_geometry(struct geometry *g, int m, int n);
  53. void create_cone_geometry(struct geometry *g, int n);
  54. void render_geometry(struct geometry *g);
  55. void delete_geometry(struct geometry *g);
  56. #endif