From b43a6ee5868fcec39d13495b990f1c905be50b83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 17 Sep 2012 02:37:13 +0200 Subject: [PATCH] Square primitive. --- src/Primitives/CMakeLists.txt | 2 ++ src/Primitives/Square.cpp | 31 ++++++++++++++++++++++++++++ src/Primitives/Square.h | 39 +++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 src/Primitives/Square.cpp create mode 100644 src/Primitives/Square.h diff --git a/src/Primitives/CMakeLists.txt b/src/Primitives/CMakeLists.txt index e554119cb..d154d79c6 100644 --- a/src/Primitives/CMakeLists.txt +++ b/src/Primitives/CMakeLists.txt @@ -4,6 +4,7 @@ set(MagnumPrimitives_SRCS Cylinder.cpp Icosphere.cpp Plane.cpp + Square.cpp UVSphere.cpp) set(MagnumPrimitives_HEADERS Capsule.h @@ -11,6 +12,7 @@ set(MagnumPrimitives_HEADERS Cylinder.h Icosphere.h Plane.h + Square.h UVSphere.h) add_library(MagnumPrimitives STATIC ${MagnumPrimitives_SRCS}) diff --git a/src/Primitives/Square.cpp b/src/Primitives/Square.cpp new file mode 100644 index 000000000..1855bcd6e --- /dev/null +++ b/src/Primitives/Square.cpp @@ -0,0 +1,31 @@ +/* + Copyright © 2010, 2011, 2012 Vladimír Vondruš + + This file is part of Magnum. + + Magnum is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 3 + only, as published by the Free Software Foundation. + + Magnum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License version 3 for more details. +*/ + +#include "Square.h" + +#include "Math/Point2D.h" + +using namespace std; + +namespace Magnum { namespace Primitives { + +Square::Square(): MeshData2D("", Mesh::Primitive::TriangleStrip, nullptr, {new 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 new file mode 100644 index 000000000..67ad3ad5e --- /dev/null +++ b/src/Primitives/Square.h @@ -0,0 +1,39 @@ +#ifndef Magnum_Primitives_Square_h +#define Magnum_Primitives_Square_h +/* + Copyright © 2010, 2011, 2012 Vladimír Vondruš + + This file is part of Magnum. + + Magnum is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 3 + only, as published by the Free Software Foundation. + + Magnum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License version 3 for more details. +*/ + +/** @file + * @brief Class Magnum::Primitives::Square + */ + +#include "Trade/MeshData2D.h" + +namespace Magnum { namespace Primitives { + +/** +@brief %Square primitive + +2x2 square. +*/ +class Square: public Trade::MeshData2D { + public: + /** @brief Constructor */ + Square(); +}; + +}} + +#endif