2
3
4
5
6
7
8
11#ifndef _GLSL_STRUCT_BASE_STRUCT_HPP_
12 #define _GLSL_STRUCT_BASE_STRUCT_HPP_
14 #include <glslstruct/config.hpp>
17_GLSL_STRUCT_ERROR(
"This is only available for c++17 and greater!");
20 #include <glslstruct/layout/base_layout.hpp>
21 #include <glslstruct/value/glsl_value.hpp>
25
26
27
28
52 #pragma region TYPE_CHECKS
133 #pragma region GET_VALUE_DATA
162 #pragma region GET_VALUE_FROM_DATA
371 "Type mismatch! (If you don't want to see this error disable type checks)");
387 "Type mismatch! (If you don't want to see this error disable type checks)");
407 "Type mismatch! (If you don't want to see this error disable type checks)");
423 "Type mismatch! (If you don't want to see this error disable type checks)");
443 "Type mismatch! (If you don't want to see this error disable type checks)");
459 "Type mismatch! (If you don't want to see this error disable type checks)");
482 "Type mismatch! (If you don't want to see this error disable type checks)");
492 "Type mismatch! (If you don't want to see this error disable type checks)");
556 "Type mismatch! (If you don't want to see this error disable type checks)");
566 "Type mismatch! (If you don't want to see this error disable type checks)");
587 "Type mismatch! (If you don't want to see this error disable type checks)");
597 "Type mismatch! (If you don't want to see this error disable type checks)");
617 "Type mismatch! (If you don't want to see this error disable type checks)");
628 "Type mismatch! (If you don't want to see this error disable type checks)");
655 "Type mismatch! (If you don't want to see this error disable type checks)");
665 "Type mismatch! (If you don't want to see this error disable type checks)");
684 #pragma region CONSTRUCTORS
768 #pragma region ADD_SCALAR
773 template<
class S, std::enable_if_t<is_glsl_scalar_v<S> && std::is_default_constructible_v<S>,
bool> =
true>
776 const std::string_view name
785 template<
class S, std::enable_if_t<is_glsl_scalar_v<S>,
bool> =
true>
793 #pragma region ADD_SCALARS_ARRAYS
798 template<
class S, std::enable_if_t<is_glsl_scalar_v<S>,
bool> =
true>
851 #pragma region ADD_VEC
876 #pragma region ADD_VEC_ARRAYS
928 #pragma region ADD_MAT
953 #pragma region ADD_MAT_ARRAYS
1005 #pragma region ADD_STRUCT
1032 #pragma region ADD_STRUCT_ARRAYS
1058 #pragma region SET_SCALAR
1081 #pragma region SET_SCALARS_ARRAYS
1133 #pragma region SET_VEC
1156 #pragma region SET_VEC_ARRAYS
1208 #pragma region SET_MAT
1231 #pragma region SET_MAT_ARRAYS
1283 #pragma region SET_STRUCT
1310 #pragma region SET_STRUCT_ARRAYS
1335 #pragma region GET_SCALARS
1348 #pragma region GET_SCALARS_ARRAYS
1374 #pragma region GET_VEC
1387 #pragma region GET_VEC_ARRAYS
1413 #pragma region GET_MAT
1426 #pragma region GET_MAT_ARRAYS
1452 #pragma region GET_STRUCT
1465 #pragma region GET_STRUCT_ARRAYS
1511 #if _GLSL_STRUCT_HAS_CXX20
1591
1592
1593
1594
1595template<
class Layout>
1596struct std::hash<glslstruct::base_struct<Layout> > {
1597 size_t operator()(
const glslstruct::base_struct<Layout>& glslStruct) {
1599 mstd::hash_append(seed, glslStruct._layout);
1600 mstd::hash_range(seed, glslStruct._data.begin(), glslStruct._data.end());
base class for glsl struct representation
Definition base_struct.hpp:34
_GLSL_STRUCT_CONSTEXPR20 std::vector< size_t > add(const std::string_view name, const S *values, const size_t valuesCount)
adds array of scalars with pointer to values and size
Definition base_struct.hpp:800
_GLSL_STRUCT_CONSTEXPR20 ~base_struct() noexcept=default
default destructor
_GLSL_STRUCT_CONSTEXPR20 base_struct & operator=(const base_struct &other) noexcept=default
default copy assign operator
static _GLSL_STRUCT_CONSTEXPR20 std::vector< std::byte > _get_scalar_value_data(const T &value)
returns scalar data bytes
Definition base_struct.hpp:137
_GLSL_STRUCT_CONSTEXPR20 base_struct & operator=(base_struct &&other) noexcept
move assign operator
Definition base_struct.hpp:758
_GLSL_STRUCT_CONSTEXPR20 size_t add(const std::string_view name) _GLSL_STRUCT_REQUIRES(std
adds scalar with default value and returns offset
Definition base_struct.hpp:775
layout_type _layout
struct layout
Definition base_struct.hpp:47
static _GLSL_STRUCT_CONSTEXPR20 std::vector< std::byte > _get_vec_value_data(const T &value)
returns vec data bytes
Definition base_struct.hpp:143
_GLSL_STRUCT_CONSTEXPR20 size_t add(const std::string_view name, const S &value)
adds scalar and returns offset
Definition base_struct.hpp:787
std::vector< std::byte > _data
struct data
Definition base_struct.hpp:49
_GLSL_STRUCT_CONSTEXPR20 base_struct(base_struct &&other) noexcept
move constructor
Definition base_struct.hpp:746
static _GLSL_STRUCT_CONSTEXPR17 size_t bad_offset() noexcept
invalid offset value returned when there is error
Definition base_struct.hpp:765
Layout layout_type
struct layout type
Definition base_struct.hpp:37
#define _GLSL_STRUCT_TYPENAME17
Definition config.hpp:216
#define _GLSL_STRUCT_HAS_TYPE_CHECKS
check if user enabled type checks for struct getters using GLSL_STRUCT_ENABLE_TYPE_CHECKS (remember i...
Definition config.hpp:173
#define _GLSL_STRUCT_CONSTEXPR20
constexpr keyword for c++20 and higher
Definition config.hpp:213
#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
#define _GLSL_STRUCT_REQUIRES(condition)
requires keyword for c++20 and higher
Definition config.hpp:214
#define _GLSL_STRUCT_HAS_TYPES
check if user not disabled type containers using GLSL_STRUCT_DISABLE_TYPES
Definition config.hpp:162
#define _GLSL_STRUCT_CONSTEXPR17
constexpr for c++17 and higher
Definition config.hpp:196
Main namespace of glslstruct library.
Definition contexts.hpp:20
check if type is simple glsl type or struct with given layout
Definition base_struct.hpp:44