From 51bc8bd67566272b2a741c5b1e6de2ff184f4ddd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 14 Nov 2012 02:15:26 +0100 Subject: [PATCH 1/7] Fixed compilation on mingw. --- src/Physics/DebugDrawResourceManager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Physics/DebugDrawResourceManager.cpp b/src/Physics/DebugDrawResourceManager.cpp index c2f35c2f3..477899368 100644 --- a/src/Physics/DebugDrawResourceManager.cpp +++ b/src/Physics/DebugDrawResourceManager.cpp @@ -39,8 +39,8 @@ template SceneGraph::Drawable* DebugDrawRes return renderer; } -template SceneGraph::Drawable<2>* DebugDrawResourceManager::createDebugRenderer(ObjectShape<2>* shape, ResourceKey options); -template SceneGraph::Drawable<3>* DebugDrawResourceManager::createDebugRenderer(ObjectShape<3>* shape, ResourceKey options); +template SceneGraph::Drawable<2> PHYSICS_EXPORT * DebugDrawResourceManager::createDebugRenderer(ObjectShape<2>* shape, ResourceKey options); +template SceneGraph::Drawable<3> PHYSICS_EXPORT * DebugDrawResourceManager::createDebugRenderer(ObjectShape<3>* shape, ResourceKey options); void DebugDrawResourceManager::createDebugMesh(Implementation::DebugRenderer<2>* renderer, AbstractShape2D* shape) { switch(shape->type()) { From d1e6ff1490c5e7021670b906f678caf1865bd1fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 14 Nov 2012 02:16:30 +0100 Subject: [PATCH 2/7] ResourceManager: assertions on global instance pointer. Better be sure than crash somewhere deep in STL code. --- src/ResourceManager.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/ResourceManager.h b/src/ResourceManager.h index a8ad00d9b..b00732199 100644 --- a/src/ResourceManager.h +++ b/src/ResourceManager.h @@ -452,7 +452,10 @@ cube->draw(); template class ResourceManager: protected Implementation::ResourceManagerData... { public: /** @brief Global instance */ - inline static ResourceManager* instance() { return _instance; } + inline static ResourceManager* instance() { + CORRADE_ASSERT(_instance, "ResourceManager::instance(): no instance exists", nullptr); + return _instance; + } /** * @brief Constructor @@ -463,7 +466,7 @@ template class ResourceManager: protected Implementation::Resour * @see instance() */ inline ResourceManager() { - CORRADE_ASSERT(!_instance, "ResourceManager: another instance is already created!", ); + CORRADE_ASSERT(!_instance, "ResourceManager::ResourceManager(): another instance is already created", ); _instance = this; } @@ -473,7 +476,10 @@ template class ResourceManager: protected Implementation::Resour * Sets global instance pointer to `nullptr`. * @see instance() */ - inline ~ResourceManager() { _instance = nullptr; } + inline ~ResourceManager() { + CORRADE_INTERNAL_ASSERT(_instance == this); + _instance = nullptr; + } /** @brief Count of resources of given type */ template inline std::size_t count() { From 124b5b73b604ca4a973fc942e6b43417ee0b4e0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 14 Nov 2012 14:40:10 +0100 Subject: [PATCH 3/7] ResourceManager: wrap global instance pointer in a function. This way only single function can be marked with "extern template" to avoid nasty issues with multiple definition errors. --- src/ResourceManager.h | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/ResourceManager.h b/src/ResourceManager.h index b00732199..3935815ea 100644 --- a/src/ResourceManager.h +++ b/src/ResourceManager.h @@ -453,8 +453,8 @@ template class ResourceManager: protected Implementation::Resour public: /** @brief Global instance */ inline static ResourceManager* instance() { - CORRADE_ASSERT(_instance, "ResourceManager::instance(): no instance exists", nullptr); - return _instance; + CORRADE_ASSERT(internalInstance(), "ResourceManager::instance(): no instance exists", nullptr); + return internalInstance(); } /** @@ -466,8 +466,8 @@ template class ResourceManager: protected Implementation::Resour * @see instance() */ inline ResourceManager() { - CORRADE_ASSERT(!_instance, "ResourceManager::ResourceManager(): another instance is already created", ); - _instance = this; + CORRADE_ASSERT(!internalInstance(), "ResourceManager::ResourceManager(): another instance is already created", ); + internalInstance() = this; } /** @@ -477,8 +477,8 @@ template class ResourceManager: protected Implementation::Resour * @see instance() */ inline ~ResourceManager() { - CORRADE_INTERNAL_ASSERT(_instance == this); - _instance = nullptr; + CORRADE_INTERNAL_ASSERT(internalInstance() == this); + internalInstance() = nullptr; } /** @brief Count of resources of given type */ @@ -564,16 +564,19 @@ template class ResourceManager: protected Implementation::Resour } inline void freeInternal() const {} - static ResourceManager* _instance; + static ResourceManager*& internalInstance(); }; +template ResourceManager*& ResourceManager::internalInstance() { + static ResourceManager* _instance(nullptr); + return _instance; +} + /** @debugoperator{Magnum::ResourceKey} */ template inline Corrade::Utility::Debug operator<<(Corrade::Utility::Debug debug, const ResourceKey& value) { return debug << static_cast&>(value); } -template ResourceManager* ResourceManager::_instance(nullptr); - } #endif From 4cc78e4cd33ccba711e74c578cc543b7b58eb101 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 14 Nov 2012 14:43:04 +0100 Subject: [PATCH 4/7] Physics: debug renderer for AABB. Using common base for Box and AABB, as the primitives are the same, but only draw function differs. --- src/Physics/CMakeLists.txt | 2 + src/Physics/DebugDrawResourceManager.cpp | 4 ++ .../Implementation/AbstractBoxRenderer.cpp | 70 +++++++++++++++++++ .../Implementation/AbstractBoxRenderer.h | 40 +++++++++++ .../Implementation/AbstractShapeRenderer.cpp | 32 +++++++++ .../Implementation/AbstractShapeRenderer.h | 50 +++++++++++++ .../Implementation/AxisAlignedBoxRenderer.cpp | 38 ++++++++++ .../Implementation/AxisAlignedBoxRenderer.h | 38 ++++++++++ src/Physics/Implementation/BoxRenderer.cpp | 44 +----------- src/Physics/Implementation/BoxRenderer.h | 19 ++--- 10 files changed, 281 insertions(+), 56 deletions(-) create mode 100644 src/Physics/Implementation/AbstractBoxRenderer.cpp create mode 100644 src/Physics/Implementation/AbstractBoxRenderer.h create mode 100644 src/Physics/Implementation/AbstractShapeRenderer.cpp create mode 100644 src/Physics/Implementation/AbstractShapeRenderer.h create mode 100644 src/Physics/Implementation/AxisAlignedBoxRenderer.cpp create mode 100644 src/Physics/Implementation/AxisAlignedBoxRenderer.h diff --git a/src/Physics/CMakeLists.txt b/src/Physics/CMakeLists.txt index e3eec9146..f577e1594 100644 --- a/src/Physics/CMakeLists.txt +++ b/src/Physics/CMakeLists.txt @@ -12,7 +12,9 @@ set(MagnumPhysics_SRCS ShapeGroup.cpp Sphere.cpp + Implementation/AbstractBoxRenderer.cpp Implementation/AbstractDebugRenderer.cpp + Implementation/AxisAlignedBoxRenderer.cpp Implementation/BoxRenderer.cpp) set(MagnumPhysics_HEADERS diff --git a/src/Physics/DebugDrawResourceManager.cpp b/src/Physics/DebugDrawResourceManager.cpp index 477899368..ed9f64d75 100644 --- a/src/Physics/DebugDrawResourceManager.cpp +++ b/src/Physics/DebugDrawResourceManager.cpp @@ -21,9 +21,11 @@ #include "ResourceManager.h" #include "Shaders/FlatShader.h" #include "AbstractShape.h" +#include "AxisAlignedBox.h" #include "Box.h" #include "ObjectShape.h" #include "ShapeGroup.h" +#include "Implementation/AxisAlignedBoxRenderer.h" #include "Implementation/BoxRenderer.h" #include "Implementation/DebugRenderer.h" @@ -44,6 +46,8 @@ template SceneGraph::Drawable<3> PHYSICS_EXPORT * DebugDrawResourceManager::crea void DebugDrawResourceManager::createDebugMesh(Implementation::DebugRenderer<2>* renderer, AbstractShape2D* shape) { switch(shape->type()) { + case AbstractShape2D::Type::AxisAlignedBox: + renderer->addRenderer(new Implementation::AxisAlignedBoxRenderer<2>(*static_cast(shape))); case AbstractShape2D::Type::Box: renderer->addRenderer(new Implementation::BoxRenderer<2>(*static_cast(shape))); break; diff --git a/src/Physics/Implementation/AbstractBoxRenderer.cpp b/src/Physics/Implementation/AbstractBoxRenderer.cpp new file mode 100644 index 000000000..95e7cdaeb --- /dev/null +++ b/src/Physics/Implementation/AbstractBoxRenderer.cpp @@ -0,0 +1,70 @@ +/* + 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 "AbstractBoxRenderer.h" + +#include "Buffer.h" +#include "Physics/DebugDrawResourceManager.h" +#include "Primitives/Cube.h" +#include "Primitives/Square.h" +#include "Shaders/FlatShader.h" + +namespace Magnum { namespace Physics { namespace Implementation { + +namespace { + template struct BoxMesh {}; + + template<> struct BoxMesh<2> { + static ResourceKey shader() { return {"shader2d"}; } + static ResourceKey key() { return {"box2d"}; } + + static Mesh* mesh(Buffer* buffer) { + Primitives::Square square; + Mesh* mesh = new Mesh; + buffer->setData(*square.positions(0), Buffer::Usage::StaticDraw); + return mesh->setPrimitive(square.primitive()) + ->setVertexCount(square.positions(0)->size()) + ->addVertexBuffer(buffer, Shaders::FlatShader<2>::Position()); + } + }; + + template<> struct BoxMesh<3> { + static ResourceKey shader() { return {"shader3d"}; } + static ResourceKey key() { return {"box3d"}; } + + static Mesh* mesh(Buffer* buffer) { + Primitives::Cube cube; + Mesh* mesh = new Mesh; + buffer->setData(*cube.positions(0), Buffer::Usage::StaticDraw); + return mesh->setPrimitive(cube.primitive()) + ->setVertexCount(cube.positions(0)->size()) + ->addVertexBuffer(buffer, Shaders::FlatShader<2>::Position()); + } + }; +} + +template AbstractBoxRenderer::AbstractBoxRenderer(): AbstractDebugRenderer(BoxMesh::shader(), BoxMesh::key()), buffer(DebugDrawResourceManager::instance()->get(BoxMesh::key())) { + if(!this->mesh) { + DebugDrawResourceManager::instance()->set(this->buffer.key(), new Buffer, ResourceDataState::Final, ResourcePolicy::Manual); + DebugDrawResourceManager::instance()->set(this->mesh.key(), BoxMesh::mesh(buffer), ResourceDataState::Final, ResourcePolicy::Manual); + } +} + +template AbstractBoxRenderer::~AbstractBoxRenderer() {} + +template class AbstractBoxRenderer<2>; +template class AbstractBoxRenderer<3>; + +}}} diff --git a/src/Physics/Implementation/AbstractBoxRenderer.h b/src/Physics/Implementation/AbstractBoxRenderer.h new file mode 100644 index 000000000..87c57687e --- /dev/null +++ b/src/Physics/Implementation/AbstractBoxRenderer.h @@ -0,0 +1,40 @@ +#ifndef Magnum_Physics_Implementation_AbstractBoxRenderer_h +#define Magnum_Physics_Implementation_AbstractBoxRenderer_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. +*/ + +#include "AbstractDebugRenderer.h" + +#include "magnumCompatibility.h" + +namespace Magnum { + +class Buffer; + +namespace Physics { namespace Implementation { + +template class AbstractBoxRenderer: public AbstractDebugRenderer { + public: + AbstractBoxRenderer(); + + ~AbstractBoxRenderer(); + + protected: + Resource buffer; +}; + +}}} + +#endif diff --git a/src/Physics/Implementation/AbstractShapeRenderer.cpp b/src/Physics/Implementation/AbstractShapeRenderer.cpp new file mode 100644 index 000000000..ee4d3596e --- /dev/null +++ b/src/Physics/Implementation/AbstractShapeRenderer.cpp @@ -0,0 +1,32 @@ +/* + 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 "AbstractShapeRenderer.h" + +#include "AbstractShaderProgram.h" +#include "Mesh.h" +#include "Physics/DebugDrawResourceManager.h" +#include "Shaders/FlatShader.h" + +namespace Magnum { namespace Physics { namespace Implementation { + +template AbstractShapeRenderer::AbstractShapeRenderer(ResourceKey shader, ResourceKey mesh): shader(DebugDrawResourceManager::instance()->get>(shader)), mesh(DebugDrawResourceManager::instance()->get(mesh)) {} + +template AbstractShapeRenderer::~AbstractShapeRenderer() {} + +template class AbstractShapeRenderer<2>; +template class AbstractShapeRenderer<3>; + +}}} diff --git a/src/Physics/Implementation/AbstractShapeRenderer.h b/src/Physics/Implementation/AbstractShapeRenderer.h new file mode 100644 index 000000000..276d53ba2 --- /dev/null +++ b/src/Physics/Implementation/AbstractShapeRenderer.h @@ -0,0 +1,50 @@ +#ifndef Magnum_Physics_Implementation_AbstractShapeRenderer_h +#define Magnum_Physics_Implementation_AbstractShapeRenderer_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. +*/ + +#include "DimensionTraits.h" +#include "ResourceManager.h" +#include "SceneGraph/SceneGraph.h" + +namespace Magnum { + +class AbstractShaderProgram; +class Mesh; + +namespace Shaders { + template class FlatShader; +} + +namespace Physics { namespace Implementation { + +struct Options; + +template class AbstractShapeRenderer { + public: + AbstractShapeRenderer(ResourceKey shader, ResourceKey mesh); + + virtual ~AbstractShapeRenderer(); + + virtual void draw(Resource& options, const typename DimensionTraits::MatrixType& transformationMatrix, SceneGraph::AbstractCamera* camera) = 0; + + protected: + Resource> shader; + Resource mesh; +}; + +}}} + +#endif diff --git a/src/Physics/Implementation/AxisAlignedBoxRenderer.cpp b/src/Physics/Implementation/AxisAlignedBoxRenderer.cpp new file mode 100644 index 000000000..57e701116 --- /dev/null +++ b/src/Physics/Implementation/AxisAlignedBoxRenderer.cpp @@ -0,0 +1,38 @@ +/* + 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 "AxisAlignedBoxRenderer.h" + +#include "Mesh.h" +#include "Physics/DebugDrawResourceManager.h" +#include "SceneGraph/AbstractCamera.h" +#include "Shaders/FlatShader.h" + +namespace Magnum { namespace Physics { namespace Implementation { + +template void AxisAlignedBoxRenderer::draw(Resource& options, const typename DimensionTraits::MatrixType&, typename SceneGraph::AbstractCamera* camera) { + typename DimensionTraits::MatrixType transformation = + DimensionTraits::MatrixType::translation(axisAlignedBox.transformedPosition())* + DimensionTraits::MatrixType::scaling(axisAlignedBox.transformedSize()); + this->shader->setTransformationProjection(camera->projectionMatrix()*camera->cameraMatrix()*transformation) + ->setColor(options->color) + ->use(); + this->mesh->draw(); +} + +template class AxisAlignedBoxRenderer<2>; +template class AxisAlignedBoxRenderer<3>; + +}}} diff --git a/src/Physics/Implementation/AxisAlignedBoxRenderer.h b/src/Physics/Implementation/AxisAlignedBoxRenderer.h new file mode 100644 index 000000000..5ee7062ec --- /dev/null +++ b/src/Physics/Implementation/AxisAlignedBoxRenderer.h @@ -0,0 +1,38 @@ +#ifndef Magnum_Physics_Implementation_AxisAlignedBoxRenderer_h +#define Magnum_Physics_Implementation_AxisAlignedBoxRenderer_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. +*/ + +#include "AbstractBoxRenderer.h" + +#include "Physics/AxisAlignedBox.h" + +#include "magnumCompatibility.h" + +namespace Magnum { namespace Physics { namespace Implementation { + +template class AxisAlignedBoxRenderer: public AbstractBoxRenderer { + public: + inline AxisAlignedBoxRenderer(AxisAlignedBox& axisAlignedBox): axisAlignedBox(axisAlignedBox) {} + + void draw(Resource& options, const typename DimensionTraits::MatrixType& transformation, typename SceneGraph::AbstractCamera* camera) override; + + private: + AxisAlignedBox& axisAlignedBox; +}; + +}}} + +#endif diff --git a/src/Physics/Implementation/BoxRenderer.cpp b/src/Physics/Implementation/BoxRenderer.cpp index a6cc9d4ca..1624e7aa3 100644 --- a/src/Physics/Implementation/BoxRenderer.cpp +++ b/src/Physics/Implementation/BoxRenderer.cpp @@ -15,55 +15,13 @@ #include "BoxRenderer.h" -#include "Buffer.h" -#include "Physics/Box.h" +#include "Mesh.h" #include "Physics/DebugDrawResourceManager.h" -#include "Primitives/Cube.h" -#include "Primitives/Square.h" #include "SceneGraph/AbstractCamera.h" #include "Shaders/FlatShader.h" namespace Magnum { namespace Physics { namespace Implementation { -namespace { - template struct BoxMesh {}; - - template<> struct BoxMesh<2> { - static ResourceKey shader() { return {"shader2d"}; } - static ResourceKey key() { return {"box2d"}; } - - static Mesh* mesh(Buffer* buffer) { - Primitives::Square square; - Mesh* mesh = new Mesh; - buffer->setData(*square.positions(0), Buffer::Usage::StaticDraw); - return mesh->setPrimitive(square.primitive()) - ->setVertexCount(square.positions(0)->size()) - ->addVertexBuffer(buffer, Shaders::FlatShader<2>::Position()); - } - }; - - template<> struct BoxMesh<3> { - static ResourceKey shader() { return {"shader3d"}; } - static ResourceKey key() { return {"box3d"}; } - - static Mesh* mesh(Buffer* buffer) { - Primitives::Cube cube; - Mesh* mesh = new Mesh; - buffer->setData(*cube.positions(0), Buffer::Usage::StaticDraw); - return mesh->setPrimitive(cube.primitive()) - ->setVertexCount(cube.positions(0)->size()) - ->addVertexBuffer(buffer, Shaders::FlatShader<2>::Position()); - } - }; -} - -template BoxRenderer::BoxRenderer(Box& box): AbstractDebugRenderer(BoxMesh::shader(), BoxMesh::key()), buffer(DebugDrawResourceManager::instance()->get(BoxMesh::key())), box(box) { - if(!this->mesh) { - DebugDrawResourceManager::instance()->set(this->buffer.key(), new Buffer, ResourceDataState::Final, ResourcePolicy::Manual); - DebugDrawResourceManager::instance()->set(this->mesh.key(), BoxMesh::mesh(buffer), ResourceDataState::Final, ResourcePolicy::Manual); - } -} - template void BoxRenderer::draw(Resource& options, const typename DimensionTraits::MatrixType&, typename SceneGraph::AbstractCamera* camera) { this->shader->setTransformationProjection(camera->projectionMatrix()*camera->cameraMatrix()*box.transformedTransformation()) ->setColor(options->color) diff --git a/src/Physics/Implementation/BoxRenderer.h b/src/Physics/Implementation/BoxRenderer.h index d563c7c63..c1e248478 100644 --- a/src/Physics/Implementation/BoxRenderer.h +++ b/src/Physics/Implementation/BoxRenderer.h @@ -15,28 +15,21 @@ GNU Lesser General Public License version 3 for more details. */ -#include "AbstractDebugRenderer.h" +#include "AbstractBoxRenderer.h" -#include "magnumCompatibility.h" - -namespace Magnum { - -class Buffer; +#include "Physics/Box.h" -namespace Physics { - -template class Box; +#include "magnumCompatibility.h" -namespace Implementation { +namespace Magnum { namespace Physics { namespace Implementation { -template class BoxRenderer: public AbstractDebugRenderer { +template class BoxRenderer: public AbstractBoxRenderer { public: - BoxRenderer(Box& box); + inline BoxRenderer(Box& box): box(box) {} void draw(Resource& options, const typename DimensionTraits::MatrixType& transformation, typename SceneGraph::AbstractCamera* camera) override; private: - Resource buffer; Box& box; }; From b2a5f535d75b37cfbf8839da198ec360c5e78c9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 14 Nov 2012 14:48:11 +0100 Subject: [PATCH 5/7] ResourceManager: allow users to instantiate internalInstance() only once. It is cumbersome, but otherwise the linking (on mingw) fails with multiple definition errors. --- src/ResourceManager.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ResourceManager.h b/src/ResourceManager.h index 3935815ea..f603a8616 100644 --- a/src/ResourceManager.h +++ b/src/ResourceManager.h @@ -567,10 +567,12 @@ template class ResourceManager: protected Implementation::Resour static ResourceManager*& internalInstance(); }; +#ifndef MAGNUM_RESOURCEMANAGER_DONT_DEFINE_INTERNALINSTANCE template ResourceManager*& ResourceManager::internalInstance() { static ResourceManager* _instance(nullptr); return _instance; } +#endif /** @debugoperator{Magnum::ResourceKey} */ template inline Corrade::Utility::Debug operator<<(Corrade::Utility::Debug debug, const ResourceKey& value) { From 1b06c24ae68328c687d0f48ab5ded5dc111b914f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 14 Nov 2012 14:49:52 +0100 Subject: [PATCH 6/7] Physics: properly instantiate and export global debugdraw manager instance. Otherwise it failed at runtime on assertion in instance(). --- src/Physics/DebugDrawResourceManager.cpp | 2 ++ src/Physics/DebugDrawResourceManager.h | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/src/Physics/DebugDrawResourceManager.cpp b/src/Physics/DebugDrawResourceManager.cpp index ed9f64d75..8e958bc57 100644 --- a/src/Physics/DebugDrawResourceManager.cpp +++ b/src/Physics/DebugDrawResourceManager.cpp @@ -13,6 +13,8 @@ GNU Lesser General Public License version 3 for more details. */ +#define MAGNUM_RESOURCEMANAGER_DEFINE_INTERNALINSTANCE + #include "DebugDrawResourceManager.h" #include "AbstractShaderProgram.h" diff --git a/src/Physics/DebugDrawResourceManager.h b/src/Physics/DebugDrawResourceManager.h index 618b594eb..c8253dfbf 100644 --- a/src/Physics/DebugDrawResourceManager.h +++ b/src/Physics/DebugDrawResourceManager.h @@ -21,7 +21,12 @@ #include "Magnum.h" #include "Color.h" + +#ifndef MAGNUM_RESOURCEMANAGER_DEFINE_INTERNALINSTANCE +#define MAGNUM_RESOURCEMANAGER_DONT_DEFINE_INTERNALINSTANCE +#endif #include "ResourceManager.h" + #include "SceneGraph/SceneGraph.h" #include "magnumPhysicsVisibility.h" @@ -41,6 +46,8 @@ namespace Physics { namespace Implementation { }} #endif +extern template ResourceManager PHYSICS_EXPORT *& ResourceManager::internalInstance(); + namespace Physics { template class AbstractShape; From d4286117e5e97b9acd3c5268edb1fdef975cbf8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 15 Nov 2012 12:43:58 +0100 Subject: [PATCH 7/7] Added extension. --- src/Extensions.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Extensions.h b/src/Extensions.h index a99f9d569..472b45a91 100644 --- a/src/Extensions.h +++ b/src/Extensions.h @@ -51,6 +51,7 @@ namespace Extensions { namespace GL { #line 1 namespace AMD { + _extension(GL,AMD,vertex_shader_layer, GL210, None) // #417 _extension(GL,AMD,shader_trinary_minmax, GL210, None) // #428 } namespace APPLE { _extension(GL,APPLE,flush_buffer_range, GL210, GL300) // #321