Added initial implementation for forward declarations: int and float scalar types, #56

This commit is contained in:
Christophe Riccio 2013-03-31 01:16:13 +01:00
parent 6a96cd819a
commit 39cf417691
16 changed files with 504 additions and 421 deletions

View File

@ -28,56 +28,12 @@
#ifndef glm_core_detail
#define glm_core_detail
/*
#include "setup.hpp"
#include <cassert>
#if(((GLM_LANG & GLM_LANG_CXX11) == GLM_LANG_CXX11) || (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)))
//#if((defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)))
#include <cstdint>
#endif
namespace glm{
namespace detail
{
# if((GLM_LANG & GLM_LANG_CXX11) == GLM_LANG_CXX11)
typedef std::int8_t int8;
typedef std::int16_t int16;
typedef std::int32_t int32;
typedef std::int64_t int64;
typedef std::uint8_t uint8;
typedef std::uint16_t uint16;
typedef std::uint32_t uint32;
typedef std::uint64_t uint64;
# else
# if(defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) // C99 detected, 64 bit types available
typedef int64_t sint64;
typedef uint64_t uint64;
# elif(GLM_COMPILER & GLM_COMPILER_VC)
typedef signed __int64 sint64;
typedef unsigned __int64 uint64;
# elif(GLM_COMPILER & (GLM_COMPILER_GCC | GLM_COMPILER_LLVM_GCC | GLM_COMPILER_CLANG))
__extension__ typedef signed long long sint64;
__extension__ typedef unsigned long long uint64;
# elif(GLM_COMPILER & GLM_COMPILER_BC)
typedef Int64 sint64;
typedef Uint64 uint64;
# else//unknown compiler
typedef signed long long sint64;
typedef unsigned long long uint64;
# endif//GLM_COMPILER
typedef signed char int8;
typedef signed short int16;
typedef signed int int32;
typedef sint64 int64;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef uint64 uint64;
#endif//
template<bool C>
struct If
{
@ -97,318 +53,8 @@ namespace detail
return val;
}
};
//template <typename T>
//struct traits
//{
// static const bool is_signed = false;
// static const bool is_float = false;
// static const bool is_vector = false;
// static const bool is_matrix = false;
// static const bool is_genType = false;
// static const bool is_genIType = false;
// static const bool is_genUType = false;
//};
//template <>
//struct traits<half>
//{
// static const bool is_float = true;
// static const bool is_genType = true;
//};
//template <>
//struct traits<float>
//{
// static const bool is_float = true;
// static const bool is_genType = true;
//};
//template <>
//struct traits<double>
//{
// static const bool is_float = true;
// static const bool is_genType = true;
//};
//template <typename genType>
//struct desc
//{
// typedef genType type;
// typedef genType * pointer;
// typedef genType const* const_pointer;
// typedef genType const *const const_pointer_const;
// typedef genType *const pointer_const;
// typedef genType & reference;
// typedef genType const& const_reference;
// typedef genType const& param_type;
// typedef typename genType::value_type value_type;
// typedef typename genType::size_type size_type;
// static const typename size_type value_size;
//};
//template <typename genType>
//const typename desc<genType>::size_type desc<genType>::value_size = genType::value_size();
union uif32
{
GLM_FUNC_QUALIFIER uif32() :
i(0)
{}
GLM_FUNC_QUALIFIER uif32(float f) :
f(f)
{}
GLM_FUNC_QUALIFIER uif32(unsigned int i) :
i(i)
{}
float f;
unsigned int i;
};
union uif64
{
GLM_FUNC_QUALIFIER uif64() :
i(0)
{}
GLM_FUNC_QUALIFIER uif64(double f) :
f(f)
{}
GLM_FUNC_QUALIFIER uif64(uint64 i) :
i(i)
{}
double f;
uint64 i;
};
typedef uif32 uif;
//////////////////
// int
template <typename T>
struct is_int
{
enum is_int_enum
{
_YES = 0,
_NO = 1
};
};
#define GLM_DETAIL_IS_INT(T) \
template <> \
struct is_int<T> \
{ \
enum is_int_enum \
{ \
_YES = 1, \
_NO = 0 \
}; \
}
//////////////////
// uint
template <typename T>
struct is_uint
{
enum is_uint_enum
{
_YES = 0,
_NO = 1
};
};
#define GLM_DETAIL_IS_UINT(T) \
template <> \
struct is_uint<T> \
{ \
enum is_uint_enum \
{ \
_YES = 1, \
_NO = 0 \
}; \
}
//GLM_DETAIL_IS_UINT(unsigned long long)
//////////////////
// float
template <typename T>
struct is_float
{
enum is_float_enum
{
_YES = 0,
_NO = 1
};
};
#define GLM_DETAIL_IS_FLOAT(T) \
template <> \
struct is_float<T> \
{ \
enum is_float_enum \
{ \
_YES = 1, \
_NO = 0 \
}; \
}
//////////////////
// bool
template <typename T>
struct is_bool
{
enum is_bool_enum
{
_YES = 0,
_NO = 1
};
};
template <>
struct is_bool<bool>
{
enum is_bool_enum
{
_YES = 1,
_NO = 0
};
};
//////////////////
// vector
template <typename T>
struct is_vector
{
enum is_vector_enum
{
_YES = 0,
_NO = 1
};
};
# define GLM_DETAIL_IS_VECTOR(TYPE) \
template <typename T> \
struct is_vector<TYPE<T> > \
{ \
enum is_vector_enum \
{ \
_YES = 1, \
_NO = 0 \
}; \
}
//////////////////
// matrix
template <typename T>
struct is_matrix
{
enum is_matrix_enum
{
_YES = 0,
_NO = 1
};
};
#define GLM_DETAIL_IS_MATRIX(T) \
template <> \
struct is_matrix \
{ \
enum is_matrix_enum \
{ \
_YES = 1, \
_NO = 0 \
}; \
}
//////////////////
// type
template <typename T>
struct type
{
enum type_enum
{
is_float = is_float<T>::_YES,
is_int = is_int<T>::_YES,
is_uint = is_uint<T>::_YES,
is_bool = is_bool<T>::_YES
};
};
//////////////////
// float_or_int_trait
struct float_or_int_value
{
enum
{
GLM_ERROR,
GLM_FLOAT,
GLM_INT
};
};
template <typename T>
struct float_or_int_trait
{
enum{ID = float_or_int_value::GLM_ERROR};
};
}//namespace detail
}//namespace glm
#if((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2005))
# define GLM_DEPRECATED __declspec(deprecated)
# define GLM_ALIGN(x) __declspec(align(x))
# define GLM_ALIGNED_STRUCT(x) __declspec(align(x)) struct
# define GLM_RESTRICT __declspec(restrict)
# define GLM_RESTRICT_VAR __restrict
# define GLM_CONSTEXPR
#elif(GLM_COMPILER & GLM_COMPILER_INTEL)
# define GLM_DEPRECATED
# define GLM_ALIGN(x) __declspec(align(x))
# define GLM_ALIGNED_STRUCT(x) __declspec(align(x)) struct
# define GLM_RESTRICT
# define GLM_RESTRICT_VAR __restrict
# define GLM_CONSTEXPR
#elif(((GLM_COMPILER & (GLM_COMPILER_GCC | GLM_COMPILER_LLVM_GCC)) && (GLM_COMPILER >= GLM_COMPILER_GCC31)) || (GLM_COMPILER & GLM_COMPILER_CLANG))
# define GLM_DEPRECATED __attribute__((__deprecated__))
# define GLM_ALIGN(x) __attribute__((aligned(x)))
# define GLM_ALIGNED_STRUCT(x) struct __attribute__((aligned(x)))
# if(GLM_COMPILER >= GLM_COMPILER_GCC33)
# define GLM_RESTRICT __restrict__
# define GLM_RESTRICT_VAR __restrict__
# else
# define GLM_RESTRICT
# define GLM_RESTRICT_VAR
# endif
# define GLM_RESTRICT __restrict__
# define GLM_RESTRICT_VAR __restrict__
# if((GLM_COMPILER >= GLM_COMPILER_GCC47) && ((GLM_LANG & GLM_LANG_CXX0X) == GLM_LANG_CXX0X))
# define GLM_CONSTEXPR constexpr
# else
# define GLM_CONSTEXPR
# endif
#else
# define GLM_DEPRECATED
# define GLM_ALIGN
# define GLM_ALIGNED_STRUCT(x)
# define GLM_RESTRICT
# define GLM_RESTRICT_VAR
# define GLM_CONSTEXPR
#endif//GLM_COMPILER
*/
#endif//glm_core_detail

