how does cliping work in opengl

i was wondering, what does opengl do to make those clipping planes work and how would i do it myself if i needed more?

i am also wondering about alot of things that opengl does like fog??? is there any good websites on this here on the internet?