diff options
Diffstat (limited to 'src/gpu/effects/shader_composer.cc')
| -rw-r--r-- | src/gpu/effects/shader_composer.cc | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/gpu/effects/shader_composer.cc b/src/gpu/effects/shader_composer.cc new file mode 100644 index 0000000..61da6e6 --- /dev/null +++ b/src/gpu/effects/shader_composer.cc @@ -0,0 +1,33 @@ +// This file is part of the 64k demo project. +// It implements the ShaderComposer class. + +#include "gpu/effects/shader_composer.h" +#include <sstream> + +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<std::string>& 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(); +} + |
