Browse Source

Don't restrict Double usage on OpenGL ES.

Restrict only what's not defined by GL on the ES flavor (double
attributes and uniforms). I love the smell of burning code.
pull/162/merge
Vladimír Vondruš 10 years ago
parent
commit
eaeda24399
  1. 2
      src/Magnum/Audio/Audio.cpp
  2. 4
      src/Magnum/DimensionTraits.h
  3. 7
      src/Magnum/Magnum.h
  4. 2
      src/Magnum/Math/Algorithms/Svd.h
  5. 8
      src/Magnum/Math/Algorithms/Test/SvdTest.cpp
  6. 8
      src/Magnum/Math/Angle.h
  7. 2
      src/Magnum/Math/Complex.h
  8. 6
      src/Magnum/Math/Constants.h
  9. 2
      src/Magnum/Math/DualComplex.h
  10. 2
      src/Magnum/Math/DualQuaternion.h
  11. 2
      src/Magnum/Math/Quaternion.h
  12. 2
      src/Magnum/Math/Range.h
  13. 8
      src/Magnum/Math/RectangularMatrix.h
  14. 28
      src/Magnum/Math/Test/AngleTest.cpp
  15. 4
      src/Magnum/Math/Test/ConstantsTest.cpp
  16. 10
      src/Magnum/Math/Test/FunctionsTest.cpp
  17. 13
      src/Magnum/Math/Test/TypeTraitsTest.cpp
  18. 10
      src/Magnum/Math/TypeTraits.h
  19. 4
      src/Magnum/Math/Vector.h
  20. 31
      src/Magnum/Math/instantiation.cpp
  21. 2
      src/Magnum/Types.h

2
src/Magnum/Audio/Audio.cpp