View File

@ -172,7 +172,7 @@ namespace glm
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packHalf2x16.xml">GLSL packHalf2x16 man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
uint packHalf2x16(vec2 const & v);
uint packHalf2x16(detail::tvec2<float32> const & v);
/// Returns a two-component floating-point vector with components obtained by unpacking a 32-bit unsigned integer into a pair of 16-bit values,
/// interpreting those values as 16-bit floating-point numbers according to the OpenGL Specification,

View File

@ -22,12 +22,14 @@
///
/// @ref core
/// @file glm/core/setup.hpp
/// @date 2006-11-13 / 2011-06-15
/// @date 2006-11-13 / 2013-03-30
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#ifndef glm_setup
#define glm_setup
#ifndef GLM_SETUP_INCLUDED
#define GLM_SETUP_INCLUDED
#include <cassert>
///////////////////////////////////////////////////////////////////////////////////////////////////
// Version
@ -726,4 +728,48 @@
# endif
#endif//GLM_MESSAGE
#endif//glm_setup
///////////////////////////////////////////////////////////////////////////////////////////////////
// Qualifiers
#if((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2005))
# define GLM_DEPRECATED __declspec(deprecated)
# define GLM_ALIGN(x) __declspec(align(x))
# define GLM_ALIGNED_STRUCT(x) __declspec(align(x)) struct
# define GLM_RESTRICT __declspec(restrict)
# define GLM_RESTRICT_VAR __restrict
# define GLM_CONSTEXPR
#elif(GLM_COMPILER & GLM_COMPILER_INTEL)
# define GLM_DEPRECATED
# define GLM_ALIGN(x) __declspec(align(x))
# define GLM_ALIGNED_STRUCT(x) __declspec(align(x)) struct
# define GLM_RESTRICT
# define GLM_RESTRICT_VAR __restrict
# define GLM_CONSTEXPR
#elif(((GLM_COMPILER & (GLM_COMPILER_GCC | GLM_COMPILER_LLVM_GCC)) && (GLM_COMPILER >= GLM_COMPILER_GCC31)) || (GLM_COMPILER & GLM_COMPILER_CLANG))
# define GLM_DEPRECATED __attribute__((__deprecated__))
# define GLM_ALIGN(x) __attribute__((aligned(x)))
# define GLM_ALIGNED_STRUCT(x) struct __attribute__((aligned(x)))
# if(GLM_COMPILER >= GLM_COMPILER_GCC33)
# define GLM_RESTRICT __restrict__
# define GLM_RESTRICT_VAR __restrict__
# else
# define GLM_RESTRICT
# define GLM_RESTRICT_VAR
# endif
# define GLM_RESTRICT __restrict__
# define GLM_RESTRICT_VAR __restrict__
# if((GLM_COMPILER >= GLM_COMPILER_GCC47) && ((GLM_LANG & GLM_LANG_CXX0X) == GLM_LANG_CXX0X))
# define GLM_CONSTEXPR constexpr
# else
# define GLM_CONSTEXPR
# endif
#else
# define GLM_DEPRECATED
# define GLM_ALIGN
# define GLM_ALIGNED_STRUCT(x)
# define GLM_RESTRICT
# define GLM_RESTRICT_VAR
# define GLM_CONSTEXPR
#endif//GLM_COMPILER
#endif//GLM_SETUP_INCLUDED

