From 0f27fb536f2cdfa102985eba5bd25e6c3846a5bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 24 Jan 2013 20:38:45 +0100 Subject: [PATCH] Primitives: Square can be now solid or wireframe. --- src/Primitives/Square.cpp | 24 ++++++++++++++++++------ src/Primitives/Square.h | 23 ++++++++++++++++++----- 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/src/Primitives/Square.cpp b/src/Primitives/Square.cpp index 57c601237..fe2dcd971 100644 --- a/src/Primitives/Square.cpp +++ b/src/Primitives/Square.cpp @@ -16,14 +16,26 @@ #include "Square.h" #include "Math/Point2D.h" +#include "Trade/MeshData2D.h" namespace Magnum { namespace Primitives { -Square::Square(): MeshData2D(Mesh::Primitive::TriangleStrip, nullptr, {new std::vector{ - {1.0f, -1.0f}, - {1.0f, 1.0f}, - {-1.0f, -1.0f}, - {-1.0f, 1.0f} -}}, {}) {} +Trade::MeshData2D Square::solid() { + return Trade::MeshData2D(Mesh::Primitive::TriangleStrip, nullptr, {new std::vector{ + {1.0f, -1.0f}, + {1.0f, 1.0f}, + {-1.0f, -1.0f}, + {-1.0f, 1.0f} + }}, {}); +} + +Trade::MeshData2D Square::wireframe() { + return Trade::MeshData2D(Mesh::Primitive::LineLoop, nullptr, {new std::vector{ + {-1.0f, -1.0f}, + {1.0f, -1.0f}, + {1.0f, 1.0f}, + {-1.0f, 1.0f} + }}, {}); +} }} diff --git a/src/Primitives/Square.h b/src/Primitives/Square.h index 7d3f96754..6bd77a172 100644 --- a/src/Primitives/Square.h +++ b/src/Primitives/Square.h @@ -19,19 +19,32 @@ * @brief Class Magnum::Primitives::Square */ -#include "Trade/MeshData2D.h" +#include "Trade/Trade.h" namespace Magnum { namespace Primitives { /** @brief 2D square primitive -2x2 square as triangle strip, non-indexed. +2x2 square. */ -class Square: public Trade::MeshData2D { +class Square { public: - /** @brief Constructor */ - explicit Square(); + /** + * @brief Solid square + * + * Non-indexed @ref Mesh::Primitive "TriangleStrip". + */ + static Trade::MeshData2D solid(); + + /** + * @brief Wireframe square + * + * Non-indexed @ref Mesh::Primitive "LineLoop." + */ + static Trade::MeshData2D wireframe(); + + Square() = delete; }; }}