glm/test/external/gli/core/levels.inl
John McFarlane 506a487d24 parameterize number of dimensions of vector in tvec<D, T, P>
- specializes for 1, 2, 3 and 4-dimensional vector types
  which are then aliased as tvec1, tvec2, tvec3 and tvec4
- requires C++11 aliases; breaks compatability with C++03
- tested on:
  - clang-3.5.2, clang-3.8.0
  - gcc 4.8.5, gcc 5.4.1, gcc 6.2.0

TODO:
- still uses template template parameters - most can probably be removed
- some definitions might now be de-duplicated
2016-12-28 17:07:12 -08:00

24 lines
528 B
C++

#include <glm/gtc/integer.hpp>
#include <glm/gtx/component_wise.hpp>
namespace gli
{
template <int D, typename T, precision P, template <int, typename, precision> class vecType>
inline T levels(vecType<D, T, P> const& Extent)
{
return glm::log2(compMax(Extent)) + static_cast<T>(1);
}
template <typename T>
inline T levels(T Extent)
{
return static_cast<T>(glm::log2(Extent) + static_cast<size_t>(1));
}
/*
inline int levels(int Extent)
{
return glm::log2(Extent) + static_cast<int>(1);
}
*/
}//namespace gli