Skip to content

Commit

Permalink
fixed frexp and ldexp
Browse files Browse the repository at this point in the history
Should resolve #31

Also updated to latest glm version
  • Loading branch information
Zuzu-Typ committed May 23, 2019
1 parent f9c3745 commit f2e47bf
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 68 deletions.
32 changes: 24 additions & 8 deletions PyGLM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16127,22 +16127,29 @@ static PyObject*
frexp_(PyObject* self, PyObject* args) {
PyObject *arg1, *arg2;
PyGLM_Arg_Unpack_2O(args, "frexp", arg1, arg2);
int i = 0;
glm::frexp(9.f,i);
if (PyGLM_Vec2_Check(arg1) && PyObject_TypeCheck(arg2, &vec2Type)) {
glm::vec2 o;
unpack_vec2(arg1, &o);
return pack_vec2(glm::frexp(o, ((vec2*)arg2)->super_type));
glm::ivec2 o2 = ((vec2*)arg2)->super_type;
PyObject* out = pack_vec2(glm::frexp(o, o2));
((vec2*)arg2)->super_type = o2;
return out;
}
if (PyGLM_Vec3_Check(arg1) && PyObject_TypeCheck(arg2, &vec3Type)) {
glm::vec3 o;
unpack_vec3(arg1, &o);
return pack_vec3(glm::frexp(o, ((vec3*)arg2)->super_type));
glm::ivec3 o2 = ((vec3*)arg2)->super_type;
PyObject* out = pack_vec2(glm::frexp(o, o2));
((vec3*)arg2)->super_type = o2;
return out;
}
if (PyGLM_Vec4_Check(arg1) && PyObject_TypeCheck(arg2, &vec4Type)) {
glm::vec4 o;
unpack_vec4(arg1, &o);
return pack_vec4(glm::frexp(o, ((vec4*)arg2)->super_type));
glm::ivec4 o2 = ((vec4*)arg2)->super_type;
PyObject* out = pack_vec4(glm::frexp(o, o2));
((vec4*)arg2)->super_type = o2;
return out;
}
PyGLM_TYPEERROR_2O("invalid argument type(s) for frexp(): ", arg1, arg2);
return NULL;
Expand All @@ -16155,17 +16162,26 @@ ldexp_(PyObject* self, PyObject* args) {
if (PyGLM_Vec2_Check(arg1) && PyObject_TypeCheck(arg2, &vec2Type)) {
glm::vec2 o;
unpack_vec2(arg1, &o);
return pack_vec2(glm::ldexp(o, ((vec2*)arg2)->super_type));
glm::ivec2 o2 = ((vec2*)arg2)->super_type;
PyObject* out = pack_vec2(glm::ldexp(o, o2));
((vec2*)arg2)->super_type = o2;
return out;
}
if (PyGLM_Vec3_Check(arg1) && PyObject_TypeCheck(arg2, &vec3Type)) {
glm::vec3 o;
unpack_vec3(arg1, &o);
return pack_vec3(glm::ldexp(o, ((vec3*)arg2)->super_type));
glm::ivec3 o2 = ((vec3*)arg2)->super_type;
PyObject* out = pack_vec3(glm::ldexp(o, o2));
((vec3*)arg2)->super_type = o2;
return out;
}
if (PyGLM_Vec4_Check(arg1) && PyObject_TypeCheck(arg2, &vec4Type)) {
glm::vec4 o;
unpack_vec4(arg1, &o);
return pack_vec4(glm::ldexp(o, ((vec4*)arg2)->super_type));
glm::ivec4 o2 = ((vec4*)arg2)->super_type;
PyObject* out = pack_vec4(glm::ldexp(o, o2));
((vec4*)arg2)->super_type = o2;
return out;
}
PyGLM_TYPEERROR_2O("invalid argument type(s) for ldexp(): ", arg1, arg2);
return NULL;
Expand Down
8 changes: 4 additions & 4 deletions glm/glm/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,8 @@ namespace glm
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/frexp.xml">GLSL frexp man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<typename genType, typename genIType>
GLM_FUNC_DECL genType frexp(genType const& x, genIType& exp);
template<typename genType>
GLM_FUNC_DECL genType frexp(genType x, int& exp);

template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> frexp(vec<L, T, Q> const& v, vec<L, int, Q>& exp);
Expand All @@ -526,8 +526,8 @@ namespace glm
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/ldexp.xml">GLSL ldexp man page</a>;
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<typename genType, typename genIType>
GLM_FUNC_DECL genType ldexp(genType const& x, genIType const& exp);
template<typename genType>
GLM_FUNC_DECL genType ldexp(genType const& x, int const& exp);

template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> ldexp(vec<L, T, Q> const& v, vec<L, int, Q> const& exp);
Expand Down
4 changes: 2 additions & 2 deletions glm/glm/detail/setup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#define GLM_VERSION_MINOR 9
#define GLM_VERSION_PATCH 9
#define GLM_VERSION_REVISION 4
#define GLM_VERSION 995
#define GLM_VERSION_MESSAGE "GLM: version 0.9.9.5"
#define GLM_VERSION 996
#define GLM_VERSION_MESSAGE "GLM: version 0.9.9.6"

#define GLM_SETUP_INCLUDED GLM_VERSION

Expand Down
4 changes: 2 additions & 2 deletions glm/glm/detail/type_quat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ namespace glm

/// Explicit conversion operators
# if GLM_HAS_EXPLICIT_CONVERSION_OPERATORS
GLM_FUNC_DECL explicit operator mat<3, 3, T, Q>();
GLM_FUNC_DECL explicit operator mat<4, 4, T, Q>();
GLM_FUNC_DECL explicit operator mat<3, 3, T, Q>() const;
GLM_FUNC_DECL explicit operator mat<4, 4, T, Q>() const;
# endif

/// Create a quaternion from two normalized axis
Expand Down
4 changes: 2 additions & 2 deletions glm/glm/detail/type_quat.inl
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,13 @@ namespace detail

# if GLM_HAS_EXPLICIT_CONVERSION_OPERATORS
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER qua<T, Q>::operator mat<3, 3, T, Q>()
GLM_FUNC_QUALIFIER qua<T, Q>::operator mat<3, 3, T, Q>() const
{
return mat3_cast(*this);
}

template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER qua<T, Q>::operator mat<4, 4, T, Q>()
GLM_FUNC_QUALIFIER qua<T, Q>::operator mat<4, 4, T, Q>() const
{
return mat4_cast(*this);
}
Expand Down
2 changes: 1 addition & 1 deletion glm/glm/ext/scalar_constants.inl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace glm
template<typename genType>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType pi()
{
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'epsilon' only accepts floating-point inputs");
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'pi' only accepts floating-point inputs");
return static_cast<genType>(3.14159265358979323846264338327950288);
}
} //namespace glm
105 changes: 57 additions & 48 deletions glm/glm/simd/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@
#define GLM_COMPILER_VC15_5 0x01000005
#define GLM_COMPILER_VC15_6 0x01000006
#define GLM_COMPILER_VC15_7 0x01000007
#define GLM_COMPILER_VC15_8 0x01000008
#define GLM_COMPILER_VC15_9 0x01000009
#define GLM_COMPILER_VC16 0x0100000A

// GCC defines
#define GLM_COMPILER_GCC 0x02000000
Expand Down Expand Up @@ -99,31 +102,31 @@
# define GLM_COMPILER GLM_COMPILER_UNKNOWN

#elif defined(__INTEL_COMPILER)
# if (__INTEL_COMPILER < 1400)
# error "GLM requires ICC 2013 SP1 or newer"
# elif __INTEL_COMPILER == 1400
# 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
# elif __INTEL_COMPILER >= 1700
# if __INTEL_COMPILER >= 1700
# define GLM_COMPILER GLM_COMPILER_INTEL17
# elif __INTEL_COMPILER >= 1600
# define GLM_COMPILER GLM_COMPILER_INTEL16
# elif __INTEL_COMPILER >= 1500
# define GLM_COMPILER GLM_COMPILER_INTEL15
# elif __INTEL_COMPILER >= 1400
# define GLM_COMPILER GLM_COMPILER_INTEL14
# elif __INTEL_COMPILER < 1400
# error "GLM requires ICC 2013 SP1 or newer"
# endif

// CUDA
#elif defined(__CUDACC__)
# if !defined(CUDA_VERSION) && !defined(GLM_FORCE_CUDA)
# include <cuda.h> // make sure version is defined since nvcc does not define it itself!
# endif
# if CUDA_VERSION < 7000
# error "GLM requires CUDA 7.0 or higher"
# elif (CUDA_VERSION >= 7000 && CUDA_VERSION < 7500)
# define GLM_COMPILER GLM_COMPILER_CUDA70
# elif (CUDA_VERSION >= 7500 && CUDA_VERSION < 8000)
# define GLM_COMPILER GLM_COMPILER_CUDA75
# elif (CUDA_VERSION >= 8000)
# if CUDA_VERSION >= 8000
# define GLM_COMPILER GLM_COMPILER_CUDA80
# elif CUDA_VERSION >= 7500
# define GLM_COMPILER GLM_COMPILER_CUDA75
# elif CUDA_VERSION >= 7000
# define GLM_COMPILER GLM_COMPILER_CUDA70
# elif CUDA_VERSION < 7000
# error "GLM requires CUDA 7.0 or higher"
# endif

// Clang
Expand Down Expand Up @@ -166,44 +169,50 @@

// Visual C++
#elif defined(_MSC_VER)
# if _MSC_VER < 1800
# error "GLM requires Visual C++ 12 - 2013 or higher"
# elif _MSC_VER == 1800
# define GLM_COMPILER GLM_COMPILER_VC12
# elif _MSC_VER == 1900
# define GLM_COMPILER GLM_COMPILER_VC14
# elif _MSC_VER == 1910
# define GLM_COMPILER GLM_COMPILER_VC15
# elif _MSC_VER == 1911
# define GLM_COMPILER GLM_COMPILER_VC15_3
# elif _MSC_VER == 1912
# define GLM_COMPILER GLM_COMPILER_VC15_5
# elif _MSC_VER == 1913
# define GLM_COMPILER GLM_COMPILER_VC15_6
# if _MSC_VER >= 1920
# define GLM_COMPILER GLM_COMPILER_VC16
# elif _MSC_VER >= 1916
# define GLM_COMPILER GLM_COMPILER_VC15_9
# elif _MSC_VER >= 1915
# define GLM_COMPILER GLM_COMPILER_VC15_8
# elif _MSC_VER >= 1914
# define GLM_COMPILER GLM_COMPILER_VC15_7
# elif _MSC_VER >= 1913
# define GLM_COMPILER GLM_COMPILER_VC15_6
# elif _MSC_VER >= 1912
# define GLM_COMPILER GLM_COMPILER_VC15_5
# elif _MSC_VER >= 1911
# define GLM_COMPILER GLM_COMPILER_VC15_3
# elif _MSC_VER >= 1910
# define GLM_COMPILER GLM_COMPILER_VC15
# elif _MSC_VER >= 1900
# define GLM_COMPILER GLM_COMPILER_VC14
# elif _MSC_VER >= 1800
# define GLM_COMPILER GLM_COMPILER_VC12
# elif _MSC_VER < 1800
# error "GLM requires Visual C++ 12 - 2013 or higher"
# endif//_MSC_VER

// G++
#elif defined(__GNUC__) || defined(__MINGW32__)
# if ((__GNUC__ == 4) && (__GNUC_MINOR__ < 6)) || (__GNUC__ < 4)
# error "GLM requires GCC 4.7 or higher"
# elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 6)
# define GLM_COMPILER (GLM_COMPILER_GCC46)
# elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 7)
# define GLM_COMPILER (GLM_COMPILER_GCC47)
# elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 8)
# define GLM_COMPILER (GLM_COMPILER_GCC48)
# elif (__GNUC__ == 4) && (__GNUC_MINOR__ >= 9)
# define GLM_COMPILER (GLM_COMPILER_GCC49)
# elif (__GNUC__ == 5)
# define GLM_COMPILER (GLM_COMPILER_GCC5)
# elif (__GNUC__ == 6)
# define GLM_COMPILER (GLM_COMPILER_GCC6)
# elif (__GNUC__ == 7)
# define GLM_COMPILER (GLM_COMPILER_GCC7)
# elif (__GNUC__ >= 8)
# define GLM_COMPILER (GLM_COMPILER_GCC8)
# if __GNUC__ >= 8
# define GLM_COMPILER GLM_COMPILER_GCC8
# elif __GNUC__ >= 7
# define GLM_COMPILER GLM_COMPILER_GCC7
# elif __GNUC__ >= 6
# define GLM_COMPILER GLM_COMPILER_GCC6
# elif __GNUC__ >= 5
# define GLM_COMPILER GLM_COMPILER_GCC5
# elif __GNUC__ == 4 && __GNUC_MINOR__ >= 9
# define GLM_COMPILER GLM_COMPILER_GCC49
# elif __GNUC__ == 4 && __GNUC_MINOR__ >= 8
# define GLM_COMPILER GLM_COMPILER_GCC48
# elif __GNUC__ == 4 && __GNUC_MINOR__ >= 7
# define GLM_COMPILER GLM_COMPILER_GCC47
# elif __GNUC__ == 4 && __GNUC_MINOR__ >= 6
# define GLM_COMPILER GLM_COMPILER_GCC46
# elif ((__GNUC__ == 4) && (__GNUC_MINOR__ < 6)) || (__GNUC__ < 4)
# error "GLM requires GCC 4.6 or higher"
# endif

#else
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
# Versions should comply with PEP440. For a discussion on single-sourcing
# the version across setup.py and the project code, see
# https://packaging.python.org/en/latest/single_source_version.html
version='0.5.2b1',
version='0.5.3b1',

description='OpenGL Mathematics library for Python',
long_description=long_description,
Expand Down

0 comments on commit f2e47bf

Please sign in to comment.