@ -42,9 +42,7 @@ static_assert(std::is_same<ALuint, UnsignedInt>::value, "ALuint is not the same
static_assert(std::is_same<ALint, Int>::value, "ALint is not the same as Int");
static_assert(std::is_same<ALsizei, Int>::value, "ALsizei is not the same as Int");
static_assert(std::is_same<ALfloat, Float>::value, "ALfloat is not the same as Float");
#ifndef MAGNUM_TARGET_GLES
static_assert(std::is_same<ALdouble, Double>::value, "ALdouble is not the same as Double");
#endif
/* Verify boolean values */
static_assert(AL_FALSE == false, "AL_FALSE is not the same as false");

4
src/Magnum/DimensionTraits.h

@ -118,7 +118,6 @@ template<> struct DimensionTraits<2, Float> {
typedef Math::Range2D<Float> RangeType;
typedef Math::Matrix3<Float> MatrixType;
};
#ifndef MAGNUM_TARGET_GLES
template<> struct DimensionTraits<2, Double> {
DimensionTraits() = delete;
@ -126,7 +125,6 @@ template<> struct DimensionTraits<2, Double> {
typedef Math::Range2D<Double> RangeType;
typedef Math::Matrix3<Double> MatrixType;
};
#endif
/* Three dimensions - integral */
template<class T> struct DimensionTraits<3, T> {
@ -144,7 +142,6 @@ template<> struct DimensionTraits<3, Float> {
typedef Math::Range3D<Float> RangeType;
typedef Math::Matrix4<Float> MatrixType;
};
#ifndef MAGNUM_TARGET_GLES
template<> struct DimensionTraits<3, Double> {
DimensionTraits() = delete;
@ -153,7 +150,6 @@ template<> struct DimensionTraits<3, Double> {
typedef Math::Matrix4<Double> MatrixType;
};
#endif
#endif
}

7
src/Magnum/Magnum.h

@ -50,10 +50,8 @@ namespace Math {
#ifdef MAGNUM_BUILD_DEPRECATED
namespace Literals {
#ifndef MAGNUM_TARGET_GLES
constexpr Rad<Double> operator "" _rad(long double);
constexpr Deg<Double> operator "" _deg(long double);
#endif
constexpr Rad<Float> operator "" _radf(long double);
constexpr Deg<Float> operator "" _degf(long double);
}
@ -345,11 +343,9 @@ typedef Math::Range3D<Int> Range3Di;
/*@}*/
#ifndef MAGNUM_TARGET_GLES
/** @{ @name Double-precision types
See @ref types for more information.
@requires_gl Only single-precision types are available in OpenGL ES and WebGL.
*/
/** @brief Double (64bit) */
@ -446,13 +442,10 @@ typedef Math::Range2D<Double> Range2Dd;
typedef Math::Range3D<Double> Range3Dd;
/*@}*/
#endif
#ifdef MAGNUM_BUILD_DEPRECATED
#ifndef MAGNUM_TARGET_GLES
using Math::Literals::operator "" _deg;
using Math::Literals::operator "" _rad;
#endif
using Math::Literals::operator "" _degf;
using Math::Literals::operator "" _radf;
#endif

2
src/Magnum/Math/Algorithms/Svd.h

@ -51,9 +51,7 @@ template<class T> T pythagoras(T a, T b) {
template<class T> constexpr T smallestDelta();
template<> constexpr Float smallestDelta<Float>() { return 1.0e-32f; }
#ifndef MAGNUM_TARGET_GLES
template<> constexpr Double smallestDelta<Double>() { return 1.0e-64; }
#endif
}

8
src/Magnum/Math/Algorithms/Test/SvdTest.cpp

@ -36,13 +36,11 @@ struct SvdTest: Corrade::TestSuite::Tester {
void testFloat();
};
#ifndef MAGNUM_TARGET_GLES
typedef RectangularMatrix<5, 8, Double> Matrix5x8d;
typedef Matrix<8, Double> Matrix8d;
typedef Matrix<5, Double> Matrix5d;
typedef Vector<8, Double> Vector8d;
typedef Vector<5, Double> Vector5d;
#endif
typedef RectangularMatrix<5, 8, Float> Matrix5x8f;
typedef Matrix<8, Float> Matrix8f;
@ -50,7 +48,6 @@ typedef Matrix<5, Float> Matrix5f;
typedef Vector<8, Float> Vector8f;
typedef Vector<5, Float> Vector5f;
#ifndef MAGNUM_TARGET_GLES
constexpr static Matrix5x8d ad(
Vector8d(22.0, 14.0, -1.0, -3.0, 9.0, 9.0, 2.0, 4.0),
Vector8d(10.0, 7.0, 13.0, -2.0, 8.0, 1.0, -6.0, 5.0),
@ -59,7 +56,6 @@ constexpr static Matrix5x8d ad(
Vector8d( 7.0, 8.0, 3.0, 4.0, 4.0, -1.0, 1.0, 2.0)
);
static const Vector5d expectedd(std::sqrt(1248.0), 0.0, 20.0, std::sqrt(384.0), 0.0);
#endif
constexpr static Matrix5x8f af(
Vector8f(22.0f, 14.0f, -1.0f, -3.0f, 9.0f, 9.0f, 2.0f, 4.0f),
@ -76,7 +72,6 @@ SvdTest::SvdTest() {
}
void SvdTest::testDouble() {
#ifndef MAGNUM_TARGET_GLES
Matrix5x8d u;
Vector5d w;
Matrix5d v;
@ -93,9 +88,6 @@ void SvdTest::testDouble() {
/* Test W */
CORRADE_COMPARE(w, expectedd);
#else
CORRADE_SKIP("Double precision is not supported when targeting OpenGL ES.");
#endif
}
void SvdTest::testFloat() {

8
src/Magnum/Math/Angle.h

@ -155,7 +155,6 @@ template<class T> class Deg: public Unit<Deg, T> {
namespace Literals {
#ifndef MAGNUM_TARGET_GLES
/** @relatesalso Magnum::Math::Deg
@brief Double-precision degree value literal
@ -165,10 +164,8 @@ Double cosine = Math::cos(60.0_deg); // cosine = 0.5
Double cosine = Math::cos(1.047_rad); // cosine = 0.5
@endcode
@see @link operator""_degf() @endlink, @link operator""_rad() @endlink
@requires_gl Only single-precision types are available in OpenGL ES and WebGL.
*/
constexpr Deg<Double> operator "" _deg(long double value) { return Deg<Double>(Double(value)); }
#endif
/** @relatesalso Magnum::Math::Deg
@brief Single-precision degree value literal
@ -222,16 +219,13 @@ template<class T> class Rad: public Unit<Rad, T> {
namespace Literals {
#ifndef MAGNUM_TARGET_GLES
/** @relatesalso Magnum::Math::Rad
@brief Double-precision radian value literal
See @link operator""_deg() @endlink for more information.
@see @link operator""_radf() @endlink
@requires_gl Only single-precision types are available in OpenGL ES and WebGL.
*/
constexpr Rad<Double> operator "" _rad(long double value) { return Rad<Double>(Double(value)); }
#endif
/** @relatesalso Magnum::Math::Rad
@brief Single-precision radian value literal
@ -260,11 +254,9 @@ template<class T> Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug& d
#ifndef DOXYGEN_GENERATING_OUTPUT
extern template MAGNUM_EXPORT Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const Unit<Rad, Float>&);
extern template MAGNUM_EXPORT Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const Unit<Deg, Float>&);
#ifndef MAGNUM_TARGET_GLES
extern template MAGNUM_EXPORT Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const Unit<Rad, Double>&);
extern template MAGNUM_EXPORT Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const Unit<Deg, Double>&);
#endif
#endif
}}

2
src/Magnum/Math/Complex.h

@ -490,10 +490,8 @@ template<class T> Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug& d
/* Explicit instantiation for commonly used types */
#ifndef DOXYGEN_GENERATING_OUTPUT
extern template MAGNUM_EXPORT Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const Complex<Float>&);
#ifndef MAGNUM_TARGET_GLES
extern template MAGNUM_EXPORT Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const Complex<Double>&);
#endif
#endif
}}

6
src/Magnum/Math/Constants.h

@ -30,11 +30,7 @@
*/
#include <cmath>
#include "Magnum/configure.h"
#ifndef MAGNUM_TARGET_GLES
#include <limits>
#endif
#include "Magnum/Types.h"
@ -83,7 +79,6 @@ template<class T> struct Constants {
};
#ifndef DOXYGEN_GENERATING_OUTPUT
#ifndef MAGNUM_TARGET_GLES
template<> struct Constants<Double> {
Constants() = delete;
@ -97,7 +92,6 @@ template<> struct Constants<Double> {
static constexpr Double nan() { return std::numeric_limits<Double>::quiet_NaN(); }
static constexpr Double inf() { return std::numeric_limits<Double>::infinity(); }
};
#endif
template<> struct Constants<Float> {
Constants() = delete;

2
src/Magnum/Math/DualComplex.h

@ -367,10 +367,8 @@ template<class T> Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug& d
/* Explicit instantiation for commonly used types */
#ifndef DOXYGEN_GENERATING_OUTPUT
extern template MAGNUM_EXPORT Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const DualComplex<Float>&);
#ifndef MAGNUM_TARGET_GLES
extern template MAGNUM_EXPORT Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const DualComplex<Double>&);
#endif
#endif
}}

2
src/Magnum/Math/DualQuaternion.h

@ -448,10 +448,8 @@ template<class T> Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug& d
/* Explicit instantiation for commonly used types */
#ifndef DOXYGEN_GENERATING_OUTPUT
extern template MAGNUM_EXPORT Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const DualQuaternion<Float>&);
#ifndef MAGNUM_TARGET_GLES
extern template MAGNUM_EXPORT Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const DualQuaternion<Double>&);
#endif
#endif
}}

