On Fri, Jun 15, 2012 at 2:30 AM, Florian Bösch <firstname.lastname@example.org>
Just so get this right:
gl.viewport(0, 0, canvas.width, canvas.height) would be broken at the moment because the backing store might not have the same size as the canvas. Which means about 99.999% of all uses of webgl are currently broken correct?
I wouldn't say 99%. I'd say the subset of WebGL apps that let their canvas be stretched to an arbitrarily large size and only on old GPUs with multiple monitors connected. (for example my current GPU has a limit of 16k and my 30in+24in monitors only add up 4480 so it would be hard for me to hit the MAX_VIEWPORT_DIMS limit. But I suppose technically you're right, it's possible if being close to out of memory a good webgl impl WebGL might allocate a smaller backbuffer rather than fail. A better impl might start losing contexts in other tabs first.
So the "correct" way to do it would be: gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight) right?
There are uses which have to be satisfied, for instance intending to render at half resolution, which would work like:
gl = canvas.getContext('webgl')
canvas.style.width = 640
canvas.style.height = 480
canvas.width = 640/2
canvas.height = 480/2
gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight)
And "drawingBufferWidth" and "drawingBufferHeight" will automatically reflect the correctly half-sized buffer regardless of high or low dpi yes?