3D GL drawing over polygons

What is the easiest way to avoid having a polygon that is behind another polygon from drawing over the one in front. For some reason when i draw 2 triangles lets say, and one is behind the other, the one that is drawn last covers up, wheather its in front or back. Do I have to sort this out by drawing all my 3D chit from front to back, or is there a Open GL command that can do this for me?

Are you enabling the depth buffer?

glEnable( GL_DEPTH_TEST );

Also put in main() in glutInitDisplayMode(