render_mesh.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #ifndef DEPTHGUIDE_RENDER_MESH_H
  2. #define DEPTHGUIDE_RENDER_MESH_H
  3. #include "render_utility.h"
  4. #include <memory>
  5. class mesh_type {
  6. public:
  7. ~mesh_type();
  8. struct create_config {
  9. std::string path;
  10. };
  11. using this_type = mesh_type;
  12. using pointer = std::shared_ptr<mesh_type>;
  13. static pointer create(const create_config &conf);
  14. struct gl_info_type : private boost::noncopyable {
  15. GLuint vao = 0; // Vertex Array Object
  16. GLuint vbo = 0; // Vertex Buffer Object
  17. GLuint ebo = 0; // Element Buffer Object
  18. GLuint num_triangle = 0; // number of triangles
  19. ~gl_info_type();
  20. };
  21. gl_info_type *get_gl_info();
  22. private:
  23. struct impl;
  24. std::unique_ptr<impl> pimpl;
  25. };
  26. using mesh_ptr = mesh_type::pointer;
  27. enum mesh_render_mode {
  28. MESH_NORMAL,
  29. MESH_DEPTH_ALPHA
  30. };
  31. struct material_type {
  32. glm::vec3 ambient;
  33. glm::vec3 diffuse;
  34. };
  35. struct mesh_info_type {
  36. mesh_type *mesh = nullptr;
  37. glm::mat4 transform = {};
  38. // make scene_render happy
  39. using material_type = ::material_type;
  40. material_type material = {};
  41. };
  42. struct camera_info_type {
  43. glm::mat4 transform;
  44. glm::mat4 project;
  45. };
  46. struct light_info_type {
  47. glm::vec3 direction;
  48. };
  49. struct mesh_render_info {
  50. mesh_render_mode mode = MESH_NORMAL;
  51. mesh_info_type model = {};
  52. camera_info_type camera = {};
  53. light_info_type light = {};
  54. union {
  55. struct {
  56. } normal;
  57. struct {
  58. mesh_info_type bg;
  59. float alpha_factor;
  60. bool show_bg;
  61. } depth_alpha;
  62. } extra = {};
  63. };
  64. void render_mesh(const mesh_render_info &info);
  65. #endif //DEPTHGUIDE_RENDER_MESH_H