I agree with Patrick and others that al these behind the back calls typically mess things up. As programmer you need a callback when the canvas resizes. Then the programmer decides if it need to adjust the viewport setting to get the transform right. The current WebGL works different than existing OpenGL implementations because you have to rescale the backbuffer as well. On Windows this was automatic.
- rescale backbuffer (what is the name of the function call ?)
- adjust viewport (viewport transform)
- adjust projection transform to get the aspect ratio right
I did some test with the window.onresize but this does not work in all cases. If the window does't resize but the canvas does e.g. by some CSS rule you do not get a callback. This means you have to set up code for every case that resizes the canvas. I would prefer a canvas.onresize that gets called whenever the canvas changes size, this can save you a lot of coding and debugging.
Carl van Heezik
Op 28 jan 2010, om 22:04 heeft Patrick Baggett het volgende geschreven:
I've been watching this thread, and I'd say that most developers who are used to XWindows and Win32 environments know that when there is a resizing of the window, you need to call glViewport(), and I think the semantics Ken described mirror that familiarity. When in doubt, I think the simplest solution should be the best, and Ken is right, describing the semantics of an automatic-resize-but-only-if-you-dont-do-glViewport (and making sure the implementation does so properly) is just more difficult than it needs to be. It also doesn't take into account that the author could call a 3rd party piece of code that does glViewport() and then disables this automatic behavior, and the author is left wondering why automatic viewport handling doesn't work, etc. etc. Law of least surprises, anyone?
That being said, I think that automatic calls of glViewport() are just wrong. The viewport is just how NDC are transformed, and have little to do with the actual back buffer contents or dimensions -- they are GL state, not part of the underlying windowing system state, therefore it should not be the windowing system's [i.e. canvas in this case] job to modify them. I think that just crosses some system separation line.
I use glViewport() to draw a subrect in 3D and use the remaining space for 2D elements. I would not want an implementation to waste it's time calling glViewport() for me, just so I can call it with what I really want, or for that matter, to clobber what I've done.
On Thu, Jan 28, 2010 at 1:30 PM, Kenneth Russell <firstname.lastname@example.org> wrote: