#include static GLfloat Rotationswinkel = 0.0; static GLuint Animationsverzögerung = 10; void reshape(GLint w, GLint h) { glViewport(0, 0, w, h); GLfloat aspect = (GLfloat)w / (GLfloat)h; glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-50.0, 50.0, -50.0 / aspect, 50.0 / aspect, -1.0, 1.0); } void display() { glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glScalef(10.0, 10.0, 1.0); glRotatef(Rotationswinkel, 0.0, 0.0, 1.0); glBegin(GL_TRIANGLES); glColor3f(1, 0, 0); glVertex3f(0, 2, 0); glColor3f(0, 1, 0); glVertex3f(-1, 0, 1); glColor3f(0, 0, 1); glVertex3f(1, 0, 1); glEnd(); glFlush(); } void timer(int v) { Rotationswinkel += 1.0; glutPostRedisplay(); glutTimerFunc(Animationsverzögerung, timer, v); } int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE); glutInitWindowSize(800, 600); glutCreateWindow("drehendes Dreieck"); glutReshapeFunc(reshape); glutDisplayFunc(display); glutTimerFunc(0, timer, 0); glutMainLoop(); }