HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
src
TTauri
Foundation
R8SNorm.hpp
1
// Copyright 2020 Pokitec
2
// All rights reserved.
3
4
#pragma once
5
6
#include "TTauri/Foundation/numeric_cast.hpp"
7
#include <algorithm>
8
9
namespace
tt {
10
11
[[nodiscard]]
constexpr
int8_t make_R8SNorm_value(
float
rhs)
noexcept
12
{
13
return
numeric_cast<int8_t>(std::clamp(rhs, -1.0f, 1.0f) * 127.0f);
14
}
15
16
struct
R8SNorm
{
17
int8_t value;
18
19
R8SNorm
() =
default
;
20
R8SNorm
(
R8SNorm
const
&rhs)
noexcept
=
default
;
21
R8SNorm
(
R8SNorm
&&rhs)
noexcept
=
default
;
22
R8SNorm
&operator=(
R8SNorm
const
&rhs)
noexcept
=
default
;
23
R8SNorm
&operator=(
R8SNorm
&&rhs)
noexcept
=
default
;
24
~R8SNorm
() =
default
;
25
26
explicit
R8SNorm
(
float
rhs) noexcept :
27
value(make_R8SNorm_value(rhs)) {}
28
29
R8SNorm
&operator=(
float
rhs)
noexcept
{
30
value = make_R8SNorm_value(rhs);
31
return
*
this
;
32
}
33
34
explicit
operator
float ()
const
noexcept
{
35
return
numeric_cast<float>(value) / 127.0f;
36
}
37
};
38
39
}
tt::R8SNorm
Definition
R8SNorm.hpp:16
Generated on Mon Apr 22 2024 12:53:56 for HikoGUI by
1.10.0