From 35eb87630358bfcc428c71fc465d5debde513369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 18 Mar 2013 19:37:15 +0100 Subject: [PATCH] Various other compilation fixes for OpenGL ES target. --- src/DimensionTraits.h | 4 +++ src/Magnum.h | 8 +++-- src/Math/Angle.h | 6 ++++ src/Math/Test/AngleTest.cpp | 46 ++++++++++++++++++++------ src/Math/Test/FunctionsTest.cpp | 12 +++++++ src/Math/Test/TypeTraitsTest.cpp | 2 ++ src/Math/TypeTraits.h | 10 ++++++ src/Query.cpp | 4 ++- src/Test/AbstractShaderProgramTest.cpp | 27 +++++++++++++++ 9 files changed, 106 insertions(+), 13 deletions(-) diff --git a/src/DimensionTraits.h b/src/DimensionTraits.h index 3ce74b5d7..d729aca74 100644 --- a/src/DimensionTraits.h +++ b/src/DimensionTraits.h @@ -77,12 +77,14 @@ template<> struct DimensionTraits<2, Float> { typedef Math::Vector2 VectorType; typedef Math::Matrix3 MatrixType; }; +#ifndef MAGNUM_TARGET_GLES template<> struct DimensionTraits<2, Double> { DimensionTraits() = delete; typedef Math::Vector2 VectorType; typedef Math::Matrix3 MatrixType; }; +#endif /* Three dimensions - integral */ template struct DimensionTraits<3, T> { @@ -98,6 +100,7 @@ template<> struct DimensionTraits<3, Float> { typedef Math::Vector3 VectorType; typedef Math::Matrix4 MatrixType; }; +#ifndef MAGNUM_TARGET_GLES template<> struct DimensionTraits<3, Double> { DimensionTraits() = delete; @@ -105,6 +108,7 @@ template<> struct DimensionTraits<3, Double> { typedef Math::Matrix4 MatrixType; }; #endif +#endif } diff --git a/src/Magnum.h b/src/Magnum.h index c93a6ce1d..b443cf30a 100644 --- a/src/Magnum.h +++ b/src/Magnum.h @@ -50,9 +50,11 @@ namespace Math { template struct Constants; #ifndef CORRADE_GCC46_COMPATIBILITY + #ifndef MAGNUM_TARGET_GLES constexpr Rad operator "" _rad(long double); - constexpr Rad operator "" _radf(long double); constexpr Deg operator "" _deg(long double); + #endif + constexpr Rad operator "" _radf(long double); constexpr Deg operator "" _degf(long double); #endif } @@ -253,9 +255,11 @@ typedef Math::Geometry::Rectangle Rectangled; #ifndef CORRADE_GCC46_COMPATIBILITY /* Using angle literals from Math namespace */ +#ifndef MAGNUM_TARGET_GLES using Math::operator "" _deg; -using Math::operator "" _degf; using Math::operator "" _rad; +#endif +using Math::operator "" _degf; using Math::operator "" _radf; #endif diff --git a/src/Math/Angle.h b/src/Math/Angle.h index 8c95d20d4..9b7b66000 100644 --- a/src/Math/Angle.h +++ b/src/Math/Angle.h @@ -147,6 +147,7 @@ template class Deg: public Unit { }; #ifndef CORRADE_GCC46_COMPATIBILITY +#ifndef MAGNUM_TARGET_GLES /** @relates Deg @brief Double-precision degree value literal @@ -157,8 +158,10 @@ Double cosine = Math::cos(1.047_rad); // cosine = 0.5 @endcode @see Magnum::operator""_deg(), operator""_degf(), operator""_rad() @note Not available on GCC < 4.7. Use Deg::Deg(T) instead. +@requires_gl Only single-precision types are available in OpenGL ES. */ inline constexpr Deg operator "" _deg(long double value) { return Deg(value); } +#endif /** @relates Deg @brief Single-precision degree value literal @@ -170,6 +173,7 @@ Float tangent = Math::tan(1.047_radf); // tangent = 1.732f @endcode @see Magnum::operator""_degf(), operator""_deg(), operator""_radf() @note Not available on GCC < 4.7. Use Deg::Deg(T) instead. +@requires_gl Only single-precision types are available in OpenGL ES. */ inline constexpr Deg operator "" _degf(long double value) { return Deg(value); } #endif @@ -206,6 +210,7 @@ template class Rad: public Unit { }; #ifndef CORRADE_GCC46_COMPATIBILITY +#ifndef MAGNUM_TARGET_GLES /** @relates Rad @brief Double-precision radian value literal @@ -214,6 +219,7 @@ See operator""_rad() for more information. @note Not available on GCC < 4.7. Use Rad::Rad(T) instead. */ inline constexpr Rad operator "" _rad(long double value) { return Rad(value); } +#endif /** @relates Rad @brief Single-precision radian value literal diff --git a/src/Math/Test/AngleTest.cpp b/src/Math/Test/AngleTest.cpp index cac78bda1..1feba3aa8 100644 --- a/src/Math/Test/AngleTest.cpp +++ b/src/Math/Test/AngleTest.cpp @@ -43,8 +43,10 @@ class AngleTest: public Corrade::TestSuite::Tester { typedef Math::Deg Deg; typedef Math::Rad Rad; +#ifndef MAGNUM_TARGET_GLES typedef Math::Deg Degd; typedef Math::Rad Radd; +#endif AngleTest::AngleTest() { addTests({&AngleTest::construct, @@ -57,44 +59,68 @@ AngleTest::AngleTest() { void AngleTest::construct() { /* Default constructor */ - constexpr Degd a; constexpr Deg m; - CORRADE_COMPARE(Double(a), 0.0f); CORRADE_COMPARE(Float(m), 0.0f); + #ifndef MAGNUM_TARGET_GLES + constexpr Degd a; + CORRADE_COMPARE(Double(a), 0.0); + #else + constexpr Deg a; + CORRADE_COMPARE(Float(a), 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(Float(b), 25.0); 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); - constexpr Radd o(n); 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 Degd d(b); constexpr Rad p(n); - CORRADE_COMPARE(Double(d), 25.0); 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::literals() { #ifndef CORRADE_GCC46_COMPATIBILITY + #ifndef MAGNUM_TARGET_GLES constexpr auto a = 25.0_deg; - constexpr auto b = 25.0_degf; CORRADE_VERIFY((std::is_same::value)); - CORRADE_VERIFY((std::is_same::value)); CORRADE_COMPARE(Double(a), 25.0); + #endif + constexpr auto b = 25.0_degf; + CORRADE_VERIFY((std::is_same::value)); CORRADE_COMPARE(Float(b), 25.0f); + #ifndef MAGNUM_TARGET_GLES constexpr auto m = 3.14_rad; - constexpr auto n = 3.14_radf; CORRADE_VERIFY((std::is_same::value)); - CORRADE_VERIFY((std::is_same::value)); CORRADE_COMPARE(Double(m), 3.14); + #endif + constexpr auto n = 3.14_radf; + CORRADE_VERIFY((std::is_same::value)); CORRADE_COMPARE(Float(n), 3.14f); #else CORRADE_SKIP("User-defined literals are not available on GCC < 4.7."); diff --git a/src/Math/Test/FunctionsTest.cpp b/src/Math/Test/FunctionsTest.cpp index 2d178c166..ed32bb73e 100644 --- a/src/Math/Test/FunctionsTest.cpp +++ b/src/Math/Test/FunctionsTest.cpp @@ -134,11 +134,13 @@ void FunctionsTest::normalizeUnsigned() { CORRADE_COMPARE((Math::normalize(0)), 0.0f); CORRADE_COMPARE((Math::normalize(255)), 1.0f); + #ifndef MAGNUM_TARGET_GLES CORRADE_COMPARE((Math::normalize(0)), 0.0); CORRADE_COMPARE((Math::normalize(std::numeric_limits::max())), 1.0); CORRADE_COMPARE((Math::normalize(0)), 0.0); CORRADE_COMPARE((Math::normalize(std::numeric_limits::max())), 1.0); + #endif CORRADE_COMPARE((Math::normalize(0)), 0.0f); CORRADE_COMPARE((Math::normalize(std::numeric_limits::max())), 1.0f); @@ -158,6 +160,7 @@ void FunctionsTest::normalizeSigned() { CORRADE_COMPARE((Math::normalize(0)), 0.0f); CORRADE_COMPARE((Math::normalize(std::numeric_limits::max())), 1.0f); + #ifndef MAGNUM_TARGET_GLES CORRADE_COMPARE((Math::normalize(std::numeric_limits::min())), -1.0); CORRADE_COMPARE((Math::normalize(0)), 0.0); CORRADE_COMPARE((Math::normalize(std::numeric_limits::max())), 1.0); @@ -165,6 +168,7 @@ void FunctionsTest::normalizeSigned() { CORRADE_COMPARE((Math::normalize(std::numeric_limits::min())), -1.0); CORRADE_COMPARE((Math::normalize(0)), 0.0); CORRADE_COMPARE((Math::normalize(std::numeric_limits::max())), 1.0); + #endif CORRADE_COMPARE((Math::normalize(16384)), 0.500015f); CORRADE_COMPARE((Math::normalize(-16384)), -0.500015f); @@ -179,6 +183,7 @@ void FunctionsTest::denormalizeUnsigned() { CORRADE_COMPARE(Math::denormalize(0.0f), 0); CORRADE_COMPARE(Math::denormalize(1.0f), std::numeric_limits::max()); + #ifndef MAGNUM_TARGET_GLES CORRADE_COMPARE(Math::denormalize(0.0), 0); CORRADE_COMPARE(Math::denormalize(1.0), std::numeric_limits::max()); @@ -188,6 +193,7 @@ void FunctionsTest::denormalizeUnsigned() { CORRADE_VERIFY(false); //CORRADE_COMPARE(Math::denormalize(1.0), std::numeric_limits::max()); } + #endif CORRADE_COMPARE(Math::denormalize(0.33f), 21626); CORRADE_COMPARE(Math::denormalize(0.66f), 43253); @@ -204,6 +210,7 @@ void FunctionsTest::denormalizeSigned() { CORRADE_COMPARE(Math::denormalize(0.0f), 0); CORRADE_COMPARE(Math::denormalize(1.0f), std::numeric_limits::max()); + #ifndef MAGNUM_TARGET_GLES CORRADE_COMPARE(Math::denormalize(-1.0), std::numeric_limits::min()+1); CORRADE_COMPARE(Math::denormalize(0.0), 0); CORRADE_COMPARE(Math::denormalize(1.0), std::numeric_limits::max()); @@ -211,6 +218,7 @@ void FunctionsTest::denormalizeSigned() { CORRADE_COMPARE(Math::denormalize(-1.0l), std::numeric_limits::min()+1); CORRADE_COMPARE(Math::denormalize(0.0l), 0); CORRADE_COMPARE(Math::denormalize(1.0l), std::numeric_limits::max()); + #endif CORRADE_COMPARE(Math::denormalize(-0.33f), -10813); CORRADE_COMPARE(Math::denormalize(0.66f), 21626); @@ -225,11 +233,13 @@ void FunctionsTest::renormalizeUnsinged() { CORRADE_COMPARE(Math::normalize(Math::denormalize(0.0f)), 0.0f); CORRADE_COMPARE(Math::normalize(Math::denormalize(1.0f)), 1.0f); + #ifndef MAGNUM_TARGET_GLES CORRADE_COMPARE(Math::normalize(Math::denormalize(0.0)), 0.0); CORRADE_COMPARE(Math::normalize(Math::denormalize(1.0)), 1.0); CORRADE_COMPARE(Math::normalize(Math::denormalize(0.0l)), 0.0l); CORRADE_COMPARE(Math::normalize(Math::denormalize(1.0l)), 1.0l); + #endif } void FunctionsTest::renormalizeSinged() { @@ -241,6 +251,7 @@ void FunctionsTest::renormalizeSinged() { CORRADE_COMPARE(Math::normalize(Math::denormalize(0.0f)), 0.0f); CORRADE_COMPARE(Math::normalize(Math::denormalize(1.0f)), 1.0f); + #ifndef MAGNUM_TARGET_GLES CORRADE_COMPARE(Math::normalize(Math::denormalize(-1.0)), -1.0); CORRADE_COMPARE(Math::normalize(Math::denormalize(0.0)), 0.0); CORRADE_COMPARE(Math::normalize(Math::denormalize(1.0)), 1.0); @@ -248,6 +259,7 @@ void FunctionsTest::renormalizeSinged() { CORRADE_COMPARE(Math::normalize(Math::denormalize(-1.0l)), -1.0l); CORRADE_COMPARE(Math::normalize(Math::denormalize(0.0l)), 0.0l); CORRADE_COMPARE(Math::normalize(Math::denormalize(1.0l)), 1.0l); + #endif } void FunctionsTest::normalizeTypeDeduction() { diff --git a/src/Math/Test/TypeTraitsTest.cpp b/src/Math/Test/TypeTraitsTest.cpp index 63a6fbace..dd5d0edad 100644 --- a/src/Math/Test/TypeTraitsTest.cpp +++ b/src/Math/Test/TypeTraitsTest.cpp @@ -59,7 +59,9 @@ void TypeTraitsTest::equalsIntegral() { void TypeTraitsTest::equalsFloatingPoint() { _equalsFloatingPoint(); + #ifndef MAGNUM_TARGET_GLES _equalsFloatingPoint(); + #endif } template void TypeTraitsTest::_equalsIntegral() { diff --git a/src/Math/TypeTraits.h b/src/Math/TypeTraits.h index addcb4206..e79c8dca4 100644 --- a/src/Math/TypeTraits.h +++ b/src/Math/TypeTraits.h @@ -136,16 +136,24 @@ template<> struct TypeTraits: Implementation::TypeTraitsIntegral { typedef Float FloatingPointType; }; template<> struct TypeTraits: Implementation::TypeTraitsIntegral { + #ifndef MAGNUM_TARGET_GLES typedef Double FloatingPointType; + #endif }; template<> struct TypeTraits: Implementation::TypeTraitsIntegral { + #ifndef MAGNUM_TARGET_GLES typedef Double FloatingPointType; + #endif }; template<> struct TypeTraits: Implementation::TypeTraitsIntegral { + #ifndef MAGNUM_TARGET_GLES typedef long double FloatingPointType; + #endif }; template<> struct TypeTraits: Implementation::TypeTraitsIntegral { + #ifndef MAGNUM_TARGET_GLES typedef long double FloatingPointType; + #endif }; /* Floating-point scalar types */ @@ -164,11 +172,13 @@ template<> struct TypeTraits: Implementation::TypeTraitsFloatingPoint struct TypeTraits: Implementation::TypeTraitsFloatingPoint { typedef Double FloatingPointType; inline constexpr static Double epsilon() { return DOUBLE_EQUALITY_PRECISION; } }; +#endif template<> struct TypeTraits: Implementation::TypeTraitsFloatingPoint { typedef long double FloatingPointType; diff --git a/src/Query.cpp b/src/Query.cpp index df80395fa..c53d02fc9 100644 --- a/src/Query.cpp +++ b/src/Query.cpp @@ -93,11 +93,11 @@ template<> Long AbstractQuery::result() { } #endif +#ifndef MAGNUM_TARGET_GLES2 Query::Query(): target(nullptr) {} Query::~Query() { delete target; } -#ifndef MAGNUM_TARGET_GLES2 void Query::begin(Query::Target target) { glBeginQuery(static_cast(target), id()); this->target = new Target(target); @@ -135,6 +135,8 @@ void SampleQuery::end() { target = nullptr; } +#ifndef MAGNUM_TARGET_GLES TimeQuery::TimeQuery() = default; +#endif } diff --git a/src/Test/AbstractShaderProgramTest.cpp b/src/Test/AbstractShaderProgramTest.cpp index 4dc11e31b..05838f101 100644 --- a/src/Test/AbstractShaderProgramTest.cpp +++ b/src/Test/AbstractShaderProgramTest.cpp @@ -83,6 +83,7 @@ void AbstractShaderProgramTest::attributeScalar() { } void AbstractShaderProgramTest::attributeScalarInt() { + #ifndef MAGNUM_TARGET_GLES2 typedef AbstractShaderProgram::Attribute<3, Int> Attribute; /* Default constructor */ @@ -92,9 +93,13 @@ void AbstractShaderProgramTest::attributeScalarInt() { /* Options */ Attribute b(Attribute::DataType::Short); CORRADE_COMPARE(b.dataSize(), 2); + #else + CORRADE_SKIP("Integer attributes are not available in OpenGL ES 2."); + #endif } void AbstractShaderProgramTest::attributeScalarUnsignedInt() { + #ifndef MAGNUM_TARGET_GLES2 typedef AbstractShaderProgram::Attribute<3, UnsignedInt> Attribute; /* Default constructor */ @@ -104,6 +109,9 @@ void AbstractShaderProgramTest::attributeScalarUnsignedInt() { /* Options */ Attribute b(Attribute::DataType::UnsignedByte); CORRADE_COMPARE(b.dataSize(), 1); + #else + CORRADE_SKIP("Integer attributes are not available in OpenGL ES 2."); + #endif } void AbstractShaderProgramTest::attributeScalarDouble() { @@ -128,12 +136,19 @@ void AbstractShaderProgramTest::attributeVector() { CORRADE_COMPARE(a.dataType(), Attribute::DataType::Float); /* Options */ + #ifndef MAGNUM_TARGET_GLES Attribute b(Attribute::Components::Two, Attribute::DataType::Double); CORRADE_COMPARE(b.components(), Attribute::Components::Two); CORRADE_COMPARE(b.dataSize(), 2*8); + #else + Attribute b(Attribute::Components::Two, Attribute::DataType::Float); + CORRADE_COMPARE(b.components(), Attribute::Components::Two); + CORRADE_COMPARE(b.dataSize(), 2*4); + #endif } void AbstractShaderProgramTest::attributeVectorInt() { + #ifndef MAGNUM_TARGET_GLES2 typedef AbstractShaderProgram::Attribute<3, Vector2i> Attribute; /* Default constructor */ @@ -145,9 +160,13 @@ void AbstractShaderProgramTest::attributeVectorInt() { /* Options */ Attribute b(Attribute::Components::One, Attribute::DataType::Int); CORRADE_COMPARE(b.dataSize(), 4); + #else + CORRADE_SKIP("Integer attributes are not available in OpenGL ES 2."); + #endif } void AbstractShaderProgramTest::attributeVectorUnsignedInt() { + #ifndef MAGNUM_TARGET_GLES2 typedef AbstractShaderProgram::Attribute<3, Vector4ui> Attribute; /* Default constructor */ @@ -159,6 +178,9 @@ void AbstractShaderProgramTest::attributeVectorUnsignedInt() { /* Options */ Attribute b(Attribute::Components::Three, Attribute::DataType::UnsignedShort); CORRADE_COMPARE(b.dataSize(), 3*2); + #else + CORRADE_SKIP("Integer attributes are not available in OpenGL ES 2."); + #endif } void AbstractShaderProgramTest::attributeVectorDouble() { @@ -183,8 +205,13 @@ void AbstractShaderProgramTest::attributeVector4() { typedef AbstractShaderProgram::Attribute<3, Vector4> Attribute; /* Custom type */ + #ifndef MAGNUM_TARGET_GLES Attribute a(Attribute::DataType::UnsignedInt2101010Rev); CORRADE_COMPARE(a.dataSize(), 4); + #else + Attribute a(Attribute::DataType::HalfFloat); + CORRADE_COMPARE(a.dataSize(), 8); + #endif } void AbstractShaderProgramTest::attributeVectorBGRA() {