1aaad5274abbeaa284b4f784478261644ff40e6c
[freeglut] / src / Common / freeglut_internal.h
1 /*\r
2  * freeglut_internal.h\r
3  *\r
4  * The freeglut library private include file.\r
5  *\r
6  * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.\r
7  * Written by Pawel W. Olszta, <olszta@sourceforge.net>\r
8  * Creation date: Thu Dec 2 1999\r
9  *\r
10  * Permission is hereby granted, free of charge, to any person obtaining a\r
11  * copy of this software and associated documentation files (the "Software"),\r
12  * to deal in the Software without restriction, including without limitation\r
13  * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
14  * and/or sell copies of the Software, and to permit persons to whom the\r
15  * Software is furnished to do so, subject to the following conditions:\r
16  *\r
17  * The above copyright notice and this permission notice shall be included\r
18  * in all copies or substantial portions of the Software.\r
19  *\r
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r
21  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
22  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL\r
23  * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
24  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
25  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
26  */\r
27 \r
28 #ifndef  FREEGLUT_INTERNAL_H\r
29 #define  FREEGLUT_INTERNAL_H\r
30 \r
31 #ifdef HAVE_CONFIG_H\r
32 #    include "config.h"\r
33 #endif\r
34 \r
35 /* XXX Update these for each release! */\r
36 #define  VERSION_MAJOR 3\r
37 #define  VERSION_MINOR 0\r
38 #define  VERSION_PATCH 0\r
39 \r
40 /* Freeglut is intended to function under all Unix/X11 and Win32 platforms. */\r
41 /* XXX: Don't all MS-Windows compilers (except Cygwin) have _WIN32 defined?\r
42  * XXX: If so, remove the first set of defined()'s below.\r
43  */\r
44 #if !defined(TARGET_HOST_POSIX_X11) && !defined(TARGET_HOST_MS_WINDOWS) && !defined(TARGET_HOST_MAC_OSX) && !defined(TARGET_HOST_SOLARIS)\r
45 #if defined(_MSC_VER) || defined(__WATCOMC__) || defined(__MINGW32__) \\r
46     || defined(_WIN32) || defined(_WIN32_WCE) \\r
47     || ( defined(__CYGWIN__) && defined(X_DISPLAY_MISSING) )\r
48 #   define  TARGET_HOST_MS_WINDOWS 1\r
49 \r
50 #elif defined(__posix__) || defined(__unix__) || defined(__linux__) || defined(__sun)\r
51 #   define  TARGET_HOST_POSIX_X11  1\r
52 \r
53 #elif defined(__APPLE__)\r
54 /* This is a placeholder until we get native OSX support ironed out -- JFF 11/18/09 */\r
55 #   define  TARGET_HOST_POSIX_X11  1\r
56 /* #   define  TARGET_HOST_MAC_OSX    1 */\r
57 \r
58 #else\r
59 #   error "Unrecognized target host!"\r
60 \r
61 #endif\r
62 #endif\r
63 \r
64 /* Detect both SunPro and gcc compilers on Sun Solaris */\r
65 #if defined (__SVR4) && defined (__sun)\r
66 #   define TARGET_HOST_SOLARIS 1\r
67 #endif\r
68 \r
69 #ifndef TARGET_HOST_MS_WINDOWS\r
70 #   define  TARGET_HOST_MS_WINDOWS 0\r
71 #endif\r
72 \r
73 #ifndef  TARGET_HOST_POSIX_X11\r
74 #   define  TARGET_HOST_POSIX_X11  0\r
75 #endif\r
76 \r
77 #ifndef  TARGET_HOST_MAC_OSX\r
78 #   define  TARGET_HOST_MAC_OSX    0\r
79 #endif\r
80 \r
81 #ifndef  TARGET_HOST_SOLARIS\r
82 #   define  TARGET_HOST_SOLARIS    0\r
83 #endif\r
84 \r
85 /* -- FIXED CONFIGURATION LIMITS ------------------------------------------- */\r
86 \r
87 #define  FREEGLUT_MAX_MENUS         3\r
88 \r
89 /* -- PLATFORM-SPECIFIC INCLUDES ------------------------------------------- */\r
90 \r
91 #if TARGET_HOST_POSIX_X11\r
92 #    include <GL/glx.h>\r
93 #    include <X11/Xlib.h>\r
94 #    include <X11/Xatom.h>\r
95 #    include <X11/keysym.h>\r
96 #    include <X11/extensions/XInput.h>\r
97 #    ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H\r
98 #        include <X11/extensions/xf86vmode.h>\r
99 #    endif\r
100 #    ifdef HAVE_X11_EXTENSIONS_XRANDR_H\r
101 #        include <X11/extensions/Xrandr.h>\r
102 #    endif\r
103 /* If GLX is too old, we will fail during runtime when multisampling\r
104    is requested, but at least freeglut compiles. */\r
105 #    ifndef GLX_SAMPLE_BUFFERS\r
106 #        define GLX_SAMPLE_BUFFERS 0x80A8\r
107 #    endif\r
108 #    ifndef GLX_SAMPLES\r
109 #        define GLX_SAMPLES 0x80A9\r
110 #    endif\r
111 \r
112 #endif\r
113 \r
114 /* These files should be available on every platform. */\r
115 #include <stdio.h>\r
116 #include <string.h>\r
117 #include <math.h>\r
118 #include <stdlib.h>\r
119 #include <stdarg.h>\r
120 \r
121 /* These are included based on autoconf directives. */\r
122 #ifdef HAVE_SYS_TYPES_H\r
123 #    include <sys/types.h>\r
124 #endif\r
125 #ifdef HAVE_UNISTD_H\r
126 #    include <unistd.h>\r
127 #endif\r
128 #ifdef TIME_WITH_SYS_TIME\r
129 #    include <sys/time.h>\r
130 #    include <time.h>\r
131 #elif defined(HAVE_SYS_TIME_H)\r
132 #    include <sys/time.h>\r
133 #else\r
134 #    include <time.h>\r
135 #endif\r
136 \r
137 /* -- AUTOCONF HACKS --------------------------------------------------------*/\r
138 \r
139 /* XXX: Update autoconf to avoid these.\r
140  * XXX: Are non-POSIX platforms intended not to use autoconf?\r
141  * If so, perhaps there should be a config_guess.h for them. Alternatively,\r
142  * config guesses could be placed above, just after the config.h exclusion.\r
143  */\r
144 #if defined(__FreeBSD__) || defined(__NetBSD__)\r
145 #    define HAVE_USB_JS 1\r
146 #    if defined(__NetBSD__) || ( defined(__FreeBSD__) && __FreeBSD_version >= 500000)\r
147 #        define HAVE_USBHID_H 1\r
148 #    endif\r
149 #endif\r
150 \r
151 #if defined(_MSC_VER) || defined(__WATCOMC__)\r
152 /* strdup() is non-standard, for all but POSIX-2001 */\r
153 #define strdup   _strdup\r
154 #endif\r
155 \r
156 /* M_PI is non-standard (defined by BSD, not ISO-C) */\r
157 #ifndef M_PI\r
158 #    define  M_PI  3.14159265358979323846\r
159 #endif\r
160 \r
161 #ifdef HAVE_STDBOOL_H\r
162 #    include <stdbool.h>\r
163 #    ifndef TRUE\r
164 #        define TRUE true\r
165 #    endif\r
166 #    ifndef FALSE\r
167 #        define FALSE false\r
168 #    endif\r
169 #else\r
170 #    ifndef TRUE\r
171 #        define  TRUE  1\r
172 #    endif\r
173 #    ifndef FALSE\r
174 #        define  FALSE  0\r
175 #    endif\r
176 #endif\r
177 \r
178 /* General defines */\r
179 \r
180 #define INVALID_MODIFIERS 0xffffffff\r
181 \r
182 \r
183 \r
184 /* Platform-specific includes */\r
185 #if TARGET_HOST_POSIX_X11\r
186 \r
187 typedef struct tagSFG_PlatformDisplay SFG_PlatformDisplay;\r
188 struct tagSFG_PlatformDisplay\r
189 {\r
190     Display*        Display;            /* The display we are being run in.  */\r
191     int             Screen;             /* The screen we are about to use.   */\r
192     Window          RootWindow;         /* The screen's root window.         */\r
193     int             Connection;         /* The display's connection number   */\r
194     Atom            DeleteWindow;       /* The window deletion atom          */\r
195     Atom            State;              /* The state atom                    */\r
196     Atom            StateFullScreen;    /* The full screen atom              */\r
197 \r
198 #ifdef HAVE_X11_EXTENSIONS_XRANDR_H\r
199     int prev_xsz, prev_ysz;\r
200     int prev_refresh;\r
201     int prev_size_valid;\r
202 #endif  /* HAVE_X11_EXTENSIONS_XRANDR_H */\r
203 \r
204 #ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H\r
205     /*\r
206      * XF86VidMode may be compilable even if it fails at runtime.  Therefore,\r
207      * the validity of the VidMode has to be tracked\r
208      */\r
209     int             DisplayModeValid;   /* Flag that indicates runtime status*/\r
210     XF86VidModeModeLine DisplayMode;    /* Current screen's display settings */\r
211     int             DisplayModeClock;   /* The display mode's refresh rate   */\r
212     int             DisplayViewPortX;   /* saved X location of the viewport  */\r
213     int             DisplayViewPortY;   /* saved Y location of the viewport  */\r
214 #endif /* HAVE_X11_EXTENSIONS_XF86VMODE_H */\r
215 \r
216     int             DisplayPointerX;    /* saved X location of the pointer   */\r
217     int             DisplayPointerY;    /* saved Y location of the pointer   */\r
218 };\r
219 \r
220 \r
221 /*\r
222  * Make "freeglut" window handle and context types so that we don't need so\r
223  * much conditionally-compiled code later in the library.\r
224  */\r
225 typedef Window     SFG_WindowHandleType ;\r
226 typedef GLXContext SFG_WindowContextType ;\r
227 typedef struct tagSFG_PlatformContext SFG_PlatformContext;\r
228 struct tagSFG_PlatformContext\r
229 {\r
230     GLXFBConfig*    FBConfig;        /* The window's FBConfig               */\r
231 };\r
232 \r
233 \r
234 \r
235 #endif\r
236 #if TARGET_HOST_MS_WINDOWS\r
237 #include "../mswin/freeglut_internal_mswin.h"\r
238 #endif\r
239 \r
240 \r
241 /* -- GLOBAL TYPE DEFINITIONS ---------------------------------------------- */\r
242 \r
243 /* Freeglut callbacks type definitions */\r
244 typedef void (* FGCBDisplay       )( void );\r
245 typedef void (* FGCBReshape       )( int, int );\r
246 typedef void (* FGCBVisibility    )( int );\r
247 typedef void (* FGCBKeyboard      )( unsigned char, int, int );\r
248 typedef void (* FGCBSpecial       )( int, int, int );\r
249 typedef void (* FGCBMouse         )( int, int, int, int );\r
250 typedef void (* FGCBMouseWheel    )( int, int, int, int );\r
251 typedef void (* FGCBMotion        )( int, int );\r
252 typedef void (* FGCBPassive       )( int, int );\r
253 typedef void (* FGCBEntry         )( int );\r
254 typedef void (* FGCBWindowStatus  )( int );\r
255 typedef void (* FGCBSelect        )( int, int, int );\r
256 typedef void (* FGCBJoystick      )( unsigned int, int, int, int );\r
257 typedef void (* FGCBKeyboardUp    )( unsigned char, int, int );\r
258 typedef void (* FGCBSpecialUp     )( int, int, int );\r
259 typedef void (* FGCBOverlayDisplay)( void );\r
260 typedef void (* FGCBSpaceMotion   )( int, int, int );\r
261 typedef void (* FGCBSpaceRotation )( int, int, int );\r
262 typedef void (* FGCBSpaceButton   )( int, int );\r
263 typedef void (* FGCBDials         )( int, int );\r
264 typedef void (* FGCBButtonBox     )( int, int );\r
265 typedef void (* FGCBTabletMotion  )( int, int );\r
266 typedef void (* FGCBTabletButton  )( int, int, int, int );\r
267 typedef void (* FGCBDestroy       )( void );\r
268 \r
269 typedef void (* FGCBMultiEntry   )( int, int );\r
270 typedef void (* FGCBMultiButton  )( int, int, int, int, int );\r
271 typedef void (* FGCBMultiMotion  )( int, int, int );\r
272 typedef void (* FGCBMultiPassive )( int, int, int );\r
273 \r
274 /* The global callbacks type definitions */\r
275 typedef void (* FGCBIdle          )( void );\r
276 typedef void (* FGCBTimer         )( int );\r
277 typedef void (* FGCBMenuState     )( int );\r
278 typedef void (* FGCBMenuStatus    )( int, int, int );\r
279 \r
280 /* The callback used when creating/using menus */\r
281 typedef void (* FGCBMenu          )( int );\r
282 \r
283 /* The FreeGLUT error/warning handler type definition */\r
284 typedef void (* FGError           ) ( const char *fmt, va_list ap);\r
285 typedef void (* FGWarning         ) ( const char *fmt, va_list ap);\r
286 \r
287 \r
288 /* A list structure */\r
289 typedef struct tagSFG_List SFG_List;\r
290 struct tagSFG_List\r
291 {\r
292     void *First;\r
293     void *Last;\r
294 };\r
295 \r
296 /* A list node structure */\r
297 typedef struct tagSFG_Node SFG_Node;\r
298 struct tagSFG_Node\r
299 {\r
300     void *Next;\r
301     void *Prev;\r
302 };\r
303 \r
304 /* A helper structure holding two ints and a boolean */\r
305 typedef struct tagSFG_XYUse SFG_XYUse;\r
306 struct tagSFG_XYUse\r
307 {\r
308     GLint           X, Y;               /* The two integers...               */\r
309     GLboolean       Use;                /* ...and a single boolean.          */\r
310 };\r
311 \r
312 /*\r
313  * An enumeration containing the state of the GLUT execution:\r
314  * initializing, running, or stopping\r
315  */\r
316 typedef enum\r
317 {\r
318   GLUT_EXEC_STATE_INIT,\r
319   GLUT_EXEC_STATE_RUNNING,\r
320   GLUT_EXEC_STATE_STOP\r
321 } fgExecutionState ;\r
322 \r
323 /* This structure holds different freeglut settings */\r
324 typedef struct tagSFG_State SFG_State;\r
325 struct tagSFG_State\r
326 {\r
327     SFG_XYUse        Position;             /* The default windows' position  */\r
328     SFG_XYUse        Size;                 /* The default windows' size      */\r
329     unsigned int     DisplayMode;          /* Display mode for new windows   */\r
330 \r
331     GLboolean        Initialised;          /* freeglut has been initialised  */\r
332 \r
333     int              DirectContext;        /* Direct rendering state         */\r
334 \r
335     GLboolean        ForceIconic;          /* New top windows are iconified  */\r
336     GLboolean        UseCurrentContext;    /* New windows share with current */\r
337 \r
338     GLboolean        GLDebugSwitch;        /* OpenGL state debugging switch  */\r
339     GLboolean        XSyncSwitch;          /* X11 sync protocol switch       */\r
340 \r
341     int              KeyRepeat;            /* Global key repeat mode.        */\r
342     int              Modifiers;            /* Current ALT/SHIFT/CTRL state   */\r
343 \r
344     GLuint           FPSInterval;          /* Interval between FPS printfs   */\r
345     GLuint           SwapCount;            /* Count of glutSwapBuffer calls  */\r
346     GLuint           SwapTime;             /* Time of last SwapBuffers       */\r
347 \r
348     unsigned long    Time;                 /* Time that glutInit was called  */\r
349     SFG_List         Timers;               /* The freeglut timer hooks       */\r
350     SFG_List         FreeTimers;           /* The unused timer hooks         */\r
351 \r
352     FGCBIdle         IdleCallback;         /* The global idle callback       */\r
353 \r
354     int              ActiveMenus;          /* Num. of currently active menus */\r
355     FGCBMenuState    MenuStateCallback;    /* Menu callbacks are global      */\r
356     FGCBMenuStatus   MenuStatusCallback;\r
357 \r
358     SFG_XYUse        GameModeSize;         /* Game mode screen's dimensions  */\r
359     int              GameModeDepth;        /* The pixel depth for game mode  */\r
360     int              GameModeRefresh;      /* The refresh rate for game mode */\r
361 \r
362     int              ActionOnWindowClose; /* Action when user closes window  */\r
363 \r
364     fgExecutionState ExecState;           /* Used for GLUT termination       */\r
365     char            *ProgramName;         /* Name of the invoking program    */\r
366     GLboolean        JoysticksInitialised;  /* Only initialize if application calls for them */\r
367     int              NumActiveJoysticks;    /* Number of active joysticks -- if zero, don't poll joysticks */\r
368     GLboolean        InputDevsInitialised;  /* Only initialize if application calls for them */\r
369 \r
370         int              MouseWheelTicks;      /* Number of ticks the mouse wheel has turned */\r
371 \r
372     int              AuxiliaryBufferNumber;  /* Number of auxiliary buffers */\r
373     int              SampleNumber;         /*  Number of samples per pixel  */\r
374 \r
375     int              MajorVersion;         /* Major OpenGL context version  */\r
376     int              MinorVersion;         /* Minor OpenGL context version  */\r
377     int              ContextFlags;         /* OpenGL context flags          */\r
378     int              ContextProfile;       /* OpenGL context profile        */\r
379     FGError          ErrorFunc;            /* User defined error handler    */\r
380     FGWarning        WarningFunc;          /* User defined warning handler  */\r
381 };\r
382 \r
383 /* The structure used by display initialization in freeglut_init.c */\r
384 typedef struct tagSFG_Display SFG_Display;\r
385 struct tagSFG_Display\r
386 {\r
387         SFG_PlatformDisplay pDisplay;\r
388 \r
389     int             ScreenWidth;        /* The screen's width in pixels      */\r
390     int             ScreenHeight;       /* The screen's height in pixels     */\r
391     int             ScreenWidthMM;      /* The screen's width in milimeters  */\r
392     int             ScreenHeightMM;     /* The screen's height in milimeters */\r
393 };\r
394 \r
395 \r
396 /* The user can create any number of timer hooks */\r
397 typedef struct tagSFG_Timer SFG_Timer;\r
398 struct tagSFG_Timer\r
399 {\r
400     SFG_Node        Node;\r
401     int             ID;                 /* The timer ID integer              */\r
402     FGCBTimer       Callback;           /* The timer callback                */\r
403     long            TriggerTime;        /* The timer trigger time            */\r
404 };\r
405 \r
406 /*\r
407  * A window and its OpenGL context. The contents of this structure\r
408  * are highly dependant on the target operating system we aim at...\r
409  */\r
410 typedef struct tagSFG_Context SFG_Context;\r
411 struct tagSFG_Context\r
412 {\r
413     SFG_WindowHandleType  Handle;    /* The window's handle                 */\r
414     SFG_WindowContextType Context;   /* The window's OpenGL/WGL context     */\r
415 \r
416         SFG_PlatformContext pContext;    /* The window's FBConfig (X11) or device context (Windows) */\r
417 \r
418     int             DoubleBuffered;  /* Treat the window as double-buffered */\r
419 };\r
420 \r
421 /* Window's state description. This structure should be kept portable. */\r
422 #if TARGET_HOST_POSIX_X11\r
423 typedef struct tagSFG_PlatformWindowState SFG_PlatformWindowState;\r
424 struct tagSFG_PlatformWindowState\r
425 {\r
426     int             OldWidth;           /* Window width from before a resize */\r
427     int             OldHeight;          /*   "    height  "    "    "   "    */\r
428 };\r
429 #endif\r
430 \r
431 \r
432 typedef struct tagSFG_WindowState SFG_WindowState;\r
433 struct tagSFG_WindowState\r
434 {\r
435     /* Note that on Windows, sizes always refer to the client area, thus without the window decorations */\r
436     int             Width;              /* Window's width in pixels          */\r
437     int             Height;             /* The same about the height         */\r
438 \r
439         SFG_PlatformWindowState pWState;    /* Window width/height (X11) or rectangle/style (Windows) from before a resize */\r
440 \r
441     GLboolean       Redisplay;          /* Do we have to redisplay?          */\r
442     GLboolean       Visible;            /* Is the window visible now         */\r
443 \r
444     int             Cursor;             /* The currently selected cursor     */\r
445 \r
446     long            JoystickPollRate;   /* The joystick polling rate         */\r
447     long            JoystickLastPoll;   /* When the last poll happened       */\r
448 \r
449     int             MouseX, MouseY;     /* The most recent mouse position    */\r
450 \r
451     GLboolean       IgnoreKeyRepeat;    /* Whether to ignore key repeat.     */\r
452     GLboolean       KeyRepeating;       /* Currently in repeat mode          */\r
453 \r
454     GLboolean       NeedToResize;       /* Do we need to resize the window?  */\r
455 \r
456     GLboolean       IsFullscreen;       /* is the window fullscreen? */\r
457 };\r
458 \r
459 \r
460 /*\r
461  * A generic function pointer.  We should really use the GLUTproc type\r
462  * defined in freeglut_ext.h, but if we include that header in this file\r
463  * a bunch of other stuff (font-related) blows up!\r
464  */\r
465 typedef void (*SFG_Proc)();\r
466 \r
467 \r
468 /*\r
469  * SET_WCB() is used as:\r
470  *\r
471  *     SET_WCB( window, cbname, func );\r
472  *\r
473  * ...where {window} is the freeglut window to set the callback,\r
474  *          {cbname} is the window-specific callback to set,\r
475  *          {func} is a function-pointer.\r
476  *\r
477  * Originally, {FETCH_WCB( ... ) = func} was rather sloppily used,\r
478  * but this can cause warnings because the FETCH_WCB() macro type-\r
479  * casts its result, and a type-cast value shouldn't be an lvalue.\r
480  *\r
481  * The {if( FETCH_WCB( ... ) != func )} test is to do type-checking\r
482  * and for no other reason.  Since it's hidden in the macro, the\r
483  * ugliness is felt to be rather benign.\r
484  */\r
485 #define SET_WCB(window,cbname,func)                            \\r
486 do                                                             \\r
487 {                                                              \\r
488     if( FETCH_WCB( window, cbname ) != (SFG_Proc)(func) )      \\r
489         (((window).CallBacks[CB_ ## cbname]) = (SFG_Proc)(func)); \\r
490 } while( 0 )\r
491 \r
492 /*\r
493  * FETCH_WCB() is used as:\r
494  *\r
495  *     FETCH_WCB( window, cbname );\r
496  *\r
497  * ...where {window} is the freeglut window to fetch the callback from,\r
498  *          {cbname} is the window-specific callback to fetch.\r
499  *\r
500  * The result is correctly type-cast to the callback function pointer\r
501  * type.\r
502  */\r
503 #define FETCH_WCB(window,cbname) \\r
504     ((window).CallBacks[CB_ ## cbname])\r
505 \r
506 /*\r
507  * INVOKE_WCB() is used as:\r
508  *\r
509  *     INVOKE_WCB( window, cbname, ( arg_list ) );\r
510  *\r
511  * ...where {window} is the freeglut window,\r
512  *          {cbname} is the window-specific callback to be invoked,\r
513  *          {(arg_list)} is the parameter list.\r
514  *\r
515  * The callback is invoked as:\r
516  *\r
517  *    callback( arg_list );\r
518  *\r
519  * ...so the parentheses are REQUIRED in the {arg_list}.\r
520  *\r
521  * NOTE that it does a sanity-check and also sets the\r
522  * current window.\r
523  *\r
524  */\r
525 #if TARGET_HOST_MS_WINDOWS && !defined(_WIN32_WCE) /* FIXME: also WinCE? */\r
526 #define INVOKE_WCB(window,cbname,arg_list)    \\r
527 do                                            \\r
528 {                                             \\r
529     if( FETCH_WCB( window, cbname ) )         \\r
530     {                                         \\r
531         FGCB ## cbname func = (FGCB ## cbname)(FETCH_WCB( window, cbname )); \\r
532         fgSetWindow( &window );               \\r
533         func arg_list;                        \\r
534     }                                         \\r
535 } while( 0 )\r
536 #else\r
537 #define INVOKE_WCB(window,cbname,arg_list)    \\r
538 do                                            \\r
539 {                                             \\r
540     if( FETCH_WCB( window, cbname ) )         \\r
541     {                                         \\r
542         fgSetWindow( &window );               \\r
543         ((FGCB ## cbname)FETCH_WCB( window, cbname )) arg_list; \\r
544     }                                         \\r
545 } while( 0 )\r
546 #endif\r
547 \r
548 /*\r
549  * The window callbacks the user can supply us with. Should be kept portable.\r
550  *\r
551  * This enumeration provides the freeglut CallBack numbers.\r
552  * The symbolic constants are indices into a window's array of\r
553  * function callbacks.  The names are formed by splicing a common\r
554  * prefix onto the callback's base name.  (This was originally\r
555  * done so that an early stage of development could live side-by-\r
556  * side with the old callback code.  The old callback code used\r
557  * the bare callback's name as a structure member, so I used a\r
558  * prefix for the array index name.)\r
559  *\r
560  * XXX For consistancy, perhaps the prefix should match the\r
561  * XXX FETCH* and INVOKE* macro suffices.  I.e., WCB_, rather than\r
562  * XXX CB_.\r
563  */\r
564 enum\r
565 {\r
566     CB_Display,\r
567     CB_Reshape,\r
568     CB_Keyboard,\r
569     CB_KeyboardUp,\r
570     CB_Special,\r
571     CB_SpecialUp,\r
572     CB_Mouse,\r
573     CB_MouseWheel,\r
574     CB_Motion,\r
575     CB_Passive,\r
576     CB_Entry,\r
577     CB_Visibility,\r
578     CB_WindowStatus,\r
579     CB_Joystick,\r
580     CB_Destroy,\r
581 \r
582     /* MPX-related */\r
583     CB_MultiEntry,\r
584     CB_MultiButton,\r
585     CB_MultiMotion,\r
586     CB_MultiPassive,\r
587 \r
588     /* Presently ignored */\r
589     CB_Select,\r
590     CB_OverlayDisplay,\r
591     CB_SpaceMotion,     /* presently implemented only on UNIX/X11 */\r
592     CB_SpaceRotation,   /* presently implemented only on UNIX/X11 */\r
593     CB_SpaceButton,     /* presently implemented only on UNIX/X11 */\r
594     CB_Dials,\r
595     CB_ButtonBox,\r
596     CB_TabletMotion,\r
597     CB_TabletButton,\r
598 \r
599     /* Always make this the LAST one */\r
600     TOTAL_CALLBACKS\r
601 };\r
602 \r
603 \r
604 /* This structure holds the OpenGL rendering context for all the menu windows */\r
605 typedef struct tagSFG_MenuContext SFG_MenuContext;\r
606 struct tagSFG_MenuContext\r
607 {\r
608     SFG_WindowContextType MContext;       /* The menu window's WGL context   */\r
609 };\r
610 \r
611 /* This structure describes a menu */\r
612 typedef struct tagSFG_Window SFG_Window;\r
613 typedef struct tagSFG_MenuEntry SFG_MenuEntry;\r
614 typedef struct tagSFG_Menu SFG_Menu;\r
615 struct tagSFG_Menu\r
616 {\r
617     SFG_Node            Node;\r
618     void               *UserData;     /* User data passed back at callback   */\r
619     int                 ID;           /* The global menu ID                  */\r
620     SFG_List            Entries;      /* The menu entries list               */\r
621     FGCBMenu            Callback;     /* The menu callback                   */\r
622     FGCBDestroy         Destroy;      /* Destruction callback                */\r
623     GLboolean           IsActive;     /* Is the menu selected?               */\r
624     int                 Width;        /* Menu box width in pixels            */\r
625     int                 Height;       /* Menu box height in pixels           */\r
626     int                 X, Y;         /* Menu box raster position            */\r
627 \r
628     SFG_MenuEntry      *ActiveEntry;  /* Currently active entry in the menu  */\r
629     SFG_Window         *Window;       /* Window for menu                     */\r
630     SFG_Window         *ParentWindow; /* Window in which the menu is invoked */\r
631 };\r
632 \r
633 /* This is a menu entry */\r
634 struct tagSFG_MenuEntry\r
635 {\r
636     SFG_Node            Node;\r
637     int                 ID;                     /* The menu entry ID (local) */\r
638     int                 Ordinal;                /* The menu's ordinal number */\r
639     char*               Text;                   /* The text to be displayed  */\r
640     SFG_Menu*           SubMenu;                /* Optional sub-menu tree    */\r
641     GLboolean           IsActive;               /* Is the entry highlighted? */\r
642     int                 Width;                  /* Label's width in pixels   */\r
643 };\r
644 \r
645 /*\r
646  * A window, making part of freeglut windows hierarchy.\r
647  * Should be kept portable.\r
648  *\r
649  * NOTE that ActiveMenu is set to menu itself if the window is a menu.\r
650  */\r
651 struct tagSFG_Window\r
652 {\r
653     SFG_Node            Node;\r
654     int                 ID;                     /* Window's ID number        */\r
655 \r
656     SFG_Context         Window;                 /* Window and OpenGL context */\r
657     SFG_WindowState     State;                  /* The window state          */\r
658     SFG_Proc            CallBacks[ TOTAL_CALLBACKS ]; /* Array of window callbacks */\r
659     void               *UserData ;              /* For use by user           */\r
660 \r
661     SFG_Menu*       Menu[ FREEGLUT_MAX_MENUS ]; /* Menus appended to window  */\r
662     SFG_Menu*       ActiveMenu;                 /* The window's active menu  */\r
663 \r
664     SFG_Window*         Parent;                 /* The parent to this window */\r
665     SFG_List            Children;               /* The subwindows d.l. list  */\r
666 \r
667     GLboolean           IsMenu;                 /* Set to 1 if we are a menu */\r
668 };\r
669 \r
670 \r
671 /* A linked list structure of windows */\r
672 typedef struct tagSFG_WindowList SFG_WindowList ;\r
673 struct tagSFG_WindowList\r
674 {\r
675     SFG_Node node;\r
676     SFG_Window *window ;\r
677 };\r
678 \r
679 /* This holds information about all the windows, menus etc. */\r
680 typedef struct tagSFG_Structure SFG_Structure;\r
681 struct tagSFG_Structure\r
682 {\r
683     SFG_List        Windows;         /* The global windows list            */\r
684     SFG_List        Menus;           /* The global menus list              */\r
685     SFG_List        WindowsToDestroy;\r
686 \r
687     SFG_Window*     CurrentWindow;   /* The currently set window          */\r
688     SFG_Menu*       CurrentMenu;     /* Same, but menu...                 */\r
689 \r
690     SFG_MenuContext* MenuContext;    /* OpenGL rendering context for menus */\r
691 \r
692     SFG_Window*      GameModeWindow; /* The game mode window               */\r
693 \r
694     int              WindowID;       /* The new current window ID          */\r
695     int              MenuID;         /* The new current menu ID            */\r
696 };\r
697 \r
698 /*\r
699  * This structure is used for the enumeration purposes.\r
700  * You can easily extend its functionalities by declaring\r
701  * a structure containing enumerator's contents and custom\r
702  * data, then casting its pointer to (SFG_Enumerator *).\r
703  */\r
704 typedef struct tagSFG_Enumerator SFG_Enumerator;\r
705 struct tagSFG_Enumerator\r
706 {\r
707     GLboolean   found;                          /* Used to terminate search  */\r
708     void*       data;                           /* Custom data pointer       */\r
709 };\r
710 typedef void (* FGCBenumerator  )( SFG_Window *, SFG_Enumerator * );\r
711 \r
712 /* The bitmap font structure */\r
713 typedef struct tagSFG_Font SFG_Font;\r
714 struct tagSFG_Font\r
715 {\r
716     char*           Name;         /* The source font name             */\r
717     int             Quantity;     /* Number of chars in font          */\r
718     int             Height;       /* Height of the characters         */\r
719     const GLubyte** Characters;   /* The characters mapping           */\r
720 \r
721     float           xorig, yorig; /* Relative origin of the character */\r
722 };\r
723 \r
724 /* The stroke font structures */\r
725 \r
726 typedef struct tagSFG_StrokeVertex SFG_StrokeVertex;\r
727 struct tagSFG_StrokeVertex\r
728 {\r
729     GLfloat         X, Y;\r
730 };\r
731 \r
732 typedef struct tagSFG_StrokeStrip SFG_StrokeStrip;\r
733 struct tagSFG_StrokeStrip\r
734 {\r
735     int             Number;\r
736     const SFG_StrokeVertex* Vertices;\r
737 };\r
738 \r
739 typedef struct tagSFG_StrokeChar SFG_StrokeChar;\r
740 struct tagSFG_StrokeChar\r
741 {\r
742     GLfloat         Right;\r
743     int             Number;\r
744     const SFG_StrokeStrip* Strips;\r
745 };\r
746 \r
747 typedef struct tagSFG_StrokeFont SFG_StrokeFont;\r
748 struct tagSFG_StrokeFont\r
749 {\r
750     char*           Name;                       /* The source font name      */\r
751     int             Quantity;                   /* Number of chars in font   */\r
752     GLfloat         Height;                     /* Height of the characters  */\r
753     const SFG_StrokeChar** Characters;          /* The characters mapping    */\r
754 };\r
755 \r
756 \r
757 /* -- JOYSTICK-SPECIFIC STRUCTURES AND TYPES ------------------------------- */\r
758 /*\r
759  * Initial defines from "js.h" starting around line 33 with the existing "freeglut_joystick.c"\r
760  * interspersed\r
761  */\r
762 \r
763 #if TARGET_HOST_MACINTOSH\r
764 #    include <InputSprocket.h>\r
765 #endif\r
766 \r
767 #if TARGET_HOST_MAC_OSX\r
768 #    include <mach/mach.h>\r
769 #    include <IOKit/IOkitLib.h>\r
770 #    include <IOKit/hid/IOHIDLib.h>\r
771 #endif\r
772 \r
773 #if TARGET_HOST_POSIX_X11\r
774 #    ifdef HAVE_SYS_IOCTL_H\r
775 #        include <sys/ioctl.h>\r
776 #    endif\r
777 #    ifdef HAVE_FCNTL_H\r
778 #        include <fcntl.h>\r
779 #    endif\r
780 #    ifdef HAVE_ERRNO_H\r
781 #        include <errno.h>\r
782 #        include <string.h>\r
783 #    endif\r
784 #    if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)\r
785 /* XXX The below hack is done until freeglut's autoconf is updated. */\r
786 #        define HAVE_USB_JS    1\r
787 \r
788 #        if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)\r
789 #            include <sys/joystick.h>\r
790 #        else\r
791 /*\r
792  * XXX NetBSD/amd64 systems may find that they have to steal the\r
793  * XXX /usr/include/machine/joystick.h from a NetBSD/i386 system.\r
794  * XXX I cannot comment whether that works for the interface, but\r
795  * XXX it lets you compile...(^&  I do not think that we can do away\r
796  * XXX with this header.\r
797  */\r
798 #            include <machine/joystick.h>         /* For analog joysticks */\r
799 #        endif\r
800 #        define JS_DATA_TYPE joystick\r
801 #        define JS_RETURN (sizeof(struct JS_DATA_TYPE))\r
802 #    endif\r
803 \r
804 #    if defined(__linux__)\r
805 #        include <linux/joystick.h>\r
806 \r
807 /* check the joystick driver version */\r
808 #        if defined(JS_VERSION) && JS_VERSION >= 0x010000\r
809 #            define JS_NEW\r
810 #        endif\r
811 #    else  /* Not BSD or Linux */\r
812 #        ifndef JS_RETURN\r
813 \r
814   /*\r
815    * We'll put these values in and that should\r
816    * allow the code to at least compile when there is\r
817    * no support. The JS open routine should error out\r
818    * and shut off all the code downstream anyway and if\r
819    * the application doesn't use a joystick we'll be fine.\r
820    */\r
821 \r
822   struct JS_DATA_TYPE\r
823   {\r
824     int buttons;\r
825     int x;\r
826     int y;\r
827   };\r
828 \r
829 #            define JS_RETURN (sizeof(struct JS_DATA_TYPE))\r
830 #        endif\r
831 #    endif\r
832 #endif\r
833 \r
834 /* XXX It might be better to poll the operating system for the numbers of buttons and\r
835  * XXX axes and then dynamically allocate the arrays.\r
836  */\r
837 #define _JS_MAX_BUTTONS 32\r
838 \r
839 #if TARGET_HOST_MACINTOSH\r
840 #    define _JS_MAX_AXES  9\r
841 typedef struct tagSFG_PlatformJoystick SFG_PlatformJoystick;\r
842 struct tagSFG_PlatformJoystick\r
843 {\r
844 #define  ISP_NUM_AXIS    9\r
845 #define  ISP_NUM_NEEDS  41\r
846     ISpElementReference isp_elem  [ ISP_NUM_NEEDS ];\r
847     ISpNeed             isp_needs [ ISP_NUM_NEEDS ];\r
848 };\r
849 #endif\r
850 \r
851 #if TARGET_HOST_MAC_OSX\r
852 #    define _JS_MAX_AXES 16\r
853 typedef struct tagSFG_PlatformJoystick SFG_PlatformJoystick;\r
854 struct tagSFG_PlatformJoystick\r
855 {\r
856     IOHIDDeviceInterface ** hidDev;\r
857     IOHIDElementCookie buttonCookies[41];\r
858     IOHIDElementCookie axisCookies[_JS_MAX_AXES];\r
859 /* The next two variables are not used anywhere */\r
860 /*    long minReport[_JS_MAX_AXES],\r
861  *         maxReport[_JS_MAX_AXES];\r
862  */\r
863 };\r
864 #endif\r
865 \r
866 #if TARGET_HOST_POSIX_X11\r
867 #    define _JS_MAX_AXES 16\r
868 typedef struct tagSFG_PlatformJoystick SFG_PlatformJoystick;\r
869 struct tagSFG_PlatformJoystick\r
870 {\r
871 #   if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)\r
872        struct os_specific_s *os;\r
873 #   endif\r
874 \r
875 #   ifdef JS_NEW\r
876        struct js_event     js;\r
877        int          tmp_buttons;\r
878        float        tmp_axes [ _JS_MAX_AXES ];\r
879 #   else\r
880        struct JS_DATA_TYPE js;\r
881 #   endif\r
882 \r
883     char         fname [ 128 ];\r
884     int          fd;\r
885 };\r
886 #endif\r
887 \r
888 /*\r
889  * Definition of "SFG_Joystick" structure -- based on JS's "jsJoystick" object class.\r
890  * See "js.h" lines 80-178.\r
891  */\r
892 typedef struct tagSFG_Joystick SFG_Joystick;\r
893 struct tagSFG_Joystick\r
894 {\r
895         SFG_PlatformJoystick pJoystick;\r
896 \r
897     int          id;\r
898     GLboolean    error;\r
899     char         name [ 128 ];\r
900     int          num_axes;\r
901     int          num_buttons;\r
902 \r
903     float dead_band[ _JS_MAX_AXES ];\r
904     float saturate [ _JS_MAX_AXES ];\r
905     float center   [ _JS_MAX_AXES ];\r
906     float max      [ _JS_MAX_AXES ];\r
907     float min      [ _JS_MAX_AXES ];\r
908 };\r
909 \r
910 \r
911 \r
912 /* -- GLOBAL VARIABLES EXPORTS --------------------------------------------- */\r
913 \r
914 /* Freeglut display related stuff (initialized once per session) */\r
915 extern SFG_Display fgDisplay;\r
916 \r
917 /* Freeglut internal structure */\r
918 extern SFG_Structure fgStructure;\r
919 \r
920 /* The current freeglut settings */\r
921 extern SFG_State fgState;\r
922 \r
923 \r
924 /* -- PRIVATE FUNCTION DECLARATIONS ---------------------------------------- */\r
925 \r
926 /*\r
927  * A call to this function makes us sure that the Display and Structure\r
928  * subsystems have been properly initialized and are ready to be used\r
929  */\r
930 #define  FREEGLUT_EXIT_IF_NOT_INITIALISED( string )               \\r
931   if ( ! fgState.Initialised )                                    \\r
932   {                                                               \\r
933     fgError ( " ERROR:  Function <%s> called"                     \\r
934               " without first calling 'glutInit'.", (string) ) ;  \\r
935   }\r
936 \r
937 #define  FREEGLUT_INTERNAL_ERROR_EXIT_IF_NOT_INITIALISED( string )  \\r
938   if ( ! fgState.Initialised )                                      \\r
939   {                                                                 \\r
940     fgError ( " ERROR:  Internal <%s> function called"              \\r
941               " without first calling 'glutInit'.", (string) ) ;    \\r
942   }\r
943 \r
944 #define  FREEGLUT_INTERNAL_ERROR_EXIT( cond, string, function )  \\r
945   if ( ! ( cond ) )                                              \\r
946   {                                                              \\r
947     fgError ( " ERROR:  Internal error <%s> in function %s",     \\r
948               (string), (function) ) ;                           \\r
949   }\r
950 \r
951 /*\r
952  * Following definitions are somewhat similiar to GLib's,\r
953  * but do not generate any log messages:\r
954  */\r
955 #define  freeglut_return_if_fail( expr ) \\r
956     if( !(expr) )                        \\r
957         return;\r
958 #define  freeglut_return_val_if_fail( expr, val ) \\r
959     if( !(expr) )                                 \\r
960         return val ;\r
961 \r
962 /*\r
963  * A call to those macros assures us that there is a current\r
964  * window set, respectively:\r
965  */\r
966 #define  FREEGLUT_EXIT_IF_NO_WINDOW( string )                               \\r
967   if ( ! fgStructure.CurrentWindow &&                                       \\r
968        ( fgState.ActionOnWindowClose != GLUT_ACTION_CONTINUE_EXECUTION ) )  \\r
969   {                                                                         \\r
970     fgError ( " ERROR:  Function <%s> called"                               \\r
971               " with no current window defined.", (string) ) ;              \\r
972   }\r
973 \r
974 /*\r
975  * The deinitialize function gets called on glutMainLoop() end. It should clean up\r
976  * everything inside of the freeglut\r
977  */\r
978 void fgDeinitialize( void );\r
979 \r
980 /*\r
981  * Those two functions are used to create/destroy the freeglut internal\r
982  * structures. This actually happens when calling glutInit() and when\r
983  * quitting the glutMainLoop() (which actually happens, when all windows\r
984  * have been closed).\r
985  */\r
986 void fgCreateStructure( void );\r
987 void fgDestroyStructure( void );\r
988 \r
989 /*\r
990  * Window creation, opening, closing and destruction.\r
991  * Also CallBack clearing/initialization.\r
992  * Defined in freeglut_structure.c, freeglut_window.c.\r
993  */\r
994 SFG_Window* fgCreateWindow( SFG_Window* parent, const char* title,\r
995                             GLboolean positionUse, int x, int y,\r
996                             GLboolean sizeUse, int w, int h,\r
997                             GLboolean gameMode, GLboolean isMenu );\r
998 void        fgSetWindow ( SFG_Window *window );\r
999 void        fgOpenWindow( SFG_Window* window, const char* title,\r
1000                           GLboolean positionUse, int x, int y,\r
1001                           GLboolean sizeUse, int w, int h,\r
1002                           GLboolean gameMode, GLboolean isSubWindow );\r
1003 void        fgCloseWindow( SFG_Window* window );\r
1004 void        fgAddToWindowDestroyList ( SFG_Window* window );\r
1005 void        fgCloseWindows ();\r
1006 void        fgDestroyWindow( SFG_Window* window );\r
1007 \r
1008 /* Menu creation and destruction. Defined in freeglut_structure.c */\r
1009 SFG_Menu*   fgCreateMenu( FGCBMenu menuCallback );\r
1010 void        fgDestroyMenu( SFG_Menu* menu );\r
1011 \r
1012 /* Joystick device management functions, defined in freeglut_joystick.c */\r
1013 int         fgJoystickDetect( void );\r
1014 void        fgInitialiseJoysticks( void );\r
1015 void        fgJoystickClose( void );\r
1016 void        fgJoystickPollWindow( SFG_Window* window );\r
1017 \r
1018 /* InputDevice Initialisation and Closure */\r
1019 int         fgInputDeviceDetect( void );\r
1020 void        fgInitialiseInputDevices( void );\r
1021 void        fgInputDeviceClose( void );\r
1022 \r
1023 /* spaceball device functions, defined in freeglut_spaceball.c */\r
1024 void        fgInitialiseSpaceball( void );\r
1025 void        fgSpaceballClose( void );\r
1026 void        fgSpaceballSetWindow( SFG_Window *window );\r
1027 \r
1028 int         fgHasSpaceball( void );\r
1029 int         fgSpaceballNumButtons( void );\r
1030 \r
1031 #if TARGET_HOST_POSIX_X11\r
1032 int         fgIsSpaceballXEvent( const XEvent *ev );\r
1033 void        fgSpaceballHandleXEvent( const XEvent *ev );\r
1034 #endif\r
1035 \r
1036 /* Setting the cursor for a given window */\r
1037 void fgSetCursor ( SFG_Window *window, int cursorID );\r
1038 \r
1039 /*\r
1040  * Helper function to enumerate through all registered windows\r
1041  * and one to enumerate all of a window's subwindows...\r
1042  *\r
1043  * The GFunc callback for those functions will be defined as:\r
1044  *\r
1045  *      void enumCallback( gpointer window, gpointer enumerator );\r
1046  *\r
1047  * where window is the enumerated (sub)window pointer (SFG_Window *),\r
1048  * and userData is the a custom user-supplied pointer. Functions\r
1049  * are defined and exported from freeglut_structure.c file.\r
1050  */\r
1051 void fgEnumWindows( FGCBenumerator enumCallback, SFG_Enumerator* enumerator );\r
1052 void fgEnumSubWindows( SFG_Window* window, FGCBenumerator enumCallback,\r
1053                        SFG_Enumerator* enumerator );\r
1054 \r
1055 /*\r
1056  * fgWindowByHandle returns a (SFG_Window *) value pointing to the\r
1057  * first window in the queue matching the specified window handle.\r
1058  * The function is defined in freeglut_structure.c file.\r
1059  */\r
1060 SFG_Window* fgWindowByHandle( SFG_WindowHandleType hWindow );\r
1061 \r
1062 /*\r
1063  * This function is similiar to the previous one, except it is\r
1064  * looking for a specified (sub)window identifier. The function\r
1065  * is defined in freeglut_structure.c file.\r
1066  */\r
1067 SFG_Window* fgWindowByID( int windowID );\r
1068 \r
1069 /*\r
1070  * Looks up a menu given its ID. This is easier than fgWindowByXXX\r
1071  * as all menus are placed in a single doubly linked list...\r
1072  */\r
1073 SFG_Menu* fgMenuByID( int menuID );\r
1074 \r
1075 /*\r
1076  * The menu activation and deactivation the code. This is the meat\r
1077  * of the menu user interface handling code...\r
1078  */\r
1079 void fgUpdateMenuHighlight ( SFG_Menu *menu );\r
1080 GLboolean fgCheckActiveMenu ( SFG_Window *window, int button, GLboolean pressed,\r
1081                               int mouse_x, int mouse_y );\r
1082 void fgDeactivateMenu( SFG_Window *window );\r
1083 \r
1084 /*\r
1085  * This function gets called just before the buffers swap, so that\r
1086  * freeglut can display the pull-down menus via OpenGL. The function\r
1087  * is defined in freeglut_menu.c file.\r
1088  */\r
1089 void fgDisplayMenu( void );\r
1090 \r
1091 /* Elapsed time as per glutGet(GLUT_ELAPSED_TIME). */\r
1092 long fgElapsedTime( void );\r
1093 \r
1094 /* System time in milliseconds */\r
1095 long unsigned fgSystemTime(void);\r
1096 \r
1097 /* List functions */\r
1098 void fgListInit(SFG_List *list);\r
1099 void fgListAppend(SFG_List *list, SFG_Node *node);\r
1100 void fgListRemove(SFG_List *list, SFG_Node *node);\r
1101 int fgListLength(SFG_List *list);\r
1102 void fgListInsert(SFG_List *list, SFG_Node *next, SFG_Node *node);\r
1103 \r
1104 /* Error Message functions */\r
1105 void fgError( const char *fmt, ... );\r
1106 void fgWarning( const char *fmt, ... );\r
1107 \r
1108 /*\r
1109  * Check if "hint" is present in "property" for "window".  See freeglut_init.c\r
1110  */\r
1111 #if TARGET_HOST_POSIX_X11\r
1112 int fgHintPresent(Window window, Atom property, Atom hint);\r
1113 \r
1114 /* Handler for X extension Events */\r
1115 #ifdef HAVE_X11_EXTENSIONS_XINPUT2_H\r
1116   void fgHandleExtensionEvents( XEvent * ev );\r
1117   void fgRegisterDevices( Display* dpy, Window* win );\r
1118 #endif\r
1119 \r
1120 #endif\r
1121 \r
1122 SFG_Proc fgPlatformGetProcAddress( const char *procName );\r
1123 \r
1124 /* Window functions needed for Platform implementations */\r
1125 /* pushing attribute/value pairs into an array */\r
1126 #define ATTRIB(a) attributes[where++]=(a)\r
1127 #define ATTRIB_VAL(a,v) {ATTRIB(a); ATTRIB(v);}\r
1128 \r
1129 extern int fghIsLegacyContextVersionRequested( void );\r
1130 extern int fghMapBit( int mask, int from, int to );\r
1131 extern int fghIsLegacyContextRequested( void );\r
1132 extern void fghContextCreationError( void );\r
1133 extern int fghNumberOfAuxBuffersRequested( void );\r
1134 \r
1135 #endif /* FREEGLUT_INTERNAL_H */\r
1136 \r
1137 /*** END OF FILE ***/\r