CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
ShaderSource.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
10#include "ShaderType.hpp"
11
14
17
18namespace CeresEngine {
19
23 Source,
24
26 Binary,
27 };
28
41 public:
44
45 public:
48 ShaderType type = ShaderType::Undefined;
49
52
53 public:
56 ShaderBinary() noexcept;
57
61 explicit ShaderBinary(ShaderType shaderType, BinaryBuffer binary) noexcept;
62
67 ShaderBinary(ShaderType shaderType, const unsigned char* binary, size_t length);
68
73
77 ShaderBinary& operator=(const ShaderBinary& other);
78
81 ShaderBinary(ShaderBinary&& other) noexcept;
82
86 ShaderBinary& operator=(ShaderBinary&& other) noexcept;
87
88 public:
90 [[nodiscard]] CE_SCRIPT_EXPORT()
91 bool isValid() const noexcept;
92
94 explicit operator bool() const noexcept;
95
96 public:
99 template<typename Processor> static constexpr void reflect(Processor&& RTTI) {
100 CE_REFL_DATA(type);
101 CE_REFL_DATA(data);
102 }
103 };
104
113 public:
116 ShaderType type = ShaderType::Undefined;
117
120 String source;
121
122 public:
127 explicit ShaderSource(ShaderType type, String source) noexcept;
128
132 explicit ShaderSource(ShaderType type, const char* source);
133
138
142 ShaderSource& operator=(const ShaderSource& other);
143
146 ShaderSource(ShaderSource&& other) noexcept;
147
151 ShaderSource& operator=(ShaderSource&& other) noexcept;
152
153 public:
156 template<typename Processor> static constexpr void reflect(Processor&& RTTI) {
157 CE_REFL_DATA(type);
158 CE_REFL_DATA(source);
159 }
160 };
161
162} // namespace CeresEngine
163
165template<> struct std::hash<CeresEngine::ShaderType> {
166 inline size_t operator()(const CeresEngine::ShaderType object) const noexcept { return CeresEngine::hash(object.raw); }
167};
168
169
170
#define CE_REFL_DATA(N)
Definition Macros.hpp:541
#define CE_SCRIPT_EXPORT(...)
The CE_SCRIPT_EXPORT macro marks a class or method as exportable and available in scripting environme...
Definition Macros.hpp:247
A ShaderBinary is an object responsible for wrapping the binary representation of a shader (i....
Definition ShaderSource.hpp:40
Vector< char > BinaryBuffer
A binary buffer type.
Definition ShaderSource.hpp:43
A ShaderSource is an object responsible for wrapping the textual representation of a shader (i....
Definition ShaderSource.hpp:112
Definition Application.hpp:19
std::vector< T, ScopedAllocatorAdaptor< StdAllocator< T, RawAllocator > > > Vector
Vector is a sequence container that encapsulates dynamic size arrays.
Definition Vector.hpp:17
ShaderSourceType
Shader source type enumeration.
Definition ShaderSource.hpp:21
@ Binary
Refers to pre-compiled shader binary.
@ Source
Refers to a high-level source code.
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
Shader type enumeration.
Definition ShaderType.hpp:59