2d clippling?

I’m trying to make a simple 2d game and I’m having a problem with clipping, using glortho. I have three rectangles: red, green, blue.

How can I give them a z-order and have them clip each other without using 3d perspective? I’d like to use real clipping and not simply drawing each one on top of the last.

never mind, i now understand the z-buffer