Addressing feature request 2116152 -- adding an fgError exit callback routine -- patch from Chris Marshall in e-mail dated 10/30/2010 2:06 PM
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@877 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
parent
c7aaa1bc6b
commit
e5e5aebedf
@ -95,5 +95,5 @@ if test "x$enable_debug" = xyes; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Generate output.
|
# 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
|
AC_OUTPUT
|
||||||
|
@ -202,6 +202,12 @@ FGAPI void FGAPIENTRY glutInitContextVersion( int majorVersion, int minorVers
|
|||||||
FGAPI void FGAPIENTRY glutInitContextFlags( int flags );
|
FGAPI void FGAPIENTRY glutInitContextFlags( int flags );
|
||||||
FGAPI void FGAPIENTRY glutInitContextProfile( int profile );
|
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
|
* GLUT API macro definitions -- the display mode definitions
|
||||||
*/
|
*/
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
EXTRA_DIST = demos.dsw
|
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
|
||||||
|
@ -196,6 +196,8 @@ static GLUTproc fghGetGLUTProcAddress( const char* procName )
|
|||||||
CHECK_NAME(glutInitContextVersion);
|
CHECK_NAME(glutInitContextVersion);
|
||||||
CHECK_NAME(glutInitContextFlags);
|
CHECK_NAME(glutInitContextFlags);
|
||||||
CHECK_NAME(glutInitContextProfile);
|
CHECK_NAME(glutInitContextProfile);
|
||||||
|
CHECK_NAME(glutInitErrorFunc);
|
||||||
|
CHECK_NAME(glutInitWarningFunc);
|
||||||
#undef CHECK_NAME
|
#undef CHECK_NAME
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -91,7 +91,9 @@ SFG_State fgState = { { -1, -1, GL_FALSE }, /* Position */
|
|||||||
1, /* MajorVersion */
|
1, /* MajorVersion */
|
||||||
0, /* MajorVersion */
|
0, /* MajorVersion */
|
||||||
0, /* ContextFlags */
|
0, /* ContextFlags */
|
||||||
0 /* ContextProfile */
|
0, /* ContextProfile */
|
||||||
|
NULL, /* ErrorFunc */
|
||||||
|
NULL /* WarningFunc */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -1143,4 +1145,24 @@ void FGAPIENTRY glutInitContextProfile( int profile )
|
|||||||
fgState.ContextProfile = profile;
|
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 ***/
|
/*** END OF FILE ***/
|
||||||
|
@ -129,6 +129,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
/* These are included based on autoconf directives. */
|
/* These are included based on autoconf directives. */
|
||||||
#ifdef HAVE_SYS_TYPES_H
|
#ifdef HAVE_SYS_TYPES_H
|
||||||
@ -243,6 +244,10 @@ typedef void (* FGCBMenuStatus )( int, int, int );
|
|||||||
/* The callback used when creating/using menus */
|
/* The callback used when creating/using menus */
|
||||||
typedef void (* FGCBMenu )( int );
|
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 */
|
/* A list structure */
|
||||||
typedef struct tagSFG_List SFG_List;
|
typedef struct tagSFG_List SFG_List;
|
||||||
@ -333,6 +338,8 @@ struct tagSFG_State
|
|||||||
int MinorVersion; /* Minor OpenGL context version */
|
int MinorVersion; /* Minor OpenGL context version */
|
||||||
int ContextFlags; /* OpenGL context flags */
|
int ContextFlags; /* OpenGL context flags */
|
||||||
int ContextProfile; /* OpenGL context profile */
|
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 */
|
/* The structure used by display initialization in freeglut_init.c */
|
||||||
|
@ -338,6 +338,17 @@ void fgError( const char *fmt, ... )
|
|||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
|
if (fgState.ErrorFunc) {
|
||||||
|
|
||||||
|
va_start( ap, fmt );
|
||||||
|
|
||||||
|
/* call user set error handler here */
|
||||||
|
fgState.ErrorFunc(fmt, ap);
|
||||||
|
|
||||||
|
va_end( ap );
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
va_start( ap, fmt );
|
va_start( ap, fmt );
|
||||||
|
|
||||||
fprintf( stderr, "freeglut ");
|
fprintf( stderr, "freeglut ");
|
||||||
@ -353,11 +364,23 @@ void fgError( const char *fmt, ... )
|
|||||||
|
|
||||||
exit( 1 );
|
exit( 1 );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void fgWarning( const char *fmt, ... )
|
void fgWarning( const char *fmt, ... )
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
|
if (fgState.WarningFunc) {
|
||||||
|
|
||||||
|
va_start( ap, fmt );
|
||||||
|
|
||||||
|
/* call user set warning handler here */
|
||||||
|
fgState.WarningFunc(fmt, ap);
|
||||||
|
|
||||||
|
va_end( ap );
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
va_start( ap, fmt );
|
va_start( ap, fmt );
|
||||||
|
|
||||||
fprintf( stderr, "freeglut ");
|
fprintf( stderr, "freeglut ");
|
||||||
@ -368,6 +391,8 @@ void fgWarning( const char *fmt, ... )
|
|||||||
|
|
||||||
va_end( ap );
|
va_end( ap );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Indicates whether Joystick events are being used by ANY window.
|
* Indicates whether Joystick events are being used by ANY window.
|
||||||
|
@ -143,6 +143,8 @@ EXPORTS
|
|||||||
glutInitContextFlags
|
glutInitContextFlags
|
||||||
glutInitContextVersion
|
glutInitContextVersion
|
||||||
glutInitContextProfile
|
glutInitContextProfile
|
||||||
|
glutInitErrorFunc
|
||||||
|
glutInitWarningFunc
|
||||||
__glutInitWithExit
|
__glutInitWithExit
|
||||||
__glutCreateWindowWithExit
|
__glutCreateWindowWithExit
|
||||||
__glutCreateMenuWithExit
|
__glutCreateMenuWithExit
|
||||||
|
Reference in New Issue
Block a user