[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Public WebGL] How to set a canvas backing store to display units?
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?
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?