Merge pull request #1 from g-truc/master

Merging from HEAD
This commit is contained in:
hbirchtree 2015-06-28 17:54:30 +02:00
commit 3ef806f0f9
23 changed files with 1061 additions and 434 deletions

View File

@ -1,10 +1,14 @@
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(glm)
enable_testing()
set(GLM_VERSION "0.9.7")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
enable_testing()
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
@ -129,7 +133,6 @@ endif()
if(CMAKE_COMPILER_IS_GNUCXX)
#add_definitions(-S)
#add_definitions(-s)
add_definitions(-m64)
add_definitions(-O2)
#add_definitions(-fprofile-arcs -ftest-coverage) gcov
@ -141,6 +144,56 @@ include_directories("${PROJECT_SOURCE_DIR}/test/external")
add_subdirectory(glm)
add_subdirectory(test)
add_subdirectory(util)
install(DIRECTORY glm DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR})
set(GLM_INSTALL_CONFIGDIR "${CMAKE_INSTALL_LIBDIR}/cmake/glm")
install(DIRECTORY glm DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/glmVersion.cmake"
VERSION ${GLM_VERSION}
COMPATIBILITY AnyNewerVersion
)
# build tree package config
configure_file(
cmake/glmBuildConfig.cmake.in
glmConfig.cmake
@ONLY
)
# install tree package config
configure_package_config_file(
cmake/glmConfig.cmake.in
${GLM_INSTALL_CONFIGDIR}/glmConfig.cmake
INSTALL_DESTINATION ${GLM_INSTALL_CONFIGDIR}
PATH_VARS CMAKE_INSTALL_INCLUDEDIR
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/${GLM_INSTALL_CONFIGDIR}/glmConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/glmVersion.cmake"
DESTINATION ${GLM_INSTALL_CONFIGDIR}
)
if (NOT CMAKE_VERSION VERSION_LESS "2.8.12")
add_library(glm INTERFACE)
target_include_directories(glm INTERFACE
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
)
install(TARGETS glm EXPORT glmTargets)
export(
EXPORT glmTargets
FILE "${CMAKE_CURRENT_BINARY_DIR}/glmTargets.cmake"
)
install(
EXPORT glmTargets FILE glmTargets.cmake
DESTINATION ${GLM_INSTALL_CONFIGDIR}
)
endif()
export(PACKAGE glm)

View File

