Radium Engine  1.5.20
Loading...
Searching...
No Matches
RawShaderMaterial.hpp
1#pragma once
2
3#include <Engine/RaEngine.hpp>
4
5#include <Core/Asset/MaterialData.hpp>
6#include <Engine/Data/Material.hpp>
7
8namespace Ra {
9namespace Engine {
10namespace Data {
11// Predeclare the External/Internal material representation converter
12class RawShaderMaterialConverter;
13} // namespace Data
14} // namespace Engine
15
16namespace Core {
17namespace Asset {
18
22class RA_ENGINE_API RawShaderMaterialData : public MaterialData
23{
26
27 public:
36 const std::string& instanceName,
39 MaterialData( instanceName, "Ra::Engine::Data::RawShaderMaterial" ),
40 m_shaders { shaders },
41 m_paramProvider { std::move( paramProvider ) } {}
42 RawShaderMaterialData() = delete;
44 ~RawShaderMaterialData() = default;
45
46 private:
49};
50
51} // namespace Asset
52} // namespace Core
53
54namespace Engine {
55namespace Data {
61class RA_ENGINE_API RawShaderMaterialConverter final
62{
63 public:
66 inline Material* operator()( const Ra::Core::Asset::MaterialData* toconvert );
67};
68
73class RA_ENGINE_API RawShaderMaterial : public Material
74{
75 public:
83 explicit RawShaderMaterial(
84 const std::string& instanceName,
87
88 ~RawShaderMaterial() override;
89
94
99 inline Data::RenderParameters& getParameters() override;
100
105 inline const Data::RenderParameters& getParameters() const override;
106
110 void registerDefaultTechnique();
111
121 void updateShaders( const std::vector<std::pair<Data::ShaderType, std::string>>& shaders,
122 std::shared_ptr<Data::ShaderParameterProvider> paramProvider = nullptr );
123
128 void updateGL() override final;
129
135 static void registerMaterial();
136
141 static void unregisterMaterial();
142
143 private:
147 std::string computeKey();
148
149 std::vector<std::pair<Data::ShaderType, std::string>> m_shaders;
150 std::shared_ptr<Data::ShaderParameterProvider> m_paramProvider;
151 std::string m_materialKey {};
152};
153
154inline Material*
155RawShaderMaterialConverter::operator()( const Ra::Core::Asset::MaterialData* toconvert ) {
156 auto mat = static_cast<const Core::Asset::RawShaderMaterialData*>( toconvert );
157 return new RawShaderMaterial( mat->getName(), mat->m_shaders, mat->m_paramProvider );
158}
159
161 return m_paramProvider->getParameters();
162}
163
165 return m_paramProvider->getParameters();
166}
167
168} // namespace Data
169} // namespace Engine
170} // namespace Ra
represent material data loaded by a file loader. Material data must be identified by a unique name....
RawShaderMaterialData(const std::string &instanceName, const std::vector< std::pair< Ra::Engine::Data::ShaderType, std::string > > &shaders, std::shared_ptr< Ra::Engine::Data::ShaderParameterProvider > paramProvider)
Base class for materials.
Definition Material.hpp:24
Data::RenderParameters & getParameters() override
RawShaderMaterial(const RawShaderMaterial &)=delete
Management of shader parameters with automatic binding of a named parameter to the corresponding glsl...
Shader program parameter provider.
hepler function to manage enum as underlying types in VariableSet
Definition Cage.cpp:3
STL namespace.