$ npm install gl-texture2d-read-floatRead out the contents of a floating-point gl-texture2d.
This will eventually be supported natively in WebGL (it's listed in the OpenGL ES 3 spec), but this fills that need until then!
read(glTex2d, done(err, data))Reads out the contents of glTex2d, which should be an instance of
gl-texture2d. When complete, done(err, data) will be called where data is
a Float32Array containing the resulting floats in the texture.
const canvas = document.createElement('canvas')
const gl = require('gl-context')(canvas)
const read = require('gl-texture2d-read-float')
const Texture2d = require('gl-texture2d')
const baboon = require('baboon-image')
const assert = require('assert')
const texture = baboon(gl, baboon)
read(texture, function(err, data) {
if (err) throw err
assert.deepEqual(data, baboon.data)
})
A few things to note:
readPixels equivalent.gl.RGBA/gl.FLOAT textures are currently supported. Pull requests are,
however, very welcome! :)See stackgl/contributing for details.
MIT. See LICENSE.md for details.