Browse Source

Fixed initializer test implementation, simplified packing implementation

Christophe Riccio 12 years ago
parent
commit
eb59cb9af6

+ 1 - 1
glm/core/func_packing.inl

@@ -61,7 +61,7 @@ namespace glm
 	GLM_FUNC_QUALIFIER uint packUnorm4x8(vec4 const & v)
 	GLM_FUNC_QUALIFIER uint packUnorm4x8(vec4 const & v)
 	{
 	{
 		u8vec4 Topack(round(clamp(v, 0.0f, 1.0f) * 255.0f));
 		u8vec4 Topack(round(clamp(v, 0.0f, 1.0f) * 255.0f));
-		return reinterpret_cast<uint&>(&Topack);
+		return reinterpret_cast<uint&>(Topack);
 	}
 	}
 
 
 	GLM_FUNC_QUALIFIER vec4 unpackUnorm4x8(uint const & p)
 	GLM_FUNC_QUALIFIER vec4 unpackUnorm4x8(uint const & p)

+ 1 - 1
glm/gtc/packing.inl

@@ -230,7 +230,7 @@ namespace detail
 	
 	
 	GLM_FUNC_QUALIFIER float unpackUnorm1x8(uint8 const & p)
 	GLM_FUNC_QUALIFIER float unpackUnorm1x8(uint8 const & p)
 	{
 	{
-		float Unpack(static_cast<float>(*const_cast<uint8*>(&p)));
+		float Unpack(static_cast<float>(p));
 		return Unpack * float(0.0039215686274509803921568627451); // 1 / 255
 		return Unpack * float(0.0039215686274509803921568627451); // 1 / 255
 	}
 	}
 	
 	

+ 1 - 1
glm/gtc/quaternion.inl

@@ -92,7 +92,7 @@ namespace detail
 		z(static_cast<T>(l.begin()[2])),
 		z(static_cast<T>(l.begin()[2])),
 		w(static_cast<T>(l.begin()[3]))
 		w(static_cast<T>(l.begin()[3]))
 	{
 	{
-		assert(v.size() >= this->length());
+		assert(l.size() >= this->length());
 	}
 	}
 #endif//GLM_HAS_INITIALIZER_LISTS
 #endif//GLM_HAS_INITIALIZER_LISTS
 
 

+ 4 - 2
test/core/core_type_mat2x3.cpp

@@ -7,7 +7,9 @@
 // File    : test/core/type_mat2x3.cpp
 // File    : test/core/type_mat2x3.cpp
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 
+#include <glm/core/func_vector_relational.hpp>
 #include <glm/core/type_mat2x3.hpp>
 #include <glm/core/type_mat2x3.hpp>
