overlapping polygons

i am trying to draw sd shapes from the data file ( where they are being defined) and they consist of polygon primitives.
my question is that often times the polygons overlap and the faces that are in the back get drawn in the front
how do i avoid that?
thanx a bunch

one way would be to order the polygons so that you draw them from back to front, and then draw them that way. this may be extremely difficult to do, depending on how the data is set up.


thanks, i thought about that but some of the shapes are pretty complicated and i think there should be another way of doing it…maybe through some OpenGL routines???

Use glEnable(GL_DEPTH_TEST) in your intitialization and in your rendering loop glClear(… | GL_DEPTH_BUFFER_BIT) where … could also include color, accum, and/or stencil buffer bits.