Browse Source

No `using namespace std` anywhere.

Also added missing std:: prefix to remaining cases of std::size_t,
std::[u]int[0-9]+_t, std::sin() etc., std::exit().
pull/7/head
Vladimír Vondruš 14 years ago
parent
commit
0f889369f4
  1. 6
      src/AbstractImage.cpp
  2. 4
      src/AbstractShaderProgram.cpp
  3. 16
      src/AbstractShaderProgram.h
  4. 4
      src/Color.h
  5. 18
      src/Context.cpp
  6. 4
      src/Context.h
  7. 2
      src/Math/Geometry/Test/DistanceTest.cpp
  8. 6
      src/Math/Geometry/Test/IntersectionTest.cpp
  9. 4
      src/Math/Math.cpp
  10. 2
      src/Math/Math.h
  11. 56
      src/Math/Test/MathTest.cpp
  12. 18
      src/Math/Test/MathTypeTraitsTest.cpp
  13. 7
      src/Math/Test/Matrix3Test.cpp
  14. 9
      src/Math/Test/Matrix4Test.cpp
  15. 11
      src/Math/Test/MatrixTest.cpp
  16. 7
      src/Math/Test/Point2DTest.cpp
  17. 7
      src/Math/Test/Point3DTest.cpp
  18. 21
      src/Math/Test/RectangularMatrixTest.cpp
  19. 7
      src/Math/Test/Vector2Test.cpp
  20. 7
      src/Math/Test/Vector3Test.cpp
  21. 7
      src/Math/Test/Vector4Test.cpp
  22. 13
      src/Math/Test/VectorTest.cpp
  23. 2
      src/Mesh.cpp
  24. 10
      src/MeshTools/CompressIndices.cpp
  25. 10
      src/MeshTools/FlipNormals.cpp
  26. 14
      src/MeshTools/GenerateFlatNormals.cpp
  27. 10
      src/MeshTools/Test/CleanTest.cpp
  28. 38
      src/MeshTools/Test/CombineIndexedArraysTest.cpp
  29. 39
      src/MeshTools/Test/CompressIndicesTest.cpp
  30. 26
      src/MeshTools/Test/FlipNormalsTest.cpp
  31. 20
      src/MeshTools/Test/GenerateFlatNormalsTest.cpp
  32. 41
      src/MeshTools/Test/InterleaveTest.cpp
  33. 16
      src/MeshTools/Test/SubdivideTest.cpp
  34. 12
      src/MeshTools/Test/TipsifyTest.cpp
  35. 40
      src/MeshTools/Tipsify.cpp
  36. 10
      src/Physics/ObjectShape.cpp
  37. 3
      src/Physics/Plane.cpp
  38. 4
      src/Physics/Test/ShapeGroupTest.cpp
  39. 4
      src/Platform/AbstractXApplication.cpp
  40. 14
      src/Platform/EglContextHandler.cpp
  41. 2
      src/Platform/ExtensionWrangler.cpp
  42. 6
      src/Platform/GlxContextHandler.cpp
  43. 8
      src/Platform/NaClApplication.cpp
  44. 4
      src/Platform/Sdl2Application.cpp
  45. 52
      src/Primitives/Capsule.cpp
  46. 6
      src/Primitives/Cube.cpp
  47. 8
      src/Primitives/Cylinder.cpp
  48. 6
      src/Primitives/Icosphere.cpp
  49. 6
      src/Primitives/Plane.cpp
  50. 4
      src/Primitives/Square.cpp
  51. 13
      src/Primitives/Test/CapsuleTest.cpp
  52. 15
      src/Primitives/Test/CylinderTest.cpp
  53. 13
      src/Primitives/Test/UVSphereTest.cpp
  54. 6
      src/Primitives/UVSphere.cpp
  55. 36
      src/Profiler.cpp
  56. 26
      src/SceneGraph/Test/ObjectTest.cpp
  57. 12
      src/Shader.cpp
  58. 20
      src/Test/ColorTest.cpp
  59. 21
      src/Test/ResourceManagerTest.cpp
  60. 40
      src/Test/SwizzleTest.cpp
  61. 1
      src/Trade/AbstractImporter.cpp
  62. 22
      src/TypeTraits.cpp

6
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:

4
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());

16
src/AbstractShaderProgram.h

