HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
sfloat_rgb32.hpp
1// Copyright Take Vos 2020.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
7#include "numeric_array.hpp"
8#include <algorithm>
9
10namespace hi::inline v1 {
11
13 // Red, Green, Blue in binary32 (native endian).
15
16public:
17 sfloat_rgb32() = default;
18 sfloat_rgb32(sfloat_rgb32 const &rhs) noexcept = default;
19 sfloat_rgb32(sfloat_rgb32 &&rhs) noexcept = default;
20 sfloat_rgb32 &operator=(sfloat_rgb32 const &rhs) noexcept = default;
21 sfloat_rgb32 &operator=(sfloat_rgb32 &&rhs) noexcept = default;
22
23 sfloat_rgb32(f32x4 const &rhs) noexcept : v{rhs.r(), rhs.g(), rhs.b()} {}
24
25 sfloat_rgb32 &operator=(f32x4 const &rhs) noexcept
26 {
27 v = {rhs.r(), rhs.g(), rhs.b()};
28 return *this;
29 }
30
31 operator f32x4() const noexcept
32 {
33 return f32x4{std::get<0>(v), std::get<1>(v), std::get<2>(v), 0.0f};
34 }
35
36 sfloat_rgb32(point3 const &rhs) noexcept : sfloat_rgb32(static_cast<f32x4>(rhs)) {}
37
38 sfloat_rgb32 &operator=(point3 const &rhs) noexcept
39 {
40 return *this = static_cast<f32x4>(rhs);
41 }
42
43 operator point3() const noexcept
44 {
45 return point3{f32x4{*this}};
46 }
47
48 [[nodiscard]] friend bool operator==(sfloat_rgb32 const &lhs, sfloat_rgb32 const &rhs) noexcept = default;
49};
50
51} // namespace hi::inline v1
Definition sfloat_rgb32.hpp:12