[Public WebGL] using the same context with multiple canvases

Vladimir Vukicevic [email protected]
Wed Dec 12 07:45:52 PST 2012

On 12/11/2012 11:35 PM, Gregg Tavares (社用) wrote:
>     canvas1 = document.createElement("canvas");
>     canvas2 = document.createElement("canvas");
>     canvas3 = document.createElement("canvas");
>     gl = WebGLRenderingContext();
>     db1 = new Drawingbuffer({ alpha: false });
>     db2 = new Drawingbuffer({ antialias: false });
>     db3 = new Drawingbuffer({ preserveDrawingBuffer: true });
>     gl.bindDrawingbuffer(db1);
>     gl.drawXXX();
>     gl.bindDrawingbuffer(db2);
>     gl.drawXXX();
>     gl.bindDrawingbuffer(db3);
>     gl.drawXXX();

Mmm.  What does this look like conceptually for the current usage? That is:

var canvas = document.createElement("canvas");
var gl = canvas.getContext("webgl", {...});

does that getContext conceptually create a Drawingbuffer and call 
setDrawingbuffer on the canvas, as well as call bindDrawingbuffer on the 
gl context?

Is Drawingbuffer webgl-specific, or a general abstraction? (Bikeshed 
note: we need a better name than "Drawingbuffer" IMO...). However, we'd 
still need to determine the types of contexts that it can be used with 
if it's general.  Maybe something like:

gl = new WebGLRenderingContext();
db1 = gl.createDrawingBuffer({ depth: false });
canvas.displayDrawingBuffer(db1);  // setDrawingBuffer on the canvas 
seems like a weird API name, as we're really choosing what buffer to 
display; what buffer is drawn to is selected by the context

twodee = Canvas2DRenderingContext();
db2 = twodee.createDrawingBuffer({ doubleBuffer: true });
canvas.displayDrawingBuffer(db2);  // is this legal; canvas originally 
displayed a webgl buffer?


db1 = new Drawingbuffer("webgl", { depth: false });
db2 = new Drawingbuffer("2d", { doubleBuffer: true });

     - Vlad

You are currently subscribed to [email protected]
To unsubscribe, send an email to [email protected] with
the following command in the body of your email:
unsubscribe public_webgl

More information about the public_webgl mailing list