OpenGL Program: Earth with Moon Rotating around Sun

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.



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.

2 thoughts on “OpenGL Program: Earth with Moon Rotating around Sun

  1. Pingback: Statistics of this Blog: 2.600 Views, 78 Countries, 20 Comments | Elmar Klausmeier's Weblog

  2. Pingback: Installing Ubuntu 14.04 Server Edition | Elmar Klausmeier's Weblog

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.