View File

@ -33,8 +33,6 @@
#include "type_float.hpp"
#include "type_int.hpp"
#include "type_gentype.hpp"
#include "type_vec1.hpp"
#include "type_vec2.hpp"
#include "type_vec3.hpp"
@ -177,7 +175,7 @@ namespace glm
//////////////////////////
// Signed integer definition
#if(defined(GLM_PRECISION_HIGHP_INT))
typedef highp_ivec2 ivec2;
typedef highp_ivec3 ivec3;
@ -191,25 +189,25 @@ namespace glm
typedef lowp_ivec3 ivec3;
typedef lowp_ivec4 ivec4;
#else
//! 2 components vector of signed integer numbers.
///
//! 2 components vector of signed integer numbers.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.5 Vectors</a>
typedef mediump_ivec2 ivec2;
//! 3 components vector of signed integer numbers.
///
//! 3 components vector of signed integer numbers.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.5 Vectors</a>
typedef mediump_ivec3 ivec3;
//! 4 components vector of signed integer numbers.
///
//! 4 components vector of signed integer numbers.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.5 Vectors</a>
typedef mediump_ivec4 ivec4;
#endif//GLM_PRECISION
//////////////////////////
// Unsigned integer definition
#if(defined(GLM_PRECISION_HIGHP_UINT))
typedef highp_uvec2 uvec2;
typedef highp_uvec3 uvec3;
@ -223,22 +221,22 @@ namespace glm
typedef lowp_uvec3 uvec3;
typedef lowp_uvec4 uvec4;
#else
//! 2 components vector of unsigned integer numbers.
///
/// 2 components vector of unsigned integer numbers.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.5 Vectors</a>
typedef mediump_uvec2 uvec2;
//! 3 components vector of unsigned integer numbers.
///
/// 3 components vector of unsigned integer numbers.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.5 Vectors</a>
typedef mediump_uvec3 uvec3;
//! 4 components vector of unsigned integer numbers.
///
/// 4 components vector of unsigned integer numbers.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.5 Vectors</a>
typedef mediump_uvec4 uvec4;
#endif//GLM_PRECISION
//////////////////////////
// Boolean definition
@ -310,27 +308,27 @@ namespace glm
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
typedef detail::tmat3x2<double> dmat3x2;
//! 3 * 3 matrix of double-precision floating-point numbers.
/// 3 * 3 matrix of double-precision floating-point numbers.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
typedef detail::tmat3x3<double> dmat3x3;
//! 3 * 4 matrix of double-precision floating-point numbers.
/// 3 * 4 matrix of double-precision floating-point numbers.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
typedef detail::tmat3x4<double> dmat3x4;
//! 4 * 2 matrix of double-precision floating-point numbers.
/// 4 * 2 matrix of double-precision floating-point numbers.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
typedef detail::tmat4x2<double> dmat4x2;
//! 4 * 3 matrix of double-precision floating-point numbers.
/// 4 * 3 matrix of double-precision floating-point numbers.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
typedef detail::tmat4x3<double> dmat4x3;
//! 4 * 4 matrix of double-precision floating-point numbers.
/// 4 * 4 matrix of double-precision floating-point numbers.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
typedef detail::tmat4x4<double> dmat4x4;

