[Public WebGL] using the same context with multiple canvases

Brandon Jones [email protected]
Tue Dec 11 09:32:39 PST 2012


I'm also fine with this proposal! Seems very practical.

Also, unless there's a technical reason to avoid it I think that sharing
drawing buffers between canvases would be a very nice option to have. The
minification and magnification options you mentioned are great real-world
applications, and I've personally used similar techniques in the native
world to great effect. Assuming we want to keep that ability, I have a
preference towards canvas.setDrawingBuffer rather than the inverse because
"set" methods tend to imply that only a single object is tracked, thus
suggesting that a canvas can only have a single drawing buffer but the
drawing buffer may be assigned to multiple canvases. If you want to avoid
adding methods to the canvas I would suggest that the drawing buffer method
instead be drawingBuffer.addCanvas/removeCanvas

 --Brandon


On Tue, Dec 11, 2012 at 1:04 AM, Florian Bösch <[email protected]> wrote:

> I'm fine with that API and I don't have a preference on which object the
> method sits to attach a canvas to a drawing buffer.
>
>
> On Tue, Dec 11, 2012 at 9:26 AM, Gregg Tavares (社用) <[email protected]>wrote:
>
>> 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/ab6e9d1b/attachment.html>


More information about the public_webgl mailing list