Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode
binding
scripts
src 0.0.8 bump Mar 20, 2019
.gitignore
.npmignore
CONTRIBUTING.md
LICENSE
README.md
binding.gyp Update include path Mar 20, 2019
package.json
tsconfig.json Initial commit. Oct 30, 2018
tslint.json
yarn.lock Yalc and npm ignore Jan 14, 2019

README.md

Headless WebGL / OpenGL ES runtime for Node.js

This repo is under active development and is not production-ready. We are actively developing as an open source project.

Details

This project aims to provide a headless runtime for WebGL and OpenGL ES shaders under Node.js. This package will use the ANGLE engine to translate WebGL and OpenGL ES shaders to the target runtime. Please see the ANGLE project for more details on support.

Future plans include surfacing an API for running Compute Shaders and a OpenGL ES API. Patches are welcome!

Supported platforms

  • Mac OS
  • Windows
  • Linux

Creating a WebGL context

To create a new WebGLRenderingContext or WebGL2RenderingContext - simply include the package and call createWebGLRenderingContext():

const nodeGles = require('node-gles');

const gl = nodeGles.createWebGLRenderingContext();

// Now, use `gl` for regular WebGL calls:
const tex = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, texture);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
...

Run demo

Clone this repo for current demos - examples coming soon

  • Float32 texture upload and download:
$ yarn ts-node src/tests/float_texture_upload_test.ts
...

buffer:  Float32Array [ 0.5, 1.5, 2.5, 3.5 ]
  • Float16 texture upload and download:
$ yarn ts-node src/tests/half_float_texture_upload_test.ts
...

buffer:  Float32Array [ 0.5, 1.5, 2.5, 3.5 ]
  • Unsigned byte texture upload and download:
$ yarn ts-node src/tests/unsigned_byte_texture_upload_test.ts
...

buffer:  Uint8Array [ 1, 2, 3, 4 ]

Development

Build instructions are under heavy development and will include an Angle binary

This project currently requires ANGLE to be checked out and built in the same parent folder as this repo. Checkout and build ANGLE with the Debug setup. After ANGLE is built, run yarn for this project.

You can’t perform that action at this time.