View Full Version : glViewPort doesn't clip

02-02-2004, 10:14 AM

I implemented windows in my 3D engine a while ago and it worked perfectly till I bought a new ATI Radeon 9600 XT. To limit the geometry to the windows, I use glViewport. Now the Radeon only seems to do quick checking but no clipping so triangles that should be partially visible go over the side of the view port. Here is a screenshot (the skydome in the background goes over the border of the window):

Is this normal glViewport behavior? What can I do against it/what is a better way to implement clipping (and no, I don't want to use stencil buffers, thats too slow)?

Thank you,


02-02-2004, 10:43 AM
Shows the problem even better.

02-02-2004, 12:27 PM

I'm not sure how that can happen with lines, maybe some sort of clever 'optimization'. However, glViewPort indeed doesn't clip and it's well documented. Look here (http://www.opengl.org/resources/features/KilgardTechniques/oglpitfall/) , issue #10

10. The Viewport Does Not Clip or Scissor

It is a very common misconception that pixels cannot be rendered outside the OpenGL viewport. The viewport is often mistaken for a type of scissor. In fact, the viewport simply defines a transformation from normalized device coordinates (that is, post-projection matrix coordinates with the perspective divide applied) to window coordinates. The OpenGL specification makes no mention of clipping or culling when describing the operation of OpenGL's viewport


Note that if you really do require a rectangular 2D scissor in your application, OpenGL does provide a true window space scissor. See glEnable(GL_SCISSOR_TEST)andglScissor.

02-03-2004, 04:27 AM
Yeah it happens to lines and polygons...

Thank you, that helped.