You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.4 KiB

  1. ///////////////////////////////////////////////////////////////////////////////////////////////////
  2. // OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net)
  3. ///////////////////////////////////////////////////////////////////////////////////////////////////
  4. // Created : 2005-12-21
  5. // Updated : 2005-12-27
  6. // Licence : This source is under MIT License
  7. // File : glm/gtx/optimum_pow.inl
  8. ///////////////////////////////////////////////////////////////////////////////////////////////////
  9. namespace glm
  10. {
  11. template <typename genType>
  12. GLM_FUNC_QUALIFIER genType pow2(const genType& x)
  13. {
  14. return x * x;
  15. }
  16. template <typename genType>
  17. GLM_FUNC_QUALIFIER genType pow3(const genType& x)
  18. {
  19. return x * x * x;
  20. }
  21. template <typename genType>
  22. GLM_FUNC_QUALIFIER genType pow4(const genType& x)
  23. {
  24. return x * x * x * x;
  25. }
  26. GLM_FUNC_QUALIFIER bool powOfTwo(int x)
  27. {
  28. return !(x & (x - 1));
  29. }
  30. GLM_FUNC_QUALIFIER detail::tvec2<bool> powOfTwo(const detail::tvec2<int>& x)
  31. {
  32. return detail::tvec2<bool>(
  33. powOfTwo(x.x),
  34. powOfTwo(x.y));
  35. }
  36. GLM_FUNC_QUALIFIER detail::tvec3<bool> powOfTwo(const detail::tvec3<int>& x)
  37. {
  38. return detail::tvec3<bool>(
  39. powOfTwo(x.x),
  40. powOfTwo(x.y),
  41. powOfTwo(x.z));
  42. }
  43. GLM_FUNC_QUALIFIER detail::tvec4<bool> powOfTwo(const detail::tvec4<int>& x)
  44. {
  45. return detail::tvec4<bool>(
  46. powOfTwo(x.x),
  47. powOfTwo(x.y),
  48. powOfTwo(x.z),
  49. powOfTwo(x.w));
  50. }
  51. }//namespace glm