Regarding planet.c example(found on this site)

Hi everyone,
Been working on this solar system program for some time now and there is a few things left to do. One of them that i have no idea about is objects overlapping each other. My program is quite long so i won’t post it all. To understand what my problem is though you can check out this example program i found on this site.
http://www.opengl.org/resources/code/basics/redbook/planet.c

Looking at that example it seems ok, but if you change the color of the planet and make it solid you’ll see it really isn’t rotating around the sun. If you hold down the ‘y’ key the planet starts moving anti-clockwise but as it passes the sun it still stays infront of it.

I was looking for a way to make the planet go behind the sun then come back in front of it as it went around.

Any help would be great. :slight_smile:

Cheers, Lamanna

The simplest way is to enable depth buffering - see your Red Book index for details.

Since planets don’t interpenetrate with each other or with the Sun, and there aren’t that many of them, it would be more efficient to sort them back-to-front before drawing. However, that would require you to do your own transformations. Depth buffering is much easier.

Thanks Mike.

That depth buffering worked great. Best thing of all it was easy to do. I thought i was up for a long night staring at code. :smiley: