Fixed issue where setting the same callback with different user pointer wouldn't change the user pointer.

Removed extra comment on FETCH_USER_DATA_WCB
Renamed helper callbacks from glutXXXCalback to fghXXXCallback
This commit is contained in:
Rcmaniac25 2016-01-18 22:15:24 -05:00
parent 55fd60f288
commit 60a437b3b8
4 changed files with 65 additions and 51 deletions

View File

@ -42,7 +42,7 @@ void FGAPIENTRY glutIdleFuncUcall( FGCBIdleUC callback, FGCBUserData userData )
fgState.IdleCallbackData = userData; fgState.IdleCallbackData = userData;
} }
static void glutIdleFuncCallback( FGCBUserData userData ) static void fghIdleFuncCallback( FGCBUserData userData )
{ {
FGCBIdle callback = (FGCBIdle)userData; FGCBIdle callback = (FGCBIdle)userData;
callback(); callback();
@ -52,7 +52,7 @@ void FGAPIENTRY glutIdleFunc( FGCBIdle callback )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutIdleFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutIdleFunc" );
if( callback ) if( callback )
glutIdleFuncUcall( glutIdleFuncCallback, (FGCBUserData)callback ); glutIdleFuncUcall( fghIdleFuncCallback, (FGCBUserData)callback );
else else
glutIdleFuncUcall( NULL, NULL ); glutIdleFuncUcall( NULL, NULL );
} }
@ -90,7 +90,7 @@ void FGAPIENTRY glutTimerFuncUcall( unsigned int timeOut, FGCBTimerUC callback,
fgListInsert( &fgState.Timers, &node->Node, &timer->Node ); fgListInsert( &fgState.Timers, &node->Node, &timer->Node );
} }
static void glutTimerFuncCallback( int ID, FGCBUserData userData ) static void fghTimerFuncCallback( int ID, FGCBUserData userData )
{ {
FGCBTimer callback = (FGCBTimer)userData; FGCBTimer callback = (FGCBTimer)userData;
callback( ID ); callback( ID );
@ -100,7 +100,7 @@ void FGAPIENTRY glutTimerFunc( unsigned int timeOut, FGCBTimer callback, int tim
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutTimerFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutTimerFunc" );
if( callback ) if( callback )
glutTimerFuncUcall( timeOut, glutTimerFuncCallback, timerID, (FGCBUserData)callback ); glutTimerFuncUcall( timeOut, fghTimerFuncCallback, timerID, (FGCBUserData)callback );
else else
glutTimerFuncUcall( timeOut, NULL, timerID, NULL ); glutTimerFuncUcall( timeOut, NULL, timerID, NULL );
} }
@ -120,7 +120,7 @@ void FGAPIENTRY glutMenuStatusFuncUcall( FGCBMenuStatusUC callback, FGCBUserData
fgState.MenuStatusCallbackData = userData; fgState.MenuStatusCallbackData = userData;
} }
static void glutMenuStatusFuncCallback( int menuState, int mouseX, int mouseY, FGCBUserData userData ) static void fghMenuStatusFuncCallback( int menuState, int mouseX, int mouseY, FGCBUserData userData )
{ {
FGCBMenuStatus callback = (FGCBMenuStatus)userData; FGCBMenuStatus callback = (FGCBMenuStatus)userData;
callback( menuState, mouseX, mouseY ); callback( menuState, mouseX, mouseY );
@ -130,7 +130,7 @@ void FGAPIENTRY glutMenuStatusFunc( FGCBMenuStatus callback )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMenuStatusFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMenuStatusFunc" );
if( callback ) if( callback )
glutMenuStatusFuncUcall( glutMenuStatusFuncCallback, (FGCBUserData)callback ); glutMenuStatusFuncUcall( fghMenuStatusFuncCallback, (FGCBUserData)callback );
else else
glutMenuStatusFuncUcall( NULL, NULL ); glutMenuStatusFuncUcall( NULL, NULL );
} }
@ -149,7 +149,7 @@ void FGAPIENTRY glutMenuDestroyFuncUcall( FGCBDestroyUC callback, FGCBUserData u
} }
} }
static void glutMenuDestroyFuncCallback( FGCBUserData userData ) static void fghMenuDestroyFuncCallback( FGCBUserData userData )
{ {
FGCBDestroy callback = (FGCBDestroy)userData; FGCBDestroy callback = (FGCBDestroy)userData;
callback(); callback();
@ -159,7 +159,7 @@ void FGAPIENTRY glutMenuDestroyFunc( FGCBDestroy callback )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMenuDestroyFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMenuDestroyFunc" );
if( callback ) if( callback )
glutMenuDestroyFuncUcall( glutMenuDestroyFuncCallback, (FGCBUserData)callback ); glutMenuDestroyFuncUcall( fghMenuDestroyFuncCallback, (FGCBUserData)callback );
else else
glutMenuDestroyFuncUcall( NULL, NULL ); glutMenuDestroyFuncUcall( NULL, NULL );
} }
@ -179,38 +179,38 @@ do \
* Types need to be defined for callbacks. It's not ideal, but it works for this. * Types need to be defined for callbacks. It's not ideal, but it works for this.
*/ */
#define IMPLEMENT_CALLBACK_FUNC_CB_ARG0(a,b) \ #define IMPLEMENT_CALLBACK_FUNC_CB_ARG0(a,b) \
static void glut##a##FuncCallback( FGCBUserData userData ) \ static void fgh##a##FuncCallback( FGCBUserData userData ) \
{ \ { \
FGCB##b callback = (FGCB##b)userData; \ FGCB##b callback = (FGCB##b)userData; \
callback(); \ callback(); \
} }
#define IMPLEMENT_CALLBACK_FUNC_CB_ARG1(a,b) \ #define IMPLEMENT_CALLBACK_FUNC_CB_ARG1(a,b) \
static void glut##a##FuncCallback( int arg1val, FGCBUserData userData ) \ static void fgh##a##FuncCallback( int arg1val, FGCBUserData userData ) \
{ \ { \
FGCB##b callback = (FGCB##b)userData; \ FGCB##b callback = (FGCB##b)userData; \
callback( arg1val ); \ callback( arg1val ); \
} }
#define IMPLEMENT_CALLBACK_FUNC_CB_ARG2(a,b) \ #define IMPLEMENT_CALLBACK_FUNC_CB_ARG2(a,b) \
static void glut##a##FuncCallback( int arg1val, int arg2val, FGCBUserData userData ) \ static void fgh##a##FuncCallback( int arg1val, int arg2val, FGCBUserData userData ) \
{ \ { \
FGCB##b callback = (FGCB##b)userData; \ FGCB##b callback = (FGCB##b)userData; \
callback( arg1val, arg2val ); \ callback( arg1val, arg2val ); \
} }
#define IMPLEMENT_CALLBACK_FUNC_CB_ARG3_USER(a,b,arg1,arg2,arg3) \ #define IMPLEMENT_CALLBACK_FUNC_CB_ARG3_USER(a,b,arg1,arg2,arg3) \
static void glut##a##FuncCallback( arg1 arg1val, arg2 arg2val, arg3 arg3val, FGCBUserData userData ) \ static void fgh##a##FuncCallback( arg1 arg1val, arg2 arg2val, arg3 arg3val, FGCBUserData userData ) \
{ \ { \
FGCB##b callback = (FGCB##b)userData; \ FGCB##b callback = (FGCB##b)userData; \
callback( arg1val, arg2val, arg3val ); \ callback( arg1val, arg2val, arg3val ); \
} }
#define IMPLEMENT_CALLBACK_FUNC_CB_ARG3(a,b) IMPLEMENT_CALLBACK_FUNC_CB_ARG3_USER(a,b,int,int,int) #define IMPLEMENT_CALLBACK_FUNC_CB_ARG3(a,b) IMPLEMENT_CALLBACK_FUNC_CB_ARG3_USER(a,b,int,int,int)
#define IMPLEMENT_CALLBACK_FUNC_CB_ARG4(a,b) \ #define IMPLEMENT_CALLBACK_FUNC_CB_ARG4(a,b) \
static void glut##a##FuncCallback( int arg1val, int arg2val, int arg3val, int arg4val, FGCBUserData userData ) \ static void fgh##a##FuncCallback( int arg1val, int arg2val, int arg3val, int arg4val, FGCBUserData userData ) \
{ \ { \
FGCB##b callback = (FGCB##b)userData; \ FGCB##b callback = (FGCB##b)userData; \
callback( arg1val, arg2val, arg3val, arg4val ); \ callback( arg1val, arg2val, arg3val, arg4val ); \
} }
#define IMPLEMENT_CALLBACK_FUNC_CB_ARG5(a,b) \ #define IMPLEMENT_CALLBACK_FUNC_CB_ARG5(a,b) \
static void glut##a##FuncCallback( int arg1val, int arg2val, int arg3val, int arg4val, int arg5val, FGCBUserData userData ) \ static void fgh##a##FuncCallback( int arg1val, int arg2val, int arg3val, int arg4val, int arg5val, FGCBUserData userData ) \
{ \ { \
FGCB##b callback = (FGCB##b)userData; \ FGCB##b callback = (FGCB##b)userData; \
callback( arg1val, arg2val, arg3val, arg4val, arg5val ); \ callback( arg1val, arg2val, arg3val, arg4val, arg5val ); \
@ -228,7 +228,7 @@ void FGAPIENTRY glut##a##Func( FGCB##b callback ) \
{ \ { \
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glut"#a"Func" ); \ FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glut"#a"Func" ); \
if( callback ) \ if( callback ) \
glut##a##FuncUcall( glut##a##FuncCallback, (FGCBUserData)callback ); \ glut##a##FuncUcall( fgh##a##FuncCallback, (FGCBUserData)callback ); \
else \ else \
glut##a##FuncUcall( NULL, NULL ); \ glut##a##FuncUcall( NULL, NULL ); \
} }
@ -310,7 +310,7 @@ void FGAPIENTRY glutDisplayFuncUcall( FGCBDisplayUC callback, FGCBUserData userD
SET_CALLBACK( Display ); SET_CALLBACK( Display );
} }
static void glutDisplayFuncCallback( FGCBUserData userData ) static void fghDisplayFuncCallback( FGCBUserData userData )
{ {
FGCBDisplay callback = (FGCBDisplay)userData; FGCBDisplay callback = (FGCBDisplay)userData;
callback(); callback();
@ -320,7 +320,7 @@ void FGAPIENTRY glutDisplayFunc( FGCBDisplay callback )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutDisplayFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutDisplayFunc" );
if( callback ) if( callback )
glutDisplayFuncUcall( glutDisplayFuncCallback, (FGCBUserData)callback ); glutDisplayFuncUcall( fghDisplayFuncCallback, (FGCBUserData)callback );
else else
glutDisplayFuncUcall( NULL, NULL ); glutDisplayFuncUcall( NULL, NULL );
} }
@ -343,7 +343,7 @@ void FGAPIENTRY glutReshapeFuncUcall( FGCBReshapeUC callback, FGCBUserData userD
SET_CALLBACK( Reshape ); SET_CALLBACK( Reshape );
} }
static void glutReshapeFuncCallback( int width, int height, FGCBUserData userData ) static void fghReshapeFuncCallback( int width, int height, FGCBUserData userData )
{ {
FGCBReshape callback = (FGCBReshape)userData; FGCBReshape callback = (FGCBReshape)userData;
callback( width, height ); callback( width, height );
@ -353,7 +353,7 @@ void FGAPIENTRY glutReshapeFunc( FGCBReshape callback )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutReshapeFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutReshapeFunc" );
if( callback ) if( callback )
glutReshapeFuncUcall( glutReshapeFuncCallback, (FGCBUserData)callback ); glutReshapeFuncUcall( fghReshapeFuncCallback, (FGCBUserData)callback );
else else
glutReshapeFuncUcall( NULL, NULL ); glutReshapeFuncUcall( NULL, NULL );
} }
@ -406,7 +406,7 @@ void FGAPIENTRY glutVisibilityFuncUcall( FGCBVisibilityUC callback, FGCBUserData
glutWindowStatusFuncUcall( NULL, NULL ); glutWindowStatusFuncUcall( NULL, NULL );
} }
static void glutVisibilityFuncCallback( int visibility, FGCBUserData userData ) static void fghVisibilityFuncCallback( int visibility, FGCBUserData userData )
{ {
FGCBVisibility callback = (FGCBVisibility)userData; FGCBVisibility callback = (FGCBVisibility)userData;
callback( visibility ); callback( visibility );
@ -416,7 +416,7 @@ void FGAPIENTRY glutVisibilityFunc( FGCBVisibility callback )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutVisibilityFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutVisibilityFunc" );
if( callback ) if( callback )
glutVisibilityFuncUcall( glutVisibilityFuncCallback, (FGCBUserData)callback ); glutVisibilityFuncUcall( fghVisibilityFuncCallback, (FGCBUserData)callback );
else else
glutVisibilityFuncUcall( NULL, NULL ); glutVisibilityFuncUcall( NULL, NULL );
} }
@ -457,7 +457,7 @@ void FGAPIENTRY glutJoystickFuncUcall( FGCBJoystickUC callback, int pollInterval
fgStructure.CurrentWindow->State.JoystickLastPoll -= pollInterval; fgStructure.CurrentWindow->State.JoystickLastPoll -= pollInterval;
} }
static void glutJoystickFuncCallback( unsigned int buttons, int axis0, int axis1, int axis2, FGCBUserData userData ) static void fghJoystickFuncCallback( unsigned int buttons, int axis0, int axis1, int axis2, FGCBUserData userData )
{ {
FGCBJoystick callback = (FGCBJoystick)userData; FGCBJoystick callback = (FGCBJoystick)userData;
callback( buttons, axis0, axis1, axis2 ); callback( buttons, axis0, axis1, axis2 );
@ -467,7 +467,7 @@ void FGAPIENTRY glutJoystickFunc( FGCBJoystick callback, int pollInterval )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutJoystickFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutJoystickFunc" );
if( callback ) if( callback )
glutJoystickFuncUcall( glutJoystickFuncCallback, pollInterval, (FGCBUserData)callback ); glutJoystickFuncUcall( fghJoystickFuncCallback, pollInterval, (FGCBUserData)callback );
else else
glutJoystickFuncUcall( NULL, pollInterval, NULL ); glutJoystickFuncUcall( NULL, pollInterval, NULL );
} }
@ -483,7 +483,7 @@ void FGAPIENTRY glutSpaceballMotionFuncUcall( FGCBSpaceMotionUC callback, FGCBUs
SET_CALLBACK( SpaceMotion ); SET_CALLBACK( SpaceMotion );
} }
static void glutSpaceballMotionFuncCallback( int x, int y, int z, FGCBUserData userData ) static void fghSpaceballMotionFuncCallback( int x, int y, int z, FGCBUserData userData )
{ {
FGCBSpaceMotion callback = (FGCBSpaceMotion)userData; FGCBSpaceMotion callback = (FGCBSpaceMotion)userData;
callback( x, y, z ); callback( x, y, z );
@ -493,7 +493,7 @@ void FGAPIENTRY glutSpaceballMotionFunc( FGCBSpaceMotion callback )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpaceballMotionFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpaceballMotionFunc" );
if( callback ) if( callback )
glutSpaceballMotionFuncUcall( glutSpaceballMotionFuncCallback, (FGCBUserData)callback ); glutSpaceballMotionFuncUcall( fghSpaceballMotionFuncCallback, (FGCBUserData)callback );
else else
glutSpaceballMotionFuncUcall( NULL, NULL ); glutSpaceballMotionFuncUcall( NULL, NULL );
} }
@ -509,7 +509,7 @@ void FGAPIENTRY glutSpaceballRotateFuncUcall( FGCBSpaceRotationUC callback, FGCB
SET_CALLBACK( SpaceRotation ); SET_CALLBACK( SpaceRotation );
} }
static void glutSpaceballRotateFuncCallback( int x, int y, int z, FGCBUserData userData ) static void fghSpaceballRotateFuncCallback( int x, int y, int z, FGCBUserData userData )
{ {
FGCBSpaceRotation callback = (FGCBSpaceRotation)userData; FGCBSpaceRotation callback = (FGCBSpaceRotation)userData;
callback( x, y, z ); callback( x, y, z );
@ -519,7 +519,7 @@ void FGAPIENTRY glutSpaceballRotateFunc( FGCBSpaceRotation callback )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpaceballRotateFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpaceballRotateFunc" );
if( callback ) if( callback )
glutSpaceballRotateFuncUcall( glutSpaceballRotateFuncCallback, (FGCBUserData)callback ); glutSpaceballRotateFuncUcall( fghSpaceballRotateFuncCallback, (FGCBUserData)callback );
else else
glutSpaceballRotateFuncUcall( NULL, NULL ); glutSpaceballRotateFuncUcall( NULL, NULL );
} }
@ -535,7 +535,7 @@ void FGAPIENTRY glutSpaceballButtonFuncUcall( FGCBSpaceButtonUC callback, FGCBUs
SET_CALLBACK( SpaceButton ); SET_CALLBACK( SpaceButton );
} }
static void glutSpaceballButtonFuncCallback( int button, int buttonState, FGCBUserData userData ) static void fghSpaceballButtonFuncCallback( int button, int buttonState, FGCBUserData userData )
{ {
FGCBSpaceButton callback = (FGCBSpaceButton)userData; FGCBSpaceButton callback = (FGCBSpaceButton)userData;
callback( button, buttonState ); callback( button, buttonState );
@ -545,7 +545,7 @@ void FGAPIENTRY glutSpaceballButtonFunc( FGCBSpaceButton callback )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpaceballButtonFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpaceballButtonFunc" );
if( callback ) if( callback )
glutSpaceballButtonFuncUcall( glutSpaceballButtonFuncCallback, (FGCBUserData)callback ); glutSpaceballButtonFuncUcall( fghSpaceballButtonFuncCallback, (FGCBUserData)callback );
else else
glutSpaceballButtonFuncUcall( NULL, NULL ); glutSpaceballButtonFuncUcall( NULL, NULL );
} }

