summaryrefslogtreecommitdiff
path: root/themes/src/tools
diff options
context:
space:
mode:
authormattkae <mattkae@protonmail.com>2023-07-31 07:31:52 -0400
committermattkae <mattkae@protonmail.com>2023-07-31 07:31:52 -0400
commitb6a666e96ffd04bd6d52be8fd9899faf27b751db (patch)
treeddc56ec77d0fa6a35a581ea49bcd1b4c3cac3756 /themes/src/tools
parentffa1ada2b7f65e0b3afe561b3291219394df21f3 (diff)
Some initial shader loading work
Diffstat (limited to 'themes/src/tools')
-rw-r--r--themes/src/tools/shader.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/themes/src/tools/shader.js b/themes/src/tools/shader.js
new file mode 100644
index 0000000..27c8682
--- /dev/null
+++ b/themes/src/tools/shader.js
@@ -0,0 +1,30 @@
+/*
+ Responsible for generating .h files from GLSL files.
+ */
+
+
+const path = require('path');
+const fs = require('fs');
+const directory = path.join(__dirname, "..", "_shaders");
+const out_directory = path.join(__dirname, "..", "shaders");
+
+const files = fs.readdirSync(directory);
+files.forEach(file => {
+ const filePath = path.join(directory, file);
+ const text = String(fs.readFileSync(filePath));
+ const splitText = text.split('\n');
+ const splitName = file.split('.');
+ const def = `SHADER_${splitName.join('_').toUpperCase()}`;
+ let result = `#ifndef ${def} \n`;
+ result += `#define ${def} \n`;
+ result += `const char* ${def.toLowerCase()} = `
+ splitText.forEach((line, index) => {
+ result += "\"" + line + " \\n\"";
+ if (index == splitText.length - 1)
+ result += ";\n";
+ else
+ result += "\n";
+ });
+ result += '#endif\n';
+ fs.writeFileSync(path.join(out_directory, splitName.join('_') + '.h'), result);
+});