/*
- * freeglut_callbacks.c
+ * fg_callbacks.c
*
* The callbacks setting methods.
*
timer->ID = timerID;
timer->TriggerTime = fgElapsedTime() + timeOut;
+ /* Insert such that timers are sorted by end-time */
for( node = fgState.Timers.First; node; node = node->Node.Next )
{
if( node->TriggerTime > timer->TriggerTime )
#define IMPLEMENT_CALLBACK_FUNC(a) IMPLEMENT_CALLBACK_FUNC_2NAME(a,a)
/* Implement all these callback setter functions... */
-IMPLEMENT_CALLBACK_FUNC(Reshape);
-IMPLEMENT_CALLBACK_FUNC(Position);
-IMPLEMENT_CALLBACK_FUNC(Keyboard);
-IMPLEMENT_CALLBACK_FUNC(KeyboardUp);
-IMPLEMENT_CALLBACK_FUNC(Special);
-IMPLEMENT_CALLBACK_FUNC(SpecialUp);
-IMPLEMENT_CALLBACK_FUNC(Mouse);
-IMPLEMENT_CALLBACK_FUNC(MouseWheel);
-IMPLEMENT_CALLBACK_FUNC(Motion);
-IMPLEMENT_CALLBACK_FUNC_2NAME(PassiveMotion,Passive);
-IMPLEMENT_CALLBACK_FUNC(Entry);
+IMPLEMENT_CALLBACK_FUNC(Position)
+IMPLEMENT_CALLBACK_FUNC(Keyboard)
+IMPLEMENT_CALLBACK_FUNC(KeyboardUp)
+IMPLEMENT_CALLBACK_FUNC(Special)
+IMPLEMENT_CALLBACK_FUNC(SpecialUp)
+IMPLEMENT_CALLBACK_FUNC(Mouse)
+IMPLEMENT_CALLBACK_FUNC(MouseWheel)
+IMPLEMENT_CALLBACK_FUNC(Motion)
+IMPLEMENT_CALLBACK_FUNC_2NAME(PassiveMotion,Passive)
+IMPLEMENT_CALLBACK_FUNC(Entry)
/* glutWMCloseFunc is an alias for glutCloseFunc; both set the window's Destroy callback */
-IMPLEMENT_CALLBACK_FUNC_2NAME(Close,Destroy);
-IMPLEMENT_CALLBACK_FUNC_2NAME(WMClose,Destroy);
-IMPLEMENT_CALLBACK_FUNC(OverlayDisplay);
-IMPLEMENT_CALLBACK_FUNC(WindowStatus);
-IMPLEMENT_CALLBACK_FUNC(ButtonBox);
-IMPLEMENT_CALLBACK_FUNC(Dials);
-IMPLEMENT_CALLBACK_FUNC(TabletMotion);
-IMPLEMENT_CALLBACK_FUNC(TabletButton);
-IMPLEMENT_CALLBACK_FUNC(MultiEntry);
-IMPLEMENT_CALLBACK_FUNC(MultiButton);
-IMPLEMENT_CALLBACK_FUNC(MultiMotion);
-IMPLEMENT_CALLBACK_FUNC(MultiPassive);
-IMPLEMENT_CALLBACK_FUNC(InitContext);
-IMPLEMENT_CALLBACK_FUNC(Pause);
-IMPLEMENT_CALLBACK_FUNC(Resume);
+IMPLEMENT_CALLBACK_FUNC_2NAME(Close,Destroy)
+IMPLEMENT_CALLBACK_FUNC_2NAME(WMClose,Destroy)
+IMPLEMENT_CALLBACK_FUNC(OverlayDisplay)
+IMPLEMENT_CALLBACK_FUNC(WindowStatus)
+IMPLEMENT_CALLBACK_FUNC(ButtonBox)
+IMPLEMENT_CALLBACK_FUNC(Dials)
+IMPLEMENT_CALLBACK_FUNC(TabletMotion)
+IMPLEMENT_CALLBACK_FUNC(TabletButton)
+IMPLEMENT_CALLBACK_FUNC(MultiEntry)
+IMPLEMENT_CALLBACK_FUNC(MultiButton)
+IMPLEMENT_CALLBACK_FUNC(MultiMotion)
+IMPLEMENT_CALLBACK_FUNC(MultiPassive)
+IMPLEMENT_CALLBACK_FUNC(InitContext)
+IMPLEMENT_CALLBACK_FUNC(AppStatus)
SET_CALLBACK( Display );
}
+void fghDefaultReshape(int width, int height)
+{
+ glViewport( 0, 0, width, height );
+}
+
+void FGAPIENTRY glutReshapeFunc( FGCBReshape callback )
+{
+ FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutReshapeFunc" );
+
+ if( !callback )
+ callback = fghDefaultReshape;
+
+ SET_CALLBACK( Reshape );
+}
+
/*
* Sets the Visibility callback for the current window.
* NB: the Visibility func is deprecated in favor of the WindowStatus func,
* DEVELOPER NOTE: in the library, only invoke the window status func, this
* gets automatically translated to the visibility func if thats what the
* user has set.
+ * window status is kind of anemic on win32 as there are no window messages
+ * to notify us that the window is covered by other windows or not.
+ * Should one want to query this, see
+ * http://stackoverflow.com/questions/5445889/get-which-process-window-is-actually-visible-in-c-sharp
+ * for an implementation outline (but it would be polling based, not push based).
*/
static void fghVisibility( int status )
{
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutJoystickFunc" );
fgInitialiseJoysticks ();
- if ( ( ( fgStructure.CurrentWindow->State.JoystickPollRate < 0 ) ||
- !FETCH_WCB(*fgStructure.CurrentWindow,Joystick) ) && /* Joystick callback was disabled */
- ( callback && ( pollInterval >= 0 ) ) ) /* but is now enabled */
+ if ( (
+ fgStructure.CurrentWindow->State.JoystickPollRate <= 0 || /* Joystick callback was disabled */
+ !FETCH_WCB(*fgStructure.CurrentWindow,Joystick)
+ ) &&
+ (
+ callback && ( pollInterval > 0 ) /* but is now enabled */
+ ) )
++fgState.NumActiveJoysticks;
- else if ( ( ( fgStructure.CurrentWindow->State.JoystickPollRate >= 0 ) &&
- FETCH_WCB(*fgStructure.CurrentWindow,Joystick) ) && /* Joystick callback was enabled */
- ( !callback || ( pollInterval < 0 ) ) ) /* but is now disabled */
+ else if ( (
+ fgStructure.CurrentWindow->State.JoystickPollRate > 0 && /* Joystick callback was enabled */
+ FETCH_WCB(*fgStructure.CurrentWindow,Joystick)
+ ) &&
+ (
+ !callback || ( pollInterval <= 0 ) /* but is now disabled */
+ ) )
--fgState.NumActiveJoysticks;
SET_CALLBACK( Joystick );
fgStructure.CurrentWindow->State.JoystickPollRate = pollInterval;
- fgStructure.CurrentWindow->State.JoystickLastPoll =
- fgElapsedTime() - fgStructure.CurrentWindow->State.JoystickPollRate;
-
- if( fgStructure.CurrentWindow->State.JoystickLastPoll < 0 )
+ /* set last poll time such that joystick will be polled asap */
+ fgStructure.CurrentWindow->State.JoystickLastPoll = fgElapsedTime();
+ if (fgStructure.CurrentWindow->State.JoystickLastPoll < pollInterval)
fgStructure.CurrentWindow->State.JoystickLastPoll = 0;
+ else
+ fgStructure.CurrentWindow->State.JoystickLastPoll -= pollInterval;
}