#include <GL/glut.h> /* Header fuer OpenGl utility toolkit */
#include <stdlib.h> /* Header fuer C-Library */
void init(void) { /* Initialisierung */
glClearColor(0.0, 0.0, 1.0, 0.0); /* setze Blau als Hintergrundfarbe */
glMatrixMode(GL_PROJECTION); /* betrifft Projektionsmatrix */
glLoadIdentity(); /* beginne mit Einheitsmatrix */
gluOrtho2D(0.0, 4.0, 0.0, 3.0); /* Orthogonalprojektions-Clip-Ebenen */
} /* in 2D: left,right,bottom,top */
void display(void){ /* Prozedur zum Zeichnen */
glClear(GL_COLOR_BUFFER_BIT); /* alle Pixel zurecksetzen */
glMatrixMode(GL_MODELVIEW); /* betrifft Modelview-Matrix */
glLoadIdentity(); /* beginne mit Einheitsmatrix */
glRotatef(45,0.0,0.0,1.0); /* drehe 45 Grad bzgl. der z-Achse */
glTranslatef(1.0, 0.0, 0.0); /* verschiebe eine Einheit nach rechts*/
glColor3f(1.0, 0.0, 0.0); /* Farbe rot */
glBegin(GL_POLYGON); /* Beginn eines Polygons */
glVertex2f(0.25, 0.25); /* links unten */
glVertex2f(0.75, 0.25); /* rechts unten */
glVertex2f(0.75, 0.75); /* rechts oben */
glVertex2f(0.25, 0.75); /* links oben */
glEnd(); /* Ende des Polygons */
glFlush(); /* direkt ausgeben */
}
int main (int argc, char ** argv) { /* Hauptprogramm */
glutInit(&argc, argv); /* initialisiere GLUT */
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB); /* single buffer, true color */
glutInitWindowSize(800, 600); /* initiale Fenstergroesse */
glutInitWindowPosition(112,84); /* initiale Fensterposition */
glutCreateWindow("hello"); /* Fenster mit Aufschrift */
init(); /* rufe init auf */
glutDisplayFunc(display); /* registriere display */
glutMainLoop(); /* beginne Event-Schleife */
return 0; /* ISO C verlangt Rueckgabe */
}