From faf94c74e21f8dc7f145c084015fbea5e8d0e25e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 22 Feb 2013 00:50:02 +0100 Subject: [PATCH] Adapted to recent meshdata/shader changes. --- src/AbstractShaderProgram.h | 4 +--- src/DebugTools/ObjectRenderer.cpp | 8 ++++---- src/Mesh.h | 8 ++++---- src/Text/TextRenderer.cpp | 24 ++++++++++++------------ src/Text/TextRenderer.h | 2 +- 5 files changed, 22 insertions(+), 24 deletions(-) diff --git a/src/AbstractShaderProgram.h b/src/AbstractShaderProgram.h index 9a28886a0..53b69ce6c 100644 --- a/src/AbstractShaderProgram.h +++ b/src/AbstractShaderProgram.h @@ -46,7 +46,7 @@ functions and properties: - %Attribute definitions with location and type for configuring meshes, for example: @code -typedef Attribute<0, Point3D> Position; +typedef Attribute<0, Vector3> Position; typedef Attribute<1, Vector3> Normal; typedef Attribute<2, Vector2> TextureCoordinates; @endcode @@ -1371,8 +1371,6 @@ template struct Attribute>: Dou template struct Attribute>: Attribute> {}; template struct Attribute>: Attribute> {}; template struct Attribute>: Attribute> {}; -template struct Attribute>: Attribute> {}; -template struct Attribute>: Attribute> {}; template struct Attribute>: Attribute> {}; template struct Attribute>: Attribute> {}; diff --git a/src/DebugTools/ObjectRenderer.cpp b/src/DebugTools/ObjectRenderer.cpp index 137df6a73..3deac8cdc 100644 --- a/src/DebugTools/ObjectRenderer.cpp +++ b/src/DebugTools/ObjectRenderer.cpp @@ -33,12 +33,12 @@ template<> struct Renderer<2> { inline static ResourceKey indexBuffer() { return {"object2d-indices"}; } inline static ResourceKey mesh() { return {"object2d"}; } - static const std::array positions; + static const std::array positions; static const std::array, 8> colors; static const std::array indices; }; -const std::array Renderer<2>::positions{{ +const std::array Renderer<2>::positions{{ { 0.0f, 0.0f}, { 1.0f, 0.0f}, /* X axis */ { 0.9f, 0.1f}, @@ -78,12 +78,12 @@ template<> struct Renderer<3> { inline static ResourceKey indexBuffer() { return {"object3d-indices"}; } inline static ResourceKey mesh() { return {"object3d"}; } - static const std::array positions; + static const std::array positions; static const std::array, 12> colors; static const std::array indices; }; -const std::array Renderer<3>::positions{{ +const std::array Renderer<3>::positions{{ { 0.0f, 0.0f, 0.0f}, { 1.0f, 0.0f, 0.0f}, /* X axis */ { 0.9f, 0.1f, 0.0f}, diff --git a/src/Mesh.h b/src/Mesh.h index 60edb1c8b..3f2c554f2 100644 --- a/src/Mesh.h +++ b/src/Mesh.h @@ -64,7 +64,7 @@ mesh is empty and no draw commands are issued when calling draw(). // Custom shader, needing only position data class MyShader: public AbstractShaderProgram { public: - typedef Attribute<0, Point3D> Position; + typedef Attribute<0, Vector3> Position; // ... }; @@ -72,7 +72,7 @@ Mesh* mesh; Buffer* vertexBuffer; // Fill vertex buffer with position data -static constexpr Point3D positions[30] = { +static constexpr Vector3 positions[30] = { // ... }; vertexBuffer->setData(positions, Buffer::Usage::StaticDraw); @@ -109,7 +109,7 @@ mesh->setPrimitive(plane.primitive()) // Custom shader class MyShader: public AbstractShaderProgram { public: - typedef Attribute<0, Point3D> Position; + typedef Attribute<0, Vector3> Position; // ... }; @@ -117,7 +117,7 @@ Buffer *vertexBuffer, *indexBuffer; Mesh* mesh; // Fill vertex buffer with position data -static constexpr Point3D positions[300] = { +static constexpr Vector3 positions[300] = { // ... }; vertexBuffer->setData(positions, Buffer::Usage::StaticDraw); diff --git a/src/Text/TextRenderer.cpp b/src/Text/TextRenderer.cpp index 4e54b86d7..4339d78f5 100644 --- a/src/Text/TextRenderer.cpp +++ b/src/Text/TextRenderer.cpp @@ -23,8 +23,6 @@ #include #endif -#include "Math/Point2D.h" -#include "Math/Point3D.h" #include "Context.h" #include "Extensions.h" #include "Mesh.h" @@ -151,30 +149,30 @@ template void createIndices(void* output, const std::uint32_t glyphCoun } } -template typename DimensionTraits::PointType point(const Vector2& vec); +template typename DimensionTraits::VectorType point(const Vector2& vec); -template<> inline Point2D point<2>(const Vector2& vec) { - return swizzle<'x', 'y', '1'>(vec); +template<> inline Vector2 point<2>(const Vector2& vec) { + return vec; } -template<> inline Point3D point<3>(const Vector2& vec) { - return swizzle<'x', 'y', '0', '1'>(vec); +template<> inline Vector3 point<3>(const Vector2& vec) { + return {vec, 1.0f}; } template struct Vertex { - typename DimensionTraits::PointType position; + typename DimensionTraits::VectorType position; Vector2 texcoords; }; } -template std::tuple::PointType>, std::vector, std::vector, Rectangle> TextRenderer::render(Font& font, GLfloat size, const std::string& text) { +template std::tuple::VectorType>, std::vector, std::vector, Rectangle> TextRenderer::render(Font& font, GLfloat size, const std::string& text) { TextLayouter layouter(font, size, text); const std::uint32_t vertexCount = layouter.glyphCount()*4; /* Output data */ - std::vector::PointType> positions; + std::vector::VectorType> positions; std::vector texcoords; positions.reserve(vertexCount); texcoords.reserve(vertexCount); @@ -210,7 +208,8 @@ template std::tuple(positions[1]), swizzle<'x', 'y'>(positions[positions.size()-2])}; return std::make_tuple(std::move(positions), std::move(texcoords), std::move(indices), rectangle); } @@ -270,7 +269,8 @@ template std::tuple TextRenderer(vertices[1].position), swizzle<'x', 'y'>(vertices[vertices.size()-2].position)}; /* Configure mesh */ Mesh mesh; diff --git a/src/Text/TextRenderer.h b/src/Text/TextRenderer.h index 89328520c..4c2a1c7f6 100644 --- a/src/Text/TextRenderer.h +++ b/src/Text/TextRenderer.h @@ -109,7 +109,7 @@ template class MAGNUM_TEXT_EXPORT TextRenderer { * Returns tuple with vertex positions, texture coordinates, indices * and rectangle spanning the rendered text. */ - static std::tuple::PointType>, std::vector, std::vector, Rectangle> render(Font& font, GLfloat size, const std::string& text); + static std::tuple::VectorType>, std::vector, std::vector, Rectangle> render(Font& font, GLfloat size, const std::string& text); /** * @brief Render text