- /*
- * Those callbacks are being ignored for the moment
- */
- FGCBSelect Select;
- FGCBOverlayDisplay OverlayDisplay;
- FGCBSpaceMotion SpaceMotion;
- FGCBSpaceRotation SpaceRotation;
- FGCBSpaceButton SpaceButton;
- FGCBDials Dials;
- FGCBButtonBox ButtonBox;
- FGCBTabletMotion TabletMotion;
- FGCBTabletButton TabletButton;
-};
+
+/*
+ * SET_WCB() is used as:
+ *
+ * SET_WCB( window, cbname, func );
+ *
+ * ...where {window} is the freeglut window to set the callback,
+ * {cbname} is the window-specific callback to set,
+ * {func} is a function-pointer.
+ *
+ * Originally, {FETCH_WCB( ... ) = func} was rather sloppily used,
+ * but this can cause warnings because the FETCH_WCB() macro type-
+ * casts its result, and a type-cast value shouldn't be an lvalue.
+ *
+ * The {if( FETCH_WCB( ... ) != func )} test is to do type-checking
+ * and for no other reason. Since it's hidden in the macro, the
+ * ugliness is felt to be rather benign.
+ */
+#define SET_WCB(window,cbname,func) \
+do \
+{ \
+ if( FETCH_WCB( window, cbname ) != (SFG_Proc)(func) ) \
+ (((window).CallBacks[CB_ ## cbname]) = (SFG_Proc)(func)); \
+} while( 0 )
+
+/*
+ * FETCH_WCB() is used as:
+ *
+ * FETCH_WCB( window, cbname );
+ *
+ * ...where {window} is the freeglut window to fetch the callback from,
+ * {cbname} is the window-specific callback to fetch.
+ *
+ * The result is correctly type-cast to the callback function pointer
+ * type.
+ */