X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fgraphics%2FEntityMesh.hpp;fp=src%2Fgraphics%2FEntityMesh.hpp;h=6b894f909f075fdd4a230d30c9801823dbf74a0a;hb=3542823a1af7f5063d7cc8da84efa248eb889b8a;hp=0000000000000000000000000000000000000000;hpb=1c2994622a6b73f90cbd3ec9c09ffb4d7724cab4;p=blank.git diff --git a/src/graphics/EntityMesh.hpp b/src/graphics/EntityMesh.hpp new file mode 100644 index 0000000..6b894f9 --- /dev/null +++ b/src/graphics/EntityMesh.hpp @@ -0,0 +1,81 @@ +#ifndef BLANK_GRAPHICS_ENTITYMESH_HPP_ +#define BLANK_GRAPHICS_ENTITYMESH_HPP_ + +#include "VertexArray.hpp" + +#include +#include +#include + + +namespace blank { + +class EntityMesh { + +public: + using Position = glm::vec3; + using TexCoord = glm::vec3; + using ColorMod = glm::vec3; + using Normal = glm::vec3; + using Index = unsigned int; + + using Positions = std::vector; + using TexCoords = std::vector; + using ColorMods = std::vector; + using Normals = std::vector; + using Indices = std::vector; + + enum Attribute { + ATTRIB_VERTEX, + ATTRIB_TEXCOORD, + ATTRIB_HSL, + ATTRIB_RGB, + ATTRIB_NORMAL, + ATTRIB_INDEX, + ATTRIB_COUNT, + }; + + struct Buffer { + + Positions vertices; + TexCoords tex_coords; + ColorMods hsl_mods; + ColorMods rgb_mods; + Normals normals; + Indices indices; + + void Clear() noexcept { + vertices.clear(); + tex_coords.clear(); + hsl_mods.clear(); + rgb_mods.clear(); + normals.clear(); + indices.clear(); + } + + void Reserve(size_t p, size_t i) { + vertices.reserve(p); + tex_coords.reserve(p); + hsl_mods.reserve(p); + rgb_mods.reserve(p); + normals.reserve(p); + indices.reserve(i); + } + + }; + + using VAO = VertexArray; + +public: + void Update(const Buffer &) noexcept; + + void Draw() const noexcept; + +private: + VAO vao; + +}; + +} + +#endif