mirror of
https://github.com/JoeyDeVries/LearnOpenGL.git
synced 2026-01-10 02:23:23 +08:00
Update GLM to latest version (0.9.9.3). This includes GLM's change of matrices no longer default initializing to the identity matrix. This commit thus also includes the update of all of LearnOpenGL's code to reflect this: all matrices are now constructor-initialized to the identity matrix where relevant.
This commit is contained in:
@@ -1,50 +1,20 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2015 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.
|
||||
///
|
||||
/// Restrictions:
|
||||
/// By making use of the Software for military purposes, you choose to make
|
||||
/// a Bunny unhappy.
|
||||
///
|
||||
/// 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/detail/func_packing.inl
|
||||
/// @date 2010-03-17 / 2011-06-15
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "func_common.hpp"
|
||||
#include "../common.hpp"
|
||||
#include "type_half.hpp"
|
||||
#include "../fwd.hpp"
|
||||
|
||||
namespace glm
|
||||
{
|
||||
GLM_FUNC_QUALIFIER uint packUnorm2x16(vec2 const & v)
|
||||
GLM_FUNC_QUALIFIER uint packUnorm2x16(vec2 const& v)
|
||||
{
|
||||
union
|
||||
{
|
||||
u16 in[2];
|
||||
unsigned short in[2];
|
||||
uint out;
|
||||
} u;
|
||||
|
||||
u16vec2 result(round(clamp(v, 0.0f, 1.0f) * 65535.0f));
|
||||
vec<2, unsigned short, defaultp> result(round(clamp(v, 0.0f, 1.0f) * 65535.0f));
|
||||
|
||||
u.in[0] = result[0];
|
||||
u.in[1] = result[1];
|
||||
@@ -57,7 +27,7 @@ namespace glm
|
||||
union
|
||||
{
|
||||
uint in;
|
||||
u16 out[2];
|
||||
unsigned short out[2];
|
||||
} u;
|
||||
|
||||
u.in = p;
|
||||
@@ -65,15 +35,15 @@ namespace glm
|
||||
return vec2(u.out[0], u.out[1]) * 1.5259021896696421759365224689097e-5f;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint packSnorm2x16(vec2 const & v)
|
||||
GLM_FUNC_QUALIFIER uint packSnorm2x16(vec2 const& v)
|
||||
{
|
||||
union
|
||||
{
|
||||
i16 in[2];
|
||||
signed short in[2];
|
||||
uint out;
|
||||
} u;
|
||||
|
||||
i16vec2 result(round(clamp(v, -1.0f, 1.0f) * 32767.0f));
|
||||
|
||||
vec<2, short, defaultp> result(round(clamp(v, -1.0f, 1.0f) * 32767.0f));
|
||||
|
||||
u.in[0] = result[0];
|
||||
u.in[1] = result[1];
|
||||
@@ -86,7 +56,7 @@ namespace glm
|
||||
union
|
||||
{
|
||||
uint in;
|
||||
i16 out[2];
|
||||
signed short out[2];
|
||||
} u;
|
||||
|
||||
u.in = p;
|
||||
@@ -94,15 +64,15 @@ namespace glm
|
||||
return clamp(vec2(u.out[0], u.out[1]) * 3.0518509475997192297128208258309e-5f, -1.0f, 1.0f);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint packUnorm4x8(vec4 const & v)
|
||||
GLM_FUNC_QUALIFIER uint packUnorm4x8(vec4 const& v)
|
||||
{
|
||||
union
|
||||
{
|
||||
u8 in[4];
|
||||
unsigned char in[4];
|
||||
uint out;
|
||||
} u;
|
||||
|
||||
u8vec4 result(round(clamp(v, 0.0f, 1.0f) * 255.0f));
|
||||
vec<4, unsigned char, defaultp> result(round(clamp(v, 0.0f, 1.0f) * 255.0f));
|
||||
|
||||
u.in[0] = result[0];
|
||||
u.in[1] = result[1];
|
||||
@@ -117,23 +87,23 @@ namespace glm
|
||||
union
|
||||
{
|
||||
uint in;
|
||||
u8 out[4];
|
||||
unsigned char out[4];
|
||||
} u;
|
||||
|
||||
u.in = p;
|
||||
|
||||
return vec4(u.out[0], u.out[1], u.out[2], u.out[3]) * 0.0039215686274509803921568627451f;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint packSnorm4x8(vec4 const & v)
|
||||
|
||||
GLM_FUNC_QUALIFIER uint packSnorm4x8(vec4 const& v)
|
||||
{
|
||||
union
|
||||
{
|
||||
i8 in[4];
|
||||
signed char in[4];
|
||||
uint out;
|
||||
} u;
|
||||
|
||||
i8vec4 result(round(clamp(v, -1.0f, 1.0f) * 127.0f));
|
||||
vec<4, signed char, defaultp> result(round(clamp(v, -1.0f, 1.0f) * 127.0f));
|
||||
|
||||
u.in[0] = result[0];
|
||||
u.in[1] = result[1];
|
||||
@@ -142,13 +112,13 @@ namespace glm
|
||||
|
||||
return u.out;
|
||||
}
|
||||
|
||||
|
||||
GLM_FUNC_QUALIFIER glm::vec4 unpackSnorm4x8(uint p)
|
||||
{
|
||||
union
|
||||
{
|
||||
uint in;
|
||||
i8 out[4];
|
||||
signed char out[4];
|
||||
} u;
|
||||
|
||||
u.in = p;
|
||||
@@ -156,7 +126,7 @@ namespace glm
|
||||
return clamp(vec4(u.out[0], u.out[1], u.out[2], u.out[3]) * 0.0078740157480315f, -1.0f, 1.0f);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER double packDouble2x32(uvec2 const & v)
|
||||
GLM_FUNC_QUALIFIER double packDouble2x32(uvec2 const& v)
|
||||
{
|
||||
union
|
||||
{
|
||||
@@ -183,11 +153,11 @@ namespace glm
|
||||
return uvec2(u.out[0], u.out[1]);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint packHalf2x16(vec2 const & v)
|
||||
GLM_FUNC_QUALIFIER uint packHalf2x16(vec2 const& v)
|
||||
{
|
||||
union
|
||||
{
|
||||
i16 in[2];
|
||||
signed short in[2];
|
||||
uint out;
|
||||
} u;
|
||||
|
||||
@@ -202,7 +172,7 @@ namespace glm
|
||||
union
|
||||
{
|
||||
uint in;
|
||||
i16 out[2];
|
||||
signed short out[2];
|
||||
} u;
|
||||
|
||||
u.in = v;
|
||||
@@ -213,3 +183,7 @@ namespace glm
|
||||
}
|
||||
}//namespace glm
|
||||
|
||||
#if GLM_CONFIG_SIMD == GLM_ENABLE
|
||||
# include "func_packing_simd.inl"
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user