From 94cc84e6d83aae7cb1af5c83ccc009085cbd79e2 Mon Sep 17 00:00:00 2001 From: Joshua Moerman Date: Fri, 19 Sep 2014 15:38:28 +0200 Subject: [PATCH] Adds adl support --- glm/gtx/adl.hpp | 117 ++++++++++++++++++++++++++++++++++++++++ test/gtx/CMakeLists.txt | 1 + test/gtx/gtx_adl.cpp | 28 ++++++++++ 3 files changed, 146 insertions(+) create mode 100644 glm/gtx/adl.hpp create mode 100644 test/gtx/gtx_adl.cpp diff --git a/glm/gtx/adl.hpp b/glm/gtx/adl.hpp new file mode 100644 index 00000000..8609744d --- /dev/null +++ b/glm/gtx/adl.hpp @@ -0,0 +1,117 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// 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 gtx_adl +/// @file gtx/adl.hpp +/// @date 2014-09-19 / 2014-09-19 +/// @author Joshua Moerman +/// +/// @brief Allows to call glm functions without the need of fully qualifying +/// the name +/// +/////////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "../trigonometric.hpp" +#include "../exponential.hpp" +#include "../common.hpp" +#include "../geometric.hpp" +#include "../matrix.hpp" +#include "../vector_relational.hpp" + +namespace glm { + namespace detail { + using glm::radians; + using glm::degrees; + using glm::sin; + using glm::cos; + using glm::tan; + using glm::asin; + using glm::acos; + using glm::atan; + using glm::sinh; + using glm::cosh; + using glm::tanh; + using glm::asinh; + using glm::acosh; + using glm::atanh; + + using glm::pow; + using glm::exp; + using glm::log; + using glm::exp2; + using glm::log2; + using glm::sqrt; + using glm::inversesqrt; + + using glm::abs; + using glm::sign; + using glm::floor; + using glm::trunc; + using glm::round; + using glm::roundEven; + using glm::ceil; + using glm::fract; + using glm::mod; + using glm::modf; + using glm::min; + using glm::max; + using glm::clamp; + using glm::step; + using glm::smoothstep; + using glm::isnan; + using glm::isinf; + using glm::floatBitsToInt; + using glm::floatBitsToUint; + using glm::intBitsToFloat; + using glm::uintBitsToFloat; + using glm::fma; + using glm::frexp; + using glm::ldexp; + + using glm::length; + using glm::distance; + using glm::dot; + using glm::cross; + using glm::normalize; + using glm::faceforward; + using glm::reflect; + using glm::refract; + + using glm::matrixCompMult; + using glm::outerProduct; + using glm::transpose; + using glm::determinant; + using glm::inverse; + + using glm::lessThan; + using glm::lessThanEqual; + using glm::greaterThan; + using glm::greaterThanEqual; + using glm::equal; + using glm::notEqual; + using glm::any; + using glm::all; + using glm::not_; + } +} diff --git a/test/gtx/CMakeLists.txt b/test/gtx/CMakeLists.txt index e93fa17c..22097e3c 100644 --- a/test/gtx/CMakeLists.txt +++ b/test/gtx/CMakeLists.txt @@ -1,3 +1,4 @@ +glmCreateTestGTC(gtx_adl) glmCreateTestGTC(gtx_associated_min_max) glmCreateTestGTC(gtx_bit) glmCreateTestGTC(gtx_closest_point) diff --git a/test/gtx/gtx_adl.cpp b/test/gtx/gtx_adl.cpp new file mode 100644 index 00000000..34f1c095 --- /dev/null +++ b/test/gtx/gtx_adl.cpp @@ -0,0 +1,28 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2014-09-19 +// Updated : 2014-09-19 +// Licence : This source is under MIT licence +// File : test/gtx/gtx_adl.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include +#include + +template +int length(T const &){ + // This function should not be picked up in main + // So we return an error here + return 1; +} + +int main(){ + int Error(0); + glm::vec3 v(0, 0, 0); + + // the glm::length function will return 0 + Error += int(length(v)); + + return Error; +}