Automatic hidden surface removal?

I have written a program that converts Bevier patches into 3-d GL_POLYGON objects (eg. 32 Bezier patches to draw a teapot which is comprised of a few thousand triangles).

Unfortunately the patches that are drawn last appear in front of the rest. This makes some interior sections of my teapot appear when they’re supposed to be hidden.

Is there some automatic way to hide triangles which should not be shown? If not, what’s the easiest way to do so that’s not absurdly inefficient?

Thanks for the help!

The z-buffer should take care of that.

glDepthFunc(GL_LEQUAL);//less or equal

I beleive it is disabled by default when you make a GL context.

Also, backfaced polygons should be removed. If the depth buffer isn’t helping you, your polygons might be wound backwards, causing the far side of the teapot to show and not the near side.