[Public WebGL] using the same context with multiple canvases

Florian Bösch [email protected]
Tue Dec 11 10:52:06 PST 2012


Having the drawing buffer separate also cleanly separates drawing buffer
attributes (alpha, stencil, depth, antialias, premultiplied alpha, preserve
drawing buffer) from the gl context and it allows to proxy the drawing
buffer to multiple canvases (maybe Brandon could expand on real world uses
for that since he mentioned it today).


On Tue, Dec 11, 2012 at 7:37 PM, Florian Bösch <[email protected]> wrote:

> A canvas on which a webgl getContext has been called has two distinct
> concepts. The context, which is the gl context (or the semantic equivalent)
> and an FBO (the drawing buffer). A 2D canvas does not have an FBO. So
> creating a context alone does not create the required FBOs that a canvas
> requires in order to be drawn onto by WebGL. Unless another object is
> introduced which encapsulates this state, FBO creation would be implicit
> which is probably a bad idea. Chris Marrin explained this on the 18th
> October 2012 on this thread
> https://www.khronos.org/webgl/public-mailing-list/archives/1210/msg00064.html
>
>
> On Tue, Dec 11, 2012 at 7:02 PM, Ian Hickson <[email protected]> wrote:
>
>> On Tue, 11 Dec 2012, Gregg Tavares (社ç~T¨) 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(...);
>>
>> I don't really understand what a drawing buffer is in this API.
>>
>> Why wouldn't you just do:
>>
>>    gl = new WebGLRenderingContext();
>>    canvas1.setContext(gl);
>>    gl.drawXXX(...);
>>    canvas2.setContext(gl);
>>    gl.drawXXX(...);
>>
>> ...?
>>
>> In any case, I think it can be made any number of ways, the only important
>> thing at this point to make sure it works consistently with the 2D context
>> and in particular to make sure it works in Worker threads is to use the
>> API described here:
>>
>>
>> http://lists.w3.org/Archives/Public/public-whatwg-archive/2012Nov/0199.html
>>
>> Specifically, the bit starting "it will require some additions to WebGL".
>>
>> HTH,
>> --
>> Ian Hickson               U+1047E                )\._.,--....,'``.    fL
>> http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
>> Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://khronos.org/pipermail/public_webgl_khronos.org/attachments/20121211/58f48210/attachment.html>


More information about the public_webgl mailing list