diff options
Diffstat (limited to 'themes/src/tools')
| -rw-r--r-- | themes/src/tools/shader.js | 30 | 
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); +}); | 
