43 value_type x, y, z, w;
47 value_type r, g, b, a;
51 value_type s, t, p, q;
59 constexpr t_vec4(
const t_vec4& v) :
60 value{v.x, v.y, v.z, v.w} {}
61 constexpr t_vec4& operator=(
const t_vec4&) =
default;
63 constexpr t_vec4(value_type in_x, value_type in_y, value_type in_z, value_type in_w) :
64 value{in_x, in_y, in_z, in_w} {}
66 constexpr explicit t_vec4(
const VkClearColorValue& v) :
67 value{
static_cast<value_type
>(v.float32[0]),
static_cast<value_type
>(v.float32[1]),
static_cast<value_type
>(v.float32[2]),
static_cast<value_type
>(v.float32[3])} {}
70 constexpr explicit t_vec4(
const t_vec4<R>& v) :
71 value{
static_cast<T
>(v.x),
static_cast<T
>(v.y),
static_cast<T
>(v.z),
static_cast<T
>(v.w)} {}
74 constexpr t_vec4(
const t_vec2<R>& v, value_type in_z, value_type in_w) :
75 value{
static_cast<T
>(v.x),
static_cast<T
>(v.y), in_z, in_w} {}
78 constexpr t_vec4(
const t_vec3<R>& v, value_type in_w) :
79 value{
static_cast<T
>(v.x),
static_cast<T
>(v.y),
static_cast<T
>(v.z), in_w} {}
81 constexpr std::size_t size()
const {
return 4; }
83 value_type& operator[](std::size_t i) {
return value[i]; }
84 value_type operator[](std::size_t i)
const {
return value[i]; }
87 t_vec4& operator=(
const t_vec4<R>& rhs)
89 value[0] =
static_cast<value_type
>(rhs[0]);
90 value[1] =
static_cast<value_type
>(rhs[1]);
91 value[2] =
static_cast<value_type
>(rhs[2]);
92 value[3] =
static_cast<value_type
>(rhs[3]);
96 t_vec4& operator=(
const VkClearColorValue& v)
98 value[0] =
static_cast<value_type
>(v.float32[0]);
99 value[1] =
static_cast<value_type
>(v.float32[1]);
100 value[2] =
static_cast<value_type
>(v.float32[2]);
101 value[3] =
static_cast<value_type
>(v.float32[3]);
105 T* data() {
return value; }
106 const T* data()
const {
return value; }
108 void set(value_type in_x, value_type in_y, value_type in_z, value_type in_w)
116 inline t_vec4& operator+=(
const t_vec4& rhs)
118 value[0] += rhs.value[0];
119 value[1] += rhs.value[1];
120 value[2] += rhs.value[2];
121 value[3] += rhs.value[3];
125 inline t_vec4& operator-=(
const t_vec4& rhs)
127 value[0] -= rhs.value[0];
128 value[1] -= rhs.value[1];
129 value[2] -= rhs.value[2];
130 value[3] -= rhs.value[3];
134 inline t_vec4& operator*=(value_type rhs)
143 inline t_vec4& operator*=(
const t_vec4& rhs)
145 value[0] *= rhs.value[0];
146 value[1] *= rhs.value[1];
147 value[2] *= rhs.value[2];
148 value[3] *= rhs.value[3];
152 friend constexpr t_vec4<T> operator*(
const t_vec4<T>& lhs, T rhs)
154 return t_vec4<T>(lhs[0] * rhs, lhs[1] * rhs, lhs[2] * rhs, lhs[3] * rhs);
157 friend constexpr t_vec4<T> operator*(T lhs,
const t_vec4<T>& rhs)
159 return t_vec4<T>(lhs * rhs[0], lhs * rhs[1], lhs * rhs[2], lhs * rhs[3]);
162 inline t_vec4& operator/=(value_type rhs)
164 if constexpr (std::is_floating_point_v<value_type>)
166 value_type inv = numbers<value_type>::one() / rhs;
182 operator VkClearColorValue()
const noexcept {
return VkClearColorValue{{r, g, b, a}}; }
184 explicit operator bool()
const noexcept {
return value[0] != numbers<value_type>::zero() || value[1] != numbers<value_type>::zero() || value[2] != numbers<value_type>::zero() || value[3] != numbers<value_type>::zero(); }