diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..b726899f --- /dev/null +++ b/.gitignore @@ -0,0 +1,47 @@ +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +# CMake +CMakeCache.txt +CMakeFiles +Makefile +cmake_install.cmake +install_manifest.txt +*.cmake +# ^ May need to add future .cmake files as exceptions + +# Test logs +Testing/* + +# Test input +test/gtc/*.dds + +# Project Files +*.cbp +*.user diff --git a/CMakeLists.txt b/CMakeLists.txt index 5925d5fe..962fa640 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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(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) diff --git a/cmake/CMakePackageConfigHelpers.cmake b/cmake/CMakePackageConfigHelpers.cmake new file mode 100644 index 00000000..48039e52 --- /dev/null +++ b/cmake/CMakePackageConfigHelpers.cmake @@ -0,0 +1,227 @@ +# - CONFIGURE_PACKAGE_CONFIG_FILE(), WRITE_BASIC_PACKAGE_VERSION_FILE() +# +# CONFIGURE_PACKAGE_CONFIG_FILE( INSTALL_DESTINATION +# [PATH_VARS ... ] +# [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 Config.cmake or -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 and arguments are the input and output file, the same way +# as in CONFIGURE_FILE(). +# +# The 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 to given as PATH_VARS are the variables which contain +# install destinations. For each of them the macro will create a helper variable +# PACKAGE_. 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() 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__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 ConfigVersion.cmake file to . +# 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 +# +# 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() diff --git a/cmake/glmBuildConfig.cmake.in b/cmake/glmBuildConfig.cmake.in new file mode 100644 index 00000000..bec9af30 --- /dev/null +++ b/cmake/glmBuildConfig.cmake.in @@ -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() diff --git a/cmake/glmConfig.cmake.in b/cmake/glmConfig.cmake.in new file mode 100644 index 00000000..3f8a1fe5 --- /dev/null +++ b/cmake/glmConfig.cmake.in @@ -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() diff --git a/doc/glm.docx b/doc/glm.docx index 80add995..ce05f6f8 100644 Binary files a/doc/glm.docx and b/doc/glm.docx differ diff --git a/glm/CMakeLists.txt b/glm/CMakeLists.txt index aaeae626..8f2f552e 100644 --- a/glm/CMakeLists.txt +++ b/glm/CMakeLists.txt @@ -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} diff --git a/glm/detail/func_integer.inl b/glm/detail/func_integer.inl index 31eddf9b..20e29d6f 100644 --- a/glm/detail/func_integer.inl +++ b/glm/detail/func_integer.inl @@ -248,10 +248,8 @@ namespace detail GLM_STATIC_ASSERT(sizeof(uint) == sizeof(uint32), "uint and uint32 size mismatch"); uint64 Value64 = static_cast(x) * static_cast(y); - uint32* PointerMSB = (reinterpret_cast(&Value64) + 1); - msb = *PointerMSB; - uint32* PointerLSB = (reinterpret_cast(&Value64) + 0); - lsb = *PointerLSB; + msb = static_cast(Value64 >> static_cast(32)); + lsb = static_cast(Value64); } template class vecType> @@ -270,10 +268,8 @@ namespace detail GLM_STATIC_ASSERT(sizeof(int) == sizeof(int32), "int and int32 size mismatch"); int64 Value64 = static_cast(x) * static_cast(y); - int32* PointerMSB = (reinterpret_cast(&Value64) + 1); - msb = *PointerMSB; - int32* PointerLSB = (reinterpret_cast(&Value64)); - lsb = *PointerLSB; + msb = static_cast(Value64 >> static_cast(32)); + lsb = static_cast(Value64); } template class vecType> diff --git a/glm/detail/func_packing.inl b/glm/detail/func_packing.inl index 3132a279..34953fdf 100644 --- a/glm/detail/func_packing.inl +++ b/glm/detail/func_packing.inl @@ -38,82 +38,178 @@ namespace glm { GLM_FUNC_QUALIFIER uint packUnorm2x16(vec2 const & v) { - u16vec2 const Topack(round(clamp(v, 0.0f, 1.0f) * 65535.0f)); - return reinterpret_cast(Topack); + union + { + u16 in[2]; + uint out; + } u; + + u16vec2 result(round(clamp(v, 0.0f, 1.0f) * 65535.0f)); + + u.in[0] = result[0]; + u.in[1] = result[1]; + + return u.out; } GLM_FUNC_QUALIFIER vec2 unpackUnorm2x16(uint p) { - vec2 Unpack(reinterpret_cast(p)); - return Unpack * float(1.5259021896696421759365224689097e-5); // 1.0 / 65535.0 + union + { + uint in; + u16 out[2]; + } u; + + u.in = p; + + return vec2(u.out[0], u.out[1]) * 1.5259021896696421759365224689097e-5f; } GLM_FUNC_QUALIFIER uint packSnorm2x16(vec2 const & v) { - i16vec2 const Topack(round(clamp(v ,-1.0f, 1.0f) * 32767.0f)); - return reinterpret_cast(Topack); + union + { + i16 in[2]; + uint out; + } u; + + i16vec2 result(round(clamp(v, -1.0f, 1.0f) * 32767.0f)); + + u.in[0] = result[0]; + u.in[1] = result[1]; + + return u.out; } GLM_FUNC_QUALIFIER vec2 unpackSnorm2x16(uint p) { - vec2 const Unpack(reinterpret_cast(p)); - return clamp( - Unpack * 3.0518509475997192297128208258309e-5f, //1.0f / 32767.0f, - -1.0f, 1.0f); + union + { + uint in; + i16 out[2]; + } u; + + u.in = p; + + return clamp(vec2(u.out[0], u.out[1]) * 3.0518509475997192297128208258309e-5f, -1.0f, 1.0f); } GLM_FUNC_QUALIFIER uint packUnorm4x8(vec4 const & v) { - u8vec4 const Topack(round(clamp(v, 0.0f, 1.0f) * 255.0f)); - return reinterpret_cast(Topack); + union + { + u8 in[4]; + uint out; + } u; + + u8vec4 result(round(clamp(v, 0.0f, 1.0f) * 255.0f)); + + u.in[0] = result[0]; + u.in[1] = result[1]; + u.in[2] = result[2]; + u.in[3] = result[3]; + + return u.out; } GLM_FUNC_QUALIFIER vec4 unpackUnorm4x8(uint p) { - vec4 const Unpack(reinterpret_cast(p)); - return Unpack * float(0.0039215686274509803921568627451); // 1 / 255 + union + { + uint in; + u8 out[4]; + } u; + + u.in = p; + + return vec4(u.out[0], u.out[1], u.out[2], u.out[3]) * 0.0039215686274509803921568627451f; } GLM_FUNC_QUALIFIER uint packSnorm4x8(vec4 const & v) { - i8vec4 const Topack(round(clamp(v ,-1.0f, 1.0f) * 127.0f)); - return reinterpret_cast(Topack); + union + { + i8 in[4]; + uint out; + } u; + + i8vec4 result(round(clamp(v, -1.0f, 1.0f) * 127.0f)); + + u.in[0] = result[0]; + u.in[1] = result[1]; + u.in[2] = result[2]; + u.in[3] = result[3]; + + return u.out; } GLM_FUNC_QUALIFIER glm::vec4 unpackSnorm4x8(uint p) { - vec4 const Unpack(reinterpret_cast(p)); - return clamp( - Unpack * 0.0078740157480315f, // 1.0f / 127.0f - -1.0f, 1.0f); + union + { + uint in; + i8 out[4]; + } u; + + u.in = p; + + return clamp(vec4(u.out[0], u.out[1], u.out[2], u.out[3]) * 0.0078740157480315f, -1.0f, 1.0f); } GLM_FUNC_QUALIFIER double packDouble2x32(uvec2 const & v) { - return reinterpret_cast(v); + union + { + uint in[2]; + double out; + } u; + + u.in[0] = v[0]; + u.in[1] = v[1]; + + return u.out; } GLM_FUNC_QUALIFIER uvec2 unpackDouble2x32(double v) { - return reinterpret_cast(v); + union + { + double in; + uint out[2]; + } u; + + u.in = v; + + return uvec2(u.out[0], u.out[1]); } GLM_FUNC_QUALIFIER uint packHalf2x16(vec2 const & v) { - i16vec2 const Unpack( - detail::toFloat16(v.x), - detail::toFloat16(v.y)); + union + { + i16 in[2]; + uint out; + } u; - return reinterpret_cast(Unpack); + u.in[0] = detail::toFloat16(v.x); + u.in[1] = detail::toFloat16(v.y); + + return u.out; } GLM_FUNC_QUALIFIER vec2 unpackHalf2x16(uint v) { - i16vec2 const Unpack(reinterpret_cast(v)); - + union + { + uint in; + i16 out[2]; + } u; + + u.in = v; + return vec2( - detail::toFloat32(Unpack.x), - detail::toFloat32(Unpack.y)); + detail::toFloat32(u.out[0]), + detail::toFloat32(u.out[1])); } }//namespace glm diff --git a/glm/detail/setup.hpp b/glm/detail/setup.hpp index 1defed89..efac4987 100644 --- a/glm/detail/setup.hpp +++ b/glm/detail/setup.hpp @@ -8,14 +8,14 @@ /// 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 @@ -117,7 +117,7 @@ // Compiler // User defines: GLM_FORCE_COMPILER_UNKNOWN -// TODO ? __llvm__ +// TODO ? __llvm__ #define GLM_COMPILER_UNKNOWN 0x00000000 @@ -128,6 +128,7 @@ #define GLM_COMPILER_INTEL13 0x00100030 #define GLM_COMPILER_INTEL14 0x00100040 #define GLM_COMPILER_INTEL15 0x00100050 +#define GLM_COMPILER_INTEL16 0x00100060 // Visual C++ defines #define GLM_COMPILER_VC 0x01000000 @@ -145,6 +146,9 @@ #define GLM_COMPILER_GCC48 0x020000F0 #define GLM_COMPILER_GCC49 0x02000100 #define GLM_COMPILER_GCC50 0x02000200 +#define GLM_COMPILER_GCC51 0x02000300 +#define GLM_COMPILER_GCC52 0x02000400 +#define GLM_COMPILER_GCC53 0x02000500 // CUDA #define GLM_COMPILER_CUDA 0x10000000 @@ -154,6 +158,8 @@ #define GLM_COMPILER_CUDA50 0x10000070 #define GLM_COMPILER_CUDA60 0x10000080 #define GLM_COMPILER_CUDA65 0x10000090 +#define GLM_COMPILER_CUDA70 0x100000A0 +#define GLM_COMPILER_CUDA75 0x100000B0 // LLVM #define GLM_COMPILER_LLVM 0x20000000 @@ -161,6 +167,10 @@ #define GLM_COMPILER_LLVM33 0x20000040 #define GLM_COMPILER_LLVM34 0x20000050 #define GLM_COMPILER_LLVM35 0x20000060 +#define GLM_COMPILER_LLVM36 0x20000070 +#define GLM_COMPILER_LLVM37 0x20000080 +#define GLM_COMPILER_LLVM38 0x20000090 +#define GLM_COMPILER_LLVM39 0x200000A0 // Apple Clang #define GLM_COMPILER_APPLE_CLANG 0x40000000 @@ -170,6 +180,7 @@ #define GLM_COMPILER_APPLE_CLANG50 0x40000040 #define GLM_COMPILER_APPLE_CLANG51 0x40000050 #define GLM_COMPILER_APPLE_CLANG60 0x40000060 +#define GLM_COMPILER_APPLE_CLANG61 0x40000070 // Build model #define GLM_MODEL_32 0x00000010 @@ -190,6 +201,8 @@ # define GLM_COMPILER GLM_COMPILER_INTEL14 # elif __INTEL_COMPILER >= 1500 # define GLM_COMPILER GLM_COMPILER_INTEL15 +# elif __INTEL_COMPILER >= 1600 +# define GLM_COMPILER GLM_COMPILER_INTEL16 # else # define GLM_COMPILER GLM_COMPILER_INTEL # endif @@ -197,7 +210,7 @@ // CUDA #elif defined(__CUDACC__) # if !defined(CUDA_VERSION) && !defined(GLM_FORCE_CUDA) -# include // make sure version is defined since nvcc does not define it itself! +# include // make sure version is defined since nvcc does not define it itself! # endif # if CUDA_VERSION < 3000 # error "GLM requires CUDA 3.0 or higher" @@ -234,8 +247,14 @@ # define GLM_COMPILER GLM_COMPILER_APPLE_CLANG50 # elif __clang_major__ == 5 && __clang_minor__ == 1 # define GLM_COMPILER GLM_COMPILER_APPLE_CLANG51 -# elif __clang_major__ >= 6 +# elif __clang_major__ == 6 && __clang_minor__ == 0 # define GLM_COMPILER GLM_COMPILER_APPLE_CLANG60 +# elif __clang_major__ == 6 && __clang_minor__ >= 1 +# define GLM_COMPILER GLM_COMPILER_APPLE_CLANG61 +# elif __clang_major__ >= 7 +# define GLM_COMPILER GLM_COMPILER_APPLE_CLANG61 +# else +# define GLM_COMPILER GLM_COMPILER_APPLE_CLANG # endif # else # if __clang_major__ == 3 && __clang_minor__ == 0 @@ -250,12 +269,22 @@ # define GLM_COMPILER GLM_COMPILER_LLVM34 # elif __clang_major__ == 3 && __clang_minor__ == 5 # define GLM_COMPILER GLM_COMPILER_LLVM35 +# elif __clang_major__ == 3 && __clang_minor__ == 6 +# define GLM_COMPILER GLM_COMPILER_LLVM36 +# elif __clang_major__ == 3 && __clang_minor__ == 7 +# define GLM_COMPILER GLM_COMPILER_LLVM37 +# elif __clang_major__ == 3 && __clang_minor__ == 8 +# define GLM_COMPILER GLM_COMPILER_LLVM38 +# elif __clang_major__ == 3 && __clang_minor__ >= 9 +# define GLM_COMPILER GLM_COMPILER_LLVM39 +# elif __clang_major__ >= 4 +# define GLM_COMPILER GLM_COMPILER_LLVM39 # else -# define GLM_COMPILER GLM_COMPILER_LLVM35 +# define GLM_COMPILER GLM_COMPILER_LLVM # endif # endif -// G++ +// G++ #elif defined(__GNUC__) || defined(__MINGW32__) # if (__GNUC__ == 4) && (__GNUC_MINOR__ == 2) # define GLM_COMPILER (GLM_COMPILER_GCC42) @@ -273,8 +302,14 @@ # define GLM_COMPILER (GLM_COMPILER_GCC48) # elif (__GNUC__ == 4) && (__GNUC_MINOR__ >= 9) # define GLM_COMPILER (GLM_COMPILER_GCC49) -# elif (__GNUC__ > 4 ) +# elif (__GNUC__ == 5) && (__GNUC_MINOR__ == 0) # define GLM_COMPILER (GLM_COMPILER_GCC50) +# elif (__GNUC__ == 5) && (__GNUC_MINOR__ == 1) +# define GLM_COMPILER (GLM_COMPILER_GCC51) +# elif (__GNUC__ == 5) && (__GNUC_MINOR__ == 2) +# define GLM_COMPILER (GLM_COMPILER_GCC52) +# elif (__GNUC__ == 5) && (__GNUC_MINOR__ >= 3) +# define GLM_COMPILER (GLM_COMPILER_GCC53) # else # define GLM_COMPILER (GLM_COMPILER_GCC) # endif @@ -502,12 +537,22 @@ #if GLM_PLATFORM == GLM_PLATFORM_ANDROID # define GLM_HAS_CXX11_STL 0 -#elif GLM_COMPILER & (GLM_COMPILER_LLVM | GLM_COMPILER_APPLE_CLANG | GLM_COMPILER_INTEL) -# define GLM_HAS_CXX11_STL __has_include("__config") +#elif GLM_COMPILER & (GLM_COMPILER_LLVM | GLM_COMPILER_APPLE_CLANG) +# if __has_include(<__config>) // libc++ +# include <__config> +//# else // libstdc++ +//# include +# endif +# if defined(_LIBCPP_VERSION)// || defined(__GLIBCXX__) +# define GLM_HAS_CXX11_STL 1 +# else +# define GLM_HAS_CXX11_STL 0 +# endif #else # define GLM_HAS_CXX11_STL ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && \ ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC48)) || \ - ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2013))) + ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2013)) || \ + ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_COMPILER >= GLM_COMPILER_INTEL15))) #endif // N1720 @@ -624,7 +669,7 @@ ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2012))) #endif -// +// #if GLM_LANG & GLM_LANG_CXX11_FLAG # define GLM_HAS_ASSIGNABLE 1 #else @@ -632,11 +677,10 @@ ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC49))) #endif -// -#define GLM_HAS_TRIVIAL_QUERIES 0//( \ - //((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2013))) +// +#define GLM_HAS_TRIVIAL_QUERIES 0 -// +// #if GLM_LANG & GLM_LANG_CXX11_FLAG # define GLM_HAS_MAKE_SIGNED 1 #else @@ -644,7 +688,7 @@ ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2013))) #endif -// +// #if GLM_ARCH == GLM_ARCH_PURE # define GLM_HAS_BITSCAN_WINDOWS 0 #else @@ -653,7 +697,7 @@ #endif // OpenMP -#ifdef _OPENMP +#ifdef _OPENMP # if GLM_COMPILER & GLM_COMPILER_GCC # if GLM_COMPILER >= GLM_COMPILER_GCC47 # define GLM_HAS_OPENMP 31 @@ -675,7 +719,7 @@ #define GLM_HAS_ANONYMOUS_UNION (GLM_LANG & GLM_LANG_CXXMS_FLAG) /////////////////////////////////////////////////////////////////////////////////// -// Platform +// Platform // User defines: GLM_FORCE_PURE GLM_FORCE_SSE2 GLM_FORCE_SSE3 GLM_FORCE_AVX GLM_FORCE_AVX2 @@ -725,7 +769,7 @@ # define GLM_ARCH (GLM_ARCH_PURE) # endif #elif (GLM_COMPILER & GLM_COMPILER_GCC) && (defined(__i386__) || defined(__x86_64__)) -# if defined(__AVX2__) +# if defined(__AVX2__) # define GLM_ARCH (GLM_ARCH_AVX2 | GLM_ARCH_AVX | GLM_ARCH_SSE4 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2) # elif defined(__AVX__) # define GLM_ARCH (GLM_ARCH_AVX | GLM_ARCH_SSE4 | GLM_ARCH_SSE3 | GLM_ARCH_SSE2) @@ -881,8 +925,16 @@ #if GLM_HAS_CONSTEXPR # define GLM_CONSTEXPR constexpr +# define GLM_RELAXED_CONSTEXPR constexpr #else # define GLM_CONSTEXPR +# define GLM_RELAXED_CONSTEXPR const +#endif + +#ifdef GLM_FORCE_EXPLICIT_CTOR +# define GLM_EXPLICIT explicit +#else +# define GLM_EXPLICIT #endif /////////////////////////////////////////////////////////////////////////////////// diff --git a/glm/detail/type_mat2x2.hpp b/glm/detail/type_mat2x2.hpp index 046ceac3..c24d929a 100644 --- a/glm/detail/type_mat2x2.hpp +++ b/glm/detail/type_mat2x2.hpp @@ -8,14 +8,14 @@ /// 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 @@ -54,11 +54,18 @@ namespace glm template friend tvec2 operator/(tvec2 const & v, tmat2x2 const & m); +# ifdef GLM_META_PROG_HELPERS + static GLM_RELAXED_CONSTEXPR length_t components = 2; + static GLM_RELAXED_CONSTEXPR length_t columns = 2; + static GLM_RELAXED_CONSTEXPR length_t rows = 2; + static GLM_RELAXED_CONSTEXPR precision prec = P; +# endif//GLM_META_PROG_HELPERS + private: /// @cond DETAIL col_type value[2]; /// @endcond - + public: ////////////////////////////////////// // Constructors @@ -91,13 +98,8 @@ namespace glm ////////////////////////////////////// // Matrix conversions -# ifdef GLM_FORCE_EXPLICIT_CTOR - template - GLM_FUNC_DECL explicit tmat2x2(tmat2x2 const & m); -# else - template - GLM_FUNC_DECL tmat2x2(tmat2x2 const & m); -# endif + template + GLM_FUNC_DECL GLM_EXPLICIT tmat2x2(tmat2x2 const & m); GLM_FUNC_DECL explicit tmat2x2(tmat3x3 const & x); GLM_FUNC_DECL explicit tmat2x2(tmat4x4 const & x); @@ -130,23 +132,23 @@ namespace glm GLM_FUNC_DECL tmat2x2 & operator=(tmat2x2 const & v); - template + template GLM_FUNC_DECL tmat2x2 & operator=(tmat2x2 const & m); - template + template GLM_FUNC_DECL tmat2x2 & operator+=(U s); - template + template GLM_FUNC_DECL tmat2x2 & operator+=(tmat2x2 const & m); - template + template GLM_FUNC_DECL tmat2x2 & operator-=(U s); - template + template GLM_FUNC_DECL tmat2x2 & operator-=(tmat2x2 const & m); - template + template GLM_FUNC_DECL tmat2x2 & operator*=(U s); - template + template GLM_FUNC_DECL tmat2x2 & operator*=(tmat2x2 const & m); - template + template GLM_FUNC_DECL tmat2x2 & operator/=(U s); - template + template GLM_FUNC_DECL tmat2x2 & operator/=(tmat2x2 const & m); ////////////////////////////////////// @@ -191,10 +193,10 @@ namespace glm template GLM_FUNC_DECL tmat2x2 operator*(tmat2x2 const & m1, tmat2x2 const & m2); - + template GLM_FUNC_DECL tmat3x2 operator*(tmat2x2 const & m1, tmat3x2 const & m2); - + template GLM_FUNC_DECL tmat4x2 operator*(tmat2x2 const & m1, tmat4x2 const & m2); @@ -214,7 +216,7 @@ namespace glm GLM_FUNC_DECL tmat2x2 operator/(tmat2x2 const & m1, tmat2x2 const & m2); // Unary constant operators - template + template GLM_FUNC_DECL tmat2x2 const operator-(tmat2x2 const & m); } //namespace glm diff --git a/glm/detail/type_mat2x3.hpp b/glm/detail/type_mat2x3.hpp index 9986e881..f0e4fbdc 100644 --- a/glm/detail/type_mat2x3.hpp +++ b/glm/detail/type_mat2x3.hpp @@ -8,14 +8,14 @@ /// 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 @@ -50,11 +50,18 @@ namespace glm typedef tmat3x2 transpose_type; typedef T value_type; +# ifdef GLM_META_PROG_HELPERS + static GLM_RELAXED_CONSTEXPR length_t components = 2; + static GLM_RELAXED_CONSTEXPR length_t cols = 3; + static GLM_RELAXED_CONSTEXPR length_t rows = 2; + static GLM_RELAXED_CONSTEXPR precision prec = P; +# endif//GLM_META_PROG_HELPERS + private: - /// @cond DETAIL + /// @cond DETAIL col_type value[2]; /// @endcond - + public: // Constructors GLM_FUNC_DECL tmat2x3(); @@ -78,7 +85,7 @@ namespace glm GLM_FUNC_DECL tmat2x3( X1 const & x1, Y1 const & y1, Z1 const & z1, X2 const & x2, Y2 const & y2, Z2 const & z2); - + template GLM_FUNC_DECL tmat2x3( tvec3 const & v1, @@ -87,13 +94,8 @@ namespace glm ////////////////////////////////////// // Matrix conversion -# ifdef GLM_FORCE_EXPLICIT_CTOR - template - GLM_FUNC_DECL explicit tmat2x3(tmat2x3 const & m); -# else - template - GLM_FUNC_DECL tmat2x3(tmat2x3 const & m); -# endif + template + GLM_FUNC_DECL GLM_EXPLICIT tmat2x3(tmat2x3 const & m); GLM_FUNC_DECL explicit tmat2x3(tmat2x2 const & x); GLM_FUNC_DECL explicit tmat2x3(tmat3x3 const & x); @@ -126,19 +128,19 @@ namespace glm GLM_FUNC_DECL tmat2x3 & operator=(tmat2x3 const & m); - template + template GLM_FUNC_DECL tmat2x3 & operator=(tmat2x3 const & m); - template + template GLM_FUNC_DECL tmat2x3 & operator+=(U s); - template + template GLM_FUNC_DECL tmat2x3 & operator+=(tmat2x3 const & m); - template + template GLM_FUNC_DECL tmat2x3 & operator-=(U s); - template + template GLM_FUNC_DECL tmat2x3 & operator-=(tmat2x3 const & m); - template + template GLM_FUNC_DECL tmat2x3 & operator*=(U s); - template + template GLM_FUNC_DECL tmat2x3 & operator/=(U s); ////////////////////////////////////// @@ -181,7 +183,7 @@ namespace glm template GLM_FUNC_DECL tmat3x3 operator*(tmat2x3 const & m1, tmat3x2 const & m2); - + template GLM_FUNC_DECL tmat4x3 operator*(tmat2x3 const & m1, tmat4x2 const & m2); diff --git a/glm/detail/type_mat2x4.hpp b/glm/detail/type_mat2x4.hpp index 9239e9c9..6b0f190b 100644 --- a/glm/detail/type_mat2x4.hpp +++ b/glm/detail/type_mat2x4.hpp @@ -8,14 +8,14 @@ /// 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 @@ -50,11 +50,18 @@ namespace glm typedef tmat4x2 transpose_type; typedef T value_type; +# ifdef GLM_META_PROG_HELPERS + static GLM_RELAXED_CONSTEXPR length_t components = 2; + static GLM_RELAXED_CONSTEXPR length_t cols = 4; + static GLM_RELAXED_CONSTEXPR length_t rows = 2; + static GLM_RELAXED_CONSTEXPR precision prec = P; +# endif//GLM_META_PROG_HELPERS + private: /// @cond DETAIL col_type value[2]; /// @endcond - + public: // Constructors GLM_FUNC_DECL tmat2x4(); @@ -68,7 +75,7 @@ namespace glm T const & x0, T const & y0, T const & z0, T const & w0, T const & x1, T const & y1, T const & z1, T const & w1); GLM_FUNC_DECL tmat2x4( - col_type const & v0, + col_type const & v0, col_type const & v1); ////////////////////////////////////// @@ -88,13 +95,8 @@ namespace glm ////////////////////////////////////// // Matrix conversions -# ifdef GLM_FORCE_EXPLICIT_CTOR - template - GLM_FUNC_DECL explicit tmat2x4(tmat2x4 const & m); -# else - template - GLM_FUNC_DECL tmat2x4(tmat2x4 const & m); -# endif + template + GLM_FUNC_DECL GLM_EXPLICIT tmat2x4(tmat2x4 const & m); GLM_FUNC_DECL explicit tmat2x4(tmat2x2 const & x); GLM_FUNC_DECL explicit tmat2x4(tmat3x3 const & x); @@ -127,19 +129,19 @@ namespace glm GLM_FUNC_DECL tmat2x4 & operator=(tmat2x4 const & m); - template + template GLM_FUNC_DECL tmat2x4 & operator=(tmat2x4 const & m); - template + template GLM_FUNC_DECL tmat2x4 & operator+=(U s); - template + template GLM_FUNC_DECL tmat2x4 & operator+=(tmat2x4 const & m); - template + template GLM_FUNC_DECL tmat2x4 & operator-=(U s); - template + template GLM_FUNC_DECL tmat2x4 & operator-=(tmat2x4 const & m); - template + template GLM_FUNC_DECL tmat2x4 & operator*=(U s); - template + template GLM_FUNC_DECL tmat2x4 & operator/=(U s); ////////////////////////////////////// @@ -179,7 +181,7 @@ namespace glm template GLM_FUNC_DECL tmat4x4 operator*(tmat2x4 const & m1, tmat4x2 const & m2); - + template GLM_FUNC_DECL tmat2x4 operator*(tmat2x4 const & m1, tmat2x2 const & m2); @@ -189,7 +191,7 @@ namespace glm template GLM_FUNC_DECL tmat2x4 operator/(tmat2x4 const & m, T s); - template + template GLM_FUNC_DECL tmat2x4 operator/(T s, tmat2x4 const & m); // Unary constant operators diff --git a/glm/detail/type_mat3x2.hpp b/glm/detail/type_mat3x2.hpp index 9fd573f2..1ee94214 100644 --- a/glm/detail/type_mat3x2.hpp +++ b/glm/detail/type_mat3x2.hpp @@ -8,14 +8,14 @@ /// 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 @@ -50,11 +50,18 @@ namespace glm typedef tmat2x3 transpose_type; typedef T value_type; +# ifdef GLM_META_PROG_HELPERS + static GLM_RELAXED_CONSTEXPR length_t components = 3; + static GLM_RELAXED_CONSTEXPR length_t cols = 2; + static GLM_RELAXED_CONSTEXPR length_t rows = 3; + static GLM_RELAXED_CONSTEXPR precision prec = P; +# endif//GLM_META_PROG_HELPERS + private: /// @cond DETAIL col_type value[3]; /// @endcond - + public: // Constructors GLM_FUNC_DECL tmat3x2(); @@ -84,7 +91,7 @@ namespace glm X1 const & x1, Y1 const & y1, X2 const & x2, Y2 const & y2, X3 const & x3, Y3 const & y3); - + template GLM_FUNC_DECL tmat3x2( tvec2 const & v1, @@ -94,13 +101,8 @@ namespace glm ////////////////////////////////////// // Matrix conversions -# ifdef GLM_FORCE_EXPLICIT_CTOR - template - GLM_FUNC_DECL explicit tmat3x2(tmat3x2 const & m); -# else - template - GLM_FUNC_DECL tmat3x2(tmat3x2 const & m); -# endif + template + GLM_FUNC_DECL GLM_EXPLICIT tmat3x2(tmat3x2 const & m); GLM_FUNC_DECL explicit tmat3x2(tmat2x2 const & x); GLM_FUNC_DECL explicit tmat3x2(tmat3x3 const & x); @@ -133,19 +135,19 @@ namespace glm GLM_FUNC_DECL tmat3x2 & operator=(tmat3x2 const & m); - template + template GLM_FUNC_DECL tmat3x2 & operator=(tmat3x2 const & m); - template + template GLM_FUNC_DECL tmat3x2 & operator+=(U s); - template + template GLM_FUNC_DECL tmat3x2 & operator+=(tmat3x2 const & m); - template + template GLM_FUNC_DECL tmat3x2 & operator-=(U s); - template + template GLM_FUNC_DECL tmat3x2 & operator-=(tmat3x2 const & m); - template + template GLM_FUNC_DECL tmat3x2 & operator*=(U s); - template + template GLM_FUNC_DECL tmat3x2 & operator/=(U s); ////////////////////////////////////// @@ -184,10 +186,10 @@ namespace glm template GLM_FUNC_DECL tmat2x2 operator*(tmat3x2 const & m1, tmat2x3 const & m2); - + template GLM_FUNC_DECL tmat3x2 operator*(tmat3x2 const & m1, tmat3x3 const & m2); - + template GLM_FUNC_DECL tmat4x2 operator*(tmat3x2 const & m1, tmat4x3 const & m2); diff --git a/glm/detail/type_mat3x3.hpp b/glm/detail/type_mat3x3.hpp index dddfc535..1ad3e6a2 100644 --- a/glm/detail/type_mat3x3.hpp +++ b/glm/detail/type_mat3x3.hpp @@ -8,14 +8,14 @@ /// 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 @@ -49,6 +49,13 @@ namespace glm typedef tmat3x3 transpose_type; typedef T value_type; +# ifdef GLM_META_PROG_HELPERS + static GLM_RELAXED_CONSTEXPR length_t components = 3; + static GLM_RELAXED_CONSTEXPR length_t cols = 3; + static GLM_RELAXED_CONSTEXPR length_t rows = 3; + static GLM_RELAXED_CONSTEXPR precision prec = P; +# endif//GLM_META_PROG_HELPERS + template friend tvec3 operator/(tmat3x3 const & m, tvec3 const & v); template @@ -88,7 +95,7 @@ namespace glm X1 const & x1, Y1 const & y1, Z1 const & z1, X2 const & x2, Y2 const & y2, Z2 const & z2, X3 const & x3, Y3 const & y3, Z3 const & z3); - + template GLM_FUNC_DECL tmat3x3( tvec3 const & v1, @@ -98,13 +105,8 @@ namespace glm ////////////////////////////////////// // Matrix conversions -# ifdef GLM_FORCE_EXPLICIT_CTOR - template - GLM_FUNC_DECL explicit tmat3x3(tmat3x3 const & m); -# else - template - GLM_FUNC_DECL tmat3x3(tmat3x3 const & m); -# endif + template + GLM_FUNC_DECL GLM_EXPLICIT tmat3x3(tmat3x3 const & m); GLM_FUNC_DECL explicit tmat3x3(tmat2x2 const & x); GLM_FUNC_DECL explicit tmat3x3(tmat4x4 const & x); @@ -198,10 +200,10 @@ namespace glm template GLM_FUNC_DECL tmat3x3 operator*(tmat3x3 const & m1, tmat3x3 const & m2); - + template GLM_FUNC_DECL tmat2x3 operator*(tmat3x3 const & m1, tmat2x3 const & m2); - + template GLM_FUNC_DECL tmat4x3 operator*(tmat3x3 const & m1, tmat4x3 const & m2); diff --git a/glm/detail/type_mat3x4.hpp b/glm/detail/type_mat3x4.hpp index 7814e3fd..12a27820 100644 --- a/glm/detail/type_mat3x4.hpp +++ b/glm/detail/type_mat3x4.hpp @@ -8,14 +8,14 @@ /// 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 @@ -50,6 +50,13 @@ namespace glm typedef tmat4x3 transpose_type; typedef T value_type; +# ifdef GLM_META_PROG_HELPERS + static GLM_RELAXED_CONSTEXPR length_t components = 3; + static GLM_RELAXED_CONSTEXPR length_t cols = 4; + static GLM_RELAXED_CONSTEXPR length_t rows = 3; + static GLM_RELAXED_CONSTEXPR precision prec = P; +# endif//GLM_META_PROG_HELPERS + private: /// @cond DETAIL col_type value[3]; @@ -83,7 +90,7 @@ namespace glm X1 const & x1, Y1 const & y1, Z1 const & z1, W1 const & w1, X2 const & x2, Y2 const & y2, Z2 const & z2, W2 const & w2, X3 const & x3, Y3 const & y3, Z3 const & z3, W3 const & w3); - + template GLM_FUNC_DECL tmat3x4( tvec4 const & v1, @@ -93,13 +100,8 @@ namespace glm ////////////////////////////////////// // Matrix conversion -# ifdef GLM_FORCE_EXPLICIT_CTOR - template - GLM_FUNC_DECL explicit tmat3x4(tmat3x4 const & m); -# else - template - GLM_FUNC_DECL tmat3x4(tmat3x4 const & m); -# endif + template + GLM_FUNC_DECL GLM_EXPLICIT tmat3x4(tmat3x4 const & m); GLM_FUNC_DECL explicit tmat3x4(tmat2x2 const & x); GLM_FUNC_DECL explicit tmat3x4(tmat3x3 const & x); @@ -132,19 +134,19 @@ namespace glm GLM_FUNC_DECL tmat3x4 & operator=(tmat3x4 const & m); - template + template GLM_FUNC_DECL tmat3x4 & operator=(tmat3x4 const & m); - template + template GLM_FUNC_DECL tmat3x4 & operator+=(U s); - template + template GLM_FUNC_DECL tmat3x4 & operator+=(tmat3x4 const & m); - template + template GLM_FUNC_DECL tmat3x4 & operator-=(U s); - template + template GLM_FUNC_DECL tmat3x4 & operator-=(tmat3x4 const & m); - template + template GLM_FUNC_DECL tmat3x4 & operator*=(U s); - template + template GLM_FUNC_DECL tmat3x4 & operator/=(U s); ////////////////////////////////////// @@ -178,15 +180,15 @@ namespace glm template GLM_FUNC_DECL typename tmat3x4::col_type operator*(tmat3x4 const & m, typename tmat3x4::row_type const & v); - template + template GLM_FUNC_DECL typename tmat3x4::row_type operator*(typename tmat3x4::col_type const & v, tmat3x4 const & m); template GLM_FUNC_DECL tmat4x4 operator*(tmat3x4 const & m1, tmat4x3 const & m2); - + template GLM_FUNC_DECL tmat2x4 operator*(tmat3x4 const & m1, tmat2x3 const & m2); - + template GLM_FUNC_DECL tmat3x4 operator*(tmat3x4 const & m1, tmat3x3 const & m2); diff --git a/glm/detail/type_mat4x2.hpp b/glm/detail/type_mat4x2.hpp index d529ecbd..99a1dd74 100644 --- a/glm/detail/type_mat4x2.hpp +++ b/glm/detail/type_mat4x2.hpp @@ -8,14 +8,14 @@ /// 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 @@ -50,6 +50,13 @@ namespace glm typedef tmat2x4 transpose_type; typedef T value_type; +# ifdef GLM_META_PROG_HELPERS + static GLM_RELAXED_CONSTEXPR length_t components = 4; + static GLM_RELAXED_CONSTEXPR length_t cols = 2; + static GLM_RELAXED_CONSTEXPR length_t rows = 4; + static GLM_RELAXED_CONSTEXPR precision prec = P; +# endif//GLM_META_PROG_HELPERS + private: /// @cond DETAIL col_type value[4]; @@ -70,7 +77,7 @@ namespace glm T const & x2, T const & y2, T const & x3, T const & y3); GLM_FUNC_DECL tmat4x2( - col_type const & v0, + col_type const & v0, col_type const & v1, col_type const & v2, col_type const & v3); @@ -99,13 +106,8 @@ namespace glm ////////////////////////////////////// // Matrix conversions -# ifdef GLM_FORCE_EXPLICIT_CTOR - template - GLM_FUNC_DECL explicit tmat4x2(tmat4x2 const & m); -# else - template - GLM_FUNC_DECL tmat4x2(tmat4x2 const & m); -# endif + template + GLM_FUNC_DECL GLM_EXPLICIT tmat4x2(tmat4x2 const & m); GLM_FUNC_DECL explicit tmat4x2(tmat2x2 const & x); GLM_FUNC_DECL explicit tmat4x2(tmat3x3 const & x); @@ -138,19 +140,19 @@ namespace glm GLM_FUNC_DECL tmat4x2 & operator=(tmat4x2 const & m); - template + template GLM_FUNC_DECL tmat4x2 & operator=(tmat4x2 const & m); - template + template GLM_FUNC_DECL tmat4x2 & operator+=(U s); - template + template GLM_FUNC_DECL tmat4x2 & operator+=(tmat4x2 const & m); - template + template GLM_FUNC_DECL tmat4x2 & operator-=(U s); - template + template GLM_FUNC_DECL tmat4x2 & operator-=(tmat4x2 const & m); - template + template GLM_FUNC_DECL tmat4x2 & operator*=(U s); - template + template GLM_FUNC_DECL tmat4x2 & operator/=(U s); ////////////////////////////////////// @@ -189,10 +191,10 @@ namespace glm template GLM_FUNC_DECL tmat3x2 operator*(tmat4x2 const & m1, tmat3x4 const & m2); - + template GLM_FUNC_DECL tmat4x2 operator*(tmat4x2 const & m1, tmat4x4 const & m2); - + template GLM_FUNC_DECL tmat2x3 operator*(tmat4x3 const & m1, tmat2x4 const & m2); diff --git a/glm/detail/type_mat4x3.hpp b/glm/detail/type_mat4x3.hpp index 8bde1ac0..a29c7fb2 100644 --- a/glm/detail/type_mat4x3.hpp +++ b/glm/detail/type_mat4x3.hpp @@ -8,14 +8,14 @@ /// 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 @@ -50,8 +50,15 @@ namespace glm typedef tmat3x4 transpose_type; typedef T value_type; +# ifdef GLM_META_PROG_HELPERS + static GLM_RELAXED_CONSTEXPR length_t components = 4; + static GLM_RELAXED_CONSTEXPR length_t cols = 3; + static GLM_RELAXED_CONSTEXPR length_t rows = 4; + static GLM_RELAXED_CONSTEXPR precision prec = P; +# endif//GLM_META_PROG_HELPERS + private: - // Data + // Data col_type value[4]; public: @@ -87,7 +94,7 @@ namespace glm X2 const & x2, Y2 const & y2, Z2 const & z2, X3 const & x3, Y3 const & y3, Z3 const & z3, X4 const & x4, Y4 const & y4, Z4 const & z4); - + template GLM_FUNC_DECL tmat4x3( tvec3 const & v1, @@ -98,13 +105,8 @@ namespace glm ////////////////////////////////////// // Matrix conversions -# ifdef GLM_FORCE_EXPLICIT_CTOR - template - GLM_FUNC_DECL explicit tmat4x3(tmat4x3 const & m); -# else - template - GLM_FUNC_DECL tmat4x3(tmat4x3 const & m); -# endif + template + GLM_FUNC_DECL GLM_EXPLICIT tmat4x3(tmat4x3 const & m); GLM_FUNC_DECL explicit tmat4x3(tmat2x2 const & x); GLM_FUNC_DECL explicit tmat4x3(tmat3x3 const & x); @@ -191,7 +193,7 @@ namespace glm template GLM_FUNC_DECL tmat3x3 operator*(tmat4x3 const & m1, tmat3x4 const & m2); - + template GLM_FUNC_DECL tmat4x3 operator*(tmat4x3 const & m1, tmat4x4 const & m2); diff --git a/glm/detail/type_mat4x4.hpp b/glm/detail/type_mat4x4.hpp index dcb7269b..e8e9bcd4 100644 --- a/glm/detail/type_mat4x4.hpp +++ b/glm/detail/type_mat4x4.hpp @@ -8,14 +8,14 @@ /// 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 @@ -49,6 +49,13 @@ namespace glm typedef tmat4x4 transpose_type; typedef T value_type; +# ifdef GLM_META_PROG_HELPERS + static GLM_RELAXED_CONSTEXPR length_t components = 4; + static GLM_RELAXED_CONSTEXPR length_t cols = 4; + static GLM_RELAXED_CONSTEXPR length_t rows = 4; + static GLM_RELAXED_CONSTEXPR precision prec = P; +# endif//GLM_META_PROG_HELPERS + template friend tvec4 operator/(tmat4x4 const & m, tvec4 const & v); template @@ -103,13 +110,8 @@ namespace glm ////////////////////////////////////// // Matrix conversions -# ifdef GLM_FORCE_EXPLICIT_CTOR - template - GLM_FUNC_DECL explicit tmat4x4(tmat4x4 const & m); -# else - template - GLM_FUNC_DECL tmat4x4(tmat4x4 const & m); -# endif + template + GLM_FUNC_DECL GLM_EXPLICIT tmat4x4(tmat4x4 const & m); GLM_FUNC_DECL explicit tmat4x4(tmat2x2 const & x); GLM_FUNC_DECL explicit tmat4x4(tmat3x3 const & x); @@ -177,13 +179,13 @@ namespace glm template GLM_FUNC_DECL tmat4x4 operator+(T const & s, tmat4x4 const & m); - template + template GLM_FUNC_DECL tmat4x4 operator+(tmat4x4 const & m1, tmat4x4 const & m2); - template + template GLM_FUNC_DECL tmat4x4 operator-(tmat4x4 const & m, T const & s); - template + template GLM_FUNC_DECL tmat4x4 operator-(T const & s, tmat4x4 const & m); template diff --git a/glm/detail/type_vec1.hpp b/glm/detail/type_vec1.hpp index 3550d032..aef5922d 100644 --- a/glm/detail/type_vec1.hpp +++ b/glm/detail/type_vec1.hpp @@ -8,14 +8,14 @@ /// 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 @@ -55,6 +55,11 @@ namespace glm typedef tvec1 bool_type; typedef T value_type; +# ifdef GLM_META_PROG_HELPERS + static GLM_RELAXED_CONSTEXPR length_t components = 1; + static GLM_RELAXED_CONSTEXPR precision prec = P; +# endif//GLM_META_PROG_HELPERS + ////////////////////////////////////// // Data @@ -120,7 +125,7 @@ namespace glm ////////////////////////////////////// // Conversion vector constructors - + //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) template GLM_FUNC_DECL explicit tvec1(tvec2 const & v); @@ -131,15 +136,9 @@ namespace glm template GLM_FUNC_DECL explicit tvec1(tvec4 const & v); -# ifdef GLM_FORCE_EXPLICIT_CTOR - //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) - template - GLM_FUNC_DECL explicit tvec1(tvec1 const & v); -# else - //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) - template - GLM_FUNC_DECL tvec1(tvec1 const & v); -# endif + //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) + template + GLM_FUNC_DECL GLM_EXPLICIT tvec1(tvec1 const & v); ////////////////////////////////////// // Swizzle constructors @@ -157,23 +156,23 @@ namespace glm GLM_FUNC_DECL tvec1 & operator=(tvec1 const & v); - template + template GLM_FUNC_DECL tvec1 & operator=(tvec1 const & v); - template + template GLM_FUNC_DECL tvec1 & operator+=(U const & s); - template + template GLM_FUNC_DECL tvec1 & operator+=(tvec1 const & v); - template + template GLM_FUNC_DECL tvec1 & operator-=(U const & s); - template + template GLM_FUNC_DECL tvec1 & operator-=(tvec1 const & v); - template + template GLM_FUNC_DECL tvec1 & operator*=(U const & s); - template + template GLM_FUNC_DECL tvec1 & operator*=(tvec1 const & v); - template + template GLM_FUNC_DECL tvec1 & operator/=(U const & s); - template + template GLM_FUNC_DECL tvec1 & operator/=(tvec1 const & v); ////////////////////////////////////// @@ -187,29 +186,29 @@ namespace glm ////////////////////////////////////// // Unary bit operators - template + template GLM_FUNC_DECL tvec1 & operator%=(U const & s); - template + template GLM_FUNC_DECL tvec1 & operator%=(tvec1 const & v); - template + template GLM_FUNC_DECL tvec1 & operator&=(U const & s); - template + template GLM_FUNC_DECL tvec1 & operator&=(tvec1 const & v); - template + template GLM_FUNC_DECL tvec1 & operator|=(U const & s); - template + template GLM_FUNC_DECL tvec1 & operator|=(tvec1 const & v); - template + template GLM_FUNC_DECL tvec1 & operator^=(U const & s); - template + template GLM_FUNC_DECL tvec1 & operator^=(tvec1 const & v); - template + template GLM_FUNC_DECL tvec1 & operator<<=(U const & s); - template + template GLM_FUNC_DECL tvec1 & operator<<=(tvec1 const & v); - template + template GLM_FUNC_DECL tvec1 & operator>>=(U const & s); - template + template GLM_FUNC_DECL tvec1 & operator>>=(tvec1 const & v); }; @@ -313,7 +312,7 @@ namespace glm template GLM_FUNC_DECL tvec1 operator>>(tvec1 const & v1, tvec1 const & v2); - template + template GLM_FUNC_DECL tvec1 operator~(tvec1 const & v); }//namespace glm diff --git a/glm/detail/type_vec2.hpp b/glm/detail/type_vec2.hpp index 29cfa092..3609a24f 100644 --- a/glm/detail/type_vec2.hpp +++ b/glm/detail/type_vec2.hpp @@ -55,6 +55,11 @@ namespace glm typedef tvec2 bool_type; typedef T value_type; +# ifdef GLM_META_PROG_HELPERS + static GLM_RELAXED_CONSTEXPR length_t components = 2; + static GLM_RELAXED_CONSTEXPR precision prec = P; +# endif//GLM_META_PROG_HELPERS + ////////////////////////////////////// // Data @@ -139,15 +144,9 @@ namespace glm template GLM_FUNC_DECL explicit tvec2(tvec4 const & v); -# ifdef GLM_FORCE_EXPLICIT_CTOR - //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) - template - GLM_FUNC_DECL explicit tvec2(tvec2 const & v); -# else - //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) - template - GLM_FUNC_DECL tvec2(tvec2 const & v); -# endif + //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) + template + GLM_FUNC_DECL GLM_EXPLICIT tvec2(tvec2 const & v); ////////////////////////////////////// // Swizzle constructors diff --git a/glm/detail/type_vec3.hpp b/glm/detail/type_vec3.hpp index 5f0673bf..9665c55f 100644 --- a/glm/detail/type_vec3.hpp +++ b/glm/detail/type_vec3.hpp @@ -47,7 +47,7 @@ namespace glm { template struct tvec3 - { + { ////////////////////////////////////// // Implementation detail @@ -55,6 +55,11 @@ namespace glm typedef tvec3 bool_type; typedef T value_type; +# ifdef GLM_META_PROG_HELPERS + static GLM_RELAXED_CONSTEXPR length_t components = 3; + static GLM_RELAXED_CONSTEXPR precision prec = P; +# endif//GLM_META_PROG_HELPERS + ////////////////////////////////////// // Data @@ -149,15 +154,9 @@ namespace glm template GLM_FUNC_DECL explicit tvec3(tvec4 const & v); -# ifdef GLM_FORCE_EXPLICIT_CTOR - //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) - template - GLM_FUNC_DECL explicit tvec3(tvec3 const & v); -# else - //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) - template - GLM_FUNC_DECL tvec3(tvec3 const & v); -# endif + //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) + template + GLM_FUNC_DECL GLM_EXPLICIT tvec3(tvec3 const & v); ////////////////////////////////////// // Swizzle constructors diff --git a/glm/detail/type_vec4.hpp b/glm/detail/type_vec4.hpp index 8189d6f0..b48040fd 100644 --- a/glm/detail/type_vec4.hpp +++ b/glm/detail/type_vec4.hpp @@ -109,6 +109,11 @@ namespace detail typedef tvec4 bool_type; typedef T value_type; +# ifdef GLM_META_PROG_HELPERS + static GLM_RELAXED_CONSTEXPR length_t components = 4; + static GLM_RELAXED_CONSTEXPR precision prec = P; +# endif//GLM_META_PROG_HELPERS + ////////////////////////////////////// // Data @@ -224,16 +229,10 @@ namespace detail //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) template GLM_FUNC_DECL explicit tvec4(tvec2 const & a, tvec2 const & b); - -# ifdef GLM_FORCE_EXPLICIT_CTOR - //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) - template - GLM_FUNC_DECL explicit tvec4(tvec4 const & v); -# else - //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) - template - GLM_FUNC_DECL tvec4(tvec4 const & v); -# endif + + //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) + template + GLM_FUNC_DECL GLM_EXPLICIT tvec4(tvec4 const & v); ////////////////////////////////////// // Swizzle constructors diff --git a/glm/gtc/matrix_transform.hpp b/glm/gtc/matrix_transform.hpp index e70e6a81..d4ff3cfe 100644 --- a/glm/gtc/matrix_transform.hpp +++ b/glm/gtc/matrix_transform.hpp @@ -92,7 +92,7 @@ namespace glm /// /// @param m Input matrix multiplied by this rotation matrix. /// @param angle Rotation angle expressed in radians. - /// @param axis Rotation axis, recommanded to be normalized. + /// @param axis Rotation axis, recommended to be normalized. /// @tparam T Value type used to build the matrix. Supported: half, float or double. /// @see gtc_matrix_transform /// @see - rotate(tmat4x4 const & m, T angle, T x, T y, T z) @@ -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). diff --git a/glm/gtc/quaternion.hpp b/glm/gtc/quaternion.hpp index 812b5b00..07e2f18a 100644 --- a/glm/gtc/quaternion.hpp +++ b/glm/gtc/quaternion.hpp @@ -65,6 +65,11 @@ namespace glm typedef tquat type; typedef T value_type; +# ifdef GLM_META_PROG_HELPERS + static GLM_RELAXED_CONSTEXPR length_t components = 4; + static GLM_RELAXED_CONSTEXPR precision prec = P; +# endif//GLM_META_PROG_HELPERS + public: T x, y, z, w; @@ -103,24 +108,19 @@ namespace glm GLM_FUNC_DECL tquat(T const & w, T const & x, T const & y, T const & z); ////////////////////////////////////// - // Convertions + // Conversions + + template + GLM_FUNC_DECL GLM_EXPLICIT tquat(tquat const & q); -# ifdef GLM_FORCE_EXPLICIT_CTOR - template - GLM_FUNC_DECL explicit tquat(tquat const & q); -# else - template - GLM_FUNC_DECL tquat(tquat const & q); -# endif - // explicit conversion operators # if GLM_HAS_EXPLICIT_CONVERSION_OPERATORS GLM_FUNC_DECL explicit operator tmat3x3(); GLM_FUNC_DECL explicit operator tmat4x4(); # endif - + /// Create a quaternion from two normalized axis - /// + /// /// @param u A first normalized axis /// @param v A second normalized axis /// @see gtc_quaternion diff --git a/glm/gtx/compatibility.hpp b/glm/gtx/compatibility.hpp index 6a3623be..5b3f0513 100644 --- a/glm/gtx/compatibility.hpp +++ b/glm/gtx/compatibility.hpp @@ -84,6 +84,7 @@ namespace glm template GLM_FUNC_QUALIFIER tvec4 atan2(const tvec4& x, const tvec4& y){return atan(x, y);} //!< \brief Arc tangent. Returns an angle whose tangent is y/x. The signs of x and y are used to determine what quadrant the angle is in. The range of values returned by this function is [-PI, PI]. Results are undefined if x and y are both 0. (From GLM_GTX_compatibility) template GLM_FUNC_DECL bool isfinite(genType const & x); //!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility) + template GLM_FUNC_DECL tvec1 isfinite(const tvec1& x); //!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility) template GLM_FUNC_DECL tvec2 isfinite(const tvec2& x); //!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility) template GLM_FUNC_DECL tvec3 isfinite(const tvec3& x); //!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility) template GLM_FUNC_DECL tvec4 isfinite(const tvec4& x); //!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility) diff --git a/glm/gtx/compatibility.inl b/glm/gtx/compatibility.inl index decc26c2..77f99d13 100644 --- a/glm/gtx/compatibility.inl +++ b/glm/gtx/compatibility.inl @@ -46,10 +46,21 @@ namespace glm # elif GLM_COMPILER & GLM_COMPILER_GCC && GLM_PLATFORM & GLM_PLATFORM_ANDROID return _isfinite(x) != 0; # else - return x >= std::numeric_limits::min() && x <= std::numeric_limits::max(); + if (std::numeric_limits::is_integer || std::denorm_absent == std::numeric_limits::has_denorm) + return std::numeric_limits::min() <= x && std::numeric_limits::max() >= x; + else + return -std::numeric_limits::max() <= x && std::numeric_limits::max() >= x; # endif } + template + GLM_FUNC_QUALIFIER tvec1 isfinite( + tvec1 const & x) + { + return tvec1( + isfinite(x.x)); + } + template GLM_FUNC_QUALIFIER tvec2 isfinite( tvec2 const & x) diff --git a/glm/gtx/dual_quaternion.hpp b/glm/gtx/dual_quaternion.hpp index a8005cb8..624470f4 100644 --- a/glm/gtx/dual_quaternion.hpp +++ b/glm/gtx/dual_quaternion.hpp @@ -15,7 +15,7 @@ /// 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 @@ -63,10 +63,15 @@ namespace glm { typedef T value_type; typedef glm::tquat part_type; - + +# ifdef GLM_META_PROG_HELPERS + static GLM_RELAXED_CONSTEXPR length_t components = 8; + static GLM_RELAXED_CONSTEXPR precision prec = P; +# endif//GLM_META_PROG_HELPERS + public: glm::tquat real, dual; - + ////////////////////////////////////// // Component accesses @@ -105,17 +110,12 @@ namespace glm ////////////////////////////////////////////////////////////// // tdualquat conversions -# ifdef GLM_FORCE_EXPLICIT_CTOR - template - GLM_FUNC_DECL explicit tdualquat(tdualquat const & q); -# else - template - GLM_FUNC_DECL tdualquat(tdualquat const & q); -# endif + template + GLM_FUNC_DECL GLM_EXPLICIT tdualquat(tdualquat const & q); GLM_FUNC_DECL explicit tdualquat(tmat2x4 const & holder_mat); GLM_FUNC_DECL explicit tdualquat(tmat3x4 const & aug_mat); - + // Operators GLM_FUNC_DECL tdualquat & operator=(tdualquat const & m); @@ -126,51 +126,51 @@ namespace glm template GLM_FUNC_DECL tdualquat & operator/=(U s); }; - + template GLM_FUNC_DECL tquat operator- ( tquat const & q); - + template GLM_FUNC_DECL tdualquat operator+ ( tdualquat const & q, tdualquat const & p); - + template GLM_FUNC_DECL tdualquat operator* ( tdualquat const & q, tdualquat const & p); - + template GLM_FUNC_DECL tvec3 operator* ( tquat const & q, tvec3 const & v); - + template GLM_FUNC_DECL tvec3 operator* ( tvec3 const & v, tquat const & q); - + template GLM_FUNC_DECL tvec4 operator* ( tquat const & q, tvec4 const & v); - + template GLM_FUNC_DECL tvec4 operator* ( tvec4 const & v, tquat const & q); - + template GLM_FUNC_DECL tdualquat operator* ( tdualquat const & q, T const & s); - + template GLM_FUNC_DECL tdualquat operator* ( T const & s, tdualquat const & q); - + template GLM_FUNC_DECL tdualquat operator/ ( tdualquat const & q, @@ -227,17 +227,17 @@ namespace glm GLM_FUNC_DECL tdualquat dualquat_cast( tmat3x4 const & x); - + /// Dual-quaternion of low single-precision floating-point numbers. /// /// @see gtx_dual_quaternion typedef tdualquat lowp_dualquat; - + /// Dual-quaternion of medium single-precision floating-point numbers. /// /// @see gtx_dual_quaternion typedef tdualquat mediump_dualquat; - + /// Dual-quaternion of high single-precision floating-point numbers. /// /// @see gtx_dual_quaternion @@ -248,40 +248,40 @@ namespace glm /// /// @see gtx_dual_quaternion typedef tdualquat lowp_fdualquat; - + /// Dual-quaternion of medium single-precision floating-point numbers. /// /// @see gtx_dual_quaternion typedef tdualquat mediump_fdualquat; - + /// Dual-quaternion of high single-precision floating-point numbers. /// /// @see gtx_dual_quaternion typedef tdualquat highp_fdualquat; - - + + /// Dual-quaternion of low double-precision floating-point numbers. /// /// @see gtx_dual_quaternion typedef tdualquat lowp_ddualquat; - + /// Dual-quaternion of medium double-precision floating-point numbers. /// /// @see gtx_dual_quaternion typedef tdualquat mediump_ddualquat; - + /// Dual-quaternion of high double-precision floating-point numbers. /// /// @see gtx_dual_quaternion typedef tdualquat highp_ddualquat; - + #if(!defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT)) /// Dual-quaternion of floating-point numbers. /// /// @see gtx_dual_quaternion typedef highp_fdualquat dualquat; - + /// Dual-quaternion of single-precision floating-point numbers. /// /// @see gtx_dual_quaternion @@ -298,7 +298,7 @@ namespace glm #else # error "GLM error: multiple default precision requested for single-precision floating-point types" #endif - + #if(!defined(GLM_PRECISION_HIGHP_DOUBLE) && !defined(GLM_PRECISION_MEDIUMP_DOUBLE) && !defined(GLM_PRECISION_LOWP_DOUBLE)) /// Dual-quaternion of default double-precision floating-point numbers. diff --git a/glm/gtx/euler_angles.hpp b/glm/gtx/euler_angles.hpp index 7a1cb364..e772bbf0 100644 --- a/glm/gtx/euler_angles.hpp +++ b/glm/gtx/euler_angles.hpp @@ -114,6 +114,14 @@ namespace glm T const & angleZ, T const & angleY); + /// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (X * Y * Z). + /// @see gtx_euler_angles + template + GLM_FUNC_DECL tmat4x4 eulerAngleXYZ( + T const & t1, + T const & t2, + T const & t3); + /// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (Y * X * Z). /// @see gtx_euler_angles template @@ -121,7 +129,7 @@ namespace glm T const & yaw, T const & pitch, T const & roll); - + /// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (Y * X * Z). /// @see gtx_euler_angles template @@ -150,6 +158,14 @@ namespace glm template GLM_FUNC_DECL tmat4x4 orientate4(tvec3 const & angles); + /// Extracts the (X * Y * Z) Euler angles from the rotation matrix M + /// @see gtx_euler_angles + template + GLM_FUNC_DECL void extractEulerAngleXYZ(tmat4x4 & M, + T & t1, + T & t2, + T & t3); + /// @} }//namespace glm diff --git a/glm/gtx/euler_angles.inl b/glm/gtx/euler_angles.inl index 77fea425..80b30dbe 100644 --- a/glm/gtx/euler_angles.inl +++ b/glm/gtx/euler_angles.inl @@ -30,6 +30,8 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////////////////////// +#include "compatibility.hpp" // glm::atan2 + namespace glm { template @@ -157,7 +159,42 @@ namespace glm { return eulerAngleZ(angleZ) * eulerAngleY(angleY); } - + + template + GLM_FUNC_QUALIFIER tmat4x4 eulerAngleXYZ + ( + T const & t1, + T const & t2, + T const & t3 + ) + { + T c1 = glm::cos(-t1); + T c2 = glm::cos(-t2); + T c3 = glm::cos(-t3); + T s1 = glm::sin(-t1); + T s2 = glm::sin(-t2); + T s3 = glm::sin(-t3); + + tmat4x4 Result; + Result[0][0] = c2 * c3; + Result[0][1] =-c1 * s3 + s1 * s2 * c3; + Result[0][2] = s1 * s3 + c1 * s2 * c3; + Result[0][3] = static_cast(0); + Result[1][0] = c2 * s3; + Result[1][1] = c1 * c3 + s1 * s2 * s3; + Result[1][2] =-s1 * c3 + c1 * s2 * s3; + Result[1][3] = static_cast(0); + Result[2][0] =-s2; + Result[2][1] = s1 * c2; + Result[2][2] = c1 * c2; + Result[2][3] = static_cast(0); + Result[3][0] = static_cast(0); + Result[3][1] = static_cast(0); + Result[3][2] = static_cast(0); + Result[3][3] = static_cast(1); + return Result; + } + template GLM_FUNC_QUALIFIER tmat4x4 eulerAngleYXZ ( @@ -284,4 +321,21 @@ namespace glm { return yawPitchRoll(angles.z, angles.x, angles.y); } + + template + GLM_FUNC_DECL void extractEulerAngleXYZ(tmat4x4 & M, + T & t1, + T & t2, + T & t3) + { + float T1 = glm::atan2(M[2][1], M[2][2]); + float C2 = glm::sqrt(M[0][0]*M[0][0] + M[1][0]*M[1][0]); + float T2 = glm::atan2(-M[2][0], C2); + float S1 = glm::sin(T1); + float C1 = glm::cos(T1); + float T3 = glm::atan2(S1*M[0][2] - C1*M[0][1], C1*M[1][1] - S1*M[1][2 ]); + t1 = -T1; + t2 = -T2; + t3 = -T3; + } }//namespace glm diff --git a/glm/gtx/fast_trigonometry.inl b/glm/gtx/fast_trigonometry.inl index 16a821ad..b8c65810 100644 --- a/glm/gtx/fast_trigonometry.inl +++ b/glm/gtx/fast_trigonometry.inl @@ -33,6 +33,16 @@ namespace glm{ namespace detail { + template class vecType> + GLM_FUNC_QUALIFIER vecType taylorCos(vecType const & x) + { + return static_cast(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 GLM_FUNC_QUALIFIER T cos_52s(T x) { @@ -66,11 +76,11 @@ namespace detail { T const angle(wrapAngle(x)); - if(angle()) + if(angle < half_pi()) return detail::cos_52s(angle); - if(angle()) + if(angle < pi()) return -detail::cos_52s(pi() - angle); - if(angle<(T(3) * half_pi())) + if(angle < (T(3) * half_pi())) return -detail::cos_52s(angle - pi()); return detail::cos_52s(two_pi() - angle); diff --git a/glm/gtx/hash.hpp b/glm/gtx/hash.hpp index f029b751..31e86dc6 100644 --- a/glm/gtx/hash.hpp +++ b/glm/gtx/hash.hpp @@ -41,6 +41,10 @@ #pragma once +#if !GLM_HAS_CXX11_STL +# error "GLM_GTX_hash requires C++11 standard library support" +#endif + #include #include "../vec2.hpp" diff --git a/glm/gtx/intersect.hpp b/glm/gtx/intersect.hpp index ef3d42d1..d35b4c54 100644 --- a/glm/gtx/intersect.hpp +++ b/glm/gtx/intersect.hpp @@ -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 diff --git a/glm/gtx/io.hpp b/glm/gtx/io.hpp index b3842bbd..a52ab9c0 100644 --- a/glm/gtx/io.hpp +++ b/glm/gtx/io.hpp @@ -220,6 +220,12 @@ namespace glm std::pair const, tmat4x4 const> const &); + template + GLM_FUNC_DECL std::basic_ostream & operator<<( + std::basic_ostream &, + std::pair, + tmat4x4 > const &); + /// @} }//namespace glm diff --git a/glm/gtx/io.inl b/glm/gtx/io.inl index 5af266dd..92c68732 100644 --- a/glm/gtx/io.inl +++ b/glm/gtx/io.inl @@ -645,4 +645,12 @@ namespace io return os; } + + template + GLM_FUNC_QUALIFIER std::basic_ostream& operator<<( + std::basic_ostream & os, + std::pair, tmat4x4 > const& a) + { + return operator<<(os, static_cast const, tmat4x4 const> const&>(a)); + } }//namespace glm diff --git a/glm/gtx/norm.hpp b/glm/gtx/norm.hpp index d8fbf2c1..f1d8d1b2 100644 --- a/glm/gtx/norm.hpp +++ b/glm/gtx/norm.hpp @@ -67,14 +67,14 @@ namespace glm GLM_FUNC_DECL typename genType::value_type length2( genType const & x); - //! Returns the squared distance between p0 and p1, i.e., length(p0 - p1). + //! Returns the squared distance between p0 and p1, i.e., length2(p0 - p1). //! From GLM_GTX_norm extension. template GLM_FUNC_DECL T distance2( T const & p0, T const & p1); - //! Returns the squared distance between p0 and p1, i.e., length(p0 - p1). + //! Returns the squared distance between p0 and p1, i.e., length2(p0 - p1). //! From GLM_GTX_norm extension. template GLM_FUNC_DECL typename genType::value_type distance2( diff --git a/glm/gtx/quaternion.inl b/glm/gtx/quaternion.inl index 4c5b3d66..7467b42d 100644 --- a/glm/gtx/quaternion.inl +++ b/glm/gtx/quaternion.inl @@ -121,33 +121,28 @@ namespace glm } template - GLM_FUNC_QUALIFIER tquat pow - ( - tquat const & x, - T const & y - ) + GLM_FUNC_QUALIFIER tquat pow(tquat const & x, T const & y) { - if(abs(x.w) > (static_cast(1) - epsilon())) - return x; - T Angle = acos(y); + //Raising to the power of 0 should yield 1 + //Needed to prevent a division by 0 error later on + if(y > -epsilon() && y < epsilon()) + return tquat(1,0,0,0); + + //To deal with non-unit quaternions + T magnitude = sqrt(x.x * x.x + x.y * x.y + x.z * x.z + x.w *x.w); + + //Equivalent to raising a real number to a power + //Needed to prevent a division by 0 error later on + if(abs(x.w / magnitude) > static_cast(1) - epsilon() && abs(x.w / magnitude) < static_cast(1) + epsilon()) + return tquat(pow(x.w, y),0,0,0); + + T Angle = acos(x.w / magnitude); T NewAngle = Angle * y; T Div = sin(NewAngle) / sin(Angle); - return tquat( - cos(NewAngle), - x.x * Div, - x.y * Div, - x.z * Div); - } + T Mag = pow(magnitude, y-1); - //template - //GLM_FUNC_QUALIFIER tquat sqrt - //( - // tquat const & q - //) - //{ - // T q0 = static_cast(1) - dot(q, q); - // return T(2) * (T(1) + q0) * q; - //} + return tquat(cos(NewAngle) * magnitude * Mag, x.x * Div * Mag, x.y * Div * Mag, x.z * Div * Mag); + } template GLM_FUNC_QUALIFIER tvec3 rotate diff --git a/glm/gtx/scalar_multiplication.hpp b/glm/gtx/scalar_multiplication.hpp index 5f6c4d9e..3b34d2b3 100644 --- a/glm/gtx/scalar_multiplication.hpp +++ b/glm/gtx/scalar_multiplication.hpp @@ -44,7 +44,7 @@ #include "../detail/setup.hpp" #if !GLM_HAS_TEMPLATE_ALIASES && !(GLM_COMPILER & GLM_COMPILER_GCC) -# error "GLM_GTX_scalar_multiplication requires C++11 suppport or alias templates and if not support for GCC" +# error "GLM_GTX_scalar_multiplication requires C++11 support or alias templates and if not support for GCC" #endif #include "../vec2.hpp" diff --git a/glm/gtx/simd_mat4.hpp b/glm/gtx/simd_mat4.hpp index 89ee5e75..a321d1ed 100644 --- a/glm/gtx/simd_mat4.hpp +++ b/glm/gtx/simd_mat4.hpp @@ -8,14 +8,14 @@ /// 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 @@ -33,9 +33,9 @@ /// /// @defgroup gtx_simd_mat4 GLM_GTX_simd_mat4 /// @ingroup gtx -/// +/// /// @brief SIMD implementation of mat4 type. -/// +/// /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// @@ -71,6 +71,13 @@ namespace detail typedef fmat4x4SIMD type; typedef fmat4x4SIMD transpose_type; +# ifdef GLM_META_PROG_HELPERS + static GLM_RELAXED_CONSTEXPR length_t components = 4; + static GLM_RELAXED_CONSTEXPR length_t cols = 4; + static GLM_RELAXED_CONSTEXPR length_t rows = 4; + static GLM_RELAXED_CONSTEXPR precision prec = defaultp; +# endif//GLM_META_PROG_HELPERS + GLM_FUNC_DECL length_t length() const; fvec4SIMD Data[4]; @@ -96,7 +103,7 @@ namespace detail __m128 const in[4]); // Conversions - //template + //template //explicit tmat4x4(tmat4x4 const & m); //explicit tmat4x4(tmat2x2 const & x); diff --git a/glm/gtx/simd_quat.hpp b/glm/gtx/simd_quat.hpp index 810ce30c..0c30e501 100644 --- a/glm/gtx/simd_quat.hpp +++ b/glm/gtx/simd_quat.hpp @@ -8,14 +8,14 @@ /// 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 @@ -33,9 +33,9 @@ /// /// @defgroup gtx_simd_quat GLM_GTX_simd_quat /// @ingroup gtx -/// +/// /// @brief SIMD implementation of quat type. -/// +/// /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// @@ -76,6 +76,11 @@ namespace detail typedef fquatSIMD type; typedef tquat bool_type; +# ifdef GLM_META_PROG_HELPERS + static GLM_RELAXED_CONSTEXPR length_t components = 4; + static GLM_RELAXED_CONSTEXPR precision prec = defaultp; +# endif//GLM_META_PROG_HELPERS + #ifdef GLM_SIMD_ENABLE_XYZW_UNION union { @@ -99,15 +104,15 @@ namespace detail explicit fquatSIMD( ctor); explicit fquatSIMD( - float const & w, - float const & x, - float const & y, + float const & w, + float const & x, + float const & y, float const & z); explicit fquatSIMD( quat const & v); explicit fquatSIMD( vec3 const & eulerAngles); - + ////////////////////////////////////// // Unary arithmetic operators @@ -124,16 +129,16 @@ namespace detail detail::fquatSIMD operator- ( detail::fquatSIMD const & q); - detail::fquatSIMD operator+ ( - detail::fquatSIMD const & q, - detail::fquatSIMD const & p); + detail::fquatSIMD operator+ ( + detail::fquatSIMD const & q, + detail::fquatSIMD const & p); - detail::fquatSIMD operator* ( - detail::fquatSIMD const & q, - detail::fquatSIMD const & p); + detail::fquatSIMD operator* ( + detail::fquatSIMD const & q, + detail::fquatSIMD const & p); detail::fvec4SIMD operator* ( - detail::fquatSIMD const & q, + detail::fquatSIMD const & q, detail::fvec4SIMD const & v); detail::fvec4SIMD operator* ( @@ -141,7 +146,7 @@ namespace detail detail::fquatSIMD const & q); detail::fquatSIMD operator* ( - detail::fquatSIMD const & q, + detail::fquatSIMD const & q, float s); detail::fquatSIMD operator* ( @@ -149,7 +154,7 @@ namespace detail detail::fquatSIMD const & q); detail::fquatSIMD operator/ ( - detail::fquatSIMD const & q, + detail::fquatSIMD const & q, float s); }//namespace detail @@ -192,64 +197,64 @@ namespace detail detail::fquatSIMD const & q); - /// Returns the length of the quaternion. - /// + /// Returns the length of the quaternion. + /// /// @see gtx_simd_quat float length( detail::fquatSIMD const & x); - /// Returns the normalized quaternion. - /// + /// Returns the normalized quaternion. + /// /// @see gtx_simd_quat detail::fquatSIMD normalize( detail::fquatSIMD const & x); - /// Returns dot product of q1 and q2, i.e., q1[0] * q2[0] + q1[1] * q2[1] + ... - /// + /// Returns dot product of q1 and q2, i.e., q1[0] * q2[0] + q1[1] * q2[1] + ... + /// /// @see gtx_simd_quat float dot( - detail::fquatSIMD const & q1, + detail::fquatSIMD const & q1, detail::fquatSIMD const & q2); /// Spherical linear interpolation of two quaternions. /// The interpolation is oriented and the rotation is performed at constant speed. /// For short path spherical linear interpolation, use the slerp function. - /// + /// /// @param x A quaternion /// @param y A quaternion /// @param a Interpolation factor. The interpolation is defined beyond the range [0, 1]. /// @tparam T Value type used to build the quaternion. Supported: half, float or double. /// @see gtx_simd_quat - /// @see - slerp(detail::fquatSIMD const & x, detail::fquatSIMD const & y, T const & a) + /// @see - slerp(detail::fquatSIMD const & x, detail::fquatSIMD const & y, T const & a) detail::fquatSIMD mix( - detail::fquatSIMD const & x, - detail::fquatSIMD const & y, + detail::fquatSIMD const & x, + detail::fquatSIMD const & y, float const & a); - /// Linear interpolation of two quaternions. + /// Linear interpolation of two quaternions. /// The interpolation is oriented. - /// + /// /// @param x A quaternion /// @param y A quaternion /// @param a Interpolation factor. The interpolation is defined in the range [0, 1]. /// @tparam T Value type used to build the quaternion. Supported: half, float or double. /// @see gtx_simd_quat detail::fquatSIMD lerp( - detail::fquatSIMD const & x, - detail::fquatSIMD const & y, + detail::fquatSIMD const & x, + detail::fquatSIMD const & y, float const & a); /// Spherical linear interpolation of two quaternions. /// The interpolation always take the short path and the rotation is performed at constant speed. - /// + /// /// @param x A quaternion /// @param y A quaternion /// @param a Interpolation factor. The interpolation is defined beyond the range [0, 1]. /// @tparam T Value type used to build the quaternion. Supported: half, float or double. /// @see gtx_simd_quat detail::fquatSIMD slerp( - detail::fquatSIMD const & x, - detail::fquatSIMD const & y, + detail::fquatSIMD const & x, + detail::fquatSIMD const & y, float const & a); @@ -262,10 +267,10 @@ namespace detail /// This will use the equivalent to fastAcos() and fastSin(). /// /// @see gtx_simd_quat - /// @see - mix(detail::fquatSIMD const & x, detail::fquatSIMD const & y, T const & a) + /// @see - mix(detail::fquatSIMD const & x, detail::fquatSIMD const & y, T const & a) detail::fquatSIMD fastMix( - detail::fquatSIMD const & x, - detail::fquatSIMD const & y, + detail::fquatSIMD const & x, + detail::fquatSIMD const & y, float const & a); /// Identical to fastMix() except takes the shortest path. @@ -273,22 +278,22 @@ namespace detail /// The same rules apply here as those in fastMix(). Both quaternions must be unit length and 'a' must be /// in the range [0, 1]. /// - /// @see - fastMix(detail::fquatSIMD const & x, detail::fquatSIMD const & y, T const & a) - /// @see - slerp(detail::fquatSIMD const & x, detail::fquatSIMD const & y, T const & a) + /// @see - fastMix(detail::fquatSIMD const & x, detail::fquatSIMD const & y, T const & a) + /// @see - slerp(detail::fquatSIMD const & x, detail::fquatSIMD const & y, T const & a) detail::fquatSIMD fastSlerp( - detail::fquatSIMD const & x, - detail::fquatSIMD const & y, + detail::fquatSIMD const & x, + detail::fquatSIMD const & y, float const & a); - /// Returns the q conjugate. - /// + /// Returns the q conjugate. + /// /// @see gtx_simd_quat detail::fquatSIMD conjugate( detail::fquatSIMD const & q); - /// Returns the q inverse. - /// + /// Returns the q inverse. + /// /// @see gtx_simd_quat detail::fquatSIMD inverse( detail::fquatSIMD const & q); @@ -296,14 +301,14 @@ namespace detail /// Build a quaternion from an angle and a normalized axis. /// /// @param angle Angle expressed in radians. - /// @param axis Axis of the quaternion, must be normalized. + /// @param axis Axis of the quaternion, must be normalized. /// /// @see gtx_simd_quat detail::fquatSIMD angleAxisSIMD( - float const & angle, + float const & angle, vec3 const & axis); - /// Build a quaternion from an angle and a normalized axis. + /// Build a quaternion from an angle and a normalized axis. /// /// @param angle Angle expressed in radians. /// @param x x component of the x-axis, x, y, z must be a normalized axis @@ -312,9 +317,9 @@ namespace detail /// /// @see gtx_simd_quat detail::fquatSIMD angleAxisSIMD( - float const & angle, - float const & x, - float const & y, + float const & angle, + float const & x, + float const & y, float const & z); // TODO: Move this to somewhere more appropriate. Used with fastMix() and fastSlerp(). diff --git a/glm/gtx/simd_vec4.hpp b/glm/gtx/simd_vec4.hpp index 2d836a41..905af456 100644 --- a/glm/gtx/simd_vec4.hpp +++ b/glm/gtx/simd_vec4.hpp @@ -8,14 +8,14 @@ /// 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 @@ -33,9 +33,9 @@ /// /// @defgroup gtx_simd_vec4 GLM_GTX_simd_vec4 /// @ingroup gtx -/// +/// /// @brief SIMD implementation of vec4 type. -/// +/// /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// @@ -99,6 +99,11 @@ namespace detail typedef fvec4SIMD type; typedef tvec4 bool_type; +# ifdef GLM_META_PROG_HELPERS + static GLM_RELAXED_CONSTEXPR length_t components = 4; + static GLM_RELAXED_CONSTEXPR precision prec = defaultp; +# endif//GLM_META_PROG_HELPERS + #ifdef GLM_SIMD_ENABLE_XYZW_UNION union { @@ -124,9 +129,9 @@ namespace detail explicit fvec4SIMD( float const & s); explicit fvec4SIMD( - float const & x, - float const & y, - float const & z, + float const & x, + float const & y, + float const & z, float const & w); explicit fvec4SIMD( vec4 const & v); @@ -213,13 +218,13 @@ namespace detail //! Returns a value equal to the nearest integer to x. //! A fractional part of 0.5 will round toward the nearest even - //! integer. (Both 3.5 and 4.5 for x will return 4.0.) + //! integer. (Both 3.5 and 4.5 for x will return 4.0.) /// /// @see gtx_simd_vec4 //detail::fvec4SIMD roundEven(detail::fvec4SIMD const & x); - //! Returns a value equal to the nearest integer - //! that is greater than or equal to x. + //! Returns a value equal to the nearest integer + //! that is greater than or equal to x. /// @see gtx_simd_vec4 detail::fvec4SIMD ceil(detail::fvec4SIMD const & x); @@ -233,7 +238,7 @@ namespace detail /// /// @see gtx_simd_vec4 detail::fvec4SIMD mod( - detail::fvec4SIMD const & x, + detail::fvec4SIMD const & x, detail::fvec4SIMD const & y); //! Modulus. Returns x - y * floor(x / y) @@ -241,7 +246,7 @@ namespace detail /// /// @see gtx_simd_vec4 detail::fvec4SIMD mod( - detail::fvec4SIMD const & x, + detail::fvec4SIMD const & x, float const & y); //! Returns the fractional part of x and sets i to the integer @@ -250,51 +255,51 @@ namespace detail //! sign as x. //! (From GLM_GTX_simd_vec4 extension, common function) //detail::fvec4SIMD modf( - // detail::fvec4SIMD const & x, + // detail::fvec4SIMD const & x, // detail::fvec4SIMD & i); //! Returns y if y < x; otherwise, it returns x. - /// + /// /// @see gtx_simd_vec4 detail::fvec4SIMD min( - detail::fvec4SIMD const & x, + detail::fvec4SIMD const & x, detail::fvec4SIMD const & y); detail::fvec4SIMD min( - detail::fvec4SIMD const & x, + detail::fvec4SIMD const & x, float const & y); //! Returns y if x < y; otherwise, it returns x. /// /// @see gtx_simd_vec4 detail::fvec4SIMD max( - detail::fvec4SIMD const & x, + detail::fvec4SIMD const & x, detail::fvec4SIMD const & y); detail::fvec4SIMD max( - detail::fvec4SIMD const & x, + detail::fvec4SIMD const & x, float const & y); - //! Returns min(max(x, minVal), maxVal) for each component in x + //! Returns min(max(x, minVal), maxVal) for each component in x //! using the floating-point values minVal and maxVal. /// /// @see gtx_simd_vec4 detail::fvec4SIMD clamp( - detail::fvec4SIMD const & x, - detail::fvec4SIMD const & minVal, - detail::fvec4SIMD const & maxVal); + detail::fvec4SIMD const & x, + detail::fvec4SIMD const & minVal, + detail::fvec4SIMD const & maxVal); detail::fvec4SIMD clamp( - detail::fvec4SIMD const & x, - float const & minVal, - float const & maxVal); + detail::fvec4SIMD const & x, + float const & minVal, + float const & maxVal); - //! \return If genTypeU is a floating scalar or vector: - //! Returns x * (1.0 - a) + y * a, i.e., the linear blend of - //! x and y using the floating-point value a. + //! \return If genTypeU is a floating scalar or vector: + //! Returns x * (1.0 - a) + y * a, i.e., the linear blend of + //! x and y using the floating-point value a. //! The value for a is not restricted to the range [0, 1]. //! - //! \return If genTypeU is a boolean scalar or vector: + //! \return If genTypeU is a boolean scalar or vector: //! Selects which vector each returned component comes //! from. For a component of a that is false, the //! corresponding component of x is returned. For a @@ -305,9 +310,9 @@ namespace detail //! provides different functionality than //! genType mix(genType x, genType y, genType(a)) //! where a is a Boolean vector. - //! + //! //! From GLSL 1.30.08 specification, section 8.3 - //! + //! //! \param[in] x Floating point scalar or vector. //! \param[in] y Floating point scalar or vector. //! \param[in] a Floating point or boolean scalar or vector. @@ -316,19 +321,19 @@ namespace detail /// /// @see gtx_simd_vec4 detail::fvec4SIMD mix( - detail::fvec4SIMD const & x, - detail::fvec4SIMD const & y, + detail::fvec4SIMD const & x, + detail::fvec4SIMD const & y, detail::fvec4SIMD const & a); //! Returns 0.0 if x < edge, otherwise it returns 1.0. /// /// @see gtx_simd_vec4 detail::fvec4SIMD step( - detail::fvec4SIMD const & edge, + detail::fvec4SIMD const & edge, detail::fvec4SIMD const & x); detail::fvec4SIMD step( - float const & edge, + float const & edge, detail::fvec4SIMD const & x); //! Returns 0.0 if x <= edge0 and 1.0 if x >= edge1 and @@ -343,13 +348,13 @@ namespace detail /// /// @see gtx_simd_vec4 detail::fvec4SIMD smoothstep( - detail::fvec4SIMD const & edge0, - detail::fvec4SIMD const & edge1, + detail::fvec4SIMD const & edge0, + detail::fvec4SIMD const & edge1, detail::fvec4SIMD const & x); detail::fvec4SIMD smoothstep( - float const & edge0, - float const & edge1, + float const & edge0, + float const & edge1, detail::fvec4SIMD const & x); //! Returns true if x holds a NaN (not a number) @@ -390,8 +395,8 @@ namespace detail /// /// @see gtx_simd_vec4 detail::fvec4SIMD fma( - detail::fvec4SIMD const & a, - detail::fvec4SIMD const & b, + detail::fvec4SIMD const & a, + detail::fvec4SIMD const & b, detail::fvec4SIMD const & c); //! Splits x into a floating-point significand in the range diff --git a/glm/gtx/wrap.hpp b/glm/gtx/wrap.hpp index cf21d6fe..20566516 100644 --- a/glm/gtx/wrap.hpp +++ b/glm/gtx/wrap.hpp @@ -63,6 +63,11 @@ namespace glm template GLM_FUNC_DECL genType repeat(genType const & Texcoord); + /// Simulate GL_MIRRORED_REPEAT OpenGL wrap mode + /// @see gtx_wrap extension. + template + GLM_FUNC_DECL genType mirrorClamp(genType const & Texcoord); + /// Simulate GL_MIRROR_REPEAT OpenGL wrap mode /// @see gtx_wrap extension. template diff --git a/glm/gtx/wrap.inl b/glm/gtx/wrap.inl index 5cd084ea..402e815d 100644 --- a/glm/gtx/wrap.inl +++ b/glm/gtx/wrap.inl @@ -33,67 +33,46 @@ namespace glm { template - 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 - GLM_FUNC_QUALIFIER tvec2 clamp - ( - tvec2 const & Texcoord - ) + GLM_FUNC_QUALIFIER tvec2 clamp(tvec2 const & Texcoord) { tvec2 Result; for(typename tvec2::size_type i = 0; i < tvec2::value_size(); ++i) - Result[i] = clamp(Texcoord[i]); + Result[i] = clamp_to_edge(Texcoord[i]); return Result; } template - GLM_FUNC_QUALIFIER tvec3 clamp - ( - tvec3 const & Texcoord - ) + GLM_FUNC_QUALIFIER tvec3 clamp(tvec3 const & Texcoord) { tvec3 Result; for(typename tvec3::size_type i = 0; i < tvec3::value_size(); ++i) - Result[i] = clamp(Texcoord[i]); + Result[i] = clamp_to_edge(Texcoord[i]); return Result; } template - GLM_FUNC_QUALIFIER tvec4 clamp - ( - tvec4 const & Texcoord - ) + GLM_FUNC_QUALIFIER tvec4 clamp(tvec4 const & Texcoord) { tvec4 Result; for(typename tvec4::size_type i = 0; i < tvec4::value_size(); ++i) - Result[i] = clamp(Texcoord[i]); + Result[i] = clamp_to_edge(Texcoord[i]); return Result; } - //////////////////////// - // repeat - - template - GLM_FUNC_QUALIFIER genType repeat - ( - genType const & Texcoord - ) + template + GLM_FUNC_QUALIFIER genType repeat(genType const & Texcoord) { return glm::fract(Texcoord); } - template - GLM_FUNC_QUALIFIER tvec2 repeat - ( - tvec2 const & Texcoord - ) + template + GLM_FUNC_QUALIFIER tvec2 repeat(tvec2 const & Texcoord) { tvec2 Result; for(typename tvec2::size_type i = 0; i < tvec2::value_size(); ++i) @@ -101,11 +80,8 @@ namespace glm return Result; } - template - GLM_FUNC_QUALIFIER tvec3 repeat - ( - tvec3 const & Texcoord - ) + template + GLM_FUNC_QUALIFIER tvec3 repeat(tvec3 const & Texcoord) { tvec3 Result; for(typename tvec3::size_type i = 0; i < tvec3::value_size(); ++i) @@ -113,11 +89,8 @@ namespace glm return Result; } - template - GLM_FUNC_QUALIFIER tvec4 repeat - ( - tvec4 const & Texcoord - ) + template + GLM_FUNC_QUALIFIER tvec4 repeat(tvec4 const & Texcoord) { tvec4 Result; for(typename tvec4::size_type i = 0; i < tvec4::value_size(); ++i) @@ -125,18 +98,47 @@ namespace glm return Result; } - //////////////////////// - // mirrorRepeat - - template - GLM_FUNC_QUALIFIER genType mirrorRepeat - ( - genType const & Texcoord - ) + template + 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 + GLM_FUNC_QUALIFIER tvec2 mirrorClamp(tvec2 const & Texcoord) + { + tvec2 Result; + for(typename tvec2::size_type i = 0; i < tvec2::value_size(); ++i) + Result[i] = mirrorClamp(Texcoord[i]); + return Result; + } + + template + GLM_FUNC_QUALIFIER tvec3 mirrorClamp(tvec3 const & Texcoord) + { + tvec3 Result; + for(typename tvec3::size_type i = 0; i < tvec3::value_size(); ++i) + Result[i] = mirrorClamp(Texcoord[i]); + return Result; + } + + template + GLM_FUNC_QUALIFIER tvec4 mirrorClamp(tvec4 const & Texcoord) + { + tvec4 Result; + for(typename tvec4::size_type i = 0; i < tvec4::value_size(); ++i) + Result[i] = mirrorClamp(Texcoord[i]); + return Result; + } + + template + 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 - GLM_FUNC_QUALIFIER tvec2 mirrorRepeat - ( - tvec2 const & Texcoord - ) + template + GLM_FUNC_QUALIFIER tvec2 mirrorRepeat(tvec2 const & Texcoord) { tvec2 Result; for(typename tvec2::size_type i = 0; i < tvec2::value_size(); ++i) @@ -159,11 +158,8 @@ namespace glm return Result; } - template - GLM_FUNC_QUALIFIER tvec3 mirrorRepeat - ( - tvec3 const & Texcoord - ) + template + GLM_FUNC_QUALIFIER tvec3 mirrorRepeat(tvec3 const & Texcoord) { tvec3 Result; for(typename tvec3::size_type i = 0; i < tvec3::value_size(); ++i) @@ -171,11 +167,8 @@ namespace glm return Result; } - template - GLM_FUNC_QUALIFIER tvec4 mirrorRepeat - ( - tvec4 const & Texcoord - ) + template + GLM_FUNC_QUALIFIER tvec4 mirrorRepeat(tvec4 const & Texcoord) { tvec4 Result; for(typename tvec4::size_type i = 0; i < tvec4::value_size(); ++i) diff --git a/readme.txt b/readme.md similarity index 65% rename from readme.txt rename to readme.md index 56645b7c..83ff6f8e 100644 --- a/readme.txt +++ b/readme.md @@ -1,108 +1,111 @@ -================================================================================ -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 +#include // glm::vec4 +#include // glm::mat4 +#include // 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::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 to perform std::hash on GLM types #320 +- Added for texcoord wrapping +- Added static components and precision members to all vector and quat types #350 +- Added .gitignore #349 -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 +- Updated list of compiler versions -Deprecation: +##### 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 +- Fixed isfinite with C++98 compilers #343 +- Fixed Intel compiler build error on Linux #354 +- Fixed use of libstdc++ with Clang #351 +- Fixed quaternion pow #346 + +##### 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 @@ -115,17 +118,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 @@ -138,10 +140,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 @@ -161,7 +162,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 @@ -181,7 +182,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 @@ -192,7 +193,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 @@ -201,9 +202,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 @@ -223,9 +223,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 @@ -240,9 +239,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 @@ -254,9 +252,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) @@ -267,9 +264,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 @@ -307,9 +303,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 @@ -323,9 +318,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 @@ -334,9 +328,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 @@ -347,9 +340,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 @@ -361,9 +353,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 @@ -376,9 +367,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 @@ -389,9 +379,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 @@ -400,9 +389,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 @@ -411,9 +399,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 @@ -424,32 +411,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 @@ -459,9 +442,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 @@ -475,55 +457,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 @@ -531,42 +505,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 @@ -574,315 +541,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 -================================================================================ diff --git a/test/core/core_func_common.cpp b/test/core/core_func_common.cpp index 9a7c5d94..7911a72f 100644 --- a/test/core/core_func_common.cpp +++ b/test/core/core_func_common.cpp @@ -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); diff --git a/test/core/core_func_integer_bit_count.cpp b/test/core/core_func_integer_bit_count.cpp index 8af4a8d6..c72d63e6 100644 --- a/test/core/core_func_integer_bit_count.cpp +++ b/test/core/core_func_integer_bit_count.cpp @@ -210,7 +210,7 @@ int main() # ifdef NDEBUG int i, n; - static int test[] = {0,0, 1,1, 2,1, 3,2, 4,1, 5,2, 6,2, 7,3, + static unsigned test[] = {0,0, 1,1, 2,1, 3,2, 4,1, 5,2, 6,2, 7,3, 8,1, 9,2, 10,2, 11,3, 12,2, 13,3, 14,3, 15,4, 16,1, 17,2, 0x3F,6, 0x40,1, 0x41,2, 0x7f,7, 0x80,1, 0x81,2, 0xfe,7, 0xff,8, 0x4000,1, 0x4001,2, 0x7000,3, 0x7fff,15, @@ -230,7 +230,7 @@ int main() if (pop0(test[i]) != test[i+1]) error(test[i], pop0(test[i]));} TimestampEnd = std::clock(); - printf("pop0: %d clocks\n", TimestampEnd - TimestampBeg); + printf("pop0: %ld clocks\n", TimestampEnd - TimestampBeg); TimestampBeg = std::clock(); for (std::size_t k = 0; k < Count; ++k) @@ -238,7 +238,7 @@ int main() if (pop1(test[i]) != test[i+1]) error(test[i], pop1(test[i]));} TimestampEnd = std::clock(); - printf("pop1: %d clocks\n", TimestampEnd - TimestampBeg); + printf("pop1: %ld clocks\n", TimestampEnd - TimestampBeg); TimestampBeg = std::clock(); for (std::size_t k = 0; k < Count; ++k) @@ -246,7 +246,7 @@ int main() if (pop2(test[i]) != test[i+1]) error(test[i], pop2(test[i]));} TimestampEnd = std::clock(); - printf("pop2: %d clocks\n", TimestampEnd - TimestampBeg); + printf("pop2: %ld clocks\n", TimestampEnd - TimestampBeg); TimestampBeg = std::clock(); for (std::size_t k = 0; k < Count; ++k) @@ -254,7 +254,7 @@ int main() if (pop3(test[i]) != test[i+1]) error(test[i], pop3(test[i]));} TimestampEnd = std::clock(); - printf("pop3: %d clocks\n", TimestampEnd - TimestampBeg); + printf("pop3: %ld clocks\n", TimestampEnd - TimestampBeg); TimestampBeg = std::clock(); for (std::size_t k = 0; k < Count; ++k) @@ -262,7 +262,7 @@ int main() if (pop4(test[i]) != test[i+1]) error(test[i], pop4(test[i]));} TimestampEnd = std::clock(); - printf("pop4: %d clocks\n", TimestampEnd - TimestampBeg); + printf("pop4: %ld clocks\n", TimestampEnd - TimestampBeg); TimestampBeg = std::clock(); for (std::size_t k = 0; k < Count; ++k) @@ -270,7 +270,7 @@ int main() if (pop5(test[i]) != test[i+1]) error(test[i], pop5(test[i]));} TimestampEnd = std::clock(); - printf("pop5: %d clocks\n", TimestampEnd - TimestampBeg); + printf("pop5: %ld clocks\n", TimestampEnd - TimestampBeg); TimestampBeg = std::clock(); for (std::size_t k = 0; k < Count; ++k) @@ -278,7 +278,7 @@ int main() if (pop5a(test[i]) != test[i+1]) error(test[i], pop5a(test[i]));} TimestampEnd = std::clock(); - printf("pop5a: %d clocks\n", TimestampEnd - TimestampBeg); + printf("pop5a: %ld clocks\n", TimestampEnd - TimestampBeg); TimestampBeg = std::clock(); for (std::size_t k = 0; k < Count; ++k) @@ -286,7 +286,7 @@ int main() if (pop6(test[i]) != test[i+1]) error(test[i], pop6(test[i]));} TimestampEnd = std::clock(); - printf("pop6: %d clocks\n", TimestampEnd - TimestampBeg); + printf("pop6: %ld clocks\n", TimestampEnd - TimestampBeg); TimestampBeg = std::clock(); for (std::size_t k = 0; k < Count; ++k) @@ -295,7 +295,7 @@ int main() if (pop7(test[i]) != test[i+1]) error(test[i], pop7(test[i]));} TimestampEnd = std::clock(); - printf("pop7: %d clocks\n", TimestampEnd - TimestampBeg); + printf("pop7: %ld clocks\n", TimestampEnd - TimestampBeg); TimestampBeg = std::clock(); for (std::size_t k = 0; k < Count; ++k) @@ -304,7 +304,7 @@ int main() if (pop8(test[i]) != test[i+1]) error(test[i], pop8(test[i]));} TimestampEnd = std::clock(); - printf("pop8: %d clocks\n", TimestampEnd - TimestampBeg); + printf("pop8: %ld clocks\n", TimestampEnd - TimestampBeg); TimestampBeg = std::clock(); for (std::size_t k = 0; k < Count; ++k) @@ -313,7 +313,7 @@ int main() if (pop9(test[i]) != test[i+1]) error(test[i], pop9(test[i]));} TimestampEnd = std::clock(); - printf("pop9: %d clocks\n", TimestampEnd - TimestampBeg); + printf("pop9: %ld clocks\n", TimestampEnd - TimestampBeg); if (errors == 0) printf("Passed all %d cases.\n", sizeof(test)/8); diff --git a/test/core/core_func_trigonometric.cpp b/test/core/core_func_trigonometric.cpp index fa391151..abadc6f5 100644 --- a/test/core/core_func_trigonometric.cpp +++ b/test/core/core_func_trigonometric.cpp @@ -30,17 +30,12 @@ /////////////////////////////////////////////////////////////////////////////////// #include -/* -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; } diff --git a/test/core/core_setup_message.cpp b/test/core/core_setup_message.cpp index 0955f2e1..6c9a3765 100644 --- a/test/core/core_setup_message.cpp +++ b/test/core/core_setup_message.cpp @@ -62,6 +62,15 @@ int test_compiler() case GLM_COMPILER_GCC50: std::printf("GLM_COMPILER_GCC50\n"); break; + case GLM_COMPILER_GCC51: + std::printf("GLM_COMPILER_GCC51\n"); + break; + case GLM_COMPILER_GCC52: + std::printf("GLM_COMPILER_GCC52\n"); + break; + case GLM_COMPILER_GCC53: + std::printf("GLM_COMPILER_GCC53\n"); + break; default: std::printf("GCC version not detected\n"); Error += 1; @@ -94,6 +103,9 @@ int test_compiler() case GLM_COMPILER_APPLE_CLANG60: std::printf("GLM_COMPILER_APPLE_CLANG60\n"); break; + case GLM_COMPILER_APPLE_CLANG61: + std::printf("GLM_COMPILER_APPLE_CLANG61\n"); + break; default: std::printf("Apple Clang version not detected\n"); break; @@ -115,6 +127,18 @@ int test_compiler() case GLM_COMPILER_LLVM35: std::printf("GLM_COMPILER_LLVM35\n"); break; + case GLM_COMPILER_LLVM36: + std::printf("GLM_COMPILER_LLVM36\n"); + break; + case GLM_COMPILER_LLVM37: + std::printf("GLM_COMPILER_LLVM37\n"); + break; + case GLM_COMPILER_LLVM38: + std::printf("GLM_COMPILER_LLVM38\n"); + break; + case GLM_COMPILER_LLVM39: + std::printf("GLM_COMPILER_LLVM39\n"); + break; default: std::printf("LLVM version not detected\n"); break; @@ -139,6 +163,9 @@ int test_compiler() case GLM_COMPILER_INTEL15: std::printf("GLM_COMPILER_INTEL15\n"); break; + case GLM_COMPILER_INTEL16: + std::printf("GLM_COMPILER_INTEL16\n"); + break; default: std::printf("Intel compiler version not detected\n"); Error += 1; @@ -196,7 +223,7 @@ int test_instruction_set() int test_cpp_version() { - std::printf("__cplusplus: %d\n", __cplusplus); + std::printf("__cplusplus: %ld\n", __cplusplus); return 0; } diff --git a/test/core/core_type_vec1.cpp b/test/core/core_type_vec1.cpp index 24d1796a..67917844 100644 --- a/test/core/core_type_vec1.cpp +++ b/test/core/core_type_vec1.cpp @@ -29,6 +29,9 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// +#if !(GLM_COMPILER & GLM_COMPILER_GCC) +# define GLM_META_PROG_HELPERS +#endif #define GLM_SWIZZLE #include #include @@ -131,6 +134,7 @@ int test_vec1_size() Error += 8 == sizeof(glm::highp_dvec1) ? 0 : 1; Error += glm::vec1().length() == 1 ? 0 : 1; Error += glm::dvec1().length() == 1 ? 0 : 1; + Error += glm::vec1::components == 1 ? 0 : 1; return Error; } @@ -169,6 +173,10 @@ int main() glm::vec1 v; assert(v.length() == 1); +# ifdef GLM_META_PROG_HELPERS + assert(glm::vec1::components == 1); +# endif + Error += test_vec1_size(); Error += test_vec1_ctor(); Error += test_vec1_operators(); diff --git a/test/core/core_type_vec2.cpp b/test/core/core_type_vec2.cpp index 1b545c43..2b8f8575 100644 --- a/test/core/core_type_vec2.cpp +++ b/test/core/core_type_vec2.cpp @@ -8,14 +8,14 @@ /// 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 @@ -29,6 +29,9 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// +#if !(GLM_COMPILER & GLM_COMPILER_GCC) +# define GLM_META_PROG_HELPERS +#endif #define GLM_SWIZZLE #include #include @@ -102,81 +105,81 @@ int test_vec2_operators() { glm::vec2 A(1.0f, 2.0f); glm::vec2 B(4.0f, 5.0f); - + glm::vec2 C = A + B; Error += C == glm::vec2(5, 7) ? 0 : 1; - + glm::vec2 D = B - A; Error += D == glm::vec2(3, 3) ? 0 : 1; - + glm::vec2 E = A * B; Error += E == glm::vec2(4, 10) ? 0 : 1; - + glm::vec2 F = B / A; Error += F == glm::vec2(4, 2.5) ? 0 : 1; - + glm::vec2 G = A + 1.0f; Error += G == glm::vec2(2, 3) ? 0 : 1; - + glm::vec2 H = B - 1.0f; Error += H == glm::vec2(3, 4) ? 0 : 1; - + glm::vec2 I = A * 2.0f; Error += I == glm::vec2(2, 4) ? 0 : 1; - + glm::vec2 J = B / 2.0f; Error += J == glm::vec2(2, 2.5) ? 0 : 1; - + glm::vec2 K = 1.0f + A; Error += K == glm::vec2(2, 3) ? 0 : 1; - + glm::vec2 L = 1.0f - B; Error += L == glm::vec2(-3, -4) ? 0 : 1; - + glm::vec2 M = 2.0f * A; Error += M == glm::vec2(2, 4) ? 0 : 1; - + glm::vec2 N = 2.0f / B; Error += N == glm::vec2(0.5, 2.0 / 5.0) ? 0 : 1; } - + { glm::vec2 A(1.0f, 2.0f); glm::vec2 B(4.0f, 5.0f); - + A += B; Error += A == glm::vec2(5, 7) ? 0 : 1; - + A += 1.0f; Error += A == glm::vec2(6, 8) ? 0 : 1; } { glm::vec2 A(1.0f, 2.0f); glm::vec2 B(4.0f, 5.0f); - + B -= A; Error += B == glm::vec2(3, 3) ? 0 : 1; - + B -= 1.0f; Error += B == glm::vec2(2, 2) ? 0 : 1; } { glm::vec2 A(1.0f, 2.0f); glm::vec2 B(4.0f, 5.0f); - + A *= B; Error += A == glm::vec2(4, 10) ? 0 : 1; - + A *= 2.0f; Error += A == glm::vec2(8, 20) ? 0 : 1; } { glm::vec2 A(1.0f, 2.0f); glm::vec2 B(4.0f, 5.0f); - + B /= A; Error += B == glm::vec2(4, 2.5) ? 0 : 1; - + B /= 2.0f; Error += B == glm::vec2(2, 1.25) ? 0 : 1; } @@ -186,39 +189,39 @@ int test_vec2_operators() B /= B.y; Error += B == glm::vec2(1.0f) ? 0 : 1; } - + { glm::vec2 A(1.0f, 2.0f); glm::vec2 B = -A; Error += B == glm::vec2(-1.0f, -2.0f) ? 0 : 1; } - + { glm::vec2 A(1.0f, 2.0f); glm::vec2 B = --A; Error += B == glm::vec2(0.0f, 1.0f) ? 0 : 1; } - + { glm::vec2 A(1.0f, 2.0f); glm::vec2 B = A--; Error += B == glm::vec2(1.0f, 2.0f) ? 0 : 1; Error += A == glm::vec2(0.0f, 1.0f) ? 0 : 1; } - + { glm::vec2 A(1.0f, 2.0f); glm::vec2 B = ++A; Error += B == glm::vec2(2.0f, 3.0f) ? 0 : 1; } - + { glm::vec2 A(1.0f, 2.0f); glm::vec2 B = A++; Error += B == glm::vec2(1.0f, 2.0f) ? 0 : 1; Error += A == glm::vec2(2.0f, 3.0f) ? 0 : 1; } - + return Error; } @@ -283,14 +286,15 @@ int test_vec2_ctor() int test_vec2_size() { int Error = 0; - + Error += sizeof(glm::vec2) == sizeof(glm::mediump_vec2) ? 0 : 1; Error += 8 == sizeof(glm::mediump_vec2) ? 0 : 1; Error += sizeof(glm::dvec2) == sizeof(glm::highp_dvec2) ? 0 : 1; Error += 16 == sizeof(glm::highp_dvec2) ? 0 : 1; Error += glm::vec2().length() == 2 ? 0 : 1; Error += glm::dvec2().length() == 2 ? 0 : 1; - + Error += glm::vec2::components == 2 ? 0 : 1; + return Error; } @@ -328,6 +332,10 @@ int main() glm::vec2 v; assert(v.length() == 2); +# ifdef GLM_META_PROG_HELPERS + assert(glm::vec2::components == 2); +# endif + Error += test_vec2_size(); Error += test_vec2_ctor(); Error += test_vec2_operators(); diff --git a/test/core/core_type_vec3.cpp b/test/core/core_type_vec3.cpp index 81d8ed35..e2ce6ee1 100644 --- a/test/core/core_type_vec3.cpp +++ b/test/core/core_type_vec3.cpp @@ -29,6 +29,9 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// +#if !(GLM_COMPILER & GLM_COMPILER_GCC) +# define GLM_META_PROG_HELPERS +#endif #define GLM_SWIZZLE #include #include @@ -263,7 +266,7 @@ int test_vec3_size() Error += 24 == sizeof(glm::highp_dvec3) ? 0 : 1; Error += glm::vec3().length() == 3 ? 0 : 1; Error += glm::dvec3().length() == 3 ? 0 : 1; - + Error += glm::vec3::components == 3 ? 0 : 1; return Error; } @@ -494,6 +497,13 @@ int main() { int Error = 0; + glm::vec3 v; + assert(v.length() == 3); + +# ifdef GLM_META_PROG_HELPERS + assert(glm::vec3::components == 3); +# endif + Error += test_vec3_ctor(); Error += test_vec3_operators(); Error += test_vec3_size(); diff --git a/test/core/core_type_vec4.cpp b/test/core/core_type_vec4.cpp index fa724399..4c80f5ba 100644 --- a/test/core/core_type_vec4.cpp +++ b/test/core/core_type_vec4.cpp @@ -30,6 +30,9 @@ /////////////////////////////////////////////////////////////////////////////////// //#define GLM_FORCE_AVX2 +#if !(GLM_COMPILER & GLM_COMPILER_GCC) +# define GLM_META_PROG_HELPERS +#endif #define GLM_SWIZZLE #include #include @@ -398,7 +401,7 @@ int test_vec4_perf_AoS(std::size_t Size) std::clock_t EndTime = std::clock(); - std::printf("AoS: %d\n", EndTime - StartTime); + std::printf("AoS: %ld\n", EndTime - StartTime); return Error; } @@ -437,18 +440,48 @@ int test_vec4_perf_SoA(std::size_t Size) std::clock_t EndTime = std::clock(); - std::printf("SoA: %d\n", EndTime - StartTime); + std::printf("SoA: %ld\n", EndTime - StartTime); return Error; } +namespace heap +{ + class A + { + float f; + }; + + class B : public A + { + float g; + glm::vec4 v; + }; + + int test() + { + int Error(0); + + A* p = new B; + delete p; + + return Error; + } +}//namespace heap + int main() { int Error(0); - std::size_t const Size(1000000); + glm::vec4 v; + assert(v.length() == 4); + +# ifdef GLM_META_PROG_HELPERS + assert(glm::vec4::components == 4); +# endif # ifdef NDEBUG + std::size_t const Size(1000000); Error += test_vec4_perf_AoS(Size); Error += test_vec4_perf_SoA(Size); # endif//NDEBUG @@ -458,6 +491,7 @@ int main() Error += test_vec4_operators(); Error += test_vec4_swizzle_partial(); Error += test_operator_increment(); + Error += heap::test(); return Error; } diff --git a/test/gtc/gtc_bitfield.cpp b/test/gtc/gtc_bitfield.cpp index 3f1c1ed1..5e4accf5 100644 --- a/test/gtc/gtc_bitfield.cpp +++ b/test/gtc/gtc_bitfield.cpp @@ -631,11 +631,13 @@ namespace bitfieldInterleave std::printf("glm::detail::bitfieldInterleave Time %d clocks\n", static_cast(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); diff --git a/test/gtc/gtc_color.cpp b/test/gtc/gtc_color.cpp index 77759dac..03bd0261 100644 --- a/test/gtc/gtc_color.cpp +++ b/test/gtc/gtc_color.cpp @@ -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 diff --git a/test/gtc/gtc_integer.cpp b/test/gtc/gtc_integer.cpp index 64d9377c..df1d3fdb 100644 --- a/test/gtc/gtc_integer.cpp +++ b/test/gtc/gtc_integer.cpp @@ -99,7 +99,7 @@ namespace log2_ std::clock_t End = clock(); - printf("glm::log2: %d clocks\n", End - Begin); + printf("glm::log2: %ld clocks\n", End - Begin); } { @@ -113,7 +113,7 @@ namespace log2_ std::clock_t End = clock(); - printf("glm::log2: %d clocks\n", End - Begin); + printf("glm::log2: %ld clocks\n", End - Begin); } # if GLM_HAS_BITSCAN_WINDOWS @@ -135,7 +135,7 @@ namespace log2_ std::clock_t End = clock(); - printf("glm::log2 inlined: %d clocks\n", End - Begin); + printf("glm::log2 inlined: %ld clocks\n", End - Begin); } @@ -155,7 +155,7 @@ namespace log2_ std::clock_t End = clock(); - printf("glm::log2 inlined no cast: %d clocks\n", End - Begin); + printf("glm::log2 inlined no cast: %ld clocks\n", End - Begin); } @@ -175,7 +175,7 @@ namespace log2_ std::clock_t End = clock(); - printf("glm::log2 reinterpret: %d clocks\n", End - Begin); + printf("glm::log2 reinterpret: %ld clocks\n", End - Begin); } # endif//GLM_HAS_BITSCAN_WINDOWS @@ -190,7 +190,7 @@ namespace log2_ std::clock_t End = clock(); - printf("glm::log2: %d clocks\n", End - Begin); + printf("glm::log2: %ld clocks\n", End - Begin); } { @@ -204,7 +204,7 @@ namespace log2_ std::clock_t End = clock(); - printf("glm::log2: %d clocks\n", End - Begin); + printf("glm::log2: %ld clocks\n", End - Begin); } return Error; diff --git a/test/gtc/gtc_quaternion.cpp b/test/gtc/gtc_quaternion.cpp index 8818827e..d9b3ddf1 100644 --- a/test/gtc/gtc_quaternion.cpp +++ b/test/gtc/gtc_quaternion.cpp @@ -8,14 +8,14 @@ /// 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 @@ -29,6 +29,7 @@ /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// +#define GLM_META_PROG_HELPERS #include #include #include @@ -324,6 +325,8 @@ int main() { int Error(0); + assert(glm::quat::components == 4); + Error += test_quat_ctr(); Error += test_quat_mul_vec(); Error += test_quat_two_axis_ctr(); diff --git a/test/gtx/CMakeLists.txt b/test/gtx/CMakeLists.txt index 4be4343f..be39a6c5 100644 --- a/test/gtx/CMakeLists.txt +++ b/test/gtx/CMakeLists.txt @@ -48,3 +48,4 @@ glmCreateTestGTC(gtx_string_cast) glmCreateTestGTC(gtx_type_aligned) glmCreateTestGTC(gtx_vector_angle) glmCreateTestGTC(gtx_vector_query) +glmCreateTestGTC(gtx_wrap) diff --git a/test/gtx/gtx_compatibility.cpp b/test/gtx/gtx_compatibility.cpp index bd727318..ee577b06 100644 --- a/test/gtx/gtx_compatibility.cpp +++ b/test/gtx/gtx_compatibility.cpp @@ -35,5 +35,15 @@ int main() { int Error(0); + Error += glm::isfinite(1.0f) ? 0 : 1; + Error += glm::isfinite(1.0) ? 0 : 1; + Error += glm::isfinite(-1.0f) ? 0 : 1; + Error += glm::isfinite(-1.0) ? 0 : 1; + + Error += glm::all(glm::isfinite(glm::vec4(1.0f))) ? 0 : 1; + Error += glm::all(glm::isfinite(glm::dvec4(1.0))) ? 0 : 1; + Error += glm::all(glm::isfinite(glm::vec4(-1.0f))) ? 0 : 1; + Error += glm::all(glm::isfinite(glm::dvec4(-1.0))) ? 0 : 1; + return Error; } diff --git a/test/gtx/gtx_fast_trigonometry.cpp b/test/gtx/gtx_fast_trigonometry.cpp index eb73157b..cf5515bd 100644 --- a/test/gtx/gtx_fast_trigonometry.cpp +++ b/test/gtx/gtx_fast_trigonometry.cpp @@ -31,10 +31,16 @@ #include #include +#include +#include #include #include +#include +#include +#include #include #include +#include namespace fastCos { @@ -43,12 +49,15 @@ namespace fastCos const float begin = -glm::pi(); const float end = glm::pi(); float result = 0.f; + const std::clock_t timestamp1 = std::clock(); - for(float i=begin; i(); const float end = glm::pi(); float result = 0.f; + const std::clock_t timestamp1 = std::clock(); - for (float i = begin; i(); const float end = glm::pi(); float result = 0.f; + const std::clock_t timestamp1 = std::clock(); - for (float i = begin; i(); const float end = glm::pi(); float result = 0.f; + const std::clock_t timestamp1 = std::clock(); - for (float i = begin; i(time_fast)); std::printf("acos Time %d clocks\n", static_cast(time_default)); @@ -144,10 +163,10 @@ namespace fastAsin const float end = glm::pi(); float result = 0.f; const std::clock_t timestamp1 = std::clock(); - for (float i = begin; i(); float result = 0.f; const std::clock_t timestamp1 = std::clock(); - for (float i = begin; i() * 0.5f, glm::pi() * 1.0f, glm::pi() * 1.5f); + + template class vecType> + GLM_FUNC_QUALIFIER vecType taylorSeriesNewCos(vecType const & x) + { + vecType const Powed2(x * x); + vecType const Powed4(Powed2 * Powed2); + vecType const Powed6(Powed4 * Powed2); + vecType const Powed8(Powed4 * Powed4); + + return static_cast(1) + - Powed2 * static_cast(0.5) + + Powed4 * static_cast(0.04166666666666666666666666666667) + - Powed6 * static_cast(0.00138888888888888888888888888889) + + Powed8 * static_cast(2.4801587301587301587301587301587e-5); + } + + template class vecType> + GLM_FUNC_QUALIFIER vecType taylorSeriesNewCos6(vecType const & x) + { + vecType const Powed2(x * x); + vecType const Powed4(Powed2 * Powed2); + vecType const Powed6(Powed4 * Powed2); + + return static_cast(1) + - Powed2 * static_cast(0.5) + + Powed4 * static_cast(0.04166666666666666666666666666667) + - Powed6 * static_cast(0.00138888888888888888888888888889); + } + + template class vecType> + GLM_FUNC_QUALIFIER vecType fastAbs(vecType x) + { + int* Pointer = reinterpret_cast(&x[0]); + Pointer[0] &= 0x7fffffff; + Pointer[1] &= 0x7fffffff; + Pointer[2] &= 0x7fffffff; + Pointer[3] &= 0x7fffffff; + return x; + } + + template class vecType> + GLM_FUNC_QUALIFIER vecType fastCosNew(vecType const & x) + { + vecType const Angle0_PI(fastAbs(fmod(x + glm::pi(), glm::two_pi()) - glm::pi())); + return taylorSeriesNewCos6(x); +/* + vecType const FirstQuarterPi(lessThanEqual(Angle0_PI, vecType(glm::half_pi()))); + + vecType const RevertAngle(mix(vecType(glm::pi()), vecType(0), FirstQuarterPi)); + vecType const ReturnSign(mix(vecType(-1), vecType(1), FirstQuarterPi)); + vecType const SectionAngle(RevertAngle - Angle0_PI); + + return ReturnSign * taylorSeriesNewCos(SectionAngle); +*/ + } + + int perf_fastCosNew(float Begin, float End, std::size_t Samples) + { + std::vector 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] = 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 class vecType> + GLM_FUNC_QUALIFIER vecType deterministic_fmod(vecType const & x, T y) + { + return x - y * trunc(x / y); + } + + template class vecType> + GLM_FUNC_QUALIFIER vecType fastCosDeterminisctic(vecType const & x) + { + vecType const Angle0_PI(abs(deterministic_fmod(x + glm::pi(), glm::two_pi()) - glm::pi())); + vecType const FirstQuarterPi(lessThanEqual(Angle0_PI, vecType(glm::half_pi()))); + + vecType const RevertAngle(mix(vecType(glm::pi()), vecType(0), FirstQuarterPi)); + vecType const ReturnSign(mix(vecType(-1), vecType(1), FirstQuarterPi)); + vecType const SectionAngle(RevertAngle - Angle0_PI); + + return ReturnSign * taylorSeriesNewCos(SectionAngle); + } + + int perf_fastCosDeterminisctic(float Begin, float End, std::size_t Samples) + { + std::vector 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 class vecType> + GLM_FUNC_QUALIFIER vecType taylorSeriesRefCos(vecType const & x) + { + return static_cast(1) + - (x * x) / glm::factorial(static_cast(2)) + + (x * x * x * x) / glm::factorial(static_cast(4)) + - (x * x * x * x * x * x) / glm::factorial(static_cast(6)) + + (x * x * x * x * x * x * x * x) / glm::factorial(static_cast(8)); + } + + template class vecType> + GLM_FUNC_QUALIFIER vecType fastRefCos(vecType const & x) + { + vecType const Angle0_PI(glm::abs(fmod(x + glm::pi(), glm::two_pi()) - glm::pi())); +// return taylorSeriesRefCos(Angle0_PI); + + vecType const FirstQuarterPi(lessThanEqual(Angle0_PI, vecType(glm::half_pi()))); + + vecType const RevertAngle(mix(vecType(glm::pi()), vecType(0), FirstQuarterPi)); + vecType const ReturnSign(mix(vecType(-1), vecType(1), FirstQuarterPi)); + vecType const SectionAngle(RevertAngle - Angle0_PI); + + return ReturnSign * taylorSeriesRefCos(SectionAngle); + } + + int perf_fastCosRef(float Begin, float End, std::size_t Samples) + { + std::vector 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 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 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 const End = glm::pi(); + 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(); Angle < 4.0f * glm::pi(); 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(); diff --git a/test/gtx/gtx_type_aligned.cpp b/test/gtx/gtx_type_aligned.cpp index aeff2b7e..b69a6307 100644 --- a/test/gtx/gtx_type_aligned.cpp +++ b/test/gtx/gtx_type_aligned.cpp @@ -47,7 +47,7 @@ int test_decl() glm::vec4 B; }; - printf("vec4 - Aligned: %d, unaligned: %d\n", sizeof(S1), sizeof(S2)); + printf("vec4 - Aligned: %ld, unaligned: %ld\n", sizeof(S1), sizeof(S2)); Error += sizeof(S1) >= sizeof(S2) ? 0 : 1; } @@ -65,7 +65,7 @@ int test_decl() glm::aligned_vec3 B; }; - printf("vec3: %d, aligned: %d\n", sizeof(S1), sizeof(S2)); + printf("vec3: %ld, aligned: %ld\n", sizeof(S1), sizeof(S2)); Error += sizeof(S1) <= sizeof(S2) ? 0 : 1; } @@ -83,7 +83,7 @@ int test_decl() glm::vec4 B; }; - printf("vec4 - Aligned: %d, unaligned: %d\n", sizeof(S1), sizeof(S2)); + printf("vec4 - Aligned: %ld, unaligned: %ld\n", sizeof(S1), sizeof(S2)); Error += sizeof(S1) >= sizeof(S2) ? 0 : 1; } @@ -101,7 +101,7 @@ int test_decl() glm::dvec4 B; }; - printf("dvec4 - Aligned: %d, unaligned: %d\n", sizeof(S1), sizeof(S2)); + printf("dvec4 - Aligned: %ld, unaligned: %ld\n", sizeof(S1), sizeof(S2)); Error += sizeof(S1) >= sizeof(S2) ? 0 : 1; } diff --git a/test/gtx/gtx_wrap.cpp b/test/gtx/gtx_wrap.cpp new file mode 100644 index 00000000..b65d94ba --- /dev/null +++ b/test/gtx/gtx_wrap.cpp @@ -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 +#include + +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; +} diff --git a/util/CMakeLists.txt b/util/CMakeLists.txt deleted file mode 100644 index 3deeb15b..00000000 --- a/util/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/FindGLM.cmake - DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}/cmake) - diff --git a/util/FindGLM.cmake b/util/FindGLM.cmake deleted file mode 100644 index 2d900929..00000000 --- a/util/FindGLM.cmake +++ /dev/null @@ -1,63 +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/glm.hpp OR -# /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}") - - MESSAGE(STATUS "GLM_INCLUDE_DIR = ${GLM_INCLUDE_DIR}") -ENDIF(GLM_FOUND)