/*
    fullglut.c     **** Vertiefung für Glut: Windows, Eingabe ****

    - Wie firstglut.c, erweitert um die wesentlichen Glut-"Functions".
    - Zum Ausprobieren; nützliche Funktionen können in später in eigene
      Programme kopiert werden.
    - Neu: Programmabbruch mit q-Taste (statt einer beliebigen Taste).
    - Keine neuen OpenGL-Funktionen.


    > Welche Funktionen sind gegenüber firstglut.c hinzugekommen?

    > Wann werden diese aufgerufen, wozu können sie nützlich sein?

    > glutPassiveMotionFunc() und glutIdleFunc() sind zunächst
      auskommentiert. Bitte Kommentare entfernen und ausprobieren.
      Warum waren sie zu Anfang wohl auskommentiert?

    > Was bedeutet der state-Wert beispielsweise bei der
      entry_func()? Tip: die man-page zu glutEntryFunc lesen
      (Unix-Kommando: man glutEntryFunc).
      Welche Vorteile hat die Verwendung von symbolischen Konstanten
      wie GLUT_LEFT, GLUT_ENTERED gegenüber "nackten" Zahlen wie
      0 und 1 in Programmen. (Und warum ist GLUT_LEFT vielleicht
      kein besonders gut gewählter Symbolname ? ;-)
*/



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



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

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



static void     reshape_func (int width, int height)
/**************************************************/
{
    printf ("reshape_func (width=%d, height=%d)\n", width, height);
    glViewport (0, 0, width, height);
}



static void     visibility_func (int state)
/*****************************************/
{
    printf ("visibility_func (state=%d)\n", state);
}



static void     windowstatus_func (int state)
/*******************************************/
{
    printf ("windowstatus_func (state=%d)\n", state);
}



static void     entry_func (int state)
/************************************/
{
    printf ("entry_func (state=%d)\n", state);
}



static void     mouse_func (int button, int state, int x, int y)
/**************************************************************/
{
    printf ("mouse_func (button=%d, state=%d, x=%d, y=%d)\n",
        button, state, x, y);
}



static void     motion_func (int x, int y)
/****************************************/
{
    printf ("motion_func (x=%d, y=%d)\n", x, y);
}



static void     passivemotion_func (int x, int y)
/***********************************************/
{
    printf ("passivemotion_func (x=%d, y=%d)\n", x, y);
}



static void     dials_func (int dial, int value)
/**********************************************/
{
    printf ("dials_func (dial=%d, value=%d)\n", dial, value);
}



static void     keyboard_func (unsigned char key, int x, int y)
/*************************************************************/
{
    printf ("keyboard_func (key='%c', x=%d, y=%d)\n", key, x, y);

    if (key == 'q' || key == 'Q')
        exit (0);
}



static void     keyboard_up_func (unsigned char key, int x, int y)
/****************************************************************/
{
    printf ("keyboard_up_func (key='%c', x=%d, y=%d)\n", key, x, y);
}



static void     specialkey_func (int key, int x, int y)
/*****************************************************/
{
    printf ("specialkey_func (key=%d, x=%d, y=%d)\n", key, x, y);
}



static void     specialkey_up_func (int key, int x, int y)
/********************************************************/
{
    printf ("specialkey_up_func (key=%d, x=%d, y=%d)\n", key, x, y);
}



static void     timer_func (int value)
/************************************/
{
    printf ("timer_func (value=%d)\n", value);
}



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



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

    glutInitWindowPosition (200, 100);
    glutInitWindowSize (400, 400);
    glutCreateWindow ("fullglut");

    /* window functions: */
    glutDisplayFunc (display_func);
    glutReshapeFunc (reshape_func);
    glutVisibilityFunc (visibility_func);

    /* mouse (and dialbox) functions: */
    glutEntryFunc (entry_func);
    glutMouseFunc (mouse_func);
    glutMotionFunc (motion_func);
    /* glutPassiveMotionFunc (passivemotion_func); */
    glutDialsFunc (dials_func);

    /* keyboard functions: */
    glutKeyboardFunc (keyboard_func);
    glutKeyboardUpFunc (keyboard_up_func);
    glutSpecialFunc (specialkey_func);
    glutSpecialUpFunc (specialkey_up_func);

    /* timing and animation */
    glutTimerFunc (1000, timer_func, 1);
    glutTimerFunc (2000, timer_func, 2);
    glutTimerFunc (3000, timer_func, 3);
    glutTimerFunc (4000, timer_func, 4);
    glutTimerFunc (5000, timer_func, 5);
    /* glutIdleFunc (idle_func); */

    glutMainLoop ();

    return 0;
}




