+static void
+WindowStatus(int state)
+{
+ int winIdx;
+ int window = getWindowAndIdx(&winIdx);
+ printf ( "%6d Window %d WindowStatus Callback: %d\n",
+ ++sequence_number, window, state ) ;
+ windowStatus_called[winIdx] = 1 ;
+ windowStatus_state[winIdx] = state ;
+ windowStatus_seq[winIdx] = sequence_number ;
+ glutPostRedisplay () ;
+}
+
+static void
+SpaceMotion(int x, int y, int z)
+{
+ int window = getWindowAndIdx(NULL);
+ printf ( "%6d Window %d SpaceMotion Callback: %d %d %d\n",
+ ++sequence_number, window, x, y, z ) ;
+ glutPostRedisplay () ;
+}
+
+static void
+SpaceRotation(int x, int y, int z)
+{
+ int window = getWindowAndIdx(NULL);
+ printf ( "%6d Window %d SpaceRotation Callback: %d %d %d\n",
+ ++sequence_number, window, x, y, z ) ;
+ glutPostRedisplay () ;
+}
+
+static void
+SpaceButton(int button, int updown)
+{
+ int window = getWindowAndIdx(NULL);
+ printf ( "%6d Window %d SpaceButton Callback: %d %d\n",
+ ++sequence_number, window, button, updown ) ;
+ glutPostRedisplay () ;
+}
+
+static void
+Dials(int x, int y)
+{
+ int window = getWindowAndIdx(NULL);
+ printf ( "%6d Window %d Dials Callback: %d %d\n",
+ ++sequence_number, window, x, y ) ;
+ glutPostRedisplay () ;
+}
+
+static void
+ButtonBox(int button, int updown)
+{
+ int window = getWindowAndIdx(NULL);
+ printf ( "%6d Window %d ButtonBox Callback: %d %d\n",
+ ++sequence_number, window, button, updown ) ;
+ glutPostRedisplay () ;
+}
+
+static void
+TabletMotion(int x, int y)
+{
+ int window = getWindowAndIdx(NULL);
+ printf ( "%6d Window %d TabletMotion Callback: %d %d\n",
+ ++sequence_number, window, x, y ) ;
+ glutPostRedisplay () ;
+}
+
+static void
+TabletButton(int button, int updown, int x, int y)
+{
+ int window = getWindowAndIdx(NULL);
+ printf ( "%6d Window %d TabletButton Callback: %d %d %d %d\n",
+ ++sequence_number, window, button, updown, x, y ) ;
+ glutPostRedisplay () ;
+}
+
+static void
+MenuCallback ( int value )
+{
+ int menu = glutGetMenu();
+ int window = getWindowAndIdx(NULL);
+ printf( "%6d Menu %d MenuCallback for menu opened in Window %d - value is %d\n",
+ ++sequence_number, menu, window, value );
+}
+
+static void
+MenuDestroy( void )
+{
+ int menu = glutGetMenu();
+ menudestroy_called = 1 ;
+ printf ( "%6d Menu %d MenuDestroy Callback\n",
+ ++sequence_number, menu ) ;
+}
+
+static void
+MenuStatus( int status, int x, int y )
+{
+ /* Menu and window for which this event is triggered are current when the callback is called */
+ int menu = glutGetMenu();
+ int window = getWindowAndIdx(NULL);
+ menustatus_called = 1 ;
+ printf ( "%6d Menu %d MenuStatus Callback in Window %d: %d %d %d\n",
+ ++sequence_number, menu, window, status, x, y ) ;
+ glutPostRedisplay () ;
+}
+
+
+static void
+MenuState( int status )
+{
+ /* Menu and window for which this event is triggered are current when the callback is called */
+ int menu = glutGetMenu();
+ int window = getWindowAndIdx(NULL);
+ menustate_called = 1 ;
+ printf ( "%6d Menu %d MenuState Callback in Window %d: %d\n",
+ ++sequence_number, menu, window, status) ;
+ glutPostRedisplay () ;
+}
+
+static void Idle ( void )
+{
+ ++sequence_number ;
+}
+
+static void SetWindowCallbacks( int first )
+{
+ /* All these callbacks are set for only the current window */
+ glutDisplayFunc( Display );
+ glutReshapeFunc( Reshape );
+ glutPositionFunc( Position );
+ glutKeyboardFunc( Key );
+ glutSpecialFunc( Special );
+ glutKeyboardUpFunc( KeyUp );
+ glutSpecialUpFunc( SpecialUp );
+ if (first)
+ glutJoystickFunc( Joystick, 100 );
+ glutMouseFunc ( Mouse ) ;
+ glutMouseWheelFunc ( MouseWheel ) ;
+ glutMotionFunc ( Motion ) ;
+ glutPassiveMotionFunc ( PassiveMotion ) ;
+ glutEntryFunc ( Entry ) ;
+ glutCloseFunc ( Close ) ;
+ glutOverlayDisplayFunc ( OverlayDisplay ) ;
+ glutSpaceballMotionFunc ( SpaceMotion ) ;
+ glutSpaceballRotateFunc ( SpaceRotation ) ;
+ glutSpaceballButtonFunc ( SpaceButton ) ;
+ glutButtonBoxFunc ( ButtonBox ) ;
+ glutDialsFunc ( Dials ) ;
+ glutTabletMotionFunc ( TabletMotion ) ;
+ glutTabletButtonFunc ( TabletButton ) ;
+ /* glutVisibilityFunc is deprecated in favor of glutWindowStatusFunc, which provides more detail.
+ * Setting one of these overwrites the other (see docs).
+ */
+ glutVisibilityFunc ( Visibility ); /* This will thus never be called, as glutWindowStatusFunc is set afterwards */
+ glutWindowStatusFunc ( WindowStatus ) ;
+}