material.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /**
  2. *** :: Material ::
  3. ***
  4. *** Material in system. Provides shader.
  5. *** Also provides shader "uniform" values
  6. ***
  7. **/
  8. #ifndef material_h
  9. #define material_h
  10. #include "cengine.h"
  11. #include "casset.h"
  12. #include "assets/shader.h"
  13. typedef union {
  14. int as_int;
  15. float as_float;
  16. vec2 as_vec2;
  17. vec3 as_vec3;
  18. vec4 as_vec4;
  19. asset_hndl as_asset;
  20. } material_item;
  21. static const int mat_item_int = 0;
  22. static const int mat_item_float = 1;
  23. static const int mat_item_vec2 = 2;
  24. static const int mat_item_vec3 = 3;
  25. static const int mat_item_vec4 = 4;
  26. static const int mat_item_shader = 5;
  27. static const int mat_item_texture = 6;
  28. typedef struct {
  29. shader_program* program;
  30. int num_items;
  31. int* types;
  32. char** names;
  33. material_item* items;
  34. } material_entry;
  35. void material_entry_delete(material_entry* me);
  36. material_item material_entry_item(material_entry* me, char* name);
  37. bool material_entry_has_item(material_entry* me, char* name);
  38. void material_entry_add_item(material_entry* me, char* name, int type, material_item mi);
  39. typedef struct {
  40. int num_entries;
  41. material_entry** entries;
  42. } material;
  43. material* material_new();
  44. void material_delete(material* m);
  45. material* mat_load_file(char* filename);
  46. material_entry* material_get_entry(material* m, int index);
  47. material_entry* material_add_entry(material* m);
  48. shader_program* material_first_program(material* m);
  49. #endif