2
3
4
5
6
7
8
11#ifndef _GLSL_STRUCT_SCALAR_TRAITS_HPP_
12 #define _GLSL_STRUCT_SCALAR_TRAITS_HPP_
14 #include <glslstruct/config.hpp>
17_GLSL_STRUCT_ERROR(
"This is only available for c++17 and greater!");
20 #include <glslstruct/type/data/scalar_data.hpp>
21 #include <glslstruct/utils/ValueType.hpp>
24 #pragma region DEFAULT_TRAITS
27
28
29
31 struct scalar_traits<
bool> {
33 static ValueType get_value_type()
noexcept;
36 static scalar_data get_data(
bool value);
39 static bool get_value(
const scalar_data& data);
43
44
45
47 struct scalar_traits<
int> {
49 static ValueType get_value_type()
noexcept;
52 static scalar_data get_data(
int value);
55 static int get_value(
const scalar_data& data);
59
60
61
63 struct scalar_traits<
unsigned int> {
65 static ValueType get_value_type()
noexcept;
68 static scalar_data get_data(
unsigned int value);
71 static unsigned int get_value(
const scalar_data& data);
75
76
77
79 struct scalar_traits<
float> {
81 static ValueType get_value_type()
noexcept;
84 static scalar_data get_data(
float value);
87 static float get_value(
const scalar_data& data);
91
92
93
95 struct scalar_traits<
double> {
97 static ValueType get_value_type()
noexcept;
100 static scalar_data get_data(
double value);
103 static double get_value(
const scalar_data& data);
108 #pragma region FUNCTIONS
111 template<utils::glsl_scalar T>
113 template<
class T, std::enable_if_t<utils::is_glsl_scalar_v<T>,
bool> =
true>
115 static inline ValueType get_scalar_value_type()
noexcept {
116 return scalar_traits<T>::get_value_type();
121 template<utils::glsl_scalar T>
123 template<
class T, std::enable_if_t<utils::is_glsl_scalar_v<T>,
bool> =
true>
125 static inline scalar_data get_scalar_data(
const T& value) {
126 return scalar_traits<T>::get_data(value);
131 template<utils::glsl_scalar T>
133 template<
class T, std::enable_if_t<utils::is_glsl_scalar_v<T>,
bool> =
true>
135 static inline T get_scalar_value(
const scalar_data& data) {
136 return scalar_traits<T>::get_value(data);
140 std::string scalar_to_string(ValueType valueType);
144 template<utils::glsl_scalar T>
146 template<
class T, std::enable_if_t<utils::is_glsl_scalar_v<T>,
bool> =
true>
148 static inline std::string scalar_to_string() {
149 return scalar_to_string(get_scalar_value_type<T>());
#define _GLSL_STRUCT_HAS_CXX20
check if compiler has c++ version greater or equal to c++20 and if user enabled c++20 features using ...
Definition config.hpp:142
#define _GLSL_STRUCT_HAS_CXX17
check if compiler has c++ version greater or equal to c++17
Definition config.hpp:130