diff --git a/src/AbstractImage.cpp b/src/AbstractImage.cpp index 84b2b82eb..00e2fcbd8 100644 --- a/src/AbstractImage.cpp +++ b/src/AbstractImage.cpp @@ -19,12 +19,10 @@ #include "TypeTraits.h" -using namespace std; - namespace Magnum { -size_t AbstractImage::pixelSize(Components format, ComponentType type) { - size_t size = 0; +std::size_t AbstractImage::pixelSize(Components format, ComponentType type) { + std::size_t size = 0; switch(type) { #ifndef MAGNUM_TARGET_GLES case ComponentType::RGB332: diff --git a/src/AbstractShaderProgram.cpp b/src/AbstractShaderProgram.cpp index cb181b9b4..7fe59d747 100644 --- a/src/AbstractShaderProgram.cpp +++ b/src/AbstractShaderProgram.cpp @@ -25,8 +25,6 @@ #define LINKER_MESSAGE_MAX_LENGTH 1024 -using namespace std; - namespace Magnum { AbstractShaderProgram::Uniform1fImplementation AbstractShaderProgram::uniform1fImplementation = &AbstractShaderProgram::uniformImplementationDefault; @@ -108,7 +106,7 @@ bool AbstractShaderProgram::attachShader(Shader& shader) { return true; } -void AbstractShaderProgram::bindAttributeLocation(GLuint location, const string& name) { +void AbstractShaderProgram::bindAttributeLocation(GLuint location, const std::string& name) { CORRADE_ASSERT(state == Initialized, "AbstractShaderProgram: attribute cannot be bound after linking.", ); glBindAttribLocation(_id, location, name.c_str()); diff --git a/src/AbstractShaderProgram.h b/src/AbstractShaderProgram.h index 53a383d1a..4f506270a 100644 --- a/src/AbstractShaderProgram.h +++ b/src/AbstractShaderProgram.h @@ -1095,17 +1095,17 @@ template<> struct Attribute { CORRADE_ENUMSET_OPERATORS(Attribute::DataOptions) -template struct Attribute>: public Attribute { +template struct Attribute>: public Attribute { inline constexpr static GLint size(DataOptions) { return vectorSize; } inline constexpr static std::size_t vectorCount() { return 1; } }; -template struct Attribute>: public Attribute { +template struct Attribute>: public Attribute { inline constexpr static GLint size(DataOptions) { return rows; } inline constexpr static std::size_t vectorCount() { return cols; } }; -template struct Attribute>: public Attribute { +template struct Attribute>: public Attribute { inline constexpr static GLint size(DataOptions) { return matrixSize; } inline constexpr static std::size_t vectorCount() { return matrixSize; } }; @@ -1192,11 +1192,11 @@ template<> struct Attribute { inline constexpr static GLint size() { return 1; } }; -template struct Attribute>: public Attribute { +template struct Attribute>: public Attribute { inline constexpr static GLint size() { return size; } }; -template struct Attribute>: public Attribute { +template struct Attribute>: public Attribute { inline constexpr static GLint size() { return size; } }; @@ -1216,17 +1216,17 @@ template<> struct Attribute { inline constexpr static std::size_t vectorCount() { return 1; } }; -template struct Attribute>: public Attribute { +template struct Attribute>: public Attribute { inline constexpr static GLint size() { return rows; } inline constexpr static std::size_t vectorCount() { return cols; } }; -template struct Attribute>: public Attribute { +template struct Attribute>: public Attribute { inline constexpr static GLint size() { return size; } inline constexpr static std::size_t vectorCount() { return size; } }; -template struct Attribute>: public Attribute { +template struct Attribute>: public Attribute { inline constexpr static GLint size() { return size; } inline constexpr static std::size_t vectorCount() { return size; } }; diff --git a/src/Color.h b/src/Color.h index 300fa549a..54eac2a1c 100644 --- a/src/Color.h +++ b/src/Color.h @@ -167,7 +167,7 @@ class Color3: public Math::Vector3 { * @brief Create integral color from floating-point color * * E.g. `{0.294118, 0.45098, 0.878431}` is converted to - * `{75, 115, 224}`, if resulting type is `uint8_t`. + * `{75, 115, 224}`, if resulting type is `std::uint8_t`. * * @note This function is enabled only if source type is floating-point * and destination type is integral. @@ -182,7 +182,7 @@ class Color3: public Math::Vector3 { * @brief Create floating-point color from integral color * * E.g. `{75, 115, 224}` is converted to - * `{0.294118, 0.45098, 0.878431}`, if source type is `uint8_t`. + * `{0.294118, 0.45098, 0.878431}`, if source type is `std::uint8_t`. * * @note This function is enabled only if source type is integral * and destination type is floating-point. diff --git a/src/Context.cpp b/src/Context.cpp index 8b43039bb..28f49000c 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -30,8 +30,6 @@ #include "Implementation/State.h" #include "DebugMarker.h" -using namespace std; - namespace Magnum { #ifndef DOXYGEN_GENERATING_OUTPUT @@ -202,7 +200,7 @@ Context::Context() { _version = static_cast(_majorVersion*100+_minorVersion*10); /* Get first future (not supported) version */ - vector versions{ + std::vector versions{ #ifndef MAGNUM_TARGET_GLES Version::GL300, Version::GL310, @@ -218,17 +216,17 @@ Context::Context() { #endif Version::None }; - size_t future = 0; + std::size_t future = 0; while(versions[future] != Version::None && !isVersionSupported(_version)) ++future; /* List of extensions from future versions (extensions from current and previous versions should be supported automatically, so we don't need to check for them) */ - unordered_map futureExtensions; - for(size_t i = future; i != versions.size(); ++i) + std::unordered_map futureExtensions; + for(std::size_t i = future; i != versions.size(); ++i) for(const Extension& extension: Extension::extensions(versions[i])) - futureExtensions.insert(make_pair(extension._string, extension)); + futureExtensions.insert(std::make_pair(extension._string, extension)); /* Check for presence of extensions in future versions */ #ifndef MAGNUM_TARGET_GLES @@ -253,8 +251,8 @@ Context::Context() { /* Don't crash when glGetString() returns nullptr */ const char* e = reinterpret_cast(glGetString(GL_EXTENSIONS)); if(e) { - vector extensions = Corrade::Utility::String::split(e, ' '); - for(const string& extension: extensions) { + std::vector extensions = Corrade::Utility::String::split(e, ' '); + for(const std::string& extension: extensions) { auto found = futureExtensions.find(extension); if(found != futureExtensions.end()) { _supportedExtensions.push_back(found->second); @@ -289,7 +287,7 @@ Context::~Context() { _current = nullptr; } -Version Context::supportedVersion(initializer_list versions) const { +Version Context::supportedVersion(std::initializer_list versions) const { for(auto version: versions) if(isVersionSupported(version)) return version; diff --git a/src/Context.h b/src/Context.h index 5704762ab..ea6172e31 100644 --- a/src/Context.h +++ b/src/Context.h @@ -318,7 +318,7 @@ MAGNUM_ASSERT_VERSION_SUPPORTED(Version::GL330); do { \ if(!Context::current()->isVersionSupported(version)) { \ Corrade::Utility::Error() << "Magnum: required version" << version << "is not supported"; \ - exit(-3); \ + std::exit(-3); \ } \ } while(0) #endif @@ -348,7 +348,7 @@ MAGNUM_ASSERT_EXTENSION_SUPPORTED(Extensions::GL::ARB::geometry_shader4); do { \ if(!Context::current()->isExtensionSupported()) { \ Corrade::Utility::Error() << "Magnum: required extension" << extension::string() << "is not supported"; \ - exit(-3); \ + std::exit(-3); \ } \ } while(0) #endif diff --git a/src/Math/Geometry/Test/DistanceTest.cpp b/src/Math/Geometry/Test/DistanceTest.cpp index ace9c485a..79de37345 100644 --- a/src/Math/Geometry/Test/DistanceTest.cpp +++ b/src/Math/Geometry/Test/DistanceTest.cpp @@ -22,8 +22,6 @@ CORRADE_TEST_MAIN(Magnum::Math::Geometry::Test::DistanceTest) -using namespace std; - namespace Magnum { namespace Math { namespace Geometry { namespace Test { typedef Magnum::Math::Vector2 Vector2; diff --git a/src/Math/Geometry/Test/IntersectionTest.cpp b/src/Math/Geometry/Test/IntersectionTest.cpp index 5112b5e84..c19591be8 100644 --- a/src/Math/Geometry/Test/IntersectionTest.cpp +++ b/src/Math/Geometry/Test/IntersectionTest.cpp @@ -21,8 +21,6 @@ CORRADE_TEST_MAIN(Magnum::Math::Geometry::Test::IntersectionTest) -using namespace std; - namespace Magnum { namespace Math { namespace Geometry { namespace Test { typedef Magnum::Math::Vector3 Vector3; @@ -45,11 +43,11 @@ void IntersectionTest::planeLine() { /* Line lies on the plane */ CORRADE_COMPARE(Intersection::planeLine(planePosition, planeNormal, - Vector3(1.0f, 0.5f, 0.5f), Vector3(0.0f, 1.0f, 0.5f)), numeric_limits::quiet_NaN()); + Vector3(1.0f, 0.5f, 0.5f), Vector3(0.0f, 1.0f, 0.5f)), std::numeric_limits::quiet_NaN()); /* Line is parallell to the plane */ CORRADE_COMPARE((Intersection::planeLine(planePosition, planeNormal, - Vector3(1.0f, 0.0f, 1.0f), Vector3(0.0f, 0.0f, 1.0f))), -numeric_limits::infinity()); + Vector3(1.0f, 0.0f, 1.0f), Vector3(0.0f, 0.0f, 1.0f))), -std::numeric_limits::infinity()); } }}}} diff --git a/src/Math/Math.cpp b/src/Math/Math.cpp index ec39d403d..7e432040f 100644 --- a/src/Math/Math.cpp +++ b/src/Math/Math.cpp @@ -15,12 +15,10 @@ #include "Math.h" -using namespace std; - namespace Magnum { namespace Math { std::uint32_t log(std::uint32_t base, std::uint32_t number) { - uint32_t log = 0; + std::uint32_t log = 0; while(number /= base) ++log; return log; diff --git a/src/Math/Math.h b/src/Math/Math.h index a11f3c142..5d68b2e2d 100644 --- a/src/Math/Math.h +++ b/src/Math/Math.h @@ -78,7 +78,7 @@ explicit, e.g.: float a = normalize('\127'); // b = 1.0f -float b = normalize('\127'); +float b = normalize('\127'); @endcode @todo Signed normalization to [-1.0, 1.0] like in OpenGL? diff --git a/src/Math/Test/MathTest.cpp b/src/Math/Test/MathTest.cpp index 3aa7348ed..424e470cc 100644 --- a/src/Math/Test/MathTest.cpp +++ b/src/Math/Test/MathTest.cpp @@ -17,8 +17,6 @@ #include "Math.h" -using namespace std; - CORRADE_TEST_MAIN(Magnum::Math::Test::MathTest) namespace Magnum { namespace Math { namespace Test { @@ -33,46 +31,46 @@ MathTest::MathTest() { void MathTest::normalize() { /* Range for signed and unsigned */ - CORRADE_COMPARE((Math::normalize(-128)), 0.0f); - CORRADE_COMPARE((Math::normalize(127)), 1.0f); - CORRADE_COMPARE((Math::normalize(0)), 0.0f); - CORRADE_COMPARE((Math::normalize(255)), 1.0f); + CORRADE_COMPARE((Math::normalize(-128)), 0.0f); + CORRADE_COMPARE((Math::normalize(127)), 1.0f); + CORRADE_COMPARE((Math::normalize(0)), 0.0f); + CORRADE_COMPARE((Math::normalize(255)), 1.0f); /* Between */ - CORRADE_COMPARE((Math::normalize(16384)), 0.750011f); - CORRADE_COMPARE((Math::normalize(-16384)), 0.250004f); + CORRADE_COMPARE((Math::normalize(16384)), 0.750011f); + CORRADE_COMPARE((Math::normalize(-16384)), 0.250004f); /* Test overflow for large types */ - CORRADE_COMPARE((Math::normalize(numeric_limits::min())), 0.0f); - CORRADE_COMPARE((Math::normalize(numeric_limits::max())), 1.0f); - CORRADE_COMPARE((Math::normalize(0)), 0.0f); - CORRADE_COMPARE((Math::normalize(numeric_limits::max())), 1.0f); - - CORRADE_COMPARE((Math::normalize(numeric_limits::min())), 0.0); - CORRADE_COMPARE((Math::normalize(numeric_limits::max())), 1.0); - CORRADE_COMPARE((Math::normalize(0)), 0.0); - CORRADE_COMPARE((Math::normalize(numeric_limits::max())), 1.0); + CORRADE_COMPARE((Math::normalize(std::numeric_limits::min())), 0.0f); + CORRADE_COMPARE((Math::normalize(std::numeric_limits::max())), 1.0f); + CORRADE_COMPARE((Math::normalize(0)), 0.0f); + CORRADE_COMPARE((Math::normalize(std::numeric_limits::max())), 1.0f); + + CORRADE_COMPARE((Math::normalize(std::numeric_limits::min())), 0.0); + CORRADE_COMPARE((Math::normalize(std::numeric_limits::max())), 1.0); + CORRADE_COMPARE((Math::normalize(0)), 0.0); + CORRADE_COMPARE((Math::normalize(std::numeric_limits::max())), 1.0); } void MathTest::denormalize() { /* Range for signed and unsigned */ - CORRADE_COMPARE(Math::denormalize(0.0f), -128); - CORRADE_COMPARE(Math::denormalize(1.0f), 127); - CORRADE_COMPARE(Math::denormalize(0.0f), 0); - CORRADE_COMPARE(Math::denormalize(1.0f), 255); + CORRADE_COMPARE(Math::denormalize(0.0f), -128); + CORRADE_COMPARE(Math::denormalize(1.0f), 127); + CORRADE_COMPARE(Math::denormalize(0.0f), 0); + CORRADE_COMPARE(Math::denormalize(1.0f), 255); /* Between */ - CORRADE_COMPARE(Math::denormalize(0.33f), -11141); - CORRADE_COMPARE(Math::denormalize(0.66f), 10485); + CORRADE_COMPARE(Math::denormalize(0.33f), -11141); + CORRADE_COMPARE(Math::denormalize(0.66f), 10485); /* Test overflow for large types */ - CORRADE_COMPARE(Math::denormalize(0.0f), numeric_limits::min()); - CORRADE_COMPARE(Math::denormalize(0.0f), 0); - CORRADE_COMPARE(Math::denormalize(0.0), numeric_limits::min()); - CORRADE_COMPARE(Math::denormalize(0.0), 0); + CORRADE_COMPARE(Math::denormalize(0.0f), std::numeric_limits::min()); + CORRADE_COMPARE(Math::denormalize(0.0f), 0); + CORRADE_COMPARE(Math::denormalize(0.0), std::numeric_limits::min()); + CORRADE_COMPARE(Math::denormalize(0.0), 0); - CORRADE_COMPARE(Math::denormalize(1.0), numeric_limits::max()); - CORRADE_COMPARE(Math::denormalize(1.0), numeric_limits::max()); + CORRADE_COMPARE(Math::denormalize(1.0), std::numeric_limits::max()); + CORRADE_COMPARE(Math::denormalize(1.0), std::numeric_limits::max()); // { // CORRADE_EXPECT_FAIL("Denormalize doesn't work for large types well"); diff --git a/src/Math/Test/MathTypeTraitsTest.cpp b/src/Math/Test/MathTypeTraitsTest.cpp index cae312032..e2d08dd1c 100644 --- a/src/Math/Test/MathTypeTraitsTest.cpp +++ b/src/Math/Test/MathTypeTraitsTest.cpp @@ -21,8 +21,6 @@ CORRADE_TEST_MAIN(Magnum::Math::Test::MathTypeTraitsTest) -using namespace std; - namespace Magnum { namespace Math { namespace Test { MathTypeTraitsTest::MathTypeTraitsTest() { @@ -31,14 +29,14 @@ MathTypeTraitsTest::MathTypeTraitsTest() { } void MathTypeTraitsTest::equalsIntegral() { - _equalsIntegral(); - _equalsIntegral(); - _equalsIntegral(); - _equalsIntegral(); - _equalsIntegral(); - _equalsIntegral(); - _equalsIntegral(); - _equalsIntegral(); + _equalsIntegral(); + _equalsIntegral(); + _equalsIntegral(); + _equalsIntegral(); + _equalsIntegral(); + _equalsIntegral(); + _equalsIntegral(); + _equalsIntegral(); } void MathTypeTraitsTest::equalsFloatingPoint() { diff --git a/src/Math/Test/Matrix3Test.cpp b/src/Math/Test/Matrix3Test.cpp index e25c020b0..107d61494 100644 --- a/src/Math/Test/Matrix3Test.cpp +++ b/src/Math/Test/Matrix3Test.cpp @@ -22,7 +22,6 @@ CORRADE_TEST_MAIN(Magnum::Math::Test::Matrix3Test) -using namespace std; using namespace Corrade::Utility; namespace Magnum { namespace Math { namespace Test { @@ -140,7 +139,7 @@ void Matrix3Test::debug() { 7.0f, -1.0f, 8.0f ); - ostringstream o; + std::ostringstream o; Debug(&o) << m; CORRADE_COMPARE(o.str(), "Matrix(3, 4, 7,\n" " 5, 4, -1,\n" @@ -155,10 +154,10 @@ void Matrix3Test::configuration() { 4.0f, 7.0f, 3.125f, 4.0f, 5.0f, 9.55f ); - string value("5 4 4 8 7 5 4 3.125 9.55"); + std::string value("5 4 4 8 7 5 4 3.125 9.55"); c.setValue("matrix", m); - CORRADE_COMPARE(c.value("matrix"), value); + CORRADE_COMPARE(c.value("matrix"), value); CORRADE_COMPARE(c.value("matrix"), m); } diff --git a/src/Math/Test/Matrix4Test.cpp b/src/Math/Test/Matrix4Test.cpp index 7ecac7095..5b2ed7a1b 100644 --- a/src/Math/Test/Matrix4Test.cpp +++ b/src/Math/Test/Matrix4Test.cpp @@ -22,7 +22,6 @@ CORRADE_TEST_MAIN(Magnum::Math::Test::Matrix4Test) -using namespace std; using namespace Corrade::Utility; namespace Magnum { namespace Math { namespace Test { @@ -93,7 +92,7 @@ void Matrix4Test::scaling() { } void Matrix4Test::rotation() { - ostringstream o; + std::ostringstream o; Error::setOutput(&o); CORRADE_COMPARE(Matrix4::rotation(deg(-74.0f), {-1.0f, 2.0f, 2.0f}), Matrix4()); @@ -190,7 +189,7 @@ void Matrix4Test::debug() { 9.0f, 4.0f, 5.0f, 9.0f ); - ostringstream o; + std::ostringstream o; Debug(&o) << m; CORRADE_COMPARE(o.str(), "Matrix(3, 4, 7, 9,\n" " 5, 4, -1, 4,\n" @@ -207,10 +206,10 @@ void Matrix4Test::configuration() { 7.0f, -1.0f, 8.0f, 0.0f, 9.0f, 4.0f, 5.0f, 9.55f ); - string value("3 4 7 9 5 4 -1 4 8 7 8 5 4 3.125 0 9.55"); + std::string value("3 4 7 9 5 4 -1 4 8 7 8 5 4 3.125 0 9.55"); c.setValue("matrix", m); - CORRADE_COMPARE(c.value("matrix"), value); + CORRADE_COMPARE(c.value("matrix"), value); CORRADE_COMPARE(c.value("matrix"), m); } diff --git a/src/Math/Test/MatrixTest.cpp b/src/Math/Test/MatrixTest.cpp index cc902f199..924ac0afe 100644 --- a/src/Math/Test/MatrixTest.cpp +++ b/src/Math/Test/MatrixTest.cpp @@ -21,7 +21,6 @@ CORRADE_TEST_MAIN(Magnum::Math::Test::MatrixTest) -using namespace std; using namespace Corrade::Utility; namespace Magnum { namespace Math { namespace Test { @@ -98,7 +97,7 @@ void MatrixTest::constructZero() { } void MatrixTest::trace() { - Matrix<5, int32_t> m( + Matrix<5, std::int32_t> m( 1, 2, 3, 0, 0, 2, 3, 2, 1, -2, 1, 1, -20, 1, 0, @@ -127,7 +126,7 @@ void MatrixTest::ij() { } void MatrixTest::determinant() { - Matrix<5, int32_t> m( + Matrix<5, std::int32_t> m( 1, 2, 2, 1, 0, 2, 3, 2, 1, -2, 1, 1, 1, 1, 0, @@ -167,7 +166,7 @@ void MatrixTest::debug() { 9.0f, 4.0f, 5.0f, 9.0f ); - ostringstream o; + std::ostringstream o; Debug(&o) << m; CORRADE_COMPARE(o.str(), "Matrix(3, 4, 7, 9,\n" " 5, 4, -1, 4,\n" @@ -194,10 +193,10 @@ void MatrixTest::configuration() { 7.0f, -1.0f, 8.0f, 0.0f, 9.0f, 4.0f, 5.0f, 9.55f ); - string value("3 4 7 9 5 4 -1 4 8 7 8 5 4 3.125 0 9.55"); + std::string value("3 4 7 9 5 4 -1 4 8 7 8 5 4 3.125 0 9.55"); c.setValue("matrix", m); - CORRADE_COMPARE(c.value("matrix"), value); + CORRADE_COMPARE(c.value("matrix"), value); CORRADE_COMPARE(c.value("matrix"), m); } diff --git a/src/Math/Test/Point2DTest.cpp b/src/Math/Test/Point2DTest.cpp index 63a93c345..0ad2c4dae 100644 --- a/src/Math/Test/Point2DTest.cpp +++ b/src/Math/Test/Point2DTest.cpp @@ -21,7 +21,6 @@ CORRADE_TEST_MAIN(Magnum::Math::Test::Point2DTest) -using namespace std; using namespace Corrade::Utility; namespace Magnum { namespace Math { namespace Test { @@ -41,7 +40,7 @@ void Point2DTest::construct() { } void Point2DTest::debug() { - ostringstream o; + std::ostringstream o; Debug(&o) << Point2D(0.5f, 15.0f, 1.0f); CORRADE_COMPARE(o.str(), "Vector(0.5, 15, 1)\n"); } @@ -50,10 +49,10 @@ void Point2DTest::configuration() { Configuration c; Point2D vec(3.0f, 3.125f, 9.55f); - string value("3 3.125 9.55"); + std::string value("3 3.125 9.55"); c.setValue("point", vec); - CORRADE_COMPARE(c.value("point"), value); + CORRADE_COMPARE(c.value("point"), value); CORRADE_COMPARE(c.value("point"), vec); } diff --git a/src/Math/Test/Point3DTest.cpp b/src/Math/Test/Point3DTest.cpp index e4f24920f..9293b7881 100644 --- a/src/Math/Test/Point3DTest.cpp +++ b/src/Math/Test/Point3DTest.cpp @@ -21,7 +21,6 @@ CORRADE_TEST_MAIN(Magnum::Math::Test::Point3DTest) -using namespace std; using namespace Corrade::Utility; namespace Magnum { namespace Math { namespace Test { @@ -41,7 +40,7 @@ void Point3DTest::construct() { } void Point3DTest::debug() { - ostringstream o; + std::ostringstream o; Debug(&o) << Point3D(0.5f, 15.0f, 1.0f, 1.0f); CORRADE_COMPARE(o.str(), "Vector(0.5, 15, 1, 1)\n"); } @@ -50,10 +49,10 @@ void Point3DTest::configuration() { Configuration c; Point3D vec(3.0f, 3.125f, 9.0f, 9.55f); - string value("3 3.125 9 9.55"); + std::string value("3 3.125 9 9.55"); c.setValue("point", vec); - CORRADE_COMPARE(c.value("point"), value); + CORRADE_COMPARE(c.value("point"), value); CORRADE_COMPARE(c.value("point"), vec); } diff --git a/src/Math/Test/RectangularMatrixTest.cpp b/src/Math/Test/RectangularMatrixTest.cpp index 344e2fcd1..adb989de0 100644 --- a/src/Math/Test/RectangularMatrixTest.cpp +++ b/src/Math/Test/RectangularMatrixTest.cpp @@ -21,7 +21,6 @@ CORRADE_TEST_MAIN(Magnum::Math::Test::RectangularMatrixTest) -using namespace std; using namespace Corrade::Utility; namespace Magnum { namespace Math { namespace Test { @@ -29,7 +28,7 @@ namespace Magnum { namespace Math { namespace Test { typedef RectangularMatrix<4, 3, float> Matrix4x3; typedef RectangularMatrix<3, 4, float> Matrix3x4; typedef RectangularMatrix<2, 2, float> Matrix2; -typedef RectangularMatrix<2, 2, int32_t> Matrix2i; +typedef RectangularMatrix<2, 2, std::int32_t> Matrix2i; typedef Vector<4, float> Vector4; RectangularMatrixTest::RectangularMatrixTest() { @@ -154,8 +153,8 @@ void RectangularMatrixTest::multiplyDivide() { CORRADE_COMPARE(-1.5f*vec, multiplied); CORRADE_COMPARE(multiplied/-1.5f, vec); - Math::RectangularMatrix<1, 1, int8_t> vecChar(32); - Math::RectangularMatrix<1, 1, int8_t> multipliedChar(-48); + Math::RectangularMatrix<1, 1, std::int8_t> vecChar(32); + Math::RectangularMatrix<1, 1, std::int8_t> multipliedChar(-48); CORRADE_COMPARE(vecChar*-1.5f, multipliedChar); CORRADE_COMPARE(multipliedChar/-1.5f, vecChar); CORRADE_COMPARE(-1.5f*vecChar, multipliedChar); @@ -168,14 +167,14 @@ void RectangularMatrixTest::multiplyDivide() { } void RectangularMatrixTest::multiply() { - RectangularMatrix<4, 6, int32_t> left( + RectangularMatrix<4, 6, std::int32_t> left( -5, 27, 10, 33, 0, -15, 7, 56, 66, 1, 0, -24, 4, 41, 4, 0, 1, -4, 9, -100, 19, -49, 1, 9 ); - RectangularMatrix<5, 4, int32_t> right( + RectangularMatrix<5, 4, std::int32_t> right( 1, -7, 0, 158, 2, 24, -3, 40, 3, -15, -2, -50, @@ -183,7 +182,7 @@ void RectangularMatrixTest::multiply() { 5, 30, 4, 18 ); - RectangularMatrix<5, 6, int32_t> expected( + RectangularMatrix<5, 6, std::int32_t> expected( 1368, -16165, 2550, -7716, 158, 1575, 506, -2725, 2352, -1870, 37, -234, -578, 4159, -1918, 2534, -52, -127, @@ -218,7 +217,7 @@ void RectangularMatrixTest::debug() { 7.0f, -1.0f, 8.0f, 0.0f ); - ostringstream o; + std::ostringstream o; Debug(&o) << m; CORRADE_COMPARE(o.str(), "Matrix(3, 4, 7,\n" " 5, 4, -1,\n" @@ -226,7 +225,7 @@ void RectangularMatrixTest::debug() { " 4, 3, 0)\n"); o.str(""); - Debug(&o) << "a" << Matrix3x4() << "b" << RectangularMatrix<4, 3, int8_t>(); + Debug(&o) << "a" << Matrix3x4() << "b" << RectangularMatrix<4, 3, std::int8_t>(); CORRADE_COMPARE(o.str(), "a Matrix(0, 0, 0,\n" " 0, 0, 0,\n" " 0, 0, 0,\n" @@ -241,12 +240,12 @@ void RectangularMatrixTest::configuration() { 4.0f, 4.0f, 7.0f, 3.125f, 7.0f, -1.0f, 8.0f, 9.55f ); - string value("3 4 7 5 4 -1 8 7 8 4 3.125 9.55"); + std::string value("3 4 7 5 4 -1 8 7 8 4 3.125 9.55"); Configuration c; c.setValue("matrix", m); - CORRADE_COMPARE(c.value("matrix"), value); + CORRADE_COMPARE(c.value("matrix"), value); CORRADE_COMPARE(c.value("matrix"), m); } diff --git a/src/Math/Test/Vector2Test.cpp b/src/Math/Test/Vector2Test.cpp index a5ec5b443..316094de0 100644 --- a/src/Math/Test/Vector2Test.cpp +++ b/src/Math/Test/Vector2Test.cpp @@ -21,7 +21,6 @@ CORRADE_TEST_MAIN(Magnum::Math::Test::Vector2Test) -using namespace std; using namespace Corrade::Utility; namespace Magnum { namespace Math { namespace Test { @@ -62,7 +61,7 @@ void Vector2Test::scales() { } void Vector2Test::debug() { - ostringstream o; + std::ostringstream o; Debug(&o) << Vector2(0.5f, 15.0f); CORRADE_COMPARE(o.str(), "Vector(0.5, 15)\n"); } @@ -71,10 +70,10 @@ void Vector2Test::configuration() { Configuration c; Vector2 vec(3.125f, 9.0f); - string value("3.125 9"); + std::string value("3.125 9"); c.setValue("vector", vec); - CORRADE_COMPARE(c.value("vector"), value); + CORRADE_COMPARE(c.value("vector"), value); CORRADE_COMPARE(c.value("vector"), vec); } diff --git a/src/Math/Test/Vector3Test.cpp b/src/Math/Test/Vector3Test.cpp index ea2f3409a..51b31437f 100644 --- a/src/Math/Test/Vector3Test.cpp +++ b/src/Math/Test/Vector3Test.cpp @@ -21,7 +21,6 @@ CORRADE_TEST_MAIN(Magnum::Math::Test::Vector3Test) -using namespace std; using namespace Corrade::Utility; namespace Magnum { namespace Math { namespace Test { @@ -82,7 +81,7 @@ void Vector3Test::twoComponent() { } void Vector3Test::debug() { - ostringstream o; + std::ostringstream o; Debug(&o) << Vector3(0.5f, 15.0f, 1.0f); CORRADE_COMPARE(o.str(), "Vector(0.5, 15, 1)\n"); } @@ -91,10 +90,10 @@ void Vector3Test::configuration() { Configuration c; Vector3 vec(3.0f, 3.125f, 9.55f); - string value("3 3.125 9.55"); + std::string value("3 3.125 9.55"); c.setValue("vector", vec); - CORRADE_COMPARE(c.value("vector"), value); + CORRADE_COMPARE(c.value("vector"), value); CORRADE_COMPARE(c.value("vector"), vec); } diff --git a/src/Math/Test/Vector4Test.cpp b/src/Math/Test/Vector4Test.cpp index 04f93d1e5..e8f40f4ae 100644 --- a/src/Math/Test/Vector4Test.cpp +++ b/src/Math/Test/Vector4Test.cpp @@ -21,7 +21,6 @@ CORRADE_TEST_MAIN(Magnum::Math::Test::Vector4Test) -using namespace std; using namespace Corrade::Utility; namespace Magnum { namespace Math { namespace Test { @@ -68,7 +67,7 @@ void Vector4Test::twoComponent() { } void Vector4Test::debug() { - ostringstream o; + std::ostringstream o; Debug(&o) << Vector4(0.5f, 15.0f, 1.0f, 1.0f); CORRADE_COMPARE(o.str(), "Vector(0.5, 15, 1, 1)\n"); } @@ -77,10 +76,10 @@ void Vector4Test::configuration() { Configuration c; Vector4 vec(3.0f, 3.125f, 9.0f, 9.55f); - string value("3 3.125 9 9.55"); + std::string value("3 3.125 9 9.55"); c.setValue("vector", vec); - CORRADE_COMPARE(c.value("vector"), value); + CORRADE_COMPARE(c.value("vector"), value); CORRADE_COMPARE(c.value("vector"), vec); } diff --git a/src/Math/Test/VectorTest.cpp b/src/Math/Test/VectorTest.cpp index f9a86cc62..99486230f 100644 --- a/src/Math/Test/VectorTest.cpp +++ b/src/Math/Test/VectorTest.cpp @@ -22,7 +22,6 @@ CORRADE_TEST_MAIN(Magnum::Math::Test::VectorTest) -using namespace std; using namespace Corrade::Utility; namespace Magnum { namespace Math { namespace Test { @@ -110,18 +109,18 @@ void VectorTest::max() { } void VectorTest::angle() { - ostringstream o; + std::ostringstream o; Error::setOutput(&o); /* Both vectors must be normalized, otherwise NaN is returned */ - CORRADE_COMPARE(Vector3::angle(Vector3(2.0f, 3.0f, 4.0f).normalized(), {1.0f, -2.0f, 3.0f}), numeric_limits::quiet_NaN()); + CORRADE_COMPARE(Vector3::angle(Vector3(2.0f, 3.0f, 4.0f).normalized(), {1.0f, -2.0f, 3.0f}), std::numeric_limits::quiet_NaN()); CORRADE_COMPARE(o.str(), "Math::Vector::angle(): vectors must be normalized\n"); - CORRADE_COMPARE(Vector3::angle({2.0f, 3.0f, 4.0f}, Vector3(1.0f, -2.0f, 3.0f).normalized()), numeric_limits::quiet_NaN()); + CORRADE_COMPARE(Vector3::angle({2.0f, 3.0f, 4.0f}, Vector3(1.0f, -2.0f, 3.0f).normalized()), std::numeric_limits::quiet_NaN()); CORRADE_COMPARE(Vector3::angle(Vector3(2.0f, 3.0f, 4.0f).normalized(), Vector3(1.0f, -2.0f, 3.0f).normalized()), rad(1.162514f)); } void VectorTest::debug() { - ostringstream o; + std::ostringstream o; Debug(&o) << Vector4(0.5f, 15.0f, 1.0f, 1.0f); CORRADE_COMPARE(o.str(), "Vector(0.5, 15, 1, 1)\n"); @@ -134,10 +133,10 @@ void VectorTest::configuration() { Configuration c; Vector4 vec(3.0f, 3.125f, 9.0f, 9.55f); - string value("3 3.125 9 9.55"); + std::string value("3 3.125 9 9.55"); c.setValue("vector", vec); - CORRADE_COMPARE(c.value("vector"), value); + CORRADE_COMPARE(c.value("vector"), value); CORRADE_COMPARE(c.value("vector"), vec); } diff --git a/src/Mesh.cpp b/src/Mesh.cpp index 621642dd1..67260b7cf 100644 --- a/src/Mesh.cpp +++ b/src/Mesh.cpp @@ -23,8 +23,6 @@ #include "Implementation/MeshState.h" #include "Implementation/State.h" -using namespace std; - namespace Magnum { Mesh::CreateImplementation Mesh::createImplementation = &Mesh::createImplementationDefault; diff --git a/src/MeshTools/CompressIndices.cpp b/src/MeshTools/CompressIndices.cpp index e3e53b674..af2a53e93 100644 --- a/src/MeshTools/CompressIndices.cpp +++ b/src/MeshTools/CompressIndices.cpp @@ -22,19 +22,17 @@ #include "IndexedMesh.h" #include "SizeTraits.h" -using namespace std; - namespace Magnum { namespace MeshTools { #ifndef DOXYGEN_GENERATING_OUTPUT namespace Implementation { -std::tuple CompressIndices::operator()() const { +std::tuple CompressIndices::operator()() const { return SizeBasedCall(*std::max_element(indices.begin(), indices.end()))(indices); } void CompressIndices::operator()(IndexedMesh* mesh, Buffer* buffer, Buffer::Usage usage) const { - size_t indexCount; + std::size_t indexCount; Type indexType; char* data; std::tie(indexCount, indexType, data) = operator()(); @@ -47,10 +45,10 @@ void CompressIndices::operator()(IndexedMesh* mesh, Buffer* buffer, Buffer::Usag delete[] data; } -template std::tuple CompressIndices::Compressor::run(const std::vector& indices) { +template std::tuple CompressIndices::Compressor::run(const std::vector& indices) { /* Create smallest possible version of index buffer */ char* buffer = new char[indices.size()*sizeof(IndexType)]; - for(size_t i = 0; i != indices.size(); ++i) { + for(std::size_t i = 0; i != indices.size(); ++i) { IndexType index = indices[i]; memcpy(buffer+i*sizeof(IndexType), reinterpret_cast(&index), sizeof(IndexType)); } diff --git a/src/MeshTools/FlipNormals.cpp b/src/MeshTools/FlipNormals.cpp index f34304fa1..596dfb4a3 100644 --- a/src/MeshTools/FlipNormals.cpp +++ b/src/MeshTools/FlipNormals.cpp @@ -17,18 +17,16 @@ #include "Math/Vector3.h" -using namespace std; - namespace Magnum { namespace MeshTools { -void flipFaceWinding(vector& indices) { +void flipFaceWinding(std::vector& indices) { CORRADE_ASSERT(!(indices.size()%3), "MeshTools::flipNormals(): index count is not divisible by 3!", ); - for(size_t i = 0; i != indices.size(); i += 3) - swap(indices[i+1], indices[i+2]); + for(std::size_t i = 0; i != indices.size(); i += 3) + std::swap(indices[i+1], indices[i+2]); } -void flipNormals(vector& normals) { +void flipNormals(std::vector& normals) { for(Vector3& normal: normals) normal = -normal; } diff --git a/src/MeshTools/GenerateFlatNormals.cpp b/src/MeshTools/GenerateFlatNormals.cpp index 918d19d68..0ea2de883 100644 --- a/src/MeshTools/GenerateFlatNormals.cpp +++ b/src/MeshTools/GenerateFlatNormals.cpp @@ -18,19 +18,17 @@ #include "Math/Point3D.h" #include "MeshTools/Clean.h" -using namespace std; - namespace Magnum { namespace MeshTools { -tuple, vector> generateFlatNormals(const vector& indices, const vector& positions) { - CORRADE_ASSERT(!(indices.size()%3), "MeshTools::generateFlatNormals(): index count is not divisible by 3!", (tuple, vector>())); +std::tuple, std::vector> generateFlatNormals(const std::vector& indices, const std::vector& positions) { + CORRADE_ASSERT(!(indices.size()%3), "MeshTools::generateFlatNormals(): index count is not divisible by 3!", (std::tuple, std::vector>())); /* Create normal for every triangle (assuming counterclockwise winding) */ - vector normalIndices; + std::vector normalIndices; normalIndices.reserve(indices.size()); - vector normals; + std::vector normals; normals.reserve(indices.size()/3); - for(size_t i = 0; i != indices.size(); i += 3) { + for(std::size_t i = 0; i != indices.size(); i += 3) { Vector3 normal = Vector3::cross(positions[indices[i+2]].xyz()-positions[indices[i+1]].xyz(), positions[indices[i]].xyz()-positions[indices[i+1]].xyz()).normalized(); @@ -43,7 +41,7 @@ tuple, vector> generateFlatNormals(const vector positions{1, 2, 1, 4}; - vector indices{0, 1, 2, 1, 2, 3}; + std::vector positions{1, 2, 1, 4}; + std::vector indices{0, 1, 2, 1, 2, 3}; MeshTools::clean(indices, positions); /* Verify cleanup */ - CORRADE_VERIFY(positions == (vector{1, 2, 4})); - CORRADE_COMPARE(indices, (vector{0, 1, 0, 1, 0, 2})); + CORRADE_VERIFY(positions == (std::vector{1, 2, 4})); + CORRADE_COMPARE(indices, (std::vector{0, 1, 0, 1, 0, 2})); } }}} diff --git a/src/MeshTools/Test/CombineIndexedArraysTest.cpp b/src/MeshTools/Test/CombineIndexedArraysTest.cpp index 57211078b..b97447e68 100644 --- a/src/MeshTools/Test/CombineIndexedArraysTest.cpp +++ b/src/MeshTools/Test/CombineIndexedArraysTest.cpp @@ -21,8 +21,6 @@ CORRADE_TEST_MAIN(Magnum::MeshTools::Test::CombineIndexedArraysTest) -using namespace std; - namespace Magnum { namespace MeshTools { namespace Test { CombineIndexedArraysTest::CombineIndexedArraysTest() { @@ -31,31 +29,31 @@ CombineIndexedArraysTest::CombineIndexedArraysTest() { } void CombineIndexedArraysTest::wrongIndexCount() { - stringstream ss; + std::stringstream ss; Error::setOutput(&ss); - vector array; - vector result = MeshTools::combineIndexedArrays( - tuple&, vector&>(vector{0, 1, 0}, array), - tuple&, vector&>(vector{3, 4}, array)); + std::vector array; + std::vector result = MeshTools::combineIndexedArrays( + std::tuple&, std::vector&>(std::vector{0, 1, 0}, array), + std::tuple&, std::vector&>(std::vector{3, 4}, array)); CORRADE_COMPARE(result.size(), 0); CORRADE_COMPARE(ss.str(), "MeshTools::combineIndexedArrays(): index arrays don't have the same length, nothing done.\n"); } void CombineIndexedArraysTest::combine() { - vector array1{ 0, 1 }; - vector array2{ 0, 1, 2, 3, 4 }; - vector array3{ 0, 1, 2, 3, 4, 5, 6, 7 }; - - vector result = MeshTools::combineIndexedArrays( - tuple&, vector&>(vector{0, 1, 0}, array1), - tuple&, vector&>(vector{3, 4, 3}, array2), - tuple&, vector&>(vector{6, 7, 6}, array3)); - - CORRADE_COMPARE(result, (vector{0, 1, 0})); - CORRADE_COMPARE(array1, (vector{0, 1})); - CORRADE_COMPARE(array2, (vector{3, 4})); - CORRADE_COMPARE(array3, (vector{6, 7})); + std::vector array1{ 0, 1 }; + std::vector array2{ 0, 1, 2, 3, 4 }; + std::vector array3{ 0, 1, 2, 3, 4, 5, 6, 7 }; + + std::vector result = MeshTools::combineIndexedArrays( + std::tuple&, std::vector&>(std::vector{0, 1, 0}, array1), + std::tuple&, std::vector&>(std::vector{3, 4, 3}, array2), + std::tuple&, std::vector&>(std::vector{6, 7, 6}, array3)); + + CORRADE_COMPARE(result, (std::vector{0, 1, 0})); + CORRADE_COMPARE(array1, (std::vector{0, 1})); + CORRADE_COMPARE(array2, (std::vector{3, 4})); + CORRADE_COMPARE(array3, (std::vector{6, 7})); } }}} diff --git a/src/MeshTools/Test/CompressIndicesTest.cpp b/src/MeshTools/Test/CompressIndicesTest.cpp index f50b7ce49..7814e2872 100644 --- a/src/MeshTools/Test/CompressIndicesTest.cpp +++ b/src/MeshTools/Test/CompressIndicesTest.cpp @@ -21,7 +21,6 @@ CORRADE_TEST_MAIN(Magnum::MeshTools::Test::CompressIndicesTest) -using namespace std; using Corrade::Utility::Endianness; namespace Magnum { namespace MeshTools { namespace Test { @@ -33,38 +32,38 @@ CompressIndicesTest::CompressIndicesTest() { } void CompressIndicesTest::compressChar() { - size_t indexCount; + std::size_t indexCount; Type indexType; char* data; - tie(indexCount, indexType, data) = MeshTools::compressIndices( - vector{1, 2, 3, 0, 4}); + std::tie(indexCount, indexType, data) = MeshTools::compressIndices( + std::vector{1, 2, 3, 0, 4}); CORRADE_COMPARE(indexCount, 5); CORRADE_VERIFY(indexType == Type::UnsignedByte); - CORRADE_COMPARE(vector(data, data+indexCount*TypeInfo::sizeOf(indexType)), - (vector{ 0x01, 0x02, 0x03, 0x00, 0x04 })); + CORRADE_COMPARE(std::vector(data, data+indexCount*TypeInfo::sizeOf(indexType)), + (std::vector{ 0x01, 0x02, 0x03, 0x00, 0x04 })); delete[] data; } void CompressIndicesTest::compressShort() { - size_t indexCount; + std::size_t indexCount; Type indexType; char* data; - tie(indexCount, indexType, data) = MeshTools::compressIndices( - vector{1, 256, 0, 5}); + std::tie(indexCount, indexType, data) = MeshTools::compressIndices( + std::vector{1, 256, 0, 5}); CORRADE_COMPARE(indexCount, 4); CORRADE_VERIFY(indexType == Type::UnsignedShort); if(!Endianness::isBigEndian()) { - CORRADE_COMPARE(vector(data, data+indexCount*TypeInfo::sizeOf(indexType)), - (vector{ 0x01, 0x00, + CORRADE_COMPARE(std::vector(data, data+indexCount*TypeInfo::sizeOf(indexType)), + (std::vector{ 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x05, 0x00 })); } else { - CORRADE_COMPARE(vector(data, data+indexCount*TypeInfo::sizeOf(indexType)), - (vector{ 0x00, 0x01, + CORRADE_COMPARE(std::vector(data, data+indexCount*TypeInfo::sizeOf(indexType)), + (std::vector{ 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x05 })); @@ -74,23 +73,23 @@ void CompressIndicesTest::compressShort() { } void CompressIndicesTest::compressInt() { - size_t indexCount; + std::size_t indexCount; Type indexType; char* data; - tie(indexCount, indexType, data) = MeshTools::compressIndices( - vector{65536, 3, 2}); + std::tie(indexCount, indexType, data) = MeshTools::compressIndices( + std::vector{65536, 3, 2}); CORRADE_COMPARE(indexCount, 3); CORRADE_VERIFY(indexType == Type::UnsignedInt); if(!Endianness::isBigEndian()) { - CORRADE_COMPARE(vector(data, data+indexCount*TypeInfo::sizeOf(indexType)), - (vector{ 0x00, 0x00, 0x01, 0x00, + CORRADE_COMPARE(std::vector(data, data+indexCount*TypeInfo::sizeOf(indexType)), + (std::vector{ 0x00, 0x00, 0x01, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00 })); } else { - CORRADE_COMPARE(vector(data, data+indexCount*TypeInfo::sizeOf(indexType)), - (vector{ 0x00, 0x01, 0x00, 0x00, + CORRADE_COMPARE(std::vector(data, data+indexCount*TypeInfo::sizeOf(indexType)), + (std::vector{ 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02 })); } diff --git a/src/MeshTools/Test/FlipNormalsTest.cpp b/src/MeshTools/Test/FlipNormalsTest.cpp index b900f39d5..0a693b6de 100644 --- a/src/MeshTools/Test/FlipNormalsTest.cpp +++ b/src/MeshTools/Test/FlipNormalsTest.cpp @@ -22,8 +22,6 @@ CORRADE_TEST_MAIN(Magnum::MeshTools::Test::FlipNormalsTest) -using namespace std; - namespace Magnum { namespace MeshTools { namespace Test { FlipNormalsTest::FlipNormalsTest() { @@ -33,33 +31,33 @@ FlipNormalsTest::FlipNormalsTest() { } void FlipNormalsTest::wrongIndexCount() { - stringstream ss; + std::stringstream ss; Error::setOutput(&ss); - vector indices{0, 1}; + std::vector indices{0, 1}; MeshTools::flipFaceWinding(indices); CORRADE_COMPARE(ss.str(), "MeshTools::flipNormals(): index count is not divisible by 3!\n"); } void FlipNormalsTest::flipFaceWinding() { - vector indices{0, 1, 2, - 3, 4, 5}; + std::vector indices{0, 1, 2, + 3, 4, 5}; MeshTools::flipFaceWinding(indices); - CORRADE_COMPARE(indices, (vector{0, 2, 1, - 3, 5, 4})); + CORRADE_COMPARE(indices, (std::vector{0, 2, 1, + 3, 5, 4})); } void FlipNormalsTest::flipNormals() { - vector normals{Vector3::xAxis(), - Vector3::yAxis(), - Vector3::zAxis()}; + std::vector normals{Vector3::xAxis(), + Vector3::yAxis(), + Vector3::zAxis()}; MeshTools::flipNormals(normals); - CORRADE_COMPARE(normals, (vector{-Vector3::xAxis(), - -Vector3::yAxis(), - -Vector3::zAxis()})); + CORRADE_COMPARE(normals, (std::vector{-Vector3::xAxis(), + -Vector3::yAxis(), + -Vector3::zAxis()})); } }}} diff --git a/src/MeshTools/Test/GenerateFlatNormalsTest.cpp b/src/MeshTools/Test/GenerateFlatNormalsTest.cpp index 8cd88d313..5f91f05d9 100644 --- a/src/MeshTools/Test/GenerateFlatNormalsTest.cpp +++ b/src/MeshTools/Test/GenerateFlatNormalsTest.cpp @@ -22,8 +22,6 @@ CORRADE_TEST_MAIN(Magnum::MeshTools::Test::GenerateFlatNormalsTest) -using namespace std; - namespace Magnum { namespace MeshTools { namespace Test { GenerateFlatNormalsTest::GenerateFlatNormalsTest() { @@ -32,11 +30,11 @@ GenerateFlatNormalsTest::GenerateFlatNormalsTest() { } void GenerateFlatNormalsTest::wrongIndexCount() { - stringstream ss; + std::stringstream ss; Error::setOutput(&ss); - vector indices; - vector normals; - tie(indices, normals) = MeshTools::generateFlatNormals({ + std::vector indices; + std::vector normals; + std::tie(indices, normals) = MeshTools::generateFlatNormals({ 0, 1 }, {}); @@ -47,9 +45,9 @@ void GenerateFlatNormalsTest::wrongIndexCount() { void GenerateFlatNormalsTest::generate() { /* Two vertices connected by one edge, each winded in another direction */ - vector indices; - vector normals; - tie(indices, normals) = MeshTools::generateFlatNormals({ + std::vector indices; + std::vector normals; + std::tie(indices, normals) = MeshTools::generateFlatNormals({ 0, 1, 2, 1, 2, 3 }, { @@ -59,11 +57,11 @@ void GenerateFlatNormalsTest::generate() { {1.0f, 0.0f, 0.0f} }); - CORRADE_COMPARE(indices, (vector{ + CORRADE_COMPARE(indices, (std::vector{ 0, 0, 0, 1, 1, 1 })); - CORRADE_COMPARE(normals, (vector{ + CORRADE_COMPARE(normals, (std::vector{ Vector3::zAxis(), -Vector3::zAxis() })); diff --git a/src/MeshTools/Test/InterleaveTest.cpp b/src/MeshTools/Test/InterleaveTest.cpp index b734ea39a..e3416b166 100644 --- a/src/MeshTools/Test/InterleaveTest.cpp +++ b/src/MeshTools/Test/InterleaveTest.cpp @@ -23,7 +23,6 @@ CORRADE_TEST_MAIN(Magnum::MeshTools::Test::InterleaveTest) -using namespace std; using Corrade::Utility::Endianness; namespace Magnum { namespace MeshTools { namespace Test { @@ -35,42 +34,42 @@ InterleaveTest::InterleaveTest() { } void InterleaveTest::attributeCount() { - stringstream ss; + std::stringstream ss; Error::setOutput(&ss); - CORRADE_COMPARE((Implementation::Interleave::attributeCount(vector{0, 1, 2}, - vector{0, 1, 2, 3, 4, 5})), size_t(0)); + CORRADE_COMPARE((Implementation::Interleave::attributeCount(std::vector{0, 1, 2}, + std::vector{0, 1, 2, 3, 4, 5})), std::size_t(0)); CORRADE_COMPARE(ss.str(), "MeshTools::interleave(): attribute arrays don't have the same length, nothing done.\n"); - CORRADE_COMPARE((Implementation::Interleave::attributeCount(vector{0, 1, 2}, - vector{3, 4, 5})), size_t(3)); + CORRADE_COMPARE((Implementation::Interleave::attributeCount(std::vector{0, 1, 2}, + std::vector{3, 4, 5})), std::size_t(3)); } void InterleaveTest::stride() { - CORRADE_COMPARE(Implementation::Interleave::stride(vector()), size_t(1)); - CORRADE_COMPARE(Implementation::Interleave::stride(vector()), size_t(4)); - CORRADE_COMPARE((Implementation::Interleave::stride(vector(), vector())), size_t(5)); + CORRADE_COMPARE(Implementation::Interleave::stride(std::vector()), std::size_t(1)); + CORRADE_COMPARE(Implementation::Interleave::stride(std::vector()), std::size_t(4)); + CORRADE_COMPARE((Implementation::Interleave::stride(std::vector(), std::vector())), std::size_t(5)); } void InterleaveTest::write() { - size_t attributeCount; - size_t stride; + std::size_t attributeCount; + std::size_t stride; char* data; - tie(attributeCount, stride, data) = MeshTools::interleave( - vector{0, 1, 2}, - vector{3, 4, 5}, - vector{6, 7, 8}); - - CORRADE_COMPARE(attributeCount, size_t(3)); - CORRADE_COMPARE(stride, size_t(7)); - size_t size = attributeCount*stride; + std::tie(attributeCount, stride, data) = MeshTools::interleave( + std::vector{0, 1, 2}, + std::vector{3, 4, 5}, + std::vector{6, 7, 8}); + + CORRADE_COMPARE(attributeCount, std::size_t(3)); + CORRADE_COMPARE(stride, std::size_t(7)); + std::size_t size = attributeCount*stride; if(!Endianness::isBigEndian()) { - CORRADE_COMPARE(vector(data, data+size), (vector{ + CORRADE_COMPARE(std::vector(data, data+size), (std::vector{ 0x00, 0x03, 0x00, 0x00, 0x00, 0x06, 0x00, 0x01, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x02, 0x05, 0x00, 0x00, 0x00, 0x08, 0x00 })); } else { - CORRADE_COMPARE(vector(data, data+size), (vector{ + CORRADE_COMPARE(std::vector(data, data+size), (std::vector{ 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x06, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x08 diff --git a/src/MeshTools/Test/SubdivideTest.cpp b/src/MeshTools/Test/SubdivideTest.cpp index 965c3ad36..33401d54d 100644 --- a/src/MeshTools/Test/SubdivideTest.cpp +++ b/src/MeshTools/Test/SubdivideTest.cpp @@ -22,8 +22,6 @@ CORRADE_TEST_MAIN(Magnum::MeshTools::Test::SubdivideTest) -using namespace std; - namespace Magnum { namespace MeshTools { namespace Test { SubdivideTest::SubdivideTest() { @@ -32,24 +30,24 @@ SubdivideTest::SubdivideTest() { } void SubdivideTest::wrongIndexCount() { - stringstream ss; + std::stringstream ss; Error::setOutput(&ss); - vector positions; - vector indices{0, 1}; + std::vector positions; + std::vector indices{0, 1}; MeshTools::subdivide(indices, positions, interpolator); CORRADE_COMPARE(ss.str(), "MeshTools::subdivide(): index count is not divisible by 3!\n"); } void SubdivideTest::subdivide() { - vector positions{0, 2, 6, 8}; - vector indices{0, 1, 2, 1, 2, 3}; + std::vector positions{0, 2, 6, 8}; + std::vector indices{0, 1, 2, 1, 2, 3}; MeshTools::subdivide(indices, positions, interpolator); CORRADE_COMPARE(indices.size(), 24); - CORRADE_VERIFY(positions == (vector{0, 2, 6, 8, 1, 4, 3, 4, 7, 5})); - CORRADE_COMPARE(indices, (vector{4, 5, 6, 7, 8, 9, 0, 4, 6, 4, 1, 5, 6, 5, 2, 1, 7, 9, 7, 2, 8, 9, 8, 3})); + CORRADE_VERIFY(positions == (std::vector{0, 2, 6, 8, 1, 4, 3, 4, 7, 5})); + CORRADE_COMPARE(indices, (std::vector{4, 5, 6, 7, 8, 9, 0, 4, 6, 4, 1, 5, 6, 5, 2, 1, 7, 9, 7, 2, 8, 9, 8, 3})); MeshTools::clean(indices, positions); diff --git a/src/MeshTools/Test/TipsifyTest.cpp b/src/MeshTools/Test/TipsifyTest.cpp index fc0a7c243..6138075b7 100644 --- a/src/MeshTools/Test/TipsifyTest.cpp +++ b/src/MeshTools/Test/TipsifyTest.cpp @@ -19,8 +19,6 @@ CORRADE_TEST_MAIN(Magnum::MeshTools::Test::TipsifyTest) -using namespace std; - namespace Magnum { namespace MeshTools { namespace Test { /* @@ -67,10 +65,10 @@ TipsifyTest::TipsifyTest(): indices{ } void TipsifyTest::buildAdjacency() { - vector liveTriangleCount, neighborOffset, neighbors; + std::vector liveTriangleCount, neighborOffset, neighbors; Implementation::Tipsify(indices, vertexCount).buildAdjacency(liveTriangleCount, neighborOffset, neighbors); - CORRADE_COMPARE(liveTriangleCount, (vector{ + CORRADE_COMPARE(liveTriangleCount, (std::vector{ 1, 3, 3, 2, 4, 6, 6, 2, 2, 6, 6, 4, @@ -78,7 +76,7 @@ void TipsifyTest::buildAdjacency() { 1, 1, 1 })); - CORRADE_COMPARE(neighborOffset, (vector{ + CORRADE_COMPARE(neighborOffset, (std::vector{ 0, 1, 4, 7, 9, 13, 19, 25, 27, 29, 35, 41, @@ -86,7 +84,7 @@ void TipsifyTest::buildAdjacency() { 54, 55, 56, 57 })); - CORRADE_COMPARE(neighbors, (vector{ + CORRADE_COMPARE(neighbors, (std::vector{ 0, 0, 7, 11, 2, 7, 13, @@ -114,7 +112,7 @@ void TipsifyTest::buildAdjacency() { void TipsifyTest::tipsify() { MeshTools::tipsify(indices, vertexCount, 3); - CORRADE_COMPARE(indices, (vector{ + CORRADE_COMPARE(indices, (std::vector{ 4, 1, 0, 9, 5, 4, 1, 4, 5, diff --git a/src/MeshTools/Tipsify.cpp b/src/MeshTools/Tipsify.cpp index 7b5b6c00b..803304daf 100644 --- a/src/MeshTools/Tipsify.cpp +++ b/src/MeshTools/Tipsify.cpp @@ -17,44 +17,42 @@ #include -using namespace std; - #ifndef DOXYGEN_GENERATING_OUTPUT namespace Magnum { namespace MeshTools { namespace Implementation { -void Tipsify::operator()(size_t cacheSize) { +void Tipsify::operator()(std::size_t cacheSize) { /* Neighboring triangles for each vertex, per-vertex live triangle count */ - std::vector liveTriangleCount, neighborPosition, neighbors; + std::vector liveTriangleCount, neighborPosition, neighbors; buildAdjacency(liveTriangleCount, neighborPosition, neighbors); /* Global time, per-vertex caching timestamps, per-triangle emmited flag */ - uint32_t time = cacheSize+1; - std::vector timestamp(vertexCount); + std::uint32_t time = cacheSize+1; + std::vector timestamp(vertexCount); std::vector emitted(indices.size()/3); /* Dead-end vertex stack */ - std::stack deadEndStack; + std::stack deadEndStack; /* Output index buffer */ - std::vector outputIndices; + std::vector outputIndices; outputIndices.reserve(indices.size()); /* Starting vertex for fanning, cursor */ - uint32_t fanningVertex = 0; - uint32_t i = 0; + std::uint32_t fanningVertex = 0; + std::uint32_t i = 0; while(fanningVertex != 0xFFFFFFFFu) { /* Array with candidates for next fanning vertex (in 1-ring around fanning vertex) */ - std::vector candidates; + std::vector candidates; /* For all neighbors of fanning vertex */ - for(uint32_t ti = neighborPosition[fanningVertex], t = neighbors[ti]; ti != neighborPosition[fanningVertex+1]; t = neighbors[++ti]) { + for(std::uint32_t ti = neighborPosition[fanningVertex], t = neighbors[ti]; ti != neighborPosition[fanningVertex+1]; t = neighbors[++ti]) { /* Continue if already emitted */ if(emitted[t]) continue; emitted[t] = true; /* Write all vertices of the triangle to output buffer */ - for(uint32_t vi = 0, v = indices[t*3]; vi != 3; v = indices[++vi+t*3]) { + for(std::uint32_t vi = 0, v = indices[t*3]; vi != 3; v = indices[++vi+t*3]) { outputIndices.push_back(v); /* Add to dead end stack and candidates array */ @@ -75,15 +73,15 @@ void Tipsify::operator()(size_t cacheSize) { fanningVertex = 0xFFFFFFFFu; /* Go through candidates in 1-ring around fanning vertex */ - int32_t candidatePriority = -1; - for(uint32_t v: candidates) { + std::int32_t candidatePriority = -1; + for(std::uint32_t v: candidates) { /* Skip if it doesn't have any live triangles */ if(!liveTriangleCount[v]) continue; /* Get most fresh candidate which will still be in cache even after fanning. Every fanned triangle will generate at most two cache misses, thus 2*liveTriangleCount */ - int32_t priority = 0; + std::int32_t priority = 0; if(time-timestamp[v]+2*liveTriangleCount[v] <= cacheSize) priority = time-timestamp[v]; if(priority > candidatePriority) { @@ -119,12 +117,12 @@ void Tipsify::operator()(size_t cacheSize) { std::swap(indices, outputIndices); } -void Tipsify::buildAdjacency(std::vector& liveTriangleCount, std::vector& neighborOffset, std::vector& neighbors) const { +void Tipsify::buildAdjacency(std::vector& liveTriangleCount, std::vector& neighborOffset, std::vector& neighbors) const { /* How many times is each vertex referenced == count of neighboring triangles for each vertex */ liveTriangleCount.clear(); liveTriangleCount.resize(vertexCount); - for(size_t i = 0; i != indices.size(); ++i) + for(std::size_t i = 0; i != indices.size(); ++i) ++liveTriangleCount[indices[i]]; /* Building offset array from counts. Neighbors for i-th vertex will at @@ -134,8 +132,8 @@ void Tipsify::buildAdjacency(std::vector& liveTriangleCount, std::vect neighborOffset.clear(); neighborOffset.reserve(vertexCount+1); neighborOffset.push_back(0); - uint32_t sum = 0; - for(size_t i = 0; i != vertexCount; ++i) { + std::uint32_t sum = 0; + for(std::size_t i = 0; i != vertexCount; ++i) { neighborOffset.push_back(sum); sum += liveTriangleCount[i]; } @@ -144,7 +142,7 @@ void Tipsify::buildAdjacency(std::vector& liveTriangleCount, std::vect positioning */ neighbors.clear(); neighbors.resize(sum); - for(size_t i = 0; i != indices.size(); ++i) + for(std::size_t i = 0; i != indices.size(); ++i) neighbors[neighborOffset[indices[i]+1]++] = i/3; } diff --git a/src/Physics/ObjectShape.cpp b/src/Physics/ObjectShape.cpp index 766a475a9..41469f188 100644 --- a/src/Physics/ObjectShape.cpp +++ b/src/Physics/ObjectShape.cpp @@ -20,23 +20,21 @@ #include "AbstractShape.h" #include "ObjectShapeGroup.h" -using namespace std; - namespace Magnum { namespace Physics { -template ObjectShape::ObjectShape(SceneGraph::AbstractObject* object, ObjectShapeGroup* group): SceneGraph::AbstractGroupedFeature>(object, group), _shape(nullptr) { +template ObjectShape::ObjectShape(SceneGraph::AbstractObject* object, ObjectShapeGroup* group): SceneGraph::AbstractGroupedFeature>(object, group), _shape(nullptr) { this->setCachedTransformations(SceneGraph::AbstractFeature::CachedTransformation::Absolute); } -template ObjectShape::~ObjectShape() { +template ObjectShape::~ObjectShape() { delete _shape; } -template void ObjectShape::markDirty() { +template void ObjectShape::markDirty() { group()->setDirty(); } -template void ObjectShape::clean(const typename DimensionTraits::MatrixType& absoluteTransformationMatrix) { +template void ObjectShape::clean(const typename DimensionTraits::MatrixType& absoluteTransformationMatrix) { if(_shape) _shape->applyTransformationMatrix(absoluteTransformationMatrix); } diff --git a/src/Physics/Plane.cpp b/src/Physics/Plane.cpp index 4798b991c..77af71cc9 100644 --- a/src/Physics/Plane.cpp +++ b/src/Physics/Plane.cpp @@ -22,7 +22,6 @@ #include "Math/Geometry/Intersection.h" #include "LineSegment.h" -using namespace std; using namespace Magnum::Math::Geometry; namespace Magnum { namespace Physics { @@ -43,7 +42,7 @@ bool Plane::collides(const AbstractShape<3>* other) const { bool Plane::operator%(const Line3D& other) const { float t = Intersection::planeLine(transformedPosition(), transformedNormal(), other.transformedA(), other.transformedB()); - return t != t || (t != numeric_limits::infinity() && t != -numeric_limits::infinity()); + return t != t || (t != std::numeric_limits::infinity() && t != -std::numeric_limits::infinity()); } bool Plane::operator%(const LineSegment3D& other) const { diff --git a/src/Physics/Test/ShapeGroupTest.cpp b/src/Physics/Test/ShapeGroupTest.cpp index 249dc8dd7..eb5d0f989 100644 --- a/src/Physics/Test/ShapeGroupTest.cpp +++ b/src/Physics/Test/ShapeGroupTest.cpp @@ -20,8 +20,6 @@ #include "Physics/LineSegment.h" #include "Physics/ShapeGroup.h" -using namespace std; - CORRADE_TEST_MAIN(Magnum::Physics::Test::ShapeGroupTest) namespace Magnum { namespace Physics { namespace Test { @@ -50,7 +48,7 @@ void ShapeGroupTest::reference() { Physics::Point3D point({1.0f, 2.0f, 3.0f}); Physics::LineSegment3D segment({2.0f, 1.0f, 30.0f}, {1.0f, -20.0f, 3.0f}); - ShapeGroup3D group = !(ref(point) || ref(segment)); + ShapeGroup3D group = !(std::ref(point) || std::ref(segment)); group.applyTransformationMatrix(Matrix4::translation(Vector3(1.0f))); diff --git a/src/Platform/AbstractXApplication.cpp b/src/Platform/AbstractXApplication.cpp index aa71c876d..db8b58c7b 100644 --- a/src/Platform/AbstractXApplication.cpp +++ b/src/Platform/AbstractXApplication.cpp @@ -25,11 +25,9 @@ /* Mask for X events */ #define INPUT_MASK KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask|PointerMotionMask|StructureNotifyMask -using namespace std; - namespace Magnum { namespace Platform { -AbstractXApplication::AbstractXApplication(AbstractContextHandler* contextHandler, int&, char**, const string& title, const Vector2i& size): contextHandler(contextHandler), viewportSize(size), flags(Flag::Redraw) { +AbstractXApplication::AbstractXApplication(AbstractContextHandler* contextHandler, int&, char**, const std::string& title, const Vector2i& size): contextHandler(contextHandler), viewportSize(size), flags(Flag::Redraw) { /* Get default X display */ display = XOpenDisplay(0); diff --git a/src/Platform/EglContextHandler.cpp b/src/Platform/EglContextHandler.cpp index 6f0c9884d..92cae17b6 100644 --- a/src/Platform/EglContextHandler.cpp +++ b/src/Platform/EglContextHandler.cpp @@ -32,7 +32,7 @@ VisualId EglContextHandler::getVisualId(EGLNativeDisplayType nativeDisplay) { display = eglGetDisplay(nativeDisplay); if(!eglInitialize(display, nullptr, nullptr)) { Error() << "Cannot initialize EGL:" << errorString(eglGetError()); - exit(1); + std::exit(1); } #ifndef MAGNUM_TARGET_GLES @@ -42,7 +42,7 @@ VisualId EglContextHandler::getVisualId(EGLNativeDisplayType nativeDisplay) { #endif if(!eglBindAPI(api)) { Error() << "Cannot bind EGL API:" << errorString(eglGetError()); - exit(1); + std::exit(1); } /* Choose EGL config */ @@ -61,19 +61,19 @@ VisualId EglContextHandler::getVisualId(EGLNativeDisplayType nativeDisplay) { EGLint configCount; if(!eglChooseConfig(display, attribs, &config, 1, &configCount)) { Error() << "Cannot get EGL visual config:" << errorString(eglGetError()); - exit(1); + std::exit(1); } if(!configCount) { Error() << "No matching EGL visual config available"; - exit(1); + std::exit(1); } /* Get visual ID */ EGLint visualId; if(!eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &visualId)) { Error() << "Cannot get native visual ID:" << errorString(eglGetError()); - exit(1); + std::exit(1); } return visualId; @@ -88,11 +88,11 @@ void EglContextHandler::createContext(EGLNativeWindowType window) { }; if(!eglCreateContext(display, config, EGL_NO_CONTEXT, contextAttributes)) { Error() << "Cannot create EGL context:" << errorString(eglGetError()); - exit(1); + std::exit(1); } if(!(surface = eglCreateWindowSurface(display, config, window, NULL))) { Error() << "Cannot create window surface:" << errorString(eglGetError()); - exit(1); + std::exit(1); } /** @bug Fixme: On desktop OpenGL and Mesa EGL implementation OpenGL version is 1.0, which is wrong */ diff --git a/src/Platform/ExtensionWrangler.cpp b/src/Platform/ExtensionWrangler.cpp index 1216075a8..3c58b7da1 100644 --- a/src/Platform/ExtensionWrangler.cpp +++ b/src/Platform/ExtensionWrangler.cpp @@ -32,7 +32,7 @@ void ExtensionWrangler::initialize(ExperimentalFeatures experimentalFeatures) { GLenum err = glewInit(); if(err != GLEW_OK) { Error() << "ExtensionWrangler: cannot initialize GLEW:" << glewGetErrorString(err); - exit(1); + std::exit(1); } #else static_cast(experimentalFeatures); /* Shut up about unused parameter */ diff --git a/src/Platform/GlxContextHandler.cpp b/src/Platform/GlxContextHandler.cpp index cc6ab5698..f7915e98e 100644 --- a/src/Platform/GlxContextHandler.cpp +++ b/src/Platform/GlxContextHandler.cpp @@ -32,7 +32,7 @@ VisualID GlxContextHandler::getVisualId(Display* nativeDisplay) { glXQueryVersion(nativeDisplay, &major, &minor); if(major == 1 && minor < 4) { Error() << "GlxContextHandler: GLX version 1.4 or greater is required."; - exit(1); + std::exit(1); } /* Choose config */ @@ -50,7 +50,7 @@ VisualID GlxContextHandler::getVisualId(Display* nativeDisplay) { configs = glXChooseFBConfig(nativeDisplay, DefaultScreen(nativeDisplay), attributes, &configCount); if(!configCount) { Error() << "GlxContextHandler: no supported framebuffer configuration found."; - exit(1); + std::exit(1); } /* Get visual ID */ @@ -83,7 +83,7 @@ void GlxContextHandler::createContext(Window nativeWindow) { XFree(configs); if(!context) { Error() << "GlxContextHandler: cannot create context."; - exit(1); + std::exit(1); } } diff --git a/src/Platform/NaClApplication.cpp b/src/Platform/NaClApplication.cpp index 6bcf4203d..20da70355 100644 --- a/src/Platform/NaClApplication.cpp +++ b/src/Platform/NaClApplication.cpp @@ -24,7 +24,7 @@ namespace Magnum { namespace Platform { NaClApplication::NaClApplication(PP_Instance instance, const Vector2i& size): Instance(instance), Graphics3DClient(this), MouseLock(this), viewportSize(size) { - int32_t attributes[] = { + std::int32_t attributes[] = { PP_GRAPHICS3DATTRIB_ALPHA_SIZE, 8, PP_GRAPHICS3DATTRIB_DEPTH_SIZE, 24, PP_GRAPHICS3DATTRIB_STENCIL_SIZE, 8, @@ -38,11 +38,11 @@ NaClApplication::NaClApplication(PP_Instance instance, const Vector2i& size): In graphics = new pp::Graphics3D(this, attributes); if(graphics->is_null()) { Error() << "Platform::NaClApplication::NaClApplication(): cannot create graphics"; - exit(1); + std::exit(1); } if(!BindGraphics(*graphics)) { Error() << "Platform::NaClApplication::NaClApplication(): cannot bind graphics"; - exit(1); + std::exit(1); } fullscreen = new pp::Fullscreen(this); @@ -195,7 +195,7 @@ void NaClApplication::setMouseLocked(bool enabled) { else UnlockMouse(); } -void NaClApplication::mouseLockCallback(void* applicationInstance, int32_t) { +void NaClApplication::mouseLockCallback(void* applicationInstance, std::int32_t) { NaClApplication* instance = static_cast(applicationInstance); instance->flags |= Flag::MouseLocked; } diff --git a/src/Platform/Sdl2Application.cpp b/src/Platform/Sdl2Application.cpp index 49e6980e8..f8a0a0a8f 100644 --- a/src/Platform/Sdl2Application.cpp +++ b/src/Platform/Sdl2Application.cpp @@ -43,7 +43,7 @@ Sdl2Application::InputEvent::Modifiers fixedModifiers(Uint16 mod) { Sdl2Application::Sdl2Application(int, char**, const std::string& name, const Vector2i& size): _redraw(true) { if(SDL_Init(SDL_INIT_VIDEO) < 0) { Error() << "Cannot initialize SDL."; - exit(1); + std::exit(1); } /* Enable double buffering and 24bt depth buffer */ @@ -54,7 +54,7 @@ Sdl2Application::Sdl2Application(int, char**, const std::string& name, const Vec size.x(), size.y(), SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN); if(!window) { Error() << "Cannot create window."; - exit(2); + std::exit(2); } context = SDL_GL_CreateContext(window); diff --git a/src/Primitives/Capsule.cpp b/src/Primitives/Capsule.cpp index c7d6568c7..3f1fcca20 100644 --- a/src/Primitives/Capsule.cpp +++ b/src/Primitives/Capsule.cpp @@ -18,11 +18,9 @@ #include "Math/Constants.h" #include "Math/Point3D.h" -using namespace std; - namespace Magnum { namespace Primitives { -Capsule::Capsule(std::uint32_t hemisphereRings, std::uint32_t cylinderRings, std::uint32_t segments, GLfloat length, TextureCoords textureCoords): MeshData3D("", Mesh::Primitive::Triangles, new vector, {new vector()}, {new vector()}, textureCoords == TextureCoords::Generate ? vector*>{new vector()} : vector*>()), segments(segments), textureCoords(textureCoords) { +Capsule::Capsule(std::uint32_t hemisphereRings, std::uint32_t cylinderRings, std::uint32_t segments, GLfloat length, TextureCoords textureCoords): MeshData3D("", Mesh::Primitive::Triangles, new std::vector, {new std::vector()}, {new std::vector()}, textureCoords == TextureCoords::Generate ? std::vector*>{new std::vector()} : std::vector*>()), segments(segments), textureCoords(textureCoords) { CORRADE_ASSERT(hemisphereRings >= 1 && cylinderRings >= 1 && segments >= 3, "Capsule must have at least one hemisphere ring, one cylinder ring and three segments", ); GLfloat height = 2.0f+length; @@ -50,7 +48,7 @@ Capsule::Capsule(std::uint32_t hemisphereRings, std::uint32_t cylinderRings, std topFaceRing(); } -Capsule::Capsule(uint32_t segments, TextureCoords textureCoords): MeshData3D("", Mesh::Primitive::Triangles, new std::vector, {new std::vector()}, {new std::vector()}, textureCoords == TextureCoords::Generate ? std::vector*>{new std::vector()} : std::vector*>()), segments(segments), textureCoords(textureCoords) {} +Capsule::Capsule(std::uint32_t segments, TextureCoords textureCoords): MeshData3D("", Mesh::Primitive::Triangles, new std::vector, {new std::vector()}, {new std::vector()}, textureCoords == TextureCoords::Generate ? std::vector*>{new std::vector()} : std::vector*>()), segments(segments), textureCoords(textureCoords) {} void Capsule::capVertex(GLfloat y, GLfloat normalY, GLfloat textureCoordsV) { positions(0)->push_back({0.0f, y, 0.0f}); @@ -60,18 +58,18 @@ void Capsule::capVertex(GLfloat y, GLfloat normalY, GLfloat textureCoordsV) { textureCoords2D(0)->push_back({0.5, textureCoordsV}); } -void Capsule::hemisphereVertexRings(uint32_t count, GLfloat centerY, GLfloat startRingAngle, GLfloat ringAngleIncrement, GLfloat startTextureCoordsV, GLfloat textureCoordsVIncrement) { +void Capsule::hemisphereVertexRings(std::uint32_t count, GLfloat centerY, GLfloat startRingAngle, GLfloat ringAngleIncrement, GLfloat startTextureCoordsV, GLfloat textureCoordsVIncrement) { GLfloat segmentAngleIncrement = 2*Constants::pi()/segments; GLfloat x, y, z; - for(uint32_t i = 0; i != count; ++i) { + for(std::uint32_t i = 0; i != count; ++i) { GLfloat ringAngle = startRingAngle + i*ringAngleIncrement; - x = z = cos(ringAngle); - y = sin(ringAngle); + x = z = std::cos(ringAngle); + y = std::sin(ringAngle); - for(uint32_t j = 0; j != segments; ++j) { + for(std::uint32_t j = 0; j != segments; ++j) { GLfloat segmentAngle = j*segmentAngleIncrement; - positions(0)->push_back({x*sin(segmentAngle), centerY+y, z*cos(segmentAngle)}); - normals(0)->push_back({x*sin(segmentAngle), y, z*cos(segmentAngle)}); + positions(0)->push_back({x*std::sin(segmentAngle), centerY+y, z*std::cos(segmentAngle)}); + normals(0)->push_back({x*std::sin(segmentAngle), y, z*std::cos(segmentAngle)}); if(textureCoords == TextureCoords::Generate) textureCoords2D(0)->push_back({j*1.0f/segments, startTextureCoordsV + i*textureCoordsVIncrement}); @@ -86,13 +84,13 @@ void Capsule::hemisphereVertexRings(uint32_t count, GLfloat centerY, GLfloat sta } } -void Capsule::cylinderVertexRings(uint32_t count, GLfloat startY, GLfloat yIncrement, GLfloat startTextureCoordsV, GLfloat textureCoordsVIncrement) { +void Capsule::cylinderVertexRings(std::uint32_t count, GLfloat startY, GLfloat yIncrement, GLfloat startTextureCoordsV, GLfloat textureCoordsVIncrement) { GLfloat segmentAngleIncrement = 2*Constants::pi()/segments; - for(uint32_t i = 0; i != count; ++i) { - for(uint32_t j = 0; j != segments; ++j) { + for(std::uint32_t i = 0; i != count; ++i) { + for(std::uint32_t j = 0; j != segments; ++j) { GLfloat segmentAngle = j*segmentAngleIncrement; - positions(0)->push_back({sin(segmentAngle), startY, cos(segmentAngle)}); - normals(0)->push_back({sin(segmentAngle), 0.0f, cos(segmentAngle)}); + positions(0)->push_back({std::sin(segmentAngle), startY, std::cos(segmentAngle)}); + normals(0)->push_back({std::sin(segmentAngle), 0.0f, std::cos(segmentAngle)}); if(textureCoords == TextureCoords::Generate) textureCoords2D(0)->push_back({j*1.0f/segments, startTextureCoordsV + i*textureCoordsVIncrement}); @@ -110,7 +108,7 @@ void Capsule::cylinderVertexRings(uint32_t count, GLfloat startY, GLfloat yIncre } void Capsule::bottomFaceRing() { - for(uint32_t j = 0; j != segments; ++j) { + for(std::uint32_t j = 0; j != segments; ++j) { /* Bottom vertex */ indices()->push_back(0); @@ -123,16 +121,16 @@ void Capsule::bottomFaceRing() { } } -void Capsule::faceRings(uint32_t count, uint32_t offset) { - uint32_t vertexSegments = segments + (textureCoords == TextureCoords::Generate ? 1 : 0); +void Capsule::faceRings(std::uint32_t count, std::uint32_t offset) { + std::uint32_t vertexSegments = segments + (textureCoords == TextureCoords::Generate ? 1 : 0); - for(uint32_t i = 0; i != count; ++i) { - for(uint32_t j = 0; j != segments; ++j) { - uint32_t bottomLeft = i*vertexSegments+j+offset; - uint32_t bottomRight = ((j != segments-1 || textureCoords == TextureCoords::Generate) ? + for(std::uint32_t i = 0; i != count; ++i) { + for(std::uint32_t j = 0; j != segments; ++j) { + std::uint32_t bottomLeft = i*vertexSegments+j+offset; + std::uint32_t bottomRight = ((j != segments-1 || textureCoords == TextureCoords::Generate) ? i*vertexSegments+j+1+offset : i*segments+offset); - uint32_t topLeft = bottomLeft+vertexSegments; - uint32_t topRight = bottomRight+vertexSegments; + std::uint32_t topLeft = bottomLeft+vertexSegments; + std::uint32_t topRight = bottomRight+vertexSegments; indices()->push_back(bottomLeft); indices()->push_back(bottomRight); @@ -145,9 +143,9 @@ void Capsule::faceRings(uint32_t count, uint32_t offset) { } void Capsule::topFaceRing() { - uint32_t vertexSegments = segments + (textureCoords == TextureCoords::Generate ? 1 : 0); + std::uint32_t vertexSegments = segments + (textureCoords == TextureCoords::Generate ? 1 : 0); - for(uint32_t j = 0; j != segments; ++j) { + for(std::uint32_t j = 0; j != segments; ++j) { /* Bottom left vertex */ indices()->push_back(normals(0)->size()-vertexSegments+j-1); diff --git a/src/Primitives/Cube.cpp b/src/Primitives/Cube.cpp index 12d92139f..f3fd4f44e 100644 --- a/src/Primitives/Cube.cpp +++ b/src/Primitives/Cube.cpp @@ -17,11 +17,9 @@ #include "Math/Point3D.h" -using namespace std; - namespace Magnum { namespace Primitives { -Cube::Cube(): MeshData3D("", Mesh::Primitive::Triangles, nullptr, {new vector{ +Cube::Cube(): MeshData3D("", Mesh::Primitive::Triangles, nullptr, {new std::vector{ {-1.0f, -1.0f, 1.0f}, { 1.0f, -1.0f, 1.0f}, { 1.0f, 1.0f, 1.0f}, /* +Z */ @@ -63,7 +61,7 @@ Cube::Cube(): MeshData3D("", Mesh::Primitive::Triangles, nullptr, {new vector{ +}}, {new std::vector{ { 0.0f, 0.0f, 1.0f}, { 0.0f, 0.0f, 1.0f}, { 0.0f, 0.0f, 1.0f}, /* +Z */ diff --git a/src/Primitives/Cylinder.cpp b/src/Primitives/Cylinder.cpp index 0d8460107..025242e39 100644 --- a/src/Primitives/Cylinder.cpp +++ b/src/Primitives/Cylinder.cpp @@ -17,11 +17,9 @@ #include "Math/Constants.h" -using namespace std; - namespace Magnum { namespace Primitives { -Cylinder::Cylinder(uint32_t rings, uint32_t segments, GLfloat length, Flags flags): Capsule(segments, flags & Flag::GenerateTextureCoords ? TextureCoords::Generate : TextureCoords::DontGenerate) { +Cylinder::Cylinder(std::uint32_t rings, std::uint32_t segments, GLfloat length, Flags flags): Capsule(segments, flags & Flag::GenerateTextureCoords ? TextureCoords::Generate : TextureCoords::DontGenerate) { CORRADE_ASSERT(rings >= 1 && segments >= 3, "Cylinder must have at least one ring and three segments", ); GLfloat y = length*0.5f; @@ -51,9 +49,9 @@ Cylinder::Cylinder(uint32_t rings, uint32_t segments, GLfloat length, Flags flag void Cylinder::capVertexRing(GLfloat y, GLfloat textureCoordsV, const Vector3& normal) { GLfloat segmentAngleIncrement = 2*Constants::pi()/segments; - for(uint32_t i = 0; i != segments; ++i) { + for(std::uint32_t i = 0; i != segments; ++i) { GLfloat segmentAngle = i*segmentAngleIncrement; - positions(0)->push_back({sin(segmentAngle), y, cos(segmentAngle)}); + positions(0)->push_back({std::sin(segmentAngle), y, std::cos(segmentAngle)}); normals(0)->push_back(normal); if(textureCoords == TextureCoords::Generate) diff --git a/src/Primitives/Icosphere.cpp b/src/Primitives/Icosphere.cpp index 379365e18..e637db8e4 100644 --- a/src/Primitives/Icosphere.cpp +++ b/src/Primitives/Icosphere.cpp @@ -17,11 +17,9 @@ #include "Math/Vector4.h" -using namespace std; - namespace Magnum { namespace Primitives { -Icosphere<0>::Icosphere(): MeshData3D("", Mesh::Primitive::Triangles, new vector{ +Icosphere<0>::Icosphere(): MeshData3D("", Mesh::Primitive::Triangles, new std::vector{ 1, 2, 6, 1, 7, 2, 3, 4, 5, @@ -42,7 +40,7 @@ Icosphere<0>::Icosphere(): MeshData3D("", Mesh::Primitive::Triangles, new vector 7, 1, 0, 3, 9, 8, 4, 8, 0 -}, {new vector}, {new vector{ +}, {new std::vector}, {new std::vector{ Vector3(0, -0.525731f, 0.850651f), Vector3(0.850651f, 0, 0.525731f), Vector3(0.850651f, 0, -0.525731f), diff --git a/src/Primitives/Plane.cpp b/src/Primitives/Plane.cpp index 99627bab1..d50a994a4 100644 --- a/src/Primitives/Plane.cpp +++ b/src/Primitives/Plane.cpp @@ -17,16 +17,14 @@ #include "Math/Point3D.h" -using namespace std; - namespace Magnum { namespace Primitives { -Plane::Plane(): MeshData3D("", Mesh::Primitive::TriangleStrip, nullptr, {new vector{ +Plane::Plane(): MeshData3D("", Mesh::Primitive::TriangleStrip, nullptr, {new std::vector{ {1.0f, -1.0f, 0.0f}, {1.0f, 1.0f, 0.0f}, {-1.0f, -1.0f, 0.0f}, {-1.0f, 1.0f, 0.0f} -}}, {new vector{ +}}, {new std::vector{ {0.0f, 0.0f, 1.0f}, {0.0f, 0.0f, 1.0f}, {0.0f, 0.0f, 1.0f}, diff --git a/src/Primitives/Square.cpp b/src/Primitives/Square.cpp index 1855bcd6e..73d8b1f2b 100644 --- a/src/Primitives/Square.cpp +++ b/src/Primitives/Square.cpp @@ -17,11 +17,9 @@ #include "Math/Point2D.h" -using namespace std; - namespace Magnum { namespace Primitives { -Square::Square(): MeshData2D("", Mesh::Primitive::TriangleStrip, nullptr, {new vector{ +Square::Square(): MeshData2D("", Mesh::Primitive::TriangleStrip, nullptr, {new std::vector{ {1.0f, -1.0f}, {1.0f, 1.0f}, {-1.0f, -1.0f}, diff --git a/src/Primitives/Test/CapsuleTest.cpp b/src/Primitives/Test/CapsuleTest.cpp index 1f6fb6183..51f2230ea 100644 --- a/src/Primitives/Test/CapsuleTest.cpp +++ b/src/Primitives/Test/CapsuleTest.cpp @@ -23,7 +23,6 @@ #include "Math/Point3D.h" #include "Primitives/Capsule.h" -using namespace std; using Corrade::TestSuite::Compare::Container; CORRADE_TEST_MAIN(Magnum::Primitives::Test::CapsuleTest) @@ -38,7 +37,7 @@ CapsuleTest::CapsuleTest() { void CapsuleTest::withoutTextureCoords() { Capsule capsule(2, 2, 3, 1.0f); - CORRADE_COMPARE_AS(*capsule.positions(0), (vector{ + CORRADE_COMPARE_AS(*capsule.positions(0), (std::vector{ {0.0f, -1.5f, 0.0f}, {0.0f, -1.20711f, 0.707107f}, @@ -64,7 +63,7 @@ void CapsuleTest::withoutTextureCoords() { {0.0f, 1.5f, 0.0f} }), Container); - CORRADE_COMPARE_AS(*capsule.normals(0), (vector{ + CORRADE_COMPARE_AS(*capsule.normals(0), (std::vector{ {0.0f, -1.0f, 0.0f}, {0.0f, -0.707107f, 0.707107f}, @@ -90,7 +89,7 @@ void CapsuleTest::withoutTextureCoords() { {0.0f, 1.0f, 0.0f} }), Container); - CORRADE_COMPARE_AS(*capsule.indices(), (vector{ + CORRADE_COMPARE_AS(*capsule.indices(), (std::vector{ 0, 2, 1, 0, 3, 2, 0, 1, 3, 1, 2, 5, 1, 5, 4, 2, 3, 6, 2, 6, 5, 3, 1, 4, 3, 4, 6, 4, 5, 8, 4, 8, 7, 5, 6, 9, 5, 9, 8, 6, 4, 7, 6, 7, 9, @@ -103,7 +102,7 @@ void CapsuleTest::withoutTextureCoords() { void CapsuleTest::withTextureCoords() { Capsule capsule(2, 2, 3, 1.0f, Capsule::TextureCoords::Generate); - CORRADE_COMPARE_AS(*capsule.positions(0), (vector{ + CORRADE_COMPARE_AS(*capsule.positions(0), (std::vector{ {0.0f, -1.5f, 0.0f}, {0.0f, -1.20711f, 0.707107f}, @@ -134,7 +133,7 @@ void CapsuleTest::withTextureCoords() { {0.0f, 1.5f, 0.0f} }), Container); - CORRADE_COMPARE_AS(*capsule.textureCoords2D(0), (vector{ + CORRADE_COMPARE_AS(*capsule.textureCoords2D(0), (std::vector{ {0.5f, 0.0f}, {0.0f, 0.166667f}, @@ -165,7 +164,7 @@ void CapsuleTest::withTextureCoords() { {0.5f, 1.0f} }), Container); - CORRADE_COMPARE_AS(*capsule.indices(), (vector{ + CORRADE_COMPARE_AS(*capsule.indices(), (std::vector{ 0, 2, 1, 0, 3, 2, 0, 4, 3, 1, 2, 6, 1, 6, 5, 2, 3, 7, 2, 7, 6, 3, 4, 8, 3, 8, 7, 5, 6, 10, 5, 10, 9, 6, 7, 11, 6, 11, 10, 7, 8, 12, 7, 12, 11, diff --git a/src/Primitives/Test/CylinderTest.cpp b/src/Primitives/Test/CylinderTest.cpp index f7f919cae..4eda71de4 100644 --- a/src/Primitives/Test/CylinderTest.cpp +++ b/src/Primitives/Test/CylinderTest.cpp @@ -20,7 +20,6 @@ #include "Math/Point3D.h" #include "Primitives/Cylinder.h" -using namespace std; using Corrade::TestSuite::Compare::Container; CORRADE_TEST_MAIN(Magnum::Primitives::Test::CylinderTest) @@ -35,7 +34,7 @@ CylinderTest::CylinderTest() { void CylinderTest::withoutAnything() { Cylinder cylinder(2, 3, 3.0f); - CORRADE_COMPARE_AS(*cylinder.positions(0), (vector{ + CORRADE_COMPARE_AS(*cylinder.positions(0), (std::vector{ {0.0f, -1.5f, 1.0f}, {0.866025f, -1.5f, -0.5f}, {-0.866025f, -1.5f, -0.5f}, @@ -49,7 +48,7 @@ void CylinderTest::withoutAnything() { {-0.866025f, 1.5f, -0.5f} }), Container); - CORRADE_COMPARE_AS(*cylinder.normals(0), (vector{ + CORRADE_COMPARE_AS(*cylinder.normals(0), (std::vector{ {0.0f, 0.0f, 1.0f}, {0.866025f, 0.0f, -0.5f}, {-0.866025f, 0.0f, -0.5f}, @@ -63,7 +62,7 @@ void CylinderTest::withoutAnything() { {-0.866025f, 0.0f, -0.5f} }), Container); - CORRADE_COMPARE_AS(*cylinder.indices(), (vector{ + CORRADE_COMPARE_AS(*cylinder.indices(), (std::vector{ 0, 1, 4, 0, 4, 3, 1, 2, 5, 1, 5, 4, 2, 0, 3, 2, 3, 5, 3, 4, 7, 3, 7, 6, 4, 5, 8, 4, 8, 7, 5, 3, 6, 5, 6, 8 }), Container); @@ -72,7 +71,7 @@ void CylinderTest::withoutAnything() { void CylinderTest::withTextureCoordsAndCaps() { Cylinder cylinder(2, 3, 3.0f, Cylinder::Flag::GenerateTextureCoords|Cylinder::Flag::CapEnds); - CORRADE_COMPARE_AS(*cylinder.positions(0), (vector{ + CORRADE_COMPARE_AS(*cylinder.positions(0), (std::vector{ {0.0f, -1.5f, 0.0f}, {0.0f, -1.5f, 1.0f}, @@ -103,7 +102,7 @@ void CylinderTest::withTextureCoordsAndCaps() { {0.0f, 1.5f, 0.0f} }), Container); - CORRADE_COMPARE_AS(*cylinder.normals(0), (vector{ + CORRADE_COMPARE_AS(*cylinder.normals(0), (std::vector{ {0.0f, -1.0f, 0.0f}, {0.0f, -1.0f, 0.0f}, @@ -134,7 +133,7 @@ void CylinderTest::withTextureCoordsAndCaps() { {0.0f, 1.0f, 0.0f}, }), Container); - CORRADE_COMPARE_AS(*cylinder.textureCoords2D(0), (vector{ + CORRADE_COMPARE_AS(*cylinder.textureCoords2D(0), (std::vector{ {0.5f, 0.0f}, {0.0f, 0.2f}, @@ -165,7 +164,7 @@ void CylinderTest::withTextureCoordsAndCaps() { {0.5f, 1.0f} }), Container); - CORRADE_COMPARE_AS(*cylinder.indices(), (vector{ + CORRADE_COMPARE_AS(*cylinder.indices(), (std::vector{ 0, 2, 1, 0, 3, 2, 0, 4, 3, 1, 2, 6, 1, 6, 5, 2, 3, 7, 2, 7, 6, 3, 4, 8, 3, 8, 7, 5, 6, 10, 5, 10, 9, 6, 7, 11, 6, 11, 10, 7, 8, 12, 7, diff --git a/src/Primitives/Test/UVSphereTest.cpp b/src/Primitives/Test/UVSphereTest.cpp index 1599eeb0d..4a57c5c0b 100644 --- a/src/Primitives/Test/UVSphereTest.cpp +++ b/src/Primitives/Test/UVSphereTest.cpp @@ -20,7 +20,6 @@ #include "Math/Point3D.h" #include "Primitives/UVSphere.h" -using namespace std; using Corrade::TestSuite::Compare::Container; CORRADE_TEST_MAIN(Magnum::Primitives::Test::UVSphereTest) @@ -35,7 +34,7 @@ UVSphereTest::UVSphereTest() { void UVSphereTest::withoutTextureCoords() { UVSphere sphere(3, 3); - CORRADE_COMPARE_AS(*sphere.positions(0), (vector{ + CORRADE_COMPARE_AS(*sphere.positions(0), (std::vector{ {0.0f, -1.0f, 0.0f}, {0.0f, -0.5f, 0.866025f}, @@ -49,7 +48,7 @@ void UVSphereTest::withoutTextureCoords() { {0.0f, 1.0f, 0.0f} }), Container); - CORRADE_COMPARE_AS(*sphere.normals(0), (vector{ + CORRADE_COMPARE_AS(*sphere.normals(0), (std::vector{ {0.0f, -1.0f, 0.0f}, {0.0f, -0.5f, 0.866025f}, @@ -63,7 +62,7 @@ void UVSphereTest::withoutTextureCoords() { {0.0f, 1.0f, 0.0f} }), Container); - CORRADE_COMPARE_AS(*sphere.indices(), (vector{ + CORRADE_COMPARE_AS(*sphere.indices(), (std::vector{ 0, 2, 1, 0, 3, 2, 0, 1, 3, 1, 2, 5, 1, 5, 4, 2, 3, 6, 2, 6, 5, 3, 1, 4, 3, 4, 6, 4, 5, 7, 5, 6, 7, 6, 4, 7 @@ -73,7 +72,7 @@ void UVSphereTest::withoutTextureCoords() { void UVSphereTest::withTextureCoords() { UVSphere sphere(3, 3, UVSphere::TextureCoords::Generate); - CORRADE_COMPARE_AS(*sphere.positions(0), (vector{ + CORRADE_COMPARE_AS(*sphere.positions(0), (std::vector{ {0.0f, -1.0f, 0.0f}, {0.0f, -0.5f, 0.866025f}, @@ -89,7 +88,7 @@ void UVSphereTest::withTextureCoords() { {0.0f, 1.0f, 0.0f} }), Container); - CORRADE_COMPARE_AS(*sphere.textureCoords2D(0), (vector{ + CORRADE_COMPARE_AS(*sphere.textureCoords2D(0), (std::vector{ {0.5f, 0.0f}, {0.0f, 0.333333f}, @@ -105,7 +104,7 @@ void UVSphereTest::withTextureCoords() { {0.5f, 1.0f} }), Container); - CORRADE_COMPARE_AS(*sphere.indices(), (vector{ + CORRADE_COMPARE_AS(*sphere.indices(), (std::vector{ 0, 2, 1, 0, 3, 2, 0, 4, 3, 1, 2, 6, 1, 6, 5, 2, 3, 7, 2, 7, 6, 3, 4, 8, 3, 8, 7, 5, 6, 9, 6, 7, 9, 7, 8, 9 diff --git a/src/Primitives/UVSphere.cpp b/src/Primitives/UVSphere.cpp index 920ac2dd3..5d181dd79 100644 --- a/src/Primitives/UVSphere.cpp +++ b/src/Primitives/UVSphere.cpp @@ -15,15 +15,11 @@ #include "UVSphere.h" -#include - #include "Math/Constants.h" -using namespace std; - namespace Magnum { namespace Primitives { -UVSphere::UVSphere(uint32_t rings, uint32_t segments, TextureCoords textureCoords): Capsule(segments, textureCoords) { +UVSphere::UVSphere(std::uint32_t rings, std::uint32_t segments, TextureCoords textureCoords): Capsule(segments, textureCoords) { CORRADE_ASSERT(rings >= 2 && segments >= 3, "UVSphere must have at least two rings and three segments", ); GLfloat textureCoordsVIncrement = 1.0f/rings; diff --git a/src/Profiler.cpp b/src/Profiler.cpp index 8e4178fcf..5682c3072 100644 --- a/src/Profiler.cpp +++ b/src/Profiler.cpp @@ -19,25 +19,25 @@ #include #include -using namespace std; +#include "Magnum.h" namespace Magnum { -Profiler::Section Profiler::addSection(const string& name) { +Profiler::Section Profiler::addSection(const std::string& name) { CORRADE_ASSERT(!enabled, "Profiler: cannot add section when profiling is enabled", 0); sections.push_back(name); return sections.size()-1; } -void Profiler::setMeasureDuration(size_t frames) { +void Profiler::setMeasureDuration(std::size_t frames) { CORRADE_ASSERT(!enabled, "Profiler: cannot set measure duration when profiling is enabled", ); measureDuration = frames; } void Profiler::enable() { enabled = true; - frameData.assign(measureDuration*sections.size(), chrono::high_resolution_clock::duration::zero()); - totalData.assign(sections.size(), chrono::high_resolution_clock::duration::zero()); + frameData.assign(measureDuration*sections.size(), std::chrono::high_resolution_clock::duration::zero()); + totalData.assign(sections.size(), std::chrono::high_resolution_clock::duration::zero()); frameCount = 0; } @@ -59,14 +59,14 @@ void Profiler::stop() { save(); - previousTime = chrono::high_resolution_clock::time_point(); + previousTime = std::chrono::high_resolution_clock::time_point(); } void Profiler::save() { - auto now = chrono::high_resolution_clock::now(); + auto now = std::chrono::high_resolution_clock::now(); /* If the profiler is already running, add time to given section */ - if(previousTime != chrono::high_resolution_clock::time_point()) + if(previousTime != std::chrono::high_resolution_clock::time_point()) frameData[currentFrame*sections.size()+currentSection] += now-previousTime; /* Set current time as previous for next section */ @@ -77,16 +77,16 @@ void Profiler::nextFrame() { if(!enabled) return; /* Next frame index */ - size_t nextFrame = (currentFrame+1) % measureDuration; + std::size_t nextFrame = (currentFrame+1) % measureDuration; /* Add times of current frame to total */ - for(size_t i = 0; i != sections.size(); ++i) + for(std::size_t i = 0; i != sections.size(); ++i) totalData[i] += frameData[currentFrame*sections.size()+i]; /* Subtract times of next frame from total and erase them */ - for(size_t i = 0; i != sections.size(); ++i) { + for(std::size_t i = 0; i != sections.size(); ++i) { totalData[i] -= frameData[nextFrame*sections.size()+i]; - frameData[nextFrame*sections.size()+i] = chrono::high_resolution_clock::duration::zero(); + frameData[nextFrame*sections.size()+i] = std::chrono::high_resolution_clock::duration::zero(); } /* Advance to next frame */ @@ -98,14 +98,14 @@ void Profiler::nextFrame() { void Profiler::printStatistics() { if(!enabled) return; - vector totalSorted(sections.size()); - iota(totalSorted.begin(), totalSorted.end(), 0); + std::vector totalSorted(sections.size()); + std::iota(totalSorted.begin(), totalSorted.end(), 0); - sort(totalSorted.begin(), totalSorted.end(), [this](size_t i, size_t j){return totalData[i] > totalData[j];}); + std::sort(totalSorted.begin(), totalSorted.end(), [this](std::size_t i, std::size_t j){return totalData[i] > totalData[j];}); - Corrade::Utility::Debug() << "Statistics for last" << measureDuration << "frames:"; - for(size_t i = 0; i != sections.size(); ++i) - Corrade::Utility::Debug() << ' ' << sections[totalSorted[i]] << chrono::microseconds(totalData[totalSorted[i]]).count()/frameCount << u8"µs"; + Debug() << "Statistics for last" << measureDuration << "frames:"; + for(std::size_t i = 0; i != sections.size(); ++i) + Debug() << ' ' << sections[totalSorted[i]] << std::chrono::microseconds(totalData[totalSorted[i]]).count()/frameCount << u8"µs"; } } diff --git a/src/SceneGraph/Test/ObjectTest.cpp b/src/SceneGraph/Test/ObjectTest.cpp index abe60f4c7..60bab57b6 100644 --- a/src/SceneGraph/Test/ObjectTest.cpp +++ b/src/SceneGraph/Test/ObjectTest.cpp @@ -21,8 +21,6 @@ #include "SceneGraph/MatrixTransformation3D.h" #include "SceneGraph/Scene.h" -using namespace std; - CORRADE_TEST_MAIN(Magnum::SceneGraph::Test::ObjectTest) namespace Magnum { namespace SceneGraph { namespace Test { @@ -121,22 +119,22 @@ void ObjectTest::transformations() { Matrix4 initial = Matrix4::rotationX(deg(90.0f)).inverted(); /* Empty list */ - CORRADE_COMPARE(s.transformations(vector(), initial), vector()); + CORRADE_COMPARE(s.transformations(std::vector(), initial), std::vector()); /* Scene alone */ - CORRADE_COMPARE(s.transformations({&s}, initial), vector{initial}); + CORRADE_COMPARE(s.transformations({&s}, initial), std::vector{initial}); /* One object */ Object3D first(&s); first.rotateZ(deg(30.0f)); Object3D second(&first); second.scale(Vector3(0.5f)); - CORRADE_COMPARE(s.transformations({&second}, initial), vector{ + CORRADE_COMPARE(s.transformations({&second}, initial), std::vector{ initial*Matrix4::rotationZ(deg(30.0f))*Matrix4::scaling(Vector3(0.5f)) }); /* One object and scene */ - CORRADE_COMPARE(s.transformations({&second, &s}, initial), (vector{ + CORRADE_COMPARE(s.transformations({&second, &s}, initial), (std::vector{ initial*Matrix4::rotationZ(deg(30.0f))*Matrix4::scaling(Vector3(0.5f)), initial })); @@ -144,13 +142,13 @@ void ObjectTest::transformations() { /* Two objects with foreign joint */ Object3D third(&first); third.translate(Vector3::xAxis(5.0f)); - CORRADE_COMPARE(s.transformations({&second, &third}, initial), (vector{ + CORRADE_COMPARE(s.transformations({&second, &third}, initial), (std::vector{ initial*Matrix4::rotationZ(deg(30.0f))*Matrix4::scaling(Vector3(0.5f)), initial*Matrix4::rotationZ(deg(30.0f))*Matrix4::translation(Vector3::xAxis(5.0f)), })); /* Three objects with joint as one of them */ - CORRADE_COMPARE(s.transformations({&second, &third, &first}, initial), (vector{ + CORRADE_COMPARE(s.transformations({&second, &third, &first}, initial), (std::vector{ initial*Matrix4::rotationZ(deg(30.0f))*Matrix4::scaling(Vector3(0.5f)), initial*Matrix4::rotationZ(deg(30.0f))*Matrix4::translation(Vector3::xAxis(5.0f)), initial*Matrix4::rotationZ(deg(30.0f)), @@ -160,7 +158,7 @@ void ObjectTest::transformations() { CORRADE_EXPECT_FAIL("Transformations not relative to scene are not yet implemented."); /* Transformation relative to another object */ - CORRADE_COMPARE(second.transformations({&third}), vector{ + CORRADE_COMPARE(second.transformations({&third}), std::vector{ Matrix4::scaling(Vector3(0.5f)).inverted()*Matrix4::translation(Vector3::xAxis(5.0f)) }); @@ -172,17 +170,17 @@ void ObjectTest::transformations() { orphan1.scale(Vector3::xScale(3.0f)); Object3D orphan2(&orphanParent); orphan2.translate(Vector3::zAxis(5.0f)); - CORRADE_COMPARE(orphan1.transformations({&orphan2}), vector{ + CORRADE_COMPARE(orphan1.transformations({&orphan2}), std::vector{ Matrix4::scaling(Vector3::xScale(3.0f)).inverted()*Matrix4::translation(Vector3::zAxis(5.0f)) }); } - ostringstream o; + std::ostringstream o; Error::setOutput(&o); /* Transformation of objects not part of the same scene */ Object3D orphan; - CORRADE_COMPARE(s.transformations({&orphan}), vector()); + CORRADE_COMPARE(s.transformations({&orphan}), std::vector()); CORRADE_COMPARE(o.str(), "SceneGraph::Object::transformations(): the objects are not part of the same tree\n"); } @@ -283,7 +281,7 @@ void ObjectTest::setClean() { void ObjectTest::bulkSetClean() { /* Verify it doesn't crash when passed empty list */ - Object3D::setClean(vector()); + Object3D::setClean(std::vector()); Scene3D scene; Object3D a(&scene); @@ -294,7 +292,7 @@ void ObjectTest::bulkSetClean() { CachingObject d(&c); d.scale(Vector3(-2.0f)); Object3D e(&scene); - vector cleanAll{&a, &b, &c, &d, &e}; + std::vector cleanAll{&a, &b, &c, &d, &e}; /* All objects should be cleaned */ CORRADE_VERIFY(a.isDirty()); diff --git a/src/Shader.cpp b/src/Shader.cpp index c23d66adf..d6a756720 100644 --- a/src/Shader.cpp +++ b/src/Shader.cpp @@ -25,8 +25,6 @@ typedef char GLchar; #endif -using namespace std; - namespace Magnum { Shader::Shader(Version version, Type type): _type(type), _state(State::Initialized), shader(0) { @@ -72,7 +70,7 @@ Shader& Shader::operator=(Shader&& other) { bool Shader::addFile(const std::string& filename) { /* Open file */ - ifstream file(filename.c_str()); + std::ifstream file(filename.c_str()); if(!file.good()) { file.close(); @@ -81,13 +79,13 @@ bool Shader::addFile(const std::string& filename) { } /* Get size of shader and initialize buffer */ - file.seekg(0, ios::end); - size_t size = file.tellg(); + file.seekg(0, std::ios::end); + std::size_t size = file.tellg(); char* source = new char[size+1]; source[size] = '\0'; /* Read data, close */ - file.seekg(0, ios::beg); + file.seekg(0, std::ios::beg); file.read(source, size); file.close(); @@ -104,7 +102,7 @@ GLuint Shader::compile() { /* Array of sources */ const GLchar** _sources = new const GLchar*[sources.size()]; - for(size_t i = 0; i != sources.size(); ++i) + for(std::size_t i = 0; i != sources.size(); ++i) _sources[i] = static_cast(sources[i].c_str()); /* Create shader and set its source */ diff --git a/src/Test/ColorTest.cpp b/src/Test/ColorTest.cpp index 903da1e3d..403c38668 100644 --- a/src/Test/ColorTest.cpp +++ b/src/Test/ColorTest.cpp @@ -19,16 +19,14 @@ #include "Color.h" -using namespace std; - CORRADE_TEST_MAIN(Magnum::Test::ColorTest) using namespace Corrade::Utility; namespace Magnum { namespace Test { -typedef Magnum::Color3 Color3; -typedef Magnum::Color4 Color4; +typedef Magnum::Color3 Color3; +typedef Magnum::Color4 Color4; typedef Magnum::Color3 Color3f; typedef Magnum::Color4 Color4f; @@ -125,7 +123,7 @@ void ColorTest::hsv() { CORRADE_COMPARE(Color3::fromHSV(230.0f, 0.749f, 0.427f), Color3(27, 41, 109)); float hue, saturation, value; - tie(hue, saturation, value) = Color3(27, 41, 109).toHSV(); + std::tie(hue, saturation, value) = Color3(27, 41, 109).toHSV(); CORRADE_COMPARE(hue, 229.756106f); CORRADE_COMPARE(saturation, 0.752294f); CORRADE_COMPARE(value, 0.427451f); @@ -148,12 +146,12 @@ void ColorTest::hsvOverflow() { } void ColorTest::hsvAlpha() { - CORRADE_COMPARE(Color4::fromHSV(make_tuple(230.0f, 0.749f, 0.427f), 23), Color4(27, 41, 109, 23)); + CORRADE_COMPARE(Color4::fromHSV(std::make_tuple(230.0f, 0.749f, 0.427f), 23), Color4(27, 41, 109, 23)); CORRADE_COMPARE(Color4::fromHSV(230.0f, 0.749f, 0.427f, 23), Color4(27, 41, 109, 23)); } void ColorTest::debug() { - ostringstream o; + std::ostringstream o; Debug(&o) << Color3f(0.5f, 0.75f, 1.0f); CORRADE_COMPARE(o.str(), "Vector(0.5, 0.75, 1)\n"); @@ -166,17 +164,17 @@ void ColorTest::configuration() { Configuration c; Color3f color3(0.5f, 0.75f, 1.0f); - string value3("0.5 0.75 1"); + std::string value3("0.5 0.75 1"); c.setValue("color3", color3); - CORRADE_COMPARE(c.value("color3"), value3); + CORRADE_COMPARE(c.value("color3"), value3); CORRADE_COMPARE(c.value("color3"), color3); Color4f color4(0.5f, 0.75f, 0.0f, 1.0f); - string value4("0.5 0.75 0 1"); + std::string value4("0.5 0.75 0 1"); c.setValue("color4", color4); - CORRADE_COMPARE(c.value("color4"), value4); + CORRADE_COMPARE(c.value("color4"), value4); CORRADE_COMPARE(c.value("color4"), color4); } diff --git a/src/Test/ResourceManagerTest.cpp b/src/Test/ResourceManagerTest.cpp index bd73a6b5b..6efa8c520 100644 --- a/src/Test/ResourceManagerTest.cpp +++ b/src/Test/ResourceManagerTest.cpp @@ -22,7 +22,6 @@ #include "corradeCompatibility.h" -using namespace std; using namespace Corrade::Utility; CORRADE_TEST_MAIN(Magnum::Test::ResourceManagerTest) @@ -37,7 +36,7 @@ class Data { inline ~Data() { --count; } }; -typedef Magnum::ResourceManager ResourceManager; +typedef Magnum::ResourceManager ResourceManager; class IntResourceLoader: public AbstractResourceLoader { public: @@ -117,7 +116,7 @@ void ResourceManagerTest::stateFallback() { void ResourceManagerTest::stateDisallowed() { ResourceManager rm; - stringstream out; + std::ostringstream out; Error::setOutput(&out); Data d; @@ -135,27 +134,27 @@ void ResourceManagerTest::basic() { /* One mutable, one final */ ResourceKey questionKey("the-question"); ResourceKey answerKey("the-answer"); - rm.set(questionKey, new int32_t(10), ResourceDataState::Mutable, ResourcePolicy::Resident); - rm.set(answerKey, new int32_t(42), ResourceDataState::Final, ResourcePolicy::Resident); - Resource theQuestion = rm.get(questionKey); - Resource theAnswer = rm.get(answerKey); + rm.set(questionKey, new std::int32_t(10), ResourceDataState::Mutable, ResourcePolicy::Resident); + rm.set(answerKey, new std::int32_t(42), ResourceDataState::Final, ResourcePolicy::Resident); + Resource theQuestion = rm.get(questionKey); + Resource theAnswer = rm.get(answerKey); /* Check basic functionality */ CORRADE_COMPARE(theQuestion.state(), ResourceState::Mutable); CORRADE_COMPARE(theAnswer.state(), ResourceState::Final); CORRADE_COMPARE(*theQuestion, 10); CORRADE_COMPARE(*theAnswer, 42); - CORRADE_COMPARE(rm.count(), 2); + CORRADE_COMPARE(rm.count(), 2); /* Cannot change already final resource */ - stringstream out; + std::ostringstream out; Error::setOutput(&out); - rm.set(answerKey, new int32_t(43), ResourceDataState::Mutable, ResourcePolicy::Resident); + rm.set(answerKey, new std::int32_t(43), ResourceDataState::Mutable, ResourcePolicy::Resident); CORRADE_COMPARE(*theAnswer, 42); CORRADE_COMPARE(out.str(), "ResourceManager::set(): cannot change already final resource\n"); /* But non-final can be changed */ - rm.set(questionKey, new int32_t(20), ResourceDataState::Final, ResourcePolicy::Resident); + rm.set(questionKey, new std::int32_t(20), ResourceDataState::Final, ResourcePolicy::Resident); CORRADE_COMPARE(theQuestion.state(), ResourceState::Final); CORRADE_COMPARE(*theQuestion, 20); } diff --git a/src/Test/SwizzleTest.cpp b/src/Test/SwizzleTest.cpp index 3ac1c4139..5da5a9bf3 100644 --- a/src/Test/SwizzleTest.cpp +++ b/src/Test/SwizzleTest.cpp @@ -17,8 +17,6 @@ #include "Swizzle.h" -using namespace std; - CORRADE_TEST_MAIN(Magnum::Test::SwizzleTest) namespace Magnum { namespace Test { @@ -57,37 +55,37 @@ void SwizzleTest::fromSmall() { /* Force compile-time evaluation for both */ constexpr Vector2i orig(1, 2); constexpr Vector3i swizzled(swizzle(orig, "gxr")); - CORRADE_VERIFY((integral_constant::value)); + CORRADE_VERIFY((std::integral_constant::value)); CORRADE_COMPARE((swizzle<'g', 'x', 'r'>(orig)), Vector3i(2, 1, 1)); } void SwizzleTest::type() { Vector4i orig; - CORRADE_VERIFY((is_same(orig)), Vector2i>::value)); - CORRADE_VERIFY((is_same::value)); - CORRADE_VERIFY((is_same(orig)), Vector3i>::value)); - CORRADE_VERIFY((is_same::value)); - CORRADE_VERIFY((is_same(orig)), Vector4i>::value)); - CORRADE_VERIFY((is_same::value)); + CORRADE_VERIFY((std::is_same(orig)), Vector2i>::value)); + CORRADE_VERIFY((std::is_same::value)); + CORRADE_VERIFY((std::is_same(orig)), Vector3i>::value)); + CORRADE_VERIFY((std::is_same::value)); + CORRADE_VERIFY((std::is_same(orig)), Vector4i>::value)); + CORRADE_VERIFY((std::is_same::value)); Color3 origColor3; Color4 origColor4; - CORRADE_VERIFY((is_same(origColor3)), Color3>::value)); - CORRADE_VERIFY((is_same(origColor4)), Color3>::value)); - CORRADE_VERIFY((is_same>::value)); - CORRADE_VERIFY((is_same>::value)); - CORRADE_VERIFY((is_same(origColor3)), Color4>::value)); - CORRADE_VERIFY((is_same(origColor4)), Color4>::value)); - CORRADE_VERIFY((is_same>::value)); - CORRADE_VERIFY((is_same>::value)); + CORRADE_VERIFY((std::is_same(origColor3)), Color3<>>::value)); + CORRADE_VERIFY((std::is_same(origColor4)), Color3>::value)); + CORRADE_VERIFY((std::is_same>::value)); + CORRADE_VERIFY((std::is_same>::value)); + CORRADE_VERIFY((std::is_same(origColor3)), Color4<>>::value)); + CORRADE_VERIFY((std::is_same(origColor4)), Color4>::value)); + CORRADE_VERIFY((std::is_same>::value)); + CORRADE_VERIFY((std::is_same>::value)); } void SwizzleTest::defaultType() { Vector4i orig(1, 2, 3, 4); - CORRADE_COMPARE(swizzle<'b'>(orig), (Math::Vector<1, int32_t>(3))); - CORRADE_COMPARE(swizzle(orig, "b"), (Math::Vector<1, int32_t>(3))); - CORRADE_COMPARE((swizzle<'b', 'r', 'a', 'g', 'z', 'y', 'x'>(orig)), (Math::Vector<7, int32_t>(3, 1, 4, 2, 3, 2, 1))); - CORRADE_COMPARE(swizzle(orig, "bragzyx"), (Math::Vector<7, int32_t>(3, 1, 4, 2, 3, 2, 1))); + CORRADE_COMPARE(swizzle<'b'>(orig), (Math::Vector<1, std::int32_t>(3))); + CORRADE_COMPARE(swizzle(orig, "b"), (Math::Vector<1, std::int32_t>(3))); + CORRADE_COMPARE((swizzle<'b', 'r', 'a', 'g', 'z', 'y', 'x'>(orig)), (Math::Vector<7, std::int32_t>(3, 1, 4, 2, 3, 2, 1))); + CORRADE_COMPARE(swizzle(orig, "bragzyx"), (Math::Vector<7, std::int32_t>(3, 1, 4, 2, 3, 2, 1))); } }} diff --git a/src/Trade/AbstractImporter.cpp b/src/Trade/AbstractImporter.cpp index ec68d9c21..1ccf4da86 100644 --- a/src/Trade/AbstractImporter.cpp +++ b/src/Trade/AbstractImporter.cpp @@ -17,7 +17,6 @@ #include -using namespace std; using namespace Corrade::Utility; namespace Magnum { namespace Trade { diff --git a/src/TypeTraits.cpp b/src/TypeTraits.cpp index 8e19a76c5..bf764d21d 100644 --- a/src/TypeTraits.cpp +++ b/src/TypeTraits.cpp @@ -18,25 +18,23 @@ #include #include -using namespace std; - namespace Magnum { #ifndef DOXYGEN_GENERATING_OUTPUT -static_assert(is_same::value, "GLubyte is not the same as uint8_t"); -static_assert(is_same::value, "GLbyte is not the same as int8_t"); -static_assert(is_same::value, "GLushort is not the same as uint16_t"); -static_assert(is_same::value, "GLshort is not the same as int16_t"); -static_assert(is_same::value, "GLuint is not the same as uint32_t"); -static_assert(is_same::value, "GLint is not the same as int32_t"); -static_assert(is_same::value, "GLsizei is not the same as int32_t"); -static_assert(is_same::value, "GLfloat is not the same as float"); +static_assert(std::is_same::value, "GLubyte is not the same as std::uint8_t"); +static_assert(std::is_same::value, "GLbyte is not the same as std::int8_t"); +static_assert(std::is_same::value, "GLushort is not the same as std::uint16_t"); +static_assert(std::is_same::value, "GLshort is not the same as std::int16_t"); +static_assert(std::is_same::value, "GLuint is not the same as std::uint32_t"); +static_assert(std::is_same::value, "GLint is not the same as std::int32_t"); +static_assert(std::is_same::value, "GLsizei is not the same as std::int32_t"); +static_assert(std::is_same::value, "GLfloat is not the same as float"); #ifndef MAGNUM_TARGET_GLES -static_assert(is_same::value, "GLdouble is not the same as double"); +static_assert(std::is_same::value, "GLdouble is not the same as double"); #endif #endif -size_t TypeInfo::sizeOf(Type type) { +std::size_t TypeInfo::sizeOf(Type type) { switch(type) { #define val(type) case Type::type: return TypeTraits::Type>::size(); val(UnsignedByte)