2
src/Magnum/Math/Quaternion.h

@ -554,10 +554,8 @@ template<class T> Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug& d
/* Explicit instantiation for commonly used types */
#ifndef DOXYGEN_GENERATING_OUTPUT
extern template MAGNUM_EXPORT Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const Quaternion<Float>&);
#ifndef MAGNUM_TARGET_GLES
extern template MAGNUM_EXPORT Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const Quaternion<Double>&);
#endif
#endif
namespace Implementation {

2
src/Magnum/Math/Range.h

@ -598,11 +598,9 @@ extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Range<2, M
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Range<2, Magnum::Int>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Range<3, Magnum::Float>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Range<3, Magnum::Int>>;
#ifndef MAGNUM_TARGET_GLES
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Range<2, Magnum::Double>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Range<3, Magnum::Double>>;
#endif
#endif
}}

8
src/Magnum/Math/RectangularMatrix.h

@ -524,11 +524,9 @@ template<std::size_t cols, std::size_t rows, class T> Corrade::Utility::Debug& o
extern template MAGNUM_EXPORT Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const RectangularMatrix<2, 2, Float>&);
extern template MAGNUM_EXPORT Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const RectangularMatrix<3, 3, Float>&);
extern template MAGNUM_EXPORT Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const RectangularMatrix<4, 4, Float>&);
#ifndef MAGNUM_TARGET_GLES
extern template MAGNUM_EXPORT Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const RectangularMatrix<2, 2, Double>&);
extern template MAGNUM_EXPORT Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const RectangularMatrix<3, 3, Double>&);
extern template MAGNUM_EXPORT Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const RectangularMatrix<4, 4, Double>&);
#endif
/* Rectangular matrices */
extern template MAGNUM_EXPORT Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const RectangularMatrix<2, 3, Float>&);
@ -537,14 +535,12 @@ extern template MAGNUM_EXPORT Corrade::Utility::Debug& operator<<(Corrade::Utili
extern template MAGNUM_EXPORT Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const RectangularMatrix<4, 2, Float>&);
extern template MAGNUM_EXPORT Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const RectangularMatrix<3, 4, Float>&);
extern template MAGNUM_EXPORT Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const RectangularMatrix<4, 3, Float>&);
#ifndef MAGNUM_TARGET_GLES
extern template MAGNUM_EXPORT Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const RectangularMatrix<2, 3, Double>&);
extern template MAGNUM_EXPORT Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const RectangularMatrix<3, 2, Double>&);
extern template MAGNUM_EXPORT Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const RectangularMatrix<2, 4, Double>&);
extern template MAGNUM_EXPORT Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const RectangularMatrix<4, 2, Double>&);
extern template MAGNUM_EXPORT Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const RectangularMatrix<3, 4, Double>&);
extern template MAGNUM_EXPORT Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const RectangularMatrix<4, 3, Double>&);
#endif
#define MAGNUM_RECTANGULARMATRIX_SUBCLASS_IMPLEMENTATION(cols, rows, ...) \
static __VA_ARGS__& from(T* data) { \
@ -718,11 +714,9 @@ template<std::size_t cols, std::size_t rows, class T> struct ConfigurationValue<
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<2, 2, Magnum::Float>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<3, 3, Magnum::Float>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<4, 4, Magnum::Float>>;
#ifndef MAGNUM_TARGET_GLES
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<2, 2, Magnum::Double>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<3, 3, Magnum::Double>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<4, 4, Magnum::Double>>;
#endif
/* Rectangular matrices */
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<2, 3, Magnum::Float>>;
@ -731,7 +725,6 @@ extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Rectangula
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<4, 2, Magnum::Float>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<3, 4, Magnum::Float>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<4, 3, Magnum::Float>>;
#ifndef MAGNUM_TARGET_GLES
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<2, 3, Magnum::Double>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<3, 2, Magnum::Double>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<2, 4, Magnum::Double>>;
@ -739,7 +732,6 @@ extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Rectangula
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<3, 4, Magnum::Double>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<4, 3, Magnum::Double>>;
#endif
#endif
}}

