GLSL Struct 1.4.0
glslstruct
Loading...
Searching...
No Matches
mat_type.hpp
1/*
2 * glslstruct - a C++ library designed to easily represent GLSL's Uniform Buffer Objects (UBOs) and Shader Storage Buffer Objects (SSBOs) in C++.
3 *
4 * Licensed under the BSD 3-Clause License with Attribution Requirement.
5 * See the LICENSE file for details: https://github.com/MAIPA01/glslstruct/blob/main/LICENSE
6 *
7 * Copyright (c) 2025, Patryk Antosik (MAIPA01)
8 */
9
10#pragma once
11#ifndef _GLSL_STRUCT_MAT_TYPE_HPP_
12 #define _GLSL_STRUCT_MAT_TYPE_HPP_
13
14 #include <glslstruct/config.hpp>
15
17_GLSL_STRUCT_ERROR(
18 "This is only available for c++17 and greater and when types are not disabled with defined GLSL_STRUCT_DISABLE_TYPES!"
19);
20 #else
21
22 #include <glslstruct/type/containers/type.hpp>
23
24namespace glslstruct {
25 /**
26 * @brief mat type container
27 * @ingroup glsl_types
28 */
29 class mat_type : public type<mat_type> {
30 private:
31 friend struct std::hash<mat_type>;
32
33 using base_type = type;
34
35 /// @brief number of columns
36 size_t _cols;
37 /// @brief number of rows
38 size_t _rows;
39 /// @brief scalar type of mat
40 ValueType _type;
41
42 public:
43 /// @brief constructor with scalar type, number of columns and rows of mat and size of type
44 mat_type(ValueType type, size_t cols, size_t rows, size_t size) noexcept;
45 /// @brief default copy constructor
46 mat_type(const mat_type& other) noexcept;
47 /// @brief default move constructor
48 mat_type(mat_type&& other) noexcept;
49 /// @brief default destructor
50 ~mat_type() noexcept override;
51
52 /// @brief default copy assign operator
53 mat_type& operator=(const mat_type& other) noexcept;
54 /// @brief default move assign operator
55 mat_type& operator=(mat_type&& other) noexcept;
56
57 /// @brief accept function for type visitors
59 template<type_visitor T>
60 #else
61 template<class T, std::enable_if_t<is_type_visitor_v<T>, bool> = true>
62 #endif
63 void accept(T& visitor) const {
64 visitor.visit(*this);
65 }
66
67 /// @brief returns scalar type of mat
68 [[nodiscard]] ValueType get_type() const noexcept;
69 /// @brief returns rows number
70 [[nodiscard]] size_t get_rows() const noexcept;
71 /// @brief returns columns number
72 [[nodiscard]] size_t get_cols() const noexcept;
73 /// @brief returns column vector length (rows)
74 [[nodiscard]] size_t get_vec_length() const noexcept;
75 /// @brief returns column vectors number (columns)
76 [[nodiscard]] size_t get_array_count() const noexcept;
77
78 /// @brief converts type to string
79 [[nodiscard]] std::string to_string() const noexcept override;
80
81 friend bool operator==(const mat_type& lhs, const mat_type& rhs) noexcept;
82 friend bool operator!=(const mat_type& lhs, const mat_type& rhs) noexcept;
83 };
84
85 /**
86 * @brief checks if two mats types are equal
87 * @ingroup glsl_types
88 */
89 [[nodiscard]] bool operator==(const mat_type& lhs, const mat_type& rhs) noexcept;
90 /**
91 * @brief checks if two mats types are not equal
92 * @ingroup glsl_types
93 */
94 [[nodiscard]] bool operator!=(const mat_type& lhs, const mat_type& rhs) noexcept;
95} // namespace glslstruct
96
97/**
98 * @brief std::hash overload for mat_type
99 * @ingroup glsl_types
100 */
101template<>
102struct std::hash<glslstruct::mat_type> {
103 [[nodiscard]] size_t operator()(const glslstruct::mat_type& value) const noexcept;
104};
105 #endif
106#endif
#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_TYPES
check if user not disabled type containers using GLSL_STRUCT_DISABLE_TYPES
Definition config.hpp:162
Main namespace of glslstruct library.
Definition scalar_layout_traits.hpp:23