[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Public WebGL] Loading WebGLBuffer from an HTMLImageElement

On Tue, Apr 12, 2011 at 1:46 AM, Gregg Tavares (wrk) <gman@google.com> wrote:
> You can download binary data through XHR though
> ÂÂ Âvar req = new XMLHttpRequest();
> ÂÂ Âreq.open("GET", url, true);
> ÂÂ Âreq.responseType = "arraybuffer";
> ÂÂ Âreq.onload = function() {
> ÂÂ Â Âvar theArrayBuffer = req.response;
> ÂÂ Â Âvar buf = gl.createBuffer();
> ÂÂ Â Âgl.bindBuffer(gl.ARRAY_BUFFER, buf);
> ÂÂ Â Âgl.bufferData(gl.ARRAY_BUFFER, theArrayBuffer, gl.STATIC_DRAW);
> ÂÂ Â}
> ÂÂ Âreq.send();

That's useful for things like mesh data, but I don't think it helps
with loading images.  (You'll get back your compressed PNG, and
depending on what you're doing, same-origin restrictions will also get
in the way.)

Glenn Maynard

You are currently subscribed to public_webgl@khronos.org.
To unsubscribe, send an email to majordomo@khronos.org with
the following command in the body of your email:
unsubscribe public_webgl