Setting the line endings and keywords on a bunch of new text files
[freeglut] / src / Common / freeglut_init.c
1 /*
2  * freeglut_init.c
3  *
4  * Various freeglut initialization functions.
5  *
6  * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
7  * Written by Pawel W. Olszta, <olszta@sourceforge.net>
8  * Creation date: Thu Dec 2 1999
9  *
10  * Permission is hereby granted, free of charge, to any person obtaining a
11  * copy of this software and associated documentation files (the "Software"),
12  * to deal in the Software without restriction, including without limitation
13  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14  * and/or sell copies of the Software, and to permit persons to whom the
15  * Software is furnished to do so, subject to the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be included
18  * in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
23  * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
24  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26  */
27
28 #define FREEGLUT_BUILDING_LIB
29 #include <GL/freeglut.h>
30 #include "freeglut_internal.h"
31
32 /*
33  * TODO BEFORE THE STABLE RELEASE:
34  *
35  *  fgDeinitialize()        -- Win32's OK, X11 needs the OS-specific
36  *                             deinitialization done
37  *  glutInitDisplayString() -- display mode string parsing
38  *
39  * Wouldn't it be cool to use gettext() for error messages? I just love
40  * bash saying  "nie znaleziono pliku" instead of "file not found" :)
41  * Is gettext easily portable?
42  */
43
44 /* -- GLOBAL VARIABLES ----------------------------------------------------- */
45
46 /*
47  * A structure pointed by g_pDisplay holds all information
48  * regarding the display, screen, root window etc.
49  */
50 SFG_Display fgDisplay;
51
52 /*
53  * The settings for the current freeglut session
54  */
55 SFG_State fgState = { { -1, -1, GL_FALSE },  /* Position */
56                       { 300, 300, GL_TRUE }, /* Size */
57                       GLUT_RGBA | GLUT_SINGLE | GLUT_DEPTH,  /* DisplayMode */
58                       GL_FALSE,              /* Initialised */
59                       GLUT_TRY_DIRECT_CONTEXT,  /* DirectContext */
60                       GL_FALSE,              /* ForceIconic */
61                       GL_FALSE,              /* UseCurrentContext */
62                       GL_FALSE,              /* GLDebugSwitch */
63                       GL_FALSE,              /* XSyncSwitch */
64                       GLUT_KEY_REPEAT_ON,    /* KeyRepeat */
65                       INVALID_MODIFIERS,     /* Modifiers */
66                       0,                     /* FPSInterval */
67                       0,                     /* SwapCount */
68                       0,                     /* SwapTime */
69                       0,                     /* Time */
70                       { NULL, NULL },         /* Timers */
71                       { NULL, NULL },         /* FreeTimers */
72                       NULL,                   /* IdleCallback */
73                       0,                      /* ActiveMenus */
74                       NULL,                   /* MenuStateCallback */
75                       NULL,                   /* MenuStatusCallback */
76                       { 640, 480, GL_TRUE },  /* GameModeSize */
77                       16,                     /* GameModeDepth */
78                       72,                     /* GameModeRefresh */
79                       GLUT_ACTION_EXIT,       /* ActionOnWindowClose */
80                       GLUT_EXEC_STATE_INIT,   /* ExecState */
81                       NULL,                   /* ProgramName */
82                       GL_FALSE,               /* JoysticksInitialised */
83                       0,                      /* NumActiveJoysticks */
84                       GL_FALSE,               /* InputDevsInitialised */
85                       0,                      /* MouseWheelTicks */
86                       1,                      /* AuxiliaryBufferNumber */
87                       4,                      /* SampleNumber */
88                       1,                      /* MajorVersion */
89                       0,                      /* MinorVersion */
90                       0,                      /* ContextFlags */
91                       0,                      /* ContextProfile */
92                       NULL,                   /* ErrorFunc */
93                       NULL                    /* WarningFunc */
94 };
95
96
97 /* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
98
99 extern void fgPlatformInitialize( const char* displayName );
100 extern void fgPlatformDeinitialiseInputDevices ( void );
101 extern void fgPlatformCloseDisplay ( void );
102 extern void fgPlatformDestroyContext ( SFG_PlatformDisplay pDisplay, SFG_WindowContextType MContext );
103
104
105 void fghParseCommandLineArguments ( int* pargc, char** argv, char **pDisplayName, char **pGeometry )
106 {
107 #ifndef _WIN32_WCE
108     int i, j, argc = *pargc;
109
110     {
111             /* check if GLUT_FPS env var is set */
112         const char *fps = getenv( "GLUT_FPS" );
113
114         if( fps )
115         {
116             int interval;
117             sscanf( fps, "%d", &interval );
118
119             if( interval <= 0 )
120                 fgState.FPSInterval = 5000;  /* 5000 millisecond default */
121             else
122                 fgState.FPSInterval = interval;
123         }
124     }
125
126     *pDisplayName = getenv( "DISPLAY" );
127
128     for( i = 1; i < argc; i++ )
129     {
130         if( strcmp( argv[ i ], "-display" ) == 0 )
131         {
132             if( ++i >= argc )
133                 fgError( "-display parameter must be followed by display name" );
134
135             *pDisplayName = argv[ i ];
136
137             argv[ i - 1 ] = NULL;
138             argv[ i     ] = NULL;
139             ( *pargc ) -= 2;
140         }
141         else if( strcmp( argv[ i ], "-geometry" ) == 0 )
142         {
143             if( ++i >= argc )
144                 fgError( "-geometry parameter must be followed by window "
145                          "geometry settings" );
146
147             *pGeometry = argv[ i ];
148
149             argv[ i - 1 ] = NULL;
150             argv[ i     ] = NULL;
151             ( *pargc ) -= 2;
152         }
153         else if( strcmp( argv[ i ], "-direct" ) == 0)
154         {
155             if( fgState.DirectContext == GLUT_FORCE_INDIRECT_CONTEXT )
156                 fgError( "parameters ambiguity, -direct and -indirect "
157                     "cannot be both specified" );
158
159             fgState.DirectContext = GLUT_FORCE_DIRECT_CONTEXT;
160             argv[ i ] = NULL;
161             ( *pargc )--;
162         }
163         else if( strcmp( argv[ i ], "-indirect" ) == 0 )
164         {
165             if( fgState.DirectContext == GLUT_FORCE_DIRECT_CONTEXT )
166                 fgError( "parameters ambiguity, -direct and -indirect "
167                     "cannot be both specified" );
168
169             fgState.DirectContext = GLUT_FORCE_INDIRECT_CONTEXT;
170             argv[ i ] = NULL;
171             (*pargc)--;
172         }
173         else if( strcmp( argv[ i ], "-iconic" ) == 0 )
174         {
175             fgState.ForceIconic = GL_TRUE;
176             argv[ i ] = NULL;
177             ( *pargc )--;
178         }
179         else if( strcmp( argv[ i ], "-gldebug" ) == 0 )
180         {
181             fgState.GLDebugSwitch = GL_TRUE;
182             argv[ i ] = NULL;
183             ( *pargc )--;
184         }
185         else if( strcmp( argv[ i ], "-sync" ) == 0 )
186         {
187             fgState.XSyncSwitch = GL_TRUE;
188             argv[ i ] = NULL;
189             ( *pargc )--;
190         }
191     }
192
193     /* Compact {argv}. */
194     for( i = j = 1; i < *pargc; i++, j++ )
195     {
196         /* Guaranteed to end because there are "*pargc" arguments left */
197         while ( argv[ j ] == NULL )
198             j++;
199         if ( i != j )
200             argv[ i ] = argv[ j ];
201     }
202
203 #endif /* _WIN32_WCE */
204
205 }
206
207
208 void fghCloseInputDevices ( void )
209 {
210     if ( fgState.JoysticksInitialised )
211         fgJoystickClose( );
212
213     if ( fgState.InputDevsInitialised )
214         fgInputDeviceClose( );
215 }
216
217
218 /*
219  * Perform the freeglut deinitialization...
220  */
221 void fgDeinitialize( void )
222 {
223     SFG_Timer *timer;
224
225     if( !fgState.Initialised )
226     {
227         return;
228     }
229
230         /* If we're in game mode, we want to leave game mode */
231     if( fgStructure.GameModeWindow ) {
232         glutLeaveGameMode();
233     }
234
235     /* If there was a menu created, destroy the rendering context */
236     if( fgStructure.MenuContext )
237     {
238                 fgPlatformDestroyContext (fgDisplay.pDisplay, fgStructure.MenuContext->MContext );
239         free( fgStructure.MenuContext );
240         fgStructure.MenuContext = NULL;
241     }
242
243     fgDestroyStructure( );
244
245     while( ( timer = fgState.Timers.First) )
246     {
247         fgListRemove( &fgState.Timers, &timer->Node );
248         free( timer );
249     }
250
251     while( ( timer = fgState.FreeTimers.First) )
252     {
253         fgListRemove( &fgState.FreeTimers, &timer->Node );
254         free( timer );
255     }
256
257         fgPlatformDeinitialiseInputDevices ();
258
259         fgState.MouseWheelTicks = 0;
260
261     fgState.MajorVersion = 1;
262     fgState.MinorVersion = 0;
263     fgState.ContextFlags = 0;
264     fgState.ContextProfile = 0;
265
266     fgState.Initialised = GL_FALSE;
267
268     fgState.Position.X = -1;
269     fgState.Position.Y = -1;
270     fgState.Position.Use = GL_FALSE;
271
272     fgState.Size.X = 300;
273     fgState.Size.Y = 300;
274     fgState.Size.Use = GL_TRUE;
275
276     fgState.DisplayMode = GLUT_RGBA | GLUT_SINGLE | GLUT_DEPTH;
277
278     fgState.DirectContext  = GLUT_TRY_DIRECT_CONTEXT;
279     fgState.ForceIconic         = GL_FALSE;
280     fgState.UseCurrentContext   = GL_FALSE;
281     fgState.GLDebugSwitch       = GL_FALSE;
282     fgState.XSyncSwitch         = GL_FALSE;
283     fgState.ActionOnWindowClose = GLUT_ACTION_EXIT;
284     fgState.ExecState           = GLUT_EXEC_STATE_INIT;
285
286     fgState.KeyRepeat       = GLUT_KEY_REPEAT_ON;
287     fgState.Modifiers       = INVALID_MODIFIERS;
288
289     fgState.GameModeSize.X  = 640;
290     fgState.GameModeSize.Y  = 480;
291     fgState.GameModeDepth   =  16;
292     fgState.GameModeRefresh =  72;
293
294     fgListInit( &fgState.Timers );
295     fgListInit( &fgState.FreeTimers );
296
297     fgState.IdleCallback = NULL;
298     fgState.MenuStateCallback = ( FGCBMenuState )NULL;
299     fgState.MenuStatusCallback = ( FGCBMenuStatus )NULL;
300
301     fgState.SwapCount   = 0;
302     fgState.SwapTime    = 0;
303     fgState.FPSInterval = 0;
304
305     if( fgState.ProgramName )
306     {
307         free( fgState.ProgramName );
308         fgState.ProgramName = NULL;
309     }
310
311         fgPlatformCloseDisplay ();
312
313     fgState.Initialised = GL_FALSE;
314 }
315
316
317 #if TARGET_HOST_MS_WINDOWS
318 #define NoValue         0x0000
319 #define XValue          0x0001
320 #define YValue          0x0002
321 #define WidthValue      0x0004
322 #define HeightValue     0x0008
323 #define AllValues       0x000F
324 #define XNegative       0x0010
325 #define YNegative       0x0020
326
327 extern int XParseGeometry (
328     const char *string,
329     int *x,
330     int *y,
331     unsigned int *width,    /* RETURN */
332     unsigned int *height);    /* RETURN */
333 #endif
334
335 /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
336
337 /*
338  * Perform initialization. This usually happens on the program startup
339  * and restarting after glutMainLoop termination...
340  */
341 void FGAPIENTRY glutInit( int* pargc, char** argv )
342 {
343     char* displayName = NULL;
344     char* geometry = NULL;
345     if( fgState.Initialised )
346         fgError( "illegal glutInit() reinitialization attempt" );
347
348     if (pargc && *pargc && argv && *argv && **argv)
349     {
350         fgState.ProgramName = strdup (*argv);
351
352         if( !fgState.ProgramName )
353             fgError ("Could not allocate space for the program's name.");
354     }
355
356     fgCreateStructure( );
357
358     /* Get start time */
359     fgState.Time = fgSystemTime();
360
361         fghParseCommandLineArguments ( pargc, argv, &displayName, &geometry );
362
363     /*
364      * Have the display created now. If there wasn't a "-display"
365      * in the program arguments, we will use the DISPLAY environment
366      * variable for opening the X display (see code above):
367      */
368     fgPlatformInitialize( displayName );
369
370     /*
371      * Geometry parsing deffered until here because we may need the screen
372      * size.
373      */
374
375     if (geometry )
376     {
377         unsigned int parsedWidth, parsedHeight;
378         int mask = XParseGeometry( geometry,
379                                    &fgState.Position.X, &fgState.Position.Y,
380                                    &parsedWidth, &parsedHeight );
381         /* TODO: Check for overflow? */
382         fgState.Size.X = parsedWidth;
383         fgState.Size.Y = parsedHeight;
384
385         if( (mask & (WidthValue|HeightValue)) == (WidthValue|HeightValue) )
386             fgState.Size.Use = GL_TRUE;
387
388         if( mask & XNegative )
389             fgState.Position.X += fgDisplay.ScreenWidth - fgState.Size.X;
390
391         if( mask & YNegative )
392             fgState.Position.Y += fgDisplay.ScreenHeight - fgState.Size.Y;
393
394         if( (mask & (XValue|YValue)) == (XValue|YValue) )
395             fgState.Position.Use = GL_TRUE;
396     }
397 }
398
399 /*
400  * Undoes all the "glutInit" stuff
401  */
402 void FGAPIENTRY glutExit ( void )
403 {
404   fgDeinitialize ();
405 }
406
407 /*
408  * Sets the default initial window position for new windows
409  */
410 void FGAPIENTRY glutInitWindowPosition( int x, int y )
411 {
412     fgState.Position.X = x;
413     fgState.Position.Y = y;
414
415     if( ( x >= 0 ) && ( y >= 0 ) )
416         fgState.Position.Use = GL_TRUE;
417     else
418         fgState.Position.Use = GL_FALSE;
419 }
420
421 /*
422  * Sets the default initial window size for new windows
423  */
424 void FGAPIENTRY glutInitWindowSize( int width, int height )
425 {
426     fgState.Size.X = width;
427     fgState.Size.Y = height;
428
429     if( ( width > 0 ) && ( height > 0 ) )
430         fgState.Size.Use = GL_TRUE;
431     else
432         fgState.Size.Use = GL_FALSE;
433 }
434
435 /*
436  * Sets the default display mode for all new windows
437  */
438 void FGAPIENTRY glutInitDisplayMode( unsigned int displayMode )
439 {
440     /* We will make use of this value when creating a new OpenGL context... */
441     fgState.DisplayMode = displayMode;
442 }
443
444
445 /* -- INIT DISPLAY STRING PARSING ------------------------------------------ */
446
447 static char* Tokens[] =
448 {
449     "alpha", "acca", "acc", "blue", "buffer", "conformant", "depth", "double",
450     "green", "index", "num", "red", "rgba", "rgb", "luminance", "stencil",
451     "single", "stereo", "samples", "slow", "win32pdf", "win32pfd", "xvisual",
452     "xstaticgray", "xgrayscale", "xstaticcolor", "xpseudocolor",
453     "xtruecolor", "xdirectcolor",
454     "xstaticgrey", "xgreyscale", "xstaticcolour", "xpseudocolour",
455     "xtruecolour", "xdirectcolour", "borderless", "aux"
456 };
457 #define NUM_TOKENS             (sizeof(Tokens) / sizeof(*Tokens))
458
459 void FGAPIENTRY glutInitDisplayString( const char* displayMode )
460 {
461     int glut_state_flag = 0 ;
462     /*
463      * Unpack a lot of options from a character string.  The options are
464      * delimited by blanks or tabs.
465      */
466     char *token ;
467     size_t len = strlen ( displayMode );
468     char *buffer = (char *)malloc ( (len+1) * sizeof(char) );
469     memcpy ( buffer, displayMode, len );
470     buffer[len] = '\0';
471
472     token = strtok ( buffer, " \t" );
473
474     while ( token )
475     {
476         /* Process this token */
477         int i ;
478
479         /* Temporary fix:  Ignore any length specifications and at least
480          * process the basic token
481          * TODO:  Fix this permanently
482          */
483         size_t cleanlength = strcspn ( token, "=<>~!" );
484
485         for ( i = 0; i < NUM_TOKENS; i++ )
486         {
487             if ( strncmp ( token, Tokens[i], cleanlength ) == 0 ) break ;
488         }
489
490         switch ( i )
491         {
492         case 0 :  /* "alpha":  Alpha color buffer precision in bits */
493             glut_state_flag |= GLUT_ALPHA ;  /* Somebody fix this for me! */
494             break ;
495
496         case 1 :  /* "acca":  Red, green, blue, and alpha accumulation buffer
497                      precision in bits */
498             break ;
499
500         case 2 :  /* "acc":  Red, green, and blue accumulation buffer precision
501                      in bits with zero bits alpha */
502             glut_state_flag |= GLUT_ACCUM ;  /* Somebody fix this for me! */
503             break ;
504
505         case 3 :  /* "blue":  Blue color buffer precision in bits */
506             break ;
507
508         case 4 :  /* "buffer":  Number of bits in the color index color buffer
509                    */
510             break ;
511
512         case 5 :  /* "conformant":  Boolean indicating if the frame buffer
513                      configuration is conformant or not */
514             break ;
515
516         case 6 : /* "depth":  Number of bits of precsion in the depth buffer */
517             glut_state_flag |= GLUT_DEPTH ;  /* Somebody fix this for me! */
518             break ;
519
520         case 7 :  /* "double":  Boolean indicating if the color buffer is
521                      double buffered */
522             glut_state_flag |= GLUT_DOUBLE ;
523             break ;
524
525         case 8 :  /* "green":  Green color buffer precision in bits */
526             break ;
527
528         case 9 :  /* "index":  Boolean if the color model is color index or not
529                    */
530             glut_state_flag |= GLUT_INDEX ;
531             break ;
532
533         case 10 :  /* "num":  A special capability  name indicating where the
534                       value represents the Nth frame buffer configuration
535                       matching the description string */
536             break ;
537
538         case 11 :  /* "red":  Red color buffer precision in bits */
539             break ;
540
541         case 12 :  /* "rgba":  Number of bits of red, green, blue, and alpha in
542                       the RGBA color buffer */
543             glut_state_flag |= GLUT_RGBA ;  /* Somebody fix this for me! */
544             break ;
545
546         case 13 :  /* "rgb":  Number of bits of red, green, and blue in the
547                       RGBA color buffer with zero bits alpha */
548             glut_state_flag |= GLUT_RGB ;  /* Somebody fix this for me! */
549             break ;
550
551         case 14 :  /* "luminance":  Number of bits of red in the RGBA and zero
552                       bits of green, blue (alpha not specified) of color buffer
553                       precision */
554             glut_state_flag |= GLUT_LUMINANCE ; /* Somebody fix this for me! */
555             break ;
556
557         case 15 :  /* "stencil":  Number of bits in the stencil buffer */
558             glut_state_flag |= GLUT_STENCIL;  /* Somebody fix this for me! */
559             break ;
560
561         case 16 :  /* "single":  Boolean indicate the color buffer is single
562                       buffered */
563             glut_state_flag |= GLUT_SINGLE ;
564             break ;
565
566         case 17 :  /* "stereo":  Boolean indicating the color buffer supports
567                       OpenGL-style stereo */
568             glut_state_flag |= GLUT_STEREO ;
569             break ;
570
571         case 18 :  /* "samples":  Indicates the number of multisamples to use
572                       based on GLX's SGIS_multisample extension (for
573                       antialiasing) */
574             glut_state_flag |= GLUT_MULTISAMPLE ; /*Somebody fix this for me!*/
575             break ;
576
577         case 19 :  /* "slow":  Boolean indicating if the frame buffer
578                       configuration is slow or not */
579             break ;
580
581         case 20 :  /* "win32pdf": (incorrect spelling but was there before */
582         case 21 :  /* "win32pfd":  matches the Win32 Pixel Format Descriptor by
583                       number */
584 #if TARGET_HOST_MS_WINDOWS
585 #endif
586             break ;
587
588         case 22 :  /* "xvisual":  matches the X visual ID by number */
589 #if TARGET_HOST_POSIX_X11
590 #endif
591             break ;
592
593         case 23 :  /* "xstaticgray": */
594         case 29 :  /* "xstaticgrey":  boolean indicating if the frame buffer
595                       configuration's X visual is of type StaticGray */
596 #if TARGET_HOST_POSIX_X11
597 #endif
598             break ;
599
600         case 24 :  /* "xgrayscale": */
601         case 30 :  /* "xgreyscale":  boolean indicating if the frame buffer
602                       configuration's X visual is of type GrayScale */
603 #if TARGET_HOST_POSIX_X11
604 #endif
605             break ;
606
607         case 25 :  /* "xstaticcolor": */
608         case 31 :  /* "xstaticcolour":  boolean indicating if the frame buffer
609                       configuration's X visual is of type StaticColor */
610 #if TARGET_HOST_POSIX_X11
611 #endif
612             break ;
613
614         case 26 :  /* "xpseudocolor": */
615         case 32 :  /* "xpseudocolour":  boolean indicating if the frame buffer
616                       configuration's X visual is of type PseudoColor */
617 #if TARGET_HOST_POSIX_X11
618 #endif
619             break ;
620
621         case 27 :  /* "xtruecolor": */
622         case 33 :  /* "xtruecolour":  boolean indicating if the frame buffer
623                       configuration's X visual is of type TrueColor */
624 #if TARGET_HOST_POSIX_X11
625 #endif
626             break ;
627
628         case 28 :  /* "xdirectcolor": */
629         case 34 :  /* "xdirectcolour":  boolean indicating if the frame buffer
630                       configuration's X visual is of type DirectColor */
631 #if TARGET_HOST_POSIX_X11
632 #endif
633             break ;
634
635         case 35 :  /* "borderless":  windows should not have borders */
636 #if TARGET_HOST_POSIX_X11
637 #endif
638             break ;
639
640         case 36 :  /* "aux":  some number of aux buffers */
641             glut_state_flag |= GLUT_AUX;
642             break ;
643
644         case 37 :  /* Unrecognized */
645             fgWarning ( "WARNING - Display string token not recognized:  %s",
646                         token );
647             break ;
648         }
649
650         token = strtok ( NULL, " \t" );
651     }
652
653     free ( buffer );
654
655     /* We will make use of this value when creating a new OpenGL context... */
656     fgState.DisplayMode = glut_state_flag;
657 }
658
659 /* -- SETTING OPENGL 3.0 CONTEXT CREATION PARAMETERS ---------------------- */
660
661 void FGAPIENTRY glutInitContextVersion( int majorVersion, int minorVersion )
662 {
663     /* We will make use of these valuse when creating a new OpenGL context... */
664     fgState.MajorVersion = majorVersion;
665     fgState.MinorVersion = minorVersion;
666 }
667
668
669 void FGAPIENTRY glutInitContextFlags( int flags )
670 {
671     /* We will make use of this value when creating a new OpenGL context... */
672     fgState.ContextFlags = flags;
673 }
674
675 void FGAPIENTRY glutInitContextProfile( int profile )
676 {
677     /* We will make use of this value when creating a new OpenGL context... */
678     fgState.ContextProfile = profile;
679 }
680
681 /* -------------- User Defined Error/Warning Handler Support -------------- */
682
683 /*
684  * Sets the user error handler (note the use of va_list for the args to the fmt)
685  */
686 void FGAPIENTRY glutInitErrorFunc( void (* vfgError) ( const char *fmt, va_list ap ) )
687 {
688     /* This allows user programs to handle freeglut errors */
689     fgState.ErrorFunc = vfgError;
690 }
691
692 /*
693  * Sets the user warning handler (note the use of va_list for the args to the fmt)
694  */
695 void FGAPIENTRY glutInitWarningFunc( void (* vfgWarning) ( const char *fmt, va_list ap ) )
696 {
697     /* This allows user programs to handle freeglut warnings */
698     fgState.WarningFunc = vfgWarning;
699 }
700
701 /*** END OF FILE ***/