ec935160ae6400f0aa96f543bd023acc493a84b4
[freeglut] / progs / demos / CallbackMaker / CallbackMaker.c
1 /* CallbackMaker.c */
2 /*
3  * Program to invoke all the callbacks that "freeglut" supports
4  */
5
6
7 #include <GL/freeglut.h>
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <stdarg.h>
11
12 static int sequence_number = 0 ;
13
14 int windows[2] = {0};
15
16 /* define status vars showing whether given callback has been called for given window */
17 #define CALLBACK_CALLED_VAR(name)                     int name##_called[2]   = {0};
18 #define CALLBACK_0V(name)                             int name##_seq[2]      = {-1}; CALLBACK_CALLED_VAR(name); 
19 #define CALLBACK_1V(name,field)                       int name##_##field[2]  = {-1}; CALLBACK_0V(name);
20 #define CALLBACK_2V(name,field1,field2)               int name##_##field2[2] = {-1}; CALLBACK_1V(name,field1);
21 #define CALLBACK_3V(name,field1,field2,field3)        int name##_##field3[2] = {-1}; CALLBACK_2V(name,field1,field2);
22 #define CALLBACK_4V(name,field1,field2,field3,field4) int name##_##field4[2] = {-1}; CALLBACK_3V(name,field1,field2,field3);
23 CALLBACK_2V(reshape,width,height);
24 CALLBACK_2V(position,top,left);
25 CALLBACK_3V(key,key,x,y);
26 CALLBACK_3V(keyup,key,x,y);
27 CALLBACK_3V(special,key,x,y);
28 CALLBACK_3V(specialup,key,x,y);
29 CALLBACK_1V(visibility,vis);
30 CALLBACK_4V(joystick,a,b,c,d);
31 CALLBACK_4V(mouse,button,updown,x,y);
32 CALLBACK_4V(mousewheel,number,direction,x,y);
33 CALLBACK_2V(motion,x,y);
34 CALLBACK_2V(passivemotion,x,y);
35 CALLBACK_0V(entry);
36 CALLBACK_0V(close);
37 /* menudestroy is registered on each menu, not a window */
38 int menudestroy_called = 0 ;
39 /* menustatus and menustate are global callbacks, set for all menus at the same time */
40 int menustatus_called = 0;
41 int menustate_called = 0;
42
43 #define STRING_LENGTH   10
44
45 static void
46 bitmapPrintf (const char *fmt, ...)
47 {
48     static char buf[256];
49     va_list args;
50
51     va_start(args, fmt);
52 #if defined(WIN32) && !defined(__CYGWIN__)
53     (void) _vsnprintf (buf, sizeof(buf), fmt, args);
54 #else
55     (void) vsnprintf (buf, sizeof(buf), fmt, args);
56 #endif
57     va_end(args);
58     glutBitmapString ( GLUT_BITMAP_HELVETICA_12, (unsigned char*)buf ) ;
59 }
60
61 static int
62 getWindowAndIdx(int *winIdx)
63 {
64     int window = glutGetWindow();
65
66     if (winIdx)
67         (*winIdx) = window==windows[0]?0:1;
68
69     return window;
70 }
71
72 static void 
73 Display(void)
74 {
75   int winIdx;
76   int window = getWindowAndIdx(&winIdx);
77   glClear ( GL_COLOR_BUFFER_BIT );
78
79   glDisable ( GL_DEPTH_TEST );
80   glMatrixMode ( GL_PROJECTION );
81   glPushMatrix();
82   glLoadIdentity();
83   glOrtho(0, glutGet ( GLUT_WINDOW_WIDTH ), 
84           0, glutGet ( GLUT_WINDOW_HEIGHT ), -1, 1 );
85   glMatrixMode ( GL_MODELVIEW );
86   glPushMatrix ();
87   glLoadIdentity ();
88   glColor3ub ( 0, 0, 0 );
89   glRasterPos2i ( 10, glutGet ( GLUT_WINDOW_HEIGHT ) - 20 );    /* 10pt margin above 10pt letters */
90
91   if ( reshape_called[winIdx] )
92   {
93     bitmapPrintf ( "Reshape %d:  %d %d\n", reshape_seq[winIdx], reshape_width[winIdx], reshape_height[winIdx] );
94   }
95
96   if ( position_called[winIdx] )
97   {
98     bitmapPrintf ( "Position %d:  %d %d\n", position_seq[winIdx], position_left[winIdx], position_top[winIdx] );
99   }
100
101   if ( key_called[winIdx] )
102   {
103     bitmapPrintf ( "Key %d:  %d(%c) %d %d\n", key_seq[winIdx], key_key[winIdx], key_key[winIdx], key_x[winIdx], key_y[winIdx] );
104   }
105
106   if ( special_called[winIdx] )
107   {
108     bitmapPrintf ( "Special %d:  %d(%c) %d %d\n", special_seq[winIdx], special_key[winIdx], special_key[winIdx], special_x[winIdx], special_y[winIdx] );
109   }
110
111   if ( visibility_called[winIdx] )
112   {
113     bitmapPrintf ( "Visibility %d:  %d\n", visibility_seq[winIdx], visibility_vis[winIdx] );
114   }
115
116   if ( keyup_called[winIdx] )
117   {
118     bitmapPrintf ( "Key Up %d:  %d(%c) %d %d\n", keyup_seq[winIdx], keyup_key[winIdx], keyup_key[winIdx], keyup_x[winIdx], keyup_y[winIdx] );
119   }
120
121   if ( specialup_called[winIdx] )
122   {
123     bitmapPrintf ( "Special Up %d:  %d(%c) %d %d\n", specialup_seq[winIdx], specialup_key[winIdx], specialup_key[winIdx], specialup_x[winIdx], specialup_y[winIdx] );
124   }
125
126   if ( joystick_called[winIdx] )
127   {
128     bitmapPrintf ( "Joystick %d:  %d %d %d %d\n", joystick_seq[winIdx], joystick_a[winIdx], joystick_b[winIdx], joystick_c[winIdx], joystick_d[winIdx] );
129   }
130
131   if ( mouse_called[winIdx] )
132   {
133     bitmapPrintf ( "Mouse %d:  %d %d %d %d\n", mouse_seq[winIdx], mouse_button[winIdx], mouse_updown[winIdx], mouse_x[winIdx], mouse_y[winIdx] );
134   }
135
136   if ( mousewheel_called[winIdx] )
137   {
138     bitmapPrintf ( "Mouse Wheel %d:  %d %d %d %d\n", mousewheel_seq[winIdx], mousewheel_number[winIdx], mousewheel_direction[winIdx], mousewheel_x[winIdx], mousewheel_y[winIdx] );
139   }
140
141   if ( motion_called[winIdx] )
142   {
143     bitmapPrintf ( "Motion %d:  %d %d\n", motion_seq[winIdx], motion_x[winIdx], motion_y[winIdx] );
144   }
145
146   if ( passivemotion_called[winIdx] )
147   {
148     bitmapPrintf ( "Passive Motion %d:  %d %d\n", passivemotion_seq[winIdx], passivemotion_x[winIdx], passivemotion_y[winIdx] );
149   }
150
151   glMatrixMode ( GL_PROJECTION );
152   glPopMatrix ();
153   glMatrixMode ( GL_MODELVIEW );
154   glPopMatrix ();
155   glEnable ( GL_DEPTH_TEST );
156
157   printf ( "%6d Window %d Display Callback\n",
158             ++sequence_number, window ) ;
159   glutSwapBuffers();
160 }
161
162 static void
163 Warning(const char *fmt, va_list ap)
164 {
165     printf("%6d Warning callback:\n");
166
167     /* print warning message */
168     vprintf(fmt, ap);
169 }
170
171 static void
172 Error(const char *fmt, va_list ap)
173 {
174     char dummy_string[STRING_LENGTH];
175     printf("%6d Error callback:\n");
176
177     /* print warning message */
178     vprintf(fmt, ap);
179
180     /* terminate program, after pause for input so user can see */
181     printf ( "Please enter something to exit: " );
182     fgets ( dummy_string, STRING_LENGTH, stdin );
183
184     /* Call exit directly as freeglut is messed
185      * up internally when an error is called. 
186      */
187     exit(1);
188 }
189
190 static void 
191 Reshape(int width, int height)
192 {
193   int winIdx;
194   int window = getWindowAndIdx(&winIdx);
195   printf ( "%6d Window %d Reshape Callback:  %d %d\n",
196             ++sequence_number, window, width, height ) ;
197   reshape_called[winIdx] = 1 ;
198   reshape_width[winIdx] = width ;
199   reshape_height[winIdx] = height ;
200   reshape_seq[winIdx] = sequence_number ;
201   glViewport(0,0,width,height);
202   glutPostRedisplay () ;
203 }
204
205 static void 
206 Position(int left, int top)
207 {
208   int winIdx;
209   int window = getWindowAndIdx(&winIdx);
210   printf ( "%6d Window %d Reshape Callback:  %d %d\n",
211             ++sequence_number, window, left, top ) ;
212   position_called[winIdx] = 1 ;
213   position_left[winIdx] = left ;
214   position_top[winIdx] = top ;
215   position_seq[winIdx] = sequence_number ;
216   glutPostRedisplay () ;
217 }
218
219 static void 
220 Key(unsigned char key, int x, int y)
221 {
222   int winIdx;
223   int window = getWindowAndIdx(&winIdx);
224   printf ( "%6d Window %d Keyboard Callback:  %d %d %d\n",
225             ++sequence_number, window, key, x, y ) ;
226   key_called[winIdx] = 1 ;
227   key_key[winIdx] = key ;
228   key_x[winIdx] = x ;
229   key_y[winIdx] = y ;
230   key_seq[winIdx] = sequence_number ;
231   glutPostRedisplay () ;
232 }
233
234 static void 
235 Special(int key, int x, int y)
236 {
237   int winIdx;
238   int window = getWindowAndIdx(&winIdx);
239   printf ( "%6d Window %d Special Key Callback:  %d %d %d\n",
240             ++sequence_number, window, key, x, y ) ;
241   special_called[winIdx] = 1 ;
242   special_key[winIdx] = key ;
243   special_x[winIdx] = x ;
244   special_y[winIdx] = y ;
245   special_seq[winIdx] = sequence_number ;
246   glutPostRedisplay () ;
247 }
248
249 static void 
250 Visibility(int vis)
251 {
252   int winIdx;
253   int window = getWindowAndIdx(&winIdx);
254   printf ( "%6d Window %d Visibility Callback:  %d\n",
255             ++sequence_number, window, vis ) ;
256   visibility_called[winIdx] = 1 ;
257   visibility_vis[winIdx] = vis ;
258   visibility_seq[winIdx] = sequence_number ;
259   glutPostRedisplay () ;
260 }
261
262 static void 
263 KeyUp(unsigned char key, int x, int y)
264 {
265   int winIdx;
266   int window = getWindowAndIdx(&winIdx);
267   printf ( "%6d Window %d Key Release Callback:  %d %d %d\n",
268             ++sequence_number, window, key, x, y ) ;
269   keyup_called[winIdx] = 1 ;
270   keyup_key[winIdx] = key ;
271   keyup_x[winIdx] = x ;
272   keyup_y[winIdx] = y ;
273   keyup_seq[winIdx] = sequence_number ;
274   glutPostRedisplay () ;
275 }
276
277 static void 
278 SpecialUp(int key, int x, int y)
279 {
280   int winIdx;
281   int window = getWindowAndIdx(&winIdx);
282   printf ( "%6d Window %d Special Key Release Callback:  %d %d %d\n",
283             ++sequence_number, window, key, x, y ) ;
284   specialup_called[winIdx] = 1 ;
285   specialup_key[winIdx] = key ;
286   specialup_x[winIdx] = x ;
287   specialup_y[winIdx] = y ;
288   specialup_seq[winIdx] = sequence_number ;
289   glutPostRedisplay () ;
290 }
291
292 static void 
293 Joystick( unsigned int a, int b, int c, int d)  /* Need meaningful names */
294 {
295   int winIdx;
296   int window = getWindowAndIdx(&winIdx);
297   printf ( "%6d Window %d Joystick Callback:  %d %d %d %d\n",
298             ++sequence_number, window, a, b, c, d ) ;
299   joystick_called[winIdx] = 1 ;
300   joystick_a[winIdx] = a ;
301   joystick_b[winIdx] = b ;
302   joystick_c[winIdx] = c ;
303   joystick_d[winIdx] = d ;
304   joystick_seq[winIdx] = sequence_number ;
305   glutPostRedisplay () ;
306 }
307
308 static void 
309 Mouse(int button, int updown, int x, int y)
310 {
311   int winIdx;
312   int window = getWindowAndIdx(&winIdx);
313   printf ( "%6d Window %d Mouse Click Callback:  %d %d %d %d\n",
314             ++sequence_number, window, button, updown, x, y ) ;
315   mouse_called[winIdx] = 1 ;
316   mouse_button[winIdx] = button ;
317   mouse_updown[winIdx] = updown ;
318   mouse_x[winIdx] = x ;
319   mouse_y[winIdx] = y ;
320   mouse_seq[winIdx] = sequence_number ;
321   glutPostRedisplay () ;
322 }
323
324 static void 
325 MouseWheel(int wheel_number, int direction, int x, int y)
326 {
327   int winIdx;
328   int window = getWindowAndIdx(&winIdx);
329   printf ( "%6d Window %d Mouse Wheel Callback:  %d %d %d %d\n",
330             ++sequence_number, window, wheel_number, direction, x, y ) ;
331   mousewheel_called[winIdx] = 1 ;
332   mousewheel_number[winIdx] = wheel_number ;
333   mousewheel_direction[winIdx] = direction ;
334   mousewheel_x[winIdx] = x ;
335   mousewheel_y[winIdx] = y ;
336   mousewheel_seq[winIdx] = sequence_number ;
337   glutPostRedisplay () ;
338 }
339
340 static void 
341 Motion(int x, int y)
342 {
343   int winIdx;
344   int window = getWindowAndIdx(&winIdx);
345   printf ( "%6d Window %d Mouse Motion Callback:  %d %d\n",
346             ++sequence_number, window, x, y ) ;
347   motion_called[winIdx] = 1 ;
348   motion_x[winIdx] = x ;
349   motion_y[winIdx] = y ;
350   motion_seq[winIdx] = sequence_number ;
351   glutPostRedisplay () ;
352 }
353
354 static void 
355 PassiveMotion(int x, int y)
356 {
357   int winIdx;
358   int window = getWindowAndIdx(&winIdx);
359   printf ( "%6d Window %d Mouse Passive Motion Callback:  %d %d\n",
360             ++sequence_number, window, x, y ) ;
361   passivemotion_called[winIdx] = 1 ;
362   passivemotion_x[winIdx] = x ;
363   passivemotion_y[winIdx] = y ;
364   passivemotion_seq[winIdx] = sequence_number ;
365   glutPostRedisplay () ;
366 }
367
368 static void 
369 Entry(int state)
370 {
371   int window = getWindowAndIdx(NULL);
372   printf ( "%6d Window %d Entry Callback:  %d\n",
373             ++sequence_number, window, state ) ;
374   glutPostRedisplay () ;
375 }
376
377 static void 
378 Close(void)
379 {
380   int window = getWindowAndIdx(NULL);
381   printf ( "%6d Window %d Close Callback\n",
382             ++sequence_number, window ) ;
383 }
384
385 static void 
386 OverlayDisplay(void)
387 {
388   int window = getWindowAndIdx(NULL);
389   printf ( "%6d Window %d OverlayDisplay Callback\n",
390             ++sequence_number, window ) ;
391   glutPostRedisplay () ;
392 }
393
394 static void 
395 WindowStatus(int state)
396 {
397   int window = getWindowAndIdx(NULL);
398   printf ( "%6d Window %d WindowStatus Callback:  %d\n",
399             ++sequence_number, window, state ) ;
400   glutPostRedisplay () ;
401 }
402
403 static void 
404 SpaceMotion(int x, int y, int z)
405 {
406   int window = getWindowAndIdx(NULL);
407   printf ( "%6d Window %d SpaceMotion Callback:  %d %d %d\n",
408             ++sequence_number, window, x, y, z ) ;
409   glutPostRedisplay () ;
410 }
411
412 static void 
413 SpaceRotation(int x, int y, int z)
414 {
415   int window = getWindowAndIdx(NULL);
416   printf ( "%6d Window %d SpaceRotation Callback:  %d %d %d\n",
417             ++sequence_number, window, x, y, z ) ;
418   glutPostRedisplay () ;
419 }
420
421 static void 
422 SpaceButton(int button, int updown)
423 {
424   int window = getWindowAndIdx(NULL);
425   printf ( "%6d Window %d SpaceButton Callback:  %d %d\n",
426             ++sequence_number, window, button, updown ) ;
427   glutPostRedisplay () ;
428 }
429
430 static void 
431 Dials(int x, int y)
432 {
433   int window = getWindowAndIdx(NULL);
434   printf ( "%6d Window %d Dials Callback:  %d %d\n",
435             ++sequence_number, window, x, y ) ;
436   glutPostRedisplay () ;
437 }
438
439 static void 
440 ButtonBox(int button, int updown)
441 {
442   int window = getWindowAndIdx(NULL);
443   printf ( "%6d Window %d ButtonBox Callback:  %d %d\n",
444             ++sequence_number, window, button, updown ) ;
445   glutPostRedisplay () ;
446 }
447
448 static void 
449 TabletMotion(int x, int y)
450 {
451   int window = getWindowAndIdx(NULL);
452   printf ( "%6d Window %d TabletMotion Callback:  %d %d\n",
453             ++sequence_number, window, x, y ) ;
454   glutPostRedisplay () ;
455 }
456
457 static void 
458 TabletButton(int button, int updown, int x, int y)
459 {
460   int window = getWindowAndIdx(NULL);
461   printf ( "%6d Window %d TabletButton Callback:  %d %d %d %d\n",
462             ++sequence_number, window, button, updown, x, y ) ;
463   glutPostRedisplay () ;
464 }
465
466 static void
467 MenuCallback ( int value )
468 {
469   int menu = glutGetMenu();
470   int window = getWindowAndIdx(NULL);
471   printf( "%6d Menu %d MenuCallback for menu opened in Window %d - value is %d\n",
472           ++sequence_number, menu, window, value );
473 }
474
475 static void 
476 MenuDestroy( void )
477 {
478   int menu = glutGetMenu();
479   menudestroy_called = 1 ;
480   printf ( "%6d Menu %d MenuDestroy Callback\n",
481             ++sequence_number, menu ) ;
482 }
483
484 static void 
485 MenuStatus( int status, int x, int y )
486 {
487   /* Menu and window for which this event is triggered are current when the callback is called */
488   int menu = glutGetMenu();
489   int window = getWindowAndIdx(NULL);
490   menustatus_called = 1 ;
491   printf ( "%6d Menu %d MenuStatus Callback in Window %d:  %d %d %d\n",
492             ++sequence_number, menu, window, status, x, y ) ;
493   glutPostRedisplay () ;
494 }
495
496
497 static void 
498 MenuState( int status )
499 {
500   /* Menu and window for which this event is triggered are current when the callback is called */
501   int menu = glutGetMenu();
502   int window = getWindowAndIdx(NULL);
503   menustate_called = 1 ;
504   printf ( "%6d Menu %d MenuState Callback in Window %d:  %d\n",
505             ++sequence_number, menu, window, status) ;
506   glutPostRedisplay () ;
507 }
508
509 static void Idle ( void )
510 {
511   ++sequence_number ;
512 }
513
514 int 
515 main(int argc, char *argv[])
516 {
517   char dummy_string[STRING_LENGTH];
518
519   int menuID, subMenuA, subMenuB;
520
521   glutInitWarningFunc(Warning);
522   glutInitErrorFunc(Error);
523   glutInitWindowSize(500, 250);
524   glutInitWindowPosition ( 140, 140 );
525   glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE );
526   glutInit(&argc, argv);
527   glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE,GLUT_ACTION_CONTINUE_EXECUTION);
528
529   /* Set other global callback (global as in not associated with any specific menu or window) */
530   glutIdleFunc ( Idle );
531   glutMenuStatusFunc ( MenuStatus );
532   glutMenuStateFunc  ( MenuState ); /* Note that glutMenuStatusFunc is an enhanced version of the deprecated glutMenuStateFunc. */
533
534   windows[0] = glutCreateWindow( "Callback Demo" );
535   printf ( "Creating window %d as 'Callback Demo'\n", windows[0] ) ;
536
537   glClearColor(1.0, 1.0, 1.0, 1.0);
538
539   /* callbacks and settings specific to this window */
540   glutDisplayFunc( Display );
541   glutReshapeFunc( Reshape );
542   glutPositionFunc( Position );
543   glutKeyboardFunc( Key );
544   glutSpecialFunc( Special );
545   glutVisibilityFunc( Visibility );
546   glutKeyboardUpFunc( KeyUp );
547   glutSpecialUpFunc( SpecialUp );
548   glutJoystickFunc( Joystick, 100 );
549   glutMouseFunc ( Mouse ) ;
550   glutMouseWheelFunc ( MouseWheel ) ;
551   glutMotionFunc ( Motion ) ;
552   glutPassiveMotionFunc ( PassiveMotion ) ;
553   glutEntryFunc ( Entry ) ;
554   glutCloseFunc ( Close ) ;
555   glutOverlayDisplayFunc ( OverlayDisplay ) ;
556   glutWindowStatusFunc ( WindowStatus ) ;
557   glutSpaceballMotionFunc ( SpaceMotion ) ;
558   glutSpaceballRotateFunc ( SpaceRotation ) ;
559   glutSpaceballButtonFunc ( SpaceButton ) ;
560   glutButtonBoxFunc ( ButtonBox ) ;
561   glutDialsFunc ( Dials ) ;
562   glutTabletMotionFunc ( TabletMotion ) ;
563   glutTabletButtonFunc ( TabletButton ) ;
564   glutSetKeyRepeat(GLUT_KEY_REPEAT_OFF) ;
565
566   subMenuA = glutCreateMenu( MenuCallback );
567   glutAddMenuEntry( "Sub menu A1 (01)", 11 );
568   glutAddMenuEntry( "Sub menu A2 (02)", 12 );
569   glutAddMenuEntry( "Sub menu A3 (03)", 13 );
570   glutMenuDestroyFunc ( MenuDestroy );  /* callback specific to this menu */
571
572   subMenuB = glutCreateMenu( MenuCallback );
573   glutAddMenuEntry( "Sub menu B1 (04)", 14 );
574   glutAddMenuEntry( "Sub menu B2 (05)", 15 );
575   glutAddMenuEntry( "Sub menu B3 (06)", 16 );
576   glutAddSubMenu( "Going to sub menu A", subMenuA );
577   glutMenuDestroyFunc ( MenuDestroy );  /* callback specific to this menu */
578
579   menuID = glutCreateMenu( MenuCallback );
580   glutAddMenuEntry( "Entry one",   21 );
581   glutAddMenuEntry( "Entry two",   22 );
582   glutAddMenuEntry( "Entry three", 23 );
583   glutAddMenuEntry( "Entry four",  24 );
584   glutAddMenuEntry( "Entry five",  25 );
585   glutAddSubMenu( "Enter sub menu A", subMenuA );
586   glutAddSubMenu( "Enter sub menu B", subMenuB );
587   glutMenuDestroyFunc ( MenuDestroy );  /* callback specific to this menu */
588
589   glutAttachMenu( GLUT_LEFT_BUTTON );
590
591   glutInitWindowPosition ( 140+500+2*glutGet(GLUT_WINDOW_BORDER_WIDTH), 140 );
592   /* Position second window right next to the first */
593   windows[1] = glutCreateWindow( "Second Window" );
594   printf ( "Creating window %d as 'Second Window'\n", windows[1] ) ;
595
596   glClearColor(1.0, 1.0, 1.0, 1.0);
597
598   /* callbacks and settings specific to this window */
599   glutDisplayFunc( Display );
600   glutReshapeFunc( Reshape );
601   glutPositionFunc( Position );
602   glutKeyboardFunc( Key );
603   glutSpecialFunc( Special );
604   glutVisibilityFunc( Visibility );
605   glutKeyboardUpFunc( KeyUp );
606   glutSpecialUpFunc( SpecialUp );
607   /*  glutJoystickFunc( Joystick, 100 ); */
608   glutMouseFunc ( Mouse ) ;
609   glutMouseWheelFunc ( MouseWheel ) ;
610   glutMotionFunc ( Motion ) ;
611   glutPassiveMotionFunc ( PassiveMotion ) ;
612   glutEntryFunc ( Entry ) ;
613   glutCloseFunc ( Close ) ;
614   glutOverlayDisplayFunc ( OverlayDisplay ) ;
615   glutWindowStatusFunc ( WindowStatus ) ;
616   glutSpaceballMotionFunc ( SpaceMotion ) ;
617   glutSpaceballRotateFunc ( SpaceRotation ) ;
618   glutSpaceballButtonFunc ( SpaceButton ) ;
619   glutButtonBoxFunc ( ButtonBox ) ;
620   glutDialsFunc ( Dials ) ;
621   glutTabletMotionFunc ( TabletMotion ) ;
622   glutTabletButtonFunc ( TabletButton ) ;
623   glutSetKeyRepeat(GLUT_KEY_REPEAT_OFF) ;
624
625   glutSetMenu(subMenuB);
626   glutAttachMenu( GLUT_RIGHT_BUTTON );
627
628
629   printf ( "Please enter something to continue: " );
630   fgets ( dummy_string, STRING_LENGTH, stdin );
631
632   glutMainLoop();
633
634   printf ( "Back from the 'freeglut' main loop\n" ) ;
635
636   return EXIT_SUCCESS;
637 }