- #include <GL/glut.h>
- #include <stdlib.h>
- void display(void) {
- glClearColor(0,0,0,0);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glLoadIdentity();
- glTranslatef( 0.0, 0.0, 1.0);
- glBegin(GL_POLYGON);
- glColor3f(1,0,0); // alle weiteren Vertice werden rot gezeichnet
- glVertex3f(0.0, 0.0, 0.0);
- glColor3f(0,1,0); // alle weiteren Verticen werden grün gezeichnet
- glVertex3f( 0.0, 1.0, 0.0);
- glColor3f(0,0,1); // alle weiteren Verticen werden blau gezeichnet
- glVertex3f( 1.0, 1.0, 0.0);
- glEnd();
- glutSwapBuffers();
- }
- int main(int argc, char** argv) {
- glutInit(&argc,argv);
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
- glutInitWindowSize(800, 600);
- glutCreateWindow("Dreieck");
- glutDisplayFunc(display);
- glutMainLoop();
- }