]> git.localhorst.tv Git - blank.git/blobdiff - src/graphics/PrimitiveMesh.hpp
avoid zero vertex draw calls
[blank.git] / src / graphics / PrimitiveMesh.hpp
index 013bf37bde34175c57b0d13c773fa11334eb3cda..577321a73e8204e281a265c8402d193900445cbe 100644 (file)
@@ -16,7 +16,7 @@ class PrimitiveMesh {
 
 public:
        using Position = glm::vec3;
-       using Color = glm::vec4;
+       using Color = glm::tvec4<unsigned char>;
        using Index = unsigned short;
 
        using Positions = std::vector<Position>;
@@ -50,13 +50,13 @@ public:
 
                void FillRect(
                        float w, float h,
-                       const glm::vec4 &color = glm::vec4(0.0f),
+                       const Color &color = Color(0),
                        const glm::vec2 &pivot = glm::vec2(0.0f)
                );
 
                void OutlineBox(
                        const AABB &,
-                       const glm::vec4 &color = glm::vec4(0.0f)
+                       const Color &color = Color(0)
                );
 
        };
@@ -66,8 +66,14 @@ public:
 public:
        void Update(const Buffer &) noexcept;
 
-       void DrawLines() noexcept;
-       void DrawTriangles() noexcept;
+       bool Empty() const noexcept {
+               return vao.Empty();
+       }
+
+       void DrawLines() const noexcept;
+       void DrawTriangles() const noexcept {
+               vao.DrawTriangleElements();
+       }
 
 private:
        VAO vao;