From 5d9490c73bc99a5b24b9fcdd37c716d122aed1ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 11 Dec 2013 12:59:22 +0100 Subject: [PATCH] Extracted Primitive enum from Mesh to MeshPrimitive. Because we can't forward-declare class members we would need to include whole Mesh (along with all OpenGL headers and other stuff) just to use Primitive enum. The old Mesh::Primitive is now alias to new one, is marked as deprecated and will be removed in future release. --- src/DebugTools/ForceRenderer.cpp | 2 +- .../Implementation/AbstractBoxRenderer.cpp | 1 + .../Implementation/CapsuleRenderer.cpp | 1 + src/DebugTools/ObjectRenderer.cpp | 2 +- src/Magnum.h | 2 + src/Mesh.cpp | 18 +- src/Mesh.h | 174 +++++++++--------- src/MeshTools/FullScreenTriangle.cpp | 2 +- src/Primitives/Capsule.cpp | 9 +- src/Primitives/Capsule.h | 10 +- src/Primitives/Circle.cpp | 9 +- src/Primitives/Circle.h | 4 +- src/Primitives/Crosshair.cpp | 5 +- src/Primitives/Crosshair.h | 4 +- src/Primitives/Cube.cpp | 5 +- src/Primitives/Cube.h | 4 +- src/Primitives/Cylinder.cpp | 5 +- src/Primitives/Cylinder.h | 4 +- src/Primitives/Icosphere.cpp | 5 +- src/Primitives/Icosphere.h | 2 +- src/Primitives/Implementation/Spheroid.cpp | 3 +- .../Implementation/WireframeSpheroid.cpp | 3 +- src/Primitives/Line.cpp | 5 +- src/Primitives/Line.h | 4 +- src/Primitives/Plane.cpp | 5 +- src/Primitives/Plane.h | 4 +- src/Primitives/Square.cpp | 5 +- src/Primitives/Square.h | 4 +- src/Primitives/UVSphere.cpp | 5 +- src/Primitives/UVSphere.h | 8 +- src/Test/MeshTest.cpp | 8 +- src/Text/Renderer.cpp | 4 +- src/TextureTools/DistanceField.cpp | 2 +- src/Trade/MeshData2D.cpp | 2 +- src/Trade/MeshData2D.h | 12 +- src/Trade/MeshData3D.cpp | 2 +- src/Trade/MeshData3D.h | 12 +- 37 files changed, 192 insertions(+), 164 deletions(-) diff --git a/src/DebugTools/ForceRenderer.cpp b/src/DebugTools/ForceRenderer.cpp index e72c03551..cf5f75421 100644 --- a/src/DebugTools/ForceRenderer.cpp +++ b/src/DebugTools/ForceRenderer.cpp @@ -86,7 +86,7 @@ template ForceRenderer::ForceRenderer(SceneG ResourceManager::instance().set(this->indexBuffer.key(), indexBuffer, ResourceDataState::Final, ResourcePolicy::Manual); Mesh* mesh = new Mesh; - mesh->setPrimitive(Mesh::Primitive::Lines) + mesh->setPrimitive(MeshPrimitive::Lines) .setIndexCount(indices.size()) .addVertexBuffer(*vertexBuffer, 0, typename Shaders::Flat::Position(Shaders::Flat::Position::Components::Two)) diff --git a/src/DebugTools/Implementation/AbstractBoxRenderer.cpp b/src/DebugTools/Implementation/AbstractBoxRenderer.cpp index 5c7624d37..8e5cd07b6 100644 --- a/src/DebugTools/Implementation/AbstractBoxRenderer.cpp +++ b/src/DebugTools/Implementation/AbstractBoxRenderer.cpp @@ -24,6 +24,7 @@ #include "AbstractBoxRenderer.h" +#include "Mesh.h" #include "Primitives/Cube.h" #include "Primitives/Square.h" #include "Trade/MeshData2D.h" diff --git a/src/DebugTools/Implementation/CapsuleRenderer.cpp b/src/DebugTools/Implementation/CapsuleRenderer.cpp index ef158ba7a..a2f3d9568 100644 --- a/src/DebugTools/Implementation/CapsuleRenderer.cpp +++ b/src/DebugTools/Implementation/CapsuleRenderer.cpp @@ -24,6 +24,7 @@ #include "CapsuleRenderer.h" +#include "Mesh.h" #include "MeshView.h" #include "DebugTools/ResourceManager.h" #include "DebugTools/ShapeRenderer.h" diff --git a/src/DebugTools/ObjectRenderer.cpp b/src/DebugTools/ObjectRenderer.cpp index 84cb49177..dd20e7d8c 100644 --- a/src/DebugTools/ObjectRenderer.cpp +++ b/src/DebugTools/ObjectRenderer.cpp @@ -164,7 +164,7 @@ template ObjectRenderer::ObjectRenderer(Scen indexBuffer->setData(Renderer::indices, BufferUsage::StaticDraw); ResourceManager::instance().set(this->indexBuffer.key(), indexBuffer, ResourceDataState::Final, ResourcePolicy::Manual); - mesh->setPrimitive(Mesh::Primitive::Lines) + mesh->setPrimitive(MeshPrimitive::Lines) .setIndexCount(Renderer::indices.size()) .addVertexBuffer(*vertexBuffer, 0, typename Shaders::VertexColor::Position(), diff --git a/src/Magnum.h b/src/Magnum.h index 7485b1fcb..95494aeb9 100644 --- a/src/Magnum.h +++ b/src/Magnum.h @@ -582,6 +582,8 @@ typedef ImageReference<1> ImageReference1D; typedef ImageReference<2> ImageReference2D; typedef ImageReference<3> ImageReference3D; +enum class MeshPrimitive: GLenum; + class Mesh; class MeshView; diff --git a/src/Mesh.cpp b/src/Mesh.cpp index 8c8cdd234..6aa1e8475 100644 --- a/src/Mesh.cpp +++ b/src/Mesh.cpp @@ -82,7 +82,7 @@ std::size_t Mesh::indexSize(IndexType type) { CORRADE_ASSERT_UNREACHABLE(); } -Mesh::Mesh(Primitive primitive): _primitive(primitive), _vertexCount(0), _indexCount(0) +Mesh::Mesh(MeshPrimitive primitive): _primitive(primitive), _vertexCount(0), _indexCount(0) #ifndef MAGNUM_TARGET_GLES2 , _indexStart(0), _indexEnd(0) #endif @@ -379,9 +379,9 @@ void Mesh::unbindImplementationDefault() { void Mesh::unbindImplementationVAO() {} #ifndef DOXYGEN_GENERATING_OUTPUT -Debug operator<<(Debug debug, Mesh::Primitive value) { +Debug operator<<(Debug debug, MeshPrimitive value) { switch(value) { - #define _c(value) case Mesh::Primitive::value: return debug << "Mesh::Primitive::" #value; + #define _c(value) case MeshPrimitive::value: return debug << "MeshPrimitive::" #value; _c(Points) _c(LineStrip) _c(LineLoop) @@ -401,7 +401,7 @@ Debug operator<<(Debug debug, Mesh::Primitive value) { #undef _c } - return debug << "Mesh::Primitive::(invalid)"; + return debug << "MeshPrimitive::(invalid)"; } Debug operator<<(Debug debug, Mesh::IndexType value) { @@ -421,9 +421,9 @@ Debug operator<<(Debug debug, Mesh::IndexType value) { namespace Corrade { namespace Utility { -std::string ConfigurationValue::toString(Magnum::Mesh::Primitive value, ConfigurationValueFlags) { +std::string ConfigurationValue::toString(Magnum::MeshPrimitive value, ConfigurationValueFlags) { switch(value) { - #define _c(value) case Magnum::Mesh::Primitive::value: return #value; + #define _c(value) case Magnum::MeshPrimitive::value: return #value; _c(Points) _c(LineStrip) _c(LineLoop) @@ -446,8 +446,8 @@ std::string ConfigurationValue::toString(Magnum::Mesh:: return {}; } -Magnum::Mesh::Primitive ConfigurationValue::fromString(const std::string& stringValue, ConfigurationValueFlags) { - #define _c(value) if(stringValue == #value) return Magnum::Mesh::Primitive::value; +Magnum::MeshPrimitive ConfigurationValue::fromString(const std::string& stringValue, ConfigurationValueFlags) { + #define _c(value) if(stringValue == #value) return Magnum::MeshPrimitive::value; _c(LineStrip) _c(LineLoop) _c(Lines) @@ -465,7 +465,7 @@ Magnum::Mesh::Primitive ConfigurationValue::fromString( #endif #undef _c - return Magnum::Mesh::Primitive::Points; + return Magnum::MeshPrimitive::Points; } std::string ConfigurationValue::toString(Magnum::Mesh::IndexType value, ConfigurationValueFlags) { diff --git a/src/Mesh.h b/src/Mesh.h index 8af843eec..57af67504 100644 --- a/src/Mesh.h +++ b/src/Mesh.h @@ -35,6 +35,80 @@ namespace Magnum { +/** + * @brief %Mesh primitive type + * + * @see @ref Mesh::primitive(), @ref Mesh::setPrimitive() + */ +enum class MeshPrimitive: GLenum { + /** Single points. */ + Points = GL_POINTS, + + /** + * First two vertices define first line segment, each following + * vertex defines another segment. + */ + LineStrip = GL_LINE_STRIP, + + /** Line strip, last and first vertex are connected together. */ + LineLoop = GL_LINE_LOOP, + + /** + * Each pair of vertices defines a single line, lines aren't + * connected together. + */ + Lines = GL_LINES, + + #ifndef MAGNUM_TARGET_GLES + /** + * Line strip with adjacency information. + * @requires_gl32 %Extension @extension{ARB,geometry_shader4} + */ + LineStripAdjacency = GL_LINE_STRIP_ADJACENCY, + + /** + * Lines with adjacency information. + * @requires_gl32 %Extension @extension{ARB,geometry_shader4} + */ + LinesAdjacency = GL_LINES_ADJACENCY, + #endif + + /** + * First three vertices define first triangle, each following + * vertex defines another triangle. + */ + TriangleStrip = GL_TRIANGLE_STRIP, + + /** + * First vertex is center, each following vertex is connected to + * previous and center vertex. + */ + TriangleFan = GL_TRIANGLE_FAN, + + /** Each three vertices define one triangle. */ + Triangles = GL_TRIANGLES, + + #ifndef MAGNUM_TARGET_GLES + /** + * Triangle strip with adjacency information. + * @requires_gl32 %Extension @extension{ARB,geometry_shader4} + */ + TriangleStripAdjacency = GL_TRIANGLE_STRIP_ADJACENCY, + + /** + * Triangles with adjacency information. + * @requires_gl32 %Extension @extension{ARB,geometry_shader4} + */ + TrianglesAdjacency = GL_TRIANGLES_ADJACENCY, + + /** + * Patches. + * @requires_gl40 %Extension @extension{ARB,tessellation_shader} + */ + Patches = GL_PATCHES + #endif +}; + /** @brief %Mesh @@ -86,7 +160,7 @@ static constexpr Vector3 positions[30] = { vertexBuffer.setData(positions, BufferUsage::StaticDraw); // Set primitive and vertex count, add the buffer and specify its layout -mesh.setPrimitive(Mesh::Primitive::Triangles) +mesh.setPrimitive(MeshPrimitive::Triangles) .setVertexCount(30) .addVertexBuffer(vertexBuffer, 0, MyShader::Position()); @endcode @@ -135,7 +209,7 @@ static constexpr GLubyte indices[75] = { indexBuffer.setData(indices, BufferUsage::StaticDraw); // Set primitive, index count, specify the buffers -mesh.setPrimitive(Mesh::Primitive::Triangles) +mesh.setPrimitive(MeshPrimitive::Triangles) .setIndexCount(75) .addVertexBuffer(vertexBuffer, 0, MyShader::Position()) .setIndexBuffer(indexBuffer, 0, Mesh::IndexType::UnsignedByte, 176, 229); @@ -238,79 +312,13 @@ class MAGNUM_EXPORT Mesh { friend class MeshView; public: + #ifdef MAGNUM_BUILD_DEPRECATED /** - * @brief Primitive type - * - * @see @ref primitive(), @ref setPrimitive() + * @copybrief MeshPrimitive + * @deprecated Use @ref Magnum::MeshPrimitive "MeshPrimitive" instead. */ - enum class Primitive: GLenum { - /** Single points. */ - Points = GL_POINTS, - - /** - * First two vertices define first line segment, each following - * vertex defines another segment. - */ - LineStrip = GL_LINE_STRIP, - - /** Line strip, last and first vertex are connected together. */ - LineLoop = GL_LINE_LOOP, - - /** - * Each pair of vertices defines a single line, lines aren't - * connected together. - */ - Lines = GL_LINES, - - #ifndef MAGNUM_TARGET_GLES - /** - * Line strip with adjacency information. - * @requires_gl32 %Extension @extension{ARB,geometry_shader4} - */ - LineStripAdjacency = GL_LINE_STRIP_ADJACENCY, - - /** - * Lines with adjacency information. - * @requires_gl32 %Extension @extension{ARB,geometry_shader4} - */ - LinesAdjacency = GL_LINES_ADJACENCY, - #endif - - /** - * First three vertices define first triangle, each following - * vertex defines another triangle. - */ - TriangleStrip = GL_TRIANGLE_STRIP, - - /** - * First vertex is center, each following vertex is connected to - * previous and center vertex. - */ - TriangleFan = GL_TRIANGLE_FAN, - - /** Each three vertices define one triangle. */ - Triangles = GL_TRIANGLES, - - #ifndef MAGNUM_TARGET_GLES - /** - * Triangle strip with adjacency information. - * @requires_gl32 %Extension @extension{ARB,geometry_shader4} - */ - TriangleStripAdjacency = GL_TRIANGLE_STRIP_ADJACENCY, - - /** - * Triangles with adjacency information. - * @requires_gl32 %Extension @extension{ARB,geometry_shader4} - */ - TrianglesAdjacency = GL_TRIANGLES_ADJACENCY, - - /** - * Patches. - * @requires_gl40 %Extension @extension{ARB,tessellation_shader} - */ - Patches = GL_PATCHES - #endif - }; + typedef CORRADE_DEPRECATED("use MeshPrimitive instead") MeshPrimitive Primitive; + #endif /** * @brief Index type @@ -377,7 +385,7 @@ class MAGNUM_EXPORT Mesh { * @see @ref setPrimitive(), @ref setVertexCount(), @fn_gl{GenVertexArrays} * (if @extension{APPLE,vertex_array_object} is available) */ - explicit Mesh(Primitive primitive = Primitive::Triangles); + explicit Mesh(MeshPrimitive primitive = MeshPrimitive::Triangles); /** @brief Copying is not allowed */ Mesh(const Mesh&) = delete; @@ -407,16 +415,16 @@ class MAGNUM_EXPORT Mesh { std::size_t indexSize() const { return indexSize(_indexType); } /** @brief Primitive type */ - Primitive primitive() const { return _primitive; } + MeshPrimitive primitive() const { return _primitive; } /** * @brief Set primitive type * @return Reference to self (for method chaining) * - * Default is @ref Primitive::Triangles. + * Default is @ref MeshPrimitive::Triangles. * @see @ref setVertexCount(), @ref addVertexBuffer() */ - Mesh& setPrimitive(Primitive primitive) { + Mesh& setPrimitive(MeshPrimitive primitive) { _primitive = primitive; return *this; } @@ -743,7 +751,7 @@ class MAGNUM_EXPORT Mesh { static MAGNUM_LOCAL UnbindImplementation unbindImplementation; GLuint _id; - Primitive _primitive; + MeshPrimitive _primitive; Int _vertexCount, _indexCount; #ifndef MAGNUM_TARGET_GLES2 UnsignedInt _indexStart, _indexEnd; @@ -762,7 +770,7 @@ class MAGNUM_EXPORT Mesh { }; /** @debugoperator{Magnum::Mesh} */ -Debug MAGNUM_EXPORT operator<<(Debug debug, Mesh::Primitive value); +Debug MAGNUM_EXPORT operator<<(Debug debug, MeshPrimitive value); /** @debugoperator{Magnum::Mesh} */ Debug MAGNUM_EXPORT operator<<(Debug debug, Mesh::IndexType value); @@ -772,7 +780,7 @@ Debug MAGNUM_EXPORT operator<<(Debug debug, Mesh::IndexType value); namespace Corrade { namespace Utility { /** @configurationvalue{Magnum::Mesh} */ -template<> struct MAGNUM_EXPORT ConfigurationValue { +template<> struct MAGNUM_EXPORT ConfigurationValue { ConfigurationValue() = delete; /** @@ -780,14 +788,14 @@ template<> struct MAGNUM_EXPORT ConfigurationValue { * * If the value is invalid, returns empty string. */ - static std::string toString(Magnum::Mesh::Primitive value, ConfigurationValueFlags); + static std::string toString(Magnum::MeshPrimitive value, ConfigurationValueFlags); /** * @brief Reads enum value as string * - * If the value is invalid, returns @ref Magnum::Mesh::Primitive::Points "Mesh::Primitive::Points". + * If the value is invalid, returns @ref Magnum::MeshPrimitive::Points "MeshPrimitive::Points". */ - static Magnum::Mesh::Primitive fromString(const std::string& stringValue, ConfigurationValueFlags); + static Magnum::MeshPrimitive fromString(const std::string& stringValue, ConfigurationValueFlags); }; /** @configurationvalue{Magnum::Mesh} */ diff --git a/src/MeshTools/FullScreenTriangle.cpp b/src/MeshTools/FullScreenTriangle.cpp index da3518248..80d7ca37f 100644 --- a/src/MeshTools/FullScreenTriangle.cpp +++ b/src/MeshTools/FullScreenTriangle.cpp @@ -34,7 +34,7 @@ namespace Magnum { namespace MeshTools { std::pair fullScreenTriangle() { Mesh mesh; - mesh.setPrimitive(Mesh::Primitive::Triangles) + mesh.setPrimitive(MeshPrimitive::Triangles) .setVertexCount(3); Buffer* buffer = nullptr; diff --git a/src/Primitives/Capsule.cpp b/src/Primitives/Capsule.cpp index 88cb08983..5f4ee0220 100644 --- a/src/Primitives/Capsule.cpp +++ b/src/Primitives/Capsule.cpp @@ -26,6 +26,7 @@ #include "Math/Vector3.h" #include "Math/Functions.h" +#include "Mesh.h" #include "Primitives/Implementation/Spheroid.h" #include "Primitives/Implementation/WireframeSpheroid.h" #include "Trade/MeshData2D.h" @@ -34,7 +35,7 @@ namespace Magnum { namespace Primitives { Trade::MeshData2D Capsule2D::wireframe(UnsignedInt hemisphereRings, UnsignedInt cylinderRings, Float halfLength) { - CORRADE_ASSERT(hemisphereRings >= 1 && cylinderRings >= 1, "Capsule must have at least one hemisphere ring, one cylinder ring and three segments", Trade::MeshData2D(Mesh::Primitive::Lines, std::vector{}, std::vector>{}, std::vector>{})); + CORRADE_ASSERT(hemisphereRings >= 1 && cylinderRings >= 1, "Capsule must have at least one hemisphere ring, one cylinder ring and three segments", Trade::MeshData2D(MeshPrimitive::Lines, std::vector{}, std::vector>{}, std::vector>{})); std::vector positions; positions.reserve(hemisphereRings*4+2+(cylinderRings-1)*2); @@ -85,11 +86,11 @@ Trade::MeshData2D Capsule2D::wireframe(UnsignedInt hemisphereRings, UnsignedInt {UnsignedInt(positions.size())-3, UnsignedInt(positions.size())-1, UnsignedInt(positions.size())-2, UnsignedInt(positions.size())-1}); - return Trade::MeshData2D(Mesh::Primitive::Lines, std::move(indices), {std::move(positions)}, std::vector>{}); + return Trade::MeshData2D(MeshPrimitive::Lines, std::move(indices), {std::move(positions)}, std::vector>{}); } Trade::MeshData3D Capsule3D::solid(UnsignedInt hemisphereRings, UnsignedInt cylinderRings, UnsignedInt segments, Float halfLength, TextureCoords textureCoords) { - CORRADE_ASSERT(hemisphereRings >= 1 && cylinderRings >= 1 && segments >= 3, "Capsule must have at least one hemisphere ring, one cylinder ring and three segments", Trade::MeshData3D(Mesh::Primitive::Triangles, std::vector{}, std::vector>{}, std::vector>{}, std::vector>{})); + CORRADE_ASSERT(hemisphereRings >= 1 && cylinderRings >= 1 && segments >= 3, "Capsule must have at least one hemisphere ring, one cylinder ring and three segments", Trade::MeshData3D(MeshPrimitive::Triangles, std::vector{}, std::vector>{}, std::vector>{}, std::vector>{})); Implementation::Spheroid capsule(segments, textureCoords == TextureCoords::Generate ? Implementation::Spheroid::TextureCoords::Generate : @@ -123,7 +124,7 @@ Trade::MeshData3D Capsule3D::solid(UnsignedInt hemisphereRings, UnsignedInt cyli } Trade::MeshData3D Capsule3D::wireframe(const UnsignedInt hemisphereRings, const UnsignedInt cylinderRings, const UnsignedInt segments, const Float halfLength) { - CORRADE_ASSERT(hemisphereRings >= 1 && cylinderRings >= 1 && segments >= 4 && segments%4 == 0, "Primitives::Capsule::wireframe(): improper parameters", Trade::MeshData3D(Mesh::Primitive::Lines, std::vector{}, std::vector>{}, std::vector>{}, std::vector>{})); + CORRADE_ASSERT(hemisphereRings >= 1 && cylinderRings >= 1 && segments >= 4 && segments%4 == 0, "Primitives::Capsule::wireframe(): improper parameters", Trade::MeshData3D(MeshPrimitive::Lines, std::vector{}, std::vector>{}, std::vector>{}, std::vector>{})); Implementation::WireframeSpheroid capsule(segments/4); diff --git a/src/Primitives/Capsule.h b/src/Primitives/Capsule.h index 64adb1dbd..35508fe9e 100644 --- a/src/Primitives/Capsule.h +++ b/src/Primitives/Capsule.h @@ -48,7 +48,7 @@ class MAGNUM_PRIMITIVES_EXPORT Capsule2D { * larger or equal to 1. * @param halfLength Half the length of cylinder part * - * Indexed @ref Mesh::Primitive "Lines". + * Indexed @ref MeshPrimitive::Lines. */ static Trade::MeshData2D wireframe(UnsignedInt hemisphereRings, UnsignedInt cylinderRings, Float halfLength); }; @@ -77,9 +77,9 @@ class MAGNUM_PRIMITIVES_EXPORT Capsule3D { * @param halfLength Half the length of cylinder part * @param textureCoords Whether to generate texture coordinates. * - * Indexed @ref Mesh::Primitive "Triangles" with normals and optional - * 2D texture coordinates. If texture coordinates are generated, - * vertices of one segment are duplicated for texture wrapping. + * Indexed @ref MeshPrimitive::Triangles with normals and optional 2D + * texture coordinates. If texture coordinates are generated, vertices + * of one segment are duplicated for texture wrapping. */ static Trade::MeshData3D solid(UnsignedInt hemisphereRings, UnsignedInt cylinderRings, UnsignedInt segments, Float halfLength, TextureCoords textureCoords = TextureCoords::DontGenerate); @@ -93,7 +93,7 @@ class MAGNUM_PRIMITIVES_EXPORT Capsule3D { * equal to 4 and multiple of 4. * @param halfLength Half the length of cylinder part * - * Indexed @ref Mesh::Primitive "Lines". + * Indexed @ref MeshPrimitive::Lines. */ static Trade::MeshData3D wireframe(UnsignedInt hemisphereRings, UnsignedInt cylinderRings, UnsignedInt segments, Float halfLength); }; diff --git a/src/Primitives/Circle.cpp b/src/Primitives/Circle.cpp index 8a1f45c5b..0edbe633c 100644 --- a/src/Primitives/Circle.cpp +++ b/src/Primitives/Circle.cpp @@ -26,13 +26,14 @@ #include "Math/Functions.h" #include "Math/Vector2.h" +#include "Mesh.h" #include "Trade/MeshData2D.h" namespace Magnum { namespace Primitives { Trade::MeshData2D Circle::solid(UnsignedInt segments) { CORRADE_ASSERT(segments >= 3, "Primitives::Circle::solid(): segments must be >= 3", - Trade::MeshData2D(Mesh::Primitive::TriangleFan, std::vector{}, std::vector>{}, std::vector>{})); + Trade::MeshData2D(MeshPrimitive::TriangleFan, std::vector{}, std::vector>{}, std::vector>{})); std::vector positions; positions.reserve(segments+1); @@ -47,12 +48,12 @@ Trade::MeshData2D Circle::solid(UnsignedInt segments) { positions.emplace_back(Math::cos(angle), Math::sin(angle)); } - return Trade::MeshData2D(Mesh::Primitive::TriangleFan, std::vector{}, {std::move(positions)}, std::vector>{}); + return Trade::MeshData2D(MeshPrimitive::TriangleFan, std::vector{}, {std::move(positions)}, std::vector>{}); } Trade::MeshData2D Circle::wireframe(UnsignedInt segments) { CORRADE_ASSERT(segments >= 3, "Primitives::Circle::wireframe(): segments must be >= 3", - Trade::MeshData2D(Mesh::Primitive::LineLoop, std::vector{}, std::vector>{}, std::vector>{})); + Trade::MeshData2D(MeshPrimitive::LineLoop, std::vector{}, std::vector>{}, std::vector>{})); std::vector positions; positions.reserve(segments); @@ -64,7 +65,7 @@ Trade::MeshData2D Circle::wireframe(UnsignedInt segments) { positions.emplace_back(Math::cos(angle), Math::sin(angle)); } - return Trade::MeshData2D(Mesh::Primitive::LineLoop, std::vector{}, {std::move(positions)}, std::vector>{}); + return Trade::MeshData2D(MeshPrimitive::LineLoop, std::vector{}, {std::move(positions)}, std::vector>{}); } }} diff --git a/src/Primitives/Circle.h b/src/Primitives/Circle.h index b97c1e7b2..e0829c982 100644 --- a/src/Primitives/Circle.h +++ b/src/Primitives/Circle.h @@ -45,7 +45,7 @@ class MAGNUM_PRIMITIVES_EXPORT Circle { * @brief Solid circle * @param segments Number of segments. Must be greater or equal to 3. * - * Non-indexed @ref Mesh::Primitive "TriangleFan". + * Non-indexed @ref MeshPrimitive::TriangleFan. */ static Trade::MeshData2D solid(UnsignedInt segments); @@ -53,7 +53,7 @@ class MAGNUM_PRIMITIVES_EXPORT Circle { * @brief Wireframe circle * @param segments Number of segments. Must be greater or equal to 3. * - * Non-indexed @ref Mesh::Primitive "LineLoop". + * Non-indexed @ref MeshPrimitive::LineLoop. */ static Trade::MeshData2D wireframe(UnsignedInt segments); diff --git a/src/Primitives/Crosshair.cpp b/src/Primitives/Crosshair.cpp index 396cf24fa..ba3cfa26a 100644 --- a/src/Primitives/Crosshair.cpp +++ b/src/Primitives/Crosshair.cpp @@ -25,20 +25,21 @@ #include "Crosshair.h" #include "Math/Vector3.h" +#include "Mesh.h" #include "Trade/MeshData2D.h" #include "Trade/MeshData3D.h" namespace Magnum { namespace Primitives { Trade::MeshData2D Crosshair2D::wireframe() { - return Trade::MeshData2D(Mesh::Primitive::Lines, std::vector{}, {{ + return Trade::MeshData2D(MeshPrimitive::Lines, std::vector{}, {{ {-1.0f, 0.0f}, {1.0f, 0.0f}, { 0.0f, -1.0f}, {0.0f, 1.0f} }}, std::vector>{}); } Trade::MeshData3D Crosshair3D::wireframe() { - return Trade::MeshData3D(Mesh::Primitive::Lines, std::vector{}, {{ + return Trade::MeshData3D(MeshPrimitive::Lines, std::vector{}, {{ {-1.0f, 0.0f, 0.0f}, {1.0f, 0.0f, 0.0f}, { 0.0f, -1.0f, 0.0f}, {0.0f, 1.0f, 0.0f}, { 0.0f, 0.0f, -1.0f}, {0.0f, 0.0f, 1.0f} diff --git a/src/Primitives/Crosshair.h b/src/Primitives/Crosshair.h index b8d1a2783..eae905e2e 100644 --- a/src/Primitives/Crosshair.h +++ b/src/Primitives/Crosshair.h @@ -38,7 +38,7 @@ namespace Magnum { namespace Primitives { @brief 2D crosshair primitive 2x2 wireframe crosshair (two crossed lines), non-indexed -@ref Mesh::Primitive "Lines". +@ref MeshPrimitive::Lines. */ class MAGNUM_PRIMITIVES_EXPORT Crosshair2D { public: @@ -52,7 +52,7 @@ class MAGNUM_PRIMITIVES_EXPORT Crosshair2D { @brief 3D crosshair primitive 2x2x2 wireframe crosshair (three crossed lines), non-indexed -@ref Mesh::Primitive "Lines". +@ref MeshPrimitive::Lines. */ class MAGNUM_PRIMITIVES_EXPORT Crosshair3D { public: diff --git a/src/Primitives/Cube.cpp b/src/Primitives/Cube.cpp index 6809b723b..15f5965e8 100644 --- a/src/Primitives/Cube.cpp +++ b/src/Primitives/Cube.cpp @@ -25,12 +25,13 @@ #include "Cube.h" #include "Math/Vector3.h" +#include "Mesh.h" #include "Trade/MeshData3D.h" namespace Magnum { namespace Primitives { Trade::MeshData3D Cube::solid() { - return Trade::MeshData3D(Mesh::Primitive::Triangles, { + return Trade::MeshData3D(MeshPrimitive::Triangles, { 0, 1, 2, 0, 2, 3, /* +Z */ 4, 5, 6, 4, 6, 7, /* +X */ 8, 9, 10, 8, 10, 11, /* +Y */ @@ -101,7 +102,7 @@ Trade::MeshData3D Cube::solid() { } Trade::MeshData3D Cube::wireframe() { - return Trade::MeshData3D(Mesh::Primitive::Lines, { + return Trade::MeshData3D(MeshPrimitive::Lines, { 0, 1, 1, 2, 2, 3, 3, 0, /* +Z */ 4, 5, 5, 6, 6, 7, 7, 4, /* -Z */ 1, 5, 2, 6, /* +X */ diff --git a/src/Primitives/Cube.h b/src/Primitives/Cube.h index 52cdee061..653db9e9a 100644 --- a/src/Primitives/Cube.h +++ b/src/Primitives/Cube.h @@ -44,14 +44,14 @@ class MAGNUM_PRIMITIVES_EXPORT Cube { /** * @brief Solid cube * - * Indexed @ref Mesh::Primitive "Triangles" with flat normals. + * Indexed @ref MeshPrimitive::Triangles with flat normals. */ static Trade::MeshData3D solid(); /** * @brief Wireframe cube * - * Indexed @ref Mesh::Primitive "Lines". + * Indexed @ref MeshPrimitive::Lines. */ static Trade::MeshData3D wireframe(); diff --git a/src/Primitives/Cylinder.cpp b/src/Primitives/Cylinder.cpp index 4f02a8d6d..ae85a1777 100644 --- a/src/Primitives/Cylinder.cpp +++ b/src/Primitives/Cylinder.cpp @@ -25,6 +25,7 @@ #include "Cylinder.h" #include "Math/Vector3.h" +#include "Mesh.h" #include "Primitives/Implementation/Spheroid.h" #include "Primitives/Implementation/WireframeSpheroid.h" #include "Trade/MeshData3D.h" @@ -32,7 +33,7 @@ namespace Magnum { namespace Primitives { Trade::MeshData3D Cylinder::solid(const UnsignedInt rings, const UnsignedInt segments, const Float halfLength, const Flags flags) { - CORRADE_ASSERT(rings >= 1 && segments >= 3, "Primitives::Cylinder::solid(): cylinder must have at least one ring and three segments", Trade::MeshData3D(Mesh::Primitive::Triangles, std::vector{}, std::vector>{}, std::vector>{}, std::vector>{})); + CORRADE_ASSERT(rings >= 1 && segments >= 3, "Primitives::Cylinder::solid(): cylinder must have at least one ring and three segments", Trade::MeshData3D(MeshPrimitive::Triangles, std::vector{}, std::vector>{}, std::vector>{}, std::vector>{})); Implementation::Spheroid cylinder(segments, flags & Flag::GenerateTextureCoords ? Implementation::Spheroid::TextureCoords::Generate : Implementation::Spheroid::TextureCoords::DontGenerate); @@ -63,7 +64,7 @@ Trade::MeshData3D Cylinder::solid(const UnsignedInt rings, const UnsignedInt seg } Trade::MeshData3D Cylinder::wireframe(const UnsignedInt rings, const UnsignedInt segments, const Float halfLength) { - CORRADE_ASSERT(rings >= 1 && segments >= 4 && segments%4 == 0, "Primitives::Cylinder::wireframe(): improper parameters", Trade::MeshData3D(Mesh::Primitive::Lines, std::vector{}, std::vector>{}, std::vector>{}, std::vector>{})); + CORRADE_ASSERT(rings >= 1 && segments >= 4 && segments%4 == 0, "Primitives::Cylinder::wireframe(): improper parameters", Trade::MeshData3D(MeshPrimitive::Lines, std::vector{}, std::vector>{}, std::vector>{}, std::vector>{})); Implementation::WireframeSpheroid cylinder(segments/4); diff --git a/src/Primitives/Cylinder.h b/src/Primitives/Cylinder.h index e00946d63..bc95ad19a 100644 --- a/src/Primitives/Cylinder.h +++ b/src/Primitives/Cylinder.h @@ -65,7 +65,7 @@ class MAGNUM_PRIMITIVES_EXPORT Cylinder { * @param halfLength Half the cylinder length * @param flags Flags * - * Indexed @ref Mesh::Primitive "Triangles" with normals, optional 2D + * Indexed @ref MeshPrimitive::Triangles with normals, optional 2D * texture coordinates and optional capped ends. If texture coordinates * are generated, vertices of one segment are duplicated for texture * wrapping. @@ -80,7 +80,7 @@ class MAGNUM_PRIMITIVES_EXPORT Cylinder { * equal to 4 and multiple of 4. * @param halfLength Half the cylinder length * - * Indexed @ref Mesh::Primitive "Lines". + * Indexed @ref MeshPrimitive::Lines. */ static Trade::MeshData3D wireframe(UnsignedInt rings, UnsignedInt segments, Float halfLength); }; diff --git a/src/Primitives/Icosphere.cpp b/src/Primitives/Icosphere.cpp index 3ec685aa3..0c82d1217 100644 --- a/src/Primitives/Icosphere.cpp +++ b/src/Primitives/Icosphere.cpp @@ -25,9 +25,10 @@ #include "Icosphere.h" #include "Math/Vector3.h" -#include "Trade/MeshData3D.h" +#include "Mesh.h" #include "MeshTools/Subdivide.h" #include "MeshTools/RemoveDuplicates.h" +#include "Trade/MeshData3D.h" namespace Magnum { namespace Primitives { @@ -78,7 +79,7 @@ Trade::MeshData3D Icosphere::solid(const UnsignedInt subdivisions) { MeshTools::removeDuplicates(indices, positions); std::vector normals(positions); - return Trade::MeshData3D(Mesh::Primitive::Triangles, std::move(indices), {std::move(positions)}, {std::move(normals)}, std::vector>{}); + return Trade::MeshData3D(MeshPrimitive::Triangles, std::move(indices), {std::move(positions)}, {std::move(normals)}, std::vector>{}); } }} diff --git a/src/Primitives/Icosphere.h b/src/Primitives/Icosphere.h index e0a39360f..7ac15e4a2 100644 --- a/src/Primitives/Icosphere.h +++ b/src/Primitives/Icosphere.h @@ -45,7 +45,7 @@ class MAGNUM_PRIMITIVES_EXPORT Icosphere { * @brief Solid icosphere * @param subdivisions Number of subdivisions * - * Indexed @ref Mesh::Primitive "Triangles" with normals. + * Indexed @ref MeshPrimitive::Triangles with normals. */ static Trade::MeshData3D solid(UnsignedInt subdivisions); }; diff --git a/src/Primitives/Implementation/Spheroid.cpp b/src/Primitives/Implementation/Spheroid.cpp index e8a1a1cb6..05d2e50a7 100644 --- a/src/Primitives/Implementation/Spheroid.cpp +++ b/src/Primitives/Implementation/Spheroid.cpp @@ -26,6 +26,7 @@ #include "Math/Functions.h" #include "Math/Vector3.h" +#include "Mesh.h" #include "Trade/MeshData3D.h" namespace Magnum { namespace Primitives { namespace Implementation { @@ -161,7 +162,7 @@ void Spheroid::capVertexRing(Float y, Float textureCoordsV, const Vector3& norma } Trade::MeshData3D Spheroid::finalize() { - return Trade::MeshData3D(Mesh::Primitive::Triangles, std::move(indices), {std::move(positions)}, {std::move(normals)}, + return Trade::MeshData3D(MeshPrimitive::Triangles, std::move(indices), {std::move(positions)}, {std::move(normals)}, textureCoords == TextureCoords::Generate ? std::vector>{std::move(textureCoords2D)} : std::vector>()); } diff --git a/src/Primitives/Implementation/WireframeSpheroid.cpp b/src/Primitives/Implementation/WireframeSpheroid.cpp index 475ba759a..434da874b 100644 --- a/src/Primitives/Implementation/WireframeSpheroid.cpp +++ b/src/Primitives/Implementation/WireframeSpheroid.cpp @@ -26,6 +26,7 @@ #include "Math/Functions.h" #include "Math/Vector3.h" +#include "Mesh.h" #include "Trade/MeshData3D.h" namespace Magnum { namespace Primitives { namespace Implementation { @@ -109,7 +110,7 @@ void WireframeSpheroid::cylinder() { } Trade::MeshData3D WireframeSpheroid::finalize() { - return Trade::MeshData3D(Mesh::Primitive::Lines, std::move(_indices), {std::move(_positions)}, std::vector>{}, std::vector>{}); + return Trade::MeshData3D(MeshPrimitive::Lines, std::move(_indices), {std::move(_positions)}, std::vector>{}, std::vector>{}); } }}} diff --git a/src/Primitives/Line.cpp b/src/Primitives/Line.cpp index 016f6d082..e7255b7cd 100644 --- a/src/Primitives/Line.cpp +++ b/src/Primitives/Line.cpp @@ -25,19 +25,20 @@ #include "Line.h" #include "Math/Vector3.h" +#include "Mesh.h" #include "Trade/MeshData2D.h" #include "Trade/MeshData3D.h" namespace Magnum { namespace Primitives { Trade::MeshData2D Line2D::wireframe() { - return Trade::MeshData2D(Mesh::Primitive::Lines, std::vector{}, {{ + return Trade::MeshData2D(MeshPrimitive::Lines, std::vector{}, {{ {0.0f, 0.0f}, {1.0f, 0.0f} }}, std::vector>{}); } Trade::MeshData3D Line3D::wireframe() { - return Trade::MeshData3D(Mesh::Primitive::Lines, std::vector{}, {{ + return Trade::MeshData3D(MeshPrimitive::Lines, std::vector{}, {{ {0.0f, 0.0f, 0.0f}, {1.0f, 0.0f, 0.0f}, }}, std::vector>{}, std::vector>{}); } diff --git a/src/Primitives/Line.h b/src/Primitives/Line.h index 59a0d7a6c..868e963bd 100644 --- a/src/Primitives/Line.h +++ b/src/Primitives/Line.h @@ -38,7 +38,7 @@ namespace Magnum { namespace Primitives { @brief 2D line primitive Unit-size line in direction of positive X axis. Non-indexed -@ref Mesh::Primitive "Lines". +@ref MeshPrimitive::Lines. */ class MAGNUM_PRIMITIVES_EXPORT Line2D { public: @@ -52,7 +52,7 @@ class MAGNUM_PRIMITIVES_EXPORT Line2D { @brief 3D line primitive Unit-size line in direction of positive X axis. Non-indexed -@ref Mesh::Primitive "Lines". +@ref MeshPrimitive::Lines. */ class MAGNUM_PRIMITIVES_EXPORT Line3D { public: diff --git a/src/Primitives/Plane.cpp b/src/Primitives/Plane.cpp index a454ef645..3451168f0 100644 --- a/src/Primitives/Plane.cpp +++ b/src/Primitives/Plane.cpp @@ -25,6 +25,7 @@ #include "Plane.h" #include "Math/Vector3.h" +#include "Mesh.h" #include "Trade/MeshData3D.h" namespace Magnum { namespace Primitives { @@ -38,7 +39,7 @@ Trade::MeshData3D Plane::solid(const TextureCoords textureCoords) { {0.0f, 1.0f} }); - return Trade::MeshData3D(Mesh::Primitive::TriangleStrip, std::vector{}, {{ + return Trade::MeshData3D(MeshPrimitive::TriangleStrip, std::vector{}, {{ {1.0f, -1.0f, 0.0f}, {1.0f, 1.0f, 0.0f}, {-1.0f, -1.0f, 0.0f}, @@ -52,7 +53,7 @@ Trade::MeshData3D Plane::solid(const TextureCoords textureCoords) { } Trade::MeshData3D Plane::wireframe() { - return Trade::MeshData3D(Mesh::Primitive::LineLoop, std::vector{}, {{ + return Trade::MeshData3D(MeshPrimitive::LineLoop, std::vector{}, {{ {-1.0f, -1.0f, 0.0f}, {1.0f, -1.0f, 0.0f}, {1.0f, 1.0f, 0.0f}, diff --git a/src/Primitives/Plane.h b/src/Primitives/Plane.h index b25273124..efdc08d02 100644 --- a/src/Primitives/Plane.h +++ b/src/Primitives/Plane.h @@ -53,7 +53,7 @@ class MAGNUM_PRIMITIVES_EXPORT Plane { /** * @brief Solid plane * - * Non-indexed @ref Mesh::Primitive "TriangleStrip" with normals in + * Non-indexed @ref MeshPrimitive::TriangleStrip with normals in * positive Z direction. */ static Trade::MeshData3D solid(TextureCoords textureCoords = TextureCoords::DontGenerate); @@ -61,7 +61,7 @@ class MAGNUM_PRIMITIVES_EXPORT Plane { /** * @brief Wireframe plane * - * Non-indexed @ref Mesh::Primitive "LineLoop". + * Non-indexed @ref MeshPrimitive::LineLoop. */ static Trade::MeshData3D wireframe(); diff --git a/src/Primitives/Square.cpp b/src/Primitives/Square.cpp index 93e72b198..c83802563 100644 --- a/src/Primitives/Square.cpp +++ b/src/Primitives/Square.cpp @@ -25,6 +25,7 @@ #include "Square.h" #include "Math/Vector2.h" +#include "Mesh.h" #include "Trade/MeshData2D.h" namespace Magnum { namespace Primitives { @@ -38,7 +39,7 @@ Trade::MeshData2D Square::solid(const TextureCoords textureCoords) { {0.0f, 1.0f} }); - return Trade::MeshData2D(Mesh::Primitive::TriangleStrip, std::vector{}, {{ + return Trade::MeshData2D(MeshPrimitive::TriangleStrip, std::vector{}, {{ {1.0f, -1.0f}, {1.0f, 1.0f}, {-1.0f, -1.0f}, @@ -47,7 +48,7 @@ Trade::MeshData2D Square::solid(const TextureCoords textureCoords) { } Trade::MeshData2D Square::wireframe() { - return Trade::MeshData2D(Mesh::Primitive::LineLoop, std::vector{}, {{ + return Trade::MeshData2D(MeshPrimitive::LineLoop, std::vector{}, {{ {-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 77a7afedb..85993082a 100644 --- a/src/Primitives/Square.h +++ b/src/Primitives/Square.h @@ -53,14 +53,14 @@ class MAGNUM_PRIMITIVES_EXPORT Square { /** * @brief Solid square * - * Non-indexed @ref Mesh::Primitive "TriangleStrip". + * Non-indexed @ref MeshPrimitive::TriangleStrip. */ static Trade::MeshData2D solid(TextureCoords textureCoords = TextureCoords::DontGenerate); /** * @brief Wireframe square * - * Non-indexed @ref Mesh::Primitive "LineLoop." + * Non-indexed @ref MeshPrimitive::LineLoop. */ static Trade::MeshData2D wireframe(); diff --git a/src/Primitives/UVSphere.cpp b/src/Primitives/UVSphere.cpp index dd0c23972..b6ace4dc8 100644 --- a/src/Primitives/UVSphere.cpp +++ b/src/Primitives/UVSphere.cpp @@ -25,6 +25,7 @@ #include "UVSphere.h" #include "Math/Vector3.h" +#include "Mesh.h" #include "Primitives/Implementation/Spheroid.h" #include "Primitives/Implementation/WireframeSpheroid.h" #include "Trade/MeshData3D.h" @@ -32,7 +33,7 @@ namespace Magnum { namespace Primitives { Trade::MeshData3D UVSphere::solid(UnsignedInt rings, UnsignedInt segments, TextureCoords textureCoords) { - CORRADE_ASSERT(rings >= 2 && segments >= 3, "UVSphere must have at least two rings and three segments", Trade::MeshData3D(Mesh::Primitive::Triangles, std::vector{}, std::vector>{}, std::vector>{}, std::vector>{})); + CORRADE_ASSERT(rings >= 2 && segments >= 3, "UVSphere must have at least two rings and three segments", Trade::MeshData3D(MeshPrimitive::Triangles, std::vector{}, std::vector>{}, std::vector>{}, std::vector>{})); Implementation::Spheroid sphere(segments, textureCoords == TextureCoords::Generate ? Implementation::Spheroid::TextureCoords::Generate : @@ -59,7 +60,7 @@ Trade::MeshData3D UVSphere::solid(UnsignedInt rings, UnsignedInt segments, Textu } Trade::MeshData3D UVSphere::wireframe(const UnsignedInt rings, const UnsignedInt segments) { - CORRADE_ASSERT(rings >= 2 && rings%2 == 0 && segments >= 4 && segments%2 == 0, "Primitives::UVSphere::wireframe(): improper parameters", Trade::MeshData3D(Mesh::Primitive::Lines, std::vector{}, std::vector>{}, std::vector>{}, std::vector>{})); + CORRADE_ASSERT(rings >= 2 && rings%2 == 0 && segments >= 4 && segments%2 == 0, "Primitives::UVSphere::wireframe(): improper parameters", Trade::MeshData3D(MeshPrimitive::Lines, std::vector{}, std::vector>{}, std::vector>{}, std::vector>{})); Implementation::WireframeSpheroid sphere(segments/4); diff --git a/src/Primitives/UVSphere.h b/src/Primitives/UVSphere.h index df0fcdda5..fee053691 100644 --- a/src/Primitives/UVSphere.h +++ b/src/Primitives/UVSphere.h @@ -54,9 +54,9 @@ class MAGNUM_PRIMITIVES_EXPORT UVSphere { * equal to 3. * @param textureCoords Whether to generate texture coordinates. * - * Indexed @ref Mesh::Primitive "Triangles" with normals and optional - * 2D texture coordinates. If texture coordinates are generated, - * vertices of one segment are duplicated for texture wrapping. + * Indexed @ref MeshPrimitive::Triangles with normals and optional 2D + * texture coordinates. If texture coordinates are generated, vertices + * of one segment are duplicated for texture wrapping. */ static Trade::MeshData3D solid(UnsignedInt rings, UnsignedInt segments, TextureCoords textureCoords = TextureCoords::DontGenerate); @@ -67,7 +67,7 @@ class MAGNUM_PRIMITIVES_EXPORT UVSphere { * @param segments Number of (line) segments. Must be larger or * equal to 4 and multiple of 4. * - * Indexed @ref Mesh::Primitive "Lines". + * Indexed @ref MeshPrimitive::Lines. */ static Trade::MeshData3D wireframe(UnsignedInt rings, UnsignedInt segments); }; diff --git a/src/Test/MeshTest.cpp b/src/Test/MeshTest.cpp index 0f8ed4271..afe8d57db 100644 --- a/src/Test/MeshTest.cpp +++ b/src/Test/MeshTest.cpp @@ -49,8 +49,8 @@ MeshTest::MeshTest() { void MeshTest::debugPrimitive() { std::ostringstream o; - Debug(&o) << Mesh::Primitive::TriangleFan; - CORRADE_COMPARE(o.str(), "Mesh::Primitive::TriangleFan\n"); + Debug(&o) << MeshPrimitive::TriangleFan; + CORRADE_COMPARE(o.str(), "MeshPrimitive::TriangleFan\n"); } void MeshTest::debugIndexType() { @@ -62,9 +62,9 @@ void MeshTest::debugIndexType() { void MeshTest::configurationPrimitive() { Utility::Configuration c; - c.setValue("primitive", Mesh::Primitive::LineStrip); + c.setValue("primitive", MeshPrimitive::LineStrip); CORRADE_COMPARE(c.value("primitive"), "LineStrip"); - CORRADE_COMPARE(c.value("primitive"), Mesh::Primitive::LineStrip); + CORRADE_COMPARE(c.value("primitive"), MeshPrimitive::LineStrip); } void MeshTest::configurationIndexType() { diff --git a/src/Text/Renderer.cpp b/src/Text/Renderer.cpp index 053a67e4a..605ed274e 100644 --- a/src/Text/Renderer.cpp +++ b/src/Text/Renderer.cpp @@ -211,7 +211,7 @@ std::tuple renderInternal(AbstractFont& font, const GlyphCache& c /* Configure mesh except for vertex buffer (depends on dimension count, done in subclass) */ Mesh mesh; - mesh.setPrimitive(Mesh::Primitive::Triangles) + mesh.setPrimitive(MeshPrimitive::Triangles) .setIndexCount(indexCount) .setIndexBuffer(indexBuffer, 0, indexType, 0, vertexCount); @@ -317,7 +317,7 @@ AbstractRenderer::AbstractRenderer(AbstractFont& font, const GlyphCache& cache, #endif /* Vertex buffer configuration depends on dimension count, done in subclass */ - _mesh.setPrimitive(Mesh::Primitive::Triangles); + _mesh.setPrimitive(MeshPrimitive::Triangles); } AbstractRenderer::~AbstractRenderer() {} diff --git a/src/TextureTools/DistanceField.cpp b/src/TextureTools/DistanceField.cpp index b8d8aa2ba..52e75465f 100644 --- a/src/TextureTools/DistanceField.cpp +++ b/src/TextureTools/DistanceField.cpp @@ -175,7 +175,7 @@ void distanceField(Texture2D& input, Texture2D& output, const Range2Di& rectangl } Mesh mesh; - mesh.setPrimitive(Mesh::Primitive::Triangles) + mesh.setPrimitive(MeshPrimitive::Triangles) .setVertexCount(3); /* Older GLSL doesn't have gl_VertexID, vertices must be supplied explicitly */ diff --git a/src/Trade/MeshData2D.cpp b/src/Trade/MeshData2D.cpp index 4e06a1b00..217de6e10 100644 --- a/src/Trade/MeshData2D.cpp +++ b/src/Trade/MeshData2D.cpp @@ -28,7 +28,7 @@ namespace Magnum { namespace Trade { -MeshData2D::MeshData2D(Mesh::Primitive primitive, std::vector indices, std::vector> positions, std::vector> textureCoords2D): _primitive(primitive), _indices(std::move(indices)), _positions(std::move(positions)), _textureCoords2D(std::move(textureCoords2D)) { +MeshData2D::MeshData2D(MeshPrimitive primitive, std::vector indices, std::vector> positions, std::vector> textureCoords2D): _primitive(primitive), _indices(std::move(indices)), _positions(std::move(positions)), _textureCoords2D(std::move(textureCoords2D)) { CORRADE_ASSERT(!_positions.empty(), "Trade::MeshData2D: no position array specified", ); } diff --git a/src/Trade/MeshData2D.h b/src/Trade/MeshData2D.h index bed9b2d3e..a064977cb 100644 --- a/src/Trade/MeshData2D.h +++ b/src/Trade/MeshData2D.h @@ -28,9 +28,11 @@ * @brief Class Magnum::Trade::MeshData2D */ -#include +#include -#include "Mesh.h" +#include "Magnum.h" + +#include "magnumVisibility.h" namespace Magnum { namespace Trade { @@ -53,7 +55,7 @@ class MAGNUM_EXPORT MeshData2D { * @param textureCoords2D Two-dimensional texture coordinate arrays, * if present */ - explicit MeshData2D(Mesh::Primitive primitive, std::vector indices, std::vector> positions, std::vector> textureCoords2D); + explicit MeshData2D(MeshPrimitive primitive, std::vector indices, std::vector> positions, std::vector> textureCoords2D); /** @brief Copying is not allowed */ MeshData2D(const MeshData2D&) = delete; @@ -70,7 +72,7 @@ class MAGNUM_EXPORT MeshData2D { MeshData2D& operator=(MeshData2D&&); /** @brief Primitive */ - Mesh::Primitive primitive() const { return _primitive; } + MeshPrimitive primitive() const { return _primitive; } /** @brief Whether the mesh is indexed */ bool isIndexed() const { return !_indices.empty(); } @@ -115,7 +117,7 @@ class MAGNUM_EXPORT MeshData2D { const std::vector& textureCoords2D(UnsignedInt id) const; /**< @overload */ private: - Mesh::Primitive _primitive; + MeshPrimitive _primitive; std::vector _indices; std::vector> _positions; std::vector> _textureCoords2D; diff --git a/src/Trade/MeshData3D.cpp b/src/Trade/MeshData3D.cpp index a483521ec..fa103dc8d 100644 --- a/src/Trade/MeshData3D.cpp +++ b/src/Trade/MeshData3D.cpp @@ -28,7 +28,7 @@ namespace Magnum { namespace Trade { -MeshData3D::MeshData3D(Mesh::Primitive primitive, std::vector indices, std::vector> positions, std::vector> normals, std::vector> textureCoords2D): _primitive(primitive), _indices(std::move(indices)), _positions(std::move(positions)), _normals(std::move(normals)), _textureCoords2D(std::move(textureCoords2D)) { +MeshData3D::MeshData3D(MeshPrimitive primitive, std::vector indices, std::vector> positions, std::vector> normals, std::vector> textureCoords2D): _primitive(primitive), _indices(std::move(indices)), _positions(std::move(positions)), _normals(std::move(normals)), _textureCoords2D(std::move(textureCoords2D)) { CORRADE_ASSERT(!_positions.empty(), "Trade::MeshData3D: no position array specified", ); } diff --git a/src/Trade/MeshData3D.h b/src/Trade/MeshData3D.h index d157da1cc..d1440affb 100644 --- a/src/Trade/MeshData3D.h +++ b/src/Trade/MeshData3D.h @@ -28,9 +28,11 @@ * @brief Class Magnum::Trade::MeshData3D */ -#include +#include -#include "Mesh.h" +#include "Magnum.h" + +#include "magnumVisibility.h" namespace Magnum { namespace Trade { @@ -54,7 +56,7 @@ class MAGNUM_EXPORT MeshData3D { * @param textureCoords2D Two-dimensional texture coordinate arrays, * if present */ - explicit MeshData3D(Mesh::Primitive primitive, std::vector indices, std::vector> positions, std::vector> normals, std::vector> textureCoords2D); + explicit MeshData3D(MeshPrimitive primitive, std::vector indices, std::vector> positions, std::vector> normals, std::vector> textureCoords2D); /** @brief Copying is not allowed */ MeshData3D(const MeshData3D&) = delete; @@ -71,7 +73,7 @@ class MAGNUM_EXPORT MeshData3D { MeshData3D& operator=(MeshData3D&&); /** @brief Primitive */ - Mesh::Primitive primitive() const { return _primitive; } + MeshPrimitive primitive() const { return _primitive; } /** @brief Whether the mesh is indexed */ bool isIndexed() const { return !_indices.empty(); } @@ -131,7 +133,7 @@ class MAGNUM_EXPORT MeshData3D { const std::vector& textureCoords2D(UnsignedInt id) const; /**< @overload */ private: - Mesh::Primitive _primitive; + MeshPrimitive _primitive; std::vector _indices; std::vector> _positions; std::vector> _normals;