Added possible static_cast conversion of GLM types (#72)

master
Christophe Riccio ago%!(EXTRA string=12 years)
parent e5f8ebbfd7
commit d252dd243b
  1. 4
      glm/detail/type_mat2x2.hpp
  2. 12
      glm/detail/type_mat2x2.inl
  3. 4
      glm/detail/type_mat2x3.hpp
  4. 12
      glm/detail/type_mat2x3.inl
  5. 4
      glm/detail/type_mat2x4.hpp
  6. 12
      glm/detail/type_mat2x4.inl
  7. 4
      glm/detail/type_mat3x2.hpp
  8. 13
      glm/detail/type_mat3x2.inl
  9. 4
      glm/detail/type_mat3x3.hpp
  10. 13
      glm/detail/type_mat3x3.inl
  11. 4
      glm/detail/type_mat3x4.hpp
  12. 13
      glm/detail/type_mat3x4.inl
  13. 3
      glm/detail/type_mat4x2.hpp
  14. 13
      glm/detail/type_mat4x2.inl
  15. 3
      glm/detail/type_mat4x3.hpp
  16. 13
      glm/detail/type_mat4x3.inl
  17. 3
      glm/detail/type_mat4x4.hpp
  18. 16
      glm/detail/type_mat4x4.inl
  19. 4
      glm/detail/type_vec2.hpp
  20. 10
      glm/detail/type_vec2.inl
  21. 4
      glm/detail/type_vec3.hpp
  22. 11
      glm/detail/type_vec3.inl
  23. 4
      glm/detail/type_vec4.hpp
  24. 12
      glm/detail/type_vec4.inl
  25. 3
      readme.txt
  26. 5
      test/core/core_type_cast.cpp
  27. 8
      test/gtc/gtc_matrix_transform.cpp

@ -92,10 +92,6 @@ namespace detail
////////////////////////////////////// //////////////////////////////////////
// Conversions // Conversions
template <typename U>
GLM_FUNC_DECL explicit tmat2x2(
U const & x);
template <typename U, typename V, typename M, typename N> template <typename U, typename V, typename M, typename N>
GLM_FUNC_DECL explicit tmat2x2( GLM_FUNC_DECL explicit tmat2x2(
U const & x1, V const & y1, U const & x1, V const & y1,

@ -154,18 +154,6 @@ namespace detail
////////////////////////////////////// //////////////////////////////////////
// Conversion constructors // Conversion constructors
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tmat2x2<T, P>::tmat2x2
(
U const & s
)
{
value_type const Zero(0);
this->value[0] = tvec2<T, P>(static_cast<T>(s), Zero);
this->value[1] = tvec2<T, P>(Zero, value_type(s));
}
template <typename T, precision P> template <typename T, precision P>
template <typename X1, typename Y1, typename X2, typename Y2> template <typename X1, typename Y1, typename X2, typename Y2>
GLM_FUNC_QUALIFIER tmat2x2<T, P>::tmat2x2 GLM_FUNC_QUALIFIER tmat2x2<T, P>::tmat2x2

@ -82,10 +82,6 @@ namespace detail
////////////////////////////////////// //////////////////////////////////////
// Conversions // Conversions
template <typename U>
GLM_FUNC_DECL explicit tmat2x3(
U const & x);
template <typename X1, typename Y1, typename Z1, typename X2, typename Y2, typename Z2> template <typename X1, typename Y1, typename Z1, typename X2, typename Y2, typename Z2>
GLM_FUNC_DECL explicit tmat2x3( GLM_FUNC_DECL explicit tmat2x3(
X1 const & x1, Y1 const & y1, Z1 const & z1, X1 const & x1, Y1 const & y1, Z1 const & z1,

@ -153,18 +153,6 @@ namespace detail
////////////////////////////////////// //////////////////////////////////////
// Conversion constructors // Conversion constructors
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tmat2x3<T, P>::tmat2x3
(
U const & s
)
{
value_type const Zero(0);
this->value[0] = tvec3<T, P>(static_cast<T>(s), Zero, Zero);
this->value[1] = tvec3<T, P>(Zero, value_type(s), Zero);
}
template <typename T, precision P> template <typename T, precision P>
template < template <
typename X1, typename Y1, typename Z1, typename X1, typename Y1, typename Z1,

@ -82,10 +82,6 @@ namespace detail
////////////////////////////////////// //////////////////////////////////////
// Conversions // Conversions
template <typename U>
GLM_FUNC_DECL explicit tmat2x4(
U const & x);
template < template <
typename X1, typename Y1, typename Z1, typename W1, typename X1, typename Y1, typename Z1, typename W1,
typename X2, typename Y2, typename Z2, typename W2> typename X2, typename Y2, typename Z2, typename W2>

@ -156,18 +156,6 @@ namespace detail
////////////////////////////////////// //////////////////////////////////////
// Conversion constructors // Conversion constructors
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tmat2x4<T, P>::tmat2x4
(
U const & s
)
{
value_type const Zero(0);
this->value[0] = tvec4<T, P>(static_cast<T>(s), Zero, Zero, Zero);
this->value[1] = tvec4<T, P>(Zero, value_type(s), Zero, Zero);
}
template <typename T, precision P> template <typename T, precision P>
template < template <
typename X1, typename Y1, typename Z1, typename W1, typename X1, typename Y1, typename Z1, typename W1,

@ -84,10 +84,6 @@ namespace detail
////////////////////////////////////// //////////////////////////////////////
// Conversions // Conversions
template <typename U>
GLM_FUNC_DECL explicit tmat3x2(
U const & x);
template< template<
typename X1, typename Y1, typename X1, typename Y1,
typename X2, typename Y2, typename X2, typename Y2,

@ -163,19 +163,6 @@ namespace detail
////////////////////////////////////// //////////////////////////////////////
// Conversion constructors // Conversion constructors
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tmat3x2<T, P>::tmat3x2
(
U const & s
)
{
value_type const Zero(0);
this->value[0] = tvec2<T, P>(static_cast<T>(s), Zero);
this->value[1] = tvec2<T, P>(Zero, value_type(s));
this->value[2] = tvec2<T, P>(Zero);
}
template <typename T, precision P> template <typename T, precision P>
template < template <
typename X1, typename Y1, typename X1, typename Y1,

@ -93,10 +93,6 @@ namespace detail
////////////////////////////////////// //////////////////////////////////////
// Conversions // Conversions
template <typename U>
GLM_FUNC_DECL explicit tmat3x3(
U const & x);
template< template<
typename X1, typename Y1, typename Z1, typename X1, typename Y1, typename Z1,
typename X2, typename Y2, typename Z2, typename X2, typename Y2, typename Z2,

@ -166,19 +166,6 @@ namespace detail
////////////////////////////////////// //////////////////////////////////////
// Conversion constructors // Conversion constructors
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tmat3x3<T, P>::tmat3x3
(
U const & s
)
{
value_type const Zero(0);
this->value[0] = tvec3<T, P>(static_cast<T>(s), Zero, Zero);
this->value[1] = tvec3<T, P>(Zero, value_type(s), Zero);
this->value[2] = tvec3<T, P>(Zero, Zero, value_type(s));
}
template <typename T, precision P> template <typename T, precision P>
template < template <
typename X1, typename Y1, typename Z1, typename X1, typename Y1, typename Z1,

@ -84,10 +84,6 @@ namespace detail
////////////////////////////////////// //////////////////////////////////////
// Conversions // Conversions
template <typename U>
GLM_FUNC_DECL explicit tmat3x4(
U const & x);
template< template<
typename X1, typename Y1, typename Z1, typename W1, typename X1, typename Y1, typename Z1, typename W1,
typename X2, typename Y2, typename Z2, typename W2, typename X2, typename Y2, typename Z2, typename W2,

@ -139,19 +139,6 @@ namespace detail
////////////////////////////////////// //////////////////////////////////////
// Conversion constructors // Conversion constructors
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tmat3x4<T, P>::tmat3x4
(
U const & s
)
{
value_type const Zero(0);
this->value[0] = tvec4<T, P>(static_cast<T>(s), Zero, Zero, Zero);
this->value[1] = tvec4<T, P>(Zero, value_type(s), Zero, Zero);
this->value[2] = tvec4<T, P>(Zero, Zero, value_type(s), Zero);
}
template <typename T, precision P> template <typename T, precision P>
template < template <
typename X1, typename Y1, typename Z1, typename W1, typename X1, typename Y1, typename Z1, typename W1,

@ -86,9 +86,6 @@ namespace detail
////////////////////////////////////// //////////////////////////////////////
// Conversions // Conversions
template <typename U>
GLM_FUNC_DECL explicit tmat4x2(
U const & x);
template< template<
typename X1, typename Y1, typename X1, typename Y1,

@ -144,19 +144,6 @@ namespace detail
////////////////////////////////////// //////////////////////////////////////
// Conversion constructors // Conversion constructors
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tmat4x2<T, P>::tmat4x2
(
U const & s
)
{
value_type const Zero(0);
this->value[0] = tvec2<T, P>(static_cast<T>(s), Zero);
this->value[1] = tvec2<T, P>(Zero, value_type(s));
this->value[2] = tvec2<T, P>(Zero, Zero);
this->value[3] = tvec2<T, P>(Zero, Zero);
}
template <typename T, precision P> template <typename T, precision P>
template < template <

@ -86,9 +86,6 @@ namespace detail
////////////////////////////////////// //////////////////////////////////////
// Conversions // Conversions
template <typename U>
GLM_FUNC_DECL explicit tmat4x3(
U const & x);
template < template <
typename X1, typename Y1, typename Z1, typename X1, typename Y1, typename Z1,

@ -169,19 +169,6 @@ namespace detail
////////////////////////////////////// //////////////////////////////////////
// Conversion constructors // Conversion constructors
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tmat4x3<T, P>::tmat4x3
(
U const & s
)
{
value_type const Zero(0);
this->value[0] = tvec3<T, P>(static_cast<T>(s), Zero, Zero);
this->value[1] = tvec3<T, P>(Zero, value_type(s), Zero);
this->value[2] = tvec3<T, P>(Zero, Zero, value_type(s));
this->value[3] = tvec3<T, P>(Zero, Zero, Zero);
}
template <typename T, precision P> template <typename T, precision P>
template < template <

@ -99,9 +99,6 @@ namespace detail
////////////////////////////////////// //////////////////////////////////////
// Conversions // Conversions
template <typename U>
GLM_FUNC_DECL explicit tmat4x4(
U const & x);
template < template <
typename X1, typename Y1, typename Z1, typename W1, typename X1, typename Y1, typename Z1, typename W1,

@ -191,22 +191,6 @@ namespace detail
////////////////////////////////////// //////////////////////////////////////
// Conversion constructors // Conversion constructors
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tmat4x4<T, P>::tmat4x4
(
U const & s
)
{
GLM_STATIC_ASSERT(std::numeric_limits<U>::is_iec559 || std::numeric_limits<U>::is_integer, "*mat4x4 constructor only takes float and integer types");
value_type const Zero(0);
this->value[0] = tvec4<T, P>(static_cast<T>(s), Zero, Zero, Zero);
this->value[1] = tvec4<T, P>(Zero, value_type(s), Zero, Zero);
this->value[2] = tvec4<T, P>(Zero, Zero, value_type(s), Zero);
this->value[3] = tvec4<T, P>(Zero, Zero, Zero, value_type(s));
}
template <typename T, precision P> template <typename T, precision P>
template < template <
typename X1, typename Y1, typename Z1, typename W1, typename X1, typename Y1, typename Z1, typename W1,

@ -137,10 +137,6 @@ namespace detail
////////////////////////////////////// //////////////////////////////////////
// Conversion constructors // Conversion constructors
//! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U>
GLM_FUNC_DECL explicit tvec2(
U const & x);
//! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) //! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U, typename V> template <typename U, typename V>
GLM_FUNC_DECL explicit tvec2( GLM_FUNC_DECL explicit tvec2(

@ -111,16 +111,6 @@ namespace detail
////////////////////////////////////// //////////////////////////////////////
// Conversion scalar constructors // Conversion scalar constructors
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec2<T, P>::tvec2
(
U const & x
) :
x(static_cast<T>(x)),
y(static_cast<T>(x))
{}
template <typename T, precision P> template <typename T, precision P>
template <typename U, typename V> template <typename U, typename V>
GLM_FUNC_QUALIFIER tvec2<T, P>::tvec2 GLM_FUNC_QUALIFIER tvec2<T, P>::tvec2

@ -128,10 +128,6 @@ namespace detail
////////////////////////////////////// //////////////////////////////////////
// Conversion scalar constructors // Conversion scalar constructors
//! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U>
GLM_FUNC_DECL explicit tvec3(
U const & x);
//! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) //! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U, typename V, typename W> template <typename U, typename V, typename W>
GLM_FUNC_DECL explicit tvec3( GLM_FUNC_DECL explicit tvec3(

@ -118,17 +118,6 @@ namespace detail
////////////////////////////////////// //////////////////////////////////////
// Conversion scalar constructors // Conversion scalar constructors
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec3<T, P>::tvec3
(
U const & s
) :
x(static_cast<T>(s)),
y(static_cast<T>(s)),
z(static_cast<T>(s))
{}
template <typename T, precision P> template <typename T, precision P>
template <typename A, typename B, typename C> template <typename A, typename B, typename C>
GLM_FUNC_QUALIFIER tvec3<T, P>::tvec3 GLM_FUNC_QUALIFIER tvec3<T, P>::tvec3

@ -131,10 +131,6 @@ namespace detail
////////////////////////////////////// //////////////////////////////////////
// Conversion scalar constructors // Conversion scalar constructors
/// Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U>
GLM_FUNC_DECL explicit tvec4(
U const & x);
/// Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) /// Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename A, typename B, typename C, typename D> template <typename A, typename B, typename C, typename D>
GLM_FUNC_DECL explicit tvec4( GLM_FUNC_DECL explicit tvec4(

@ -125,18 +125,6 @@ namespace detail
////////////////////////////////////// //////////////////////////////////////
// Conversion scalar constructors // Conversion scalar constructors
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec4<T, P>::tvec4
(
U const & x
) :
x(static_cast<T>(x)),
y(static_cast<T>(x)),
z(static_cast<T>(x)),
w(static_cast<T>(x))
{}
template <typename T, precision P> template <typename T, precision P>
template <typename A, typename B, typename C, typename D> template <typename A, typename B, typename C, typename D>
GLM_FUNC_QUALIFIER tvec4<T, P>::tvec4 GLM_FUNC_QUALIFIER tvec4<T, P>::tvec4

@ -40,7 +40,8 @@ http://glm.g-truc.net/glm.pdf
GLM 0.9.5.1: 2014-XX-XX GLM 0.9.5.1: 2014-XX-XX
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
- Fixed angle and orientedAngle that sometimes return NaN values (#145) - Fixed angle and orientedAngle that sometimes return NaN values (#145)
- Deprecated degrees for function parameters and display a message. - Deprecated degrees for function parameters and display a message
- Added possible static_cast conversion of GLM types (#72)
================================================================================ ================================================================================
GLM 0.9.5.0: 2013-12-25 GLM 0.9.5.0: 2013-12-25

@ -27,8 +27,9 @@ int test_vec2_cast()
glm::mediump_vec2 G = static_cast<glm::mediump_vec2>(A); glm::mediump_vec2 G = static_cast<glm::mediump_vec2>(A);
glm::highp_vec2 H = static_cast<glm::highp_vec2>(A); glm::highp_vec2 H = static_cast<glm::highp_vec2>(A);
//my_vec2 I; my_vec2 I;
//glm::vec2 J = static_cast<glm::vec2>(I); glm::vec2 J = static_cast<glm::vec2>(I);
glm::vec2 K(7.8);
int Error(0); int Error(0);

@ -7,15 +7,21 @@
// File : test/gtc/matrix_transform.cpp // File : test/gtc/matrix_transform.cpp
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
#define GLM_FORCE_RADIANS
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp> #include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/constants.hpp>
int main() int main()
{ {
int Error = 0; int Error = 0;
glm::mat4 Projection = glm::perspective(45.0f, 4.0f / 3.0f, 0.1f, 100.0f); glm::mat4 Projection = glm::perspective(glm::pi<float>() * 0.25f, 4.0f / 3.0f, 0.1f, 100.0f);
glm::mat4 Pick = glm::pickMatrix(glm::vec2(1, 2), glm::vec2(3, 4), glm::ivec4(0, 0, 320, 240)); glm::mat4 Pick = glm::pickMatrix(glm::vec2(1, 2), glm::vec2(3, 4), glm::ivec4(0, 0, 320, 240));
glm::lowp_vec3 v(1.0);
glm::lowp_mat4 m(0);
glm::lowp_mat4 t = glm::translate(m, v);
return Error; return Error;
} }

Loading…
Cancel
Save