From ee045d261a3f17ebc677473b0b467d0f2e8e2c8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 5 Dec 2013 17:33:53 +0100 Subject: [PATCH 1/8] Make some type conversions explicit. Fixes a bunch of MSVC warnings. --- src/Color.h | 2 +- src/Math/Functions.h | 8 ++++---- src/Math/Unit.h | 2 +- src/Math/Vector.h | 8 ++++---- src/MeshTools/RemoveDuplicates.h | 2 +- src/Platform/Sdl2Application.cpp | 4 ++-- src/Plugins/TgaImageConverter/TgaImageConverter.cpp | 6 +++--- src/Primitives/Capsule.cpp | 4 ++-- src/Primitives/Circle.cpp | 4 ++-- src/Primitives/Implementation/Spheroid.cpp | 8 ++++---- src/Primitives/Implementation/WireframeSpheroid.cpp | 6 +++--- src/SceneGraph/Object.hpp | 4 ++-- src/Shader.cpp | 2 +- src/Text/AbstractFont.cpp | 2 +- src/Text/AbstractFontConverter.cpp | 2 +- src/Text/Renderer.cpp | 4 ++-- src/Timeline.cpp | 4 ++-- src/Trade/AbstractImporter.cpp | 2 +- src/Trade/Test/AbstractImageConverterTest.cpp | 4 ++-- 19 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/Color.h b/src/Color.h index 00d6ca14f..eb592f799 100644 --- a/src/Color.h +++ b/src/Color.h @@ -45,7 +45,7 @@ template typename std::enable_if::value, Basi std::tie(hue, saturation, value) = hsv; /* Remove repeats */ - hue -= int(T(hue)/T(360))*Math::Deg(360); + hue -= Math::floor(T(hue)/T(360))*Math::Deg(360); if(hue < Math::Deg(0)) hue += Math::Deg(360); int h = int(T(hue)/T(60)) % 6; diff --git a/src/Math/Functions.h b/src/Math/Functions.h index e7bf0228c..8e1e08b75 100644 --- a/src/Math/Functions.h +++ b/src/Math/Functions.h @@ -285,12 +285,12 @@ template Vector ceil(const Vector& template inline T sqrt(const T& a); #else template inline typename std::enable_if::value, T>::type sqrt(T a) { - return std::sqrt(a); + return T(std::sqrt(a)); } template Vector sqrt(const Vector& a) { Vector out; for(std::size_t i = 0; i != size; ++i) - out[i] = std::sqrt(a[i]); + out[i] = T(std::sqrt(a[i])); return out; } #endif @@ -349,7 +349,7 @@ The interpolation for vectors is done as in following, similarly for scalars: @f template inline T lerp(const T& a, const T& b, U t); #else template inline T lerp(T a, T b, U t) { - return (U(1) - t)*a + t*b; + return T((U(1) - t)*a + t*b); } template inline Vector lerp(const Vector& a, const Vector& b, U t) { return (U(1) - t)*a + t*b; @@ -471,7 +471,7 @@ template inline Integral denormalize(const template inline typename std::enable_if::value, Integral>::type denormalize(FloatingPoint value) { static_assert(std::is_floating_point::value && std::is_integral::value, "Math::denormalize(): denormalization must be done from floating-point to integral type"); - return value*std::numeric_limits::max(); + return Integral(value*std::numeric_limits::max()); } template inline typename std::enable_if::value, Integral>::type denormalize(const FloatingPoint& value) { static_assert(std::is_floating_point::value && std::is_integral::value, diff --git a/src/Math/Unit.h b/src/Math/Unit.h index 6f4cecb4b..a0822321c 100644 --- a/src/Math/Unit.h +++ b/src/Math/Unit.h @@ -51,7 +51,7 @@ template class Derived, class T> class Unit { constexpr explicit Unit(T value): value(value) {} /** @brief Construct from another underlying type */ - template constexpr explicit Unit(Unit value): value(value.value) {} + template constexpr explicit Unit(Unit value): value(T(value.value)) {} /** @brief Explicit conversion to underlying type */ constexpr explicit operator T() const { return value; } diff --git a/src/Math/Vector.h b/src/Math/Vector.h index 8fd5213b3..d4a1f6950 100644 --- a/src/Math/Vector.h +++ b/src/Math/Vector.h @@ -857,7 +857,7 @@ typename std::enable_if::value && std::is_floating_po #endif operator*=(Vector& vector, FloatingPoint number) { for(std::size_t i = 0; i != size; ++i) - vector[i] *= number; + vector[i] = Integral(vector[i]*number); return vector; } @@ -908,7 +908,7 @@ typename std::enable_if::value && std::is_floating_po #endif operator/=(Vector& vector, FloatingPoint number) { for(std::size_t i = 0; i != size; ++i) - vector[i] /= number; + vector[i] = Integral(vector[i]/number); return vector; } @@ -944,7 +944,7 @@ typename std::enable_if::value && std::is_floating_po #endif operator*=(Vector& a, const Vector& b) { for(std::size_t i = 0; i != size; ++i) - a[i] *= b[i]; + a[i] = Integral(a[i]*b[i]); return a; } @@ -997,7 +997,7 @@ typename std::enable_if::value && std::is_floating_po #endif operator/=(Vector& a, const Vector& b) { for(std::size_t i = 0; i != size; ++i) - a[i] /= b[i]; + a[i] = Integral(a[i]/b[i]); return a; } diff --git a/src/MeshTools/RemoveDuplicates.h b/src/MeshTools/RemoveDuplicates.h index 55d72e7ea..8b1ac58f2 100644 --- a/src/MeshTools/RemoveDuplicates.h +++ b/src/MeshTools/RemoveDuplicates.h @@ -121,7 +121,7 @@ template void RemoveDuplicates; diff --git a/src/Plugins/TgaImageConverter/TgaImageConverter.cpp b/src/Plugins/TgaImageConverter/TgaImageConverter.cpp index 84776f75c..0e2a8e15e 100644 --- a/src/Plugins/TgaImageConverter/TgaImageConverter.cpp +++ b/src/Plugins/TgaImageConverter/TgaImageConverter.cpp @@ -70,15 +70,15 @@ Containers::Array TgaImageConverter::doExportToData(const ImageRe } /* Initialize data buffer */ - const UnsignedByte pixelSize = image.pixelSize(); + const auto pixelSize = UnsignedByte(image.pixelSize()); auto data = Containers::Array::zeroInitialized(sizeof(TgaHeader) + pixelSize*image.size().product()); /* Fill header */ auto header = reinterpret_cast(data.begin()); header->imageType = image.format() == ColorFormat::Red ? 3 : 2; header->bpp = pixelSize*8; - header->width = Utility::Endianness::littleEndian(image.size().x()); - header->height = Utility::Endianness::littleEndian(image.size().y()); + header->width = UnsignedShort(Utility::Endianness::littleEndian(image.size().x())); + header->height = UnsignedShort(Utility::Endianness::littleEndian(image.size().y())); /* Fill data */ std::copy(image.data(), image.data()+pixelSize*image.size().product(), data.begin()+sizeof(TgaHeader)); diff --git a/src/Primitives/Capsule.cpp b/src/Primitives/Capsule.cpp index aec1057bf..88cb08983 100644 --- a/src/Primitives/Capsule.cpp +++ b/src/Primitives/Capsule.cpp @@ -46,7 +46,7 @@ Trade::MeshData2D Capsule2D::wireframe(UnsignedInt hemisphereRings, UnsignedInt /* Bottom hemisphere */ for(UnsignedInt i = 0; i != hemisphereRings; ++i) { - const Rad angle((i+1)*angleIncrement); + const Rad angle(Float(i+1)*angleIncrement); const Float x = Math::sin(angle); const Float y = -Math::cos(angle)-halfLength; positions.insert(positions.end(), {{-x, y}, {x, y}}); @@ -60,7 +60,7 @@ Trade::MeshData2D Capsule2D::wireframe(UnsignedInt hemisphereRings, UnsignedInt /* Top hemisphere */ for(UnsignedInt i = 0; i != hemisphereRings; ++i) { - const Rad angle(i*angleIncrement); + const Rad angle(Float(i)*angleIncrement); const Float x = Math::cos(angle); const Float y = Math::sin(angle)+halfLength; positions.insert(positions.end(), {{-x, y}, {x, y}}); diff --git a/src/Primitives/Circle.cpp b/src/Primitives/Circle.cpp index ac2d06e48..8a1f45c5b 100644 --- a/src/Primitives/Circle.cpp +++ b/src/Primitives/Circle.cpp @@ -43,7 +43,7 @@ Trade::MeshData2D Circle::solid(UnsignedInt segments) { /* Points on circle */ const Rad angleIncrement(2*Constants::pi()/segments); for(UnsignedInt i = 0; i != segments; ++i) { - const Rad angle(i*angleIncrement); + const Rad angle(Float(i)*angleIncrement); positions.emplace_back(Math::cos(angle), Math::sin(angle)); } @@ -60,7 +60,7 @@ Trade::MeshData2D Circle::wireframe(UnsignedInt segments) { /* Points on circle */ const Rad angleIncrement(2*Constants::pi()/segments); for(UnsignedInt i = 0; i != segments; ++i) { - const Rad angle(i*angleIncrement); + const Rad angle(Float(i)*angleIncrement); positions.emplace_back(Math::cos(angle), Math::sin(angle)); } diff --git a/src/Primitives/Implementation/Spheroid.cpp b/src/Primitives/Implementation/Spheroid.cpp index 506221c73..e8a1a1cb6 100644 --- a/src/Primitives/Implementation/Spheroid.cpp +++ b/src/Primitives/Implementation/Spheroid.cpp @@ -44,12 +44,12 @@ void Spheroid::hemisphereVertexRings(UnsignedInt count, Float centerY, Rad start Rad segmentAngleIncrement(2*Constants::pi()/segments); Float x, y, z; for(UnsignedInt i = 0; i != count; ++i) { - Rad ringAngle = startRingAngle + i*ringAngleIncrement; + Rad ringAngle = startRingAngle + Float(i)*ringAngleIncrement; x = z = Math::cos(ringAngle); y = Math::sin(ringAngle); for(UnsignedInt j = 0; j != segments; ++j) { - Rad segmentAngle = j*segmentAngleIncrement; + Rad segmentAngle = Float(j)*segmentAngleIncrement; positions.push_back({x*Math::sin(segmentAngle), centerY+y, z*Math::cos(segmentAngle)}); normals.push_back({x*Math::sin(segmentAngle), y, z*Math::cos(segmentAngle)}); @@ -70,7 +70,7 @@ void Spheroid::cylinderVertexRings(UnsignedInt count, Float startY, Float yIncre Rad segmentAngleIncrement(2*Constants::pi()/segments); for(UnsignedInt i = 0; i != count; ++i) { for(UnsignedInt j = 0; j != segments; ++j) { - Rad segmentAngle = j*segmentAngleIncrement; + Rad segmentAngle = Float(j)*segmentAngleIncrement; positions.push_back({Math::sin(segmentAngle), startY, Math::cos(segmentAngle)}); normals.push_back({Math::sin(segmentAngle), 0.0f, Math::cos(segmentAngle)}); @@ -144,7 +144,7 @@ void Spheroid::capVertexRing(Float y, Float textureCoordsV, const Vector3& norma Rad segmentAngleIncrement(2*Constants::pi()/segments); for(UnsignedInt i = 0; i != segments; ++i) { - Rad segmentAngle = i*segmentAngleIncrement; + Rad segmentAngle = Float(i)*segmentAngleIncrement; positions.push_back({Math::sin(segmentAngle), y, Math::cos(segmentAngle)}); normals.push_back(normal); diff --git a/src/Primitives/Implementation/WireframeSpheroid.cpp b/src/Primitives/Implementation/WireframeSpheroid.cpp index a53d7f371..475ba759a 100644 --- a/src/Primitives/Implementation/WireframeSpheroid.cpp +++ b/src/Primitives/Implementation/WireframeSpheroid.cpp @@ -45,7 +45,7 @@ void WireframeSpheroid::bottomHemisphere(const Float endY, const UnsignedInt rin /* Hemisphere vertices and indices */ const Rad ringAngleIncrement(Constants::pi()/(2*rings)); for(UnsignedInt j = 0; j != rings-1; ++j) { - const Rad angle = (j+1)*ringAngleIncrement; + const Rad angle = Float(j+1)*ringAngleIncrement; _positions.emplace_back(0.0f, endY - Math::cos(angle), Math::sin(angle)); _positions.emplace_back(Math::sin(angle), endY - Math::cos(angle), 0.0f); @@ -66,7 +66,7 @@ void WireframeSpheroid::topHemisphere(const Float startY, const UnsignedInt ring /* Hemisphere vertices and indices */ const Rad ringAngleIncrement(Constants::pi()/(2*rings)); for(UnsignedInt j = 0; j != rings-1; ++j) { - const Rad angle = (j+1)*ringAngleIncrement; + const Rad angle = Float(j+1)*ringAngleIncrement; /* Connect previous hemisphere ring to current vertices */ if(j != 0) for(UnsignedInt i = 0; i != 4; ++i) @@ -91,7 +91,7 @@ void WireframeSpheroid::ring(const Float y) { const Rad segmentAngleIncrement(Constants::pi()/(2*_segments)); for(UnsignedInt j = 0; j != _segments; ++j) { for(UnsignedInt i = 0; i != 4; ++i) { - const Rad segmentAngle = Rad(i*Constants::pi()/2) + j*segmentAngleIncrement; + const Rad segmentAngle = Rad(Float(i)*Constants::pi()/2) + Float(j)*segmentAngleIncrement; if(j != 0) _indices.insert(_indices.end(), {UnsignedInt(_positions.size()-4), UnsignedInt(_positions.size())}); _positions.emplace_back(Math::sin(segmentAngle), y, Math::cos(segmentAngle)); } diff --git a/src/SceneGraph/Object.hpp b/src/SceneGraph/Object.hpp index f9acc65b5..2cc163593 100644 --- a/src/SceneGraph/Object.hpp +++ b/src/SceneGraph/Object.hpp @@ -212,7 +212,7 @@ template std::vector Ob with different counter */ if(objects[i]->counter != 0xFFFFu) continue; - objects[i]->counter = i; + objects[i]->counter = UnsignedShort(i); objects[i]->flags |= Flag::Joint; } std::vector*> jointObjects(objects); @@ -252,7 +252,7 @@ template std::vector Ob CORRADE_ASSERT(jointObjects.size() < 0xFFFFu, "SceneGraph::Object::transformations(): too large scene", std::vector{}); CORRADE_INTERNAL_ASSERT(parent->counter == 0xFFFFu); - parent->counter = jointObjects.size(); + parent->counter = UnsignedShort(jointObjects.size()); parent->flags |= Flag::Joint; jointObjects.push_back(parent); } diff --git a/src/Shader.cpp b/src/Shader.cpp index e3a334c1b..664871931 100644 --- a/src/Shader.cpp +++ b/src/Shader.cpp @@ -610,7 +610,7 @@ Shader& Shader::addFile(const std::string& filename) { /* Get size of shader and initialize buffer */ file.seekg(0, std::ios::end); - std::string source(file.tellg(), '\0'); + std::string source(std::size_t(file.tellg()), '\0'); /* Read data, close */ file.seekg(0, std::ios::beg); diff --git a/src/Text/AbstractFont.cpp b/src/Text/AbstractFont.cpp index dace4ac51..0d92fc077 100644 --- a/src/Text/AbstractFont.cpp +++ b/src/Text/AbstractFont.cpp @@ -94,7 +94,7 @@ std::pair AbstractFont::doOpenFile(const std::string& filename, co /* Create array to hold file contents */ in.seekg(0, std::ios::end); - Containers::Array data(in.tellg()); + Containers::Array data(std::size_t(in.tellg())); /* Read data, close */ in.seekg(0, std::ios::beg); diff --git a/src/Text/AbstractFontConverter.cpp b/src/Text/AbstractFontConverter.cpp index e754e00ff..9dd5e4320 100644 --- a/src/Text/AbstractFontConverter.cpp +++ b/src/Text/AbstractFontConverter.cpp @@ -221,7 +221,7 @@ std::unique_ptr AbstractFontConverter::doImportGlyphCacheFromFile(co /* Create array to hold file contents */ in.seekg(0, std::ios::end); - Containers::Array data(in.tellg()); + Containers::Array data(std::size_t(in.tellg())); /* Read data, close */ in.seekg(0, std::ios::beg); diff --git a/src/Text/Renderer.cpp b/src/Text/Renderer.cpp index 534e3e26f..053a67e4a 100644 --- a/src/Text/Renderer.cpp +++ b/src/Text/Renderer.cpp @@ -43,8 +43,8 @@ template void createIndices(void* output, const UnsignedInt glyphCount) | | |/ / | 1---3 1 3---4 */ - const T vertex = i*4; - const T pos = i*6; + const T vertex = T(i)*4; + const T pos = T(i)*6; out[pos] = vertex; out[pos+1] = vertex+1; out[pos+2] = vertex+2; diff --git a/src/Timeline.cpp b/src/Timeline.cpp index 94cecc19f..6d6c2b65e 100644 --- a/src/Timeline.cpp +++ b/src/Timeline.cpp @@ -51,11 +51,11 @@ void Timeline::nextFrame() { if(!running) return; auto now = high_resolution_clock::now(); - UnsignedInt duration = duration_cast(now-_previousFrameTime).count(); + auto duration = UnsignedInt(duration_cast(now-_previousFrameTime).count()); _previousFrameDuration = duration/1e6f; if(_previousFrameDuration < _minimalFrameTime) { - Utility::sleep(_minimalFrameTime*1000 - duration/1000); + Utility::sleep(std::size_t(_minimalFrameTime*1000) - duration/1000); now = high_resolution_clock::now(); _previousFrameDuration = duration_cast(now-_previousFrameTime).count()/1e6f; } diff --git a/src/Trade/AbstractImporter.cpp b/src/Trade/AbstractImporter.cpp index f6b8dd3f8..76ec4021a 100644 --- a/src/Trade/AbstractImporter.cpp +++ b/src/Trade/AbstractImporter.cpp @@ -76,7 +76,7 @@ void AbstractImporter::doOpenFile(const std::string& filename) { /* Create array to hold file contents */ in.seekg(0, std::ios::end); - Containers::Array data(in.tellg()); + Containers::Array data(std::size_t(in.tellg())); /* Read data, close */ in.seekg(0, std::ios::beg); diff --git a/src/Trade/Test/AbstractImageConverterTest.cpp b/src/Trade/Test/AbstractImageConverterTest.cpp index fa0c5616b..78cb19876 100644 --- a/src/Trade/Test/AbstractImageConverterTest.cpp +++ b/src/Trade/Test/AbstractImageConverterTest.cpp @@ -53,8 +53,8 @@ void AbstractImageConverterTest::exportToFile() { Containers::Array doExportToData(const ImageReference2D& image) const override { Containers::Array out(2); - out[0] = image.size().x(); - out[1] = image.size().y(); + out[0] = static_cast(image.size().x()); + out[1] = static_cast(image.size().y()); return out; }; }; From e4cf804ec46aa3cddd0bd64e362ffcceb6f60c37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 5 Dec 2013 17:34:50 +0100 Subject: [PATCH 2/8] Use proper numeric literals. Thanks to MSVC for these. --- src/Math/Algorithms/Svd.h | 2 +- src/Math/Test/UnitTest.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Math/Algorithms/Svd.h b/src/Math/Algorithms/Svd.h index 3d4aef076..1ae6a46aa 100644 --- a/src/Math/Algorithms/Svd.h +++ b/src/Math/Algorithms/Svd.h @@ -49,7 +49,7 @@ template T pythagoras(T a, T b) { } template constexpr T smallestDelta(); -template<> constexpr Float smallestDelta() { return 1.0e-32; } +template<> constexpr Float smallestDelta() { return 1.0e-32f; } #ifndef MAGNUM_TARGET_GLES template<> constexpr Double smallestDelta() { return 1.0e-64; } #endif diff --git a/src/Math/Test/UnitTest.cpp b/src/Math/Test/UnitTest.cpp index 805b0a4b1..d1ce67d48 100644 --- a/src/Math/Test/UnitTest.cpp +++ b/src/Math/Test/UnitTest.cpp @@ -76,7 +76,7 @@ void UnitTest::constructDefault() { } void UnitTest::constructConversion() { - constexpr Seci a(25.0); + constexpr Seci a(25); constexpr Sec b(a); CORRADE_COMPARE(b, Sec(25.0f)); From 219429aeba71b1c6f433767fb5d90d63fa27880d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 5 Dec 2013 17:35:24 +0100 Subject: [PATCH 3/8] No need to have const members in AbstractShaderProgram::Attribute. Someone might someday want to copy them somehow, restricting that doesn't improve anything. --- src/AbstractShaderProgram.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/AbstractShaderProgram.h b/src/AbstractShaderProgram.h index eaa4b3c2b..ee5418187 100644 --- a/src/AbstractShaderProgram.h +++ b/src/AbstractShaderProgram.h @@ -1321,9 +1321,9 @@ template class AbstractShaderProgram::Attribute { constexpr DataOptions dataOptions() const { return _dataOptions; } private: - const Components _components; - const DataType _dataType; - const DataOptions _dataOptions; + Components _components; + DataType _dataType; + DataOptions _dataOptions; }; #ifdef DOXYGEN_GENERATING_OUTPUT From e3bf8070b5690e3f7c3eb7f36de164c90d54cf4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 5 Dec 2013 17:37:05 +0100 Subject: [PATCH 4/8] Don't return after std::abort(). MSVC marks that as unreachable code, which is. --- src/AbstractImage.cpp | 1 - src/AbstractShaderProgram.cpp | 4 ---- 2 files changed, 5 deletions(-) diff --git a/src/AbstractImage.cpp b/src/AbstractImage.cpp index d593752a7..4442dad7b 100644 --- a/src/AbstractImage.cpp +++ b/src/AbstractImage.cpp @@ -133,7 +133,6 @@ std::size_t AbstractImage::pixelSize(ColorFormat format, ColorType type) { } CORRADE_ASSERT_UNREACHABLE(); - return 0; } } diff --git a/src/AbstractShaderProgram.cpp b/src/AbstractShaderProgram.cpp index a290dd070..c75ad6386 100644 --- a/src/AbstractShaderProgram.cpp +++ b/src/AbstractShaderProgram.cpp @@ -762,7 +762,6 @@ std::size_t FloatAttribute::size(GLint components, DataType dataType) { } CORRADE_ASSERT_UNREACHABLE(); - return 0; } #ifndef MAGNUM_TARGET_GLES2 @@ -780,7 +779,6 @@ std::size_t IntAttribute::size(GLint components, DataType dataType) { } CORRADE_ASSERT_UNREACHABLE(); - return 0; } #endif @@ -792,7 +790,6 @@ std::size_t DoubleAttribute::size(GLint components, DataType dataType) { } CORRADE_ASSERT_UNREACHABLE(); - return 0; } #endif @@ -827,7 +824,6 @@ std::size_t Attribute>::size(GLint components, DataType d } CORRADE_ASSERT_UNREACHABLE(); - return 0; } Debug operator<<(Debug debug, SizedAttribute<1, 1>::Components value) { From c2a2ca88e4b1be37c0058510f9942aadb616dbda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 5 Dec 2013 17:37:46 +0100 Subject: [PATCH 5/8] SceneGraph: fix assertion expression. We should have used == instead of =, the counter is set to that value later anyway, so this didn't break anything... but the assert was useless. Hopefully it won't fire each time now :-) --- src/SceneGraph/Object.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SceneGraph/Object.hpp b/src/SceneGraph/Object.hpp index 2cc163593..b050a7a96 100644 --- a/src/SceneGraph/Object.hpp +++ b/src/SceneGraph/Object.hpp @@ -282,7 +282,7 @@ template std::vector Ob for(auto i: jointObjects) { /* All not-already cleaned objects (...duplicate occurences) should have joint mark */ - CORRADE_INTERNAL_ASSERT(i->counter = 0xFFFFu || i->flags & Flag::Joint); + CORRADE_INTERNAL_ASSERT(i->counter == 0xFFFFu || i->flags & Flag::Joint); i->flags &= ~Flag::Joint; i->counter = 0xFFFFu; } From 14ea7dd072560dc5ce1daafdfe5d103840eb3651 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 5 Dec 2013 17:39:26 +0100 Subject: [PATCH 6/8] DebugTools: fix linking on Windows. MSVC complained about dllexporting already exported interface or what. MinGW doesn't care. --- src/DebugTools/ResourceManager.cpp | 4 ++++ src/DebugTools/ResourceManager.h | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/DebugTools/ResourceManager.cpp b/src/DebugTools/ResourceManager.cpp index 6b385af7d..8a8491f55 100644 --- a/src/DebugTools/ResourceManager.cpp +++ b/src/DebugTools/ResourceManager.cpp @@ -35,7 +35,11 @@ namespace Magnum { +#ifndef _WIN32 template class ResourceManager; +#else +template class MAGNUM_DEBUGTOOLS_EXPORT ResourceManager; +#endif namespace DebugTools { diff --git a/src/DebugTools/ResourceManager.h b/src/DebugTools/ResourceManager.h index f5205e044..c83ecd7a2 100644 --- a/src/DebugTools/ResourceManager.h +++ b/src/DebugTools/ResourceManager.h @@ -45,7 +45,11 @@ namespace Magnum { /** @todo Do the listing in one place, not five thousand! */ +#ifndef _WIN32 extern template ResourceManager MAGNUM_DEBUGTOOLS_EXPORT *& ResourceManager::internalInstance(); +#else +extern template class MAGNUM_DEBUGTOOLS_EXPORT ResourceManager; +#endif namespace DebugTools { From bdfab39a89f1d78279d6ee136a7af290556d2184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 5 Dec 2013 17:41:05 +0100 Subject: [PATCH 7/8] external: use GCC-specific flags only for GCC/Clang. --- external/OpenGL/GL/CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/external/OpenGL/GL/CMakeLists.txt b/external/OpenGL/GL/CMakeLists.txt index 5af8720ab..c8048349e 100644 --- a/external/OpenGL/GL/CMakeLists.txt +++ b/external/OpenGL/GL/CMakeLists.txt @@ -23,6 +23,11 @@ # add_library(MagnumGLLoadGenObjects OBJECT gl_magnum.c) -set_target_properties(MagnumGLLoadGenObjects PROPERTIES COMPILE_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} -fvisibility=hidden -DGLLoadGen_EXPORTS") + +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + set_target_properties(MagnumGLLoadGenObjects PROPERTIES COMPILE_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} -fvisibility=hidden -DGLLoadGen_EXPORTS") +else() + set_target_properties(MagnumGLLoadGenObjects PROPERTIES COMPILE_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} -DGLLoadGen_EXPORTS") +endif() install(FILES gl_magnum.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/OpenGL/GL) From b9b9c38371e45efaa998352e86d301c8f4e452cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 5 Dec 2013 17:41:30 +0100 Subject: [PATCH 8/8] SceneGraph: fix infinite recursion problems. Spotted by MSVC. The virtual interface isn't used much anyway, so it wasn't detected until now. --- src/SceneGraph/DualComplexTransformation.h | 2 +- src/SceneGraph/MatrixTransformation2D.h | 2 +- src/SceneGraph/RigidMatrixTransformation2D.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/SceneGraph/DualComplexTransformation.h b/src/SceneGraph/DualComplexTransformation.h index 539c5ed79..6037fab9e 100644 --- a/src/SceneGraph/DualComplexTransformation.h +++ b/src/SceneGraph/DualComplexTransformation.h @@ -129,7 +129,7 @@ template class BasicDualComplexTransformation: public AbstractBasicTran } void doRotate(Math::Rad angle, TransformationType type) override final { - doRotate(angle, type); + rotate(angle, type); } /* No assertions fired, for internal use */ diff --git a/src/SceneGraph/MatrixTransformation2D.h b/src/SceneGraph/MatrixTransformation2D.h index ae282f44d..d3b4f03dc 100644 --- a/src/SceneGraph/MatrixTransformation2D.h +++ b/src/SceneGraph/MatrixTransformation2D.h @@ -129,7 +129,7 @@ template class BasicMatrixTransformation2D: public AbstractBasicTransla } void doRotate(Math::Rad angle, TransformationType type) override final { - doRotate(angle, type); + rotate(angle, type); } void doScale(const Math::Vector2& vector, TransformationType type) override final { diff --git a/src/SceneGraph/RigidMatrixTransformation2D.h b/src/SceneGraph/RigidMatrixTransformation2D.h index b369f114e..072015013 100644 --- a/src/SceneGraph/RigidMatrixTransformation2D.h +++ b/src/SceneGraph/RigidMatrixTransformation2D.h @@ -146,7 +146,7 @@ template class BasicRigidMatrixTransformation2D: public AbstractBasicTr } void doRotate(Math::Rad angle, TransformationType type) override final { - doRotate(angle, type); + rotate(angle, type); } /* No assertions fired, for internal use */