+#include <vector>
 
 
 static int test_operators()
 static int test_operators()
 {
 {
@@ -34,8 +36,8 @@ int test_ctr()
 	
 	
 #if(GLM_HAS_INITIALIZER_LISTS)
 #if(GLM_HAS_INITIALIZER_LISTS)
 	glm::mat2x3 m0(
 	glm::mat2x3 m0(
-		glm::vec2(0, 1, 2),
-		glm::vec2(3, 4, 5));
+		glm::vec3(0, 1, 2),
+		glm::vec3(3, 4, 5));
 	
 	
 	glm::mat2x3 m1{0, 1, 2, 3, 4, 5};
 	glm::mat2x3 m1{0, 1, 2, 3, 4, 5};
 	
 	

+ 2 - 0
test/core/core_type_mat2x4.cpp

@@ -7,7 +7,9 @@
 // File    : test/core/type_mat2x4.cpp
 // File    : test/core/type_mat2x4.cpp
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 
+#include <glm/core/func_vector_relational.hpp>
 #include <glm/core/type_mat2x4.hpp>
 #include <glm/core/type_mat2x4.hpp>
+#include <vector>
 
 
 static int test_operators()
 static int test_operators()
 {
 {

+ 2 - 0
test/core/core_type_mat3x2.cpp

@@ -7,7 +7,9 @@
 // File    : test/core/type_mat3x2.cpp
 // File    : test/core/type_mat3x2.cpp
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 
+#include <glm/core/func_vector_relational.hpp>
 #include <glm/core/type_mat3x2.hpp>
 #include <glm/core/type_mat3x2.hpp>
+#include <vector>
 
 
 static bool test_operators()
 static bool test_operators()
 {
 {

+ 6 - 5
test/core/core_type_mat3x3.cpp

@@ -10,6 +10,7 @@
 #include <glm/core/type_mat3x3.hpp>
 #include <glm/core/type_mat3x3.hpp>
 #include <glm/gtc/epsilon.hpp>
 #include <glm/gtc/epsilon.hpp>
 #include <cstdio>
 #include <cstdio>
+#include <vector>
 
 
 void print(glm::dmat3 const & Mat0)
 void print(glm::dmat3 const & Mat0)
 {
 {
@@ -94,7 +95,7 @@ int test_ctr()
 	glm::mat3x3 m0(
 	glm::mat3x3 m0(
 		glm::vec3(0, 1, 2),
 		glm::vec3(0, 1, 2),
 		glm::vec3(3, 4, 5),
 		glm::vec3(3, 4, 5),
-		glm::vec3(6, 7, 9));
+		glm::vec3(6, 7, 8));
 	
 	
 	glm::mat3x3 m1{0, 1, 2, 3, 4, 5, 6, 7, 8};
 	glm::mat3x3 m1{0, 1, 2, 3, 4, 5, 6, 7, 8};
 	
 	
@@ -117,13 +118,13 @@ int test_ctr()
 	std::vector<glm::mat3x3> v2{
 	std::vector<glm::mat3x3> v2{
 		{
 		{
 			{ 0, 1, 2},
 			{ 0, 1, 2},
-			{ 4, 5, 6},
-			{ 7, 8, 9}
+			{ 3, 4, 5},
+			{ 6, 7, 8}
 		},
 		},
 		{
 		{
 			{ 0, 1, 2},
 			{ 0, 1, 2},
-			{ 4, 5, 6},
-			{ 7, 8, 9}
+			{ 3, 4, 5},
+			{ 6, 7, 8}
 		}
 		}
 	};
 	};
 	
 	

+ 16 - 13
test/core/core_type_mat3x4.cpp

@@ -7,7 +7,9 @@
 // File    : test/core/type_mat3x4.cpp
 // File    : test/core/type_mat3x4.cpp
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 
+#include <glm/core/func_vector_relational.hpp>
 #include <glm/core/type_mat3x4.hpp>
 #include <glm/core/type_mat3x4.hpp>
+#include <vector>
 
 
 static bool test_operators()
 static bool test_operators()
 {
 {
@@ -34,17 +36,16 @@ int test_ctr()
 	
 	
 #if(GLM_HAS_INITIALIZER_LISTS)
 #if(GLM_HAS_INITIALIZER_LISTS)
 	glm::mat3x4 m0(
 	glm::mat3x4 m0(
-		glm::vec3(0, 1, 2),
-		glm::vec3(3, 4, 5),
-		glm::vec3(6, 7, 8),
-		glm::vec3(9, 10, 11));
+		glm::vec4(0, 1, 2, 3),
+		glm::vec4(4, 5, 6, 7),
+		glm::vec4(8, 9, 10, 11));
 	
 	
 	glm::mat3x4 m1{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
 	glm::mat3x4 m1{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
 	
 	
 	glm::mat3x4 m2{
 	glm::mat3x4 m2{
-		{0, 1, 2},
-		{3, 4, 5},
-		{6, 7, 8}};
+		{0, 1, 2, 3},
+		{4, 5, 6, 7},
+		{8, 9, 10, 11}};
 	
 	
 	for(int i = 0; i < m0.length(); ++i)
 	for(int i = 0; i < m0.length(); ++i)
 		Error += glm::all(glm::equal(m0[i], m2[i])) ? 0 : 1;
 		Error += glm::all(glm::equal(m0[i], m2[i])) ? 0 : 1;
@@ -53,18 +54,20 @@ int test_ctr()
 		Error += glm::all(glm::equal(m1[i], m2[i])) ? 0 : 1;
 		Error += glm::all(glm::equal(m1[i], m2[i])) ? 0 : 1;
 	
 	
 	std::vector<glm::mat3x4> v1{
 	std::vector<glm::mat3x4> v1{
-		{0, 1, 2, 3, 4, 5, 6, 7, 8},
-		{0, 1, 2, 3, 4, 5, 6, 7, 8}
+		{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11},
+		{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
 	};
 	};
 	
 	
 	std::vector<glm::mat3x4> v2{
 	std::vector<glm::mat3x4> v2{
 		{
 		{
-			{ 0, 1, 2},
-			{ 4, 5, 6}
+			{ 0, 1, 2, 3},
+			{ 4, 5, 6, 7},
+			{ 8, 9, 10, 11}
 		},
 		},
 		{
 		{
-			{ 0, 1, 2},
-			{ 4, 5, 6}
+			{ 0, 1, 2, 3},
+			{ 4, 5, 6, 7},
+			{ 8, 9, 10, 11}
 		}
 		}
 	};
 	};