#ifndef ENGINE_INCLUDE_RESOURCES_MESH_H_ #define ENGINE_INCLUDE_RESOURCES_MESH_H_ #include #include #include #include #include "gfx.h" #include "gfx_device.h" namespace engine { struct Vertex { glm::vec3 pos; glm::vec3 norm; glm::vec4 tangent; // w component flips binormal if -1. w should be 1 or -1 glm::vec2 uv; static constexpr int FloatsPerVertex() { return static_cast(sizeof(Vertex) / sizeof(float)); } }; } // namespace engine namespace engine { class Mesh { public: Mesh(GFXDevice* gfx, const std::vector& vertices); Mesh(GFXDevice* gfx, const std::vector& vertices, const std::vector& indices) : gfx_(gfx) { InitMesh(vertices, indices); } ~Mesh(); Mesh(const Mesh&) = delete; Mesh& operator=(const Mesh&) = delete; const gfx::Buffer* GetVB(); const gfx::Buffer* GetIB(); uint32_t GetCount(); private: GFXDevice* const gfx_; const gfx::Buffer* vb_; const gfx::Buffer* ib_; uint32_t count_; void InitMesh(const std::vector& vertices, const std::vector& indices); }; } // namespace engine #endif