KhronosGroup / KhronosGroup/glslang

How to use glslang in the browser?

Open
#3,643 0 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
C++
Stars
3.6k
Forks
989
Avg merge
1d 2h
Merged PRs (30d)
31

Description

I built glslang with Emscripten and included the JavaScript file into an HTML file. It runs and prints the help message to the console. My question is how can I pass arguments to it and how can I validate GLSL. I tried to set `Module.arguments` and call `Module._main` with arguments, but it still only prints the help message to the console. My code is something like this:
```html

var Module = {
onRuntimeInitialized: async () => {
setTimeout(() => {
Module.arguments = ['--stdin -C -l -S vert'];
Module.stdin = () => 'void main(){a}';
Module._main(['--stdin -C -l -S vert']);
}, 5000);
},
};

```
I use an additional `setTimeout` because initially, the browser says that `_main` is not a function. I'm not sure why because I'm inside `onRuntimeInitialized`.

Contributor guide

Open the contributing guide

Research direction

Start with the browser usage shown in glslang.js and the Emscripten entry points Module.arguments, Module.stdin, Module._main, and onRuntimeInitialized. Reproduce the reported initialization and argument-passing behavior, then document a working path for passing compiler arguments and validating GLSL in the browser.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, javascript
Domain
compilers, web-dev
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.