/src/renderer/mesh.h

https://bitbucket.org/vivkin/gam3b00bs/ · C Header · 61 lines · 29 code · 10 blank · 22 comment · 0 complexity · bafc4bee2b75c8837b01e59fea81ea7b MD5 · raw file

  1. /*
  2. ƒва файла, *.mesh и с тем же именем *.blob
  3. mesh:
  4. mesh_header_t 20 байт
  5. subset_data sizeof( subset_t ) * subset_count;
  6. blob:
  7. vertex_data vertex_size * vertex_count байт
  8. index_data index_size * index_count байт
  9. */
  10. //-----------------------------------------------------------------------------
  11. #pragma once
  12. #include "types.h"
  13. #include "renderer/device.h"
  14. //-----------------------------------------------------------------------------
  15. #define MAX_SUBSETS 16
  16. //-----------------------------------------------------------------------------
  17. //fwd decl
  18. struct buffer_t;
  19. //-----------------------------------------------------------------------------
  20. struct mesh_header_t
  21. {
  22. uint32 vertex_size;
  23. uint32 vertex_count;
  24. uint32 vertex_type;
  25. uint32 index_size; // либо 16, либо 32, иначе assert
  26. uint32 index_count;
  27. uint32 subset_count;
  28. };
  29. //-----------------------------------------------------------------------------
  30. struct subset_t
  31. {
  32. uint32 index_offset;
  33. uint32 vertex_offset;
  34. uint32 index_count;
  35. };
  36. //-----------------------------------------------------------------------------
  37. struct mesh_t
  38. {
  39. mesh_header_t header;
  40. subset_t subsets[MAX_SUBSETS];
  41. vbuffer_h vb;
  42. ibuffer_h ib;
  43. };
  44. typedef mesh_t* mesh_h;
  45. //-----------------------------------------------------------------------------
  46. mesh_h mesh_load( const char* dir, const char* name );
  47. //-----------------------------------------------------------------------------