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

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

On Wed, Nov 14, 2012 at 1:03 AM, Ian Hickson <ian@hixie.ch> wrote:
This question is still important; IMHO the answer to this question is
related to where settings that apply to rendering to a specific canvas
element's bitmap should be.
GL contexts map via an affine transform set by the gl.viewport command in the form of left, top, width, height.

All coordinate transforms during vertex shading target the device normal space (-1 to 1 in x and y). The screen coordinate for a fragment is figured out by OpenGL with the formula xout = (xin*0.5+0.5)*width + left and respective for vertical.
My recommendation for WebGL would be to have an explicit method that
pushes the bits to the screen, and that would also clear the buffer. So
then (c) and (d) couldn't happen.
I find this a noteworthy idea. Two remarks:
1) classically there exists a call in OpenGL called "flip" (which webgl does not have) which does exactly that in double buffering situations.
2) A call like it on a DrawingBuffer could help to flip exactly that drawing buffer you've actually drawn, avoiding to update drawing buffers which haven't actually been updated, and avoiding the preserveDrawingBuffer mess somewhat.