Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use glslang in the browser? #3643

Open
racz16 opened this issue Jul 2, 2024 · 0 comments
Open

How to use glslang in the browser? #3643

racz16 opened this issue Jul 2, 2024 · 0 comments
Labels

Comments

@racz16
Copy link

racz16 commented Jul 2, 2024

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:

<script src="glslang.js"></script>
<script>
    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);
        },
    };
</script>

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants