webgl-to-img-stream
Convert a WebGL context's canvas' pixel data into an image, and write that image to a writable stream. Meant to be used in Node.js
Background / Initial Motivation
This module is meant to help with testing WebGL components.
Say you have a WebGL component that takes your canvas' WebGL context and a model view matrix and draws
a fire particle effect at a location of your choice. You can verify that that works by rendering it in node
(using something like require('gl')
) and then writing your rendering to a .png
file on your file system
using webgl-to-img-stream
. You can then use something like image-diff
to make sure that your new .png
file matches the one that you expect.
To Install
$ npm install --save webgl-to-img-stream
Usage
var webGlToImgStream = var fs = var canvasWidth = 128var canvasHeight = 128var gl = canvasWidth canvasHeight// ... do whatever you want with your WebGL context ... var outputFile = fs // Your canvas's contents have now been saved to your file system
See Also
License
MIT