View File

@ -29,12 +29,13 @@
#ifndef glm_core_type_float
#define glm_core_type_float
#include "type_half.hpp"
#include "setup.hpp"
namespace glm{
namespace detail
{
class half;
typedef detail::half float16;
typedef float float32;
typedef double float64;
@ -100,6 +101,30 @@ namespace detail
namespace detail
{
//////////////////
// float
template <typename T>
struct is_float
{
enum is_float_enum
{
_YES = 0,
_NO = 1
};
};
#define GLM_DETAIL_IS_FLOAT(T) \
template <> \
struct is_float<T> \
{ \
enum is_float_enum \
{ \
_YES = 1, \
_NO = 0 \
}; \
}
////////////////////
// Mark half to be flaot
GLM_DETAIL_IS_FLOAT(detail::half);
@ -124,6 +149,57 @@ namespace detail
{
enum{ID = float_or_int_value::GLM_FLOAT};
};
union uif32
{
GLM_FUNC_QUALIFIER uif32() :
i(0)
{}
GLM_FUNC_QUALIFIER uif32(float f) :
f(f)
{}
GLM_FUNC_QUALIFIER uif32(uint32 i) :
i(i)
{}
float f;
uint32 i;
};
union uif64
{
GLM_FUNC_QUALIFIER uif64() :
i(0)
{}
GLM_FUNC_QUALIFIER uif64(double f) :
f(f)
{}
GLM_FUNC_QUALIFIER uif64(uint64 i) :
i(i)
{}
double f;
uint64 i;
};
//////////////////
// type
template <typename T>
struct type
{
enum type_enum
{
is_float = is_float<T>::_YES,
is_int = is_int<T>::_YES,
is_uint = is_uint<T>::_YES,
is_bool = is_bool<T>::_YES
};
};
}//namespace detail
}//namespace glm

View File

@ -161,7 +161,61 @@ namespace detail
class_type& operator-- ();
};
*/
}//namespace detail
//template <typename T>
//struct traits
//{
// static const bool is_signed = false;
// static const bool is_float = false;
// static const bool is_vector = false;
// static const bool is_matrix = false;
// static const bool is_genType = false;
// static const bool is_genIType = false;
// static const bool is_genUType = false;
//};
//template <>
//struct traits<half>
//{
// static const bool is_float = true;
// static const bool is_genType = true;
//};
//template <>
//struct traits<float>
//{
// static const bool is_float = true;
// static const bool is_genType = true;
//};
//template <>
//struct traits<double>
//{
// static const bool is_float = true;
// static const bool is_genType = true;
//};
//template <typename genType>
//struct desc
//{
// typedef genType type;
// typedef genType * pointer;
// typedef genType const* const_pointer;
// typedef genType const *const const_pointer_const;
// typedef genType *const pointer_const;
// typedef genType & reference;
// typedef genType const& const_reference;
// typedef genType const& param_type;
// typedef typename genType::value_type value_type;
// typedef typename genType::size_type size_type;
// static const typename size_type value_size;
//};
//template <typename genType>
//const typename desc<genType>::size_type desc<genType>::value_size = genType::value_size();
}//namespace detail
}//namespace glm
//#include "type_gentype.inl"

