I started learning OpenGL from http://www.videotutorialsrock.com/ a few days ago. To learn something, I decided to make an analog clock.
Things went pretty good, I made the arms and made them move the way they should. Then I got the suggestion to cover the middle, since the arms looked funny. So I made a little box to cover it. Ran into some issues because I had screwed up beforehand, but managed to do it. Then I decided to make some kind of background, so I could try out lightning and perhaps textures. This wasn’t a big issue either, just copying the code I made for the little “cover box” and change its parameters.
Also, since my brother didn’t believe the clock was actually 3D (which some might say it’s not, but whatever) I did some keyhandling so the camera rotates left, right, up, down, in and out. That’s about as far as I’ve come at this point.
Now the question. The arms, backgrounds and cover are outputted on different places on the Z axis, like:
cover - arms - background
with a small gap in between. To my understanding, this is what decides which object is in front of something else when rendering. However, I noticed something funny when moving the camera around the back of the clock - looking at it from behind, I still see the arms and the cover, even though they’re supposed to be on the far side (the front) of the background.
I looked around, but can’t find any info on this. So can someone explain why this is? That is the question, sorry for all the background info.
The source (it’s just one file, hopefully properly commented and not too large) can be found here:
http://fryspunkten.se/coding/OGL_Clock.cpp
if anybody feels like trying it out themselves.
Any other questions, just ask. But I would like to solve this before moving on with the program (got big plans for my clock, yay!). And the window which prints the variables all the time is for error checking a problem I had, sorry about that.