Browse Source

Added not function

Christophe Riccio 11 years ago
parent
commit
bf9e4458b6

+ 14 - 0
glm/detail/func_vector_relational.hpp

@@ -132,6 +132,20 @@ namespace glm
 	template <precision P, template <typename, precision> class vecType>
 	GLM_FUNC_DECL vecType<bool, P> not_(vecType<bool, P> const & v);
 
+#	if GLM_COMPILER & GLM_COMPILER_VC && GLM_COMPILER >= GLM_COMPILER_VC12
+
+	/// Returns the component-wise logical complement of x.
+	/// /!\ Because of language incompatibilities between C++ and GLSL, GLM defines the function not but not_ instead.
+	///
+	/// @tparam vecType Boolean vector types.
+	///
+	/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/not.xml">GLSL not man page</a>
+	/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.7 Vector Relational Functions</a>
+	template <precision P, template <typename, precision> class vecType>
+	GLM_FUNC_DECL vecType<bool, P> not(vecType<bool, P> const & v){return not_(v);}
+
+#	endif
+
 	/// @}
 }//namespace glm
 

+ 0 - 8
glm/detail/func_vector_relational.inl

@@ -33,8 +33,6 @@ namespace glm
 	template <typename T, precision P, template <typename, precision> class vecType>
 	GLM_FUNC_QUALIFIER vecType<bool, P> lessThan(vecType<T, P> const & x, vecType<T, P> const & y)
 	{
-		GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559 || std::numeric_limits<T>::is_integer,
-			"Invalid template instantiation of 'lessThan', GLM vector types required floating-point or integer value types vectors");
 		assert(detail::component_count(x) == detail::component_count(y));
 
 		vecType<bool, P> Result(uninitialize);
@@ -47,8 +45,6 @@ namespace glm
 	template <typename T, precision P, template <typename, precision> class vecType>
 	GLM_FUNC_QUALIFIER vecType<bool, P> lessThanEqual(vecType<T, P> const & x, vecType<T, P> const & y)
 	{
-		GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559 || std::numeric_limits<T>::is_integer,
-			"Invalid template instantiation of 'lessThanEqual', GLM vector types required floating-point or integer value types vectors");
 		assert(detail::component_count(x) == detail::component_count(y));
 
 		vecType<bool, P> Result(uninitialize);
@@ -60,8 +56,6 @@ namespace glm
 	template <typename T, precision P, template <typename, precision> class vecType>
 	GLM_FUNC_QUALIFIER vecType<bool, P> greaterThan(vecType<T, P> const & x, vecType<T, P> const & y)
 	{
-		GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559 || std::numeric_limits<T>::is_integer,
-			"Invalid template instantiation of 'greaterThan', GLM vector types required floating-point or integer value types vectors");
 		assert(detail::component_count(x) == detail::component_count(y));
 
 		vecType<bool, P> Result(uninitialize);
@@ -73,8 +67,6 @@ namespace glm
 	template <typename T, precision P, template <typename, precision> class vecType>
 	GLM_FUNC_QUALIFIER vecType<bool, P> greaterThanEqual(vecType<T, P> const & x, vecType<T, P> const & y)
 	{
-		GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559 || std::numeric_limits<T>::is_integer,
-			"Invalid template instantiation of 'greaterThanEqual', GLM vector types required floating-point or integer value types vectors");
 		assert(detail::component_count(x) == detail::component_count(y));
 
 		vecType<bool, P> Result(uninitialize);

+ 1 - 1
glm/detail/setup.hpp

@@ -391,7 +391,7 @@
 #				define GLM_LANG (GLM_LANG_CXX98 | GLM_LANG_CXXMS_FLAG)
 #			endif
 #		else
-#			if(GLM_COMPILER >= GLM_COMPILER_VC10
+#			if GLM_COMPILER >= GLM_COMPILER_VC10
 #				define GLM_LANG GLM_LANG_CXX0X
 #			else
 #				define GLM_LANG GLM_LANG_CXX98

+ 1 - 0
readme.txt

@@ -75,6 +75,7 @@ GLM 0.9.6.0: 2014-XX-XX
 - Separated Apple Clang and LLVM compiler detection
 - Added GLM_FORCE_NO_CTOR_INIT
 - Added 'uninitialize' to explicitly not initialize a GLM type
+- Added not function (from GLSL specification) on VC12
 
 ================================================================================
 GLM 0.9.5.4: 2014-06-21

+ 34 - 1
test/core/core_func_vector_relational.cpp

@@ -7,12 +7,45 @@
 // File    : test/core/vector_relational.cpp
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-#include <glm/glm.hpp>
+#include <glm/vec2.hpp>
+#include <glm/vec3.hpp>
+#include <glm/vec4.hpp>
+#include <glm/vector_relational.hpp>
+#include <glm/gtc/vec1.hpp>
+
+int test_not()
+{
+	int Error(0);
+
+	{
+		glm::bvec1 v(false);
+		Error += glm::all(glm::not_(v)) ? 0 : 1;
+	}
+
+	{
+		glm::bvec2 v(false);
+		Error += glm::all(glm::not_(v)) ? 0 : 1;
+	}
+
+	{
+		glm::bvec3 v(false);
+		Error += glm::all(glm::not_(v)) ? 0 : 1;
+	}
+	
+	{
+		glm::bvec4 v(false);
+		Error += glm::all(glm::not_(v)) ? 0 : 1;
+	}
+
+	return Error;
+}
 
 int main()
 {
 	int Error(0);
 
+	Error += test_not();
+
 	return Error;
 }