[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Public WebGL] using the same context with multiple canvases



This is just my opinion, but it feels more natural to flip the bindings so that the canvas is being set as a target for the context, like so:

gl = canvas1.getContext("webgl");
gl.clearColor(0, 1, 0, 1);
gl.clear(gl.COLOR_BUFFER_BIT);
gl.bindCanvas(canvas2);
gl.clear(gl.COLOR_BUFFER_BIT);

By representing the canvas as a property of the context, I feel it better implies the fact that the context can only draw to a single canvas at a time. But like I said, just my opinion.

I'm a big fan of this idea overall! It will certainly make life easier for developers that are trying to do anything resembling the traditional 4-view modeling tools, but there's some fun opportunities for other more creative uses too!

--Brandon


On Wed, Oct 17, 2012 at 6:23 PM, Kevin Reid <kpreid@switchb.org> wrote:

On Oct 17, 2012, at 18:04, Gregg Tavares (社用) wrote:

> I'd like to pursue this idea further that Florian brought up which is that, for drawing to multiple canvases, rather than share resources across contexts it would be much nicer to just be able to use the same context with multiple canvases. Something like
>
>     ctx1 = canvas1.getContext("webgl");
>     ctx1.clearColor(0,1,0,1);
>     ctx1.clear(gl.COLOR_BUFFER_BIT);
>     canvas2.setContext(ctx1);
>     ctx1.clear(gl.COLOR_BUFFER_BIT);
>
> Clear's both canvas1 and canvas2 to green
>
> Issues: Under the current WebGL the only way to setup a canvas is by calling getContext(..., contextCreationParameters). Whether the canvas is RGB or RGBA, has depth or stencil, is premultiplied or not, has it's backbuffer preserved or not, etc..

How about getContext("webgl", { attach: ctx1, other params... }); ? This way there never needs to exist a second context, and the canvas DOM interface doesn't need to be extended.

--
Kevin Reid                                  <http://switchb.org/kpreid/>


-----------------------------------------------------------
You are currently subscribed to public_webgl@khronos.org.
To unsubscribe, send an email to majordomo@khronos.org with
the following command in the body of your email:
unsubscribe public_webgl
-----------------------------------------------------------