Fixed issue where setting the same callback with different user pointer wouldn't...
[freeglut] / src / fg_internal.h
1 /*
2  * fg_internal.h
3  *
4  * The freeglut library private include file.
5  *
6  * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
7  * Written by Pawel W. Olszta, <olszta@sourceforge.net>
8  * Creation date: Thu Dec 2 1999
9  *
10  * Permission is hereby granted, free of charge, to any person obtaining a
11  * copy of this software and associated documentation files (the "Software"),
12  * to deal in the Software without restriction, including without limitation
13  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14  * and/or sell copies of the Software, and to permit persons to whom the
15  * Software is furnished to do so, subject to the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be included
18  * in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
23  * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
24  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26  */
27
28 #ifndef  FREEGLUT_INTERNAL_H
29 #define  FREEGLUT_INTERNAL_H
30
31 #ifdef HAVE_CONFIG_H
32 #    include "config.h"
33 #endif
34
35 #include "fg_version.h"
36 #include "fg_callback_macros.h"
37
38 /* Freeglut is intended to function under all Unix/X11 and Win32 platforms. */
39 /* XXX: Don't all MS-Windows compilers (except Cygwin) have _WIN32 defined?
40  * XXX: If so, remove the first set of defined()'s below.
41  */
42 #if !defined(TARGET_HOST_POSIX_X11) && !defined(TARGET_HOST_MS_WINDOWS) && !defined(TARGET_HOST_MAC_OSX) && !defined(TARGET_HOST_SOLARIS) && \
43     !defined(TARGET_HOST_ANDROID) && !defined(TARGET_HOST_BLACKBERRY) && !defined(TARGET_HOST_POSIX_WAYLAND)
44 #if defined(_MSC_VER) || defined(__WATCOMC__) || defined(__MINGW32__) \
45     || defined(_WIN32) || defined(_WIN32_WCE) \
46     || ( defined(__CYGWIN__) && defined(X_DISPLAY_MISSING) )
47 #   define  TARGET_HOST_MS_WINDOWS 1
48
49 #elif defined (__ANDROID__)
50 #   define  TARGET_HOST_ANDROID  1
51
52 #elif defined (__QNXNTO__) || defined (__PLAYBOOK__)
53 #   define  TARGET_HOST_BLACKBERRY  1
54
55 #elif defined(__posix__) || defined(__unix__) || defined(__linux__) || defined(__sun)
56 #   if defined(FREEGLUT_WAYLAND)
57 #      define  TARGET_HOST_POSIX_WAYLAND  1
58 #   else
59 #      define  TARGET_HOST_POSIX_X11  1
60 #   endif
61
62 #elif defined(__APPLE__)
63 /* This is a placeholder until we get native OSX support ironed out -- JFF 11/18/09 */
64 #   define  TARGET_HOST_POSIX_X11  1
65 /* #   define  TARGET_HOST_MAC_OSX    1 */
66
67 #else
68 #   error "Unrecognized target host!"
69
70 #endif
71 #endif
72
73 /* Detect both SunPro and gcc compilers on Sun Solaris */
74 #if defined (__SVR4) && defined (__sun)
75 #   define TARGET_HOST_SOLARIS 1
76 #endif
77
78 #ifndef TARGET_HOST_MS_WINDOWS
79 #   define  TARGET_HOST_MS_WINDOWS     0
80 #endif
81
82 #ifndef TARGET_HOST_ANDROID
83 #   define  TARGET_HOST_ANDROID        0
84 #endif
85
86 #ifndef TARGET_HOST_BLACKBERRY
87 #   define  TARGET_HOST_BLACKBERRY     0
88 #endif
89
90 #ifndef  TARGET_HOST_POSIX_WAYLAND
91 #   define  TARGET_HOST_POSIX_WAYLAND  0
92 #endif
93
94 #ifndef  TARGET_HOST_POSIX_X11
95 #   define  TARGET_HOST_POSIX_X11      0
96 #endif
97
98 #ifndef  TARGET_HOST_MAC_OSX
99 #   define  TARGET_HOST_MAC_OSX        0
100 #endif
101
102 #ifndef  TARGET_HOST_SOLARIS
103 #   define  TARGET_HOST_SOLARIS        0
104 #endif
105
106 /* -- FIXED CONFIGURATION LIMITS ------------------------------------------- */
107
108 #define  FREEGLUT_MAX_MENUS            3
109
110 /* These files should be available on every platform. */
111 #include <stdio.h>
112 #include <string.h>
113 #include <math.h>
114 #include <stdlib.h>
115 #include <stdarg.h>
116
117 /* These are included based on autoconf directives. */
118 #ifdef HAVE_SYS_TYPES_H
119 #    include <sys/types.h>
120 #endif
121 #ifdef HAVE_UNISTD_H
122 #    include <unistd.h>
123 #endif
124 #ifdef TIME_WITH_SYS_TIME
125 #    include <sys/time.h>
126 #    include <time.h>
127 #elif defined(HAVE_SYS_TIME_H)
128 #    include <sys/time.h>
129 #else
130 #    include <time.h>
131 #endif
132
133 /* -- AUTOCONF HACKS --------------------------------------------------------*/
134
135 /* XXX: Update autoconf to avoid these.
136  * XXX: Are non-POSIX platforms intended not to use autoconf?
137  * If so, perhaps there should be a config_guess.h for them. Alternatively,
138  * config guesses could be placed above, just after the config.h exclusion.
139  */
140 #if defined(__FreeBSD__) || defined(__NetBSD__)
141 #    define HAVE_USB_JS 1
142 #    if defined(__NetBSD__) || ( defined(__FreeBSD__) && __FreeBSD_version >= 500000)
143 #        define HAVE_USBHID_H 1
144 #    endif
145 #endif
146
147 #if defined(_MSC_VER) || defined(__WATCOMC__)
148 /* strdup() is non-standard, for all but POSIX-2001 */
149 #define strdup   _strdup
150 #endif
151
152 /* M_PI is non-standard (defined by BSD, not ISO-C) */
153 #ifndef M_PI
154 #    define  M_PI  3.14159265358979323846
155 #endif
156
157 #ifdef HAVE_STDBOOL_H
158 #    include <stdbool.h>
159 #    ifndef TRUE
160 #        define TRUE true
161 #    endif
162 #    ifndef FALSE
163 #        define FALSE false
164 #    endif
165 #else
166 #    ifndef TRUE
167 #        define  TRUE  1
168 #    endif
169 #    ifndef FALSE
170 #        define  FALSE  0
171 #    endif
172 #endif
173
174 /* General defines */
175 #define INVALID_MODIFIERS 0xffffffff
176
177 /* FreeGLUT internal time type */
178 #if defined(HAVE_STDINT_H)
179 #   include <stdint.h>
180     typedef uint64_t fg_time_t;
181 #elif defined(HAVE_INTTYPES_H)
182 #   include <inttypes.h>
183     typedef uint64_t fg_time_t;
184 #elif defined(HAVE_U__INT64)
185     typedef unsigned __int64 fg_time_t;
186 #elif defined(HAVE_ULONG_LONG)
187     typedef unsigned long long fg_time_t;
188 #else
189     typedef unsigned long fg_time_t;
190 #endif
191
192 #ifndef __fg_unused
193 # ifdef __GNUC__
194 #  define __fg_unused __attribute__((unused))
195 # else
196 #  define __fg_unused
197 # endif
198 #endif
199
200 /* Platform-specific includes */
201 #if TARGET_HOST_POSIX_WAYLAND
202 #include "wayland/fg_internal_wl.h"
203 #endif
204 #if TARGET_HOST_POSIX_X11
205 #include "x11/fg_internal_x11.h"
206 #endif
207 #if TARGET_HOST_MS_WINDOWS
208 #include "mswin/fg_internal_mswin.h"
209 #endif
210 #if TARGET_HOST_ANDROID
211 #include "android/fg_internal_android.h"
212 #endif
213 #if TARGET_HOST_BLACKBERRY
214 #include "blackberry/fg_internal_blackberry.h"
215 #endif
216
217
218 /* -- GLOBAL TYPE DEFINITIONS ---------------------------------------------- */
219
220 /* 
221  * Freeglut callbacks type definitions
222  *
223  * If anything here is modified or added, update fg_callback_macros.h functions.
224  *
225  * This is not ideal, but freeglut needs to either define minimal compiler specs,
226  * or update header every time this is changed or updated.
227  */
228 typedef void* FGCBUserData;
229
230 typedef void (* FGCBDisplay         )( void );
231 typedef void (* FGCBDisplayUC       )( FGCBUserData );
232 typedef void (* FGCBReshape         )( int, int );
233 typedef void (* FGCBReshapeUC       )( int, int, FGCBUserData );
234 typedef void (* FGCBPosition        )( int, int );
235 typedef void (* FGCBPositionUC      )( int, int, FGCBUserData );
236 typedef void (* FGCBVisibility      )( int );
237 typedef void (* FGCBVisibilityUC    )( int, FGCBUserData );
238 typedef void (* FGCBKeyboard        )( unsigned char, int, int );
239 typedef void (* FGCBKeyboardUC      )( unsigned char, int, int, FGCBUserData );
240 typedef void (* FGCBKeyboardUp      )( unsigned char, int, int );
241 typedef void (* FGCBKeyboardUpUC    )( unsigned char, int, int, FGCBUserData );
242 typedef void (* FGCBSpecial         )( int, int, int );
243 typedef void (* FGCBSpecialUC       )( int, int, int, FGCBUserData );
244 typedef void (* FGCBSpecialUp       )( int, int, int );
245 typedef void (* FGCBSpecialUpUC     )( int, int, int, FGCBUserData );
246 typedef void (* FGCBMouse           )( int, int, int, int );
247 typedef void (* FGCBMouseUC         )( int, int, int, int, FGCBUserData );
248 typedef void (* FGCBMouseWheel      )( int, int, int, int );
249 typedef void (* FGCBMouseWheelUC    )( int, int, int, int, FGCBUserData );
250 typedef void (* FGCBMotion          )( int, int );
251 typedef void (* FGCBMotionUC        )( int, int, FGCBUserData );
252 typedef void (* FGCBPassive         )( int, int );
253 typedef void (* FGCBPassiveUC       )( int, int, FGCBUserData );
254 typedef void (* FGCBEntry           )( int );
255 typedef void (* FGCBEntryUC         )( int, FGCBUserData );
256 typedef void (* FGCBWindowStatus    )( int );
257 typedef void (* FGCBWindowStatusUC  )( int, FGCBUserData );
258 typedef void (* FGCBJoystick        )( unsigned int, int, int, int );
259 typedef void (* FGCBJoystickUC      )( unsigned int, int, int, int, FGCBUserData );
260 typedef void (* FGCBOverlayDisplay  )( void );
261 typedef void (* FGCBOverlayDisplayUC)( FGCBUserData );
262 typedef void (* FGCBSpaceMotion     )( int, int, int );
263 typedef void (* FGCBSpaceMotionUC   )( int, int, int, FGCBUserData );
264 typedef void (* FGCBSpaceRotation   )( int, int, int );
265 typedef void (* FGCBSpaceRotationUC )( int, int, int, FGCBUserData );
266 typedef void (* FGCBSpaceButton     )( int, int );
267 typedef void (* FGCBSpaceButtonUC   )( int, int, FGCBUserData );
268 typedef void (* FGCBDials           )( int, int );
269 typedef void (* FGCBDialsUC         )( int, int, FGCBUserData );
270 typedef void (* FGCBButtonBox       )( int, int );
271 typedef void (* FGCBButtonBoxUC     )( int, int, FGCBUserData );
272 typedef void (* FGCBTabletMotion    )( int, int );
273 typedef void (* FGCBTabletMotionUC  )( int, int, FGCBUserData );
274 typedef void (* FGCBTabletButton    )( int, int, int, int );
275 typedef void (* FGCBTabletButtonUC  )( int, int, int, int, FGCBUserData );
276 typedef void (* FGCBDestroy         )( void );    /* Used for both window and menu destroy callbacks */
277 typedef void (* FGCBDestroyUC       )( FGCBUserData );
278
279 typedef void (* FGCBMultiEntry      )( int, int );
280 typedef void (* FGCBMultiEntryUC    )( int, int, FGCBUserData );
281 typedef void (* FGCBMultiButton     )( int, int, int, int, int );
282 typedef void (* FGCBMultiButtonUC   )( int, int, int, int, int, FGCBUserData );
283 typedef void (* FGCBMultiMotion     )( int, int, int );
284 typedef void (* FGCBMultiMotionUC   )( int, int, int, FGCBUserData );
285 typedef void (* FGCBMultiPassive    )( int, int, int );
286 typedef void (* FGCBMultiPassiveUC  )( int, int, int, FGCBUserData );
287
288 typedef void (* FGCBInitContext     )( void );
289 typedef void (* FGCBInitContextUC   )( FGCBUserData );
290 typedef void (* FGCBAppStatus       )( int );
291 typedef void (* FGCBAppStatusUC     )( int, FGCBUserData );
292
293 /* The global callbacks type definitions */
294 typedef void (* FGCBIdle            )( void ); \
295 typedef void (* FGCBIdleUC          )( FGCBUserData );
296 typedef void (* FGCBTimer           )( int );
297 typedef void (* FGCBTimerUC         )( int, FGCBUserData );
298 typedef void (* FGCBMenuState       )( int );
299 typedef void (* FGCBMenuStatus      )( int, int, int );
300 typedef void (* FGCBMenuStatusUC    )( int, int, int, FGCBUserData );
301
302 /* The callback used when creating/using menus */
303 typedef void (* FGCBMenu            )( int );
304 typedef void (* FGCBMenuUC          )( int, FGCBUserData );
305
306 /* The FreeGLUT error/warning handler type definition */
307 typedef void (* FGError             )( const char *fmt, va_list ap );
308 typedef void (* FGErrorUC           )( const char *fmt, va_list ap, FGCBUserData userData );
309 typedef void (* FGWarning           )( const char *fmt, va_list ap );
310 typedef void (* FGWarningUC         )( const char *fmt, va_list ap, FGCBUserData userData );
311
312
313 /* A list structure */
314 typedef struct tagSFG_List SFG_List;
315 struct tagSFG_List
316 {
317     void *First;
318     void *Last;
319 };
320
321 /* A list node structure */
322 typedef struct tagSFG_Node SFG_Node;
323 struct tagSFG_Node
324 {
325     void *Next;
326     void *Prev;
327 };
328
329 /* A helper structure holding two ints and a boolean */
330 typedef struct tagSFG_XYUse SFG_XYUse;
331 struct tagSFG_XYUse
332 {
333     GLint           X, Y;               /* The two integers...               */
334     GLboolean       Use;                /* ...and a single boolean.          */
335 };
336
337 /*
338  * An enumeration containing the state of the GLUT execution:
339  * initializing, running, or stopping
340  */
341 typedef enum
342 {
343   GLUT_EXEC_STATE_INIT,
344   GLUT_EXEC_STATE_RUNNING,
345   GLUT_EXEC_STATE_STOP
346 } fgExecutionState ;
347
348 /* This structure holds different freeglut settings */
349 typedef struct tagSFG_State SFG_State;
350 struct tagSFG_State
351 {
352     SFG_XYUse        Position;             /* The default windows' position  */
353     SFG_XYUse        Size;                 /* The default windows' size      */
354     unsigned int     DisplayMode;          /* Display mode for new windows   */
355
356     GLboolean        Initialised;          /* freeglut has been initialised  */
357
358     int              DirectContext;        /* Direct rendering state         */
359
360     GLboolean        ForceIconic;          /* New top windows are iconified  */
361     GLboolean        UseCurrentContext;    /* New windows share with current */
362
363     GLboolean        GLDebugSwitch;        /* OpenGL state debugging switch  */
364     GLboolean        XSyncSwitch;          /* X11 sync protocol switch       */
365
366     int              KeyRepeat;            /* Global key repeat mode.        */
367     int              Modifiers;            /* Current ALT/SHIFT/CTRL state   */
368
369     GLuint           FPSInterval;          /* Interval between FPS printfs   */
370     GLuint           SwapCount;            /* Count of glutSwapBuffer calls  */
371     GLuint           SwapTime;             /* Time of last SwapBuffers       */
372
373     fg_time_t        Time;                 /* Time that glutInit was called  */
374     SFG_List         Timers;               /* The freeglut timer hooks       */
375     SFG_List         FreeTimers;           /* The unused timer hooks         */
376
377     FGCBIdleUC       IdleCallback;         /* The global idle callback       */
378     FGCBUserData     IdleCallbackData;     /* The global idle callback data  */
379
380     int              ActiveMenus;          /* Num. of currently active menus */
381     FGCBMenuState    MenuStateCallback;    /* Menu callbacks are global      */
382     FGCBMenuStatusUC MenuStatusCallback;
383     FGCBUserData     MenuStatusCallbackData;
384     void*            MenuFont;             /* Font to be used for newly created menus */
385
386     SFG_XYUse        GameModeSize;         /* Game mode screen's dimensions  */
387     int              GameModeDepth;        /* The pixel depth for game mode  */
388     int              GameModeRefresh;      /* The refresh rate for game mode */
389
390     int              ActionOnWindowClose;  /* Action when user closes window  */
391
392     fgExecutionState ExecState;            /* Used for GLUT termination       */
393     char            *ProgramName;          /* Name of the invoking program    */
394     GLboolean        JoysticksInitialised; /* Only initialize if application calls for them */
395     int              NumActiveJoysticks;   /* Number of active joysticks (callback defined and positive pollrate) -- if zero, don't poll joysticks */
396     GLboolean        InputDevsInitialised; /* Only initialize if application calls for them */
397
398         int              MouseWheelTicks;      /* Number of ticks the mouse wheel has turned */
399
400     int              AuxiliaryBufferNumber;/* Number of auxiliary buffers */
401     int              SampleNumber;         /*  Number of samples per pixel  */
402
403     GLboolean        SkipStaleMotion;      /* skip stale motion events */
404
405     GLboolean        StrokeFontDrawJoinDots;/* Draw dots between line segments of stroke fonts? */
406     GLboolean        AllowNegativeWindowPosition; /* GLUT, by default, doesn't allow negative window positions. Enable it? */
407
408     int              MajorVersion;         /* Major OpenGL context version  */
409     int              MinorVersion;         /* Minor OpenGL context version  */
410     int              ContextFlags;         /* OpenGL context flags          */
411     int              ContextProfile;       /* OpenGL context profile        */
412     int              HasOpenGL20;          /* fgInitGL2 could find all OpenGL 2.0 functions */
413     FGErrorUC        ErrorFunc;            /* User defined error handler    */
414     FGCBUserData     ErrorFuncData;        /* User defined error handler user data */
415     FGWarningUC      WarningFunc;          /* User defined warning handler  */
416     FGCBUserData     WarningFuncData;      /* User defined warning handler user data */
417 };
418
419 /* The structure used by display initialization in fg_init.c */
420 typedef struct tagSFG_Display SFG_Display;
421 struct tagSFG_Display
422 {
423         SFG_PlatformDisplay pDisplay;
424
425     int             ScreenWidth;        /* The screen's width in pixels      */
426     int             ScreenHeight;       /* The screen's height in pixels     */
427     int             ScreenWidthMM;      /* The screen's width in milimeters  */
428     int             ScreenHeightMM;     /* The screen's height in milimeters */
429 };
430
431
432 /* The user can create any number of timer hooks */
433 typedef struct tagSFG_Timer SFG_Timer;
434 struct tagSFG_Timer
435 {
436     SFG_Node        Node;
437     int             ID;                 /* The timer ID integer              */
438     FGCBTimerUC     Callback;           /* The timer callback                */
439     FGCBUserData    CallbackData;       /* The timer callback user data      */
440     fg_time_t       TriggerTime;        /* The timer trigger time            */
441 };
442
443 /*
444  * A window and its OpenGL context. The contents of this structure
445  * are highly dependent on the target operating system we aim at...
446  */
447 typedef struct tagSFG_Context SFG_Context;
448 struct tagSFG_Context
449 {
450     SFG_WindowHandleType  Handle;    /* The window's handle                 */
451     SFG_WindowContextType Context;   /* The window's OpenGL/WGL context     */
452
453         SFG_PlatformContext pContext;    /* The window's FBConfig (X11) or device context (Windows) */
454
455     int             DoubleBuffered;  /* Treat the window as double-buffered */
456
457     /* When drawing geometry to vertex attribute buffers, user specifies
458      * the attribute indices for vertices, normals and/or texture coords
459      * to freeglut. Those are stored here
460      */
461     GLint           attribute_v_coord;
462     GLint           attribute_v_normal;
463     GLint           attribute_v_texture;
464 };
465
466
467 /*
468  * Bitmasks indicating the different kinds of
469  * actions that can be scheduled for a window.
470  */
471 #define GLUT_INIT_WORK        (1<<0)
472 #define GLUT_VISIBILITY_WORK  (1<<1)
473 #define GLUT_POSITION_WORK    (1<<2)
474 #define GLUT_SIZE_WORK        (1<<3)
475 #define GLUT_ZORDER_WORK      (1<<4)
476 #define GLUT_FULL_SCREEN_WORK (1<<5)
477 #define GLUT_DISPLAY_WORK     (1<<6)
478
479 /*
480  * An enumeration containing the desired mapping state of a window
481  */
482 typedef enum
483 {
484   DesireHiddenState,
485   DesireIconicState,
486   DesireNormalState
487 } fgDesiredVisibility ;
488
489 /*
490  *  There is considerable confusion about the "right thing to
491  *  do" concerning window  size and position.  GLUT itself is
492  *  not consistent between Windows and UNIX/X11; since
493  *  platform independence is a virtue for "freeglut", we
494  *  decided to break with GLUT's behaviour.
495  *
496  *  Under UNIX/X11, it is apparently not possible to get the
497  *  window border sizes in order to subtract them off the
498  *  window's initial position until some time after the window
499  *  has been created.  Therefore we decided on the following
500  *  behaviour, both under Windows and under UNIX/X11:
501  *  - When you create a window with position (x,y) and size
502  *    (w,h), the upper left hand corner of the outside of the
503  *    window is at (x,y) and the size of the drawable area is
504  *    (w,h).
505  *  - When you query the size and position of the window--as
506  *    is happening here for Windows--"freeglut" will return
507  *    the size of the drawable area--the (w,h) that you
508  *    specified when you created the window--and the coordinates
509  *    of the upper left hand corner of the drawable area, i.e.
510  *    of the client rect--which is NOT the (x,y) you specified.
511  */
512 typedef struct tagSFG_WindowState SFG_WindowState;
513 struct tagSFG_WindowState   /* as per notes above, sizes always refer to the client area (thus without the window decorations) */
514 {
515     /* window state - size, position, look */
516     int             Xpos;               /* Window's top-left of client area, X-coordinate */
517     int             Ypos;               /* Window's top-left of client area, Y-coordinate */
518     int             Width;              /* Window's width in pixels          */
519     int             Height;             /* The same about the height         */
520     GLboolean       Visible;            /* Is the window visible now? Not using fgVisibilityState as we only care if visible or not */
521     int             Cursor;             /* The currently selected cursor style */
522     GLboolean       IsFullscreen;       /* is the window fullscreen?         */
523
524     /* FreeGLUT operations are deferred, that is, window moving, resizing,
525      * Z-order changing, making full screen or not do not happen immediately
526      * upon the user's request, but only in the next iteration of the main
527      * loop, before the display callback is called. This allows multiple
528      * reshape, position, etc requests to be combined into one and is
529      * compatible with the way GLUT does things. Callbacks get triggered
530      * based on the feedback/messages/notifications from the window manager.
531      * Below here we define what work should be done, as well as the relevant
532      * parameters for this work.
533      */
534     unsigned int    WorkMask;           /* work (resize, etc) to be done on the window */
535     int             DesiredXpos;        /* desired X location */
536     int             DesiredYpos;        /* desired Y location */
537     int             DesiredWidth;       /* desired window width */
538     int             DesiredHeight;      /* desired window height */
539     int             DesiredZOrder;      /* desired window Z Order position */
540     fgDesiredVisibility DesiredVisibility;/* desired visibility (hidden, iconic, shown/normal) */
541
542         SFG_PlatformWindowState pWState;    /* Window width/height (X11) or rectangle/style (Windows) from before a resize, and other stuff only needed on specific platforms */
543
544     long            JoystickPollRate;   /* The joystick polling rate         */
545     fg_time_t       JoystickLastPoll;   /* When the last poll happened       */
546
547     int             MouseX, MouseY;     /* The most recent mouse position    */
548
549     GLboolean       IgnoreKeyRepeat;    /* Whether to ignore key repeat.     */
550
551     GLboolean       VisualizeNormals;   /* When drawing objects, draw vectors representing the normals as well? */
552 };
553
554
555 /*
556  * A generic function pointer.  We should really use the GLUTproc type
557  * defined in freeglut_ext.h, but if we include that header in this file
558  * a bunch of other stuff (font-related) blows up!
559  */
560 typedef void (*SFG_Proc)();
561
562
563 /*
564  * SET_WCB() is used as:
565  *
566  *     SET_WCB( window, cbname, func, udata );
567  *
568  * ...where {window} is the freeglut window to set the callback,
569  *          {cbname} is the window-specific callback to set,
570  *          {func} is a function-pointer,
571  *          {udata} is a void* pointer for user data.
572  *
573  * Originally, {FETCH_WCB( ... ) = func} was rather sloppily used,
574  * but this can cause warnings because the FETCH_WCB() macro type-
575  * casts its result, and a type-cast value shouldn't be an lvalue.
576  *
577  * The {if( FETCH_WCB( ... ) != func )} test is to do type-checking
578  * and for no other reason.  Since it's hidden in the macro, the
579  * ugliness is felt to be rather benign.
580  *
581  * If the function-pointer is the same, the data will be the only
582  * value updated. If the function-pointer changes, the data will
583  * be changed as well, preventing stail data from being passed in.
584  * Just updating the data does nothing unless a function-pointer
585  * exists, as the data is otherwise already allocated.
586  */
587 #define SET_WCB(window,cbname,func,udata)                      \
588 do                                                             \
589 {                                                              \
590     if( FETCH_WCB( window, cbname ) != (SFG_Proc)(func) )      \
591     {                                                          \
592         (((window).CallBacks[WCB_ ## cbname]) = (SFG_Proc)(func)); \
593         (((window).CallbackDatas[WCB_ ## cbname]) = (udata));  \
594     }                                                          \
595         else if( FETCH_USER_DATA_WCB( window, cbname ) != udata )  \
596         {                                                          \
597                 (((window).CallbackDatas[WCB_ ## cbname]) = (udata));  \
598         }                                                          \
599 } while( 0 )
600
601 /*
602  * FETCH_WCB() is used as:
603  *
604  *     FETCH_WCB( window, cbname );
605  *
606  * ...where {window} is the freeglut window to fetch the callback from,
607  *          {cbname} is the window-specific callback to fetch.
608  *
609  * The result is correctly type-cast to the callback function pointer
610  * type.
611  */
612 #define FETCH_WCB(window,cbname) \
613     ((window).CallBacks[WCB_ ## cbname])
614
615 /*
616  * FETCH_USER_DATA_WCB() is used as:
617  * 
618  *     FETCH_USER_DATA_WCB( window, cbname );
619  *
620  * ...where {window} is the freeglut window,
621  *          {cbname} is the window-specific callback to be invoked,
622  *
623  * This expects a variable named "window" of type tagSFG_Window to exist.
624  *
625  * The result is the callback data pointer.
626  */
627 #define FETCH_USER_DATA_WCB(window,cbname) \
628     ((window).CallbackDatas[WCB_ ## cbname])
629
630 /*
631  * EXPAND_WCB() is used as:
632  * 
633  *     EXPAND_WCB( cbname )(( arg_list, userData ))
634  * 
635  * ... where {(arg_list)} is the parameter list and userData is user
636  * provided data.
637  *
638  * This will take the arg_list and extend it by one argument, adding
639  * the argument "userData" to the end of the list.
640  *
641  * All of this is defined in fg_callback_macros.h
642  *
643  * See that header for more info.
644  *
645  * ------------------------------------------------------------------
646  */
647
648 /*
649  * INVOKE_WCB() is used as:
650  *
651  *     INVOKE_WCB( window, cbname, ( arg_list ) );
652  *
653  * ...where {window} is the freeglut window,
654  *          {cbname} is the window-specific callback to be invoked,
655  *          {(arg_list)} is the parameter list.
656  *
657  * The callback is invoked as:
658  *
659  *    callback( arg_list, userData );
660  *
661  * ...where userData is added to the arg_list, but the parentheses 
662  * are REQUIRED in the {arg_list}.
663  *
664  * NOTE that it does a sanity-check and also sets the
665  * current window.
666  *
667  */
668 #if TARGET_HOST_MS_WINDOWS && !defined(_WIN32_WCE) /* FIXME: also WinCE? */
669 #define INVOKE_WCB(window,cbname,arg_list)    \
670 do                                            \
671 {                                             \
672     if( FETCH_WCB( window, cbname ) )         \
673     {                                         \
674         FGCB ## cbname ## UC func = (FGCB ## cbname ## UC)(FETCH_WCB( window, cbname )); \
675         FGCBUserData userData = FETCH_USER_DATA_WCB( window, cbname ); \
676         fgSetWindow( &window );               \
677                 func EXPAND_WCB( cbname )(( arg_list, userData )); \
678     }                                         \
679 } while( 0 )
680 #else
681 #define INVOKE_WCB(window,cbname,arg_list)    \
682 do                                            \
683 {                                             \
684     if( FETCH_WCB( window, cbname ) )         \
685     {                                         \
686         fgSetWindow( &window );               \
687         FGCBUserData userData = FETCH_USER_DATA_WCB( window, cbname ); \
688                 ((FGCB ## cbname ## UC)FETCH_WCB( window, cbname )) EXPAND_WCB( cbname )(( arg_list, userData )); \
689     }                                         \
690 } while( 0 )
691 #endif
692
693 /*
694  * The window callbacks the user can supply us with. Should be kept portable.
695  *
696  * This enumeration provides the freeglut CallBack numbers.
697  * The symbolic constants are indices into a window's array of
698  * function callbacks.  The names are formed by splicing a common
699  * prefix onto the callback's base name.  (This was originally
700  * done so that an early stage of development could live side-by-
701  * side with the old callback code.  The old callback code used
702  * the bare callback's name as a structure member, so I used a
703  * prefix for the array index name.)
704  */
705 enum
706 {
707     WCB_Display,
708     WCB_Reshape,
709     WCB_Position,
710     WCB_Keyboard,
711     WCB_KeyboardUp,
712     WCB_Special,
713     WCB_SpecialUp,
714     WCB_Mouse,
715     WCB_MouseWheel,
716     WCB_Motion,
717     WCB_Passive,
718     WCB_Entry,
719     WCB_Visibility,
720     WCB_WindowStatus,
721     WCB_Joystick,
722     WCB_Destroy,
723
724     /* Multi-Pointer X and touch related */
725     WCB_MultiEntry,
726     WCB_MultiButton,
727     WCB_MultiMotion,
728     WCB_MultiPassive,
729
730     /* Mobile platforms LifeCycle */
731     WCB_InitContext,
732     WCB_AppStatus,
733
734     /* Presently ignored */
735     WCB_Select,
736     WCB_OverlayDisplay,
737     WCB_SpaceMotion,     /* presently implemented only on UNIX/X11 and Windows */
738     WCB_SpaceRotation,   /* presently implemented only on UNIX/X11 and Windows */
739     WCB_SpaceButton,     /* presently implemented only on UNIX/X11 and Windows */
740     WCB_Dials,
741     WCB_ButtonBox,
742     WCB_TabletMotion,
743     WCB_TabletButton,
744
745     /* Always make this the LAST one */
746     TOTAL_CALLBACKS
747 };
748
749
750 /* This structure holds the OpenGL rendering context for all the menu windows */
751 typedef struct tagSFG_MenuContext SFG_MenuContext;
752 struct tagSFG_MenuContext
753 {
754     SFG_WindowContextType MContext;       /* The menu window's WGL context   */
755 };
756
757 /* This structure describes a menu */
758 typedef struct tagSFG_Window SFG_Window;
759 typedef struct tagSFG_MenuEntry SFG_MenuEntry;
760 typedef struct tagSFG_Menu SFG_Menu;
761 struct tagSFG_Menu
762 {
763     SFG_Node            Node;
764     void               *UserData;     /* User data passed back at callback   */
765     int                 ID;           /* The global menu ID                  */
766     SFG_List            Entries;      /* The menu entries list               */
767     FGCBMenuUC          Callback;     /* The menu callback                   */
768     FGCBUserData        CallbackData; /* The menu callback user data         */
769     FGCBDestroyUC       Destroy;      /* Destruction callback                */
770     FGCBUserData        DestroyData;  /* Destruction callback user data      */
771     GLboolean           IsActive;     /* Is the menu selected?               */
772     void*               Font;         /* Font to be used for displaying this menu */
773     int                 Width;        /* Menu box width in pixels            */
774     int                 Height;       /* Menu box height in pixels           */
775     int                 X, Y;         /* Menu box raster position            */
776
777     SFG_MenuEntry      *ActiveEntry;  /* Currently active entry in the menu  */
778     SFG_Window         *Window;       /* Window for menu                     */
779     SFG_Window         *ParentWindow; /* Window in which the menu is invoked */
780 };
781
782 /* This is a menu entry */
783 struct tagSFG_MenuEntry
784 {
785     SFG_Node            Node;
786     int                 ID;                     /* The menu entry ID (local) */
787     int                 Ordinal;                /* The menu's ordinal number */
788     char*               Text;                   /* The text to be displayed  */
789     SFG_Menu*           SubMenu;                /* Optional sub-menu tree    */
790     GLboolean           IsActive;               /* Is the entry highlighted? */
791     int                 Width;                  /* Label's width in pixels   */
792 };
793
794 /*
795  * A window, making part of freeglut windows hierarchy.
796  * Should be kept portable.
797  *
798  * NOTE that ActiveMenu is set to menu itself if the window is a menu.
799  */
800 struct tagSFG_Window
801 {
802     SFG_Node            Node;
803     int                 ID;                     /* Window's ID number        */
804
805     SFG_Context         Window;                 /* Window and OpenGL context */
806     SFG_WindowState     State;                  /* The window state          */
807     SFG_Proc            CallBacks[ TOTAL_CALLBACKS ]; /* Array of window callbacks */
808     FGCBUserData        CallbackDatas[ TOTAL_CALLBACKS ]; /* Array of window callback datas */
809     void               *UserData ;              /* For use by user           */
810
811     SFG_Menu*           Menu[ FREEGLUT_MAX_MENUS ]; /* Menus appended to window  */
812     SFG_Menu*           ActiveMenu;             /* The window's active menu  */
813
814     SFG_Window*         Parent;                 /* The parent to this window */
815     SFG_List            Children;               /* The subwindows d.l. list  */
816
817     GLboolean           IsMenu;                 /* Set to 1 if we are a menu */
818 };
819
820
821 /* A linked list structure of windows */
822 typedef struct tagSFG_WindowList SFG_WindowList ;
823 struct tagSFG_WindowList
824 {
825     SFG_Node node;
826     SFG_Window *window ;
827 };
828
829 /* This holds information about all the windows, menus etc. */
830 typedef struct tagSFG_Structure SFG_Structure;
831 struct tagSFG_Structure
832 {
833     SFG_List        Windows;         /* The global windows list            */
834     SFG_List        Menus;           /* The global menus list              */
835     SFG_List        WindowsToDestroy;
836
837     SFG_Window*     CurrentWindow;   /* The currently set window          */
838     SFG_Menu*       CurrentMenu;     /* Same, but menu...                 */
839
840     SFG_MenuContext* MenuContext;    /* OpenGL rendering context for menus */
841
842     SFG_Window*      GameModeWindow; /* The game mode window               */
843
844     int              WindowID;       /* The window ID for the next window to be created */
845     int              MenuID;         /* The menu ID for the next menu to be created */
846 };
847
848 /*
849  * This structure is used for the enumeration purposes.
850  * You can easily extend its functionalities by declaring
851  * a structure containing enumerator's contents and custom
852  * data, then casting its pointer to (SFG_Enumerator *).
853  */
854 typedef struct tagSFG_Enumerator SFG_Enumerator;
855 struct tagSFG_Enumerator
856 {
857     GLboolean   found;                          /* Used to terminate search  */
858     void*       data;                           /* Custom data pointer       */
859 };
860 typedef void (* FGCBWindowEnumerator  )( SFG_Window *, SFG_Enumerator * );
861 typedef void (* FGCBMenuEnumerator  )( SFG_Menu *, SFG_Enumerator * );
862
863 /* The bitmap font structure */
864 typedef struct tagSFG_Font SFG_Font;
865 struct tagSFG_Font
866 {
867     char*           Name;         /* The source font name             */
868     int             Quantity;     /* Number of chars in font          */
869     int             Height;       /* Height of the characters         */
870     const GLubyte** Characters;   /* The characters mapping           */
871
872     float           xorig, yorig; /* Relative origin of the character */
873 };
874
875 /* The stroke font structures */
876
877 typedef struct tagSFG_StrokeVertex SFG_StrokeVertex;
878 struct tagSFG_StrokeVertex
879 {
880     GLfloat         X, Y;
881 };
882
883 typedef struct tagSFG_StrokeStrip SFG_StrokeStrip;
884 struct tagSFG_StrokeStrip
885 {
886     int             Number;
887     const SFG_StrokeVertex* Vertices;
888 };
889
890 typedef struct tagSFG_StrokeChar SFG_StrokeChar;
891 struct tagSFG_StrokeChar
892 {
893     GLfloat         Right;
894     int             Number;
895     const SFG_StrokeStrip* Strips;
896 };
897
898 typedef struct tagSFG_StrokeFont SFG_StrokeFont;
899 struct tagSFG_StrokeFont
900 {
901     char*           Name;                       /* The source font name      */
902     int             Quantity;                   /* Number of chars in font   */
903     GLfloat         Height;                     /* Height of the characters  */
904     const SFG_StrokeChar** Characters;          /* The characters mapping    */
905 };
906
907
908 /* -- JOYSTICK-SPECIFIC STRUCTURES AND TYPES ------------------------------- */
909 /*
910  * Initial defines from "js.h" starting around line 33 with the existing "fg_joystick.c"
911  * interspersed
912  */
913
914 #if TARGET_HOST_MACINTOSH
915 #    include <InputSprocket.h>
916 #endif
917
918 #if TARGET_HOST_MAC_OSX
919 #    include <mach/mach.h>
920 #    include <IOKit/IOkitLib.h>
921 #    include <IOKit/hid/IOHIDLib.h>
922 #endif
923
924 /* XXX It might be better to poll the operating system for the numbers of buttons and
925  * XXX axes and then dynamically allocate the arrays.
926  */
927 #define _JS_MAX_BUTTONS 32
928
929 #if TARGET_HOST_MACINTOSH
930 #    define _JS_MAX_AXES  9
931 typedef struct tagSFG_PlatformJoystick SFG_PlatformJoystick;
932 struct tagSFG_PlatformJoystick
933 {
934 #define  ISP_NUM_AXIS    9
935 #define  ISP_NUM_NEEDS  41
936     ISpElementReference isp_elem  [ ISP_NUM_NEEDS ];
937     ISpNeed             isp_needs [ ISP_NUM_NEEDS ];
938 };
939 #endif
940
941 #if TARGET_HOST_MAC_OSX
942 #    define _JS_MAX_AXES 16
943 typedef struct tagSFG_PlatformJoystick SFG_PlatformJoystick;
944 struct tagSFG_PlatformJoystick
945 {
946     IOHIDDeviceInterface ** hidDev;
947     IOHIDElementCookie buttonCookies[41];
948     IOHIDElementCookie axisCookies[_JS_MAX_AXES];
949 /* The next two variables are not used anywhere */
950 /*    long minReport[_JS_MAX_AXES],
951  *         maxReport[_JS_MAX_AXES];
952  */
953 };
954 #endif
955
956
957 /*
958  * Definition of "SFG_Joystick" structure -- based on JS's "jsJoystick" object class.
959  * See "js.h" lines 80-178.
960  */
961 typedef struct tagSFG_Joystick SFG_Joystick;
962 struct tagSFG_Joystick
963 {
964         SFG_PlatformJoystick pJoystick;
965
966     int          id;
967     GLboolean    error;
968     char         name [ 128 ];
969     int          num_axes;
970     int          num_buttons;
971
972     float dead_band[ _JS_MAX_AXES ];
973     float saturate [ _JS_MAX_AXES ];
974     float center   [ _JS_MAX_AXES ];
975     float max      [ _JS_MAX_AXES ];
976     float min      [ _JS_MAX_AXES ];
977 };
978
979
980
981 /* -- GLOBAL VARIABLES EXPORTS --------------------------------------------- */
982
983 /* Freeglut display related stuff (initialized once per session) */
984 extern SFG_Display fgDisplay;
985
986 /* Freeglut internal structure */
987 extern SFG_Structure fgStructure;
988
989 /* The current freeglut settings */
990 extern SFG_State fgState;
991
992
993 /* -- PRIVATE FUNCTION DECLARATIONS ---------------------------------------- */
994
995 /*
996  * A call to this function makes us sure that the Display and Structure
997  * subsystems have been properly initialized and are ready to be used
998  */
999 #define  FREEGLUT_EXIT_IF_NOT_INITIALISED( string )               \
1000   if ( ! fgState.Initialised )                                    \
1001   {                                                               \
1002     fgError ( " ERROR:  Function <%s> called"                     \
1003               " without first calling 'glutInit'.", (string) ) ;  \
1004   }
1005
1006 #define  FREEGLUT_INTERNAL_ERROR_EXIT_IF_NOT_INITIALISED( string )  \
1007   if ( ! fgState.Initialised )                                      \
1008   {                                                                 \
1009     fgError ( " ERROR:  Internal <%s> function called"              \
1010               " without first calling 'glutInit'.", (string) ) ;    \
1011   }
1012
1013 #define  FREEGLUT_INTERNAL_ERROR_EXIT( cond, string, function )  \
1014   if ( ! ( cond ) )                                              \
1015   {                                                              \
1016     fgError ( " ERROR:  Internal error <%s> in function %s",     \
1017               (string), (function) ) ;                           \
1018   }
1019
1020 /*
1021  * Following definitions are somewhat similar to GLib's,
1022  * but do not generate any log messages:
1023  */
1024 #define  freeglut_return_if_fail( expr ) \
1025     if( !(expr) )                        \
1026         return;
1027 #define  freeglut_return_val_if_fail( expr, val ) \
1028     if( !(expr) )                                 \
1029         return val ;
1030
1031 /*
1032  * A call to those macros assures us that there is a current
1033  * window set, respectively:
1034  */
1035 #define  FREEGLUT_EXIT_IF_NO_WINDOW( string )                               \
1036   if ( ! fgStructure.CurrentWindow &&                                       \
1037        ( fgState.ActionOnWindowClose != GLUT_ACTION_CONTINUE_EXECUTION ) )  \
1038   {                                                                         \
1039     fgError ( " ERROR:  Function <%s> called"                               \
1040               " with no current window defined.", (string) ) ;              \
1041   }
1042
1043 /*
1044  * The deinitialize function gets called on glutMainLoop() end. It should clean up
1045  * everything inside of the freeglut
1046  */
1047 void fgDeinitialize( void );
1048
1049 /*
1050  * Those two functions are used to create/destroy the freeglut internal
1051  * structures. This actually happens when calling glutInit() and when
1052  * quitting the glutMainLoop() (which actually happens, when all windows
1053  * have been closed).
1054  */
1055 void fgCreateStructure( void );
1056 void fgDestroyStructure( void );
1057
1058 /*
1059  * Window creation, opening, closing and destruction.
1060  * Also CallBack clearing/initialization.
1061  * Defined in fg_structure.c, fg_window.c.
1062  */
1063 SFG_Window* fgCreateWindow( SFG_Window* parent, const char* title,
1064                             GLboolean positionUse, int x, int y,
1065                             GLboolean sizeUse, int w, int h,
1066                             GLboolean gameMode, GLboolean isMenu );
1067 void        fgSetWindow ( SFG_Window *window );
1068 void        fgOpenWindow( SFG_Window* window, const char* title,
1069                           GLboolean positionUse, int x, int y,
1070                           GLboolean sizeUse, int w, int h,
1071                           GLboolean gameMode, GLboolean isSubWindow );
1072 void        fgCloseWindow( SFG_Window* window );
1073 void        fgAddToWindowDestroyList ( SFG_Window* window );
1074 void        fgCloseWindows ();
1075 void        fgDestroyWindow( SFG_Window* window );
1076
1077 /* Menu creation and destruction. Defined in fg_structure.c */
1078 SFG_Menu*   fgCreateMenu( FGCBMenuUC menuCallback, FGCBUserData userData );
1079 void        fgDestroyMenu( SFG_Menu* menu );
1080
1081 /* Joystick device management functions, defined in fg_joystick.c */
1082 int         fgJoystickDetect( void );
1083 void        fgInitialiseJoysticks( void );
1084 void        fgJoystickClose( void );
1085 void        fgJoystickPollWindow( SFG_Window* window );
1086
1087 /* InputDevice Initialisation and Closure */
1088 int         fgInputDeviceDetect( void );
1089 void        fgInitialiseInputDevices( void );
1090 void        fgInputDeviceClose( void );
1091
1092 /* spaceball device functions, defined in fg_spaceball.c */
1093 void        fgInitialiseSpaceball( void );
1094 void        fgSpaceballClose( void );
1095 void        fgSpaceballSetWindow( SFG_Window *window );
1096
1097 int         fgHasSpaceball( void );
1098 int         fgSpaceballNumButtons( void );
1099
1100 /* Setting the cursor for a given window */
1101 void fgSetCursor ( SFG_Window *window, int cursorID );
1102
1103 /*
1104  * Helper function to enumerate through all registered windows
1105  * and one to enumerate all of a window's subwindows...
1106  *
1107  * The GFunc callback for those functions will be defined as:
1108  *
1109  *      void enumCallback( gpointer window, gpointer enumerator );
1110  *
1111  * where window is the enumerated (sub)window pointer (SFG_Window *),
1112  * and userData is the a custom user-supplied pointer. Functions
1113  * are defined and exported from fg_structure.c file.
1114  */
1115 void fgEnumWindows( FGCBWindowEnumerator enumCallback, SFG_Enumerator* enumerator );
1116 void fgEnumSubWindows( SFG_Window* window, FGCBWindowEnumerator enumCallback,
1117                        SFG_Enumerator* enumerator );
1118
1119 /*
1120  * fgWindowByHandle returns a (SFG_Window *) value pointing to the
1121  * first window in the queue matching the specified window handle.
1122  * The function is defined in fg_structure.c file.
1123  */
1124 SFG_Window* fgWindowByHandle( SFG_WindowHandleType hWindow );
1125
1126 /*
1127  * This function is similar to the previous one, except it is
1128  * looking for a specified (sub)window identifier. The function
1129  * is defined in fg_structure.c file.
1130  */
1131 SFG_Window* fgWindowByID( int windowID );
1132
1133 /*
1134  * Looks up a menu given its ID. This is easier than fgWindowByXXX
1135  * as all menus are placed in a single doubly linked list...
1136  */
1137 SFG_Menu* fgMenuByID( int menuID );
1138
1139 /*
1140  * Returns active menu, if any. Assumption: only one menu active throughout application at any one time.
1141  * This is easier than fgWindowByXXX as all menus are placed in one doubly linked list...
1142  */
1143 SFG_Menu* fgGetActiveMenu( );
1144
1145 /*
1146  * The menu activation and deactivation the code. This is the meat
1147  * of the menu user interface handling code...
1148  */
1149 void fgUpdateMenuHighlight ( SFG_Menu *menu );
1150 GLboolean fgCheckActiveMenu ( SFG_Window *window, int button, GLboolean pressed,
1151                               int mouse_x, int mouse_y );
1152 void fgDeactivateMenu( SFG_Window *window );
1153
1154 /*
1155  * This function gets called just before the buffers swap, so that
1156  * freeglut can display the pull-down menus via OpenGL. The function
1157  * is defined in fg_menu.c file.
1158  */
1159 void fgDisplayMenu( void );
1160
1161 /* Elapsed time as per glutGet(GLUT_ELAPSED_TIME). */
1162 fg_time_t fgElapsedTime( void );
1163
1164 /* System time in milliseconds */
1165 fg_time_t fgSystemTime(void);
1166
1167 /* List functions */
1168 void fgListInit(SFG_List *list);
1169 void fgListAppend(SFG_List *list, SFG_Node *node);
1170 void fgListRemove(SFG_List *list, SFG_Node *node);
1171 int fgListLength(SFG_List *list);
1172 void fgListInsert(SFG_List *list, SFG_Node *next, SFG_Node *node);
1173
1174 /* Error Message functions */
1175 void fgError( const char *fmt, ... );
1176 void fgWarning( const char *fmt, ... );
1177
1178 SFG_Proc fgPlatformGetProcAddress( const char *procName );
1179
1180 /* pushing attribute/value pairs into an array */
1181 #define ATTRIB(a) attributes[where++]=(a)
1182 #define ATTRIB_VAL(a,v) {ATTRIB(a); ATTRIB(v);}
1183
1184 int fghMapBit( int mask, int from, int to );
1185 int fghIsLegacyContextRequested( void );
1186 void fghContextCreationError( void );
1187 int fghNumberOfAuxBuffersRequested( void );
1188
1189 #endif /* FREEGLUT_INTERNAL_H */
1190
1191 /*** END OF FILE ***/