Browse Source

Added packHalf2x16 tests

Christophe Riccio 14 years ago
parent
commit
64f9e3564d
1 changed files with 15 additions and 0 deletions
  1. 15 0
      test/core/core_func_packing.cpp

+ 15 - 0
test/core/core_func_packing.cpp

@@ -8,11 +8,26 @@
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 #include <glm/glm.hpp>
+#include <glm/gtc/half_float.hpp>
+#include <vector>
 
 int test_packHalf2x16()
 {
 	int Error = 0;
 	
+	std::vector<glm::hvec2> A;
+	A.push_back(glm::hvec2(glm::half( 1.0f), glm::half( 2.0f)));
+	A.push_back(glm::hvec2(glm::half(-1.0f), glm::half(-2.0f)));
+	A.push_back(glm::hvec2(glm::half(-1.1f), glm::half( 1.1f)));
+	
+	for(std::size_t i = 0; i < A.size(); ++i)
+	{
+		glm::vec2 B(A[i]);
+		glm::uint C = glm::packHalf2x16(B);
+		glm::vec2 D = glm::unpackHalf2x16(C);
+		Error += B == D ? 0 : 1;
+	}
+	
 	return Error;
 }