// This file is part of the 64k demo project. // It implements the ShaderComposer class. #include "gpu/effects/shader_composer.h" #include ShaderComposer& ShaderComposer::Get() { static ShaderComposer instance; return instance; } void ShaderComposer::RegisterSnippet(const std::string& name, const std::string& code) { snippets_[name] = code; } std::string ShaderComposer::Compose(const std::vector& dependencies, const std::string& main_code) { std::stringstream ss; ss << "// Generated by ShaderComposer\n\n"; for (const auto& dep : dependencies) { auto it = snippets_.find(dep); if (it != snippets_.end()) { ss << "// --- Snippet: " << dep << " ---\n"; ss << it->second << "\n"; } } ss << "// --- Main Code ---\n"; ss << main_code; return ss.str(); }