View File

@ -29,7 +29,6 @@
#ifndef glm_core_type_half
#define glm_core_type_half
#include <cstdlib>
#include "_detail.hpp"
namespace glm{

View File

@ -57,7 +57,7 @@ namespace detail
// Plus or minus zero
//
detail::uif result;
detail::uif32 result;
result.i = (unsigned int)(s << 31);
return result.f;
}
@ -85,7 +85,7 @@ namespace detail
// Positive or negative infinity
//
uif result;
uif32 result;
result.i = (unsigned int)((s << 31) | 0x7f800000);
return result.f;
}
@ -95,7 +95,7 @@ namespace detail
// Nan -- preserve sign and significand bits
//
uif result;
uif32 result;
result.i = (unsigned int)((s << 31) | 0x7f800000 | (m << 13));
return result.f;
}
@ -112,14 +112,14 @@ namespace detail
// Assemble s, e and m.
//
uif Result;
uif32 Result;
Result.i = (unsigned int)((s << 31) | (e << 23) | m);
return Result.f;
}
GLM_FUNC_QUALIFIER hdata toFloat16(float const & f)
{
uif Entry;
uif32 Entry;
Entry.f = f;
int i = (int)Entry.i;

View File

@ -22,7 +22,7 @@
///
/// @ref core
/// @file glm/core/type_int.hpp
/// @date 2008-08-22 / 2011-06-15
/// @date 2008-08-22 / 2013-03-30
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
@ -32,27 +32,71 @@
#include "setup.hpp"
#include "_detail.hpp"
#if(((GLM_LANG & GLM_LANG_CXX11) == GLM_LANG_CXX11) || (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)))
//#if((defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)))
#include <cstdint>
#endif
namespace glm{
namespace detail
{
# if((GLM_LANG & GLM_LANG_CXX11) == GLM_LANG_CXX11)
typedef std::int8_t int8;
typedef std::int16_t int16;
typedef std::int32_t int32;
typedef std::int64_t int64;
typedef std::uint8_t uint8;
typedef std::uint16_t uint16;
typedef std::uint32_t uint32;
typedef std::uint64_t uint64;
# else
# if(defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) // C99 detected, 64 bit types available
typedef int64_t sint64;
typedef uint64_t uint64;
# elif(GLM_COMPILER & GLM_COMPILER_VC)
typedef signed __int64 sint64;
typedef unsigned __int64 uint64;
# elif(GLM_COMPILER & (GLM_COMPILER_GCC | GLM_COMPILER_LLVM_GCC | GLM_COMPILER_CLANG))
__extension__ typedef signed long long sint64;
__extension__ typedef unsigned long long uint64;
# elif(GLM_COMPILER & GLM_COMPILER_BC)
typedef Int64 sint64;
typedef Uint64 uint64;
# else//unknown compiler
typedef signed long long sint64;
typedef unsigned long long uint64;
# endif//GLM_COMPILER
typedef signed char int8;
typedef signed short int16;
typedef signed int int32;
typedef sint64 int64;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef uint64 uint64;
#endif//
typedef signed short lowp_int_t;
typedef signed int mediump_int_t;
typedef int64 highp_int_t;
typedef unsigned short lowp_uint_t;
typedef unsigned int mediump_uint_t;
typedef uint64 highp_uint_t;
}//namespace detail
typedef detail::int8 int8;
typedef detail::int16 int16;
typedef detail::int32 int32;
typedef detail::int64 int64;
typedef detail::int8 int8;
typedef detail::int16 int16;
typedef detail::int32 int32;
typedef detail::int64 int64;
typedef detail::uint8 uint8;
typedef detail::uint16 uint16;
typedef detail::uint32 uint32;
typedef detail::uint64 uint64;
typedef detail::uint8 uint8;
typedef detail::uint16 uint16;
typedef detail::uint32 uint32;
typedef detail::uint64 uint64;
/// @addtogroup core_precision
/// @{
@ -126,7 +170,7 @@ namespace detail
/// Unsigned integer type.
///
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.3 Integers</a>
typedef uint_t uint;
typedef uint_t uint;
/// @}
@ -146,11 +190,59 @@ namespace detail
namespace detail
{
//////////////////
// int
template <typename T>
struct is_int
{
enum is_int_enum
{
_YES = 0,
_NO = 1
};
};
#define GLM_DETAIL_IS_INT(T) \
template <> \
struct is_int<T> \
{ \
enum is_int_enum \
{ \
_YES = 1, \
_NO = 0 \
}; \
}
GLM_DETAIL_IS_INT(signed char);
GLM_DETAIL_IS_INT(signed short);
GLM_DETAIL_IS_INT(signed int);
GLM_DETAIL_IS_INT(signed long);
GLM_DETAIL_IS_INT(highp_int_t);
//////////////////
// uint
template <typename T>
struct is_uint
{
enum is_uint_enum
{
_YES = 0,
_NO = 1
};
};
#define GLM_DETAIL_IS_UINT(T) \
template <> \
struct is_uint<T> \
{ \
enum is_uint_enum \
{ \
_YES = 1, \
_NO = 0 \
}; \
}
GLM_DETAIL_IS_UINT(unsigned char);
GLM_DETAIL_IS_UINT(unsigned short);
@ -158,50 +250,92 @@ namespace detail
GLM_DETAIL_IS_UINT(unsigned long);
GLM_DETAIL_IS_UINT(highp_uint_t);
//////////////////
// bool
template <typename T>
struct is_bool
{
enum is_bool_enum
{
_YES = 0,
_NO = 1
};
};
template <>
struct float_or_int_trait<int8>
struct is_bool<bool>
{
enum is_bool_enum
{
_YES = 1,
_NO = 0
};
};
//////////////////
// float_or_int_trait
struct float_or_int_value
{
enum
{
GLM_ERROR,
GLM_FLOAT,
GLM_INT
};
};
template <typename T>
struct float_or_int_trait
{
enum{ID = float_or_int_value::GLM_ERROR};
};
template <>
struct float_or_int_trait<detail::int8>
{
enum{ID = float_or_int_value::GLM_INT};
};
template <>
struct float_or_int_trait<int16>
struct float_or_int_trait<detail::int16>
{
enum{ID = float_or_int_value::GLM_INT};
};
template <>
struct float_or_int_trait<int32>
struct float_or_int_trait<detail::int32>
{
enum{ID = float_or_int_value::GLM_INT};
};
template <>
struct float_or_int_trait<int64>
struct float_or_int_trait<detail::int64>
{
enum{ID = float_or_int_value::GLM_INT};
};
template <>
struct float_or_int_trait<uint8>
struct float_or_int_trait<detail::uint8>
{
enum{ID = float_or_int_value::GLM_INT};
};
template <>
struct float_or_int_trait<uint16>
struct float_or_int_trait<detail::uint16>
{
enum{ID = float_or_int_value::GLM_INT};
};
template <>
struct float_or_int_trait<uint32>
struct float_or_int_trait<detail::uint32>
{
enum{ID = float_or_int_value::GLM_INT};
};
template <>
struct float_or_int_trait<uint64>
struct float_or_int_trait<detail::uint64>
{
enum{ID = float_or_int_value::GLM_INT};
};

View File

@ -34,7 +34,26 @@
namespace glm{
namespace detail
{
template <typename T>
struct is_matrix
{
enum is_matrix_enum
{
_YES = 0,
_NO = 1
};
};
#define GLM_DETAIL_IS_MATRIX(T) \
template <> \
struct is_matrix \
{ \
enum is_matrix_enum \
{ \
_YES = 1, \
_NO = 0 \
}; \
}
}//namespace detail
}//namespace glm

View File

@ -34,7 +34,26 @@
namespace glm{
namespace detail
{
template <typename T>
struct is_vector
{
enum is_vector_enum
{
_YES = 0,
_NO = 1
};
};
# define GLM_DETAIL_IS_VECTOR(TYPE) \
template <typename T> \
struct is_vector<TYPE<T> > \
{ \
enum is_vector_enum \
{ \
_YES = 1, \
_NO = 0 \
}; \
}
}//namespace detail
}//namespace glm

58
glm/fwd.hpp Normal file
View File

@ -0,0 +1,58 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @ref core
/// @file glm/fwd.hpp
/// @date 2013-03-30 / 2013-03-30
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#ifndef GLM_FWD_INCLUDED
#define GLM_FWD_INCLUDED
#include "core/type_int.hpp"
#include "core/type_float.hpp"
namespace glm{
namespace detail
{
class half;
template <typename T> struct tvec1;
template <typename T> struct tvec2;
template <typename T> struct tvec3;
template <typename T> struct tvec4;
template <typename T> struct tmat2x2;
template <typename T> struct tmat2x3;
template <typename T> struct tmat2x4;
template <typename T> struct tmat3x2;
template <typename T> struct tmat3x3;
template <typename T> struct tmat3x4;
template <typename T> struct tmat4x2;
template <typename T> struct tmat4x3;
template <typename T> struct tmat4x4;
}//namespace detail
}//namespace glm
#endif//GLM_FWD_INCLUDED

View File

@ -84,8 +84,10 @@
#include <climits>
#include <cfloat>
#include <limits>
#include <cstdio>
//#include <cstdint>
//#include <type_traits>
#include "fwd.hpp"
#include "core/setup.hpp"
#if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_CORE_INCLUDED_DISPLAYED))
@ -95,8 +97,28 @@
#include "./core/_detail.hpp"
#include "./core/_vectorize.hpp"
#include "./core/type_half.hpp"
#include "./core/type_float.hpp"
#include "./core/type_int.hpp"
#include "./core/type.hpp"
#include "./core/type_vec1.hpp"
#include "./core/type_vec2.hpp"
#include "./core/type_vec3.hpp"
#include "./core/type_vec4.hpp"
#include "./core/type_mat2x2.hpp"
#include "./core/type_mat2x3.hpp"
#include "./core/type_mat2x4.hpp"
#include "./core/type_mat3x2.hpp"
#include "./core/type_mat3x3.hpp"
#include "./core/type_mat3x4.hpp"
#include "./core/type_mat4x2.hpp"
#include "./core/type_mat4x3.hpp"
#include "./core/type_mat4x4.hpp"
#include "./core/func_trigonometric.hpp"
#include "./core/func_exponential.hpp"
#include "./core/func_common.hpp"
@ -106,6 +128,7 @@
#include "./core/func_vector_relational.hpp"
#include "./core/func_integer.hpp"
#include "./core/func_noise.hpp"
#include "./core/_swizzle.hpp"
#endif//glm_glm

View File

@ -39,7 +39,7 @@
#define GLM_GTX_matrix_interpolation GLM_VERSION
// Dependency:
//#include "../glm.hpp"
#include "../glm.hpp"
#if(defined(GLM_MESSAGES) && !defined(glm_ext))
# pragma message("GLM: GLM_GTX_matrix_interpolation extension included")

View File

@ -254,6 +254,13 @@ int test_model()
return Error;
}
int test_cpp_version()
{
std::cout << "__cplusplus: " << __cplusplus << std::endl;
return 0;
}
int test_operators()
{
glm::vec3 A(1.0f);
@ -268,6 +275,7 @@ int main()
{
int Error = 0;
Error += test_cpp_version();
Error += test_compiler();
Error += test_model();
Error += test_operators();

View File

@ -11,7 +11,7 @@
#include <glm/gtc/random.hpp>
#include <glm/gtc/epsilon.hpp>
#include <iostream>
#if(GLM_LANG & GLM_LANG_CXX0X)
#if((GLM_LANG & GLM_LANG_CXX0X) == GLM_LANG_CXX0X)
# include <array>
#endif
@ -139,7 +139,7 @@ int test_ballRand()
return Error;
}
#if(GLM_LANG & GLM_LANG_CXX0X)
#if((GLM_LANG & GLM_LANG_CXX0X) == GLM_LANG_CXX0X)
int test_grid()
{
int Error = 0;
@ -188,6 +188,9 @@ int main()
Error += test_sphericalRand();
Error += test_diskRand();
Error += test_ballRand();
#if((GLM_LANG & GLM_LANG_CXX0X) == GLM_LANG_CXX0X)
Error += test_grid();
#endif
return Error;
}