Browse Source

Various other compilation fixes for OpenGL ES target.

pull/278/head
Vladimír Vondruš 13 years ago
parent
commit
35eb876303
  1. 4
      src/DimensionTraits.h
  2. 8
      src/Magnum.h
  3. 6
      src/Math/Angle.h
  4. 46
      src/Math/Test/AngleTest.cpp
  5. 12
      src/Math/Test/FunctionsTest.cpp
  6. 2
      src/Math/Test/TypeTraitsTest.cpp
  7. 10
      src/Math/TypeTraits.h
  8. 4
      src/Query.cpp
  9. 27
      src/Test/AbstractShaderProgramTest.cpp

4
src/DimensionTraits.h

@ -77,12 +77,14 @@ template<> struct DimensionTraits<2, Float> {
typedef Math::Vector2<Float> VectorType;
typedef Math::Matrix3<Float> MatrixType;
};
#ifndef MAGNUM_TARGET_GLES
template<> struct DimensionTraits<2, Double> {
DimensionTraits() = delete;
typedef Math::Vector2<Double> VectorType;
typedef Math::Matrix3<Double> MatrixType;
};
#endif
/* Three dimensions - integral */
template<class T> struct DimensionTraits<3, T> {
@ -98,6 +100,7 @@ template<> struct DimensionTraits<3, Float> {
typedef Math::Vector3<Float> VectorType;
typedef Math::Matrix4<Float> MatrixType;
};
#ifndef MAGNUM_TARGET_GLES
template<> struct DimensionTraits<3, Double> {
DimensionTraits() = delete;
@ -105,6 +108,7 @@ template<> struct DimensionTraits<3, Double> {
typedef Math::Matrix4<Double> MatrixType;
};
#endif
#endif
}

8
src/Magnum.h

@ -50,9 +50,11 @@ namespace Math {
template<class T> struct Constants;
#ifndef CORRADE_GCC46_COMPATIBILITY
#ifndef MAGNUM_TARGET_GLES
constexpr Rad<Double> operator "" _rad(long double);
constexpr Rad<Float> operator "" _radf(long double);
constexpr Deg<Double> operator "" _deg(long double);
#endif
constexpr Rad<Float> operator "" _radf(long double);
constexpr Deg<Float> operator "" _degf(long double);
#endif
}
@ -253,9 +255,11 @@ typedef Math::Geometry::Rectangle<Double> 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

6
src/Math/Angle.h

@ -147,6 +147,7 @@ template<class T> class Deg: public Unit<Deg, T> {
};
#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<Double> operator "" _deg(long double value) { return Deg<Double>(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<Float> operator "" _degf(long double value) { return Deg<Float>(value); }
#endif
@ -206,6 +210,7 @@ template<class T> class Rad: public Unit<Rad, T> {
};
#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<Double> operator "" _rad(long double value) { return Rad<Double>(value); }
#endif
/** @relates Rad
@brief Single-precision radian value literal

46
src/Math/Test/AngleTest.cpp

@ -43,8 +43,10 @@ class AngleTest: public 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,
@ -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<decltype(a), const Degd>::value));
CORRADE_VERIFY((std::is_same<decltype(b), const Deg>::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;
constexpr auto n = 3.14_radf;
CORRADE_VERIFY((std::is_same<decltype(m), const Radd>::value));
CORRADE_VERIFY((std::is_same<decltype(n), const Rad>::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);
#else
CORRADE_SKIP("User-defined literals are not available on GCC < 4.7.");

12
src/Math/Test/FunctionsTest.cpp

@ -134,11 +134,13 @@ 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);
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
CORRADE_COMPARE((Math::normalize<Float, UnsignedShort>(0)), 0.0f);
CORRADE_COMPARE((Math::normalize<Float, UnsignedShort>(std::numeric_limits<UnsignedShort>::max())), 1.0f);
@ -158,6 +160,7 @@ 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);
@ -165,6 +168,7 @@ void FunctionsTest::normalizeSigned() {
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);
#endif
CORRADE_COMPARE((Math::normalize<Float, Short>(16384)), 0.500015f);
CORRADE_COMPARE((Math::normalize<Float, Short>(-16384)), -0.500015f);
@ -179,6 +183,7 @@ 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());
@ -188,6 +193,7 @@ void FunctionsTest::denormalizeUnsigned() {
CORRADE_VERIFY(false);
//CORRADE_COMPARE(Math::denormalize<UnsignedLong>(1.0), std::numeric_limits<UnsignedLong>::max());
}
#endif
CORRADE_COMPARE(Math::denormalize<UnsignedShort>(0.33f), 21626);
CORRADE_COMPARE(Math::denormalize<UnsignedShort>(0.66f), 43253);
@ -204,6 +210,7 @@ void FunctionsTest::denormalizeSigned() {
CORRADE_COMPARE(Math::denormalize<Short>(0.0f), 0);
CORRADE_COMPARE(Math::denormalize<Short>(1.0f), std::numeric_limits<Short>::max());
#ifndef MAGNUM_TARGET_GLES
CORRADE_COMPARE(Math::denormalize<Int>(-1.0), std::numeric_limits<Int>::min()+1);
CORRADE_COMPARE(Math::denormalize<Int>(0.0), 0);
CORRADE_COMPARE(Math::denormalize<Int>(1.0), std::numeric_limits<Int>::max());
@ -211,6 +218,7 @@ void FunctionsTest::denormalizeSigned() {
CORRADE_COMPARE(Math::denormalize<Long>(-1.0l), std::numeric_limits<Long>::min()+1);
CORRADE_COMPARE(Math::denormalize<Long>(0.0l), 0);
CORRADE_COMPARE(Math::denormalize<Long>(1.0l), std::numeric_limits<Long>::max());
#endif
CORRADE_COMPARE(Math::denormalize<Short>(-0.33f), -10813);
CORRADE_COMPARE(Math::denormalize<Short>(0.66f), 21626);
@ -225,11 +233,13 @@ 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);
CORRADE_COMPARE(Math::normalize<long double>(Math::denormalize<UnsignedLong>(0.0l)), 0.0l);
CORRADE_COMPARE(Math::normalize<long double>(Math::denormalize<UnsignedLong>(1.0l)), 1.0l);
#endif
}
void FunctionsTest::renormalizeSinged() {
@ -241,6 +251,7 @@ 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);
@ -248,6 +259,7 @@ void FunctionsTest::renormalizeSinged() {
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);
CORRADE_COMPARE(Math::normalize<long double>(Math::denormalize<Long>(1.0l)), 1.0l);
#endif
}
void FunctionsTest::normalizeTypeDeduction() {

2
src/Math/Test/TypeTraitsTest.cpp

@ -59,7 +59,9 @@ void TypeTraitsTest::equalsIntegral() {
void TypeTraitsTest::equalsFloatingPoint() {
_equalsFloatingPoint<Float>();
#ifndef MAGNUM_TARGET_GLES
_equalsFloatingPoint<Double>();
#endif
}
template<class T> void TypeTraitsTest::_equalsIntegral() {

10
src/Math/TypeTraits.h

@ -136,16 +136,24 @@ 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
};
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
};
/* Floating-point scalar types */
@ -164,11 +172,13 @@ template<> struct TypeTraits<Float>: Implementation::TypeTraitsFloatingPoint<Flo
inline constexpr static Float epsilon() { return FLOAT_EQUALITY_PRECISION; }
};
#ifndef MAGNUM_TARGET_GLES
template<> struct TypeTraits<Double>: Implementation::TypeTraitsFloatingPoint<Double> {
typedef Double FloatingPointType;
inline constexpr static Double epsilon() { return DOUBLE_EQUALITY_PRECISION; }
};
#endif
template<> struct TypeTraits<long double>: Implementation::TypeTraitsFloatingPoint<long double> {
typedef long double FloatingPointType;

4
src/Query.cpp

@ -93,11 +93,11 @@ template<> Long AbstractQuery::result<Long>() {
}
#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<GLenum>(target), id());
this->target = new Target(target);
@ -135,6 +135,8 @@ void SampleQuery::end() {
target = nullptr;
}
#ifndef MAGNUM_TARGET_GLES
TimeQuery::TimeQuery() = default;
#endif
}

27
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() {

Loading…
Cancel
Save