All Projects → AlexAltea → glslang.js

AlexAltea / glslang.js

Licence: other
Real-time GLSL to SPIR-V, powered by Glslang

Programming Languages

HTML
75241 projects
javascript
184084 projects - #8 most used programming language
C++
36643 projects - #6 most used programming language
python
139335 projects - #7 most used programming language
CMake
9771 projects

Glslang.js

Last Release

Real-time GLSL to SPIR-V translator. Powered by Glslang and Khronos' SPIR-V Tools.

Compiled into JavaScript via Emscripten.

Installation

To add Glslang.js to your web application, include it with:

<script src="glslang.min.js"></script>

or install it with the Bower command:

bower install glslangjs

Usage

// Input: GLSL source code and shader type
var type = glslang.EShLangFragment;
var source = `
    #version 150
    out vec4 finalColor;
    void main() {
        finalColor = vec4(1.0, 1.0, 1.0, 1.0);
    }`;

// Initialize Glslang
glslang.initialize();

// Compile shader
var shader = new glslang.Shader(type, source);

// Output: SPIR-V binary and disassembly
var binary = shader.data();
var disassembly = shader.disasm();

// Delete shader
shader.delete();

// Finalize Glslang
glslang.finalize();

Building

To build the Glslang.js library, clone the master branch of this repository, and do the following:

  1. Initialize the Glslang and SPIR-V Tools submodules: git submodule update --init.

  2. Install the development and client dependencies with: npm install and bower install.

  3. Install the lastest Python 2.x (64-bit), CMake and the Emscripten SDK. Follow the respective instructions and make sure all environment variables are configured correctly. Under Windows MinGW (specifically mingw32-make) is required.

  4. Finally, build the source with: grunt build.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].