/*
    list1.c

    - Zeigt die Verwendung von Displaylisten ("Grafikobjekten")
*/




# include       <stdio.h>
# include       <stdlib.h>
# include       <math.h>
# include       <GL/glut.h>



static GLuint   objekt_liste;



static void     erzeuge_objekt_liste (void)
/*****************************************/
{
    objekt_liste = glGenLists (1);
    glNewList (objekt_liste, GL_COMPILE);
        glBegin (GL_TRIANGLE_STRIP);
            glVertex2f (-0.2, -0.3);
            glVertex2f ( 0.0, -0.1);
            glVertex2f ( 0.0,  0.3);
            glVertex2f ( 0.2, -0.3);
        glEnd ();
    glEndList ();
}



static void     display_func (void)
/*********************************/
{
    /* printf ("display_func()\n"); */

    glClearColor (1, 1, 1, 0);
    glClear (GL_COLOR_BUFFER_BIT);

    glColor3f (0, 0, 0);
    glCallList (objekt_liste);

    glFlush ();
    glutReportErrors ();
}



static void     keyboard_func (unsigned char key, int x, int y)
/*************************************************************/
{
    exit (0);
}



extern int      main (int argc, char **argv)
/******************************************/
{
    glutInit (&argc, argv);
    glutInitDisplayMode (GLUT_RGB);

    glutInitWindowPosition (200, 100);
    glutInitWindowSize (600, 600);
    glutCreateWindow ("list1");

    glutDisplayFunc (display_func);
    glutKeyboardFunc (keyboard_func);

    erzeuge_objekt_liste ();

    glutMainLoop ();

    return 0;
}


