Using Visual C and your OpenGL configured environment write
Using Visual C++ and your OpenGL configured environment, write an application that displays a graphical scene that displays a top-down, 2-D (non-animated) view of the Sun and at least 4 planets of our solar system. You can assume elliptical orbits for all of the planets in your scene. Sizes of the ellipses should be scaled to the actual distances from the Sun. You should include circles representing each of the planets and the Sun in your scene. Sizes of the objects should be scaled proportional to their actual size (with the exception of the Sun as it will be most likely too large to have other planet be visible). Be sure to label each of your planets and the Sun. In the word document you submit, describe exactly how you scaled your planets and elliptical orbits. Be sure to reference your source for planet size, and distance from the Sun. (e.g. http://www.solarviews.com/eng/solarsys.htm)
A “rough” graphics scene might look like this:
Solution
void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); GLfloat red[] = {1,0.2,0,1}; glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, red); glutSolidSphere(10.0, 50, 50); glPopMatrix(); glPushMatrix(); glRotatef((GLfloat) EarthYear, 0.0, 1.0, 0.0); glTranslatef(20.0, 0.0, 0.0); glRotatef((GLfloat) day, 0.0, 1.0, 0.0); GLfloat blue[] = {0,0.2,1,1}; glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, blue); glutSolidSphere(1,40,30); glRotatef((GLfloat) lunar, 0.0, 1.0, 0.0); glTranslatef(1.5,0.0,0.0); GLfloat grey[] = {0.7,0.7,0.8,1}; glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, grey); glutSolidSphere(0.25, 100, 30); glPopMatrix(); glPushMatrix(); glRotatef((GLfloat) MercYear, 0.0, 1.0, 0.0); glTranslatef(12.0,0.0,0.0); GLfloat merc[] = {0.7,0.3,0.2,1}; glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, merc); glutSolidSphere(0.35, 100, 30); glPopMatrix(); glPushMatrix(); glRotatef((GLfloat) VenusYear, 0.0, 1.0, 0.0); glTranslatef(14.0,0.0,0.0); GLfloat venus[] = {0.7,0.7,0.2,1}; glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, venus); glutSolidSphere(0.9, 100, 30); glPopMatrix(); glPushMatrix(); glRotatef((GLfloat) MarsYear, 0.0, 1.0, 0.0); glTranslatef(25,0.0,0.0); glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, merc); glutSolidSphere(0.5, 100, 30); glRotatef((GLfloat) lunar, 1.0, 0.0, 0.0); glTranslatef(0.0,0.8,0.0); glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, grey); glutSolidSphere(0.125, 100, 30); glPopMatrix(); glutSwapBuffers(); }