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

Re: [Public WebGL] double-buffering and back buffer preservation




Adding a Present function seems like it certainly has advantages. Why not require it instead of having the current behavior? Like others have mentioned, this makes it more like real OpenGL and makes it easy to spread out rendering across callbacks, possibly making it better for web worker stuff in the future as well.
It has a cost -- it would mean that you would have to double-buffer all webgl content; that is, you'd have to be able to keep the displayed front buffer entirely separate than the back buffer.  Right now, a WebGL implementation can have a single buffer (for example, a FBO) that it can both render to and use as a texture for compositing.

Chris, if I'm understanding your proposal correctly, a code snippet like this:

function draw(gl) {
  gl.clear(..);
  gl.drawElements(..); // draw #1
  gl.Present(true);

  gl.drawElements(..); // draw #2
}

would have an implicit Present(false) at the end, with the displayed buffer containing draw #2 on top of draw #1, and the next time GL drawing happens (that is, the current conceptual back buffer) being cleared/invalid?

It seems, as Chris said, the main issue is what the contents of a webgl canvas are for toDataURL, drawImage, and texImage2D (with a webgl canvas as a source).

    - Vlad