X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmodel%2Fmodel.cpp;h=7aaf8f613b931a595e16a89800197260dd6fd044;hb=8ab4ea13545cccbacbd1ed610968d3f481c1b3c8;hp=b834298ac6c5354dff984b55fa4bc3b8b245c839;hpb=5998b18978bd8e7a0c9deb516474634e1d3521c9;p=blank.git diff --git a/src/model/model.cpp b/src/model/model.cpp index b834298..7aaf8f6 100644 --- a/src/model/model.cpp +++ b/src/model/model.cpp @@ -1,8 +1,11 @@ #include "BlockModel.hpp" #include "EntityModel.hpp" #include "OutlineModel.hpp" +#include "SkyBoxModel.hpp" #include "SpriteModel.hpp" +#include "shapes.hpp" + #include #include @@ -11,6 +14,9 @@ namespace blank { void EntityModel::Update(const Buffer &buf) noexcept { #ifndef NDEBUG + if (buf.tex_coords.size() < buf.vertices.size()) { + std::cerr << "EntityModel: not enough tex coords!" << std::endl; + } if (buf.colors.size() < buf.vertices.size()) { std::cerr << "EntityModel: not enough colors!" << std::endl; } @@ -21,6 +27,7 @@ void EntityModel::Update(const Buffer &buf) noexcept { vao.Bind(); vao.PushAttribute(ATTRIB_VERTEX, buf.vertices); + vao.PushAttribute(ATTRIB_TEXCOORD, buf.tex_coords); vao.PushAttribute(ATTRIB_COLOR, buf.colors); vao.PushAttribute(ATTRIB_NORMAL, buf.normals); vao.PushIndices(ATTRIB_INDEX, buf.indices); @@ -34,6 +41,9 @@ void EntityModel::Draw() const noexcept { void BlockModel::Update(const Buffer &buf) noexcept { #ifndef NDEBUG + if (buf.tex_coords.size() < buf.vertices.size()) { + std::cerr << "BlockModel: not enough tex coords!" << std::endl; + } if (buf.colors.size() < buf.vertices.size()) { std::cerr << "BlockModel: not enough colors!" << std::endl; } @@ -44,6 +54,7 @@ void BlockModel::Update(const Buffer &buf) noexcept { vao.Bind(); vao.PushAttribute(ATTRIB_VERTEX, buf.vertices); + vao.PushAttribute(ATTRIB_TEXCOORD, buf.tex_coords); vao.PushAttribute(ATTRIB_COLOR, buf.colors); vao.PushAttribute(ATTRIB_LIGHT, buf.lights); vao.PushIndices(ATTRIB_INDEX, buf.indices); @@ -76,6 +87,24 @@ void OutlineModel::Draw() noexcept { } +void SkyBoxModel::LoadUnitBox() { + Buffer buffer; + CuboidShape shape({{ -1, -1, -1 }, { 1, 1, 1 }}); + shape.Vertices(buffer); + Update(buffer); +} + +void SkyBoxModel::Update(const Buffer &buf) noexcept { + vao.Bind(); + vao.PushAttribute(ATTRIB_VERTEX, buf.vertices); + vao.PushIndices(ATTRIB_INDEX, buf.indices); +} + +void SkyBoxModel::Draw() const noexcept { + vao.DrawTriangleElements(); +} + + void SpriteModel::Buffer::LoadRect( float w, float h, const glm::vec2 &pivot,