Browse Source

Primitives: Square can be now solid or wireframe.

pull/7/head
Vladimír Vondruš 13 years ago
parent
commit
0f27fb536f
  1. 24
      src/Primitives/Square.cpp
  2. 23
      src/Primitives/Square.h

24
src/Primitives/Square.cpp

@ -16,14 +16,26 @@
#include "Square.h" #include "Square.h"
#include "Math/Point2D.h" #include "Math/Point2D.h"
#include "Trade/MeshData2D.h"
namespace Magnum { namespace Primitives { namespace Magnum { namespace Primitives {
Square::Square(): MeshData2D(Mesh::Primitive::TriangleStrip, nullptr, {new std::vector<Point2D>{ Trade::MeshData2D Square::solid() {
{1.0f, -1.0f}, return Trade::MeshData2D(Mesh::Primitive::TriangleStrip, nullptr, {new std::vector<Point2D>{
{1.0f, 1.0f}, {1.0f, -1.0f},
{-1.0f, -1.0f}, {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<Point2D>{
{-1.0f, -1.0f},
{1.0f, -1.0f},
{1.0f, 1.0f},
{-1.0f, 1.0f}
}}, {});
}
}} }}

23
src/Primitives/Square.h

@ -19,19 +19,32 @@
* @brief Class Magnum::Primitives::Square * @brief Class Magnum::Primitives::Square
*/ */
#include "Trade/MeshData2D.h" #include "Trade/Trade.h"
namespace Magnum { namespace Primitives { namespace Magnum { namespace Primitives {
/** /**
@brief 2D square primitive @brief 2D square primitive
2x2 square as triangle strip, non-indexed. 2x2 square.
*/ */
class Square: public Trade::MeshData2D { class Square {
public: 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;
}; };
}} }}

Loading…
Cancel
Save