Now we crate a solar system
Share the codes as below:
1. #import <Foundation/Foundation.h>
2. #import <OpenGL/OpenGL.h>
3. #import <GLUT/GLUT.h>
4.
5. #define DAYS 30
6. #define MOUNTHS 12
7.
8. float mounth ;
9.
10. void init ( void )
11. {
12. mounth = 0 ;
13.
14. glClearColor ( 0.0 , 0.0 , 0.0 , 0.0 ) ;
15. glShadeModel( GL_SMOOTH ) ;
16. }
17.
18. void reshape ( int w , int h )
19. {
20. glViewport( 0 , 0 , (GLsizei ) w , ( GLsizei ) h ) ;
21. glMatrixMode( GL_PROJECTION ) ;
22. glLoadIdentity() ;
23. gluPerspective( 60.0 , (GLfloat ) w / ( GLfloat ) h , 1.0 , 200.0 ) ;
24. glMatrixMode( GL_MODELVIEW ) ;
25. gluLookAt( 100 , 100 , 0 , 0 , 0 , 0 , 0 , 1 , 0 ) ;
26. }
27.
28. void mouseSence ( int button , int state , int x , int y )
29. {
30. }
31.
32. void keyboard ( unsigned char key , int x , int y )
33. {
34. }
35.
36. void display ( void )
37. {
38. mounth = mounth + (float)0.1/DAYS ;
39. &