From dc5a4d83d91a5c338e1e4eef19d2c16e64eb5ca7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 20 Jan 2013 18:42:19 +0100 Subject: [PATCH] Removing IndexedMesh, part 5: merged documentation, removed IndexedMesh. --- src/CMakeLists.txt | 1 - .../Implementation/AbstractBoxRenderer.cpp | 3 +- src/DebugTools/ObjectRenderer.cpp | 9 +- src/IndexedMesh.h | 87 ---------- src/Magnum.h | 1 - src/Mesh.h | 150 ++++++++++++++---- src/MeshTools/CompressIndices.cpp | 18 +-- src/MeshTools/CompressIndices.h | 17 +- src/MeshTools/Test/CompressIndicesTest.cpp | 22 +-- src/Text/TextRenderer.cpp | 9 +- src/Text/TextRenderer.h | 2 +- 11 files changed, 161 insertions(+), 158 deletions(-) delete mode 100644 src/IndexedMesh.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 666f1c0d3..833bdc617 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -65,7 +65,6 @@ set(Magnum_HEADERS Framebuffer.h Image.h ImageWrapper.h - IndexedMesh.h Magnum.h Mesh.h Query.h diff --git a/src/DebugTools/Implementation/AbstractBoxRenderer.cpp b/src/DebugTools/Implementation/AbstractBoxRenderer.cpp index e3283626b..2d74d216e 100644 --- a/src/DebugTools/Implementation/AbstractBoxRenderer.cpp +++ b/src/DebugTools/Implementation/AbstractBoxRenderer.cpp @@ -16,7 +16,6 @@ #include "AbstractBoxRenderer.h" #include "Buffer.h" -#include "IndexedMesh.h" #include "DebugTools/ResourceManager.h" #include "MeshTools/CompressIndices.h" #include "Primitives/Cube.h" @@ -66,7 +65,7 @@ AbstractBoxRenderer<3>::AbstractBoxRenderer() { Primitives::Cube cube; Buffer* vertexBuffer = new Buffer(Buffer::Target::Array); Buffer* indexBuffer = new Buffer(Buffer::Target::ElementArray); - IndexedMesh* mesh = new IndexedMesh; + Mesh* mesh = new Mesh; vertexBuffer->setData(*cube.positions(0), Buffer::Usage::StaticDraw); ResourceManager::instance()->set(this->vertexBuffer.key(), vertexBuffer, ResourceDataState::Final, ResourcePolicy::Manual); diff --git a/src/DebugTools/ObjectRenderer.cpp b/src/DebugTools/ObjectRenderer.cpp index 39367cc56..5285f15e4 100644 --- a/src/DebugTools/ObjectRenderer.cpp +++ b/src/DebugTools/ObjectRenderer.cpp @@ -16,7 +16,6 @@ #include "ObjectRenderer.h" #include "Buffer.h" -#include "IndexedMesh.h" #include "DebugTools/ResourceManager.h" #include "MeshTools/Interleave.h" #include "SceneGraph/AbstractCamera.h" @@ -149,7 +148,7 @@ template ObjectRenderer::ObjectRenderer(Sce /* Create the mesh */ Buffer* vertexBuffer = new Buffer(Buffer::Target::Array); Buffer* indexBuffer = new Buffer(Buffer::Target::ElementArray); - IndexedMesh* mesh = new IndexedMesh; + Mesh* mesh = new Mesh; MeshTools::interleave(mesh, vertexBuffer, Buffer::Usage::StaticDraw, Renderer::positions, Renderer::colors); ResourceManager::instance()->set(this->vertexBuffer.key(), vertexBuffer, ResourceDataState::Final, ResourcePolicy::Manual); @@ -158,9 +157,11 @@ template ObjectRenderer::ObjectRenderer(Sce ResourceManager::instance()->set(this->indexBuffer.key(), indexBuffer, ResourceDataState::Final, ResourcePolicy::Manual); mesh->setPrimitive(Mesh::Primitive::Lines) - ->addInterleavedVertexBuffer(vertexBuffer, 0, typename Shaders::VertexColorShader::Position(), typename Shaders::VertexColorShader::Color()) ->setIndexCount(Renderer::indices.size()) - ->setIndexType(IndexedMesh::IndexType::UnsignedByte) + ->setIndexType(Mesh::IndexType::UnsignedByte) + ->addInterleavedVertexBuffer(vertexBuffer, 0, + typename Shaders::VertexColorShader::Position(), + typename Shaders::VertexColorShader::Color()) ->setIndexBuffer(indexBuffer); ResourceManager::instance()->set(this->mesh.key(), mesh, ResourceDataState::Final, ResourcePolicy::Manual); } diff --git a/src/IndexedMesh.h b/src/IndexedMesh.h deleted file mode 100644 index ea06a9513..000000000 --- a/src/IndexedMesh.h +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef Magnum_IndexedMesh_h -#define Magnum_IndexedMesh_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::IndexedMesh - */ - -#include "Mesh.h" - -#include "corradeCompatibility.h" - -namespace Magnum { - -/** -@brief Indexed mesh - -@section IndexedMesh-configuration Indexed mesh configuration - -Next to @ref Mesh-configuration "everything needed for non-indexed mesh" you -have to call also setIndexCount() and setIndexType(). Then create index buffer -and assign it to the mesh using setIndexBuffer() or use -MeshTools::compressIndices() to conveniently fill the index buffer and set -index count and type. - -Similarly as in Mesh itself the index buffer is not managed by the mesh, so -you have to manage it on your own. On the other hand it allows you to use -one index buffer for more meshes (with different vertex data in each mesh, for -example) or store more than only index data in one buffer. - -Example usage -- creating a cube mesh, assigning vertex buffer with -interleaved vertex attributes and compressed index buffer for use with -Shaders::PhongShader: -@code -Buffer *vertexBuffer, *indexBuffer; -Mesh* mesh; - -Primitives::Cube cube; -MeshTools::interleave(mesh, vertexBuffer, Buffer::Usage::StaticDraw, *cube.positions(0), *cube.normals(0)); -MeshTools::compressIndices(mesh, indexBuffer, Buffer::Usage::StaticDraw, *cube.indices()); -mesh->setPrimitive(plane.primitive()) - ->addInterleavedVertexBuffer(vertexBuffer, 0, Shaders::PhongShader::Position(), Shaders::PhongShader::Normal()); -@endcode - -@section IndexedMesh-drawing Rendering meshes - -From user point-of-view the operation is the same as for -@ref Mesh-drawing "non-indexed meshes". - -@section IndexedMesh-performance-optimization Performance optimizations - -If @extension{APPLE,vertex_array_object}, OpenGL ES 3.0 or -@es_extension{OES,vertex_array_object} on OpenGL ES 2.0 is supported, next to -@ref Mesh-performance-optimization "optimizations in Mesh itself" the index -buffer is bound on object construction instead of binding it in every draw() -call. -*/ -class MAGNUM_EXPORT IndexedMesh: public Mesh { - friend class Context; - - public: - /** - * @brief Constructor - * @param primitive Primitive type - * - * Creates indexed mesh with zero vertex count, zero index count and - * no vertex or index buffers. - */ - inline explicit IndexedMesh(Primitive primitive = Primitive::Triangles): Mesh(primitive) {} -}; - -} - -#endif diff --git a/src/Magnum.h b/src/Magnum.h index 5880f51e9..017261599 100644 --- a/src/Magnum.h +++ b/src/Magnum.h @@ -172,7 +172,6 @@ typedef ImageWrapper<1> ImageWrapper1D; typedef ImageWrapper<2> ImageWrapper2D; typedef ImageWrapper<3> ImageWrapper3D; -class IndexedMesh; class Mesh; class Query; class Renderbuffer; diff --git a/src/Mesh.h b/src/Mesh.h index b3956b716..02b60c9ea 100644 --- a/src/Mesh.h +++ b/src/Mesh.h @@ -28,75 +28,168 @@ namespace Magnum { /** -@brief Non-indexed mesh +@brief %Mesh @section Mesh-configuration Mesh configuration -To properly configure mesh, you have to set primitive either in constructor or -using setPrimitive() and call setVertexCount(). Then create vertex buffers and -fill them with vertex data. You can also use MeshTools::interleave() to -conveniently set vertex count and buffer data. At last assign them to mesh and -@ref AbstractShaderProgram::Attribute "shader attributes" using -addVertexBuffer(), addInterleavedVertexBuffer() or addVertexBufferStride(). +You have to specify at least primitive and vertex count using setPrimitive() +and setVertexCount(). Then fill your vertex buffers with data, add them to the +mesh and specify @ref AbstractShaderProgram::Attribute "shader attribute" layout +inside the buffers using addVertexBuffer(), addInterleavedVertexBuffer() or +addVertexBufferStride(). You can also use MeshTools::interleave() in +combination with addInterleavedVertexBuffer() to conveniently fill interleaved +vertex buffer(s). The function itself calls setVertexCount(), so you don't +have to do it again. -Note that the buffer is not managed (e.g. deleted on destruction) by the mesh, -so you have to manage it on your own. On the other hand it allows you to use -one buffer for more meshes (each mesh for example configured for different -shader) or store more than only vertex data in one buffer. +If you have indexed mesh, you need to call setIndexCount() instead of +setVertexCount() and additionaly specify also index type using setIndexType(). +Then fill your index buffer with data and add it to the mesh using +setIndexBuffer(). You can also use MeshTools::compressIndices() to +conveniently compress the indices, fill the index buffer and configure the +mesh instead of calling setIndexCount(), setIndexType() and setIndexBuffer() +manually. + +Note that neither vertex buffers nor index buffer is managed (e.g. deleted on +destruction) by the mesh, so you have to manage them on your own. On the other +hand it allows you to use one buffer for more meshes (each mesh for example +configured for different shader) or store data for more meshes in one buffer. + +If the mesh has non-zero index count, it is treated as indexed mesh, otherwise +it is treated as non-indexed mesh. If both index and vertex count is zero, the +mesh is empty and no draw commands are issued when calling draw(). + +@subsection Mesh-configuration-examples Example mesh configuration + +@subsubsection Mesh-configuration-examples-nonindexed Basic non-indexed mesh -Example usage -- filling buffer with position data, configuring the mesh and -assigning the buffer to mesh to use with custom shader: @code +// Custom shader, needing only position data class MyShader: public AbstractShaderProgram { public: typedef Attribute<0, Point3D> Position; // ... }; -Buffer* buffer; Mesh* mesh; +Buffer* vertexBuffer; +// Fill vertex buffer with position data static constexpr Point3D positions[30] = { // ... }; -buffer->setData(positions, Buffer::Usage::StaticDraw); +vertexBuffer->setData(positions, Buffer::Usage::StaticDraw); +// Set primitive and vertex count, add the buffer and specify its layout mesh->setPrimitive(Mesh::Primitive::Triangles) ->setVertexCount(30) - ->addVertexBuffer(buffer, MyShader::Position()); + ->addVertexBuffer(vertexBuffer, 0, MyShader::Position()); @endcode -Example usage -- creating a plane mesh and assigning buffer with interleaved -vertex attributes for use with Shaders::PhongShader: +@subsubsection Mesh-configuration-examples-nonindexed-phong Interleaved vertex data + @code -Buffer* buffer; +// Non-indexed primitive with positions and normals +Primitives::Plane plane; Mesh* mesh; +Buffer* vertexBuffer; -Primitives::Plane plane; -MeshTools::interleave(mesh, buffer, Buffer::Usage::StaticDraw, *plane.positions(0), *plane.normals(0)); +// Fill vertex buffer with interleaved position and normal data +MeshTools::interleave(mesh, buffer, Buffer::Usage::StaticDraw, + *plane.positions(0), *plane.normals(0)); + +// Set primitive and specify layout of interleaved vertex buffer, vertex count +// has been already set by MeshTools::interleave() +mesh->setPrimitive(plane.primitive()) + ->addInterleavedVertexBuffer(buffer, 0, + Shaders::PhongShader::Position(), + Shaders::PhongShader::Normal()); +@endcode + +@subsubsection Mesh-configuration-examples-indexed-phong Indexed mesh + +@code +// Custom shader +class MyShader: public AbstractShaderProgram { + public: + typedef Attribute<0, Point3D> Position; + + // ... +}; +Buffer *vertexBuffer, *indexBuffer; +Mesh* mesh; + +// Fill vertex buffer with position data +static constexpr Point3D positions[30] = { + // ... +}; +vertexBuffer->setData(positions, Buffer::Usage::StaticDraw); + +// Fill index buffer with index data +static constexpr GLubyte indices[75] = { + // ... +}; +indexBuffer->setData(indices, Buffer::Usage::StaticDraw); + +// Set primitive, index count and type, add the buffers +mesh->setPrimitive(Mesh::Primitive::Triangles) + ->setIndexCount(75) + ->setIndexType(Mesh::IndexType::UnsignedByte) + ->addVertexBuffer(vertexBuffer, 0, MyShader::Position()) + ->setIndexBuffer(indexBuffer); +@endcode + +@code +// Indexed primitive +Primitives::Cube cube; +Buffer *vertexBuffer, *indexBuffer; +Mesh* mesh; + +// Fill vertex buffer with interleaved position and normal data +MeshTools::interleave(mesh, vertexBuffer, Buffer::Usage::StaticDraw, + *cube.positions(0), *cube.normals(0)); + +// Fill index buffer with compressed index data +MeshTools::compressIndices(mesh, indexBuffer, Buffer::Usage::StaticDraw, + *cube.indices()); + +// Set primitive and specify layout of interleaved vertex buffer. Index count, +// type and index buffer has been already set by MeshTools::compressIndices(). mesh->setPrimitive(plane.primitive()) - ->addInterleavedVertexBuffer(buffer, 0, Shaders::PhongShader::Position(), Shaders::PhongShader::Normal()); + ->addInterleavedVertexBuffer(vertexBuffer, 0, + Shaders::PhongShader::Position(), + Shaders::PhongShader::Normal()); @endcode -Example usage -- passing color attribute as normalized unsigned byte with BGRA -component ordering (e.g. directly from @ref Trade::TgaImporter "TGA file"): +@subsubsection Mesh-configuration-examples-data-options Specific formats of vertex data + @code +// Custom shader with colors specified as four floating-point values class MyShader: public AbstractShaderProgram { public: typedef Attribute<1, Color4<>> Color; // ... }; -Buffer* buffer; Mesh* mesh; +Buffer* colorBuffer; + +// Fill vertex buffer with colors specified as four-byte BGRA (e.g. directly +// from TGA file) +GLubyte colors[4*30] = { + // ... +}; +colorBuffer.setData(colors, Buffer::Usage::StaticDraw); -mesh->addVertexBuffer(buffer, MyShader::Color(Type::UsignedByte, MyShader::Color::Normalized|MyShader::Color::BGRA)); +// Specify layout of color buffer -- each component is unsigned byte, we want +// to normalize them from [0, 255] to [0.0f, 1.0f] and reorder from BGRA +mesh->addVertexBuffer(colorBuffer, 0, + MyShader::Color(MyShader::Color::DataType::UsignedByte, MyShader::Color::DataOption::Normalized|MyShader::Color::DataOption::BGRA)); @endcode @section Mesh-drawing Rendering meshes Basic workflow is: bind specific framebuffer for drawing (if needed), set up -respective shader and bind required textures (see +respective shader, bind required textures (see @ref AbstractShaderProgram-rendering-workflow "AbstractShaderProgram documentation" for more infromation) and call Mesh::draw(). @@ -114,7 +207,6 @@ calls to @fn_gl{BindBuffer} and @fn_gl{BindVertexArray}. See documentation of addVertexBuffer(), addInterleavedVertexBuffer(), addVertexBufferStride() for more information. -@see IndexedMesh @todo Support for indirect draw buffer (OpenGL 4.0, @extension{ARB,draw_indirect}) @todo Redo in a way that allows glMultiDrawArrays, glDrawArraysInstanced etc. */ @@ -849,7 +941,7 @@ template<> struct MAGNUM_EXPORT ConfigurationValue { /** * @brief Read enum value as string * - * If the value is invalid, returns @ref Magnum::IndexedMesh::IndexType "IndexedMesh::IndexType::UnsignedInt". + * If the value is invalid, returns @ref Magnum::Mesh::IndexType "Mesh::IndexType::UnsignedInt". */ static Magnum::Mesh::IndexType fromString(const std::string& stringValue, ConfigurationValueFlags); }; diff --git a/src/MeshTools/CompressIndices.cpp b/src/MeshTools/CompressIndices.cpp index 2c8cda63c..7d3890517 100644 --- a/src/MeshTools/CompressIndices.cpp +++ b/src/MeshTools/CompressIndices.cpp @@ -25,12 +25,12 @@ namespace Magnum { namespace MeshTools { #ifndef DOXYGEN_GENERATING_OUTPUT namespace { -template constexpr IndexedMesh::IndexType indexType(); -template<> inline constexpr IndexedMesh::IndexType indexType() { return IndexedMesh::IndexType::UnsignedByte; } -template<> inline constexpr IndexedMesh::IndexType indexType() { return IndexedMesh::IndexType::UnsignedShort; } -template<> inline constexpr IndexedMesh::IndexType indexType() { return IndexedMesh::IndexType::UnsignedInt; } +template constexpr Mesh::IndexType indexType(); +template<> inline constexpr Mesh::IndexType indexType() { return Mesh::IndexType::UnsignedByte; } +template<> inline constexpr Mesh::IndexType indexType() { return Mesh::IndexType::UnsignedShort; } +template<> inline constexpr Mesh::IndexType indexType() { return Mesh::IndexType::UnsignedInt; } -template inline std::tuple compress(const std::vector& indices) { +template inline std::tuple compress(const std::vector& indices) { char* buffer = new char[indices.size()*sizeof(T)]; for(std::size_t i = 0; i != indices.size(); ++i) { T index = static_cast(indices[i]); @@ -43,7 +43,7 @@ template inline std::tuple } #endif -std::tuple compressIndices(const std::vector& indices) { +std::tuple compressIndices(const std::vector& indices) { std::size_t size = *std::max_element(indices.begin(), indices.end()); switch(Math::log(256, size)) { @@ -60,16 +60,16 @@ std::tuple compressIndices(const std } } -void compressIndices(IndexedMesh* mesh, Buffer* buffer, Buffer::Usage usage, const std::vector& indices) { +void compressIndices(Mesh* mesh, Buffer* buffer, Buffer::Usage usage, const std::vector& indices) { std::size_t indexCount; - IndexedMesh::IndexType indexType; + Mesh::IndexType indexType; char* data; std::tie(indexCount, indexType, data) = compressIndices(indices); mesh->setIndexBuffer(buffer) ->setIndexType(indexType) ->setIndexCount(indices.size()); - buffer->setData(indexCount*IndexedMesh::indexSize(indexType), data, usage); + buffer->setData(indexCount*Mesh::indexSize(indexType), data, usage); delete[] data; } diff --git a/src/MeshTools/CompressIndices.h b/src/MeshTools/CompressIndices.h index 6141465fb..c68b991e6 100644 --- a/src/MeshTools/CompressIndices.h +++ b/src/MeshTools/CompressIndices.h @@ -22,7 +22,7 @@ #include #include "Buffer.h" -#include "IndexedMesh.h" +#include "Mesh.h" #include "magnumMeshToolsVisibility.h" @@ -41,18 +41,18 @@ sufficient. Size of the buffer can be computed from index count and type, as shown below. Example usage: @code std::size_t indexCount; -IndexedMesh::IndexType indexType; +Mesh::IndexType indexType; char* data; std::tie(indexCount, indexType, data) = MeshTools::compressIndices(indices); -std::size_t dataSize = indexCount*IndexedMesh::indexSize(indexType); +std::size_t dataSize = indexCount*Mesh::indexSize(indexType); // ... delete[] data; @endcode -See also compressIndices(IndexedMesh*, Buffer*, Buffer::Usage, const std::vector&), +See also compressIndices(Mesh*, Buffer*, Buffer::Usage, const std::vector&), which writes the compressed data directly into index buffer of given mesh. */ -std::tuple MAGNUM_MESHTOOLS_EXPORT compressIndices(const std::vector& indices); +std::tuple MAGNUM_MESHTOOLS_EXPORT compressIndices(const std::vector& indices); /** @brief Compress vertex indices and write them to index buffer @@ -63,13 +63,12 @@ std::tuple MAGNUM_MESHTOOLS_EXPORT c The same as compressIndices(const std::vector&), but this function writes the output to given index buffer and updates index count and -type in the mesh accordingly, so you don't have to call -IndexedMesh::setIndexBuffer(), IndexedMesh::setIndexCount() and -IndexedMesh::setIndexType() on your own. +type in the mesh accordingly, so you don't have to call Mesh::setIndexBuffer(), +Mesh::setIndexCount() and Mesh::setIndexType() on your own. @see MeshTools::interleave() */ -void MAGNUM_MESHTOOLS_EXPORT compressIndices(IndexedMesh* mesh, Buffer* buffer, Buffer::Usage usage, const std::vector& indices); +void MAGNUM_MESHTOOLS_EXPORT compressIndices(Mesh* mesh, Buffer* buffer, Buffer::Usage usage, const std::vector& indices); }} diff --git a/src/MeshTools/Test/CompressIndicesTest.cpp b/src/MeshTools/Test/CompressIndicesTest.cpp index 56731f2c1..da0459b2c 100644 --- a/src/MeshTools/Test/CompressIndicesTest.cpp +++ b/src/MeshTools/Test/CompressIndicesTest.cpp @@ -39,14 +39,14 @@ CompressIndicesTest::CompressIndicesTest() { void CompressIndicesTest::compressChar() { std::size_t indexCount; - IndexedMesh::IndexType indexType; + Mesh::IndexType indexType; char* data; std::tie(indexCount, indexType, data) = MeshTools::compressIndices( std::vector{1, 2, 3, 0, 4}); CORRADE_COMPARE(indexCount, 5); - CORRADE_VERIFY(indexType == IndexedMesh::IndexType::UnsignedByte); - CORRADE_COMPARE(std::vector(data, data+indexCount*IndexedMesh::indexSize(indexType)), + CORRADE_VERIFY(indexType == Mesh::IndexType::UnsignedByte); + CORRADE_COMPARE(std::vector(data, data+indexCount*Mesh::indexSize(indexType)), (std::vector{ 0x01, 0x02, 0x03, 0x00, 0x04 })); delete[] data; @@ -54,21 +54,21 @@ void CompressIndicesTest::compressChar() { void CompressIndicesTest::compressShort() { std::size_t indexCount; - IndexedMesh::IndexType indexType; + Mesh::IndexType indexType; char* data; std::tie(indexCount, indexType, data) = MeshTools::compressIndices( std::vector{1, 256, 0, 5}); CORRADE_COMPARE(indexCount, 4); - CORRADE_VERIFY(indexType == IndexedMesh::IndexType::UnsignedShort); + CORRADE_VERIFY(indexType == Mesh::IndexType::UnsignedShort); if(!Endianness::isBigEndian()) { - CORRADE_COMPARE(std::vector(data, data+indexCount*IndexedMesh::indexSize(indexType)), + CORRADE_COMPARE(std::vector(data, data+indexCount*Mesh::indexSize(indexType)), (std::vector{ 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x05, 0x00 })); } else { - CORRADE_COMPARE(std::vector(data, data+indexCount*IndexedMesh::indexSize(indexType)), + CORRADE_COMPARE(std::vector(data, data+indexCount*Mesh::indexSize(indexType)), (std::vector{ 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, @@ -80,21 +80,21 @@ void CompressIndicesTest::compressShort() { void CompressIndicesTest::compressInt() { std::size_t indexCount; - IndexedMesh::IndexType indexType; + Mesh::IndexType indexType; char* data; std::tie(indexCount, indexType, data) = MeshTools::compressIndices( std::vector{65536, 3, 2}); CORRADE_COMPARE(indexCount, 3); - CORRADE_VERIFY(indexType == IndexedMesh::IndexType::UnsignedInt); + CORRADE_VERIFY(indexType == Mesh::IndexType::UnsignedInt); if(!Endianness::isBigEndian()) { - CORRADE_COMPARE(std::vector(data, data+indexCount*IndexedMesh::indexSize(indexType)), + CORRADE_COMPARE(std::vector(data, data+indexCount*Mesh::indexSize(indexType)), (std::vector{ 0x00, 0x00, 0x01, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00 })); } else { - CORRADE_COMPARE(std::vector(data, data+indexCount*IndexedMesh::indexSize(indexType)), + CORRADE_COMPARE(std::vector(data, data+indexCount*Mesh::indexSize(indexType)), (std::vector{ 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02 })); diff --git a/src/Text/TextRenderer.cpp b/src/Text/TextRenderer.cpp index 053cb5845..aacbba97d 100644 --- a/src/Text/TextRenderer.cpp +++ b/src/Text/TextRenderer.cpp @@ -20,7 +20,6 @@ #include "Math/Point2D.h" #include "Math/Point3D.h" -#include "IndexedMesh.h" #include "Swizzle.h" #include "MeshTools/CompressIndices.h" #include "MeshTools/Interleave.h" @@ -139,8 +138,8 @@ template std::tuple IndexedMesh TextRenderer::render(Font& font, GLfloat size, const std::string& text, Buffer* vertexBuffer, Buffer* indexBuffer, Buffer::Usage usage) { - IndexedMesh mesh; +template Mesh TextRenderer::render(Font& font, GLfloat size, const std::string& text, Buffer* vertexBuffer, Buffer* indexBuffer, Buffer::Usage usage) { + Mesh mesh; std::vector::PointType> positions; std::vector textureCoordinates; @@ -150,7 +149,9 @@ template IndexedMesh TextRenderer::render(F MeshTools::interleave(&mesh, vertexBuffer, usage, positions, textureCoordinates); MeshTools::compressIndices(&mesh, indexBuffer, usage, indices); mesh.setPrimitive(Mesh::Primitive::Triangles) - ->addInterleavedVertexBuffer(vertexBuffer, 0, typename Shaders::AbstractTextShader::Position(), typename Shaders::AbstractTextShader::TextureCoordinates()); + ->addInterleavedVertexBuffer(vertexBuffer, 0, + typename Shaders::AbstractTextShader::Position(), + typename Shaders::AbstractTextShader::TextureCoordinates()); return mesh; } diff --git a/src/Text/TextRenderer.h b/src/Text/TextRenderer.h index 81016d362..26322df2c 100644 --- a/src/Text/TextRenderer.h +++ b/src/Text/TextRenderer.h @@ -62,7 +62,7 @@ template class MAGNUM_TEXT_EXPORT TextRenderer { * @return Indexed mesh prepared for use with Shaders::AbstractTextShader * subclasses */ - static IndexedMesh render(Font& font, GLfloat size, const std::string& text, Buffer* vertexBuffer, Buffer* indexBuffer, Buffer::Usage usage); + static Mesh render(Font& font, GLfloat size, const std::string& text, Buffer* vertexBuffer, Buffer* indexBuffer, Buffer::Usage usage); private: #ifndef DOXYGEN_GENERATING_OUTPUT