/* -- INTERFACE FUNCTIONS -------------------------------------------------- */
+
/*
- * All of the callbacks setting methods can be generalized to this:
+ * Global callbacks.
+ */
+/* Sets the global idle callback */
+void FGAPIENTRY glutIdleFunc( FGCBIdle callback )
+{
+ FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutIdleFunc" );
+ fgState.IdleCallback = callback;
+}
+
+/* Creates a timer and sets its callback */
+void FGAPIENTRY glutTimerFunc( unsigned int timeOut, FGCBTimer callback, int timerID )
+{
+ SFG_Timer *timer, *node;
+
+ FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutTimerFunc" );
+
+ if( (timer = fgState.FreeTimers.Last) )
+ {
+ fgListRemove( &fgState.FreeTimers, &timer->Node );
+ }
+ else
+ {
+ if( ! (timer = malloc(sizeof(SFG_Timer))) )
+ fgError( "Fatal error: "
+ "Memory allocation failure in glutTimerFunc()" );
+ }
+
+ timer->Callback = callback;
+ timer->ID = timerID;
+ timer->TriggerTime = fgElapsedTime() + timeOut;
+
+ for( node = fgState.Timers.First; node; node = node->Node.Next )
+ {
+ if( node->TriggerTime > timer->TriggerTime )
+ break;
+ }
+
+ fgListInsert( &fgState.Timers, &node->Node, &timer->Node );
+}
+
+/* Deprecated version of glutMenuStatusFunc callback setting method */
+void FGAPIENTRY glutMenuStateFunc( FGCBMenuState callback )
+{
+ FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMenuStateFunc" );
+ fgState.MenuStateCallback = callback;
+}
+
+/* Sets the global menu status callback for the current window */
+void FGAPIENTRY glutMenuStatusFunc( FGCBMenuStatus callback )
+{
+ FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMenuStatusFunc" );
+ fgState.MenuStatusCallback = callback;
+}
+
+
+/*
+ * Menu specific callbacks.
+ */
+/* Callback upon menu destruction */
+void FGAPIENTRY glutMenuDestroyFunc( FGCBDestroy callback )
+{
+ FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMenuDestroyFunc" );
+ if( fgStructure.CurrentMenu )
+ fgStructure.CurrentMenu->Destroy = callback;
+}
+
+
+/*
+ * All of the window-specific callbacks setting methods can be generalized to this:
*/
#define SET_CALLBACK(a) \
do \
/*
* Sets the Display callback for the current window
*/
-void FGAPIENTRY glutDisplayFunc( void (* callback)( void ) )
+void FGAPIENTRY glutDisplayFunc( FGCBDisplay callback )
{
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutDisplayFunc" );
if( !callback )
/*
* Sets the Reshape callback for the current window
*/
-void FGAPIENTRY glutReshapeFunc( void (* callback)( int, int ) )
+void FGAPIENTRY glutReshapeFunc( FGCBReshape callback )
{
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutReshapeFunc" );
SET_CALLBACK( Reshape );
/*
* Sets the Keyboard callback for the current window
*/
-void FGAPIENTRY glutKeyboardFunc( void (* callback)
- ( unsigned char, int, int ) )
+void FGAPIENTRY glutKeyboardFunc( FGCBKeyboard callback )
{
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutKeyboardFunc" );
SET_CALLBACK( Keyboard );
}
/*
- * Sets the Special callback for the current window
+ * Sets the keyboard key release callback for the current window
*/
-void FGAPIENTRY glutSpecialFunc( void (* callback)( int, int, int ) )
+void FGAPIENTRY glutKeyboardUpFunc( FGCBKeyboardUp callback )
{
- FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpecialFunc" );
- SET_CALLBACK( Special );
+ FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutKeyboardUpFunc" );
+ SET_CALLBACK( KeyboardUp );
}
/*
- * Sets the global idle callback
+ * Sets the Special callback for the current window
*/
-void FGAPIENTRY glutIdleFunc( void (* callback)( void ) )
+void FGAPIENTRY glutSpecialFunc( FGCBSpecial callback )
{
- FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutIdleFunc" );
- fgState.IdleCallback = callback;
+ FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpecialFunc" );
+ SET_CALLBACK( Special );
}
/*
- * Sets the Timer callback for the current window
+ * Sets the special key release callback for the current window
*/
-void FGAPIENTRY glutTimerFunc( unsigned int timeOut, void (* callback)( int ),
- int timerID )
+void FGAPIENTRY glutSpecialUpFunc( FGCBSpecialUp callback )
{
- SFG_Timer *timer, *node;
-
- FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutTimerFunc" );
-
- if( (timer = fgState.FreeTimers.Last) )
- {
- fgListRemove( &fgState.FreeTimers, &timer->Node );
- }
- else
- {
- if( ! (timer = malloc(sizeof(SFG_Timer))) )
- fgError( "Fatal error: "
- "Memory allocation failure in glutTimerFunc()" );
- }
-
- timer->Callback = callback;
- timer->ID = timerID;
- timer->TriggerTime = fgElapsedTime() + timeOut;
-
- for( node = fgState.Timers.First; node; node = node->Node.Next )
- {
- if( node->TriggerTime > timer->TriggerTime )
- break;
- }
-
- fgListInsert( &fgState.Timers, &node->Node, &timer->Node );
+ FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpecialUpFunc" );
+ SET_CALLBACK( SpecialUp );
}
/*
INVOKE_WCB( *( fgStructure.CurrentWindow ), Visibility, ( glut_status ) );
}
-void FGAPIENTRY glutVisibilityFunc( void (* callback)( int ) )
+void FGAPIENTRY glutVisibilityFunc( FGCBVisibility callback )
{
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutVisibilityFunc" );
SET_CALLBACK( Visibility );
}
/*
- * Sets the keyboard key release callback for the current window
- */
-void FGAPIENTRY glutKeyboardUpFunc( void (* callback)
- ( unsigned char, int, int ) )
-{
- FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutKeyboardUpFunc" );
- SET_CALLBACK( KeyboardUp );
-}
-
-/*
- * Sets the special key release callback for the current window
- */
-void FGAPIENTRY glutSpecialUpFunc( void (* callback)( int, int, int ) )
-{
- FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpecialUpFunc" );
- SET_CALLBACK( SpecialUp );
-}
-
-/*
* Sets the joystick callback and polling rate for the current window
*/
-void FGAPIENTRY glutJoystickFunc( void (* callback)
- ( unsigned int, int, int, int ),
- int pollInterval )
+void FGAPIENTRY glutJoystickFunc( FGCBJoystick callback, int pollInterval )
{
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutJoystickFunc" );
fgInitialiseJoysticks ();
/*
* Sets the mouse callback for the current window
*/
-void FGAPIENTRY glutMouseFunc( void (* callback)( int, int, int, int ) )
+void FGAPIENTRY glutMouseFunc( FGCBMouse callback )
{
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMouseFunc" );
SET_CALLBACK( Mouse );
/*
* Sets the mouse wheel callback for the current window
*/
-void FGAPIENTRY glutMouseWheelFunc( void (* callback)( int, int, int, int ) )
+void FGAPIENTRY glutMouseWheelFunc( FGCBMouseWheel callback )
{
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMouseWheelFunc" );
SET_CALLBACK( MouseWheel );
* Sets the mouse motion callback for the current window (one or more buttons
* are pressed)
*/
-void FGAPIENTRY glutMotionFunc( void (* callback)( int, int ) )
+void FGAPIENTRY glutMotionFunc( FGCBMotion callback )
{
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMotionFunc" );
SET_CALLBACK( Motion );
* Sets the passive mouse motion callback for the current window (no mouse
* buttons are pressed)
*/
-void FGAPIENTRY glutPassiveMotionFunc( void (* callback)( int, int ) )
+void FGAPIENTRY glutPassiveMotionFunc( FGCBPassive callback )
{
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutPassiveMotionFunc" );
SET_CALLBACK( Passive );
/*
* Window mouse entry/leave callback
*/
-void FGAPIENTRY glutEntryFunc( void (* callback)( int ) )
+void FGAPIENTRY glutEntryFunc( FGCBEntry callback )
{
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutEntryFunc" );
SET_CALLBACK( Entry );
/*
* Window destruction callbacks
*/
-void FGAPIENTRY glutCloseFunc( void (* callback)( void ) )
+void FGAPIENTRY glutCloseFunc( FGCBDestroy callback )
{
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutCloseFunc" );
SET_CALLBACK( Destroy );
}
-void FGAPIENTRY glutWMCloseFunc( void (* callback)( void ) )
+void FGAPIENTRY glutWMCloseFunc( FGCBDestroy callback )
{
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWMCloseFunc" );
glutCloseFunc( callback );
}
-/* A. Donev: Destruction callback for menus */
-void FGAPIENTRY glutMenuDestroyFunc( void (* callback)( void ) )
-{
- FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMenuDestroyFunc" );
- if( fgStructure.CurrentMenu )
- fgStructure.CurrentMenu->Destroy = callback;
-}
-
-/*
- * Deprecated version of glutMenuStatusFunc callback setting method
- */
-void FGAPIENTRY glutMenuStateFunc( void (* callback)( int ) )
-{
- FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMenuStateFunc" );
- fgState.MenuStateCallback = callback;
-}
-
-/*
- * Sets the global menu status callback for the current window
- */
-void FGAPIENTRY glutMenuStatusFunc( void (* callback)( int, int, int ) )
-{
- FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMenuStatusFunc" );
- fgState.MenuStatusCallback = callback;
-}
-
/*
* Sets the overlay display callback for the current window
*/
-void FGAPIENTRY glutOverlayDisplayFunc( void (* callback)( void ) )
+void FGAPIENTRY glutOverlayDisplayFunc( FGCBOverlayDisplay callback )
{
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutOverlayDisplayFunc" );
SET_CALLBACK( OverlayDisplay );
/*
* Sets the window status callback for the current window
*/
-void FGAPIENTRY glutWindowStatusFunc( void (* callback)( int ) )
+void FGAPIENTRY glutWindowStatusFunc( FGCBWindowStatus callback )
{
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWindowStatusFunc" );
SET_CALLBACK( WindowStatus );
/*
* Sets the spaceball motion callback for the current window
*/
-void FGAPIENTRY glutSpaceballMotionFunc( void (* callback)( int, int, int ) )
+void FGAPIENTRY glutSpaceballMotionFunc( FGCBSpaceMotion callback )
{
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpaceballMotionFunc" );
fgInitialiseSpaceball();
/*
* Sets the spaceball rotate callback for the current window
*/
-void FGAPIENTRY glutSpaceballRotateFunc( void (* callback)( int, int, int ) )
+void FGAPIENTRY glutSpaceballRotateFunc( FGCBSpaceRotation callback )
{
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpaceballRotateFunc" );
fgInitialiseSpaceball();
/*
* Sets the spaceball button callback for the current window
*/
-void FGAPIENTRY glutSpaceballButtonFunc( void (* callback)( int, int ) )
+void FGAPIENTRY glutSpaceballButtonFunc( FGCBSpaceButton callback )
{
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpaceballButtonFunc" );
fgInitialiseSpaceball();
/*
* Sets the button box callback for the current window
*/
-void FGAPIENTRY glutButtonBoxFunc( void (* callback)( int, int ) )
+void FGAPIENTRY glutButtonBoxFunc( FGCBButtonBox callback )
{
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutButtonBoxFunc" );
SET_CALLBACK( ButtonBox );
/*
* Sets the dials box callback for the current window
*/
-void FGAPIENTRY glutDialsFunc( void (* callback)( int, int ) )
+void FGAPIENTRY glutDialsFunc( FGCBDials callback )
{
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutDialsFunc" );
SET_CALLBACK( Dials );
/*
* Sets the tablet motion callback for the current window
*/
-void FGAPIENTRY glutTabletMotionFunc( void (* callback)( int, int ) )
+void FGAPIENTRY glutTabletMotionFunc( FGCBTabletMotion callback )
{
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutTabletMotionFunc" );
SET_CALLBACK( TabletMotion );
/*
* Sets the tablet buttons callback for the current window
*/
-void FGAPIENTRY glutTabletButtonFunc( void (* callback)( int, int, int, int ) )
+void FGAPIENTRY glutTabletButtonFunc( FGCBTabletButton callback )
{
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutTabletButtonFunc" );
SET_CALLBACK( TabletButton );
/*
* Sets the multi-pointer entry callback for the current window
*/
-void FGAPIENTRY glutMultiEntryFunc( void (* callback)(int, int ) )
+void FGAPIENTRY glutMultiEntryFunc( FGCBMultiEntry callback )
{
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMultiEntryFunc" );
SET_CALLBACK( MultiEntry );
/*
* Sets the multi-pointer button callback for the current window
*/
-void FGAPIENTRY glutMultiButtonFunc( void (* callback)(int, int, int, int, int ) )
+void FGAPIENTRY glutMultiButtonFunc( FGCBMultiButton callback )
{
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMultiButtonFunc" );
SET_CALLBACK( MultiButton );
/*
* Sets the multi-pointer motion callback for the current window
*/
-void FGAPIENTRY glutMultiMotionFunc( void (* callback)(int, int, int ) )
+void FGAPIENTRY glutMultiMotionFunc( FGCBMultiMotion callback )
{
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMultiMotionFunc" );
SET_CALLBACK( MultiMotion );
/*
* Sets the multi-pointer passive motion callback for the current window
*/
-void FGAPIENTRY glutMultiPassiveFunc( void (* callback)(int, int, int ) )
+void FGAPIENTRY glutMultiPassiveFunc( FGCBMultiPassive callback )
{
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMultiPassiveFunc" );
SET_CALLBACK( MultiPassive );
/*
* Sets the context reload callback for the current window
*/
-void FGAPIENTRY glutInitContextFunc( void (* callback)() )
+void FGAPIENTRY glutInitContextFunc( FGCBInitContext callback )
{
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutInitContextFunc" );
SET_CALLBACK( InitContext );
/*
* Sets the pause callback for the current window
*/
-void FGAPIENTRY glutPauseFunc( void (* callback)() )
+void FGAPIENTRY glutPauseFunc( FGCBPause callback )
{
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutPauseFunc" );
SET_CALLBACK( Pause );
/*
* Sets the resume callback for the current window
*/
-void FGAPIENTRY glutResumeFunc( void (* callback)() )
+void FGAPIENTRY glutResumeFunc( FGCBResume callback )
{
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutResumeFunc" );
SET_CALLBACK( Resume );