From 6277440507f3da13f9a130533865462313c728d7 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Thu, 13 Oct 2011 12:26:11 +0100 Subject: [PATCH 1/2] Fixed removed namespace still present --- glm/gtx/gradient_paint.hpp | 12 +++++----- glm/gtx/gradient_paint.inl | 34 +++++++++++++++------------ test/gtx/CMakeLists.txt | 1 + test/gtx/gtx_gradient_paint.cpp | 41 +++++++++++++++++++++++++++++++++ 4 files changed, 67 insertions(+), 21 deletions(-) create mode 100644 test/gtx/gtx_gradient_paint.cpp diff --git a/glm/gtx/gradient_paint.hpp b/glm/gtx/gradient_paint.hpp index d46bd581..746e32a7 100644 --- a/glm/gtx/gradient_paint.hpp +++ b/glm/gtx/gradient_paint.hpp @@ -55,18 +55,18 @@ namespace glm /// @see - gtx_gradient_paint template valType radialGradient( - glm::detail::tvec2 const & Center, + detail::tvec2 const & Center, valType const & Radius, - glm::detail::tvec2 const & Focal, - glm::detail::tvec2 const & Position); + detail::tvec2 const & Focal, + detail::tvec2 const & Position); /// Return a color from a linear gradient. /// @see - gtx_gradient_paint template valType linearGradient( - glm::detail::tvec2 const & Point0, - glm::detail::tvec2 const & Point1, - glm::detail::tvec2 const & Position); + detail::tvec2 const & Point0, + detail::tvec2 const & Point1, + detail::tvec2 const & Position); /// @} }// namespace glm diff --git a/glm/gtx/gradient_paint.inl b/glm/gtx/gradient_paint.inl index f6ea0718..0043f47e 100644 --- a/glm/gtx/gradient_paint.inl +++ b/glm/gtx/gradient_paint.inl @@ -10,30 +10,34 @@ namespace glm{ template -valType radialGradient( - glm::detail::tvec2 const & Center, +valType radialGradient +( + detail::tvec2 const & Center, valType const & Radius, - glm::detail::tvec2 const & Focal, - glm::detail::tvec2 const & Position) + detail::tvec2 const & Focal, + detail::tvec2 const & Position +) { - glm::detail::tvec2 F = Focal - Center; - glm::detail::tvec2 D = Position - Focal; - valType Radius2 = gtx::pow2(Radius); - valType Fx2 = gtx::pow2(F.x); - valType Fy2 = gtx::pow2(F.y); + detail::tvec2 F = Focal - Center; + detail::tvec2 D = Position - Focal; + valType Radius2 = pow2(Radius); + valType Fx2 = pow2(F.x); + valType Fy2 = pow2(F.y); - valType Numerator = (D.x * F.x + D.y * F.y) + glm::sqrt(Radius2 * (gtx::pow2(D.x) + gtx::pow2(D.y)) - gtx::pow2(D.x * F.y - D.y * F.x)); + valType Numerator = (D.x * F.x + D.y * F.y) + sqrt(Radius2 * (pow2(D.x) + pow2(D.y)) - pow2(D.x * F.y - D.y * F.x)); valType Denominator = Radius2 - (Fx2 + Fy2); return Numerator / Denominator; } template -valType linearGradient( - glm::detail::tvec2 const & Point0, - glm::detail::tvec2 const & Point1, - glm::detail::tvec2 const & Position) +valType linearGradient +( + detail::tvec2 const & Point0, + detail::tvec2 const & Point1, + detail::tvec2 const & Position +) { - glm::detail::tvec2 Dist = Point1 - Point0; + detail::tvec2 Dist = Point1 - Point0; return (Dist.x * (Position.x - Point0.x) + Dist.y * (Position.y - Point0.y)) / glm::dot(Dist, Dist); } diff --git a/test/gtx/CMakeLists.txt b/test/gtx/CMakeLists.txt index 504aeff8..89a55f7a 100644 --- a/test/gtx/CMakeLists.txt +++ b/test/gtx/CMakeLists.txt @@ -1,4 +1,5 @@ glmCreateTestGTC(gtx_bit) +glmCreateTestGTC(gtx_gradient_paint) glmCreateTestGTC(gtx_integer) glmCreateTestGTC(gtx_noise) glmCreateTestGTC(gtx_quaternion) diff --git a/test/gtx/gtx_gradient_paint.cpp b/test/gtx/gtx_gradient_paint.cpp new file mode 100644 index 00000000..85de7b9d --- /dev/null +++ b/test/gtx/gtx_gradient_paint.cpp @@ -0,0 +1,41 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2011-10-13 +// Updated : 2011-10-13 +// Licence : This source is under MIT licence +// File : test/gtx/gradient_paint.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include +#include + +int test_radialGradient() +{ + int Error = 0; + + float Gradient = glm::radialGradient(glm::vec2(0), 1.0f, glm::vec2(1), glm::vec2(0.5)); + + return Error; +} + +int test_linearGradient() +{ + int Error = 0; + + float Gradient = glm::linearGradient(glm::vec2(0), glm::vec2(1), glm::vec2(0.5)); + + return Error; +} + +int main() +{ + int Error = 0; + + Error += test_radialGradient(); + Error += test_linearGradient(); + + return Error; +} + + From 70efce771dfcf4c355ea60a9f77b960543526c6d Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Thu, 13 Oct 2011 12:44:17 +0100 Subject: [PATCH 2/2] Updated date --- glm/gtx/integer.hpp | 2 +- glm/gtx/integer.inl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/glm/gtx/integer.hpp b/glm/gtx/integer.hpp index 9369bd43..b33d7ea6 100644 --- a/glm/gtx/integer.hpp +++ b/glm/gtx/integer.hpp @@ -22,7 +22,7 @@ /// /// @ref gtx_integer /// @file glm/gtx/integer.hpp -/// @date 2005-12-24 / 2011-06-07 +/// @date 2005-12-24 / 2011-10-13 /// @author Christophe Riccio /// /// @see core (dependence) diff --git a/glm/gtx/integer.inl b/glm/gtx/integer.inl index 8c883728..e8be0e41 100644 --- a/glm/gtx/integer.inl +++ b/glm/gtx/integer.inl @@ -2,7 +2,7 @@ // OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net) /////////////////////////////////////////////////////////////////////////////////////////////////// // Created : 2005-12-24 -// Updated : 2006-12-06 +// Updated : 2011-10-13 // Licence : This source is under MIT License // File : glm/gtx/integer.inl ///////////////////////////////////////////////////////////////////////////////////////////////////