gl-texture2d-pixels
Gets the RGBA pixels from a gl-texture2d as a Uint8Array. Same API as get-image-pixels.
var getPixels = var array = console //true
Note: This is a fairly expensive operation in WebGL.
Usage
getPixels(texture[, opts])
Gets the RGBA pixels from gl-texture2d object as a Uint8Array with some optional parameters.
x
the x position to start clipping, default 0y
the y position to start clipping, default 0width
the width of the source to copy; this will change the returned array's shape. defaults to image widthheight
the height of the source to copy; this will change the returned array's shape. defaults to image height
The texture object can actually be any generic GL wrapper, as long as it has these fields:
{
handle, //the WebGLTexture handle
gl, //the gl handle to WebGLRenderingContext
shape //an array of [width, height]
}
getPixels.dispose()
Release the shared canvas for GC. This is mainly useful if you need to minimize disruptive GC hitches, e.g. in a game loop.
License
MIT, see LICENSE.md for details.