Browse Source

Added scalar conversion constructor

Christophe Riccio 11 years ago
parent
commit
d722b398c9

+ 3 - 4
glm/detail/type_vec1.hpp

@@ -77,14 +77,13 @@ namespace detail
 		GLM_FUNC_DECL tvec1(tvec1<T, P> const & v);
 		template <precision Q>
 		GLM_FUNC_DECL tvec1(tvec1<T, Q> const & v);
+		template <typename U>
+		GLM_FUNC_DECL tvec1(U const & s);
 
 		//////////////////////////////////////
 		// Explicit basic constructors
 
-		GLM_FUNC_DECL explicit tvec1(
-			ctor);
-		GLM_FUNC_DECL tvec1(
-			T const & s);
+		GLM_FUNC_DECL explicit tvec1(ctor);
 
 		//////////////////////////////////////
 		// Conversion vector constructors

+ 6 - 5
glm/detail/type_vec1.inl

@@ -71,6 +71,12 @@ namespace detail
 		x(v.x)
 	{}
 
+	template <typename T, precision P>
+	template <typename U>
+	GLM_FUNC_QUALIFIER  tvec1<T, P>::tvec1(U const & s) :
+		x(static_cast<T>(s))
+	{}
+
 	//////////////////////////////////////
 	// Explicit basic constructors
 
@@ -78,11 +84,6 @@ namespace detail
 	GLM_FUNC_QUALIFIER tvec1<T, P>::tvec1(ctor)
 	{}
 
-	template <typename T, precision P>
-	GLM_FUNC_QUALIFIER tvec1<T, P>::tvec1(T const & s) :
-		x(s)
-	{}
-
 	//////////////////////////////////////
 	// Conversion vector constructors
 

+ 67 - 0
glm/gtc/user_defined_type.hpp

@@ -0,0 +1,67 @@
+///////////////////////////////////////////////////////////////////////////////////
+/// OpenGL Mathematics (glm.g-truc.net)
+///
+/// Copyright (c) 2005 - 2014 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.
+/// 
+/// 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 gtc_std
+/// @file glm/gtc/std.hpp
+/// @date 2014-07-25 / 2014-07-25
+/// @author Christophe Riccio
+/// 
+/// @see core (dependence)
+///
+/// @defgroup gtc_std GLM_GTC_std_type
+/// @ingroup gtc
+/// 
+/// @brief Comparison functions for a user defined epsilon values.
+/// 
+/// <glm/gtc/std.hpp> need to be included to use these functionalities.
+///////////////////////////////////////////////////////////////////////////////////
+
+#pragma once
+
+// Dependencies
+#include "../detail/setup.hpp"
+#include "../detail/precision.hpp"
+#include "../detail/type_vec1.hpp"
+#include "../detail/type_vec2.hpp"
+#include "../detail/type_vec3.hpp"
+#include "../detail/type_vec4.hpp"
+
+#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
+#	pragma message("GLM: GLM_GTC_std_type extension included")
+#endif
+
+namespace glm
+{
+	namespace type
+	{
+		void func(){}
+	}
+
+	using namespace type;
+
+	/// @addtogroup gtc_std
+	/// @{
+
+
+
+	/// @}
+}//namespace glm

+ 30 - 0
test/gtc/gtc_user_defined_types.cpp

@@ -0,0 +1,30 @@
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Created : 2010-09-16
+// Updated : 2011-05-27
+// Licence : This source is under MIT licence
+// File    : test/gtc/type_ptr.cpp
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+#define GLM_FORCE_RADIANS
+#include <glm/gtc/user_defined_type.hpp>
+
+int test_make_pointer_vec()
+{
+	int Error = 0;
+
+	glm::func();
+	//func();
+
+	return Error;
+}
+
+int main()
+{
+	int Error = 0;
+
+	Error += test_make_pointer_vec();
+
+	return Error;
+}