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