[Public WebGL] using the same context with multiple canvases

Gregg Tavares (社用) [email protected]
Tue Dec 11 00:26:29 PST 2012


So to continue this discussion we still need to figure out what we plan to
do for WebGL 1 context, multiple canvases

IIRC the current thinking is this

    gl = new WebGLRenderingContext();
    db1 = new Drawingbuffer(creationAttributes1);
    db2 = new Drawingbuffer(creationAttributes2);
    canvas1 = document.createElement("canvas");
    canvas2 = document.createElement("canvas");
    canvas1.setDrawingbuffer(db1);
    canvas2.setDrawingbuffer(db2);
    gl.bindDrawingbuffer(db1);
    gl.drawXXX(...);
    gl.bindDrawingbuffer(db2);
    gl.drawXXX(...);

These issues are separate from CanvasProxy etc.

Are there any problems with this?

Can you assign the same drawingBuffer to more than one canvas?

    canvas1.setDrawingbuffer(db1);
    canvas2.setDrawingbuffer(db1);

I don't know if there's any use case for that though I suppose it might
give you free magnification (zoom) or minification (document navigation)
with the right CSS options. You'd basically be compositing the same
drawingBuffer in multiple places on the page.

Should associating the canvas with a drawing buffer be a drawingbuffer
method to avoid adding stuff to the canvas?

   db1.setCanvas(canvas1);


Note that although this doesn't work with canvas2d arguably canvas2d should
also have creation parameters. Specifically it would be nice if it was
possible to ask for a double buffered canvas as in {preserveDrawingbuffer:
false} as double buffering can be significantly faster than the fake single
buffered ones we have now that requires a copy. It might also be a good way
to request a non HD-DPI 2d canvas.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://khronos.org/pipermail/public_webgl_khronos.org/attachments/20121211/ddb655fa/attachment.html>


More information about the public_webgl mailing list