summaryrefslogtreecommitdiffstats
path: root/Bachelor/GDV2/EigeneAufgabe.cpp
blob: 153b573dbf515153698c6fc24485243be42a7b9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include <iostream.h>

#include <windows.h>



#include <GL\glut.h>







// globale statische Variable

static float spin = 0;





void Init()	

{

	cout << "Init" << endl;

	// Hier finden jene Aktionen statt, die zum Programmstart einmalig 

	// durchgef�hrt werden m�ssen



	glEnable(GL_DEPTH_TEST); 

}



void RenderScene()

{

	cout << "RenderScene" << endl;

	glClearColor( 1., .6, 0., 0. );

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);// Puffer loeschen



	glColor4f(1.f,.0f,.0f,1.0f);

	glLoadIdentity();

	glRotatef ( spin, 0.0, 0.0, 1.0 );

	glutSolidSphere( 0.7, 10, 10 ); //Normalen werden hier automatisch berechnet



	//glFlush();

	glutSwapBuffers();

}



void Reshape(int w,int h)

{

	// Hier finden die Reaktionen auf eine Ver�nderung der Gr��e des 

	// Graphikfensters statt

	cout << "Reshape" << endl;

	glViewport( 0, 0, (GLsizei) w, (GLsizei) h );

	glMatrixMode( GL_PROJECTION );

	glLoadIdentity();

	glOrtho(-1., 1., -1., 1., 0., 1.);

	glMatrixMode( GL_MODELVIEW );

	glLoadIdentity();

	

}



void Animate ()

{

	// An dieser Stelle werden Berechnungen durchgef�hrt, die zu einer

	// Animation der Szene erforderlich sind. Dieser Prozess l�uft im Hintergrund.

	spin = spin + 2.;

	if( spin > 360. )

		spin -= 360.;



	// die registrierte Display-Funktion, also RenderScene, soll aufgerufen werden

	glutPostRedisplay(); 

	Sleep( 100 );

}





int main(int argc, char **argv)

{

	cout<<"Round and round"<<endl;

	glutInit(&argc, argv);;

	glutInitDisplayMode ( GLUT_DOUBLE |GLUT_RGB| GLUT_DEPTH );

	//glutInitDisplayMode ( GLUT_SINGLE |GLUT_RGB | GLUT_DEPTH );



	glutInitWindowSize ( 600,600 );



	glutCreateWindow ("Round and round");

	Init();



    glutDisplayFunc ( RenderScene );

	glutReshapeFunc ( Reshape );

	glutIdleFunc ( Animate );

	

	

	glutMainLoop ();

	return 0;

}