X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fgraphics%2Fmesh.cpp;h=906b20f3e0732d802e61c740380259f0d63fdc34;hb=f4729fcfcf6f4802dd2439aa23dc3a4faf39827d;hp=4a63d99c8f56a2f87612e4dd83748abe90324971;hpb=2da9efc1037fba0461303327151318b8edf4dfc7;p=blank.git diff --git a/src/graphics/mesh.cpp b/src/graphics/mesh.cpp index 4a63d99..906b20f 100644 --- a/src/graphics/mesh.cpp +++ b/src/graphics/mesh.cpp @@ -4,7 +4,7 @@ #include "SkyBoxMesh.hpp" #include "SpriteMesh.hpp" -#include "../model/geometry.hpp" +#include "../geometry/primitive.hpp" #include #include @@ -18,10 +18,10 @@ void EntityMesh::Update(const Buffer &buf) noexcept { std::cerr << "EntityMesh: not enough tex coords!" << std::endl; } if (buf.hsl_mods.size() < buf.vertices.size()) { - std::cerr << "BlockMesh: not enough HSL modifiers!" << std::endl; + std::cerr << "EntityMesh: not enough HSL modifiers!" << std::endl; } if (buf.rgb_mods.size() < buf.vertices.size()) { - std::cerr << "BlockMesh: not enough RGB modifiers!" << std::endl; + std::cerr << "EntityMesh: not enough RGB modifiers!" << std::endl; } if (buf.normals.size() < buf.vertices.size()) { std::cerr << "EntityMesh: not enough normals!" << std::endl; @@ -31,18 +31,13 @@ void EntityMesh::Update(const Buffer &buf) noexcept { vao.Bind(); vao.PushAttribute(ATTRIB_VERTEX, buf.vertices); vao.PushAttribute(ATTRIB_TEXCOORD, buf.tex_coords); - vao.PushAttribute(ATTRIB_HSL, buf.hsl_mods); - vao.PushAttribute(ATTRIB_RGB, buf.rgb_mods); + vao.PushAttribute(ATTRIB_HSL, buf.hsl_mods, true); + vao.PushAttribute(ATTRIB_RGB, buf.rgb_mods, true); vao.PushAttribute(ATTRIB_NORMAL, buf.normals); vao.PushIndices(ATTRIB_INDEX, buf.indices); } -void EntityMesh::Draw() const noexcept { - vao.DrawTriangleElements(); -} - - void BlockMesh::Update(const Buffer &buf) noexcept { #ifndef NDEBUG if (buf.tex_coords.size() < buf.vertices.size()) { @@ -62,21 +57,16 @@ void BlockMesh::Update(const Buffer &buf) noexcept { vao.Bind(); vao.PushAttribute(ATTRIB_VERTEX, buf.vertices); vao.PushAttribute(ATTRIB_TEXCOORD, buf.tex_coords); - vao.PushAttribute(ATTRIB_HSL, buf.hsl_mods); - vao.PushAttribute(ATTRIB_RGB, buf.rgb_mods); + vao.PushAttribute(ATTRIB_HSL, buf.hsl_mods, true); + vao.PushAttribute(ATTRIB_RGB, buf.rgb_mods, true); vao.PushAttribute(ATTRIB_LIGHT, buf.lights); vao.PushIndices(ATTRIB_INDEX, buf.indices); } -void BlockMesh::Draw() const noexcept { - vao.DrawTriangleElements(); -} - - void PrimitiveMesh::Buffer::FillRect( float w, float h, - const glm::vec4 &color, + const Color &color, const glm::vec2 &pivot ) { Clear(); @@ -92,7 +82,7 @@ void PrimitiveMesh::Buffer::FillRect( indices.assign({ 0, 2, 1, 1, 2, 3 }); } -void PrimitiveMesh::Buffer::OutlineBox(const AABB &box, const glm::vec4 &color) { +void PrimitiveMesh::Buffer::OutlineBox(const AABB &box, const Color &color) { Clear(); Reserve(8, 24); @@ -124,21 +114,17 @@ void PrimitiveMesh::Update(const Buffer &buf) noexcept { vao.Bind(); vao.PushAttribute(ATTRIB_VERTEX, buf.vertices); - vao.PushAttribute(ATTRIB_COLOR, buf.colors); + vao.PushAttribute(ATTRIB_COLOR, buf.colors, true); vao.PushIndices(ATTRIB_INDEX, buf.indices); } -void PrimitiveMesh::DrawLines() noexcept { +void PrimitiveMesh::DrawLines() const noexcept { glEnable(GL_LINE_SMOOTH); glLineWidth(2.0f); vao.DrawLineElements(); } -void PrimitiveMesh::DrawTriangles() noexcept { - vao.DrawTriangleElements(); -} - void SkyBoxMesh::LoadUnitBox() { Buffer buffer; @@ -169,10 +155,6 @@ void SkyBoxMesh::Update(const Buffer &buf) noexcept { vao.PushIndices(ATTRIB_INDEX, buf.indices); } -void SkyBoxMesh::Draw() const noexcept { - vao.DrawTriangleElements(); -} - void SpriteMesh::Buffer::LoadRect( float w, float h, @@ -210,9 +192,4 @@ void SpriteMesh::Update(const Buffer &buf) noexcept { vao.PushIndices(ATTRIB_INDEX, buf.indices); } - -void SpriteMesh::Draw() noexcept { - vao.DrawTriangleElements(); -} - }