Newbie confusion with 3d perspective

Hello everyone.
I’m making a few examples to start learning about JOGL.
But I’m having a little confusion with 3D view.
The image below shows my problem.


http://img692.imageshack.us/img692/724/problemlk.jpg

The rectangle pink and red are like as walls in my example, and the larger blue rectangle would be like heaven. The Z coordinate of the walls is much smaller than the sky, but when I go walking till I get behind the sky, the walls are drawn on the sky. The most logical would be the sky hide the walls, since their position was to hide.

The order in which design objects make a difference? How do I know which to draw first? I thought I could draw in any order and glu.gluLookAt define what would appear.

I’m using the camera with gluLookAt and gluPerspective.

Any help will be very welcome.
Thanks

The order that you draw objects is important if you’re not using the depth test (z-buffering). You have to turn it on, it doesn’t come enabled. Add the line


gl.glEnable(GL.GL_DEPTH_TEST);

in your initialization and everything should draw in the correct order.

That being said, I couldn’t understand what you expected to happen vs. what actually happened to say if there aren’t other bugs in your code besides the depth test. :slight_smile:

Oh man you saved my life!

Thank you for quick response.

The ways to learn a totally new paradigm and alone sometimes are difficult = /

Thanks again.