Original post is here: eklausmeier.goip.de
My other son had a practical training at Fraunhofer IGD. He wrote an OpenGL/C++ program in Windows where one views the earth rotating around the sun, thereby with its rotating moon, see picture below.
openglSunEM-X
I ported this program to Gtk/Linux. You'll find the code in openglSunEM.c
. The link between Gtk and OpenGL is realized by GtkGlExt. On Ubuntu you have to install libgtkglext1-dev
.
openglSunEM
can either be called with or without textures using command line flag "-t". Typing ESC stops the program.
The main geometric transformation is handled in drawGLScene()
: draw sun, draw earth, draw moon (which rotates around the earth, which in turn rotates around the sun). The speed of rotation can be increased or decreased with the arrow keys (GDK_KEY_Up
, GDK_KEY_Down
), one can zoom in or out (GDK_KEY_I
, GDK_KEY_O
).
The whole animation can be rotated like an arcball, its implementation being in ArcBall2.c
.