@ -0,0 +1,227 @@
# - CONFIGURE_PACKAGE_CONFIG_FILE(), WRITE_BASIC_PACKAGE_VERSION_FILE()
#
# CONFIGURE_PACKAGE_CONFIG_FILE(<input> <output> INSTALL_DESTINATION <path>
# [PATH_VARS <var1> <var2> ... <varN>]
# [NO_SET_AND_CHECK_MACRO]
# [NO_CHECK_REQUIRED_COMPONENTS_MACRO])
#
# CONFIGURE_PACKAGE_CONFIG_FILE() should be used instead of the plain
# CONFIGURE_FILE() command when creating the <Name>Config.cmake or <Name>-config.cmake
# file for installing a project or library. It helps making the resulting package
# relocatable by avoiding hardcoded paths in the installed Config.cmake file.
#
# In a FooConfig.cmake file there may be code like this to make the
# install destinations know to the using project:
# set(FOO_INCLUDE_DIR "@CMAKE_INSTALL_FULL_INCLUDEDIR@" )
# set(FOO_DATA_DIR "@CMAKE_INSTALL_PREFIX@/@RELATIVE_DATA_INSTALL_DIR@" )
# set(FOO_ICONS_DIR "@CMAKE_INSTALL_PREFIX@/share/icons" )
# ...logic to determine installedPrefix from the own location...
# set(FOO_CONFIG_DIR "${installedPrefix}/@CONFIG_INSTALL_DIR@" )
# All 4 options shown above are not sufficient, since the first 3 hardcode
# the absolute directory locations, and the 4th case works only if the logic
# to determine the installedPrefix is correct, and if CONFIG_INSTALL_DIR contains
# a relative path, which in general cannot be guaranteed.
# This has the effect that the resulting FooConfig.cmake file would work poorly
# under Windows and OSX, where users are used to choose the install location
# of a binary package at install time, independent from how CMAKE_INSTALL_PREFIX
# was set at build/cmake time.
#
# Using CONFIGURE_PACKAGE_CONFIG_FILE() helps. If used correctly, it makes the
# resulting FooConfig.cmake file relocatable.
# Usage:
# 1. write a FooConfig.cmake.in file as you are used to
# 2. insert a line containing only the string "@PACKAGE_INIT@"
# 3. instead of SET(FOO_DIR "@SOME_INSTALL_DIR@"), use SET(FOO_DIR "@PACKAGE_SOME_INSTALL_DIR@")
# (this must be after the @PACKAGE_INIT@ line)
# 4. instead of using the normal CONFIGURE_FILE(), use CONFIGURE_PACKAGE_CONFIG_FILE()
#
# The <input> and <output> arguments are the input and output file, the same way
# as in CONFIGURE_FILE().
#
# The <path> given to INSTALL_DESTINATION must be the destination where the FooConfig.cmake
# file will be installed to. This can either be a relative or absolute path, both work.
#
# The variables <var1> to <varN> given as PATH_VARS are the variables which contain
# install destinations. For each of them the macro will create a helper variable
# PACKAGE_<var...>. These helper variables must be used
# in the FooConfig.cmake.in file for setting the installed location. They are calculated
# by CONFIGURE_PACKAGE_CONFIG_FILE() so that they are always relative to the
# installed location of the package. This works both for relative and also for absolute locations.
# For absolute locations it works only if the absolute location is a subdirectory
# of CMAKE_INSTALL_PREFIX.
#
# By default configure_package_config_file() also generates two helper macros,
# set_and_check() and check_required_components() into the FooConfig.cmake file.
#
# set_and_check() should be used instead of the normal set()
# command for setting directories and file locations. Additionally to setting the
# variable it also checks that the referenced file or directory actually exists
# and fails with a FATAL_ERROR otherwise. This makes sure that the created
# FooConfig.cmake file does not contain wrong references.
# When using the NO_SET_AND_CHECK_MACRO, this macro is not generated into the
# FooConfig.cmake file.
#
# check_required_components(<package_name>) should be called at the end of the
# FooConfig.cmake file if the package supports components.
# This macro checks whether all requested, non-optional components have been found,
# and if this is not the case, sets the Foo_FOUND variable to FALSE, so that the package
# is considered to be not found.
# It does that by testing the Foo_<Component>_FOUND variables for all requested
# required components.
# When using the NO_CHECK_REQUIRED_COMPONENTS option, this macro is not generated
# into the FooConfig.cmake file.
#
# For an example see below the documentation for WRITE_BASIC_PACKAGE_VERSION_FILE().
#
#
# WRITE_BASIC_PACKAGE_VERSION_FILE( filename VERSION major.minor.patch COMPATIBILITY (AnyNewerVersion|SameMajorVersion|ExactVersion) )
#
# Writes a file for use as <package>ConfigVersion.cmake file to <filename>.
# See the documentation of FIND_PACKAGE() for details on this.
# filename is the output filename, it should be in the build tree.
# major.minor.patch is the version number of the project to be installed
# The COMPATIBILITY mode AnyNewerVersion means that the installed package version
# will be considered compatible if it is newer or exactly the same as the requested version.
# This mode should be used for packages which are fully backward compatible,
# also across major versions.
# If SameMajorVersion is used instead, then the behaviour differs from AnyNewerVersion
# in that the major version number must be the same as requested, e.g. version 2.0 will
# not be considered compatible if 1.0 is requested.
# This mode should be used for packages which guarantee backward compatibility within the
# same major version.
# If ExactVersion is used, then the package is only considered compatible if the requested
# version matches exactly its own version number (not considering the tweak version).
# For example, version 1.2.3 of a package is only considered compatible to requested version 1.2.3.
# This mode is for packages without compatibility guarantees.
# If your project has more elaborated version matching rules, you will need to write your
# own custom ConfigVersion.cmake file instead of using this macro.
#
# Internally, this macro executes configure_file() to create the resulting
# version file. Depending on the COMPATIBLITY, either the file
# BasicConfigVersion-SameMajorVersion.cmake.in or BasicConfigVersion-AnyNewerVersion.cmake.in
# is used. Please note that these two files are internal to CMake and you should
# not call configure_file() on them yourself, but they can be used as starting
# point to create more sophisticted custom ConfigVersion.cmake files.
#
#
# Example using both configure_package_config_file() and write_basic_package_version_file():
# CMakeLists.txt:
# set(INCLUDE_INSTALL_DIR include/ ... CACHE )
# set(LIB_INSTALL_DIR lib/ ... CACHE )
# set(SYSCONFIG_INSTALL_DIR etc/foo/ ... CACHE )
# ...
# include(CMakePackageConfigHelpers)
# configure_package_config_file(FooConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/FooConfig.cmake
# INSTALL_DESTINATION ${LIB_INSTALL_DIR}/Foo/cmake
# PATH_VARS INCLUDE_INSTALL_DIR SYSCONFIG_INSTALL_DIR)
# write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/FooConfigVersion.cmake
# VERSION 1.2.3
# COMPATIBILITY SameMajorVersion )
# install(FILES ${CMAKE_CURRENT_BINARY_DIR}/FooConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/FooConfigVersion.cmake
# DESTINATION ${LIB_INSTALL_DIR}/Foo/cmake )
#
# With a FooConfig.cmake.in:
# set(FOO_VERSION x.y.z)
# ...
# @PACKAGE_INIT@
# ...
# set_and_check(FOO_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@")
# set_and_check(FOO_SYSCONFIG_DIR "@PACKAGE_SYSCONFIG_INSTALL_DIR@")
#
# check_required_components(Foo)
#=============================================================================
# Copyright 2012 Alexander Neundorf <neundorf@kde.org>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
include(CMakeParseArguments)
include(WriteBasicConfigVersionFile)
macro(WRITE_BASIC_PACKAGE_VERSION_FILE)
write_basic_config_version_file(${ARGN})
endmacro()
function(CONFIGURE_PACKAGE_CONFIG_FILE _inputFile _outputFile)
set(options NO_SET_AND_CHECK_MACRO NO_CHECK_REQUIRED_COMPONENTS_MACRO)
set(oneValueArgs INSTALL_DESTINATION )
set(multiValueArgs PATH_VARS )
cmake_parse_arguments(CCF "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(CCF_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "Unknown keywords given to CONFIGURE_PACKAGE_CONFIG_FILE(): \"${CCF_UNPARSED_ARGUMENTS}\"")
endif()
if(NOT CCF_INSTALL_DESTINATION)
message(FATAL_ERROR "No INSTALL_DESTINATION given to CONFIGURE_PACKAGE_CONFIG_FILE()")
endif()
if(IS_ABSOLUTE "${CCF_INSTALL_DESTINATION}")
set(absInstallDir "${CCF_INSTALL_DESTINATION}")
else()
set(absInstallDir "${CMAKE_INSTALL_PREFIX}/${CCF_INSTALL_DESTINATION}")
endif()
file(RELATIVE_PATH PACKAGE_RELATIVE_PATH "${absInstallDir}" "${CMAKE_INSTALL_PREFIX}" )
foreach(var ${CCF_PATH_VARS})
if(NOT DEFINED ${var})
message(FATAL_ERROR "Variable ${var} does not exist")
else()
if(IS_ABSOLUTE "${${var}}")
string(REPLACE "${CMAKE_INSTALL_PREFIX}" "\${PACKAGE_PREFIX_DIR}"
PACKAGE_${var} "${${var}}")
else()
set(PACKAGE_${var} "\${PACKAGE_PREFIX_DIR}/${${var}}")
endif()
endif()
endforeach()
set(PACKAGE_INIT "
####### Expanded from @PACKAGE_INIT@ by configure_package_config_file() #######
get_filename_component(PACKAGE_PREFIX_DIR \"\${CMAKE_CURRENT_LIST_DIR}/${PACKAGE_RELATIVE_PATH}\" ABSOLUTE)
")
if(NOT CCF_NO_SET_AND_CHECK_MACRO)
set(PACKAGE_INIT "${PACKAGE_INIT}
macro(set_and_check _var _file)
set(\${_var} \"\${_file}\")
if(NOT EXISTS \"\${_file}\")
message(FATAL_ERROR \"File or directory \${_file} referenced by variable \${_var} does not exist !\")
endif()
endmacro()
")
endif()
if(NOT CCF_NO_CHECK_REQUIRED_COMPONENTS_MACRO)
set(PACKAGE_INIT "${PACKAGE_INIT}
macro(check_required_components _NAME)
foreach(comp \${\${_NAME}_FIND_COMPONENTS})
if(NOT \${_NAME}_\${comp}_FOUND)
if(\${_NAME}_FIND_REQUIRED_\${comp})
set(\${_NAME}_FOUND FALSE)
endif()
endif()
endforeach(comp)
endmacro()
")
endif()
set(PACKAGE_INIT "${PACKAGE_INIT}
####################################################################################")
configure_file("${_inputFile}" "${_outputFile}" @ONLY)
endfunction()

View File

@ -0,0 +1,6 @@
set(GLM_VERSION "@GLM_VERSION@")
set(GLM_INCLUDE_DIRS "@CMAKE_CURRENT_SOURCE_DIR@")
if (NOT CMAKE_VERSION VERSION_LESS "2.8.12")
include("${CMAKE_CURRENT_LIST_DIR}/glmTargets.cmake")
endif()

9
cmake/glmConfig.cmake.in Normal file
View File

@ -0,0 +1,9 @@
set(GLM_VERSION "@GLM_VERSION@")
@PACKAGE_INIT@
set_and_check(GLM_INCLUDE_DIRS "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@")
if (NOT CMAKE_VERSION VERSION_LESS "2.8.12")
include("${CMAKE_CURRENT_LIST_DIR}/glmTargets.cmake")
endif()

Binary file not shown.

View File

@ -4,6 +4,7 @@ file(GLOB ROOT_SOURCE *.cpp)
file(GLOB ROOT_INLINE *.inl)
file(GLOB ROOT_HEADER *.hpp)
file(GLOB ROOT_TEXT ../*.txt)
file(GLOB ROOT_MD ../*.md)
file(GLOB ROOT_NAT ../util/glm.natvis)
file(GLOB_RECURSE CORE_SOURCE ./detail/*.cpp)
@ -18,7 +19,7 @@ file(GLOB_RECURSE GTX_SOURCE ./gtx/*.cpp)
file(GLOB_RECURSE GTX_INLINE ./gtx/*.inl)
file(GLOB_RECURSE GTX_HEADER ./gtx/*.hpp)
source_group("Text Files" FILES ${ROOT_TEXT})
source_group("Text Files" FILES ${ROOT_TEXT} ${ROOT_MD})
source_group("Core Files" FILES ${CORE_SOURCE})
source_group("Core Files" FILES ${CORE_INLINE})
source_group("Core Files" FILES ${CORE_HEADER})
@ -32,7 +33,7 @@ source_group("GTX Files" FILES ${GTX_HEADER})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
if(GLM_TEST_ENABLE)
add_executable(${NAME} ${ROOT_TEXT} ${ROOT_NAT}
add_executable(${NAME} ${ROOT_TEXT} ${ROOT_MD} ${ROOT_NAT}
${ROOT_SOURCE} ${ROOT_INLINE} ${ROOT_HEADER}
${CORE_SOURCE} ${CORE_INLINE} ${CORE_HEADER}
${GTC_SOURCE} ${GTC_INLINE} ${GTC_HEADER}

View File

@ -173,7 +173,7 @@ namespace glm
/// Creates a matrix for a symetric perspective-view frustum based on the default handedness.
///
/// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
/// @param fovy Specifies the field of view angle in the y direction. Expressed in radians.
/// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
/// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
/// @param far Specifies the distance from the viewer to the far clipping plane (always positive).

View File

@ -33,6 +33,16 @@
namespace glm{
namespace detail
{
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> taylorCos(vecType<T, P> const & x)
{
return static_cast<T>(1)
- (x * x) / 2.f
+ (x * x * x * x) / 24.f
- (x * x * x * x * x * x) / 720.f
+ (x * x * x * x * x * x * x * x) / 40320.f;
}
template <typename T>
GLM_FUNC_QUALIFIER T cos_52s(T x)
{
@ -66,11 +76,11 @@ namespace detail
{
T const angle(wrapAngle<T>(x));
if(angle<half_pi<T>())
if(angle < half_pi<T>())
return detail::cos_52s(angle);
if(angle<pi<T>())
if(angle < pi<T>())
return -detail::cos_52s(pi<T>() - angle);
if(angle<(T(3) * half_pi<T>()))
if(angle < (T(3) * half_pi<T>()))
return -detail::cos_52s(angle - pi<T>());
return detail::cos_52s(two_pi<T>() - angle);

View File

@ -55,7 +55,7 @@ namespace glm
/// @addtogroup gtx_intersect
/// @{
//! Compute the intersection of a ray and a triangle.
//! Compute the intersection of a ray and a plane.
//! Ray direction and plane normal must be unit length.
//! From GLM_GTX_intersect extension.
template <typename genType>

View File

@ -220,6 +220,12 @@ namespace glm
std::pair<tmat4x4<T,P> const,
tmat4x4<T,P> const> const &);
template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr> & operator<<(
std::basic_ostream<CTy,CTr> &,
std::pair<tmat4x4<T,P>,
tmat4x4<T,P> > const &);
/// @}
}//namespace glm

View File

@ -645,4 +645,12 @@ namespace io
return os;
}
template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>& operator<<(
std::basic_ostream<CTy,CTr> & os,
std::pair<tmat4x4<T,P>, tmat4x4<T,P> > const& a)
{
return operator<<(os, static_cast<std::pair<tmat4x4<T,P> const, tmat4x4<T,P> const> const&>(a));
}
}//namespace glm

View File

@ -63,6 +63,11 @@ namespace glm
template <typename genType>
GLM_FUNC_DECL genType repeat(genType const & Texcoord);
/// Simulate GL_MIRRORED_REPEAT OpenGL wrap mode
/// @see gtx_wrap extension.
template <typename genType>
GLM_FUNC_DECL genType mirrorClamp(genType const & Texcoord);
/// Simulate GL_MIRROR_REPEAT OpenGL wrap mode
/// @see gtx_wrap extension.
template <typename genType>

View File

@ -33,67 +33,46 @@
namespace glm
{
template <typename genType>
GLM_FUNC_QUALIFIER genType clamp
(
genType const & Texcoord
)
GLM_FUNC_QUALIFIER genType clamp(genType const & Texcoord)
{
return glm::clamp(Texcoord, genType(0), genType(1));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> clamp
(
tvec2<T, P> const & Texcoord
)
GLM_FUNC_QUALIFIER tvec2<T, P> clamp(tvec2<T, P> const & Texcoord)
{
tvec2<T, P> Result;
for(typename tvec2<T, P>::size_type i = 0; i < tvec2<T, P>::value_size(); ++i)
Result[i] = clamp(Texcoord[i]);
Result[i] = clamp_to_edge(Texcoord[i]);
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> clamp
(
tvec3<T, P> const & Texcoord
)
GLM_FUNC_QUALIFIER tvec3<T, P> clamp(tvec3<T, P> const & Texcoord)
{
tvec3<T, P> Result;
for(typename tvec3<T, P>::size_type i = 0; i < tvec3<T, P>::value_size(); ++i)
Result[i] = clamp(Texcoord[i]);
Result[i] = clamp_to_edge(Texcoord[i]);
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> clamp
(
tvec4<T, P> const & Texcoord
)
GLM_FUNC_QUALIFIER tvec4<T, P> clamp(tvec4<T, P> const & Texcoord)
{
tvec4<T, P> Result;
for(typename tvec4<T, P>::size_type i = 0; i < tvec4<T, P>::value_size(); ++i)
Result[i] = clamp(Texcoord[i]);
Result[i] = clamp_to_edge(Texcoord[i]);
return Result;
}
////////////////////////
// repeat
template <typename genType>
GLM_FUNC_QUALIFIER genType repeat
(
genType const & Texcoord
)
template <typename genType>
GLM_FUNC_QUALIFIER genType repeat(genType const & Texcoord)
{
return glm::fract(Texcoord);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> repeat
(
tvec2<T, P> const & Texcoord
)
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> repeat(tvec2<T, P> const & Texcoord)
{
tvec2<T, P> Result;
for(typename tvec2<T, P>::size_type i = 0; i < tvec2<T, P>::value_size(); ++i)
@ -101,11 +80,8 @@ namespace glm
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> repeat
(
tvec3<T, P> const & Texcoord
)
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> repeat(tvec3<T, P> const & Texcoord)
{
tvec3<T, P> Result;
for(typename tvec3<T, P>::size_type i = 0; i < tvec3<T, P>::value_size(); ++i)
@ -113,11 +89,8 @@ namespace glm
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> repeat
(
tvec4<T, P> const & Texcoord
)
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> repeat(tvec4<T, P> const & Texcoord)
{
tvec4<T, P> Result;
for(typename tvec4<T, P>::size_type i = 0; i < tvec4<T, P>::value_size(); ++i)
@ -125,18 +98,47 @@ namespace glm
return Result;
}
////////////////////////
// mirrorRepeat
template <typename genType, precision P>
GLM_FUNC_QUALIFIER genType mirrorRepeat
(
genType const & Texcoord
)
template <typename genType>
GLM_FUNC_QUALIFIER genType mirrorClamp(genType const & Texcoord)
{
genType const Clamp = genType(int(glm::floor(Texcoord)) % 2);
genType const Floor = glm::floor(Texcoord);
genType const Rest = Texcoord - Floor;
return glm::fract(glm::abs(Texcoord));
//return glm::mod(glm::abs(Texcoord), 1.0f);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> mirrorClamp(tvec2<T, P> const & Texcoord)
{
tvec2<T, P> Result;
for(typename tvec2<T, P>::size_type i = 0; i < tvec2<T, P>::value_size(); ++i)
Result[i] = mirrorClamp(Texcoord[i]);
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> mirrorClamp(tvec3<T, P> const & Texcoord)
{
tvec3<T, P> Result;
for(typename tvec3<T, P>::size_type i = 0; i < tvec3<T, P>::value_size(); ++i)
Result[i] = mirrorClamp(Texcoord[i]);
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> mirrorClamp(tvec4<T, P> const & Texcoord)
{
tvec4<T, P> Result;
for(typename tvec4<T, P>::size_type i = 0; i < tvec4<T, P>::value_size(); ++i)
Result[i] = mirrorClamp(Texcoord[i]);
return Result;
}
template <typename genType>
GLM_FUNC_QUALIFIER genType mirrorRepeat(genType const & Texcoord)
{
genType const Abs = glm::abs(Texcoord);
genType const Clamp = genType(int(glm::floor(Abs)) % 2);
genType const Floor = glm::floor(Abs);
genType const Rest = Abs - Floor;
genType const Mirror = Clamp + Rest;
genType Out;
@ -147,11 +149,8 @@ namespace glm
return Out;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> mirrorRepeat
(
tvec2<T, P> const & Texcoord
)
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> mirrorRepeat(tvec2<T, P> const & Texcoord)
{
tvec2<T, P> Result;
for(typename tvec2<T, P>::size_type i = 0; i < tvec2<T, P>::value_size(); ++i)
@ -159,11 +158,8 @@ namespace glm
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> mirrorRepeat
(
tvec3<T, P> const & Texcoord
)
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> mirrorRepeat(tvec3<T, P> const & Texcoord)
{
tvec3<T, P> Result;
for(typename tvec3<T, P>::size_type i = 0; i < tvec3<T, P>::value_size(); ++i)
@ -171,11 +167,8 @@ namespace glm
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> mirrorRepeat
(
tvec4<T, P> const & Texcoord
)
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> mirrorRepeat(tvec4<T, P> const & Texcoord)
{
tvec4<T, P> Result;
for(typename tvec4<T, P>::size_type i = 0; i < tvec4<T, P>::value_size(); ++i)

View File

@ -1,115 +1,104 @@
================================================================================
OpenGL Mathematics (GLM)
--------------------------------------------------------------------------------
GLM can be distributed and/or modified under the terms of either
a) The Happy Bunny License, or b) the MIT License.
![glm](doc/logo.png)
================================================================================
The Happy Bunny License (Modified MIT License)
--------------------------------------------------------------------------------
Copyright (c) 2005 - 2015 G-Truc Creation
[OpenGL Mathematics](http://glm.g-truc.net/) (*GLM*) is a header only C++ mathematics library for graphics software based on the [OpenGL Shading Language (GLSL) specifications](https://www.opengl.org/registry/doc/GLSLangSpec.4.50.diff.pdf).
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:
*GLM* provides classes and functions designed and implemented with the same naming conventions and functionalities than *GLSL* so that anyone who knows *GLSL*, can use *GLM* as well in C++.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
This project isn't limited to *GLSL* features. An extension system, based on the *GLSL* extension conventions, provides extended capabilities: matrix transformations, quaternions, data packing, random numbers, noise, etc...
Restrictions:
By making use of the Software for military purposes, you choose to make a
Bunny unhappy.
This library works perfectly with *[OpenGL](https://www.opengl.org)* but it also ensures interoperability with other third party libraries and SDK. It is a good candidate for software rendering (raytracing / rasterisation), image processing, physic simulations and any development context that requires a simple and convenient mathematics library.
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.
*GLM* is written in C++98 but can take advantage of C++11 when supported by the compiler. It is a platform independent library with no dependence and it officially supports the following compilers:
- [Apple Clang 4.0](https://developer.apple.com/library/mac/documentation/CompilerTools/Conceptual/LLVMCompilerOverview/index.html) and higher
- [GCC](http://gcc.gnu.org/) 4.2 and higher
- [Intel C++ Composer](https://software.intel.com/en-us/intel-compilers) XE 2013 and higher
- [LLVM](http://llvm.org/) 3.0 and higher
- [Visual C++](http://www.visualstudio.com/) 2010 and higher
- [CUDA](https://developer.nvidia.com/about-cuda) 4.0 and higher (experimental)
- Any conform C++98 or C++11 compiler
================================================================================
The MIT License
--------------------------------------------------------------------------------
Copyright (c) 2005 - 2015 G-Truc Creation
For more information about *GLM*, please have a look at the [manual](http://glm.g-truc.net/0.9.6/glm-0.9.6.pdf) and the [API reference documentation](http://glm.g-truc.net/0.9.6/api/index.html).
The source code and the documentation are licensed under the [Happy Bunny License (Modified MIT) or the MIT License](./copying.txt).
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:
Thanks for contributing to the project by [submitting issues](https://github.com/g-truc/glm/issues) for bug reports and feature requests. Any feedback is welcome at [glm@g-truc.net](mailto://glm@g-truc.net).
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.
```c++
#include <glm/vec3.hpp> // glm::vec3
#include <glm/vec4.hpp> // glm::vec4
#include <glm/mat4x4.hpp> // glm::mat4
#include <glm/gtc/matrix_transform.hpp> // glm::translate, glm::rotate, glm::scale, glm::perspective
================================================================================
GLM Usage
--------------------------------------------------------------------------------
GLM is a header only library, there is nothing to build, just include it.
#include <glm/glm.hpp>
glm::mat4 camera(float Translate, glm::vec2 const & Rotate)
{
glm::mat4 Projection = glm::perspective(45.0f, 4.0f / 3.0f, 0.1f, 100.f);
glm::mat4 View = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, -Translate));
View = glm::rotate(View, Rotate.y, glm::vec3(-1.0f, 0.0f, 0.0f));
View = glm::rotate(View, Rotate.x, glm::vec3(0.0f, 1.0f, 0.0f));
glm::mat4 Model = glm::scale(glm::mat4(1.0f), glm::vec3(0.5f));
return Projection * View * Model;
}
```
More informations in GLM manual:
http://glm.g-truc.net/glm.pdf
## Project Health
================================================================================
GLM 0.9.7.0: 2015-XX-XX
--------------------------------------------------------------------------------
Features:
| Service | System | Compiler | Status |
| ------- | ------ | -------- | ------ |
| [Drone](https://drone.io/github.com/g-truc/glm) | Linux 64 bits | GCC 4.6.3 | [![Build Status](https://drone.io/github.com/g-truc/glm/status.png)](https://drone.io/github.com/g-truc/glm/latest) |
## [Lastest release](https://github.com/g-truc/glm/releases/latest)
## Release notes
#### GLM 0.9.7.0 - 2015-XX-XX
##### Features:
- Added GTC_color: convertRgbToSrgb and convertSrgbToRgb functions
- Added 'fmod' overload to GTX_common with tests #308
- Left handed perspective and lookAt functions #314
- Added functions eulerAngleXYZ and extractEulerAngleXYZ #311
- Added <glm/gtx/hash.hpp> to perform to perform std::hash on GLM types #320
- Added <glm/gtx/hash.hpp> to perform std::hash on GLM types #320
- Added <glm/gtx/wrap.hpp> for texcoord wrapping
Improvements:
##### Improvements:
- Changed usage of __has_include to support Intel compiler #307
- Specialized integer implementation of YCoCg-R #310
- Don't show status message in 'FindGLM' if 'QUIET' option is set. #317
- Added master branch continuous integration service on Linux 64 #332
- Clarified manual regarding angle unit in GLM, added FAQ 11 #326
Fixes:
##### Fixes:
- Fixed (u)int64 MSB/LSB handling on BE archs #306
- Fixed multi-line comment warning in g++. #315
- Fixed specifier removal by 'std::make_pair<>' #333
- Fixed perspective fovy argument documentation #327
- Removed -m64 causing build issues on Linux 32 #331
Deprecation:
##### Deprecation:
- Removed integer specification for 'mod' in GTC_integer #308
================================================================================
GLM 0.9.6.4: 2015-0X-XX
--------------------------------------------------------------------------------
Fixes:
#### GLM 0.9.6.4 - 2015-0X-XX
##### Fixes:
- Fixed default precision for quat and dual_quat type #312
================================================================================
GLM 0.9.6.3: 2015-02-15
--------------------------------------------------------------------------------
#### [GLM 0.9.6.3 - 2015-02-15](https://github.com/g-truc/glm/releases/tag/0.9.6.3)
- Fixed Android doesn't have C++ 11 STL #284
================================================================================
GLM 0.9.6.2: 2015-02-15
--------------------------------------------------------------------------------
Features:
#### GLM 0.9.6.2 - 2015-02-15
##### Features:
- Added display of GLM version with other GLM_MESSAGES
- Added ARM instruction set detection
Improvements:
--------------------------------------------------------------------------------
##### Improvements:
- Removed assert for perspective with zFar < zNear #298
- Added Visual Studio natvis support for vec1, quat and dualqual types
- Cleaned up C++11 feature detections
- Clarify GLM licensing
Fixes:
##### Fixes:
- Fixed faceforward build #289
- Fixed conflict with Xlib #define True 1 #293
- Fixed decompose function VS2010 templating issues #294
@ -122,17 +111,16 @@ Fixes:
- Fixed functions not inlined with Clang #302
- Fixed memory corruption (undefined behaviour) #303
================================================================================
GLM 0.9.6.1: 2014-12-10
--------------------------------------------------------------------------------
Features:
#### GLM 0.9.6.1 - 2014-12-10
##### Features:
- Added GLM_LANG_CXX14_FLAG and GLM_LANG_CXX1Z_FLAG language feature flags
- Added C++14 detection
Improvements:
##### Improvements:
- Clean up GLM_MESSAGES compilation log to report only detected capabilities
Fixes:
##### Fixes:
- Fixed scalar uaddCarry build error with Cuda #276
- Fixed C++11 explicit conversion operators detection #282
- Fixed missing explicit convertion when using integer log2 with *vec1 types
@ -145,10 +133,9 @@ Fixes:
- Fixed conflict between GTX_compatibility and GTC_quaternion #286
- Fixed C++ language restriction using GLM_FORCE_CXX**
================================================================================
GLM 0.9.6.0: 2014-11-30
--------------------------------------------------------------------------------
Features:
#### GLM 0.9.6.0 - 2014-11-30
##### Features:
- Exposed template vector and matrix types in 'glm' namespace #239, #244
- Added GTX_scalar_multiplication for C++ 11 compiler only #242
- Added GTX_range for C++ 11 compiler only #240
@ -168,7 +155,7 @@ Features:
- Added GLM_FORCE_EXPLICIT_CTOR to require explicit type conversions #269
- Added GTX_type_aligned for aligned vector, matrix and quaternion types
Improvements:
##### Improvements:
- Rely on C++11 to implement isinf and isnan
- Removed GLM_FORCE_CUDA, Cuda is implicitly detected
- Separated Apple Clang and LLVM compiler detection
@ -188,7 +175,7 @@ Improvements:
- Optimized sign function #272
- Added explicit cast from quat to mat3 and mat4 #275
Fixes:
##### Fixes:
- Fixed std::nextafter not supported with C++11 on Android #217
- Fixed missing value_type for dual quaternion
- Fixed return type of dual quaternion length
@ -199,7 +186,7 @@ Fixes:
- Fixed uaddCarray #253
- Fixed float comparison warnings #270
Deprecation:
##### Deprecation:
- Removed degrees for function parameters
- Removed GLM_FORCE_RADIANS, active by default
- Removed VC 2005 / 8 and 2008 / 9 support
@ -208,9 +195,8 @@ Deprecation:
- Removed LLVM 2.6 to 3.1 support
- Removed CUDA 3.0 to 3.2 support
================================================================================
GLM 0.9.5.4: 2014-06-21
--------------------------------------------------------------------------------
#### [GLM 0.9.5.4 - 2014-06-21](https://github.com/g-truc/glm/releases/tag/0.9.5.4)
- Fixed non-utf8 character #196
- Added FindGLM install for CMake #189
- Fixed GTX_color_space - saturation #195
@ -230,9 +216,8 @@ GLM 0.9.5.4: 2014-06-21
- Fixed std::nextafter not supported with C++11 on Android #213
- Fixed corner cases in exp and log functions for quaternions #199
================================================================================
GLM 0.9.5.3: 2014-04-02
--------------------------------------------------------------------------------
#### GLM 0.9.5.3 - 2014-04-02
- Added instruction set auto detection with Visual C++ using _M_IX86_FP - /arch
compiler argument
- Fixed GTX_raw_data code dependency
@ -247,9 +232,8 @@ GLM 0.9.5.3: 2014-04-02
- Added full tests for eulerAngle*** functions (#173)
- Added workaround for a CUDA compiler bug (#186, #185)
================================================================================
GLM 0.9.5.2: 2014-02-08
--------------------------------------------------------------------------------
#### GLM 0.9.5.2 - 2014-02-08
- Fixed initializer list ambiguity (#159, #160)
- Fixed warnings with the Android NDK 9c
- Fixed non power of two matrix products
@ -261,9 +245,8 @@ GLM 0.9.5.2: 2014-02-08
- Tentative fix for strict aliasing warning in GCC 4.8.1 / Android NDK 9c (#152)
- Fixed GLM_GTC_constants description brief (#162)
================================================================================
GLM 0.9.5.1: 2014-01-11
--------------------------------------------------------------------------------
#### GLM 0.9.5.1 - 2014-01-11
- Fixed angle and orientedAngle that sometimes return NaN values (#145)
- Deprecated degrees for function parameters and display a message
- Added possible static_cast conversion of GLM types (#72)
@ -274,9 +257,8 @@ GLM 0.9.5.1: 2014-01-11
- Added intersectRayPlane function (#153)
- Fixed outerProduct return type (#155)
================================================================================
GLM 0.9.5.0: 2013-12-25
--------------------------------------------------------------------------------
#### GLM 0.9.5.0 - 2013-12-25
- Added forward declarations (glm/fwd.hpp) for faster compilations
- Added per feature headers
- Minimized GLM internal dependencies
@ -314,9 +296,8 @@ GLM 0.9.5.0: 2013-12-25
- Improved GLM messages enabled when defining GLM_MESSAGES
- Hidden matrix _inverse function implementation detail into private section
================================================================================
GLM 0.9.4.6: 2013-09-20
--------------------------------------------------------------------------------
#### [GLM 0.9.4.6 - 2013-09-20](https://github.com/g-truc/glm/releases/tag/0.9.4.6)
- Fixed detection to select the last known compiler if newer version #106
- Fixed is_int and is_uint code duplication with GCC and C++11 #107
- Fixed test suite build while using Clang in C++11 mode
@ -330,9 +311,8 @@ GLM 0.9.4.6: 2013-09-20
- Fixed const ref issue on assignment operator taking a scalar parameter #116
- Fixed glm::eulerAngleY implementation #117
================================================================================
GLM 0.9.4.5: 2013-08-12
--------------------------------------------------------------------------------
#### GLM 0.9.4.5 - 2013-08-12
- Fixed CUDA support
- Fixed inclusion of intrinsics in "pure" mode #92
- Fixed language detection on GCC when the C++0x mode isn't enabled #95
@ -341,9 +321,8 @@ GLM 0.9.4.5: 2013-08-12
- Added Windows CE detection #92
- Added missing value_ptr for quaternions #99
================================================================================
GLM 0.9.4.4: 2013-05-29
--------------------------------------------------------------------------------
#### GLM 0.9.4.4 - 2013-05-29
- Fixed slerp when costheta is close to 1 #65
- Fixed mat4x2 value_type constructor #70
- Fixed glm.natvis for Visual C++ 12 #82
@ -354,9 +333,8 @@ GLM 0.9.4.4: 2013-05-29
- Fixed GLM_GTX_multiple with negative values #79
- Fixed glm::perspective when zNear is zero #71
================================================================================
GLM 0.9.4.3: 2013-03-20
--------------------------------------------------------------------------------
#### GLM 0.9.4.3 - 2013-03-20
- Detected qualifier for Clang
- Fixed C++11 mode for GCC, couldn't be enabled without MS extensions
- Fixed squad, intermediate and exp quaternion functions
@ -368,9 +346,8 @@ GLM 0.9.4.3: 2013-03-20
- Autodetected C++ version using __cplusplus value
- Fixed mix for bool and bvec* third parameter
================================================================================
GLM 0.9.4.2: 2013-02-14
--------------------------------------------------------------------------------
#### GLM 0.9.4.2 - 2013-02-14
- Fixed compAdd from GTX_component_wise
- Fixed SIMD support for Intel compiler on Windows
- Fixed isnan and isinf for CUDA compiler
@ -383,9 +360,8 @@ GLM 0.9.4.2: 2013-02-14
- Fixed documentation warnings
- Fixed CUDA warnings
================================================================================
GLM 0.9.4.1: 2012-12-22
--------------------------------------------------------------------------------
#### GLM 0.9.4.1 - 2012-12-22
- Improved half support: -0.0 case and implicit conversions
- Fixed Intel Composer Compiler support on Linux
- Fixed interaction between quaternion and euler angles
@ -396,9 +372,8 @@ GLM 0.9.4.1: 2012-12-22
- Fixed assert messages
- Added slerp and lerp quaternion functions and tests
================================================================================
GLM 0.9.4.0: 2012-11-18
--------------------------------------------------------------------------------
#### GLM 0.9.4.0 - 2012-11-18
- Added Intel Composer Compiler support
- Promoted GTC_espilon extension
- Promoted GTC_ulp extension
@ -407,9 +382,8 @@ GLM 0.9.4.0: 2012-11-18
- Fixed detection of Clang and LLVM GCC on MacOS X
- Added debugger visualizers for Visual C++ 2012
================================================================================
GLM 0.9.3.4: 2012-06-30
--------------------------------------------------------------------------------
#### [GLM 0.9.3.4 - 2012-06-30](https://github.com/g-truc/glm/releases/tag/0.9.3.4)
- Added SSE4 and AVX2 detection.
- Removed VIRTREV_xstream and the incompatibility generated with GCC
- Fixed C++11 compiler option for GCC
@ -418,9 +392,8 @@ GLM 0.9.3.4: 2012-06-30
- Fixed warnings
- Fixed SSE includes
================================================================================
GLM 0.9.3.3: 2012-05-10
--------------------------------------------------------------------------------
#### GLM 0.9.3.3 - 2012-05-10
- Fixed isinf and isnan
- Improved compatibility with Intel compiler
- Added CMake test build options: SIMD, C++11, fast math and MS land ext
@ -431,32 +404,28 @@ GLM 0.9.3.3: 2012-05-10
- Fixed various warnings
- Added VC11 support
================================================================================
GLM 0.9.3.2: 2012-03-15
--------------------------------------------------------------------------------
#### GLM 0.9.3.2 - 2012-03-15
- Fixed doxygen documentation
- Fixed Clang version detection
- Fixed simd mat4 /= operator
================================================================================
GLM 0.9.3.1: 2012-01-25
--------------------------------------------------------------------------------
#### GLM 0.9.3.1 - 2012-01-25
- Fixed platform detection
- Fixed warnings
- Removed detail code from Doxygen doc
================================================================================
GLM 0.9.3.0: 2012-01-09
--------------------------------------------------------------------------------
#### GLM 0.9.3.0 - 2012-01-09
- Added CPP Check project
- Fixed conflict with Windows headers
- Fixed isinf implementation
- Fixed Boost conflict
- Fixed warnings
================================================================================
GLM 0.9.3.B: 2011-12-12
--------------------------------------------------------------------------------
#### GLM 0.9.3.B - 2011-12-12
- Added support for Chrone Native Client
- Added epsilon constant
- Removed value_size function from vector types
@ -466,9 +435,8 @@ GLM 0.9.3.B: 2011-12-12
- Fixed step function accuracy
- Fixed outerProduct
================================================================================
GLM 0.9.3.A: 2011-11-11
--------------------------------------------------------------------------------
#### GLM 0.9.3.A - 2011-11-11
- Improved doxygen documentation
- Added new swizzle operators for C++11 compilers
- Added new swizzle operators declared as functions
@ -482,55 +450,47 @@ generation distribution
- Fixed half based type contructors
- Added GLSL core noise functions
================================================================================
GLM 0.9.2.7: 2011-10-24
--------------------------------------------------------------------------------
#### GLM 0.9.2.7 - 2011-10-24
- Added more swizzling constructors
- Added missing none-squared matrix products
================================================================================
GLM 0.9.2.6: 2011-10-01
--------------------------------------------------------------------------------
#### GLM 0.9.2.6 - 2011-10-01
- Fixed half based type build on old GCC
- Fixed /W4 warnings on Visual C++
- Fixed some missing l-value swizzle operators
================================================================================
GLM 0.9.2.5: 2011-09-20
--------------------------------------------------------------------------------
#### GLM 0.9.2.5 - 2011-09-20
- Fixed floatBitToXint functions
- Fixed pack and unpack functions
- Fixed round functions
================================================================================
GLM 0.9.2.4: 2011-09-03
--------------------------------------------------------------------------------
#### GLM 0.9.2.4 - 2011-09-03
- Fixed extensions bugs
================================================================================
GLM 0.9.2.3: 2011-06-08
--------------------------------------------------------------------------------
#### GLM 0.9.2.3 - 2011-06-08
- Fixed build issues
================================================================================
GLM 0.9.2.2: 2011-06-02
--------------------------------------------------------------------------------
#### GLM 0.9.2.2 - 2011-06-02
- Expend matrix constructors flexibility
- Improved quaternion implementation
- Fixed many warnings across platforms and compilers
================================================================================
GLM 0.9.2.1: 2011-05-24
--------------------------------------------------------------------------------
#### GLM 0.9.2.1 - 2011-05-24
- Automatically detect CUDA support
- Improved compiler detection
- Fixed errors and warnings in VC with C++ extensions disabled
- Fixed and tested GLM_GTX_vector_angle
- Fixed and tested GLM_GTX_rotate_vector
================================================================================
GLM 0.9.2.0: 2011-05-09
--------------------------------------------------------------------------------
#### GLM 0.9.2.0 - 2011-05-09
- Added CUDA support
- Added CTest test suite
- Added GLM_GTX_ulp extension
@ -538,42 +498,35 @@ GLM 0.9.2.0: 2011-05-09
- Added GLM_GTX_matrix_interpolation extension
- Updated quaternion slerp interpolation
================================================================================
GLM 0.9.1.3: 2011-05-07
--------------------------------------------------------------------------------
#### GLM 0.9.1.3 - 2011-05-07
- Fixed bugs
================================================================================
GLM 0.9.1.2: 2011-04-15
--------------------------------------------------------------------------------
#### GLM 0.9.1.2 - 2011-04-15
- Fixed bugs
================================================================================
GLM 0.9.1.1: 2011-03-17
--------------------------------------------------------------------------------
#### GLM 0.9.1.1 - 2011-03-17
- Fixed bugs
================================================================================
GLM 0.9.1.0: 2011-03-03
--------------------------------------------------------------------------------
#### GLM 0.9.1.0 - 2011-03-03
- Fixed bugs
================================================================================
GLM 0.9.1.B: 2011-02-13
--------------------------------------------------------------------------------
#### GLM 0.9.1.B - 2011-02-13
- Updated API documentation
- Improved SIMD implementation
- Fixed Linux build
================================================================================
GLM 0.9.0.8: 2011-02-13
--------------------------------------------------------------------------------
#### GLM 0.9.0.8 - 2011-02-13
- Added quaternion product operator.
- Clarify that GLM is a header only library.
================================================================================
GLM 0.9.1.A: 2011-01-31
--------------------------------------------------------------------------------
#### GLM 0.9.1.A - 2011-01-31
- Added SIMD support
- Added new swizzle functions
- Improved static assert error message with C++0x static_assert
@ -581,315 +534,261 @@ GLM 0.9.1.A: 2011-01-31
- Reduced branching
- Fixed trunc implementation
================================================================================
GLM 0.9.0.7: 2011-01-30
--------------------------------------------------------------------------------
#### GLM 0.9.0.7 - 2011-01-30
- Added GLSL 4.10 packing functions
- Added == and != operators for every types.
================================================================================
GLM 0.9.0.6: 2010-12-21
--------------------------------------------------------------------------------
#### GLM 0.9.0.6 - 2010-12-21
- Many matrices bugs fixed
================================================================================
GLM 0.9.0.5: 2010-11-01
--------------------------------------------------------------------------------
#### GLM 0.9.0.5 - 2010-11-01
- Improved Clang support
- Fixed bugs
================================================================================
GLM 0.9.0.4: 2010-10-04
--------------------------------------------------------------------------------
#### GLM 0.9.0.4 - 2010-10-04
- Added autoexp for GLM
- Fixed bugs
================================================================================
GLM 0.9.0.3: 2010-08-26
--------------------------------------------------------------------------------
#### GLM 0.9.0.3 - 2010-08-26
- Fixed non-squared matrix operators
================================================================================
GLM 0.9.0.2: 2010-07-08
--------------------------------------------------------------------------------
#### GLM 0.9.0.2 - 2010-07-08
- Added GLM_GTX_int_10_10_10_2
- Fixed bugs
================================================================================
GLM 0.9.0.1: 2010-06-21
--------------------------------------------------------------------------------
#### GLM 0.9.0.1 - 2010-06-21
- Fixed extensions errors
================================================================================
GLM 0.9.0.0: 2010-05-25
--------------------------------------------------------------------------------
#### GLM 0.9.0.0 - 2010-05-25
- Objective-C support
- Fixed warnings
- Updated documentation
================================================================================
GLM 0.9.B.2: 2010-04-30
--------------------------------------------------------------------------------
#### GLM 0.9.B.2 - 2010-04-30
- Git transition
- Removed experimental code from releases
- Fixed bugs
================================================================================
GLM 0.9.B.1: 2010-04-03
--------------------------------------------------------------------------------
#### GLM 0.9.B.1 - 2010-04-03
- Based on GLSL 4.00 specification
- Added the new core functions
- Added some implicit conversion support
================================================================================
GLM 0.9.A.2: 2010-02-20
--------------------------------------------------------------------------------
#### GLM 0.9.A.2 - 2010-02-20
- Improved some possible errors messages
- Improved declarations and definitions match
================================================================================
GLM 0.9.A.1: 2010-02-09
--------------------------------------------------------------------------------
#### GLM 0.9.A.1 - 2010-02-09
- Removed deprecated features
- Internal redesign
================================================================================
GLM 0.8.4.4 final: 2010-01-25
--------------------------------------------------------------------------------
#### GLM 0.8.4.4 final - 2010-01-25
- Fixed warnings
================================================================================
GLM 0.8.4.3 final: 2009-11-16
--------------------------------------------------------------------------------
#### GLM 0.8.4.3 final - 2009-11-16
- Fixed Half float arithmetic
- Fixed setup defines
================================================================================
GLM 0.8.4.2 final: 2009-10-19
--------------------------------------------------------------------------------
#### GLM 0.8.4.2 final - 2009-10-19
- Fixed Half float adds
================================================================================
GLM 0.8.4.1 final: 2009-10-05
--------------------------------------------------------------------------------
#### GLM 0.8.4.1 final - 2009-10-05
- Updated documentation
- Fixed MacOS X build
================================================================================
GLM 0.8.4.0 final: 2009-09-16
--------------------------------------------------------------------------------
#### GLM 0.8.4.0 final - 2009-09-16
- Added GCC 4.4 and VC2010 support
- Added matrix optimizations
================================================================================
GLM 0.8.3.5 final: 2009-08-11
--------------------------------------------------------------------------------
#### GLM 0.8.3.5 final - 2009-08-11
- Fixed bugs
================================================================================
GLM 0.8.3.4 final: 2009-08-10
--------------------------------------------------------------------------------
#### GLM 0.8.3.4 final - 2009-08-10
- Updated GLM according GLSL 1.5 spec
- Fixed bugs
================================================================================
GLM 0.8.3.3 final: 2009-06-25
--------------------------------------------------------------------------------
#### GLM 0.8.3.3 final - 2009-06-25
- Fixed bugs
================================================================================
GLM 0.8.3.2 final: 2009-06-04
--------------------------------------------------------------------------------
#### GLM 0.8.3.2 final - 2009-06-04
- Added GLM_GTC_quaternion
- Added GLM_GTC_type_precision
================================================================================
GLM 0.8.3.1 final: 2009-05-21
--------------------------------------------------------------------------------
#### GLM 0.8.3.1 final - 2009-05-21
- Fixed old extension system.
================================================================================
GLM 0.8.3.0 final: 2009-05-06
--------------------------------------------------------------------------------
#### GLM 0.8.3.0 final - 2009-05-06
- Added stable extensions.
- Added new extension system.
================================================================================
GLM 0.8.2.3 final: 2009-04-01
--------------------------------------------------------------------------------
#### GLM 0.8.2.3 final - 2009-04-01
- Fixed bugs.
================================================================================
GLM 0.8.2.2 final: 2009-02-24
--------------------------------------------------------------------------------
#### GLM 0.8.2.2 final - 2009-02-24
- Fixed bugs.
================================================================================
GLM 0.8.2.1 final: 2009-02-13
--------------------------------------------------------------------------------
#### GLM 0.8.2.1 final - 2009-02-13
- Fixed bugs.
================================================================================
GLM 0.8.2 final: 2009-01-21
--------------------------------------------------------------------------------
#### GLM 0.8.2 final - 2009-01-21
- Fixed bugs.
================================================================================
GLM 0.8.1 final: 2008-10-30
--------------------------------------------------------------------------------
#### GLM 0.8.1 final - 2008-10-30
- Fixed bugs.
================================================================================
GLM 0.8.0 final: 2008-10-23
--------------------------------------------------------------------------------
#### GLM 0.8.0 final - 2008-10-23
- New method to use extension.
================================================================================
GLM 0.8.0 beta3: 2008-10-10
--------------------------------------------------------------------------------
#### GLM 0.8.0 beta3 - 2008-10-10
- Added CMake support for GLM tests.
================================================================================
GLM 0.8.0 beta2: 2008-10-04
--------------------------------------------------------------------------------
#### GLM 0.8.0 beta2 - 2008-10-04
- Improved half scalars and vectors support.
================================================================================
GLM 0.8.0 beta1: 2008-09-26
--------------------------------------------------------------------------------
#### GLM 0.8.0 beta1 - 2008-09-26
- Improved GLSL conformance
- Added GLSL 1.30 support
- Improved API documentation
================================================================================
GLM 0.7.6 final: 2008-08-08
--------------------------------------------------------------------------------
#### GLM 0.7.6 final - 2008-08-08
- Improved C++ standard comformance
- Added Static assert for types checking
================================================================================
GLM 0.7.5 final: 2008-07-05
--------------------------------------------------------------------------------
#### GLM 0.7.5 final - 2008-07-05
- Added build message system with Visual Studio
- Pedantic build with GCC
================================================================================
GLM 0.7.4 final: 2008-06-01
--------------------------------------------------------------------------------
#### GLM 0.7.4 final - 2008-06-01
- Added external dependencies system.
================================================================================
GLM 0.7.3 final: 2008-05-24
--------------------------------------------------------------------------------
#### GLM 0.7.3 final - 2008-05-24
- Fixed bugs
- Added new extension group
================================================================================
GLM 0.7.2 final: 2008-04-27
--------------------------------------------------------------------------------
#### GLM 0.7.2 final - 2008-04-27
- Updated documentation
- Added preprocessor options
================================================================================
GLM 0.7.1 final: 2008-03-24
--------------------------------------------------------------------------------
#### GLM 0.7.1 final - 2008-03-24
- Disabled half on GCC
- Fixed extensions
================================================================================
GLM 0.7.0 final: 2008-03-22
--------------------------------------------------------------------------------
#### GLM 0.7.0 final - 2008-03-22
- Changed to MIT license
- Added new documentation
================================================================================
GLM 0.6.4 : 2007-12-10
--------------------------------------------------------------------------------
#### GLM 0.6.4 - 2007-12-10
- Fixed swizzle operators
================================================================================
GLM 0.6.3 : 2007-11-05
--------------------------------------------------------------------------------
#### GLM 0.6.3 - 2007-11-05
- Fixed type data accesses
- Fixed 3DSMax sdk conflict
================================================================================
GLM 0.6.2 : 2007-10-08
--------------------------------------------------------------------------------
#### GLM 0.6.2 - 2007-10-08
- Fixed extension
================================================================================
GLM 0.6.1 : 2007-10-07
--------------------------------------------------------------------------------
#### GLM 0.6.1 - 2007-10-07
- Fixed a namespace error
- Added extensions
================================================================================
GLM 0.6.0 : 2007-09-16
--------------------------------------------------------------------------------
#### GLM 0.6.0 : 2007-09-16
- Added new extension namespace mecanium
- Added Automatic compiler detection
================================================================================
GLM 0.5.1 : 2007-02-19
--------------------------------------------------------------------------------
#### GLM 0.5.1 - 2007-02-19
- Fixed swizzle operators
================================================================================
GLM 0.5.0 : 2007-01-06
--------------------------------------------------------------------------------
#### GLM 0.5.0 - 2007-01-06
- Upgrated to GLSL 1.2
- Added swizzle operators
- Added setup settings
================================================================================
GLM 0.4.1 : 2006-05-22
--------------------------------------------------------------------------------
#### GLM 0.4.1 - 2006-05-22
- Added OpenGL examples
================================================================================
GLM 0.4.0 : 2006-05-17
--------------------------------------------------------------------------------
#### GLM 0.4.0 - 2006-05-17
- Added missing operators to vec* and mat*
- Added first GLSL 1.2 features
- Fixed windows.h before glm.h when windows.h required
================================================================================
GLM 0.3.2 : 2006-04-21
--------------------------------------------------------------------------------
#### GLM 0.3.2 - 2006-04-21
- Fixed texcoord components access.
- Fixed mat4 and imat4 division operators.
================================================================================
GLM 0.3.1 : 2006-03-28
--------------------------------------------------------------------------------
#### GLM 0.3.1 - 2006-03-28
- Added GCC 4.0 support under MacOS X.
- Added GCC 4.0 and 4.1 support under Linux.
- Added code optimisations.
================================================================================
GLM 0.3 : 2006-02-19
--------------------------------------------------------------------------------
#### GLM 0.3 - 2006-02-19
- Improved GLSL type conversion and construction compliance.
- Added experimental extensions.
- Added Doxygen Documentation.
- Added code optimisations.
- Fixed bugs.
================================================================================
GLM 0.2: 2005-05-05
--------------------------------------------------------------------------------
#### GLM 0.2 - 2005-05-05
- Improve adaptative from GLSL.
- Add experimental extensions based on OpenGL extension process.
- Fixe bugs.
================================================================================
GLM 0.1: 2005-02-21
--------------------------------------------------------------------------------
#### GLM 0.1 - 2005-02-21
- Add vec2, vec3, vec4 GLSL types
- Add ivec2, ivec3, ivec4 GLSL types
- Add bvec2, bvec3, bvec4 GLSL types
- Add mat2, mat3, mat4 GLSL types
- Add almost all functions
================================================================================

View File

@ -168,6 +168,22 @@ namespace mod_
{
int Error(0);
{
float A(1.5f);
float B(1.0f);
float C = glm::mod(A, B);
Error += glm::abs(C - 0.5f) < 0.00001f ? 0 : 1;
}
{
float A(-0.2f);
float B(1.0f);
float C = glm::mod(A, B);
Error += glm::abs(C - 0.8f) < 0.00001f ? 0 : 1;
}
{
float A(3.0);
float B(2.0f);

View File

@ -30,17 +30,12 @@
///////////////////////////////////////////////////////////////////////////////////
#include <glm/trigonometric.hpp>
/*
float sin(float x) {
float temp;
temp = (x + M_PI) / ((2 * M_PI) - M_PI);
return limited_sin((x + M_PI) - ((2 * M_PI) - M_PI) * temp));
}
*/
int main()
{
int Failed = 0;
int Error = 0;
return Failed;
return Error;
}

View File

@ -631,11 +631,13 @@ namespace bitfieldInterleave
std::printf("glm::detail::bitfieldInterleave Time %d clocks\n", static_cast<unsigned int>(Time));
}
# if(GLM_ARCH != GLM_ARCH_PURE)
# if(GLM_ARCH != GLM_ARCH_PURE && !(GLM_COMPILER & GLM_COMPILER_GCC))
{
// SIMD
std::vector<__m128i> SimdData(x_max * y_max);
std::vector<__m128i> SimdParam(x_max * y_max);
std::vector<__m128i> SimdData;
SimdData.resize(x_max * y_max);
std::vector<__m128i> SimdParam;
SimdParam.resize(x_max * y_max);
for(int i = 0; i < SimdParam.size(); ++i)
SimdParam[i] = _mm_set_epi32(i % x_max, 0, i / y_max, 0);

View File

@ -39,20 +39,34 @@ namespace srgb
{
int Error(0);
glm::vec4 const ColorSourceRGB(1.0, 0.5, 0.0, 1.0);
glm::vec3 const ColorSourceRGB(1.0, 0.5, 0.0);
{
glm::vec4 const ColorSRGB = glm::convertRgbToSrgb(ColorSourceRGB);
glm::vec4 const ColorRGB = glm::convertSrgbToRgb(ColorSRGB);
glm::vec3 const ColorSRGB = glm::convertRgbToSrgb(ColorSourceRGB);
glm::vec3 const ColorRGB = glm::convertSrgbToRgb(ColorSRGB);
Error += glm::all(glm::epsilonEqual(ColorSourceRGB, ColorRGB, 0.00001f)) ? 0 : 1;
}
{
glm::vec4 const ColorSRGB = glm::convertRgbToSrgb(ColorSourceRGB, 2.8f);
glm::vec4 const ColorRGB = glm::convertSrgbToRgb(ColorSRGB, 2.8f);
glm::vec3 const ColorSRGB = glm::convertRgbToSrgb(ColorSourceRGB, 2.8f);
glm::vec3 const ColorRGB = glm::convertSrgbToRgb(ColorSRGB, 2.8f);
Error += glm::all(glm::epsilonEqual(ColorSourceRGB, ColorRGB, 0.00001f)) ? 0 : 1;
}
glm::vec4 const ColorSourceRGBA(1.0, 0.5, 0.0, 1.0);
{
glm::vec4 const ColorSRGB = glm::convertRgbToSrgb(ColorSourceRGBA);
glm::vec4 const ColorRGB = glm::convertSrgbToRgb(ColorSRGB);
Error += glm::all(glm::epsilonEqual(ColorSourceRGBA, ColorRGB, 0.00001f)) ? 0 : 1;
}
{
glm::vec4 const ColorSRGB = glm::convertRgbToSrgb(ColorSourceRGBA, 2.8f);
glm::vec4 const ColorRGB = glm::convertSrgbToRgb(ColorSRGB, 2.8f);
Error += glm::all(glm::epsilonEqual(ColorSourceRGBA, ColorRGB, 0.00001f)) ? 0 : 1;
}
return Error;
}
}//namespace srgb

View File

@ -48,3 +48,4 @@ glmCreateTestGTC(gtx_string_cast)
glmCreateTestGTC(gtx_type_aligned)
glmCreateTestGTC(gtx_vector_angle)
glmCreateTestGTC(gtx_vector_query)
glmCreateTestGTC(gtx_wrap)

View File

@ -31,10 +31,16 @@
#include <glm/gtc/type_precision.hpp>
#include <glm/gtx/fast_trigonometry.hpp>
#include <glm/gtx/integer.hpp>
#include <glm/gtx/common.hpp>
#include <glm/gtc/constants.hpp>
#include <glm/gtc/ulp.hpp>
#include <glm/gtc/vec1.hpp>
#include <glm/trigonometric.hpp>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
namespace fastCos
{
@ -43,12 +49,15 @@ namespace fastCos
const float begin = -glm::pi<float>();
const float end = glm::pi<float>();
float result = 0.f;
const std::clock_t timestamp1 = std::clock();
for(float i=begin; i<end; i = glm::next_float(i, end))
for(float i = begin; i < end; i = glm::next_float(i))
result = glm::fastCos(i);
const std::clock_t timestamp2 = std::clock();
for(float i=begin; i<end; i = glm::next_float(i, end))
for(float i = begin; i < end; i = glm::next_float(i))
result = glm::cos(i);
const std::clock_t timestamp3 = std::clock();
const std::clock_t time_fast = timestamp2 - timestamp1;
const std::clock_t time_default = timestamp3 - timestamp2;
@ -74,12 +83,15 @@ namespace fastSin
const float begin = -glm::pi<float>();
const float end = glm::pi<float>();
float result = 0.f;
const std::clock_t timestamp1 = std::clock();
for (float i = begin; i<end; i = glm::next_float(i, end))
for(float i = begin; i < end; i = glm::next_float(i))
result = glm::fastSin(i);
const std::clock_t timestamp2 = std::clock();
for (float i = begin; i<end; i = glm::next_float(i, end))
for(float i = begin; i < end; i = glm::next_float(i))
result = glm::sin(i);
const std::clock_t timestamp3 = std::clock();
const std::clock_t time_fast = timestamp2 - timestamp1;
const std::clock_t time_default = timestamp3 - timestamp2;
@ -97,12 +109,15 @@ namespace fastTan
const float begin = -glm::pi<float>();
const float end = glm::pi<float>();
float result = 0.f;
const std::clock_t timestamp1 = std::clock();
for (float i = begin; i<end; i = glm::next_float(i, end))
for(float i = begin; i < end; i = glm::next_float(i))
result = glm::fastTan(i);
const std::clock_t timestamp2 = std::clock();
for (float i = begin; i<end; i = glm::next_float(i, end))
for (float i = begin; i < end; i = glm::next_float(i))
result = glm::tan(i);
const std::clock_t timestamp3 = std::clock();
const std::clock_t time_fast = timestamp2 - timestamp1;
const std::clock_t time_default = timestamp3 - timestamp2;
@ -120,15 +135,19 @@ namespace fastAcos
const float begin = -glm::pi<float>();
const float end = glm::pi<float>();
float result = 0.f;
const std::clock_t timestamp1 = std::clock();
for (float i = begin; i<end; i = glm::next_float(i, end))
for(float i = begin; i < end; i = glm::next_float(i))
result = glm::fastAcos(i);
const std::clock_t timestamp2 = std::clock();
for (float i = begin; i<end; i = glm::next_float(i, end))
for(float i = begin; i < end; i = glm::next_float(i))
result = glm::acos(i);
const std::clock_t timestamp3 = std::clock();
const std::clock_t time_fast = timestamp2 - timestamp1;
const std::clock_t time_default = timestamp3 - timestamp2;
std::printf("fastAcos Time %d clocks\n", static_cast<unsigned int>(time_fast));
std::printf("acos Time %d clocks\n", static_cast<unsigned int>(time_default));
@ -144,10 +163,10 @@ namespace fastAsin
const float end = glm::pi<float>();
float result = 0.f;
const std::clock_t timestamp1 = std::clock();
for (float i = begin; i<end; i = glm::next_float(i, end))
for(float i = begin; i < end; i = glm::next_float(i))
result = glm::fastAsin(i);
const std::clock_t timestamp2 = std::clock();
for (float i = begin; i<end; i = glm::next_float(i, end))
for(float i = begin; i < end; i = glm::next_float(i))
result = glm::asin(i);
const std::clock_t timestamp3 = std::clock();
const std::clock_t time_fast = timestamp2 - timestamp1;
@ -167,10 +186,10 @@ namespace fastAtan
const float end = glm::pi<float>();
float result = 0.f;
const std::clock_t timestamp1 = std::clock();
for (float i = begin; i<end; i = glm::next_float(i, end))
for(float i = begin; i < end; i = glm::next_float(i))
result = glm::fastAtan(i);
const std::clock_t timestamp2 = std::clock();
for (float i = begin; i<end; i = glm::next_float(i, end))
for(float i = begin; i < end; i = glm::next_float(i))
result = glm::atan(i);
const std::clock_t timestamp3 = std::clock();
const std::clock_t time_fast = timestamp2 - timestamp1;
@ -182,10 +201,269 @@ namespace fastAtan
}
}//namespace fastAtan
namespace taylorCos
{
glm::vec4 const AngleShift(0.0f, glm::pi<float>() * 0.5f, glm::pi<float>() * 1.0f, glm::pi<float>() * 1.5f);
template <typename T, glm::precision P, template <typename, glm::precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> taylorSeriesNewCos(vecType<T, P> const & x)
{
vecType<T, P> const Powed2(x * x);
vecType<T, P> const Powed4(Powed2 * Powed2);
vecType<T, P> const Powed6(Powed4 * Powed2);
vecType<T, P> const Powed8(Powed4 * Powed4);
return static_cast<T>(1)
- Powed2 * static_cast<T>(0.5)
+ Powed4 * static_cast<T>(0.04166666666666666666666666666667)
- Powed6 * static_cast<T>(0.00138888888888888888888888888889)
+ Powed8 * static_cast<T>(2.4801587301587301587301587301587e-5);
}
template <typename T, glm::precision P, template <typename, glm::precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> taylorSeriesNewCos6(vecType<T, P> const & x)
{
vecType<T, P> const Powed2(x * x);
vecType<T, P> const Powed4(Powed2 * Powed2);
vecType<T, P> const Powed6(Powed4 * Powed2);
return static_cast<T>(1)
- Powed2 * static_cast<T>(0.5)
+ Powed4 * static_cast<T>(0.04166666666666666666666666666667)
- Powed6 * static_cast<T>(0.00138888888888888888888888888889);
}
template <glm::precision P, template <typename, glm::precision> class vecType>
GLM_FUNC_QUALIFIER vecType<float, P> fastAbs(vecType<float, P> x)
{
int* Pointer = reinterpret_cast<int*>(&x[0]);
*(((int *) &Pointer[0]) + 1) &= 0x7fffffff;
*(((int *) &Pointer[1]) + 1) &= 0x7fffffff;
*(((int *) &Pointer[2]) + 1) &= 0x7fffffff;
*(((int *) &Pointer[3]) + 1) &= 0x7fffffff;
return x;
}
template <typename T, glm::precision P, template <typename, glm::precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> fastCosNew(vecType<T, P> const & x)
{
vecType<T, P> const Angle0_PI(fastAbs(fmod(x + glm::pi<T>(), glm::two_pi<T>()) - glm::pi<T>()));
return taylorSeriesNewCos6(x);
/*
vecType<bool, P> const FirstQuarterPi(lessThanEqual(Angle0_PI, vecType<T, P>(glm::half_pi<T>())));
vecType<T, P> const RevertAngle(mix(vecType<T, P>(glm::pi<T>()), vecType<T, P>(0), FirstQuarterPi));
vecType<T, P> const ReturnSign(mix(vecType<T, P>(-1), vecType<T, P>(1), FirstQuarterPi));
vecType<T, P> const SectionAngle(RevertAngle - Angle0_PI);
return ReturnSign * taylorSeriesNewCos(SectionAngle);
*/
}
int perf_fastCosNew(float Begin, float End, std::size_t Samples)
{
std::vector<glm::vec4> Results;
Results.resize(Samples);
float Steps = (End - Begin) / Samples;
std::clock_t const TimeStampBegin = std::clock();
for(std::size_t i = 0; i < Samples; ++i)
Results[i] = taylorCos::fastCosNew(AngleShift + glm::vec4(Begin + Steps * i));
std::clock_t const TimeStampEnd = std::clock();
std::printf("fastCosNew %ld clocks\n", TimeStampEnd - TimeStampBegin);
int Error = 0;
for(std::size_t i = 0; i < Samples; ++i)
Error += Results[i].x >= -1.0f && Results[i].x <= 1.0f ? 0 : 1;
return Error;
}
template <typename T, glm::precision P, template <typename, glm::precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> deterministic_fmod(vecType<T, P> const & x, T y)
{
return x - y * trunc(x / y);
}
template <typename T, glm::precision P, template <typename, glm::precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> fastCosDeterminisctic(vecType<T, P> const & x)
{
vecType<T, P> const Angle0_PI(abs(deterministic_fmod(x + glm::pi<T>(), glm::two_pi<T>()) - glm::pi<T>()));
vecType<bool, P> const FirstQuarterPi(lessThanEqual(Angle0_PI, vecType<T, P>(glm::half_pi<T>())));
vecType<T, P> const RevertAngle(mix(vecType<T, P>(glm::pi<T>()), vecType<T, P>(0), FirstQuarterPi));
vecType<T, P> const ReturnSign(mix(vecType<T, P>(-1), vecType<T, P>(1), FirstQuarterPi));
vecType<T, P> const SectionAngle(RevertAngle - Angle0_PI);
return ReturnSign * taylorSeriesNewCos(SectionAngle);
}
int perf_fastCosDeterminisctic(float Begin, float End, std::size_t Samples)
{
std::vector<glm::vec4> Results;
Results.resize(Samples);
float Steps = (End - Begin) / Samples;
std::clock_t const TimeStampBegin = std::clock();
for(std::size_t i = 0; i < Samples; ++i)
Results[i] = taylorCos::fastCosDeterminisctic(AngleShift + glm::vec4(Begin + Steps * i));
std::clock_t const TimeStampEnd = std::clock();
std::printf("fastCosDeterminisctic %ld clocks\n", TimeStampEnd - TimeStampBegin);
int Error = 0;
for(std::size_t i = 0; i < Samples; ++i)
Error += Results[i].x >= -1.0f && Results[i].x <= 1.0f ? 0 : 1;
return Error;
}
template <typename T, glm::precision P, template <typename, glm::precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> taylorSeriesRefCos(vecType<T, P> const & x)
{
return static_cast<T>(1)
- (x * x) / glm::factorial(static_cast<T>(2))
+ (x * x * x * x) / glm::factorial(static_cast<T>(4))
- (x * x * x * x * x * x) / glm::factorial(static_cast<T>(6))
+ (x * x * x * x * x * x * x * x) / glm::factorial(static_cast<T>(8));
}
template <typename T, glm::precision P, template <typename, glm::precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> fastRefCos(vecType<T, P> const & x)
{
vecType<T, P> const Angle0_PI(glm::abs(fmod(x + glm::pi<T>(), glm::two_pi<T>()) - glm::pi<T>()));
// return taylorSeriesRefCos(Angle0_PI);
vecType<bool, P> const FirstQuarterPi(lessThanEqual(Angle0_PI, vecType<T, P>(glm::half_pi<T>())));
vecType<T, P> const RevertAngle(mix(vecType<T, P>(glm::pi<T>()), vecType<T, P>(0), FirstQuarterPi));
vecType<T, P> const ReturnSign(mix(vecType<T, P>(-1), vecType<T, P>(1), FirstQuarterPi));
vecType<T, P> const SectionAngle(RevertAngle - Angle0_PI);
return ReturnSign * taylorSeriesRefCos(SectionAngle);
}
int perf_fastCosRef(float Begin, float End, std::size_t Samples)
{
std::vector<glm::vec4> Results;
Results.resize(Samples);
float Steps = (End - Begin) / Samples;
std::clock_t const TimeStampBegin = std::clock();
for(std::size_t i = 0; i < Samples; ++i)
Results[i] = taylorCos::fastRefCos(AngleShift + glm::vec4(Begin + Steps * i));
std::clock_t const TimeStampEnd = std::clock();
std::printf("fastCosRef %ld clocks\n", TimeStampEnd - TimeStampBegin);
int Error = 0;
for(std::size_t i = 0; i < Samples; ++i)
Error += Results[i].x >= -1.0f && Results[i].x <= 1.0f ? 0 : 1;
return Error;
}
int perf_fastCosOld(float Begin, float End, std::size_t Samples)
{
std::vector<glm::vec4> Results;
Results.resize(Samples);
float Steps = (End - Begin) / Samples;
std::clock_t const TimeStampBegin = std::clock();
for(std::size_t i = 0; i < Samples; ++i)
Results[i] = glm::fastCos(AngleShift + glm::vec4(Begin + Steps * i));
std::clock_t const TimeStampEnd = std::clock();
std::printf("fastCosOld %ld clocks\n", TimeStampEnd - TimeStampBegin);
int Error = 0;
for(std::size_t i = 0; i < Samples; ++i)
Error += Results[i].x >= -1.0f && Results[i].x <= 1.0f ? 0 : 1;
return Error;
}
int perf_cos(float Begin, float End, std::size_t Samples)
{
std::vector<glm::vec4> Results;
Results.resize(Samples);
float Steps = (End - Begin) / Samples;
std::clock_t const TimeStampBegin = std::clock();
for(std::size_t i = 0; i < Samples; ++i)
Results[i] = glm::cos(AngleShift + glm::vec4(Begin + Steps * i));
std::clock_t const TimeStampEnd = std::clock();
std::printf("cos %ld clocks\n", TimeStampEnd - TimeStampBegin);
int Error = 0;
for(std::size_t i = 0; i < Samples; ++i)
Error += Results[i].x >= -1.0f && Results[i].x <= 1.0f ? 0 : 1;
return Error;
}
int perf()
{
int Error = 0;
float const Begin = -glm::pi<float>();
float const End = glm::pi<float>();
std::size_t const Samples = 10000000;
Error += perf_cos(Begin, End, Samples);
Error += perf_fastCosOld(Begin, End, Samples);
Error += perf_fastCosRef(Begin, End, Samples);
//Error += perf_fastCosNew(Begin, End, Samples);
Error += perf_fastCosDeterminisctic(Begin, End, Samples);
return Error;
}
int test()
{
int Error = 0;
//for(float Angle = -4.0f * glm::pi<float>(); Angle < 4.0f * glm::pi<float>(); Angle += 0.1f)
//for(float Angle = -720.0f; Angle < 720.0f; Angle += 0.1f)
for(float Angle = 0.0f; Angle < 180.0f; Angle += 0.1f)
{
float const modAngle = std::fmod(glm::abs(Angle), 360.f);
assert(modAngle >= 0.0f && modAngle <= 360.f);
float const radAngle = glm::radians(modAngle);
float const Cos0 = std::cos(radAngle);
float const Cos1 = taylorCos::fastRefCos(glm::fvec1(radAngle)).x;
Error += glm::abs(Cos1 - Cos0) < 0.1f ? 0 : 1;
float const Cos2 = taylorCos::fastCosNew(glm::fvec1(radAngle)).x;
//Error += glm::abs(Cos2 - Cos0) < 0.1f ? 0 : 1;
assert(!Error);
}
return Error;
}
}//namespace taylorCos
int main()
{
int Error(0);
Error += ::taylorCos::test();
Error += ::taylorCos::perf();
# ifdef NDEBUG
Error += ::fastCos::perf();
Error += ::fastSin::perf();

172
test/gtx/gtx_wrap.cpp Normal file
View File

@ -0,0 +1,172 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 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.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// 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.
///
/// @file test/gtx/gtx_normal.cpp
/// @date 2013-10-25 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtx/wrap.hpp>
#include <glm/gtc/epsilon.hpp>
namespace clamp
{
int test()
{
int Error(0);
float A = glm::clamp(0.5f);
Error += glm::epsilonEqual(A, 0.5f, 0.00001f) ? 0 : 1;
float B = glm::clamp(0.0f);
Error += glm::epsilonEqual(B, 0.0f, 0.00001f) ? 0 : 1;
float C = glm::clamp(1.0f);
Error += glm::epsilonEqual(C, 1.0f, 0.00001f) ? 0 : 1;
float D = glm::clamp(-0.5f);
Error += glm::epsilonEqual(D, 0.0f, 0.00001f) ? 0 : 1;
float E = glm::clamp(1.5f);
Error += glm::epsilonEqual(E, 1.0f, 0.00001f) ? 0 : 1;
return Error;
}
}//namespace clamp
namespace repeat
{
int test()
{
int Error(0);
float A = glm::repeat(0.5f);
Error += glm::epsilonEqual(A, 0.5f, 0.00001f) ? 0 : 1;
float B = glm::repeat(0.0f);
Error += glm::epsilonEqual(B, 0.0f, 0.00001f) ? 0 : 1;
float C = glm::repeat(1.0f);
Error += glm::epsilonEqual(C, 0.0f, 0.00001f) ? 0 : 1;
float D = glm::repeat(-0.5f);
Error += glm::epsilonEqual(D, 0.5f, 0.00001f) ? 0 : 1;
float E = glm::repeat(1.5f);
Error += glm::epsilonEqual(E, 0.5f, 0.00001f) ? 0 : 1;
float F = glm::repeat(0.9f);
Error += glm::epsilonEqual(F, 0.9f, 0.00001f) ? 0 : 1;
return Error;
}
}//namespace repeat
namespace mirrorClamp
{
int test()
{
int Error(0);
float A = glm::mirrorClamp(0.5f);
Error += glm::epsilonEqual(A, 0.5f, 0.00001f) ? 0 : 1;
float B = glm::mirrorClamp(0.0f);
Error += glm::epsilonEqual(B, 0.0f, 0.00001f) ? 0 : 1;
float C = glm::mirrorClamp(1.1f);
Error += glm::epsilonEqual(C, 0.1f, 0.00001f) ? 0 : 1;
float D = glm::mirrorClamp(-0.5f);
Error += glm::epsilonEqual(D, 0.5f, 0.00001f) ? 0 : 1;
float E = glm::mirrorClamp(1.5f);
Error += glm::epsilonEqual(E, 0.5f, 0.00001f) ? 0 : 1;
float F = glm::mirrorClamp(0.9f);
Error += glm::epsilonEqual(F, 0.9f, 0.00001f) ? 0 : 1;
float G = glm::mirrorClamp(3.1f);
Error += glm::epsilonEqual(G, 0.1f, 0.00001f) ? 0 : 1;
float H = glm::mirrorClamp(-3.1f);
Error += glm::epsilonEqual(H, 0.1f, 0.00001f) ? 0 : 1;
float I = glm::mirrorClamp(-0.9f);
Error += glm::epsilonEqual(I, 0.9f, 0.00001f) ? 0 : 1;
return Error;
}
}//namespace mirrorClamp
namespace mirrorRepeat
{
int test()
{
int Error(0);
float A = glm::mirrorRepeat(0.5f);
Error += glm::epsilonEqual(A, 0.5f, 0.00001f) ? 0 : 1;
float B = glm::mirrorRepeat(0.0f);
Error += glm::epsilonEqual(B, 0.0f, 0.00001f) ? 0 : 1;
float C = glm::mirrorRepeat(1.0f);
Error += glm::epsilonEqual(C, 1.0f, 0.00001f) ? 0 : 1;
float D = glm::mirrorRepeat(-0.5f);
Error += glm::epsilonEqual(D, 0.5f, 0.00001f) ? 0 : 1;
float E = glm::mirrorRepeat(1.5f);
Error += glm::epsilonEqual(E, 0.5f, 0.00001f) ? 0 : 1;
float F = glm::mirrorRepeat(0.9f);
Error += glm::epsilonEqual(F, 0.9f, 0.00001f) ? 0 : 1;
float G = glm::mirrorRepeat(3.0f);
Error += glm::epsilonEqual(G, 1.0f, 0.00001f) ? 0 : 1;
float H = glm::mirrorRepeat(-3.0f);
Error += glm::epsilonEqual(H, 1.0f, 0.00001f) ? 0 : 1;
float I = glm::mirrorRepeat(-1.0f);
Error += glm::epsilonEqual(I, 1.0f, 0.00001f) ? 0 : 1;
return Error;
}
}//namespace mirrorRepeat
int main()
{
int Error(0);
Error += clamp::test();
Error += repeat::test();
Error += mirrorClamp::test();
Error += mirrorRepeat::test();
return Error;
}

View File

@ -1,3 +0,0 @@
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/FindGLM.cmake
DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}/cmake)

View File

@ -1,65 +0,0 @@
# FindGLM - attempts to locate the glm matrix/vector library.
#
# This module defines the following variables (on success):
# GLM_INCLUDE_DIRS - where to find glm/glm.hpp
# GLM_FOUND - if the library was successfully located
#
# It is trying a few standard installation locations, but can be customized
# with the following variables:
# GLM_ROOT_DIR - root directory of a glm installation
# Headers are expected to be found in either:
# <GLM_ROOT_DIR>/glm/glm.hpp OR
# <GLM_ROOT_DIR>/include/glm/glm.hpp
# This variable can either be a cmake or environment
# variable. Note however that changing the value
# of the environment varible will NOT result in
# re-running the header search and therefore NOT
# adjust the variables set by this module.
#=============================================================================
# Copyright 2012 Carsten Neumann
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
# default search dirs
SET(_glm_HEADER_SEARCH_DIRS
"/usr/include"
"/usr/local/include")
# check environment variable
SET(_glm_ENV_ROOT_DIR "$ENV{GLM_ROOT_DIR}")
IF(NOT GLM_ROOT_DIR AND _glm_ENV_ROOT_DIR)
SET(GLM_ROOT_DIR "${_glm_ENV_ROOT_DIR}")
ENDIF(NOT GLM_ROOT_DIR AND _glm_ENV_ROOT_DIR)
# put user specified location at beginning of search
IF(GLM_ROOT_DIR)
SET(_glm_HEADER_SEARCH_DIRS "${GLM_ROOT_DIR}"
"${GLM_ROOT_DIR}/include"
${_glm_HEADER_SEARCH_DIRS})
ENDIF(GLM_ROOT_DIR)
# locate header
FIND_PATH(GLM_INCLUDE_DIR "glm/glm.hpp"
PATHS ${_glm_HEADER_SEARCH_DIRS})
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLM DEFAULT_MSG
GLM_INCLUDE_DIR)
IF(GLM_FOUND)
SET(GLM_INCLUDE_DIRS "${GLM_INCLUDE_DIR}")
IF(NOT GLM_FIND_QUIETLY)
MESSAGE(STATUS "GLM_INCLUDE_DIR = ${GLM_INCLUDE_DIR}")
ENDIF(NOT GLM_FIND_QUIETLY)
ENDIF(GLM_FOUND)