28
src/Magnum/Math/Test/AngleTest.cpp

@ -47,10 +47,8 @@ struct AngleTest: Corrade::TestSuite::Tester {
typedef Math::Deg<Float> Deg;
typedef Math::Rad<Float> Rad;
#ifndef MAGNUM_TARGET_GLES
typedef Math::Deg<Double> Degd;
typedef Math::Rad<Double> Radd;
#endif
AngleTest::AngleTest() {
addTests({&AngleTest::construct,
@ -70,50 +68,28 @@ void AngleTest::construct() {
constexpr Deg m2{ZeroInit};
CORRADE_COMPARE(Float(m1), 0.0f);
CORRADE_COMPARE(Float(m2), 0.0f);
#ifndef MAGNUM_TARGET_GLES
constexpr Radd a1;
constexpr Radd a2{ZeroInit};
CORRADE_COMPARE(Double(a1), 0.0);
CORRADE_COMPARE(Double(a2), 0.0);
#else
constexpr Rad a1;
constexpr Rad a2{ZeroInit};
CORRADE_COMPARE(Float(a1), 0.0f);
CORRADE_COMPARE(Float(a2), 0.0f);
#endif
/* Value constructor */
constexpr Deg b(25.0);
CORRADE_COMPARE(Float(b), 25.0f);
#ifndef MAGNUM_TARGET_GLES
constexpr Radd n(3.14);
CORRADE_COMPARE(Double(n), 3.14);
#else
constexpr Rad n(3.14);
CORRADE_COMPARE(Float(n), 3.14f);
#endif
/* Copy constructor */
constexpr Deg c(b);
CORRADE_COMPARE(c, b);
#ifndef MAGNUM_TARGET_GLES
constexpr Radd o(n);
CORRADE_COMPARE(o, n);
#else
constexpr Rad o(n);
CORRADE_COMPARE(o, n);
#endif
/* Conversion operator */
constexpr Rad p(n);
CORRADE_COMPARE(Float(p), 3.14f);
#ifndef MAGNUM_TARGET_GLES
constexpr Degd d(b);
CORRADE_COMPARE(Double(d), 25.0);
#else
constexpr Deg d(b);
CORRADE_COMPARE(Float(d), 25.0f);
#endif
}
void AngleTest::constructNoInit() {
@ -128,20 +104,16 @@ void AngleTest::constructNoInit() {
void AngleTest::literals() {
using namespace Literals;
#ifndef MAGNUM_TARGET_GLES
constexpr auto a = 25.0_deg;
CORRADE_VERIFY((std::is_same<decltype(a), const Degd>::value));
CORRADE_COMPARE(Double(a), 25.0);
#endif
constexpr auto b = 25.0_degf;
CORRADE_VERIFY((std::is_same<decltype(b), const Deg>::value));
CORRADE_COMPARE(Float(b), 25.0f);
#ifndef MAGNUM_TARGET_GLES
constexpr auto m = 3.14_rad;
CORRADE_VERIFY((std::is_same<decltype(m), const Radd>::value));
CORRADE_COMPARE(Double(m), 3.14);
#endif
constexpr auto n = 3.14_radf;
CORRADE_VERIFY((std::is_same<decltype(n), const Rad>::value));
CORRADE_COMPARE(Float(n), 3.14f);

4
src/Magnum/Math/Test/ConstantsTest.cpp

@ -49,16 +49,12 @@ ConstantsTest::ConstantsTest() {
void ConstantsTest::constants() {
_constants<Float>();
#ifndef MAGNUM_TARGET_GLES
_constants<Double>();
#endif
}
void ConstantsTest::specials() {
_specials<Float>();
#ifndef MAGNUM_TARGET_GLES
_specials<Double>();
#endif
}
template<class T> void ConstantsTest::_constants() {

10
src/Magnum/Math/Test/FunctionsTest.cpp

@ -277,10 +277,10 @@ void FunctionsTest::normalizeUnsigned() {
CORRADE_COMPARE((Math::normalize<Float, UnsignedByte>(0)), 0.0f);
CORRADE_COMPARE((Math::normalize<Float, UnsignedByte>(255)), 1.0f);
#ifndef MAGNUM_TARGET_GLES
CORRADE_COMPARE((Math::normalize<Double, UnsignedInt>(0)), 0.0);
CORRADE_COMPARE((Math::normalize<Double, UnsignedInt>(std::numeric_limits<UnsignedInt>::max())), 1.0);
#ifndef MAGNUM_TARGET_WEBGL
CORRADE_COMPARE((Math::normalize<long double, UnsignedLong>(0)), 0.0);
CORRADE_COMPARE((Math::normalize<long double, UnsignedLong>(std::numeric_limits<UnsignedLong>::max())), 1.0);
#endif
@ -303,11 +303,11 @@ void FunctionsTest::normalizeSigned() {
CORRADE_COMPARE((Math::normalize<Float, Short>(0)), 0.0f);
CORRADE_COMPARE((Math::normalize<Float, Short>(std::numeric_limits<Short>::max())), 1.0f);
#ifndef MAGNUM_TARGET_GLES
CORRADE_COMPARE((Math::normalize<Double, Int>(std::numeric_limits<Int>::min())), -1.0);
CORRADE_COMPARE((Math::normalize<Double, Int>(0)), 0.0);
CORRADE_COMPARE((Math::normalize<Double, Int>(std::numeric_limits<Int>::max())), 1.0);
#ifndef MAGNUM_TARGET_WEBGL
CORRADE_COMPARE((Math::normalize<long double, Long>(std::numeric_limits<Long>::min())), -1.0);
CORRADE_COMPARE((Math::normalize<long double, Long>(0)), 0.0);
CORRADE_COMPARE((Math::normalize<long double, Long>(std::numeric_limits<Long>::max())), 1.0);
@ -326,10 +326,10 @@ void FunctionsTest::denormalizeUnsigned() {
CORRADE_COMPARE(Math::denormalize<UnsignedShort>(0.0f), 0);
CORRADE_COMPARE(Math::denormalize<UnsignedShort>(1.0f), std::numeric_limits<UnsignedShort>::max());
#ifndef MAGNUM_TARGET_GLES
CORRADE_COMPARE(Math::denormalize<UnsignedInt>(0.0), 0);
CORRADE_COMPARE(Math::denormalize<UnsignedInt>(1.0), std::numeric_limits<UnsignedInt>::max());
#ifndef MAGNUM_TARGET_WEBGL
CORRADE_COMPARE(Math::denormalize<UnsignedLong>(0.0l), 0);
{
#ifdef CORRADE_MSVC2015_COMPATIBILITY
@ -387,10 +387,10 @@ void FunctionsTest::renormalizeUnsinged() {
CORRADE_COMPARE(Math::normalize<Float>(Math::denormalize<UnsignedShort>(0.0f)), 0.0f);
CORRADE_COMPARE(Math::normalize<Float>(Math::denormalize<UnsignedShort>(1.0f)), 1.0f);
#ifndef MAGNUM_TARGET_GLES
CORRADE_COMPARE(Math::normalize<Double>(Math::denormalize<UnsignedInt>(0.0)), 0.0);
CORRADE_COMPARE(Math::normalize<Double>(Math::denormalize<UnsignedInt>(1.0)), 1.0);
#ifndef MAGNUM_TARGET_WEBGL
CORRADE_COMPARE(Math::normalize<long double>(Math::denormalize<UnsignedLong>(0.0l)), 0.0l);
{
#ifdef CORRADE_MSVC2015_COMPATIBILITY
@ -410,11 +410,11 @@ void FunctionsTest::renormalizeSinged() {
CORRADE_COMPARE(Math::normalize<Float>(Math::denormalize<Short>(0.0f)), 0.0f);
CORRADE_COMPARE(Math::normalize<Float>(Math::denormalize<Short>(1.0f)), 1.0f);
#ifndef MAGNUM_TARGET_GLES
CORRADE_COMPARE(Math::normalize<Double>(Math::denormalize<Int>(-1.0)), -1.0);
CORRADE_COMPARE(Math::normalize<Double>(Math::denormalize<Int>(0.0)), 0.0);
CORRADE_COMPARE(Math::normalize<Double>(Math::denormalize<Int>(1.0)), 1.0);
#ifndef MAGNUM_TARGET_WEBGL
CORRADE_COMPARE(Math::normalize<long double>(Math::denormalize<Long>(-1.0l)), -1.0l);
CORRADE_COMPARE(Math::normalize<long double>(Math::denormalize<Long>(0.0l)), 0.0l);
{

13
src/Magnum/Math/Test/TypeTraitsTest.cpp

@ -53,26 +53,15 @@ TypeTraitsTest::TypeTraitsTest() {
&TypeTraitsTest::equalsIntegral<Long>,
#endif
&TypeTraitsTest::equalsFloatingPoint0<Float>,
#ifndef MAGNUM_TARGET_GLES
&TypeTraitsTest::equalsFloatingPoint0<Double>,
#endif
&TypeTraitsTest::equalsFloatingPoint1<Float>,
#ifndef MAGNUM_TARGET_GLES
&TypeTraitsTest::equalsFloatingPoint1<Double>,
#endif
&TypeTraitsTest::equalsFloatingPointLarge<Float>,
#ifndef MAGNUM_TARGET_GLES
&TypeTraitsTest::equalsFloatingPointLarge<Double>,
#endif
&TypeTraitsTest::equalsFloatingPointInfinity<Float>,
#ifndef MAGNUM_TARGET_GLES
&TypeTraitsTest::equalsFloatingPointInfinity<Double>,
#endif
&TypeTraitsTest::equalsFloatingPointNaN<Float>,
#ifndef MAGNUM_TARGET_GLES
&TypeTraitsTest::equalsFloatingPointNaN<Double>
#endif
});
&TypeTraitsTest::equalsFloatingPointNaN<Double>});
}
template<class T> void TypeTraitsTest::equalsIntegral() {

10
src/Magnum/Math/TypeTraits.h

@ -127,25 +127,17 @@ template<> struct TypeTraits<Short>: Implementation::TypeTraitsIntegral<Short> {
typedef Float FloatingPointType;
};
template<> struct TypeTraits<UnsignedInt>: Implementation::TypeTraitsIntegral<UnsignedInt> {
#ifndef MAGNUM_TARGET_GLES
typedef Double FloatingPointType;
#endif
};
template<> struct TypeTraits<Int>: Implementation::TypeTraitsIntegral<Int> {
#ifndef MAGNUM_TARGET_GLES
typedef Double FloatingPointType;
#endif
};
#ifndef MAGNUM_TARGET_WEBGL
template<> struct TypeTraits<UnsignedLong>: Implementation::TypeTraitsIntegral<UnsignedLong> {
#ifndef MAGNUM_TARGET_GLES
typedef long double FloatingPointType;
#endif
};
template<> struct TypeTraits<Long>: Implementation::TypeTraitsIntegral<Long> {
#ifndef MAGNUM_TARGET_GLES
typedef long double FloatingPointType;
#endif
};
#endif
@ -183,13 +175,11 @@ template<> struct TypeTraits<Float>: Implementation::TypeTraitsFloatingPoint<Flo
constexpr static Float epsilon() { return FLOAT_EQUALITY_PRECISION; }
};
#ifndef MAGNUM_TARGET_GLES
template<> struct TypeTraits<Double>: Implementation::TypeTraitsFloatingPoint<Double> {
typedef Double FloatingPointType;
constexpr static Double epsilon() { return DOUBLE_EQUALITY_PRECISION; }
};
#endif
template<> struct TypeTraits<long double>: Implementation::TypeTraitsFloatingPoint<long double> {
typedef long double FloatingPointType;

4
src/Magnum/Math/Vector.h

@ -1085,12 +1085,10 @@ extern template MAGNUM_EXPORT Corrade::Utility::Debug& operator<<(Corrade::Utili
extern template MAGNUM_EXPORT Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const Vector<2, UnsignedInt>&);
extern template MAGNUM_EXPORT Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const Vector<3, UnsignedInt>&);
extern template MAGNUM_EXPORT Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const Vector<4, UnsignedInt>&);
#ifndef MAGNUM_TARGET_GLES
extern template MAGNUM_EXPORT Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const Vector<2, Double>&);
extern template MAGNUM_EXPORT Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const Vector<3, Double>&);
extern template MAGNUM_EXPORT Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const Vector<4, Double>&);
#endif
#endif
#ifndef DOXYGEN_GENERATING_OUTPUT
#define MAGNUM_VECTOR_SUBCLASS_IMPLEMENTATION(size, Type) \
@ -1404,12 +1402,10 @@ extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Vector<4,
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Vector<2, Magnum::UnsignedInt>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Vector<3, Magnum::UnsignedInt>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Vector<4, Magnum::UnsignedInt>>;
#ifndef MAGNUM_TARGET_GLES
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Vector<2, Magnum::Double>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Vector<3, Magnum::Double>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Vector<4, Magnum::Double>>;
#endif
#endif
}}

31
src/Magnum/Math/instantiation.cpp

@ -33,11 +33,9 @@ namespace Corrade { namespace Utility {
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<2, 2, Magnum::Float>>;
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<3, 3, Magnum::Float>>;
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<4, 4, Magnum::Float>>;
#ifndef MAGNUM_TARGET_GLES
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<2, 2, Magnum::Double>>;
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<3, 3, Magnum::Double>>;
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<4, 4, Magnum::Double>>;
#endif
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<2, 3, Magnum::Float>>;
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<3, 2, Magnum::Float>>;
@ -45,14 +43,12 @@ template struct ConfigurationValue<Magnum::Math::RectangularMatrix<2, 4, Magnum:
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<4, 2, Magnum::Float>>;
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<3, 4, Magnum::Float>>;
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<4, 3, Magnum::Float>>;
#ifndef MAGNUM_TARGET_GLES
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<2, 3, Magnum::Double>>;
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<3, 2, Magnum::Double>>;
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<2, 4, Magnum::Double>>;
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<4, 2, Magnum::Double>>;
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<3, 4, Magnum::Double>>;
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<4, 3, Magnum::Double>>;
#endif
template struct ConfigurationValue<Magnum::Math::Vector<2, Magnum::Float>>;
template struct ConfigurationValue<Magnum::Math::Vector<3, Magnum::Float>>;
@ -63,21 +59,17 @@ template struct ConfigurationValue<Magnum::Math::Vector<4, Magnum::Int>>;
template struct ConfigurationValue<Magnum::Math::Vector<2, Magnum::UnsignedInt>>;
template struct ConfigurationValue<Magnum::Math::Vector<3, Magnum::UnsignedInt>>;
template struct ConfigurationValue<Magnum::Math::Vector<4, Magnum::UnsignedInt>>;
#ifndef MAGNUM_TARGET_GLES
template struct ConfigurationValue<Magnum::Math::Vector<2, Magnum::Double>>;
template struct ConfigurationValue<Magnum::Math::Vector<3, Magnum::Double>>;
template struct ConfigurationValue<Magnum::Math::Vector<4, Magnum::Double>>;
#endif
template struct ConfigurationValue<Magnum::Math::Range<2, Magnum::Float>>;
template struct ConfigurationValue<Magnum::Math::Range<2, Magnum::Int>>;
template struct ConfigurationValue<Magnum::Math::Range<3, Magnum::Float>>;
template struct ConfigurationValue<Magnum::Math::Range<3, Magnum::Int>>;
#ifndef MAGNUM_TARGET_GLES
template struct ConfigurationValue<Magnum::Math::Range<2, Magnum::Double>>;
template struct ConfigurationValue<Magnum::Math::Range<3, Magnum::Double>>;
#endif
#endif
}}
@ -85,24 +77,16 @@ namespace Magnum { namespace Math {
#ifndef DOXYGEN_GENERATING_OUTPUT
template Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const Complex<Float>&);
#ifndef MAGNUM_TARGET_GLES
template Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const Complex<Double>&);
#endif
template Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const DualComplex<Float>&);
#ifndef MAGNUM_TARGET_GLES
template Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const DualComplex<Double>&);
#endif
template Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const DualQuaternion<Float>&);
#ifndef MAGNUM_TARGET_GLES
template Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const DualQuaternion<Double>&);
#endif
template Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const Quaternion<Float>&);
#ifndef MAGNUM_TARGET_GLES
template Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const Quaternion<Double>&);
#endif
/* Check proper size of GL types */
static_assert(sizeof(Vector<2, Float>) == 8, "Improper size of 2-element Float vector");
@ -114,20 +98,16 @@ static_assert(sizeof(Vector<4, Int>) == 16, "Improper size of 4-element Int vect
static_assert(sizeof(Vector<2, UnsignedInt>) == 8, "Improper size of 2-element UnsignedInt vector");
static_assert(sizeof(Vector<3, UnsignedInt>) == 12, "Improper size of 3-element UnsignedInt vector");
static_assert(sizeof(Vector<4, UnsignedInt>) == 16, "Improper size of 4-element UnsignedInt vector");
#ifndef MAGNUM_TARGET_GLES
static_assert(sizeof(Vector<2, Double>) == 16, "Improper size of 2-element Double vector");
static_assert(sizeof(Vector<3, Double>) == 24, "Improper size of 3-element Double vector");
static_assert(sizeof(Vector<4, Double>) == 32, "Improper size of 4-element Double vector");
#endif
static_assert(sizeof(RectangularMatrix<2, 2, Float>) == 16, "Improper size of 2x2 Float matrix");
static_assert(sizeof(RectangularMatrix<3, 3, Float>) == 36, "Improper size of 3x3 Float matrix");
static_assert(sizeof(RectangularMatrix<4, 4, Float>) == 64, "Improper size of 4x4 Float matrix");
#ifndef MAGNUM_TARGET_GLES
static_assert(sizeof(RectangularMatrix<2, 2, Double>) == 32, "Improper size of 2x2 Double matrix");
static_assert(sizeof(RectangularMatrix<3, 3, Double>) == 72, "Improper size of 3x3 Double matrix");
static_assert(sizeof(RectangularMatrix<4, 4, Double>) == 128, "Improper size of 4x4 Double matrix");
#endif
static_assert(sizeof(RectangularMatrix<2, 3, Float>) == 24, "Improper size of 2x3 Float matrix");
static_assert(sizeof(RectangularMatrix<3, 2, Float>) == 24, "Improper size of 3x2 Float matrix");
@ -135,23 +115,19 @@ static_assert(sizeof(RectangularMatrix<2, 4, Float>) == 32, "Improper size of 2x
static_assert(sizeof(RectangularMatrix<4, 2, Float>) == 32, "Improper size of 4x2 Float matrix");
static_assert(sizeof(RectangularMatrix<3, 4, Float>) == 48, "Improper size of 3x4 Float matrix");
static_assert(sizeof(RectangularMatrix<4, 3, Float>) == 48, "Improper size of 4x3 Float matrix");
#ifndef MAGNUM_TARGET_GLES
static_assert(sizeof(RectangularMatrix<2, 3, Double>) == 48, "Improper size of 2x3 Double matrix");
static_assert(sizeof(RectangularMatrix<3, 2, Double>) == 48, "Improper size of 3x2 Double matrix");
static_assert(sizeof(RectangularMatrix<2, 4, Double>) == 64, "Improper size of 2x4 Double matrix");
static_assert(sizeof(RectangularMatrix<4, 2, Double>) == 64, "Improper size of 4x2 Double matrix");
static_assert(sizeof(RectangularMatrix<3, 4, Double>) == 96, "Improper size of 3x4 Double matrix");
static_assert(sizeof(RectangularMatrix<4, 3, Double>) == 96, "Improper size of 4x3 Double matrix");
#endif
template Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const RectangularMatrix<2, 2, Float>&);
template Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const RectangularMatrix<3, 3, Float>&);
template Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const RectangularMatrix<4, 4, Float>&);
#ifndef MAGNUM_TARGET_GLES
template Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const RectangularMatrix<2, 2, Double>&);
template Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const RectangularMatrix<3, 3, Double>&);
template Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const RectangularMatrix<4, 4, Double>&);
#endif
template Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const RectangularMatrix<2, 3, Float>&);
template Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const RectangularMatrix<3, 2, Float>&);
@ -159,21 +135,17 @@ template Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const Rec
template Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const RectangularMatrix<4, 2, Float>&);
template Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const RectangularMatrix<3, 4, Float>&);
template Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const RectangularMatrix<4, 3, Float>&);
#ifndef MAGNUM_TARGET_GLES
template Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const RectangularMatrix<2, 3, Double>&);
template Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const RectangularMatrix<3, 2, Double>&);
template Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const RectangularMatrix<2, 4, Double>&);
template Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const RectangularMatrix<4, 2, Double>&);
template Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const RectangularMatrix<3, 4, Double>&);
template Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const RectangularMatrix<4, 3, Double>&);
#endif
template Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const Unit<Rad, Float>&);
template Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const Unit<Deg, Float>&);
#ifndef MAGNUM_TARGET_GLES
template Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const Unit<Rad, Double>&);
template Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const Unit<Deg, Double>&);
#endif
template Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const Vector<2, Float>&);
template Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const Vector<3, Float>&);
@ -184,12 +156,9 @@ template Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const Vec
template Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const Vector<2, UnsignedInt>&);
template Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const Vector<3, UnsignedInt>&);
template Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const Vector<4, UnsignedInt>&);
#ifndef MAGNUM_TARGET_GLES
template Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const Vector<2, Double>&);
template Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const Vector<3, Double>&);
template Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug&, const Vector<4, Double>&);
#endif
#endif
}}

2
src/Magnum/Types.h

@ -48,9 +48,7 @@ typedef std::int64_t Long;
#endif
typedef float Float;
#ifndef MAGNUM_TARGET_GLES
typedef double Double;
#endif
}

Loading…
Cancel
Save