X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fblock.cpp;fp=src%2Fblock.cpp;h=02e8476c4a2af7cf9ec407fd76040acf8c057dba;hb=804bde3fc09e4317eef629861638a68bfad3e343;hp=0000000000000000000000000000000000000000;hpb=bea14b67ae4e5705965f3cc6422410a25f38ef9e;p=blank.git diff --git a/src/block.cpp b/src/block.cpp new file mode 100644 index 0000000..02e8476 --- /dev/null +++ b/src/block.cpp @@ -0,0 +1,40 @@ +#include "block.hpp" + + +namespace blank { + +const BlockType BlockType::DEFAULT; +const NullShape BlockType::DEFAULT_SHAPE; + +void BlockType::FillVBO( + const glm::vec3 &pos, + std::vector &vertices, + std::vector &colors, + std::vector &normals +) const { + shape->Vertices(vertices, pos); + colors.insert(colors.end(), shape->VertexCount(), color); + shape->Normals(normals); +} + +void BlockType::FillOutlineVBO( + std::vector &vertices, + std::vector &colors +) const { + shape->Outline(vertices); + colors.insert(colors.end(), shape->OutlineCount(), outline_color); +} + + +BlockTypeRegistry::BlockTypeRegistry() { + Add(BlockType::DEFAULT); +} + +int BlockTypeRegistry::Add(const BlockType &t) { + int id = types.size(); + types.push_back(t); + types.back().id = id; + return id; +} + +}