Browse Source

Disable 64bit integers for WebGL.

Due to crappy JavaScript design which doesn't count with any integers at
all, the integers needs to be "emulated" inside the 52-bit exponent of
doubles, which means that only 32bit integers can fit there (not to
mention various issues with 32b overflow, which needs to be emulated
somehow to work properly).
pull/51/head
Vladimír Vondruš 12 years ago
parent
commit
87d8b6a229
  1. 14
      src/Magnum/Magnum.h
  2. 2
      src/Magnum/Math/TypeTraits.h
  3. 2
      src/Magnum/Query.cpp
  4. 4
      src/Magnum/Query.h
  5. 2
      src/Magnum/Types.h

14
src/Magnum/Magnum.h

@ -167,11 +167,21 @@ typedef std::uint32_t UnsignedInt;
/** @brief Signed int (32bit) */
typedef std::int32_t Int;
/** @brief Unsigned long (64bit) */
#ifndef MAGNUM_TARGET_WEBGL
/**
@brief Unsigned long (64bit)
@attention 64-bit integers are not available in @ref MAGNUM_TARGET_WEBGL "WebGL".
*/
typedef std::uint64_t UnsignedLong;
/** @brief Signed long (64bit) */
/**
@brief Signed long (64bit)
@attention 64-bit integers are not available in @ref MAGNUM_TARGET_WEBGL "WebGL".
*/
typedef std::int64_t Long;
#endif
/** @brief Float (32bit) */
typedef float Float;

2
src/Magnum/Math/TypeTraits.h

@ -144,6 +144,7 @@ template<> struct TypeTraits<Int>: Implementation::TypeTraitsIntegral<Int> {
typedef Double FloatingPointType;
#endif
};
#ifndef MAGNUM_TARGET_WEBGL
template<> struct TypeTraits<UnsignedLong>: Implementation::TypeTraitsIntegral<UnsignedLong> {
#ifndef MAGNUM_TARGET_GLES
typedef long double FloatingPointType;
@ -154,6 +155,7 @@ template<> struct TypeTraits<Long>: Implementation::TypeTraitsIntegral<Long> {
typedef long double FloatingPointType;
#endif
};
#endif
/* Floating-point scalar types */
namespace Implementation {

2
src/Magnum/Query.cpp

@ -123,6 +123,7 @@ template<> Int AbstractQuery::result<Int>() {
return result;
}
#ifndef MAGNUM_TARGET_WEBGL
template<> UnsignedLong AbstractQuery::result<UnsignedLong>() {
CORRADE_ASSERT(!target, "AbstractQuery::result(): the query is currently running", {});
@ -151,6 +152,7 @@ template<> Long AbstractQuery::result<Long>() {
return result;
}
#endif
#endif
void AbstractQuery::begin(GLenum target) {
CORRADE_ASSERT(!this->target, "AbstractQuery::begin(): the query is already running", );

4
src/Magnum/Query.h

@ -107,6 +107,8 @@ class MAGNUM_EXPORT AbstractQuery: public AbstractObject {
* @requires_es_extension %Extension @es_extension{EXT,disjoint_timer_query}
* for result types @ref Magnum::Int "Int", @ref Magnum::UnsignedLong "UnsignedLong"
* @ref Magnum::Long "Long".
* @attention @ref Magnum::UnsignedLong "UnsignedLong" and @ref Magnum::Long "Long"
* result type is not available in @ref MAGNUM_TARGET_WEBGL "WebGL".
*/
template<class T> T result();
@ -147,9 +149,11 @@ class MAGNUM_EXPORT AbstractQuery: public AbstractObject {
template<> bool MAGNUM_EXPORT AbstractQuery::result<bool>();
template<> UnsignedInt MAGNUM_EXPORT AbstractQuery::result<UnsignedInt>();
template<> Int MAGNUM_EXPORT AbstractQuery::result<Int>();
#ifndef MAGNUM_TARGET_WEBGL
template<> UnsignedLong MAGNUM_EXPORT AbstractQuery::result<UnsignedLong>();
template<> Long MAGNUM_EXPORT AbstractQuery::result<Long>();
#endif
#endif
#ifndef MAGNUM_TARGET_GLES2
/**

2
src/Magnum/Types.h

@ -42,8 +42,10 @@ typedef std::uint16_t UnsignedShort;
typedef std::int16_t Short;
typedef std::uint32_t UnsignedInt;
typedef std::int32_t Int;
#ifndef MAGNUM_TARGET_WEBGL
typedef std::uint64_t UnsignedLong;
typedef std::int64_t Long;
#endif
/** @todo C++14: use std::float32_t and std::float_64t [N3626](http://open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3626.pdf) */
typedef float Float;

Loading…
Cancel
Save