- //---------------------------------------------------------------------------
- #ifdef _WIN32
- #include <windows.h>
- #define GLUT_BUILDING_LIB
- #include "GL/gl.h"
- #include "GL/glut.h"
- #include <vcl.h>
- #include <conio.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <math.h>
- #pragma argsused
- #define DELTA 0.25f
- #include "Berechnungen.h"
- Berechnung berechne1;
- GLfloat x1,y1;
- GLfloat x2,y2;
- GLfloat x3,y3;
- GLfloat x4,y4;
- GLfloat x5,y5;
- GLfloat x6,y6;
- GLfloat x7,y7;
- GLfloat rotation1,rotation2;
- GLfloat rotation3,rotation4;
- GLfloat rotation5,rotation6;
- GLfloat rotation7,rotation8;
- GLfloat zoomfaktor=1.0;
- GLfloat pos[5] = {-1, 0, -2};
- GLfloat white[4] = {1., 1., 1., 1.};
- GLfloat black[4] = {0., 0., 0., 0.};
- GLUquadric *quadSphere, *quadSphere1,*quadSphere2;
- // Funktion zum darstellen der Kugel
- void zeichne_kugel(void)
- {
- glClear ( GL_DEPTH_BUFFER_BIT );
- glClear ( GL_COLOR_BUFFER_BIT );
- glPushMatrix();
- //"Sonne"
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity ();
- glTranslatef (0,0, -2);
- glRotatef (rotation2,0. , 0., 1.);
- glLightfv (GL_LIGHT1, GL_POSITION, pos); //Setze Position
- glColor3f (1.0, 1.0, 0.0);
- gluSphere (quadSphere1, .25, 50, 25);
- rotation2=(rotation2-0.15);
- glutPostRedisplay ();
- //"Erde=Fixpunkt"
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity ();
- glTranslatef (x1, y1, -2);
- glRotatef (rotation1,0. , 1., 0.);
- glColor3f (0., .4, 1.0);
- gluSphere (quadSphere, 0.0228843, 100, 50);
- rotation1=(rotation1+0.6);
- x1 = berechne1.berechneNeuePosition_x1();
- y1 = berechne1.berechneNeuePosition_y1();
- glutPostRedisplay ();
- //"Merkur"
- glLoadIdentity ();
- glTranslatef (x2, y2, -2);
- glRotatef (rotation1,0. , 1., 0.);
- glColor3f (.5, .5, .5);
- gluSphere (quadSphere, 0.008764, 100, 50);
- rotation1=(rotation1+0.6);
- x2 = berechne1.berechneNeuePosition_x2();
- y2 = berechne1.berechneNeuePosition_y2();
- glutPostRedisplay ();
- //"Venus"
- glLoadIdentity ();
- glTranslatef (x3, y3, -2);
- glRotatef (rotation1,0. , 1., 0.);
- glColor3f (.2, 1.2, 1.);
- gluSphere (quadSphere, 0.02173157, 100, 50);
- rotation1=(rotation1+0.6);
- x3 = berechne1.berechneNeuePosition_x3();
- y3 = berechne1.berechneNeuePosition_y3();
- glutPostRedisplay ();
- //"Mars"
- glLoadIdentity ();
- glTranslatef (x4, y4, -2);
- glRotatef (rotation1,0. , 1., 0.);
- glColor3f (1.0, .6, 0.);
- gluSphere (quadSphere, 0.01221299463, 100, 50);
- rotation1=(rotation1+0.6);
- x4 = berechne1.berechneNeuePosition_x4();
- y4 = berechne1.berechneNeuePosition_y4();
- glutPostRedisplay ();
- //"Juptier"
- glLoadIdentity ();
- glTranslatef (x5, y5, -2);
- glRotatef (rotation1,0. , 1., 0.);
- glColor3f (1.0, .6, 0.);
- gluSphere (quadSphere2, 0.14, 100, 50);
- rotation1=(rotation1+0.6);
- x5 = berechne1.berechneNeuePosition_x5();
- y5 = berechne1.berechneNeuePosition_y5();
- glutPostRedisplay ();
- glPopMatrix();
- glutSwapBuffers();
- }
- void zeichne_bildNeu(int w, int h)
- {
- glViewport (0,0, w, h);
- glMatrixMode (GL_PROJECTION);
- glLoadIdentity ();
- gluPerspective (150, (float)w/(float)h, 2, 20.);
- glMatrixMode (GL_MODELVIEW);
- glLoadIdentity();
- }
- void init (void)
- {
- glEnable (GL_DEPTH_TEST);
- {
- glEnable (GL_LIGHTING);
- glEnable (GL_LIGHT1);
- glLightfv (GL_LIGHT1, GL_DIFFUSE, white);
- glEnable (GL_COLOR_MATERIAL);
- }
- quadSphere = gluNewQuadric();
- quadSphere1 = gluNewQuadric();
- quadSphere2 = gluNewQuadric();
- glutDisplayFunc (zeichne_kugel);
- glutReshapeFunc (zeichne_bildNeu);
- }
- void main(int argc, char** argv)
- {
- glutInit (&argc,argv);
- glutInitDisplayMode (GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
- glutInitWindowSize (500,500);
- glutInitWindowPosition (0,0);
- glutCreateWindow ("2Kugeln_Umkreisen");
- glutIdleFunc(zeichne_kugel);
- init();
- rotation1 = berechne1.getRotation_1();
- rotation2 = berechne1.getRotation_2();
- glutMainLoop ();
- }
- #endif