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

Re: [Public WebGL] Loading WebGLBuffer from an HTMLImageElement

You can download binary data through XHR though

    var req = new XMLHttpRequest();
    req.open("GET", url, true);
    req.responseType = "arraybuffer";
    req. {
      var theArrayBuffer = req.response;
      var buf = gl.createBuffer();
      gl.bindBuffer(gl.ARRAY_BUFFER, buf);
      gl.bufferData(gl.ARRAY_BUFFER, theArrayBuffer, gl.STATIC_DRAW);

On Mon, Apr 11, 2011 at 9:58 PM, Glenn Maynard <glenn@zewt.org> wrote:

It currently doesn't appear possible to load a WebGLBuffer from an
image, to use an image as vertex data.  I can't do this manually, by
writing the image to a 2d Canvas and passing its ImageData to
bufferData, due to same-origin restrictions.

WebGLBuffer's bufferData and bufferSubData APIs should support similar
entry points as WebGLTexture.texImage2D, accepting HTMLImageElement,
HTMLCanvasElement and HTMLVideoElement, for the same reasons:
performance and dealing with same-origin restrictions.  Of course,
this would affect the origin-clean flag, just as with WebGLTexture.

It would also be consistent to allow reading WebGLTextures into
WebGLBuffer--another operation you can do natively--though its
usefulness is limited by the present lack of floating-point texture

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