Browse Source

Added new default precision API

Christophe Riccio 14 years ago
parent
commit
f4d6be2064
2 changed files with 28 additions and 31 deletions
  1. 11 12
      glm/core/type_float.hpp
  2. 17 19
      glm/core/type_int.hpp

+ 11 - 12
glm/core/type_float.hpp

@@ -46,7 +46,7 @@ namespace glm
 		//! There is no guarantee on the actual precision.
 		//! From GLSL 1.30.8 specification
 		//! \ingroup core_precision
-		typedef mediump_float_t		mediump_float;
+		typedef mediump_float_t	mediump_float;
 		//! High precision floating-point numbers.
 		//! There is no guarantee on the actual precision.
 		//! From GLSL 1.30.8 specification
@@ -55,18 +55,17 @@ namespace glm
 	}
 	//namespace precision
 
-#ifndef GLM_PRECISION 
-	typedef precision::mediump_float		float_t;
-#elif(GLM_PRECISION & GLM_PRECISION_HIGHP_FLOAT)
-	typedef precision::highp_float			float_t;
-#elif(GLM_PRECISION & GLM_PRECISION_MEDIUMP_FLOAT)
-	typedef precision::mediump_float		float_t;
-#elif(GLM_PRECISION & GLM_PRECISION_LOWP_FLOAT)
-	typedef precision::lowp_float			float_t;
+#if(!defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT))
+	typedef precision::mediump_float				float_t;
+#elif(defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT))
+	typedef precision::highp_float				float_t;
+#elif(!defined(GLM_PRECISION_HIGHP_FLOAT) && defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT))
+	typedef precision::mediump_float				float_t;
+#elif(!defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && defined(GLM_PRECISION_LOWP_FLOAT))
+	typedef precision::lowp_float					float_t;
 #else
-	#	pragma message("GLM message: Precisson undefined for float numbers.");
-	typedef precision::mediump_float		float_t;
-#endif//GLM_PRECISION
+#	error "GLM error: multiple default precision requested for floating-point types"
+#endif
 
 	}//namespace type
 	}//namespace core

+ 17 - 19
glm/core/type_int.hpp

@@ -54,7 +54,7 @@ namespace glm
 		//! There is no guarantee on the actual precision.
 		//! From GLSL 1.30.8 specification.
 		//! \ingroup core_precision
-		typedef detail::mediump_int_t			mediump_int;
+		typedef detail::mediump_int_t				mediump_int;
 		//! High precision signed integer.
 		//! There is no guarantee on the actual precision.
 		//! From GLSL 1.30.8 specification.
@@ -75,35 +75,33 @@ namespace glm
 		//! There is no guarantee on the actual precision.
 		//! From GLSL 1.30.8 specification.
 		//! \ingroup core_precision
-		typedef detail::highp_uint_t			highp_uint;
+		typedef detail::highp_uint_t				highp_uint;
 	}
 	//namespace precision
 
-#ifndef GLM_PRECISION 
+#if(!defined(GLM_PRECISION_HIGHP_INT) && !defined(GLM_PRECISION_MEDIUMP_INT) && !defined(GLM_PRECISION_LOWP_INT))
 	typedef precision::mediump_int				int_t;
-#elif(GLM_PRECISION & GLM_PRECISION_HIGHP_INT)
-	typedef precision::highp_int				int_t;
-#elif(GLM_PRECISION & GLM_PRECISION_MEDIUMP_INT)
+#elif(defined(GLM_PRECISION_HIGHP_INT) && !defined(GLM_PRECISION_MEDIUMP_INT) && !defined(GLM_PRECISION_LOWP_INT))
+	typedef precision::highp_int					int_t;
+#elif(!defined(GLM_PRECISION_HIGHP_INT) && defined(GLM_PRECISION_MEDIUMP_INT) && !defined(GLM_PRECISION_LOWP_INT))
 	typedef precision::mediump_int				int_t;
-#elif(GLM_PRECISION & GLM_PRECISION_LOWP_INT)
+#elif(!defined(GLM_PRECISION_HIGHP_INT) && !defined(GLM_PRECISION_MEDIUMP_INT) && defined(GLM_PRECISION_LOWP_INT))
 	typedef precision::lowp_int					int_t;
 #else
-	typedef precision::mediump_int							int_t;
-#	pragma message("GLM message: Precisson undefined for signed integer number.");
-#endif//GLM_PRECISION
+#	error "GLM error: multiple default precision requested for signed interger types"
+#endif
 
-#ifndef GLM_PRECISION 
+#if(!defined(GLM_PRECISION_HIGHP_UINT) && !defined(GLM_PRECISION_MEDIUMP_UINT) && !defined(GLM_PRECISION_LOWP_UINT))
 	typedef precision::mediump_uint				uint_t;
-#elif(GLM_PRECISION & GLM_PRECISION_HIGHP_UINT)
-	typedef precision::highp_uint				uint_t;
-#elif(GLM_PRECISION & GLM_PRECISION_MEDIUMP_UINT)
+#elif(defined(GLM_PRECISION_HIGHP_UINT) && !defined(GLM_PRECISION_MEDIUMP_UINT) && !defined(GLM_PRECISION_LOWP_UINT))
+	typedef precision::highp_uint					uint_t;
+#elif(!defined(GLM_PRECISION_HIGHP_UINT) && defined(GLM_PRECISION_MEDIUMP_UINT) && !defined(GLM_PRECISION_LOWP_UINT))
 	typedef precision::mediump_uint				uint_t;
-#elif(GLM_PRECISION & GLM_PRECISION_LOWP_UINT)
-	typedef precision::lowp_uint				uint_t;
+#elif(!defined(GLM_PRECISION_HIGHP_UINT) && !defined(GLM_PRECISION_MEDIUMP_UINT) && defined(GLM_PRECISION_LOWP_UINT))
+	typedef precision::lowp_uint					uint_t;
 #else
-	typedef precision::mediump_uint				uint_t;
-#	pragma message("GLM message: Precisson undefined for unsigned integer number.");
-#endif//GLM_PRECISION
+#	error "GLM error: multiple default precision requested for unsigned interger types"
+#endif
 
 	//! Unsigned integer. 
 	//! From GLSL 1.30.8 specification section 4.1.3 Integers.