blob: 83fa67a3ec295299fb0875a9b4dc61d89f5a2a17 (
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
|
#pragma once
#include <mbgl/math/clamp.hpp>
#include <cassert>
#include <limits>
namespace mbgl {
namespace gl {
template <class T>
class Normalized {
public:
T value;
Normalized() : value(0) {}
explicit Normalized(float f)
: value(static_cast<T>(std::numeric_limits<T>::max() * util::clamp(f, 0.0f, 1.0f))) {
assert(f >= 0.0f);
assert(f <= 1.0f);
}
float denormalized() const {
return float(value) / std::numeric_limits<T>::max();
}
};
template <class T>
bool operator==(const Normalized<T>& lhs, const Normalized<T>& rhs) {
return lhs.value == rhs.value;
}
} // namespace gl
} // namespace mbgl
|