mirror of
https://github.com/g-truc/glm.git
synced 2024-11-22 17:04:35 +00:00
No more default initialization of vector, matrix and quaternion types
This commit is contained in:
parent
c834d06c27
commit
4cf8a10af2
@ -692,14 +692,8 @@
|
||||
|
||||
#if GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
# define GLM_DEFAULT = default
|
||||
# ifdef GLM_FORCE_NO_CTOR_INIT
|
||||
# define GLM_DEFAULT_CTOR = default
|
||||
# else
|
||||
# define GLM_DEFAULT_CTOR
|
||||
# endif
|
||||
#else
|
||||
# define GLM_DEFAULT
|
||||
# define GLM_DEFAULT_CTOR
|
||||
#endif
|
||||
|
||||
#if GLM_HAS_CONSTEXPR || GLM_HAS_CONSTEXPR_PARTIAL
|
||||
|
@ -34,7 +34,7 @@ namespace glm
|
||||
|
||||
// -- Constructors --
|
||||
|
||||
GLM_FUNC_DECL mat() GLM_DEFAULT_CTOR;
|
||||
GLM_FUNC_DECL mat() GLM_DEFAULT;
|
||||
GLM_FUNC_DECL mat(mat<2, 2, T, P> const & m) GLM_DEFAULT;
|
||||
template<precision Q>
|
||||
GLM_FUNC_DECL mat(mat<2, 2, T, Q> const & m);
|
||||
|
@ -7,15 +7,10 @@ namespace glm
|
||||
{
|
||||
// -- Constructors --
|
||||
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT)
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER mat<2, 2, T, P>::mat()
|
||||
{
|
||||
# ifndef GLM_FORCE_NO_CTOR_INIT
|
||||
this->value[0] = col_type(1, 0);
|
||||
this->value[1] = col_type(0, 1);
|
||||
# endif
|
||||
}
|
||||
{}
|
||||
# endif
|
||||
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
|
@ -35,7 +35,7 @@ namespace glm
|
||||
|
||||
// -- Constructors --
|
||||
|
||||
GLM_FUNC_DECL mat() GLM_DEFAULT_CTOR;
|
||||
GLM_FUNC_DECL mat() GLM_DEFAULT;
|
||||
GLM_FUNC_DECL mat(mat<2, 3, T, P> const & m) GLM_DEFAULT;
|
||||
template<precision Q>
|
||||
GLM_FUNC_DECL mat(mat<2, 3, T, Q> const & m);
|
||||
|
@ -5,15 +5,10 @@ namespace glm
|
||||
{
|
||||
// -- Constructors --
|
||||
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT)
|
||||
template<typename T, precision P>
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER mat<2, 3, T, P>::mat()
|
||||
{
|
||||
# ifndef GLM_FORCE_NO_CTOR_INIT
|
||||
this->value[0] = col_type(1, 0, 0);
|
||||
this->value[1] = col_type(0, 1, 0);
|
||||
# endif
|
||||
}
|
||||
{}
|
||||
# endif
|
||||
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
|
@ -35,7 +35,7 @@ namespace glm
|
||||
|
||||
// -- Constructors --
|
||||
|
||||
GLM_FUNC_DECL mat() GLM_DEFAULT_CTOR;
|
||||
GLM_FUNC_DECL mat() GLM_DEFAULT;
|
||||
GLM_FUNC_DECL mat(mat<2, 4, T, P> const & m) GLM_DEFAULT;
|
||||
template<precision Q>
|
||||
GLM_FUNC_DECL mat(mat<2, 4, T, Q> const & m);
|
||||
|
@ -5,15 +5,10 @@ namespace glm
|
||||
{
|
||||
// -- Constructors --
|
||||
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT)
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER mat<2, 4, T, P>::mat()
|
||||
{
|
||||
# ifndef GLM_FORCE_NO_CTOR_INIT
|
||||
this->value[0] = col_type(1, 0, 0, 0);
|
||||
this->value[1] = col_type(0, 1, 0, 0);
|
||||
# endif
|
||||
}
|
||||
{}
|
||||
# endif
|
||||
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
|
@ -35,7 +35,7 @@ namespace glm
|
||||
|
||||
// -- Constructors --
|
||||
|
||||
GLM_FUNC_DECL mat() GLM_DEFAULT_CTOR;
|
||||
GLM_FUNC_DECL mat() GLM_DEFAULT;
|
||||
GLM_FUNC_DECL mat(mat<3, 2, T, P> const & m) GLM_DEFAULT;
|
||||
template<precision Q>
|
||||
GLM_FUNC_DECL mat(mat<3, 2, T, Q> const & m);
|
||||
|
@ -5,16 +5,10 @@ namespace glm
|
||||
{
|
||||
// -- Constructors --
|
||||
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT)
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER mat<3, 2, T, P>::mat()
|
||||
{
|
||||
# ifndef GLM_FORCE_NO_CTOR_INIT
|
||||
this->value[0] = col_type(1, 0);
|
||||
this->value[1] = col_type(0, 1);
|
||||
this->value[2] = col_type(0, 0);
|
||||
# endif
|
||||
}
|
||||
{}
|
||||
# endif
|
||||
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
|
@ -34,7 +34,7 @@ namespace glm
|
||||
|
||||
// -- Constructors --
|
||||
|
||||
GLM_FUNC_DECL mat() GLM_DEFAULT_CTOR;
|
||||
GLM_FUNC_DECL mat() GLM_DEFAULT;
|
||||
GLM_FUNC_DECL mat(mat<3, 3, T, P> const & m) GLM_DEFAULT;
|
||||
template<precision Q>
|
||||
GLM_FUNC_DECL mat(mat<3, 3, T, Q> const & m);
|
||||
|
@ -7,16 +7,10 @@ namespace glm
|
||||
{
|
||||
// -- Constructors --
|
||||
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT)
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER mat<3, 3, T, P>::mat()
|
||||
{
|
||||
# ifndef GLM_FORCE_NO_CTOR_INIT
|
||||
this->value[0] = col_type(1, 0, 0);
|
||||
this->value[1] = col_type(0, 1, 0);
|
||||
this->value[2] = col_type(0, 0, 1);
|
||||
# endif
|
||||
}
|
||||
{}
|
||||
# endif
|
||||
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
|
@ -35,7 +35,7 @@ namespace glm
|
||||
|
||||
// -- Constructors --
|
||||
|
||||
GLM_FUNC_DECL mat() GLM_DEFAULT_CTOR;
|
||||
GLM_FUNC_DECL mat() GLM_DEFAULT;
|
||||
GLM_FUNC_DECL mat(mat<3, 4, T, P> const & m) GLM_DEFAULT;
|
||||
template<precision Q>
|
||||
GLM_FUNC_DECL mat(mat<3, 4, T, Q> const & m);
|
||||
|
@ -5,16 +5,10 @@ namespace glm
|
||||
{
|
||||
// -- Constructors --
|
||||
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT)
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER mat<3, 4, T, P>::mat()
|
||||
{
|
||||
# ifndef GLM_FORCE_NO_CTOR_INIT
|
||||
this->value[0] = col_type(1, 0, 0, 0);
|
||||
this->value[1] = col_type(0, 1, 0, 0);
|
||||
this->value[2] = col_type(0, 0, 1, 0);
|
||||
# endif
|
||||
}
|
||||
{}
|
||||
# endif
|
||||
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
|
@ -35,7 +35,7 @@ namespace glm
|
||||
|
||||
// -- Constructors --
|
||||
|
||||
GLM_FUNC_DECL mat() GLM_DEFAULT_CTOR;
|
||||
GLM_FUNC_DECL mat() GLM_DEFAULT;
|
||||
GLM_FUNC_DECL mat(mat<4, 2, T, P> const & m) GLM_DEFAULT;
|
||||
template<precision Q>
|
||||
GLM_FUNC_DECL mat(mat<4, 2, T, Q> const & m);
|
||||
|
@ -5,17 +5,10 @@ namespace glm
|
||||
{
|
||||
// -- Constructors --
|
||||
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT)
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER mat<4, 2, T, P>::mat()
|
||||
{
|
||||
# ifndef GLM_FORCE_NO_CTOR_INIT
|
||||
this->value[0] = col_type(1, 0);
|
||||
this->value[1] = col_type(0, 1);
|
||||
this->value[2] = col_type(0, 0);
|
||||
this->value[3] = col_type(0, 0);
|
||||
# endif
|
||||
}
|
||||
{}
|
||||
# endif
|
||||
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
|
@ -35,7 +35,7 @@ namespace glm
|
||||
|
||||
// -- Constructors --
|
||||
|
||||
GLM_FUNC_DECL mat() GLM_DEFAULT_CTOR;
|
||||
GLM_FUNC_DECL mat() GLM_DEFAULT;
|
||||
GLM_FUNC_DECL mat(mat<4, 3, T, P> const & m) GLM_DEFAULT;
|
||||
template<precision Q>
|
||||
GLM_FUNC_DECL mat(mat<4, 3, T, Q> const & m);
|
||||
|
@ -5,17 +5,10 @@ namespace glm
|
||||
{
|
||||
// -- Constructors --
|
||||
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT)
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER mat<4, 3, T, P>::mat()
|
||||
{
|
||||
# ifndef GLM_FORCE_NO_CTOR_INIT
|
||||
this->value[0] = col_type(1, 0, 0);
|
||||
this->value[1] = col_type(0, 1, 0);
|
||||
this->value[2] = col_type(0, 0, 1);
|
||||
this->value[3] = col_type(0, 0, 0);
|
||||
# endif
|
||||
}
|
||||
{}
|
||||
# endif
|
||||
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
|
@ -34,7 +34,7 @@ namespace glm
|
||||
|
||||
// -- Constructors --
|
||||
|
||||
GLM_FUNC_DECL mat() GLM_DEFAULT_CTOR;
|
||||
GLM_FUNC_DECL mat() GLM_DEFAULT;
|
||||
GLM_FUNC_DECL mat(mat<4, 4, T, P> const& m) GLM_DEFAULT;
|
||||
template<precision Q>
|
||||
GLM_FUNC_DECL mat(mat<4, 4, T, Q> const& m);
|
||||
|
@ -7,17 +7,10 @@ namespace glm
|
||||
{
|
||||
// -- Constructors --
|
||||
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT)
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER mat<4, 4, T, P>::mat()
|
||||
{
|
||||
# ifndef GLM_FORCE_NO_CTOR_INIT
|
||||
this->value[0] = col_type(1, 0, 0, 0);
|
||||
this->value[1] = col_type(0, 1, 0, 0);
|
||||
this->value[2] = col_type(0, 0, 1, 0);
|
||||
this->value[3] = col_type(0, 0, 0, 1);
|
||||
# endif
|
||||
}
|
||||
{}
|
||||
# endif
|
||||
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
|
@ -85,7 +85,7 @@ namespace glm
|
||||
|
||||
// -- Implicit basic constructors --
|
||||
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec() GLM_DEFAULT_CTOR;
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec() GLM_DEFAULT;
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec const& v) GLM_DEFAULT;
|
||||
template<precision Q>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec<1, T, Q> const& v);
|
||||
|
@ -5,12 +5,9 @@ namespace glm
|
||||
{
|
||||
// -- Implicit basic constructors --
|
||||
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT)
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR vec<1, T, P>::vec()
|
||||
# ifndef GLM_FORCE_NO_CTOR_INIT
|
||||
: x(0)
|
||||
# endif
|
||||
{}
|
||||
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
|
||||
|
@ -86,7 +86,7 @@ namespace glm
|
||||
|
||||
// -- Implicit basic constructors --
|
||||
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec() GLM_DEFAULT_CTOR;
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec() GLM_DEFAULT;
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec const& v) GLM_DEFAULT;
|
||||
template<precision Q>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec<2, T, Q> const& v);
|
||||
|
@ -5,12 +5,9 @@ namespace glm
|
||||
{
|
||||
// -- Implicit basic constructors --
|
||||
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT)
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR vec<2, T, P>::vec()
|
||||
# ifndef GLM_FORCE_NO_CTOR_INIT
|
||||
: x(0), y(0)
|
||||
# endif
|
||||
{}
|
||||
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
|
||||
|
@ -86,7 +86,7 @@ namespace glm
|
||||
|
||||
// -- Implicit basic constructors --
|
||||
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec() GLM_DEFAULT_CTOR;
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec() GLM_DEFAULT;
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec const & v) GLM_DEFAULT;
|
||||
template<precision Q>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec<3, T, Q> const & v);
|
||||
|
@ -5,12 +5,9 @@ namespace glm
|
||||
{
|
||||
// -- Implicit basic constructors --
|
||||
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT)
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR vec<3, T, P>::vec()
|
||||
# ifndef GLM_FORCE_NO_CTOR_INIT
|
||||
: x(0), y(0), z(0)
|
||||
# endif
|
||||
{}
|
||||
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
|
||||
|
@ -89,7 +89,7 @@ namespace glm
|
||||
|
||||
// -- Implicit basic constructors --
|
||||
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR_SIMD vec() GLM_DEFAULT_CTOR;
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR_SIMD vec() GLM_DEFAULT;
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR_SIMD vec(vec<4, T, P> const& v) GLM_DEFAULT;
|
||||
template<precision Q>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR_SIMD vec(vec<4, T, Q> const& v);
|
||||
|
@ -154,12 +154,9 @@ namespace detail
|
||||
|
||||
// -- Implicit basic constructors --
|
||||
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT)
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD vec<4, T, P>::vec()
|
||||
# ifndef GLM_FORCE_NO_CTOR_INIT
|
||||
: x(0), y(0), z(0), w(0)
|
||||
# endif
|
||||
{}
|
||||
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
|
||||
|
@ -77,7 +77,7 @@ namespace glm
|
||||
|
||||
// -- Implicit basic constructors --
|
||||
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR tquat() GLM_DEFAULT_CTOR;
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR tquat() GLM_DEFAULT;
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR tquat(tquat<T, P> const& q) GLM_DEFAULT;
|
||||
template<precision Q>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR tquat(tquat<T, Q> const& q);
|
||||
|
@ -83,12 +83,9 @@ namespace detail
|
||||
|
||||
// -- Implicit basic constructors --
|
||||
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT)
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR tquat<T, P>::tquat()
|
||||
# ifndef GLM_FORCE_NO_CTOR_INIT
|
||||
: x(0), y(0), z(0), w(1)
|
||||
# endif
|
||||
{}
|
||||
# endif
|
||||
|
||||
@ -294,19 +291,19 @@ namespace detail
|
||||
// -- Binary operators --
|
||||
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> operator+(tquat<T, P> const & q, tquat<T, P> const & p)
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> operator+(tquat<T, P> const & q, tquat<T, P> const & p)
|
||||
{
|
||||
return tquat<T, P>(q) += p;
|
||||
}
|
||||
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> operator*(tquat<T, P> const & q, tquat<T, P> const & p)
|
||||
GLM_FUNC_QUALIFIER tquat<T, P> operator*(tquat<T, P> const & q, tquat<T, P> const & p)
|
||||
{
|
||||
return tquat<T, P>(q) *= p;
|
||||
}
|
||||
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER vec<3, T, P> operator*(tquat<T, P> const & q, vec<3, T, P> const & v)
|
||||
GLM_FUNC_QUALIFIER vec<3, T, P> operator*(tquat<T, P> const & q, vec<3, T, P> const & v)
|
||||
{
|
||||
vec<3, T, P> const QuatVector(q.x, q.y, q.z);
|
||||
vec<3, T, P> const uv(glm::cross(QuatVector, v));
|
||||
|
@ -56,7 +56,7 @@ namespace glm
|
||||
|
||||
// -- Implicit basic constructors --
|
||||
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR tdualquat() GLM_DEFAULT_CTOR;
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR tdualquat() GLM_DEFAULT;
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR tdualquat(tdualquat<T, P> const & d) GLM_DEFAULT;
|
||||
template<precision Q>
|
||||
GLM_FUNC_DECL GLM_CONSTEXPR tdualquat(tdualquat<T, Q> const & d);
|
||||
|
@ -24,13 +24,9 @@ namespace glm
|
||||
|
||||
// -- Implicit basic constructors --
|
||||
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT)
|
||||
# if !GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
template<typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR tdualquat<T, P>::tdualquat()
|
||||
# ifndef GLM_FORCE_NO_CTOR_INIT
|
||||
: real(tquat<T, P>())
|
||||
, dual(tquat<T, P>(0, 0, 0, 0))
|
||||
# endif
|
||||
{}
|
||||
# endif
|
||||
|
||||
|
51
manual.md
51
manual.md
@ -22,9 +22,8 @@
|
||||
+ [3.4. SIMD support](#section3_4)
|
||||
+ [3.5. Force inline](#section3_5)
|
||||
+ [3.6. Vector and matrix static size](#section3_6)
|
||||
+ [3.7. Disabling default constructor initialization](#section3_7)
|
||||
+ [3.8. Requiring explicit conversions](#section3_8)
|
||||
+ [3.9. Removing genType restriction](#section3_9)
|
||||
+ [3.7. Requiring explicit conversions](#section3_7)
|
||||
+ [3.8. Removing genType restriction](#section3_8)
|
||||
+ [4. Stable extensions](#section4)
|
||||
+ [4.1. GLM_GTC_bitfield](#section4_1)
|
||||
+ [4.2. GLM_GTC_color_space](#section4_2)
|
||||
@ -469,49 +468,7 @@ void foo(vec4 const & v)
|
||||
}
|
||||
```
|
||||
|
||||
### <a name="section3_7"></a> 3.7. Disabling default constructor initialization
|
||||
|
||||
By default and following GLSL specifications, vector and matrix default constructors initialize the components to zero. This is a reliable behavior but initialization has a cost and it’s not always necessary.
|
||||
This behavior can be disabled at compilation time by define GLM\_FORCE\_NO\_CTOR\_INIT before any inclusion of <glm/glm.hpp> or other GLM include.
|
||||
|
||||
GLM default behavior:
|
||||
|
||||
```cpp
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
void foo()
|
||||
{
|
||||
glm::vec4 v; // v is (0.0f, 0.0f, 0.0f, 0.0f)
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
GLM behavior using GLM\_FORCE\_NO\_CTOR\_INIT:
|
||||
|
||||
```cpp
|
||||
#define GLM_FORCE_NO_CTOR_INIT
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
void foo()
|
||||
{
|
||||
glm::vec4 v; // v is filled with garbage
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
Alternatively, GLM allows to explicitly not initialize a variable:
|
||||
|
||||
```cpp
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
void foo()
|
||||
{
|
||||
glm::vec4 v(glm::uninitialize);
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
### <a name="section3_8"></a> 3.8. Require explicit conversions
|
||||
### <a name="section3_7"></a> 3.7. Requiring explicit conversions
|
||||
|
||||
GLSL supports implicit conversions of vector and matrix types. For example, an ivec4 can be implicitly converted into vec4.
|
||||
|
||||
@ -548,7 +505,7 @@ void foo()
|
||||
}
|
||||
```
|
||||
|
||||
### <a name="section3_9"></a> 3.9. Removing genType restriction
|
||||
### <a name="section3_8"></a> 3.8. Removing genType restriction
|
||||
|
||||
By default GLM only supports basic types as genType for vector, matrix and quaternion types:
|
||||
|
||||
|
@ -64,6 +64,7 @@ glm::mat4 camera(float Translate, glm::vec2 const & Rotate)
|
||||
- Added quatLookAt to GTX_quaternion #659
|
||||
|
||||
#### Improvements:
|
||||
- No more default initialization of vector, matrix and quaternion types
|
||||
- Added lowp variant of GTC_color_space convertLinearToSRGB #419
|
||||
- Replaced the manual by a markdown version #458
|
||||
- Optimized GTC_packing implementation
|
||||
|
Loading…
Reference in New Issue
Block a user