|
|
|
@ -25,8 +25,9 @@ |
|
|
|
namespace Magnum { |
|
|
|
namespace Magnum { |
|
|
|
|
|
|
|
|
|
|
|
namespace Math { |
|
|
|
namespace Math { |
|
|
|
template<std::size_t, class> class Vector; |
|
|
|
template<std::size_t, std::size_t, class> class RectangularMatrix; |
|
|
|
template<std::size_t, class> class Matrix; |
|
|
|
template<std::size_t, class> class Matrix; |
|
|
|
|
|
|
|
template<std::size_t, class> class Vector; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template<class> class Color3; |
|
|
|
template<class> class Color3; |
|
|
|
@ -42,6 +43,16 @@ OpenGL-specific traits. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
#ifdef DOXYGEN_GENERATING_OUTPUT |
|
|
|
#ifdef DOXYGEN_GENERATING_OUTPUT |
|
|
|
template<class T> struct TypeTraits: public Math::MathTypeTraits<T> { |
|
|
|
template<class T> struct TypeTraits: public Math::MathTypeTraits<T> { |
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @brief Corresponding type for vertex attributes |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* Implemented only in types which can be used for vertex attributes. This |
|
|
|
|
|
|
|
* function is not present for types unusable for vertex attributes, like |
|
|
|
|
|
|
|
* five-component vectors or GLdouble in OpenGL ES. See also |
|
|
|
|
|
|
|
* @ref AbstractShaderProgram-types. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
typedef U AttributeType; |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @brief OpenGL plain type ID |
|
|
|
* @brief OpenGL plain type ID |
|
|
|
* |
|
|
|
* |
|
|
|
@ -166,6 +177,7 @@ template<> struct TypeOf<Type::Double> { typedef GLdouble Type; }; |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
template<> struct TypeTraits<GLubyte>: public Math::MathTypeTraits<std::uint8_t> { |
|
|
|
template<> struct TypeTraits<GLubyte>: public Math::MathTypeTraits<std::uint8_t> { |
|
|
|
|
|
|
|
/* Can not be used for attributes */ |
|
|
|
inline constexpr static Type type() { return Type::UnsignedByte; } |
|
|
|
inline constexpr static Type type() { return Type::UnsignedByte; } |
|
|
|
inline constexpr static Type indexType() { return Type::UnsignedByte; } |
|
|
|
inline constexpr static Type indexType() { return Type::UnsignedByte; } |
|
|
|
inline constexpr static AbstractImage::ComponentType imageType() { return AbstractImage::ComponentType::UnsignedByte; } |
|
|
|
inline constexpr static AbstractImage::ComponentType imageType() { return AbstractImage::ComponentType::UnsignedByte; } |
|
|
|
@ -174,6 +186,7 @@ template<> struct TypeTraits<GLubyte>: public Math::MathTypeTraits<std::uint8_t> |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
template<> struct TypeTraits<GLbyte>: public Math::MathTypeTraits<std::int8_t> { |
|
|
|
template<> struct TypeTraits<GLbyte>: public Math::MathTypeTraits<std::int8_t> { |
|
|
|
|
|
|
|
/* Can not be used for attributes */ |
|
|
|
inline constexpr static Type type() { return Type::Byte; } |
|
|
|
inline constexpr static Type type() { return Type::Byte; } |
|
|
|
/* Can not be used for indices */ |
|
|
|
/* Can not be used for indices */ |
|
|
|
inline constexpr static AbstractImage::ComponentType imageType() { return AbstractImage::ComponentType::Byte; } |
|
|
|
inline constexpr static AbstractImage::ComponentType imageType() { return AbstractImage::ComponentType::Byte; } |
|
|
|
@ -182,6 +195,7 @@ template<> struct TypeTraits<GLbyte>: public Math::MathTypeTraits<std::int8_t> { |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
template<> struct TypeTraits<GLushort>: public Math::MathTypeTraits<std::uint16_t> { |
|
|
|
template<> struct TypeTraits<GLushort>: public Math::MathTypeTraits<std::uint16_t> { |
|
|
|
|
|
|
|
/* Can not be used for attributes */ |
|
|
|
inline constexpr static Type type() { return Type::UnsignedShort; } |
|
|
|
inline constexpr static Type type() { return Type::UnsignedShort; } |
|
|
|
inline constexpr static Type indexType() { return Type::UnsignedShort; } |
|
|
|
inline constexpr static Type indexType() { return Type::UnsignedShort; } |
|
|
|
inline constexpr static AbstractImage::ComponentType imageType() { return AbstractImage::ComponentType::UnsignedShort; } |
|
|
|
inline constexpr static AbstractImage::ComponentType imageType() { return AbstractImage::ComponentType::UnsignedShort; } |
|
|
|
@ -190,6 +204,7 @@ template<> struct TypeTraits<GLushort>: public Math::MathTypeTraits<std::uint16_ |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
template<> struct TypeTraits<GLshort>: public Math::MathTypeTraits<std::int16_t> { |
|
|
|
template<> struct TypeTraits<GLshort>: public Math::MathTypeTraits<std::int16_t> { |
|
|
|
|
|
|
|
/* Can not be used for attributes */ |
|
|
|
inline constexpr static Type type() { return Type::Short; } |
|
|
|
inline constexpr static Type type() { return Type::Short; } |
|
|
|
/* Can not be used for indices */ |
|
|
|
/* Can not be used for indices */ |
|
|
|
inline constexpr static AbstractImage::ComponentType imageType() { return AbstractImage::ComponentType::Short; } |
|
|
|
inline constexpr static AbstractImage::ComponentType imageType() { return AbstractImage::ComponentType::Short; } |
|
|
|
@ -198,6 +213,7 @@ template<> struct TypeTraits<GLshort>: public Math::MathTypeTraits<std::int16_t> |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
template<> struct TypeTraits<GLuint>: public Math::MathTypeTraits<std::uint32_t> { |
|
|
|
template<> struct TypeTraits<GLuint>: public Math::MathTypeTraits<std::uint32_t> { |
|
|
|
|
|
|
|
typedef GLuint AttributeType; |
|
|
|
inline constexpr static Type type() { return Type::UnsignedInt; } |
|
|
|
inline constexpr static Type type() { return Type::UnsignedInt; } |
|
|
|
inline constexpr static Type indexType() { return Type::UnsignedInt; } |
|
|
|
inline constexpr static Type indexType() { return Type::UnsignedInt; } |
|
|
|
inline constexpr static AbstractImage::ComponentType imageType() { return AbstractImage::ComponentType::UnsignedInt; } |
|
|
|
inline constexpr static AbstractImage::ComponentType imageType() { return AbstractImage::ComponentType::UnsignedInt; } |
|
|
|
@ -206,6 +222,7 @@ template<> struct TypeTraits<GLuint>: public Math::MathTypeTraits<std::uint32_t> |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
template<> struct TypeTraits<GLint>: public Math::MathTypeTraits<std::int32_t> { |
|
|
|
template<> struct TypeTraits<GLint>: public Math::MathTypeTraits<std::int32_t> { |
|
|
|
|
|
|
|
typedef GLint AttributeType; |
|
|
|
inline constexpr static Type type() { return Type::Int; } |
|
|
|
inline constexpr static Type type() { return Type::Int; } |
|
|
|
/* Can not be used for indices */ |
|
|
|
/* Can not be used for indices */ |
|
|
|
inline constexpr static AbstractImage::ComponentType imageType() { return AbstractImage::ComponentType::Int; } |
|
|
|
inline constexpr static AbstractImage::ComponentType imageType() { return AbstractImage::ComponentType::Int; } |
|
|
|
@ -214,6 +231,7 @@ template<> struct TypeTraits<GLint>: public Math::MathTypeTraits<std::int32_t> { |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
template<> struct TypeTraits<GLfloat>: public Math::MathTypeTraits<float> { |
|
|
|
template<> struct TypeTraits<GLfloat>: public Math::MathTypeTraits<float> { |
|
|
|
|
|
|
|
typedef GLfloat AttributeType; |
|
|
|
inline constexpr static Type type() { return Type::Float; } |
|
|
|
inline constexpr static Type type() { return Type::Float; } |
|
|
|
/* Can not be used for indices */ |
|
|
|
/* Can not be used for indices */ |
|
|
|
inline constexpr static AbstractImage::ComponentType imageType() { return AbstractImage::ComponentType::Float; } |
|
|
|
inline constexpr static AbstractImage::ComponentType imageType() { return AbstractImage::ComponentType::Float; } |
|
|
|
@ -223,6 +241,7 @@ template<> struct TypeTraits<GLfloat>: public Math::MathTypeTraits<float> { |
|
|
|
|
|
|
|
|
|
|
|
#ifndef MAGNUM_TARGET_GLES |
|
|
|
#ifndef MAGNUM_TARGET_GLES |
|
|
|
template<> struct TypeTraits<GLdouble>: public Math::MathTypeTraits<double> { |
|
|
|
template<> struct TypeTraits<GLdouble>: public Math::MathTypeTraits<double> { |
|
|
|
|
|
|
|
typedef GLdouble AttributeType; |
|
|
|
inline constexpr static Type type() { return Type::Double; } |
|
|
|
inline constexpr static Type type() { return Type::Double; } |
|
|
|
/* Can not be used for indices */ |
|
|
|
/* Can not be used for indices */ |
|
|
|
/* Can not be used for images */ |
|
|
|
/* Can not be used for images */ |
|
|
|
@ -231,13 +250,45 @@ template<> struct TypeTraits<GLdouble>: public Math::MathTypeTraits<double> { |
|
|
|
}; |
|
|
|
}; |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
template<std::size_t vectorSize, class T> struct TypeTraits<Math::Vector<vectorSize, T>> { |
|
|
|
namespace Implementation { |
|
|
|
inline constexpr static Type type() { return TypeTraits<T>::type(); } |
|
|
|
template<std::size_t vectorSize, class T> struct VectorTypeTraits { |
|
|
|
/* Can not be used for indices */ |
|
|
|
/* Might be used for attributes, see below */ |
|
|
|
/* Can not be used for images */ |
|
|
|
inline constexpr static Type type() { return TypeTraits<T>::type(); } |
|
|
|
inline constexpr static std::size_t size() { return sizeof(T); } |
|
|
|
/* Might be used for attributes, see below */ |
|
|
|
inline constexpr static std::size_t count() { return vectorSize; } |
|
|
|
/* Can not be used for indices */ |
|
|
|
}; |
|
|
|
/* Can not be used for images */ |
|
|
|
|
|
|
|
inline constexpr static std::size_t size() { return sizeof(T); } |
|
|
|
|
|
|
|
inline constexpr static std::size_t count() { return vectorSize; } |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<class> struct VectorAttributeType {}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<> struct VectorAttributeType<GLuint> { |
|
|
|
|
|
|
|
typedef GLuint AttributeType; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<> struct VectorAttributeType<GLint> { |
|
|
|
|
|
|
|
typedef GLint AttributeType; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<> struct VectorAttributeType<GLfloat> { |
|
|
|
|
|
|
|
typedef GLfloat AttributeType; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef MAGNUM_TARGET_GLES |
|
|
|
|
|
|
|
template<> struct VectorAttributeType<GLdouble> { |
|
|
|
|
|
|
|
typedef GLdouble AttributeType; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<std::size_t vectorSize, class T> struct TypeTraits<Math::Vector<vectorSize, T>>: public Implementation::VectorTypeTraits<vectorSize, T> {}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Only some vectors can be used as attributes */ |
|
|
|
|
|
|
|
template<class T> struct TypeTraits<Math::Vector<1, T>>: Implementation::VectorTypeTraits<1, T>, Implementation::VectorAttributeType<T> {}; |
|
|
|
|
|
|
|
template<class T> struct TypeTraits<Math::Vector<2, T>>: Implementation::VectorTypeTraits<2, T>, Implementation::VectorAttributeType<T> {}; |
|
|
|
|
|
|
|
template<class T> struct TypeTraits<Math::Vector<3, T>>: Implementation::VectorTypeTraits<3, T>, Implementation::VectorAttributeType<T> {}; |
|
|
|
|
|
|
|
template<class T> struct TypeTraits<Math::Vector<4, T>>: Implementation::VectorTypeTraits<4, T>, Implementation::VectorAttributeType<T> {}; |
|
|
|
|
|
|
|
|
|
|
|
template<class T> struct TypeTraits<Math::Vector2<T>>: public TypeTraits<Math::Vector<2, T>> {}; |
|
|
|
template<class T> struct TypeTraits<Math::Vector2<T>>: public TypeTraits<Math::Vector<2, T>> {}; |
|
|
|
template<class T> struct TypeTraits<Math::Vector3<T>>: public TypeTraits<Math::Vector<3, T>> {}; |
|
|
|
template<class T> struct TypeTraits<Math::Vector3<T>>: public TypeTraits<Math::Vector<3, T>> {}; |
|
|
|
@ -247,13 +298,44 @@ template<class T> struct TypeTraits<Math::Point3D<T>>: public TypeTraits<Math::V |
|
|
|
template<class T> struct TypeTraits<Color3<T>>: public TypeTraits<Math::Vector<3, T>> {}; |
|
|
|
template<class T> struct TypeTraits<Color3<T>>: public TypeTraits<Math::Vector<3, T>> {}; |
|
|
|
template<class T> struct TypeTraits<Color4<T>>: public TypeTraits<Math::Vector<4, T>> {}; |
|
|
|
template<class T> struct TypeTraits<Color4<T>>: public TypeTraits<Math::Vector<4, T>> {}; |
|
|
|
|
|
|
|
|
|
|
|
template<std::size_t matrixSize, class T> struct TypeTraits<Math::Matrix<matrixSize, T>> { |
|
|
|
namespace Implementation { |
|
|
|
inline constexpr static Type type() { return TypeTraits<T>::type(); } |
|
|
|
template<std::size_t cols, std::size_t rows, class T> struct MatrixTypeTraits { |
|
|
|
/* Can not be used for indices */ |
|
|
|
inline constexpr static Type type() { return TypeTraits<T>::type(); } |
|
|
|
/* Can not be used for images */ |
|
|
|
/* Might be used for attributes, see below */ |
|
|
|
inline constexpr static std::size_t size() { return sizeof(T); } |
|
|
|
/* Can not be used for indices */ |
|
|
|
inline constexpr static std::size_t count() { return matrixSize*matrixSize; } |
|
|
|
/* Can not be used for images */ |
|
|
|
}; |
|
|
|
inline constexpr static std::size_t size() { return sizeof(T); } |
|
|
|
|
|
|
|
inline constexpr static std::size_t count() { return rows; } |
|
|
|
|
|
|
|
inline constexpr static std::size_t vectors() { return cols; } |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<class> struct MatrixAttributeType {}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<> struct MatrixAttributeType<GLfloat> { |
|
|
|
|
|
|
|
typedef GLfloat AttributeType; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef MAGNUM_TARGET_GLES |
|
|
|
|
|
|
|
template<> struct MatrixAttributeType<GLdouble> { |
|
|
|
|
|
|
|
typedef GLdouble AttributeType; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<std::size_t cols, std::size_t rows, class T> struct TypeTraits<Math::RectangularMatrix<cols, rows, T>>: public Implementation::MatrixTypeTraits<cols, rows, T> {}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Only some floating-point matrices can be used as attributes */ |
|
|
|
|
|
|
|
template<class T> struct TypeTraits<Math::RectangularMatrix<2, 2, T>>: Implementation::MatrixTypeTraits<2, 2, T>, Implementation::MatrixAttributeType<T> {}; |
|
|
|
|
|
|
|
template<class T> struct TypeTraits<Math::RectangularMatrix<3, 3, T>>: Implementation::MatrixTypeTraits<3, 3, T>, Implementation::MatrixAttributeType<T> {}; |
|
|
|
|
|
|
|
template<class T> struct TypeTraits<Math::RectangularMatrix<4, 4, T>>: Implementation::MatrixTypeTraits<4, 4, T>, Implementation::MatrixAttributeType<T> {}; |
|
|
|
|
|
|
|
template<class T> struct TypeTraits<Math::RectangularMatrix<2, 3, T>>: Implementation::MatrixTypeTraits<2, 3, T>, Implementation::MatrixAttributeType<T> {}; |
|
|
|
|
|
|
|
template<class T> struct TypeTraits<Math::RectangularMatrix<3, 2, T>>: Implementation::MatrixTypeTraits<3, 2, T>, Implementation::MatrixAttributeType<T> {}; |
|
|
|
|
|
|
|
template<class T> struct TypeTraits<Math::RectangularMatrix<2, 4, T>>: Implementation::MatrixTypeTraits<2, 4, T>, Implementation::MatrixAttributeType<T> {}; |
|
|
|
|
|
|
|
template<class T> struct TypeTraits<Math::RectangularMatrix<4, 2, T>>: Implementation::MatrixTypeTraits<4, 2, T>, Implementation::MatrixAttributeType<T> {}; |
|
|
|
|
|
|
|
template<class T> struct TypeTraits<Math::RectangularMatrix<3, 4, T>>: Implementation::MatrixTypeTraits<3, 4, T>, Implementation::MatrixAttributeType<T> {}; |
|
|
|
|
|
|
|
template<class T> struct TypeTraits<Math::RectangularMatrix<4, 3, T>>: Implementation::MatrixTypeTraits<4, 3, T>, Implementation::MatrixAttributeType<T> {}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<std::size_t matrixSize, class T> struct TypeTraits<Math::Matrix<matrixSize, T>>: TypeTraits<Math::RectangularMatrix<matrixSize, matrixSize, T>> {}; |
|
|
|
|
|
|
|
|
|
|
|
template<class T> struct TypeTraits<Math::Matrix3<T>>: public TypeTraits<Math::Matrix<3, T>> {}; |
|
|
|
template<class T> struct TypeTraits<Math::Matrix3<T>>: public TypeTraits<Math::Matrix<3, T>> {}; |
|
|
|
template<class T> struct TypeTraits<Math::Matrix4<T>>: public TypeTraits<Math::Matrix<4, T>> {}; |
|
|
|
template<class T> struct TypeTraits<Math::Matrix4<T>>: public TypeTraits<Math::Matrix<4, T>> {}; |
|
|
|
|