@ -1095,17 +1095,17 @@ template<> struct Attribute<GLfloat> {
CORRADE_ENUMSET_OPERATORS(Attribute<GLfloat>::DataOptions)
template<size_t vectorSize> struct Attribute<Math::Vector<vectorSize, GLfloat>>: public Attribute<GLfloat> {
template<std::size_t vectorSize> struct Attribute<Math::Vector<vectorSize, GLfloat>>: public Attribute<GLfloat> {
inline constexpr static GLint size(DataOptions) { return vectorSize; }
inline constexpr static std::size_t vectorCount() { return 1; }
};
template<size_t cols, size_t rows> struct Attribute<Math::RectangularMatrix<cols, rows, GLfloat>>: public Attribute<GLfloat> {
template<std::size_t cols, std::size_t rows> struct Attribute<Math::RectangularMatrix<cols, rows, GLfloat>>: public Attribute<GLfloat> {
inline constexpr static GLint size(DataOptions) { return rows; }
inline constexpr static std::size_t vectorCount() { return cols; }
};
template<size_t matrixSize> struct Attribute<Math::Matrix<matrixSize, GLfloat>>: public Attribute<GLfloat> {
template<std::size_t matrixSize> struct Attribute<Math::Matrix<matrixSize, GLfloat>>: public Attribute<GLfloat> {
inline constexpr static GLint size(DataOptions) { return matrixSize; }
inline constexpr static std::size_t vectorCount() { return matrixSize; }
};
@ -1192,11 +1192,11 @@ template<> struct Attribute<GLuint> {
inline constexpr static GLint size() { return 1; }
};
template<size_t size> struct Attribute<Math::Vector<size, GLint>>: public Attribute<GLint> {
template<std::size_t size> struct Attribute<Math::Vector<size, GLint>>: public Attribute<GLint> {
inline constexpr static GLint size() { return size; }
};
template<size_t size> struct Attribute<Math::Vector<size, GLuint>>: public Attribute<GLuint> {
template<std::size_t size> struct Attribute<Math::Vector<size, GLuint>>: public Attribute<GLuint> {
inline constexpr static GLint size() { return size; }
};
@ -1216,17 +1216,17 @@ template<> struct Attribute<GLdouble> {
inline constexpr static std::size_t vectorCount() { return 1; }
};
template<size_t cols, size_t rows> struct Attribute<Math::RectangularMatrix<cols, rows, GLdouble>>: public Attribute<GLdouble> {
template<std::size_t cols, std::size_t rows> struct Attribute<Math::RectangularMatrix<cols, rows, GLdouble>>: public Attribute<GLdouble> {
inline constexpr static GLint size() { return rows; }
inline constexpr static std::size_t vectorCount() { return cols; }
};
template<size_t size> struct Attribute<Math::Matrix<size, GLdouble>>: public Attribute<GLdouble> {
template<std::size_t size> struct Attribute<Math::Matrix<size, GLdouble>>: public Attribute<GLdouble> {
inline constexpr static GLint size() { return size; }
inline constexpr static std::size_t vectorCount() { return size; }
};
template<size_t size> struct Attribute<Math::Vector<size, GLdouble>>: public Attribute<GLdouble> {
template<std::size_t size> struct Attribute<Math::Vector<size, GLdouble>>: public Attribute<GLdouble> {
inline constexpr static GLint size() { return size; }
inline constexpr static std::size_t vectorCount() { return size; }
};

4
src/Color.h

@ -167,7 +167,7 @@ class Color3: public Math::Vector3<T> {
* @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<T> {
* @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.

18
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<Version>(_majorVersion*100+_minorVersion*10);
/* Get first future (not supported) version */
vector<Version> versions{
std::vector<Version> 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<string, Extension> futureExtensions;
for(size_t i = future; i != versions.size(); ++i)
std::unordered_map<std::string, Extension> 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<const char*>(glGetString(GL_EXTENSIONS));
if(e) {
vector<string> extensions = Corrade::Utility::String::split(e, ' ');
for(const string& extension: extensions) {
std::vector<std::string> 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<Version> versions) const {
Version Context::supportedVersion(std::initializer_list<Version> versions) const {
for(auto version: versions)
if(isVersionSupported(version)) return version;

4
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<extension>()) { \
Corrade::Utility::Error() << "Magnum: required extension" << extension::string() << "is not supported"; \
exit(-3); \
std::exit(-3); \
} \
} while(0)
#endif

2
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<float> Vector2;

6
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<float> 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<float>::quiet_NaN());
Vector3(1.0f, 0.5f, 0.5f), Vector3(0.0f, 1.0f, 0.5f)), std::numeric_limits<float>::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<float>::infinity());
Vector3(1.0f, 0.0f, 1.0f), Vector3(0.0f, 0.0f, 1.0f))), -std::numeric_limits<float>::infinity());
}
}}}}

4
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;

2
src/Math/Math.h

@ -78,7 +78,7 @@ explicit, e.g.:
float a = normalize<float>('\127');
// b = 1.0f
float b = normalize<float, int8_t>('\127');
float b = normalize<float, std::int8_t>('\127');
@endcode
@todo Signed normalization to [-1.0, 1.0] like in OpenGL?

56
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<float, int8_t>(-128)), 0.0f);
CORRADE_COMPARE((Math::normalize<float, int8_t>(127)), 1.0f);
CORRADE_COMPARE((Math::normalize<float, uint8_t>(0)), 0.0f);
CORRADE_COMPARE((Math::normalize<float, uint8_t>(255)), 1.0f);
CORRADE_COMPARE((Math::normalize<float, std::int8_t>(-128)), 0.0f);
CORRADE_COMPARE((Math::normalize<float, std::int8_t>(127)), 1.0f);
CORRADE_COMPARE((Math::normalize<float, std::uint8_t>(0)), 0.0f);
CORRADE_COMPARE((Math::normalize<float, std::uint8_t>(255)), 1.0f);
/* Between */
CORRADE_COMPARE((Math::normalize<float, int16_t>(16384)), 0.750011f);
CORRADE_COMPARE((Math::normalize<float, int16_t>(-16384)), 0.250004f);
CORRADE_COMPARE((Math::normalize<float, std::int16_t>(16384)), 0.750011f);
CORRADE_COMPARE((Math::normalize<float, std::int16_t>(-16384)), 0.250004f);
/* Test overflow for large types */
CORRADE_COMPARE((Math::normalize<float, int32_t>(numeric_limits<int32_t>::min())), 0.0f);
CORRADE_COMPARE((Math::normalize<float, int32_t>(numeric_limits<int32_t>::max())), 1.0f);
CORRADE_COMPARE((Math::normalize<float, uint32_t>(0)), 0.0f);
CORRADE_COMPARE((Math::normalize<float, uint32_t>(numeric_limits<uint32_t>::max())), 1.0f);
CORRADE_COMPARE((Math::normalize<double, int64_t>(numeric_limits<int64_t>::min())), 0.0);
CORRADE_COMPARE((Math::normalize<double, int64_t>(numeric_limits<int64_t>::max())), 1.0);
CORRADE_COMPARE((Math::normalize<double, uint64_t>(0)), 0.0);
CORRADE_COMPARE((Math::normalize<double, uint64_t>(numeric_limits<uint64_t>::max())), 1.0);
CORRADE_COMPARE((Math::normalize<float, std::int32_t>(std::numeric_limits<std::int32_t>::min())), 0.0f);
CORRADE_COMPARE((Math::normalize<float, std::int32_t>(std::numeric_limits<std::int32_t>::max())), 1.0f);
CORRADE_COMPARE((Math::normalize<float, std::uint32_t>(0)), 0.0f);
CORRADE_COMPARE((Math::normalize<float, std::uint32_t>(std::numeric_limits<std::uint32_t>::max())), 1.0f);
CORRADE_COMPARE((Math::normalize<double, std::int64_t>(std::numeric_limits<std::int64_t>::min())), 0.0);
CORRADE_COMPARE((Math::normalize<double, std::int64_t>(std::numeric_limits<std::int64_t>::max())), 1.0);
CORRADE_COMPARE((Math::normalize<double, std::uint64_t>(0)), 0.0);
CORRADE_COMPARE((Math::normalize<double, std::uint64_t>(std::numeric_limits<std::uint64_t>::max())), 1.0);
}
void MathTest::denormalize() {
/* Range for signed and unsigned */
CORRADE_COMPARE(Math::denormalize<int8_t>(0.0f), -128);
CORRADE_COMPARE(Math::denormalize<int8_t>(1.0f), 127);
CORRADE_COMPARE(Math::denormalize<uint8_t>(0.0f), 0);
CORRADE_COMPARE(Math::denormalize<uint8_t>(1.0f), 255);
CORRADE_COMPARE(Math::denormalize<std::int8_t>(0.0f), -128);
CORRADE_COMPARE(Math::denormalize<std::int8_t>(1.0f), 127);
CORRADE_COMPARE(Math::denormalize<std::uint8_t>(0.0f), 0);
CORRADE_COMPARE(Math::denormalize<std::uint8_t>(1.0f), 255);
/* Between */
CORRADE_COMPARE(Math::denormalize<int16_t>(0.33f), -11141);
CORRADE_COMPARE(Math::denormalize<int16_t>(0.66f), 10485);
CORRADE_COMPARE(Math::denormalize<std::int16_t>(0.33f), -11141);
CORRADE_COMPARE(Math::denormalize<std::int16_t>(0.66f), 10485);
/* Test overflow for large types */
CORRADE_COMPARE(Math::denormalize<int32_t>(0.0f), numeric_limits<int32_t>::min());
CORRADE_COMPARE(Math::denormalize<uint32_t>(0.0f), 0);
CORRADE_COMPARE(Math::denormalize<int64_t>(0.0), numeric_limits<int64_t>::min());
CORRADE_COMPARE(Math::denormalize<uint64_t>(0.0), 0);
CORRADE_COMPARE(Math::denormalize<std::int32_t>(0.0f), std::numeric_limits<std::int32_t>::min());
CORRADE_COMPARE(Math::denormalize<std::uint32_t>(0.0f), 0);
CORRADE_COMPARE(Math::denormalize<std::int64_t>(0.0), std::numeric_limits<std::int64_t>::min());
CORRADE_COMPARE(Math::denormalize<std::uint64_t>(0.0), 0);
CORRADE_COMPARE(Math::denormalize<int32_t>(1.0), numeric_limits<int32_t>::max());
CORRADE_COMPARE(Math::denormalize<uint32_t>(1.0), numeric_limits<uint32_t>::max());
CORRADE_COMPARE(Math::denormalize<std::int32_t>(1.0), std::numeric_limits<std::int32_t>::max());
CORRADE_COMPARE(Math::denormalize<std::uint32_t>(1.0), std::numeric_limits<std::uint32_t>::max());
// {
// CORRADE_EXPECT_FAIL("Denormalize doesn't work for large types well");

18
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<uint8_t>();
_equalsIntegral<int8_t>();
_equalsIntegral<uint16_t>();
_equalsIntegral<int16_t>();
_equalsIntegral<uint32_t>();
_equalsIntegral<int32_t>();
_equalsIntegral<uint64_t>();
_equalsIntegral<int64_t>();
_equalsIntegral<std::uint8_t>();
_equalsIntegral<std::int8_t>();
_equalsIntegral<std::uint16_t>();
_equalsIntegral<std::int16_t>();
_equalsIntegral<std::uint32_t>();
_equalsIntegral<std::int32_t>();
_equalsIntegral<std::uint64_t>();
_equalsIntegral<std::int64_t>();
}
void MathTypeTraitsTest::equalsFloatingPoint() {

7
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<std::string>("matrix"), value);
CORRADE_COMPARE(c.value("matrix"), value);
CORRADE_COMPARE(c.value<Matrix3>("matrix"), m);
}

