28 template <
typename Base>
34 template <
typename Base>
40 template <
typename Base>
46 template <
typename Base>
52 template <
typename Base>
54 iName{ aName }, iNeedFullUniformUpdate{ false }, iActive{ false }
64 template <
typename Base>
67 if (iHandle != std::nullopt)
68 service<i_rendering_engine>().destroy_shader_program_object(*iHandle);
71 template <
typename Base>
77 template <
typename Base>
80 for (
auto& stage : stages())
81 for (auto&
shader : stage->shaders())
87 template <
typename Base>
90 return iHandle != std::nullopt;
93 template <
typename Base>
98 auto newHandle = service<i_rendering_engine>().create_shader_program_object();
99 if (newHandle ==
nullptr)
106 template <
typename Base>
112 template <
typename Base>
118 template <
typename Base>
121 return stages().at(
static_cast<std::size_t
>(aStage));
124 template <
typename Base>
127 return stages().at(
static_cast<std::size_t
>(aStage));
130 template <
typename Base>
133 auto s = iShaderIndex.find(aName);
134 if (s != iShaderIndex.end())
139 template <
typename Base>
142 return const_cast<i_shader&
>(to_const(*this).shader(aName));
145 template <
typename Base>
153 template <
typename Base>
159 template <
typename Base>
167 template <
typename Base>
173 template <
typename Base>
176 return &first_in_stage(aShader.type()) == &aShader;
179 template <
typename Base>
182 return &last_in_stage(aShader.type()) == &aShader;
185 template <
typename Base>
188 if (have_stage(aStage))
189 for (
auto const&
shader : stage(aStage)->shaders())
195 template <
typename Base>
198 if (have_stage(aStage))
199 for (
auto shader = stage(aStage)->shaders().rbegin();
shader != stage(aStage)->shaders().rend(); ++
shader)
200 if ((**shader).enabled())
205 template <
typename Base>
208 if (have_stage(aPreviousShader.type()))
210 auto const& currentStage = stage(aPreviousShader.type());
211 auto shader = std::find_if(currentStage->shaders().begin(), currentStage->shaders().end(), [&aPreviousShader](
auto& s) { return &*s == &aPreviousShader; });
212 while(
shader != currentStage->shaders().end())
215 if ((**shader).enabled())
222 template <
typename Base>
225 if (iShaderIndex.find(aShader->name()) == iShaderIndex.end())
227 stage(aShader->type())->shaders().push_back(aShader);
228 iShaderIndex.emplace(
string{ aShader->name() }, aShader);
234 template <
typename Base>
237 for (
auto const& stage : stages())
238 for (
auto const&
shader : stage->shaders())
240 return (iNeedFullUniformUpdate =
true);
244 template <
typename Base>
247 for (
auto& stage : stages())
248 for (
auto&
shader : stage->shaders())
252 template <
typename Base>
255 for (
auto& stage : stages())
256 for (
auto&
shader : stage->shaders())
260 template <
typename Base>
268 update_uniform_storage();
269 update_uniform_locations();
274 template <
typename Base>
277 for (
auto& stage : stages())
278 for (
auto&
shader : stage->shaders())
284 template <
typename Base>
290 template <
typename Base>
293 prepare_uniforms(aContext);
298 template <
typename Base>
302 update_uniforms(aContext);
305 template <
typename Base>
308 bool const needIt = iNeedFullUniformUpdate;
309 iNeedFullUniformUpdate =
false;
313 template <
typename Base>
319 template <
typename Base>
const i_fragment_shader & fragment_shader() const override
const i_string & name() const override
const stage_t & stage(shader_type aStage) const override
i_shader & add_shader(const neolib::i_ref_ptr< i_shader > &aShader) override
bool need_full_uniform_update() const
void prepare_uniforms(const i_rendering_context &aContext) override
void set_clean() override
const i_shader & first_in_stage(shader_type aStage) const override
const i_shader & shader(const neolib::i_string &aName) const override
bool is_first_in_stage(const i_shader &aShader) const override
void * handle() const override
bool is_last_in_stage(const i_shader &aShader) const override
const i_vertex_shader & vertex_shader() const override
bool uniforms_changed() const override
bool created() const override
bool supports(vertex_buffer_type aBufferType) const override
void activate(const i_rendering_context &aContext) override
const stages_t & stages() const override
const i_shader & last_in_stage(shader_type aStage) const override
const i_shader & next_in_stage(const i_shader &aPreviousShader) const override
shader_program(const std::string aName)
void instantiate(const i_rendering_context &aContext) override
bool dirty() const override
bool active() const override
shader_stage(shader_type aType)
shader_type type() const override
shaders_t const & shaders() const override
void prepare_uniforms(const i_rendering_context &, i_shader_program &) override
bool enabled() const final
bool uniforms_changed() const final
void push_back(abstract_value_type const &aValue) final
ref_ptr< ConcreteType > make_ref(Args &&... args)
void advance(it_type &it, const distance_type distance)