summaryrefslogtreecommitdiff
path: root/src/glm/gtx/optimum_pow.inl
blob: a941ec37a82e9b7ad3d956703a6ab47619749bf4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2005-12-21
// Updated : 2005-12-27
// Licence : This source is under MIT License
// File    : glm/gtx/optimum_pow.inl
///////////////////////////////////////////////////////////////////////////////////////////////////

namespace glm{
namespace gtx{
namespace optimum_pow{

    template <typename genType> 
    GLM_FUNC_QUALIFIER genType pow2(const genType& x)
    {
        return x * x;
    }

    template <typename genType> 
    GLM_FUNC_QUALIFIER genType pow3(const genType& x)
    {
        return x * x * x;
    }

    template <typename genType> 
    GLM_FUNC_QUALIFIER genType pow4(const genType& x)
    {
        return x * x * x * x;
    }

    GLM_FUNC_QUALIFIER bool powOfTwo(int x)
    {
        return !(x & (x - 1));
    }

    GLM_FUNC_QUALIFIER detail::tvec2<bool> powOfTwo(const detail::tvec2<int>& x)
    {
        return detail::tvec2<bool>(
            powOfTwo(x.x),
            powOfTwo(x.y));
    }

    GLM_FUNC_QUALIFIER detail::tvec3<bool> powOfTwo(const detail::tvec3<int>& x)
    {
        return detail::tvec3<bool>(
            powOfTwo(x.x),
            powOfTwo(x.y),
            powOfTwo(x.z));
    }

    GLM_FUNC_QUALIFIER detail::tvec4<bool> powOfTwo(const detail::tvec4<int>& x)
    {
        return detail::tvec4<bool>(
            powOfTwo(x.x),
            powOfTwo(x.y),
            powOfTwo(x.z),
            powOfTwo(x.w));
    }

}//namespace optimum_pow
}//namespace gtx
}//namespace glm