9
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<std::string>("matrix"), value);
CORRADE_COMPARE(c.value("matrix"), value);
CORRADE_COMPARE(c.value<Matrix4>("matrix"), m);
}

11
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<std::string>("matrix"), value);
CORRADE_COMPARE(c.value("matrix"), value);
CORRADE_COMPARE(c.value<Matrix4>("matrix"), m);
}

7
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<std::string>("point"), value);
CORRADE_COMPARE(c.value("point"), value);
CORRADE_COMPARE(c.value<Point2D>("point"), vec);
}

7
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<std::string>("point"), value);
CORRADE_COMPARE(c.value("point"), value);
CORRADE_COMPARE(c.value<Point3D>("point"), vec);
}

21
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<Matrix3x4>("matrix", m);
CORRADE_COMPARE(c.value<std::string>("matrix"), value);
CORRADE_COMPARE(c.value("matrix"), value);
CORRADE_COMPARE(c.value<Matrix3x4>("matrix"), m);
}

7
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<std::string>("vector"), value);
CORRADE_COMPARE(c.value("vector"), value);
CORRADE_COMPARE(c.value<Vector2>("vector"), vec);
}

7
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<std::string>("vector"), value);
CORRADE_COMPARE(c.value("vector"), value);
CORRADE_COMPARE(c.value<Vector3>("vector"), vec);
}

7
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<std::string>("vector"), value);
CORRADE_COMPARE(c.value("vector"), value);
CORRADE_COMPARE(c.value<Vector4>("vector"), vec);
}

13
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<Vector3::Type>::quiet_NaN());
CORRADE_COMPARE(Vector3::angle(Vector3(2.0f, 3.0f, 4.0f).normalized(), {1.0f, -2.0f, 3.0f}), std::numeric_limits<Vector3::Type>::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<Vector3::Type>::quiet_NaN());
CORRADE_COMPARE(Vector3::angle({2.0f, 3.0f, 4.0f}, Vector3(1.0f, -2.0f, 3.0f).normalized()), std::numeric_limits<Vector3::Type>::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<std::string>("vector"), value);
CORRADE_COMPARE(c.value("vector"), value);
CORRADE_COMPARE(c.value<Vector4>("vector"), vec);
}

2
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;

