fi
# Generate output.
-AC_CONFIG_FILES([Makefile doc/Makefile include/GL/Makefile include/Makefile progs/Makefile progs/demos/CallbackMaker/Makefile progs/demos/Fractals/Makefile progs/demos/Fractals_random/Makefile progs/demos/Lorenz/Makefile progs/demos/Makefile progs/demos/One/Makefile progs/demos/shapes/Makefile progs/demos/smooth_opengl3/Makefile progs/demos/spaceball/Makefile src/Makefile])
+AC_CONFIG_FILES([Makefile doc/Makefile include/GL/Makefile include/Makefile progs/Makefile progs/demos/CallbackMaker/Makefile progs/demos/Error/Makefile progs/demos/Fractals/Makefile progs/demos/Fractals_random/Makefile progs/demos/Lorenz/Makefile progs/demos/Makefile progs/demos/One/Makefile progs/demos/shapes/Makefile progs/demos/smooth_opengl3/Makefile progs/demos/spaceball/Makefile src/Makefile])
AC_OUTPUT
FGAPI void FGAPIENTRY glutInitContextFlags( int flags );
FGAPI void FGAPIENTRY glutInitContextProfile( int profile );
+/* to get the typedef for va_list */
+#include <stdarg.h>
+
+FGAPI void FGAPIENTRY glutInitErrorFunc( void (* vError)( const char *fmt, va_list ap ) );
+FGAPI void FGAPIENTRY glutInitWarningFunc( void (* vWarning)( const char *fmt, va_list ap ) );
+
/*
* GLUT API macro definitions -- the display mode definitions
*/
EXTRA_DIST = demos.dsw
-SUBDIRS = CallbackMaker Fractals Fractals_random Lorenz One shapes smooth_opengl3 spaceball
+SUBDIRS = CallbackMaker Error Fractals Fractals_random Lorenz One shapes smooth_opengl3 spaceball
CHECK_NAME(glutInitContextVersion);
CHECK_NAME(glutInitContextFlags);
CHECK_NAME(glutInitContextProfile);
+ CHECK_NAME(glutInitErrorFunc);
+ CHECK_NAME(glutInitWarningFunc);
#undef CHECK_NAME
return NULL;
1, /* MajorVersion */
0, /* MajorVersion */
0, /* ContextFlags */
- 0 /* ContextProfile */
+ 0, /* ContextProfile */
+ NULL, /* ErrorFunc */
+ NULL /* WarningFunc */
};
fgState.ContextProfile = profile;
}
+/* -------------- User Defined Error/Warning Handler Support -------------- */
+
+/*
+ * Sets the user error handler (note the use of va_list for the args to the fmt)
+ */
+void FGAPIENTRY glutInitErrorFunc( void (* vfgError) ( const char *fmt, va_list ap ) )
+{
+ /* This allows user programs to handle freeglut errors */
+ fgState.ErrorFunc = vfgError;
+}
+
+/*
+ * Sets the user warning handler (note the use of va_list for the args to the fmt)
+ */
+void FGAPIENTRY glutInitWarningFunc( void (* vfgWarning) ( const char *fmt, va_list ap ) )
+{
+ /* This allows user programs to handle freeglut warnings */
+ fgState.ErrorFunc = vfgWarning;
+}
+
/*** END OF FILE ***/
#include <string.h>
#include <math.h>
#include <stdlib.h>
+#include <stdarg.h>
/* These are included based on autoconf directives. */
#ifdef HAVE_SYS_TYPES_H
/* The callback used when creating/using menus */
typedef void (* FGCBMenu )( int );
+/* The FreeGLUT error/warning handler type definition */
+typedef void (* FGError ) ( const char *fmt, va_list ap);
+typedef void (* FGWarning ) ( const char *fmt, va_list ap);
+
/* A list structure */
typedef struct tagSFG_List SFG_List;
int MinorVersion; /* Minor OpenGL context version */
int ContextFlags; /* OpenGL context flags */
int ContextProfile; /* OpenGL context profile */
+ FGError ErrorFunc; /* User defined error handler */
+ FGWarning WarningFunc; /* User defined warning handler */
};
/* The structure used by display initialization in freeglut_init.c */
{
va_list ap;
- va_start( ap, fmt );
+ if (fgState.ErrorFunc) {
- fprintf( stderr, "freeglut ");
- if( fgState.ProgramName )
- fprintf( stderr, "(%s): ", fgState.ProgramName );
- VFPRINTF( stderr, fmt, ap );
- fprintf( stderr, "\n" );
+ va_start( ap, fmt );
- va_end( ap );
+ /* call user set error handler here */
+ fgState.ErrorFunc(fmt, ap);
- if ( fgState.Initialised )
- fgDeinitialize ();
+ va_end( ap );
- exit( 1 );
+ } else {
+
+ va_start( ap, fmt );
+
+ fprintf( stderr, "freeglut ");
+ if( fgState.ProgramName )
+ fprintf( stderr, "(%s): ", fgState.ProgramName );
+ VFPRINTF( stderr, fmt, ap );
+ fprintf( stderr, "\n" );
+
+ va_end( ap );
+
+ if ( fgState.Initialised )
+ fgDeinitialize ();
+
+ exit( 1 );
+ }
}
void fgWarning( const char *fmt, ... )
{
va_list ap;
- va_start( ap, fmt );
+ if (fgState.WarningFunc) {
+
+ va_start( ap, fmt );
- fprintf( stderr, "freeglut ");
- if( fgState.ProgramName )
- fprintf( stderr, "(%s): ", fgState.ProgramName );
- VFPRINTF( stderr, fmt, ap );
- fprintf( stderr, "\n" );
+ /* call user set warning handler here */
+ fgState.WarningFunc(fmt, ap);
- va_end( ap );
+ va_end( ap );
+
+ } else {
+
+ va_start( ap, fmt );
+
+ fprintf( stderr, "freeglut ");
+ if( fgState.ProgramName )
+ fprintf( stderr, "(%s): ", fgState.ProgramName );
+ VFPRINTF( stderr, fmt, ap );
+ fprintf( stderr, "\n" );
+
+ va_end( ap );
+ }
}
+
/*
* Indicates whether Joystick events are being used by ANY window.
*
glutInitContextFlags
glutInitContextVersion
glutInitContextProfile
+ glutInitErrorFunc
+ glutInitWarningFunc
__glutInitWithExit
__glutCreateWindowWithExit
__glutCreateMenuWithExit