[Public WebGL] using the same context with multiple canvases

Brandon Jones [email protected]
Thu Dec 13 12:35:03 PST 2012


On Thu, Dec 13, 2012 at 12:08 PM, Ian Hickson <[email protected]> wrote:

> They don't have to be creation, right? I mean, you have multiple contexts
> and you have multiple canvases, you're not going to be necessarily
> creating anything after that, just binding a context to a canvas and
> drawing. If the settings are specific to a particular context/canvas
> binding, then setContext() seems the right place...
>

That would be a bad idea from a performance standpoint unless we put some
fairly obscure rules in place. For instance: switching from a
non-antialiased backbuffer to an antialiased one would be pretty expensive,
but if canvas attributes are set in setContext then it would naturally
allow the following code:

canvas1.setContext(gl, {antialias: false});
canvas2.setContext(gl, {antialias: false});
canvas1.setContext(gl, {antialias: true});

That third call would override the creation parameters declared in the
first call, which would necessitate destruction and recreation of the
underlying buffers to match the requested attributes. We could always say
in the spec that only the first call to setContext on a given canvas is
allowed creation parameters and in subsequent calls they are ignored, but
that's an open invitation to confusing behavior and obscure bugs. The
setDrawingBuffer() proposals handle the same scenario in a much less
error-prone way that more closely mirrors the underlying code.

--Brandon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://khronos.org/pipermail/public_webgl_khronos.org/attachments/20121213/f1ec6833/attachment.html>


More information about the public_webgl mailing list