diff options
| author | Mel <einebeere@gmail.com> | 2022-10-23 21:28:09 +0200 |
|---|---|---|
| committer | Mel <einebeere@gmail.com> | 2022-10-23 21:28:09 +0200 |
| commit | ad84d0686f1d7f72e86b55cdadd8272f225f776d (patch) | |
| tree | 4d3cb6fbc48f41126407d10eac3d835c1b2d0a91 /src/GFX/Mesh.hpp | |
| parent | 75a9c87b50cef2f1d749bd9042a9348bc28b4c09 (diff) | |
| download | meowcraft-ad84d0686f1d7f72e86b55cdadd8272f225f776d.tar.zst meowcraft-ad84d0686f1d7f72e86b55cdadd8272f225f776d.zip | |
Modular mesh vertex attributes
Diffstat (limited to 'src/GFX/Mesh.hpp')
| -rw-r--r-- | src/GFX/Mesh.hpp | 49 |
1 files changed, 22 insertions, 27 deletions
diff --git a/src/GFX/Mesh.hpp b/src/GFX/Mesh.hpp index c20b419..9d640b6 100644 --- a/src/GFX/Mesh.hpp +++ b/src/GFX/Mesh.hpp @@ -9,43 +9,38 @@ namespace MC::GFX { class Mesh { public: + struct Attribute { + template<size_t S = 3, typename T = float> + Attribute( + std::vector<Vector<S, T>> data + ) : data((T*) data.data()), + data_size(data.size()), + attribute_size(S), + type_size(sizeof(T)) {}; + + void* data; + long data_size; + int attribute_size; + int type_size; + }; + Mesh( - std::vector<Vector<3>> positions, - std::vector<Vector<3>> normals, - std::vector<Vector<2>> tex_coords, + std::vector<Attribute> attributes, std::vector<uint32_t> indices - ) : m_positions(std::move(positions)), - m_normals(std::move(normals)), - m_tex_coords(std::move(tex_coords)), + ) : m_attributes(std::move(attributes)), m_indices(std::move(indices)) {}; Mesh( - std::vector<Vector<3>> positions, - std::vector<Vector<3>> normals, - std::vector<Vector<2>> tex_coords - ) : m_positions(std::move(positions)), - m_normals(std::move(normals)), - m_tex_coords(std::move(tex_coords)), + std::vector<Attribute> attributes + ) : m_attributes(std::move(attributes)), m_indices() {}; - float* raw(); - size_t size(); - - float* raw_normals(); - size_t normals_size(); - - uint32_t* raw_indices(); - size_t indices_size(); - - float* raw_tex_coords(); - size_t tex_coords_size(); + std::vector<uint32_t> indices(); + std::vector<Attribute> attributes(); private: - std::vector<Vector<3>> m_positions; - std::vector<Vector<3>> m_normals; - std::vector<Vector<2>> m_tex_coords; + std::vector<Attribute> m_attributes; std::vector<uint32_t> m_indices; - }; } \ No newline at end of file |
