summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGfx/VectorN.h
diff options
context:
space:
mode:
authorJelle Raaijmakers <jelle@gmta.nl>2022-12-12 00:32:11 +0100
committerAndreas Kling <kling@serenityos.org>2022-12-20 10:42:31 +0100
commit8c094699dbb9e409e6ee0d82412f1f81372e35fe (patch)
tree873e01cea8aecde9a656cd59fdc398f05980382c /Userland/Libraries/LibGfx/VectorN.h
parenta074b7e871c3776e66abfb676051f3fefbf53fd7 (diff)
downloadserenity-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.h20
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;