#pragma once #include "shader.h" #include namespace pp::panopainter { struct LegacyStrokeEraseUniforms { glm::mat4 mvp { 1.0f }; int texture_slot = 0; int stroke_texture_slot = 1; int mask_texture_slot = 2; float alpha = 1.0f; bool mask_enabled = false; }; struct LegacyStrokeEraseShaderExecution { std::function use_shader; std::function set_int; std::function set_float; std::function set_mat4; }; [[nodiscard]] inline LegacyStrokeEraseShaderExecution legacy_shader_manager_stroke_erase_execution() noexcept { return { .use_shader = [](kShader shader) { ShaderManager::use(shader); }, .set_int = [](kShaderUniform uniform, int value) { ShaderManager::u_int(uniform, value); }, .set_float = [](kShaderUniform uniform, float value) { ShaderManager::u_float(uniform, value); }, .set_mat4 = [](kShaderUniform uniform, const glm::mat4& value) { ShaderManager::u_mat4(uniform, value); }, }; } inline void setup_legacy_stroke_erase_shader( const LegacyStrokeEraseUniforms& uniforms, const LegacyStrokeEraseShaderExecution& execution) noexcept { execution.use_shader(kShader::CompErase); execution.set_int(kShaderUniform::Tex, uniforms.texture_slot); execution.set_int(kShaderUniform::TexStroke, uniforms.stroke_texture_slot); execution.set_int(kShaderUniform::TexMask, uniforms.mask_texture_slot); execution.set_int(kShaderUniform::Mask, uniforms.mask_enabled); execution.set_float(kShaderUniform::Alpha, uniforms.alpha); execution.set_mat4(kShaderUniform::MVP, uniforms.mvp); } inline void setup_legacy_stroke_erase_shader(const LegacyStrokeEraseUniforms& uniforms) { setup_legacy_stroke_erase_shader(uniforms, legacy_shader_manager_stroke_erase_execution()); } } // namespace pp::panopainter