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

Re: [Public WebGL] WebGL back buffer contents



Generally, these are all good questions. More inline...

On Jan 25, 2010, at 2:11 PM, Gregg Tavares wrote:

> Something that's not clear to me still is how WebGL knows what's in the backbuffer.
> 
> If I do something like
> 
> window.setInterval(drawNextTriangle, 1);
> 
> function drawNextTriangle() {
>   ctx.drawElements(...);
> };
> 
> Then what will I see on the screen? Is it defined?

I'm not sure what you mean here. This should draw a new triangle every ms, right? Depending on how fast your browser can service the setInterval, it will draw a new triangle at that rate. Theoretically every ms, but I believe most browsers will throttle that down to something much lower.

> 
> Similarly if I do this
> 
> // note these are 2 different canvas elements
> ctx2d = canvas2d.getContext("2d");
> ctx3d = canvas3d.getContext("3d");
> 
> ... // setup some 3d stuff
> 
> ctx3d.drawElements(..);
> 
> // draw the contents of the 3d canvas into the 2d canvas.
> ctx2d.drawImage(canvas3d, 0, 0);
> 
> Is this defined in the spec? I didn't see it. If it's not there does it need to be?

Right now, we have this notion of "Drawing Buffer Presentation". The spec states that the drawing buffer is presented to the HTML renderer just before compositing. I think that is sufficient for compositing, but I think we need more for the case of using the 3D canvas elsewhere. We probably need some words that say something like, "when a WebGL canvas image is needed as the source for another Canvas operation, the equivalent of a finish() is first performed".

Any suggestions on the wording?

> 
> And how about this?
> 
> // note these are 2 different canvas elements
> ctx2d = canvas2d.getContext("2d");
> ctx3d = canvas3d.getContext("3d");
> 
> ... // setup some 3d stuff
> 
> ctx3d.drawElements(..);
> 
> // draw the contents of the 3d canvas into the 2d canvas.
> ctx2d.drawImage(canvas3d, 0, 0);
> 
> // Draw the 3d canvas to the 2d canvas 1 second later.
> window.setTimeout(function() {
>    ctx2d.drawImage(canvas3d, 0, 0);  // should this produce the same results as the previous drawImage?
> }, 1000);
> 
> 
> In section 2.2 of the spec it talks about presenting the draw buffer to the compositor. That doesn't seem to cover the case of drawImage in another context or canvas.toDataURL();

Right. I think we need more words about that.

> 
> I posted the 3rd example because section 2.2 of the spec says after compositing the contents of the backbuffer are undefined which suggests to me that second drawImage call will have undefined results? Am I mis-interpreting the spec?


The "undefined" bit was put there so that different swapping models could be afforded. But since direct rendering of the WebGL content is not really possible (it has to be composited by HTML to have the proper layering), I would have no trouble saying that the contents of the drawing buffer are valid until changed by a clear() or further drawing calls.

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




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