Viewport Clipping - When Vertices Go Off-Screen Entire Faces Disappear!

I really could use some help with this one. I’ve searched through the “red book” from the link off of NeHe’s site. I’ve searched these forums for “clip” and “clipping” and read several, several articles to no avail. I’ve even tried enlarging my viewport like this:

glViewport(-16,-16,width+16,height+16); // pardon if the syntax is wrong but you get the idea

which had no effect whatsoever. It’s weird though. Some of the vertices, if they go just one pixel offscreen, the entire face disappears. Others go off fine with no effect. When they disappear it actually draws the face as if that vertex didn’t exist. Which of course makes all kind of “popping” effects as you rotate the scene.

Basically I’m rendering an array of GL_QUADS to do some height-mapped terrain. It works great. I started with simple colored quads with different colored vertices and moved on to texture mapped quads. With the colored quads the disappearing was very noticeable, as the faces actually changed colors due to the vanished vertex’s color no longer being used for face color calculation. I’ll try quad strips for some expected speedup later, but I’m really banging my head against a wall here with these disappearing faces!

I’m using gluPerspective for my frustum generation, with 45 as the angle, screenwidth/screenheight as the aspect, 0.1 for near, and 200 for far.

If anyone could tell me how to display stuff so it doesn’t seemingly arbitrarily wipe out my primitives I would be most appreciative!

Thanks in advance.

Care,
Heaven

What kind of video card are you using? If only one vertex goes out of view, the face is supposed to be clipped in a way that the part that should still be visible is shown. Since you are using quads, are you certain that all 4 points lie within the same plane? I’m not sure what the specification says about the handling of quads where all four points for a quad are not planar. Maybe try using triangles, or triangle strips instead.

Deiussum asks: What kind of video card are you using?

I’m using a 3dfx Velocity 100, or basically an 8 Mb Voodoo 3 card.

Deiussum writes: If only one vertex goes out of view, the face is supposed to be clipped in a way that the part that should still be visible is shown. Since you are using quads, are you certain that all 4 points lie within the same plane?

They definitely do not.

Deiussum writes: I’m not sure what the specification says about the handling of quads where all four points for a quad are not planar. Maybe try using triangles, or triangle strips instead.

This seems like a straw worth grasping for. I’ll try it out and let you know. You know I’ve always wondered why people used two tris to make a quad when you could just use a quad. Maybe the clipping is one reason.

Thanks,
Heaven (heaven@knology.net)

If they don’t lie in the same plane you shouldn’t use GL_QUADS, use GL_TRIANGLE_FAN or GL_TRIANGLE_STRIP instead.

GL_TRIANGLE_STRIP works without anything getting clipped. Thanks.

Heaven
heaven@knology.net