[Public WebGL] using the same context with multiple canvases

Ian Hickson [email protected]
Thu Dec 13 12:08:04 PST 2012

On Thu, 13 Dec 2012, Gregg Tavares (社ç~T¨) wrote:
> >
> > Is this something that would make sense as arguments to setContext()?
> It doesn't seem like the appropriate place since they are "creation" 
> parameters and since for an animated app with multiple canvases you're 
> going to be calling setContext once per canvas per frame.

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...

> On top of that, if understand your current setContext spec, setContext 
> effectively destroys the content of the canvas when called and loses all 
> state in the context.

setContext() doesn't do anything except what the rendering context spec 
says it should:


Literally all it does is unbind the previous context and bind the new one, 
and it does that by just deferring to the spec that defines the contexts 
for how to unbind and rebind.

The 2D context resets state, but GL doesn't have to.

> For WebGL and 1 context multiple canvases we need each canvas to keep 
> its content with each call and we need the context to keep its state.

That's fine.

Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

More information about the public_webgl mailing list