From d722b398c9c85cfa7095da4fd95401800c7bb711 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Mon, 28 Jul 2014 22:08:09 +0200 Subject: [PATCH] Added scalar conversion constructor --- glm/detail/type_vec1.hpp | 7 ++- glm/detail/type_vec1.inl | 11 ++--- glm/gtc/user_defined_type.hpp | 67 +++++++++++++++++++++++++++++ test/gtc/gtc_user_defined_types.cpp | 30 +++++++++++++ 4 files changed, 106 insertions(+), 9 deletions(-) create mode 100644 glm/gtc/user_defined_type.hpp create mode 100644 test/gtc/gtc_user_defined_types.cpp diff --git a/glm/detail/type_vec1.hpp b/glm/detail/type_vec1.hpp index 4d0d23c8..2255cb28 100644 --- a/glm/detail/type_vec1.hpp +++ b/glm/detail/type_vec1.hpp @@ -77,14 +77,13 @@ namespace detail GLM_FUNC_DECL tvec1(tvec1 const & v); template GLM_FUNC_DECL tvec1(tvec1 const & v); + template + 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 diff --git a/glm/detail/type_vec1.inl b/glm/detail/type_vec1.inl index c924bb95..84fdef3a 100644 --- a/glm/detail/type_vec1.inl +++ b/glm/detail/type_vec1.inl @@ -71,6 +71,12 @@ namespace detail x(v.x) {} + template + template + GLM_FUNC_QUALIFIER tvec1::tvec1(U const & s) : + x(static_cast(s)) + {} + ////////////////////////////////////// // Explicit basic constructors @@ -78,11 +84,6 @@ namespace detail GLM_FUNC_QUALIFIER tvec1::tvec1(ctor) {} - template - GLM_FUNC_QUALIFIER tvec1::tvec1(T const & s) : - x(s) - {} - ////////////////////////////////////// // Conversion vector constructors diff --git a/glm/gtc/user_defined_type.hpp b/glm/gtc/user_defined_type.hpp new file mode 100644 index 00000000..12a3bd13 --- /dev/null +++ b/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. +/// +/// 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 diff --git a/test/gtc/gtc_user_defined_types.cpp b/test/gtc/gtc_user_defined_types.cpp new file mode 100644 index 00000000..af39620d --- /dev/null +++ b/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 + +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; +}