From 2dda5af72cc59c79fe761768ed3a6762af8cb483 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Thu, 1 Dec 2016 23:05:43 +0100 Subject: [PATCH] Fixed GCC 4.5 and older build #566 --- glm/detail/setup.hpp | 5 +++++ glm/detail/type_vec1.hpp | 5 ++++- glm/detail/type_vec2.hpp | 5 ++++- glm/detail/type_vec3.hpp | 5 ++++- glm/detail/type_vec4.hpp | 7 +++++-- glm/gtc/color_space.inl | 4 ++-- glm/gtx/color_space.inl | 22 ++++++++++------------ readme.md | 1 + test/core/core_func_swizzle.cpp | 13 +++++++++---- test/core/core_setup_message.cpp | 2 +- test/core/core_type_vec3.cpp | 11 ++++++++--- 11 files changed, 53 insertions(+), 27 deletions(-) diff --git a/glm/detail/setup.hpp b/glm/detail/setup.hpp index d4bc89a2..4b2aac63 100644 --- a/glm/detail/setup.hpp +++ b/glm/detail/setup.hpp @@ -451,6 +451,11 @@ ((GLM_COMPILER & GLM_COMPILER_CUDA) && (GLM_COMPILER >= GLM_COMPILER_CUDA70)))) #endif +#define GLM_HAS_ONLY_XYZW ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER < GLM_COMPILER_GCC46)) +#if GLM_HAS_ONLY_XYZW +# pragma message("GLM: GCC older than 4.6 has a bug presenting the use of rgba and stpq components") +#endif + // #if GLM_LANG & GLM_LANG_CXX11_FLAG # define GLM_HAS_ASSIGNABLE 1 diff --git a/glm/detail/type_vec1.hpp b/glm/detail/type_vec1.hpp index 0d54ae00..c84837b2 100644 --- a/glm/detail/type_vec1.hpp +++ b/glm/detail/type_vec1.hpp @@ -27,7 +27,10 @@ namespace glm // -- Data -- -# if GLM_HAS_ALIGNED_TYPE +# if GLM_HAS_ONLY_XYZW + T x; + +# elif GLM_HAS_ALIGNED_TYPE # if GLM_COMPILER & GLM_COMPILER_GCC # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wpedantic" diff --git a/glm/detail/type_vec2.hpp b/glm/detail/type_vec2.hpp index d7f7c213..16349203 100644 --- a/glm/detail/type_vec2.hpp +++ b/glm/detail/type_vec2.hpp @@ -26,7 +26,10 @@ namespace glm // -- Data -- -# if GLM_HAS_ALIGNED_TYPE +# if GLM_HAS_ONLY_XYZW + T x, y; + +# elif GLM_HAS_ALIGNED_TYPE # if GLM_COMPILER & GLM_COMPILER_GCC # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wpedantic" diff --git a/glm/detail/type_vec3.hpp b/glm/detail/type_vec3.hpp index 4fcb9643..be133c98 100644 --- a/glm/detail/type_vec3.hpp +++ b/glm/detail/type_vec3.hpp @@ -26,7 +26,10 @@ namespace glm // -- Data -- -# if GLM_HAS_ALIGNED_TYPE +# if GLM_HAS_ONLY_XYZW + T x, y, z; + +# elif GLM_HAS_ALIGNED_TYPE # if GLM_COMPILER & GLM_COMPILER_GCC # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wpedantic" diff --git a/glm/detail/type_vec4.hpp b/glm/detail/type_vec4.hpp index c3923b4a..5538a919 100644 --- a/glm/detail/type_vec4.hpp +++ b/glm/detail/type_vec4.hpp @@ -26,7 +26,10 @@ namespace glm // -- Data -- -# if GLM_HAS_ALIGNED_TYPE +# if GLM_HAS_ONLY_XYZW + T x, y, z, w; + +# elif GLM_HAS_ALIGNED_TYPE # if GLM_COMPILER & GLM_COMPILER_GCC # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wpedantic" @@ -36,7 +39,7 @@ namespace glm # pragma clang diagnostic ignored "-Wgnu-anonymous-struct" # pragma clang diagnostic ignored "-Wnested-anon-types" # endif - + union { struct { T x, y, z, w;}; diff --git a/glm/gtc/color_space.inl b/glm/gtc/color_space.inl index 3fe293b0..c9a44efc 100644 --- a/glm/gtc/color_space.inl +++ b/glm/gtc/color_space.inl @@ -23,7 +23,7 @@ namespace detail { GLM_FUNC_QUALIFIER static tvec4 call(tvec4 const& ColorRGB, T GammaCorrection) { - return tvec4(compute_rgbToSrgb::call(tvec3(ColorRGB), GammaCorrection), ColorRGB.a); + return tvec4(compute_rgbToSrgb::call(tvec3(ColorRGB), GammaCorrection), ColorRGB.w); } }; @@ -44,7 +44,7 @@ namespace detail { GLM_FUNC_QUALIFIER static tvec4 call(tvec4 const& ColorSRGB, T Gamma) { - return tvec4(compute_srgbToRgb::call(tvec3(ColorSRGB), Gamma), ColorSRGB.a); + return tvec4(compute_srgbToRgb::call(tvec3(ColorSRGB), Gamma), ColorSRGB.w); } }; }//namespace detail diff --git a/glm/gtx/color_space.inl b/glm/gtx/color_space.inl index 43f66415..e7cd58d4 100644 --- a/glm/gtx/color_space.inl +++ b/glm/gtx/color_space.inl @@ -105,20 +105,18 @@ namespace glm { tvec3 rgbw = tvec3(T(0.2126), T(0.7152), T(0.0722)); - T col0 = (T(1) - s) * rgbw.r; - T col1 = (T(1) - s) * rgbw.g; - T col2 = (T(1) - s) * rgbw.b; + tvec3 const col((T(1) - s) * rgbw); tmat4x4 result(T(1)); - result[0][0] = col0 + s; - result[0][1] = col0; - result[0][2] = col0; - result[1][0] = col1; - result[1][1] = col1 + s; - result[1][2] = col1; - result[2][0] = col2; - result[2][1] = col2; - result[2][2] = col2 + s; + result[0][0] = col.x + s; + result[0][1] = col.x; + result[0][2] = col.x; + result[1][0] = col.y; + result[1][1] = col.y + s; + result[1][2] = col.y; + result[2][0] = col.z; + result[2][1] = col.z; + result[2][2] = col.z + s; return result; } diff --git a/readme.md b/readme.md index 97536b47..96d8a5e8 100644 --- a/readme.md +++ b/readme.md @@ -58,6 +58,7 @@ glm::mat4 camera(float Translate, glm::vec2 const & Rotate) - Fixed intersectRayPlane returns true in parallel case #578 - Fixed GCC 6.2 compiler warnings #580 - Fixed GTX_matrix_decompose decompose #582 #448 +- Fixed GCC 4.5 and older build #566 #### [GLM 0.9.8.3](https://github.com/g-truc/glm/releases/tag/0.9.8.3) - 2016-11-12 ##### Improvements: diff --git a/test/core/core_func_swizzle.cpp b/test/core/core_func_swizzle.cpp index dfd6c8af..cd2367a2 100644 --- a/test/core/core_func_swizzle.cpp +++ b/test/core/core_func_swizzle.cpp @@ -2,6 +2,8 @@ #define GLM_FORCE_SWIZZLE #include +#if !GLM_HAS_ONLY_XYZW + int test_ivec2_swizzle() { int Error = 0; @@ -60,16 +62,19 @@ int test_vec4_swizzle() return Error; } +#endif//!GLM_HAS_ONLY_XYZW int main() { int Error = 0; - Error += test_ivec2_swizzle(); - Error += test_ivec3_swizzle(); - Error += test_ivec4_swizzle(); +# if !GLM_HAS_ONLY_XYZW + Error += test_ivec2_swizzle(); + Error += test_ivec3_swizzle(); + Error += test_ivec4_swizzle(); - Error += test_vec4_swizzle(); + Error += test_vec4_swizzle(); +# endif//!GLM_HAS_ONLY_XYZW return Error; } diff --git a/test/core/core_setup_message.cpp b/test/core/core_setup_message.cpp index ff5caf41..1e6a5d06 100644 --- a/test/core/core_setup_message.cpp +++ b/test/core/core_setup_message.cpp @@ -226,7 +226,7 @@ int test_instruction_set() int test_cpp_version() { - std::printf("__cplusplus: %lld\n", __cplusplus); + std::printf("__cplusplus: %d\n", static_cast(__cplusplus)); return 0; } diff --git a/test/core/core_type_vec3.cpp b/test/core/core_type_vec3.cpp index c9370c17..cb27a327 100644 --- a/test/core/core_type_vec3.cpp +++ b/test/core/core_type_vec3.cpp @@ -334,6 +334,7 @@ int test_vec3_swizzle3_3() return Error; } +#if !GLM_HAS_ONLY_XYZW int test_vec3_swizzle_operators() { int Error = 0; @@ -440,6 +441,7 @@ int test_vec3_swizzle_partial() return Error; } +#endif//!GLM_HAS_ONLY_XYZW int test_operator_increment() { @@ -480,10 +482,13 @@ int main() Error += test_vec3_size(); Error += test_vec3_swizzle3_2(); Error += test_vec3_swizzle3_3(); - Error += test_vec3_swizzle_partial(); - Error += test_vec3_swizzle_operators(); - Error += test_vec3_swizzle_functions(); Error += test_operator_increment(); +# if !GLM_HAS_ONLY_XYZW + Error += test_vec3_swizzle_partial(); + Error += test_vec3_swizzle_operators(); + Error += test_vec3_swizzle_functions(); +# endif//!GLM_HAS_ONLY_XYZW + return Error; }