View File

@ -681,7 +681,7 @@ void FGAPIENTRY glutInitErrorFuncUcall( FGErrorUC callback, FGCBUserData userDat
fgState.ErrorFuncData = userData; fgState.ErrorFuncData = userData;
} }
static void glutInitErrorFuncCallback( const char *fmt, va_list ap, FGCBUserData userData ) static void fghInitErrorFuncCallback( const char *fmt, va_list ap, FGCBUserData userData )
{ {
FGError callback = (FGError)userData; FGError callback = (FGError)userData;
callback( fmt, ap ); callback( fmt, ap );
@ -690,9 +690,13 @@ static void glutInitErrorFuncCallback( const char *fmt, va_list ap, FGCBUserData
void FGAPIENTRY glutInitErrorFunc( FGError callback ) void FGAPIENTRY glutInitErrorFunc( FGError callback )
{ {
if (callback) if (callback)
glutInitErrorFuncUcall( glutInitErrorFuncCallback, (FGCBUserData)callback ); {
glutInitErrorFuncUcall( fghInitErrorFuncCallback, (FGCBUserData)callback );
}
else else
{
glutInitErrorFuncUcall( NULL, NULL ); glutInitErrorFuncUcall( NULL, NULL );
}
} }
/* /*
@ -705,7 +709,7 @@ void FGAPIENTRY glutInitWarningFuncUcall( FGWarningUC callback, FGCBUserData use
fgState.WarningFuncData = userData; fgState.WarningFuncData = userData;
} }
static void glutInitWarningFuncCallback( const char *fmt, va_list ap, FGCBUserData userData ) static void fghInitWarningFuncCallback( const char *fmt, va_list ap, FGCBUserData userData )
{ {
FGWarning callback = (FGWarning)userData; FGWarning callback = (FGWarning)userData;
callback( fmt, ap ); callback( fmt, ap );
@ -714,9 +718,13 @@ static void glutInitWarningFuncCallback( const char *fmt, va_list ap, FGCBUserDa
void FGAPIENTRY glutInitWarningFunc( FGWarning callback ) void FGAPIENTRY glutInitWarningFunc( FGWarning callback )
{ {
if (callback) if (callback)
glutInitWarningFuncUcall( glutInitWarningFuncCallback, (FGCBUserData)callback ); {
glutInitWarningFuncUcall( fghInitWarningFuncCallback, (FGCBUserData)callback );
}
else else
{
glutInitWarningFuncUcall( NULL, NULL ); glutInitWarningFuncUcall( NULL, NULL );
}
} }
/*** END OF FILE ***/ /*** END OF FILE ***/

View File

@ -578,6 +578,12 @@ typedef void (*SFG_Proc)();
* The {if( FETCH_WCB( ... ) != func )} test is to do type-checking * The {if( FETCH_WCB( ... ) != func )} test is to do type-checking
* and for no other reason. Since it's hidden in the macro, the * and for no other reason. Since it's hidden in the macro, the
* ugliness is felt to be rather benign. * ugliness is felt to be rather benign.
*
* If the function-pointer is the same, the data will be the only
* value updated. If the function-pointer changes, the data will
* be changed as well, preventing stail data from being passed in.
* Just updating the data does nothing unless a function-pointer
* exists, as the data is otherwise already allocated.
*/ */
#define SET_WCB(window,cbname,func,udata) \ #define SET_WCB(window,cbname,func,udata) \
do \ do \
@ -587,6 +593,10 @@ do \
(((window).CallBacks[WCB_ ## cbname]) = (SFG_Proc)(func)); \ (((window).CallBacks[WCB_ ## cbname]) = (SFG_Proc)(func)); \
(((window).CallbackDatas[WCB_ ## cbname]) = (udata)); \ (((window).CallbackDatas[WCB_ ## cbname]) = (udata)); \
} \ } \
else if( FETCH_USER_DATA_WCB( window, cbname ) != udata ) \
{ \
(((window).CallbackDatas[WCB_ ## cbname]) = (udata)); \
} \
} while( 0 ) } while( 0 )
/* /*
@ -612,14 +622,6 @@ do \
* {cbname} is the window-specific callback to be invoked, * {cbname} is the window-specific callback to be invoked,
* *
* This expects a variable named "window" of type tagSFG_Window to exist. * This expects a variable named "window" of type tagSFG_Window to exist.
*/
/*
* FETCH_USER_DATA_WCB() is used as:
*
* FETCH_USER_DATA_WCB( window, cbname );
*
* ...where {window} is the freeglut window to fetch the callback data from,
* {cbname} is the window-specific callback data to fetch.
* *
* The result is the callback data pointer. * The result is the callback data pointer.
*/ */

View File

@ -785,13 +785,15 @@ int FGAPIENTRY glutCreateMenuUcall( FGCBMenuUC callback, FGCBUserData userData )
/* The menu object creation code resides in fg_structure.c */ /* The menu object creation code resides in fg_structure.c */
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutCreateMenuUcall" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutCreateMenuUcall" );
if (fgState.ActiveMenus) if (fgState.ActiveMenus)
fgError("Menu manipulation not allowed while menus in use."); {
fgError( "Menu manipulation not allowed while menus in use." );
}
return fgCreateMenu( callback, userData )->ID; return fgCreateMenu( callback, userData )->ID;
} }
/* Standard glutCreateMenu */ /* Standard glutCreateMenu */
static void glutCreateMenuCallback( int menu, FGCBUserData userData ) static void fghCreateMenuCallback( int menu, FGCBUserData userData )
{ {
FGCBMenu callback = (FGCBMenu)userData; FGCBMenu callback = (FGCBMenu)userData;
callback( menu ); callback( menu );
@ -801,8 +803,10 @@ int FGAPIENTRY glutCreateMenu( FGCBMenu callback )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutCreateMenu" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutCreateMenu" );
if (!callback) if (!callback)
{
return glutCreateMenuUcall( NULL, NULL ); return glutCreateMenuUcall( NULL, NULL );
return glutCreateMenuUcall( glutCreateMenuCallback, (FGCBUserData)callback ); }
return glutCreateMenuUcall( fghCreateMenuCallback, (FGCBUserData)callback );
} }
/* /*