Pitfall in "Avoiding 16 Common OpenGL Pitfalls"

Admittedly, this is a pretty minor issue, both because very few people will run into it, and because the problem isn’t very severe. However, it raises an issue which might be a real pitfall to someone learning OpenGL. It was misleading enough to puzzle me for a day, so it probably should be revised. Is MJK still the maintainer?

Anyway, the issue is for:
10. The Viewport Does Not Clip or Scissor

Alot of people never run into this issue because they always use Viewport(0, 0, width, height). Because of this, it is tempting believe that Viewport is similar to Ortho or Frustum in that it specifies the transforms by position, as in: Viewport(left, bottom, right, top). This is not actually correct, but this belief is borne out by the “solution” given to correctly clip 8-pixel wide lines:

Viewport(-4, -4, windowWidth+4, windowHeight+4)

but it really should be:

Viewport(-4, -4, windowWidth+8, windowHeight+8)

The first Viewport call doesn’t correct deal with the right or top edges.

-Won

Well in the docs and GL headers glViewport’s parameters are named left, bottom, width, height… so I dont see how this is a pitfall?

You misunderstood. He pointed out a bug on the doc which missed to resize the viewport by four on all edges. As printed it only adds 4 pixels at the bottom and left edge.