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

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




On Oct 18, 2012, at 10:34 AM, Gregg Tavares (社用) <gman@google.com> wrote:

If we're discussing naming maybe it should be called DrawingBuffer since we already have 'preserveDrawingBuffer: true/false as one of the creation parameers?

I like drawing buffer, and I like the idea of creating the context with a ctor. So maybe:

[Constructor] interface WebGLRenderingContext {
WebGLDrawingBuffer createDrawingBuffer(HTMLCanvasElement, WebGLContextAttributes);
void bindDrawingBuffer(WebGLDrawingBuffer);
WebGLDrawingBuffer currentDrawingBuffer();
}

I don't particularly like the idea of using attributes to set and get the drawingBuffer because we haven't done that for any other parts of the API, but I could live with it.



On Thu, Oct 18, 2012 at 10:31 AM, Florian Bösch <pyalot@gmail.com> wrote:
On Thu, Oct 18, 2012 at 6:40 PM, Chris Marrin <cmarrin@apple.com> wrote:
ctx = WebGLRenderingContext.createContext();
canvasFB = ctx.createCanvas(canvas, attrs);
ctx.bindCanvasFrameBuffer(canvasFB);

Would be the same as:

ctx = canvas.getContext("webgl", attrs);
canvasFB = ctx.currentCanvasFrameBuffer();

I like this idea, but I find the naming/semantic a bit confusing. Here's some suggestions:

Framebuffer is confusing since it's also used by one context to imply something different. I'd substitute by "FrontBuffer".

Creating a context without a frontbuffer:
var ctx = new WebGLRenderingContext();

Creating a frontbuffer:
var frontbuffer = ctx.createFrontBuffer(canvas);

Setting the frontbuffer to be rendered to:
ctx.frontbuffer = frontbuffer

Getting the frontbuffer currently used:
ctx.frontbuffer

Getting the canvas a frontbuffer is attached to:
frontbuffer.canvas

Getting the frontbuffer a canvas is attached to:
canvas.frontbuffer
 


-----
~Chris Marrin
cmarrin@apple.com