Intercepts uploads to WebGL buffers in order to keep track of their expected value on the GPU.
Designed solely with the intention of testing packages that interact with WebGL buffers. It's probably not something you should be using in an actual app/demo, so approach with caution.
Before using your WebGL context at all, you should let
its thing by passing it the context in question:
var canvas = documentvar gl = canvasgl
This will override a few of the context's methods to keep track of outgoing data, along with providing a new method for you to use to retrieve a buffer's data:
Given an instance of a
WebGLBuffer, returns our local copy of the data it
should have stored on the GPU. This is returned as a
Uint8Array, but you
can easily convert it to other types too thanks to the magic of typed arrays.
var buffer = gl// ...var rawData = glvar floatData = rawDatabuffer
If you're using this with gl-buffer,
you can just use the
handle property to access the underlying buffer instance:
var buffer = gl 1 2 3var rawData = glvar floatData = rawDatabufferconsole // [1, 2, 3]
MIT. See LICENSE.md for details.