From e1bf42921a5388b5751ad9719e0ef1feadd8143c Mon Sep 17 00:00:00 2001 From: Damian Tarnawski Date: Thu, 2 May 2024 15:53:12 +0200 Subject: [PATCH] Mention shdc in the readme --- main.js | 7 ++++++- package.json | 1 + readme.md | 13 ++++++++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/main.js b/main.js index f4637fd..1cf8528 100644 --- a/main.js +++ b/main.js @@ -88,6 +88,7 @@ const Command = /** @type {const} */ ({ Preview : "preview", // Start a static server that serves the dist dir Build : "build", // Build the example page Build_SHDC: "build-shdc", // Rebuild the SHDC binary + shdc : "shdc", // Generate shader utils }) /** @type {Record void>} */ @@ -272,7 +273,11 @@ const command_handlers = { [Command.Build_SHDC]() { fs.rmSync(shdc_bin_path, {force: true}) build_shdc() - } + }, + [Command.shdc]() { + build_shdc() + build_shader_utils() + }, } /** @type {(o: O, k: PropertyKey | keyof O) => k is keyof O} */ diff --git a/package.json b/package.json index 3ac2f43..c938ee0 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "server": "node main.js server", "build": "node main.js build", "preview": "node main.js preview", + "shdc": "node main.js shdc", "test": "node --test", "typecheck:ts": "tsc --noEmit -p ./jsconfig.json", "typecheck:odin": "odin check example -target:js_wasm32", diff --git a/readme.md b/readme.md index afb785c..41f6bc4 100644 --- a/readme.md +++ b/readme.md @@ -28,6 +28,16 @@ Feel free to use this repo as a template for your own projects. There are some convenience scripts in [`main.js`](https://github.com/thetarnav/odin-wasm/tree/main/main.js) for building and running the example. And a github action for building and deploying the example to github pages. +### 4. GLSL utils codegen tool + +The [`/shdc`](https://github.com/thetarnav/odin-wasm/tree/main/shdc) directory contains a cli tool for generating GLSL utils from parsing glsl shaders in the [`example/`](https://github.com/thetarnav/odin-wasm/tree/main/example) dir. + +It can be ran with `npm run shdc`, or `odin run shdc`. + +The generated file is committed to the repo, you can check it out in [`example/shaders_generated.odin`](https://github.com/thetarnav/odin-wasm/blob/main/example/shaders_generated.odin). + +The tool is just an experiment of parsing glsl, and generating some boilerplate code, so that getting attribute and uniform locations, and setting the values is a bit easier. + ## Development ### Dependencies @@ -57,4 +67,5 @@ The most important ones are: - `npm run dev` - starts the server and watches for changes - `npm run build` - builds the example to `dist/` -- `npm run preview` - starts a server to preview the built example \ No newline at end of file +- `npm run preview` - starts a server to preview the built example +- `npm run shdc` - generates shader utils from parsing glsl shaders \ No newline at end of file