10
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<size_t, Type, char* > CompressIndices::operator()() const {
std::tuple<std::size_t, Type, char* > CompressIndices::operator()() const {
return SizeBasedCall<Compressor>(*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<class IndexType> std::tuple<size_t, Type, char*> CompressIndices::Compressor::run(const std::vector<uint32_t>& indices) {
template<class IndexType> std::tuple<std::size_t, Type, char*> CompressIndices::Compressor::run(const std::vector<std::uint32_t>& 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<const char*>(&index), sizeof(IndexType));
}

10
src/MeshTools/FlipNormals.cpp

@ -17,18 +17,16 @@
#include "Math/Vector3.h"
using namespace std;
namespace Magnum { namespace MeshTools {
void flipFaceWinding(vector<std::uint32_t>& indices) {
void flipFaceWinding(std::vector<std::uint32_t>& 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<Vector3>& normals) {
void flipNormals(std::vector<Vector3>& normals) {
for(Vector3& normal: normals)
normal = -normal;
}

14
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<std::uint32_t>, vector<Vector3>> generateFlatNormals(const vector<std::uint32_t>& indices, const vector<Point3D>& positions) {
CORRADE_ASSERT(!(indices.size()%3), "MeshTools::generateFlatNormals(): index count is not divisible by 3!", (tuple<vector<uint32_t>, vector<Vector3>>()));
std::tuple<std::vector<std::uint32_t>, std::vector<Vector3>> generateFlatNormals(const std::vector<std::uint32_t>& indices, const std::vector<Point3D>& positions) {
CORRADE_ASSERT(!(indices.size()%3), "MeshTools::generateFlatNormals(): index count is not divisible by 3!", (std::tuple<std::vector<std::uint32_t>, std::vector<Vector3>>()));
/* Create normal for every triangle (assuming counterclockwise winding) */
vector<uint32_t> normalIndices;
std::vector<std::uint32_t> normalIndices;
normalIndices.reserve(indices.size());
vector<Vector3> normals;
std::vector<Vector3> 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<std::uint32_t>, vector<Vector3>> generateFlatNormals(const vector<s
/* Clean duplicate normals and return */
clean(normalIndices, normals);
return make_tuple(normalIndices, normals);
return std::make_tuple(normalIndices, normals);
}
}}

10
src/MeshTools/Test/CleanTest.cpp

@ -19,8 +19,6 @@
CORRADE_TEST_MAIN(Magnum::MeshTools::Test::CleanTest)
using namespace std;
namespace Magnum { namespace MeshTools { namespace Test {
CleanTest::CleanTest() {
@ -28,13 +26,13 @@ CleanTest::CleanTest() {
}
void CleanTest::cleanMesh() {
vector<Vector1> positions{1, 2, 1, 4};
vector<uint32_t> indices{0, 1, 2, 1, 2, 3};
std::vector<Vector1> positions{1, 2, 1, 4};
std::vector<std::uint32_t> indices{0, 1, 2, 1, 2, 3};
MeshTools::clean(indices, positions);
/* Verify cleanup */
CORRADE_VERIFY(positions == (vector<Vector1>{1, 2, 4}));
CORRADE_COMPARE(indices, (vector<uint32_t>{0, 1, 0, 1, 0, 2}));
CORRADE_VERIFY(positions == (std::vector<Vector1>{1, 2, 4}));
CORRADE_COMPARE(indices, (std::vector<std::uint32_t>{0, 1, 0, 1, 0, 2}));
}
}}}

38
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<uint32_t> array;
vector<uint32_t> result = MeshTools::combineIndexedArrays(
tuple<const vector<uint32_t>&, vector<uint32_t>&>(vector<uint32_t>{0, 1, 0}, array),
tuple<const vector<uint32_t>&, vector<uint32_t>&>(vector<uint32_t>{3, 4}, array));
std::vector<std::uint32_t> array;
std::vector<std::uint32_t> result = MeshTools::combineIndexedArrays(
std::tuple<const std::vector<std::uint32_t>&, std::vector<std::uint32_t>&>(std::vector<std::uint32_t>{0, 1, 0}, array),
std::tuple<const std::vector<std::uint32_t>&, std::vector<std::uint32_t>&>(std::vector<std::uint32_t>{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<uint32_t> array1{ 0, 1 };
vector<uint32_t> array2{ 0, 1, 2, 3, 4 };
vector<uint32_t> array3{ 0, 1, 2, 3, 4, 5, 6, 7 };
vector<uint32_t> result = MeshTools::combineIndexedArrays(
tuple<const vector<uint32_t>&, vector<uint32_t>&>(vector<uint32_t>{0, 1, 0}, array1),
tuple<const vector<uint32_t>&, vector<uint32_t>&>(vector<uint32_t>{3, 4, 3}, array2),
tuple<const vector<uint32_t>&, vector<uint32_t>&>(vector<uint32_t>{6, 7, 6}, array3));
CORRADE_COMPARE(result, (vector<uint32_t>{0, 1, 0}));
CORRADE_COMPARE(array1, (vector<uint32_t>{0, 1}));
CORRADE_COMPARE(array2, (vector<uint32_t>{3, 4}));
CORRADE_COMPARE(array3, (vector<uint32_t>{6, 7}));
std::vector<std::uint32_t> array1{ 0, 1 };
std::vector<std::uint32_t> array2{ 0, 1, 2, 3, 4 };
std::vector<std::uint32_t> array3{ 0, 1, 2, 3, 4, 5, 6, 7 };
std::vector<std::uint32_t> result = MeshTools::combineIndexedArrays(
std::tuple<const std::vector<std::uint32_t>&, std::vector<std::uint32_t>&>(std::vector<std::uint32_t>{0, 1, 0}, array1),
std::tuple<const std::vector<std::uint32_t>&, std::vector<std::uint32_t>&>(std::vector<std::uint32_t>{3, 4, 3}, array2),
std::tuple<const std::vector<std::uint32_t>&, std::vector<std::uint32_t>&>(std::vector<std::uint32_t>{6, 7, 6}, array3));
CORRADE_COMPARE(result, (std::vector<std::uint32_t>{0, 1, 0}));
CORRADE_COMPARE(array1, (std::vector<std::uint32_t>{0, 1}));
CORRADE_COMPARE(array2, (std::vector<std::uint32_t>{3, 4}));
CORRADE_COMPARE(array3, (std::vector<std::uint32_t>{6, 7}));
}
}}}

39
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<uint32_t>{1, 2, 3, 0, 4});
std::tie(indexCount, indexType, data) = MeshTools::compressIndices(
std::vector<std::uint32_t>{1, 2, 3, 0, 4});
CORRADE_COMPARE(indexCount, 5);
CORRADE_VERIFY(indexType == Type::UnsignedByte);
CORRADE_COMPARE(vector<char>(data, data+indexCount*TypeInfo::sizeOf(indexType)),
(vector<char>{ 0x01, 0x02, 0x03, 0x00, 0x04 }));
CORRADE_COMPARE(std::vector<char>(data, data+indexCount*TypeInfo::sizeOf(indexType)),
(std::vector<char>{ 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<uint32_t>{1, 256, 0, 5});
std::tie(indexCount, indexType, data) = MeshTools::compressIndices(
std::vector<std::uint32_t>{1, 256, 0, 5});
CORRADE_COMPARE(indexCount, 4);
CORRADE_VERIFY(indexType == Type::UnsignedShort);
if(!Endianness::isBigEndian()) {
CORRADE_COMPARE(vector<char>(data, data+indexCount*TypeInfo::sizeOf(indexType)),
(vector<char>{ 0x01, 0x00,
CORRADE_COMPARE(std::vector<char>(data, data+indexCount*TypeInfo::sizeOf(indexType)),
(std::vector<char>{ 0x01, 0x00,
0x00, 0x01,
0x00, 0x00,
0x05, 0x00 }));
} else {
CORRADE_COMPARE(vector<char>(data, data+indexCount*TypeInfo::sizeOf(indexType)),
(vector<char>{ 0x00, 0x01,
CORRADE_COMPARE(std::vector<char>(data, data+indexCount*TypeInfo::sizeOf(indexType)),
(std::vector<char>{ 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<uint32_t>{65536, 3, 2});
std::tie(indexCount, indexType, data) = MeshTools::compressIndices(
std::vector<std::uint32_t>{65536, 3, 2});
CORRADE_COMPARE(indexCount, 3);
CORRADE_VERIFY(indexType == Type::UnsignedInt);
if(!Endianness::isBigEndian()) {
CORRADE_COMPARE(vector<char>(data, data+indexCount*TypeInfo::sizeOf(indexType)),
(vector<char>{ 0x00, 0x00, 0x01, 0x00,
CORRADE_COMPARE(std::vector<char>(data, data+indexCount*TypeInfo::sizeOf(indexType)),
(std::vector<char>{ 0x00, 0x00, 0x01, 0x00,
0x03, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00 }));
} else {
CORRADE_COMPARE(vector<char>(data, data+indexCount*TypeInfo::sizeOf(indexType)),
(vector<char>{ 0x00, 0x01, 0x00, 0x00,
CORRADE_COMPARE(std::vector<char>(data, data+indexCount*TypeInfo::sizeOf(indexType)),
(std::vector<char>{ 0x00, 0x01, 0x00, 0x00,
0x00, 0x00, 0x00, 0x03,
0x00, 0x00, 0x00, 0x02 }));
}

26
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<uint32_t> indices{0, 1};
std::vector<std::uint32_t> indices{0, 1};
MeshTools::flipFaceWinding(indices);
CORRADE_COMPARE(ss.str(), "MeshTools::flipNormals(): index count is not divisible by 3!\n");
}
void FlipNormalsTest::flipFaceWinding() {
vector<uint32_t> indices{0, 1, 2,
3, 4, 5};
std::vector<std::uint32_t> indices{0, 1, 2,
3, 4, 5};
MeshTools::flipFaceWinding(indices);
CORRADE_COMPARE(indices, (vector<uint32_t>{0, 2, 1,
3, 5, 4}));
CORRADE_COMPARE(indices, (std::vector<std::uint32_t>{0, 2, 1,
3, 5, 4}));
}
void FlipNormalsTest::flipNormals() {
vector<Vector3> normals{Vector3::xAxis(),
Vector3::yAxis(),
Vector3::zAxis()};
std::vector<Vector3> normals{Vector3::xAxis(),
Vector3::yAxis(),
Vector3::zAxis()};
MeshTools::flipNormals(normals);
CORRADE_COMPARE(normals, (vector<Vector3>{-Vector3::xAxis(),
-Vector3::yAxis(),
-Vector3::zAxis()}));
CORRADE_COMPARE(normals, (std::vector<Vector3>{-Vector3::xAxis(),
-Vector3::yAxis(),
-Vector3::zAxis()}));
}
}}}

20
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<uint32_t> indices;
vector<Vector3> normals;
tie(indices, normals) = MeshTools::generateFlatNormals({
std::vector<std::uint32_t> indices;
std::vector<Vector3> 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<uint32_t> indices;
vector<Vector3> normals;
tie(indices, normals) = MeshTools::generateFlatNormals({
std::vector<std::uint32_t> indices;
std::vector<Vector3> 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<uint32_t>{
CORRADE_COMPARE(indices, (std::vector<std::uint32_t>{
0, 0, 0,
1, 1, 1
}));
CORRADE_COMPARE(normals, (vector<Vector3>{
CORRADE_COMPARE(normals, (std::vector<Vector3>{
Vector3::zAxis(),
-Vector3::zAxis()
}));

41
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<int8_t>{0, 1, 2},
vector<int8_t>{0, 1, 2, 3, 4, 5})), size_t(0));
CORRADE_COMPARE((Implementation::Interleave::attributeCount(std::vector<std::int8_t>{0, 1, 2},
std::vector<std::int8_t>{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<int8_t>{0, 1, 2},
vector<int8_t>{3, 4, 5})), size_t(3));
CORRADE_COMPARE((Implementation::Interleave::attributeCount(std::vector<std::int8_t>{0, 1, 2},
std::vector<std::int8_t>{3, 4, 5})), std::size_t(3));
}
void InterleaveTest::stride() {
CORRADE_COMPARE(Implementation::Interleave::stride(vector<int8_t>()), size_t(1));
CORRADE_COMPARE(Implementation::Interleave::stride(vector<int32_t>()), size_t(4));
CORRADE_COMPARE((Implementation::Interleave::stride(vector<int8_t>(), vector<int32_t>())), size_t(5));
CORRADE_COMPARE(Implementation::Interleave::stride(std::vector<std::int8_t>()), std::size_t(1));
CORRADE_COMPARE(Implementation::Interleave::stride(std::vector<std::int32_t>()), std::size_t(4));
CORRADE_COMPARE((Implementation::Interleave::stride(std::vector<std::int8_t>(), std::vector<std::int32_t>())), 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<int8_t>{0, 1, 2},
vector<int32_t>{3, 4, 5},
vector<int16_t>{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<std::int8_t>{0, 1, 2},
std::vector<std::int32_t>{3, 4, 5},
std::vector<std::int16_t>{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<char>(data, data+size), (vector<char>{
CORRADE_COMPARE(std::vector<char>(data, data+size), (std::vector<char>{
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<char>(data, data+size), (vector<char>{
CORRADE_COMPARE(std::vector<char>(data, data+size), (std::vector<char>{
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x06,
0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x07,
0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x08

16
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<Vector1> positions;
vector<uint32_t> indices{0, 1};
std::vector<Vector1> positions;
std::vector<std::uint32_t> 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<Vector1> positions{0, 2, 6, 8};
vector<uint32_t> indices{0, 1, 2, 1, 2, 3};
std::vector<Vector1> positions{0, 2, 6, 8};
std::vector<std::uint32_t> indices{0, 1, 2, 1, 2, 3};
MeshTools::subdivide(indices, positions, interpolator);
CORRADE_COMPARE(indices.size(), 24);
CORRADE_VERIFY(positions == (vector<Vector1>{0, 2, 6, 8, 1, 4, 3, 4, 7, 5}));
CORRADE_COMPARE(indices, (vector<uint32_t>{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<Vector1>{0, 2, 6, 8, 1, 4, 3, 4, 7, 5}));
CORRADE_COMPARE(indices, (std::vector<std::uint32_t>{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);

12
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<uint32_t> liveTriangleCount, neighborOffset, neighbors;
std::vector<std::uint32_t> liveTriangleCount, neighborOffset, neighbors;
Implementation::Tipsify(indices, vertexCount).buildAdjacency(liveTriangleCount, neighborOffset, neighbors);
CORRADE_COMPARE(liveTriangleCount, (vector<uint32_t>{
CORRADE_COMPARE(liveTriangleCount, (std::vector<std::uint32_t>{
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<uint32_t>{
CORRADE_COMPARE(neighborOffset, (std::vector<std::uint32_t>{
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<uint32_t>{
CORRADE_COMPARE(neighbors, (std::vector<std::uint32_t>{
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<uint32_t>{
CORRADE_COMPARE(indices, (std::vector<std::uint32_t>{
4, 1, 0,
9, 5, 4,
1, 4, 5,

40
src/MeshTools/Tipsify.cpp

@ -17,44 +17,42 @@
#include <stack>
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<uint32_t> liveTriangleCount, neighborPosition, neighbors;
std::vector<std::uint32_t> liveTriangleCount, neighborPosition, neighbors;
buildAdjacency(liveTriangleCount, neighborPosition, neighbors);
/* Global time, per-vertex caching timestamps, per-triangle emmited flag */
uint32_t time = cacheSize+1;
std::vector<uint32_t> timestamp(vertexCount);
std::uint32_t time = cacheSize+1;
std::vector<std::uint32_t> timestamp(vertexCount);
std::vector<bool> emitted(indices.size()/3);
/* Dead-end vertex stack */
std::stack<uint32_t> deadEndStack;
std::stack<std::uint32_t> deadEndStack;
/* Output index buffer */
std::vector<uint32_t> outputIndices;
std::vector<std::uint32_t> 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<uint32_t> candidates;
std::vector<std::uint32_t> 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<uint32_t>& liveTriangleCount, std::vector<uint32_t>& neighborOffset, std::vector<uint32_t>& neighbors) const {
void Tipsify::buildAdjacency(std::vector<std::uint32_t>& liveTriangleCount, std::vector<std::uint32_t>& neighborOffset, std::vector<std::uint32_t>& 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<uint32_t>& 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<uint32_t>& 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;
}

10
src/Physics/ObjectShape.cpp

@ -20,23 +20,21 @@
#include "AbstractShape.h"
#include "ObjectShapeGroup.h"
using namespace std;
namespace Magnum { namespace Physics {
template<uint8_t dimensions> ObjectShape<dimensions>::ObjectShape(SceneGraph::AbstractObject<dimensions>* object, ObjectShapeGroup<dimensions>* group): SceneGraph::AbstractGroupedFeature<dimensions, ObjectShape<dimensions>>(object, group), _shape(nullptr) {
template<std::uint8_t dimensions> ObjectShape<dimensions>::ObjectShape(SceneGraph::AbstractObject<dimensions>* object, ObjectShapeGroup<dimensions>* group): SceneGraph::AbstractGroupedFeature<dimensions, ObjectShape<dimensions>>(object, group), _shape(nullptr) {
this->setCachedTransformations(SceneGraph::AbstractFeature<dimensions>::CachedTransformation::Absolute);
}
template<uint8_t dimensions> ObjectShape<dimensions>::~ObjectShape() {
template<std::uint8_t dimensions> ObjectShape<dimensions>::~ObjectShape() {
delete _shape;
}
template<uint8_t dimensions> void ObjectShape<dimensions>::markDirty() {
template<std::uint8_t dimensions> void ObjectShape<dimensions>::markDirty() {
group()->setDirty();
}
template<uint8_t dimensions> void ObjectShape<dimensions>::clean(const typename DimensionTraits<dimensions>::MatrixType& absoluteTransformationMatrix) {
template<std::uint8_t dimensions> void ObjectShape<dimensions>::clean(const typename DimensionTraits<dimensions>::MatrixType& absoluteTransformationMatrix) {
if(_shape) _shape->applyTransformationMatrix(absoluteTransformationMatrix);
}

3
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<float>::infinity() && t != -numeric_limits<float>::infinity());
return t != t || (t != std::numeric_limits<float>::infinity() && t != -std::numeric_limits<float>::infinity());
}
bool Plane::operator%(const LineSegment3D& other) const {

4
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)));

4
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<Display*, VisualID, Window>* contextHandler, int&, char**, const string& title, const Vector2i& size): contextHandler(contextHandler), viewportSize(size), flags(Flag::Redraw) {
AbstractXApplication::AbstractXApplication(AbstractContextHandler<Display*, VisualID, Window>* contextHandler, int&, char**, const std::string& title, const Vector2i& size): contextHandler(contextHandler), viewportSize(size), flags(Flag::Redraw) {
/* Get default X display */
display = XOpenDisplay(0);

14
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 */

2
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<void>(experimentalFeatures); /* Shut up about unused parameter */

6
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);
}
}

8
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<NaClApplication*>(applicationInstance);
instance->flags |= Flag::MouseLocked;
}

4
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);

52
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<uint32_t>, {new vector<Point3D>()}, {new vector<Vector3>()}, textureCoords == TextureCoords::Generate ? vector<vector<Vector2>*>{new vector<Vector2>()} : vector<vector<Vector2>*>()), 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<std::uint32_t>, {new std::vector<Point3D>()}, {new std::vector<Vector3>()}, textureCoords == TextureCoords::Generate ? std::vector<std::vector<Vector2>*>{new std::vector<Vector2>()} : std::vector<std::vector<Vector2>*>()), 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<uint32_t>, {new std::vector<Point3D>()}, {new std::vector<Vector3>()}, textureCoords == TextureCoords::Generate ? std::vector<std::vector<Vector2>*>{new std::vector<Vector2>()} : std::vector<std::vector<Vector2>*>()), segments(segments), textureCoords(textureCoords) {}
Capsule::Capsule(std::uint32_t segments, TextureCoords textureCoords): MeshData3D("", Mesh::Primitive::Triangles, new std::vector<std::uint32_t>, {new std::vector<Point3D>()}, {new std::vector<Vector3>()}, textureCoords == TextureCoords::Generate ? std::vector<std::vector<Vector2>*>{new std::vector<Vector2>()} : std::vector<std::vector<Vector2>*>()), 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);

6
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<Point3D>{
Cube::Cube(): MeshData3D("", Mesh::Primitive::Triangles, nullptr, {new std::vector<Point3D>{
{-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<Po
{-1.0f, -1.0f, -1.0f},
{-1.0f, 1.0f, 1.0f},
{-1.0f, 1.0f, -1.0f}
}}, {new vector<Vector3>{
}}, {new std::vector<Vector3>{
{ 0.0f, 0.0f, 1.0f},
{ 0.0f, 0.0f, 1.0f},
{ 0.0f, 0.0f, 1.0f}, /* +Z */

8
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)

6
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<uint32_t>{
Icosphere<0>::Icosphere(): MeshData3D("", Mesh::Primitive::Triangles, new std::vector<std::uint32_t>{
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<Point3D>}, {new vector<Vector3>{
}, {new std::vector<Point3D>}, {new std::vector<Vector3>{
Vector3(0, -0.525731f, 0.850651f),
Vector3(0.850651f, 0, 0.525731f),
Vector3(0.850651f, 0, -0.525731f),

6
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<Point3D>{
Plane::Plane(): MeshData3D("", Mesh::Primitive::TriangleStrip, nullptr, {new std::vector<Point3D>{
{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<Vector3>{
}}, {new std::vector<Vector3>{
{0.0f, 0.0f, 1.0f},
{0.0f, 0.0f, 1.0f},
{0.0f, 0.0f, 1.0f},

4
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<Point2D>{
Square::Square(): MeshData2D("", Mesh::Primitive::TriangleStrip, nullptr, {new std::vector<Point2D>{
{1.0f, -1.0f},
{1.0f, 1.0f},
{-1.0f, -1.0f},

13
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<Point3D>{
CORRADE_COMPARE_AS(*capsule.positions(0), (std::vector<Point3D>{
{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<Vector3>{
CORRADE_COMPARE_AS(*capsule.normals(0), (std::vector<Vector3>{
{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<uint32_t>{
CORRADE_COMPARE_AS(*capsule.indices(), (std::vector<std::uint32_t>{
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<Point3D>{
CORRADE_COMPARE_AS(*capsule.positions(0), (std::vector<Point3D>{
{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<Vector2>{
CORRADE_COMPARE_AS(*capsule.textureCoords2D(0), (std::vector<Vector2>{
{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<uint32_t>{
CORRADE_COMPARE_AS(*capsule.indices(), (std::vector<std::uint32_t>{
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,

15
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<Point3D>{
CORRADE_COMPARE_AS(*cylinder.positions(0), (std::vector<Point3D>{
{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<Vector3>{
CORRADE_COMPARE_AS(*cylinder.normals(0), (std::vector<Vector3>{
{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<uint32_t>{
CORRADE_COMPARE_AS(*cylinder.indices(), (std::vector<std::uint32_t>{
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<Point3D>{
CORRADE_COMPARE_AS(*cylinder.positions(0), (std::vector<Point3D>{
{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<Vector3>{
CORRADE_COMPARE_AS(*cylinder.normals(0), (std::vector<Vector3>{
{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<Vector2>{
CORRADE_COMPARE_AS(*cylinder.textureCoords2D(0), (std::vector<Vector2>{
{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<uint32_t>{
CORRADE_COMPARE_AS(*cylinder.indices(), (std::vector<std::uint32_t>{
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,

13
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<Point3D>{
CORRADE_COMPARE_AS(*sphere.positions(0), (std::vector<Point3D>{
{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<Vector3>{
CORRADE_COMPARE_AS(*sphere.normals(0), (std::vector<Vector3>{
{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<uint32_t>{
CORRADE_COMPARE_AS(*sphere.indices(), (std::vector<std::uint32_t>{
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<Point3D>{
CORRADE_COMPARE_AS(*sphere.positions(0), (std::vector<Point3D>{
{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<Vector2>{
CORRADE_COMPARE_AS(*sphere.textureCoords2D(0), (std::vector<Vector2>{
{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<uint32_t>{
CORRADE_COMPARE_AS(*sphere.indices(), (std::vector<std::uint32_t>{
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

6
src/Primitives/UVSphere.cpp

@ -15,15 +15,11 @@
#include "UVSphere.h"
#include <Utility/Debug.h>
#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;

36
src/Profiler.cpp

@ -19,25 +19,25 @@
#include <numeric>
#include <Utility/Assert.h>
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<size_t> totalSorted(sections.size());
iota(totalSorted.begin(), totalSorted.end(), 0);
std::vector<std::size_t> 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";
}
}

26
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<Object3D*>(), initial), vector<Matrix4>());
CORRADE_COMPARE(s.transformations(std::vector<Object3D*>(), initial), std::vector<Matrix4>());
/* Scene alone */
CORRADE_COMPARE(s.transformations({&s}, initial), vector<Matrix4>{initial});
CORRADE_COMPARE(s.transformations({&s}, initial), std::vector<Matrix4>{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<Matrix4>{
CORRADE_COMPARE(s.transformations({&second}, initial), std::vector<Matrix4>{
initial*Matrix4::rotationZ(deg(30.0f))*Matrix4::scaling(Vector3(0.5f))
});
/* One object and scene */
CORRADE_COMPARE(s.transformations({&second, &s}, initial), (vector<Matrix4>{
CORRADE_COMPARE(s.transformations({&second, &s}, initial), (std::vector<Matrix4>{
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<Matrix4>{
CORRADE_COMPARE(s.transformations({&second, &third}, initial), (std::vector<Matrix4>{
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<Matrix4>{
CORRADE_COMPARE(s.transformations({&second, &third, &first}, initial), (std::vector<Matrix4>{
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<Matrix4>{
CORRADE_COMPARE(second.transformations({&third}), std::vector<Matrix4>{
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<Matrix4>{
CORRADE_COMPARE(orphan1.transformations({&orphan2}), std::vector<Matrix4>{
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<Matrix4>());
CORRADE_COMPARE(s.transformations({&orphan}), std::vector<Matrix4>());
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*>());
Object3D::setClean(std::vector<Object3D*>());
Scene3D scene;
Object3D a(&scene);
@ -294,7 +292,7 @@ void ObjectTest::bulkSetClean() {
CachingObject d(&c);
d.scale(Vector3(-2.0f));
Object3D e(&scene);
vector<Object3D*> cleanAll{&a, &b, &c, &d, &e};
std::vector<Object3D*> cleanAll{&a, &b, &c, &d, &e};
/* All objects should be cleaned */
CORRADE_VERIFY(a.isDirty());

12
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<const GLchar*>(sources[i].c_str());
/* Create shader and set its source */

20
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<uint8_t> Color3;
typedef Magnum::Color4<uint8_t> Color4;
typedef Magnum::Color3<std::uint8_t> Color3;
typedef Magnum::Color4<std::uint8_t> Color4;
typedef Magnum::Color3<float> Color3f;
typedef Magnum::Color4<float> 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<std::string>("color3"), value3);
CORRADE_COMPARE(c.value("color3"), value3);
CORRADE_COMPARE(c.value<Color3f>("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<std::string>("color4"), value4);
CORRADE_COMPARE(c.value("color4"), value4);
CORRADE_COMPARE(c.value<Color4f>("color4"), color4);
}

21
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<int32_t, Data> ResourceManager;
typedef Magnum::ResourceManager<std::int32_t, Data> ResourceManager;
class IntResourceLoader: public AbstractResourceLoader<std::int32_t> {
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<int32_t> theQuestion = rm.get<int32_t>(questionKey);
Resource<int32_t> theAnswer = rm.get<int32_t>(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<std::int32_t> theQuestion = rm.get<std::int32_t>(questionKey);
Resource<std::int32_t> theAnswer = rm.get<std::int32_t>(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<int32_t>(), 2);
CORRADE_COMPARE(rm.count<std::int32_t>(), 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);
}

40
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<bool, swizzled.x() == 2>::value));
CORRADE_VERIFY((std::integral_constant<bool, swizzled.x() == 2>::value));
CORRADE_COMPARE((swizzle<'g', 'x', 'r'>(orig)), Vector3i(2, 1, 1));
}
void SwizzleTest::type() {
Vector4i orig;
CORRADE_VERIFY((is_same<decltype(swizzle<'y', 'a'>(orig)), Vector2i>::value));
CORRADE_VERIFY((is_same<decltype(swizzle(orig, "ya")), Vector2i>::value));
CORRADE_VERIFY((is_same<decltype(swizzle<'y', 'z', 'a'>(orig)), Vector3i>::value));
CORRADE_VERIFY((is_same<decltype(swizzle(orig, "yza")), Vector3i>::value));
CORRADE_VERIFY((is_same<decltype(swizzle<'y', 'a', 'y', 'x'>(orig)), Vector4i>::value));
CORRADE_VERIFY((is_same<decltype(swizzle(orig, "yayx")), Vector4i>::value));
CORRADE_VERIFY((std::is_same<decltype(swizzle<'y', 'a'>(orig)), Vector2i>::value));
CORRADE_VERIFY((std::is_same<decltype(swizzle(orig, "ya")), Vector2i>::value));
CORRADE_VERIFY((std::is_same<decltype(swizzle<'y', 'z', 'a'>(orig)), Vector3i>::value));
CORRADE_VERIFY((std::is_same<decltype(swizzle(orig, "yza")), Vector3i>::value));
CORRADE_VERIFY((std::is_same<decltype(swizzle<'y', 'a', 'y', 'x'>(orig)), Vector4i>::value));
CORRADE_VERIFY((std::is_same<decltype(swizzle(orig, "yayx")), Vector4i>::value));
Color3<float> origColor3;
Color4<double> origColor4;
CORRADE_VERIFY((is_same<decltype(swizzle<'y', 'z', 'r'>(origColor3)), Color3<float>>::value));
CORRADE_VERIFY((is_same<decltype(swizzle<'y', 'z', 'a'>(origColor4)), Color3<double>>::value));
CORRADE_VERIFY((is_same<decltype(swizzle(origColor3, "yzr")), Color3<float>>::value));
CORRADE_VERIFY((is_same<decltype(swizzle(origColor4, "yza")), Color3<double>>::value));
CORRADE_VERIFY((is_same<decltype(swizzle<'y', 'z', 'y', 'x'>(origColor3)), Color4<float>>::value));
CORRADE_VERIFY((is_same<decltype(swizzle<'y', 'a', 'y', 'x'>(origColor4)), Color4<double>>::value));
CORRADE_VERIFY((is_same<decltype(swizzle(origColor3, "yzyx")), Color4<float>>::value));
CORRADE_VERIFY((is_same<decltype(swizzle(origColor4, "yayx")), Color4<double>>::value));
CORRADE_VERIFY((std::is_same<decltype(swizzle<'y', 'z', 'r'>(origColor3)), Color3<>>::value));
CORRADE_VERIFY((std::is_same<decltype(swizzle<'y', 'z', 'a'>(origColor4)), Color3<double>>::value));
CORRADE_VERIFY((std::is_same<decltype(swizzle(origColor3, "yzr")), Color3<>>::value));
CORRADE_VERIFY((std::is_same<decltype(swizzle(origColor4, "yza")), Color3<double>>::value));
CORRADE_VERIFY((std::is_same<decltype(swizzle<'y', 'z', 'y', 'x'>(origColor3)), Color4<>>::value));
CORRADE_VERIFY((std::is_same<decltype(swizzle<'y', 'a', 'y', 'x'>(origColor4)), Color4<double>>::value));
CORRADE_VERIFY((std::is_same<decltype(swizzle(origColor3, "yzyx")), Color4<>>::value));
CORRADE_VERIFY((std::is_same<decltype(swizzle(origColor4, "yayx")), Color4<double>>::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)));
}
}}

1
src/Trade/AbstractImporter.cpp

@ -17,7 +17,6 @@
#include <Utility/Debug.h>
using namespace std;
using namespace Corrade::Utility;
namespace Magnum { namespace Trade {

22
src/TypeTraits.cpp

@ -18,25 +18,23 @@
#include <type_traits>
#include <Utility/Debug.h>
using namespace std;
namespace Magnum {
#ifndef DOXYGEN_GENERATING_OUTPUT
static_assert(is_same<GLubyte, uint8_t>::value, "GLubyte is not the same as uint8_t");
static_assert(is_same<GLbyte, int8_t>::value, "GLbyte is not the same as int8_t");
static_assert(is_same<GLushort, uint16_t>::value, "GLushort is not the same as uint16_t");
static_assert(is_same<GLshort, int16_t>::value, "GLshort is not the same as int16_t");
static_assert(is_same<GLuint, uint32_t>::value, "GLuint is not the same as uint32_t");
static_assert(is_same<GLint, int32_t>::value, "GLint is not the same as int32_t");
static_assert(is_same<GLsizei, int32_t>::value, "GLsizei is not the same as int32_t");
static_assert(is_same<GLfloat, float>::value, "GLfloat is not the same as float");
static_assert(std::is_same<GLubyte, std::uint8_t>::value, "GLubyte is not the same as std::uint8_t");
static_assert(std::is_same<GLbyte, std::int8_t>::value, "GLbyte is not the same as std::int8_t");
static_assert(std::is_same<GLushort, std::uint16_t>::value, "GLushort is not the same as std::uint16_t");
static_assert(std::is_same<GLshort, std::int16_t>::value, "GLshort is not the same as std::int16_t");
static_assert(std::is_same<GLuint, std::uint32_t>::value, "GLuint is not the same as std::uint32_t");
static_assert(std::is_same<GLint, std::int32_t>::value, "GLint is not the same as std::int32_t");
static_assert(std::is_same<GLsizei, std::int32_t>::value, "GLsizei is not the same as std::int32_t");
static_assert(std::is_same<GLfloat, float>::value, "GLfloat is not the same as float");
#ifndef MAGNUM_TARGET_GLES
static_assert(is_same<GLdouble, double>::value, "GLdouble is not the same as double");
static_assert(std::is_same<GLdouble, double>::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<TypeOf<Type::type>::Type>::size();
val(UnsignedByte)

Loading…
Cancel
Save