Skip to content

Commit

Permalink
Mention shdc in the readme
Browse files Browse the repository at this point in the history
  • Loading branch information
thetarnav committed May 2, 2024
1 parent b51e93c commit e1bf429
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
7 changes: 6 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<Command, (args: string[]) => void>} */
Expand Down Expand Up @@ -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 extends Object>(o: O, k: PropertyKey | keyof O) => k is keyof O} */
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
13 changes: 12 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
- `npm run preview` - starts a server to preview the built example
- `npm run shdc` - generates shader utils from parsing glsl shaders

0 comments on commit e1bf429

Please sign in to comment.