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

[Public WebGL] WebGL back buffer contents



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?

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?

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();

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?