diff options
author | Jelle Raaijmakers <jelle@gmta.nl> | 2022-12-12 00:32:11 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-12-20 10:42:31 +0100 |
commit | 8c094699dbb9e409e6ee0d82412f1f81372e35fe (patch) | |
tree | 873e01cea8aecde9a656cd59fdc398f05980382c /Userland/Libraries/LibGfx/VectorN.h | |
parent | a074b7e871c3776e66abfb676051f3fefbf53fd7 (diff) | |
download | serenity-8c094699dbb9e409e6ee0d82412f1f81372e35fe.zip |
LibGL: Implement `glLightModel` integer normalization
For the ambient light model, integers need to be remapped to a range of
`-1.` through `1.`. Add the `+` and `-` operators to `VectorN` to make
it a bit easier to normalize 4 values at once.
Diffstat (limited to 'Userland/Libraries/LibGfx/VectorN.h')
-rw-r--r-- | Userland/Libraries/LibGfx/VectorN.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGfx/VectorN.h b/Userland/Libraries/LibGfx/VectorN.h index 7e67a72695..687c0ea7df 100644 --- a/Userland/Libraries/LibGfx/VectorN.h +++ b/Userland/Libraries/LibGfx/VectorN.h @@ -159,6 +159,26 @@ public: } template<typename U> + [[nodiscard]] constexpr VectorN operator+(U f) const + { + VectorN result; + UNROLL_LOOP + for (auto i = 0u; i < N; ++i) + result.m_data[i] = m_data[i] + f; + return result; + } + + template<typename U> + [[nodiscard]] constexpr VectorN operator-(U f) const + { + VectorN result; + UNROLL_LOOP + for (auto i = 0u; i < N; ++i) + result.m_data[i] = m_data[i] - f; + return result; + } + + template<typename U> [[nodiscard]] constexpr VectorN operator*(U f) const { VectorN result; |