Question: using dev c++ please Open and execute the program lab07_1.cpp . You will see two spheres being displayed; one representing the Sun and the other

using dev c++ please

Open and execute the program lab07_1.cpp . You will see two spheres being displayed; one representing the Sun and the other is a planet.

Add code to the program so that the planet can rotate around its own y-axis,.

Add code to the program so that the planet can revolve around the Sun.

lab07_1.cpp code:

#include  using namespace std; static int year = 0, day = 0; void init(void) { glClearColor (0.0, 0.0, 0.0, 0.0); glShadeModel (GL_FLAT); } void display(void) { glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0, 1.0, 1.0); glPushMatrix(); glutWireSphere(1.0, 20, 16); // The Sun glTranslatef (2.0, 0.0, 0.0); glutWireSphere(0.2, 10, 8); // The planet glPopMatrix(); glutSwapBuffers(); day += 10; year += 1; glutPostRedisplay(); } void reshape (int w, int h) { glViewport (0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode (GL_PROJECTION); glLoadIdentity (); gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 1.0, 20.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); } int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB); glutInitWindowSize (500, 500); glutInitWindowPosition (100, 100); glutCreateWindow (argv[0]); init (); glutDisplayFunc(display); glutReshapeFunc(reshape); glutMainLoop(); return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!