Putting stuff back that was undone with the menu code committed.
[freeglut] / src / freeglut_internal.h
1 /*
2  * freeglut_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 /* XXX Update these for each release! */
32 #define  VERSION_MAJOR 2
33 #define  VERSION_MINOR 0
34 #define  VERSION_PATCH 0 
35
36 /*
37  * Freeglut is meant to be available under all Unix/X11 and Win32 platforms.
38  */
39 #if !defined(_WIN32)
40 #   define  TARGET_HOST_UNIX_X11    1
41 #   define  TARGET_HOST_WIN32       0
42 #else
43 #   define  TARGET_HOST_UNIX_X11    0
44 #   define  TARGET_HOST_WIN32       1
45 #endif
46
47 #define  FREEGLUT_MAX_MENUS         3
48 #define  FREEGLUT_DEBUG             1
49
50 #if FREEGLUT_DEBUG
51     #undef   G_DISABLE_ASSERT
52     #undef   G_DISABLE_CHECKS
53 #else
54     #define  G_DISABLE_ASSERT
55     #define  G_DISABLE_CHECKS
56 #endif
57
58 /*
59  * Somehow all Win32 include headers depend on this one:
60  */
61 #if TARGET_HOST_WIN32
62 #include <windows.h>
63 #include <windowsx.h>
64
65 #define strdup   _strdup
66 #endif
67
68 /*
69  * Those files should be available on every platform.
70  */
71 #include <GL/gl.h>
72 #include <GL/glu.h>
73 #include <stdio.h>
74 #include <string.h>
75 #include <math.h>
76 #include <stdlib.h>
77 #include <assert.h>
78 #include <stdarg.h>
79 #if TARGET_HOST_UNIX_X11
80 #include <sys/time.h>
81 #endif
82
83 /*
84  * The system-dependant include files should go here:
85  */
86 #if TARGET_HOST_UNIX_X11
87     #include <GL/glx.h>
88     #include <X11/Xlib.h>
89     #include <X11/Xatom.h>
90     #include <X11/keysym.h>
91
92     #if HAVE_X11_EXTENSIONS_XF86VMODE_H
93     #include <X11/extensions/xf86vmode.h>
94     #endif
95 #endif
96
97 /*
98  * Microsoft VisualC++ 5.0's <math.h> does not define the PI
99  */
100 #ifndef M_PI
101 #    define  M_PI  3.14159265358979323846
102 #endif
103
104 #ifndef TRUE
105 #    define  TRUE  1
106 #endif
107
108 #ifndef FALSE
109 #    define  FALSE  0
110 #endif
111
112 /* -- GLOBAL TYPE DEFINITIONS ---------------------------------------------- */
113
114 /*
115  * Freeglut callbacks type definitions
116  */
117 typedef void (* FGCBdisplay       )( void );
118 typedef void (* FGCBreshape       )( int, int );
119 typedef void (* FGCBvisibility    )( int );
120 typedef void (* FGCBkeyboard      )( unsigned char, int, int );
121 typedef void (* FGCBspecial       )( int, int, int );
122 typedef void (* FGCBmouse         )( int, int, int, int );
123 typedef void (* FGCBmotion        )( int, int );
124 typedef void (* FGCBpassive       )( int, int );
125 typedef void (* FGCBentry         )( int );
126 typedef void (* FGCBwindowStatus  )( int );
127 typedef void (* FGCBselect        )( int, int, int );
128 typedef void (* FGCBjoystick      )( unsigned int, int, int, int );
129 typedef void (* FGCBkeyboardUp    )( unsigned char, int, int );
130 typedef void (* FGCBspecialUp     )( int, int, int );
131 typedef void (* FGCBoverlayDisplay)( void );
132 typedef void (* FGCBspaceMotion   )( int, int, int );
133 typedef void (* FGCBspaceRotate   )( int, int, int );
134 typedef void (* FGCBspaceButton   )( int, int );
135 typedef void (* FGCBdials         )( int, int );
136 typedef void (* FGCBbuttonBox     )( int, int );
137 typedef void (* FGCBtabletMotion  )( int, int );
138 typedef void (* FGCBtabletButton  )( int, int, int, int );
139 typedef void (* FGCBdestroy       )( void );
140
141 /*
142  * The global callbacks type definitions
143  */
144 typedef void (* FGCBidle          )( void );
145 typedef void (* FGCBtimer         )( int );
146 typedef void (* FGCBmenuState     )( int );
147 typedef void (* FGCBmenuStatus    )( int, int, int );
148
149 /*
150  * The callback used when creating/using menus
151  */
152 typedef void (* FGCBmenu          )( int );
153
154
155 /*
156  * A list structure
157  */
158 typedef struct tagSFG_List SFG_List;
159 struct tagSFG_List
160 {
161     void *First;
162     void *Last;
163 };
164
165 /*
166  * A list node structure
167  */
168 typedef struct tagSFG_Node SFG_Node;
169 struct tagSFG_Node
170 {
171     void *Next;
172     void *Prev;
173 };
174
175 /*
176  * A helper structure holding two ints and a boolean
177  */
178 typedef struct tagSFG_XYUse SFG_XYUse;
179 struct tagSFG_XYUse
180 {
181     GLint           X, Y;               /* The two integers...               */
182     GLboolean       Use;                /* ...and a single boolean.          */
183 };
184
185 /*
186  * A helper structure holding a timeval and a boolean
187  */
188 typedef struct tagSFG_Time SFG_Time;
189 struct tagSFG_Time
190 {
191 #ifdef WIN32
192     DWORD Value;
193 #else
194     struct timeval  Value;
195 #endif
196     GLboolean       Set;
197 };
198
199 /*
200  * An enumeration containing the state of the GLUT execution:  initializing, running, or stopping
201  */
202 typedef enum {
203   GLUT_EXEC_STATE_INIT,
204   GLUT_EXEC_STATE_RUNNING,
205   GLUT_EXEC_STATE_STOP
206 } fgExecutionState ;
207
208 /*
209  * This structure holds different freeglut settings
210  */
211 typedef struct tagSFG_State SFG_State;
212 struct tagSFG_State
213 {
214     SFG_XYUse        Position;             /* The default windows' position     */
215     SFG_XYUse        Size;                 /* The default windows' size         */
216     unsigned int     DisplayMode;          /* The display mode for new windows  */
217
218     GLboolean        ForceDirectContext;   /* Should we force direct contexts?  */
219     GLboolean        TryDirectContext;     /* What about giving a try to?       */
220
221     GLboolean        ForceIconic;          /* All new top windows are iconified */
222     GLboolean        UseCurrentContext;    /* New windows use current window's rendering context */
223
224     GLboolean        GLDebugSwitch;        /* OpenGL state debugging switch     */
225     GLboolean        XSyncSwitch;          /* X11 sync protocol switch          */
226
227     GLboolean        IgnoreKeyRepeat;      /* Whether to ignore key repeat...   */
228
229     GLuint           FPSInterval;          /* Interval between FPS printfs      */
230     GLuint           SwapCount;            /* Count of glutSwapBuffer calls     */
231     GLuint           SwapTime;             /* Time of last SwapBuffers          */
232
233     SFG_Time         Time;                 /* The time that glutInit was called */
234     SFG_List         Timers;               /* The freeglut timer hooks          */
235
236     FGCBidle         IdleCallback;         /* The global idle callback          */
237
238     GLboolean        BuildingAMenu;        /* True if we are presently making a menu */
239     FGCBmenuState    MenuStateCallback;    /* Menu callbacks are global         */
240     FGCBmenuStatus   MenuStatusCallback;
241
242     SFG_XYUse        GameModeSize;         /* The game mode screen's dimensions */
243     int              GameModeDepth;        /* The pixel depth for game mode     */
244     int              GameModeRefresh;      /* The refresh rate for game mode    */
245
246     int              ActionOnWindowClose ; /* Action when user clicks "x" on window header bar */
247
248     fgExecutionState ExecState ;           /* Current state of the GLUT execution */
249 };
250
251 /*
252  * The structure used by display initialization in freeglut_init.c
253  */
254 typedef struct tagSFG_Display SFG_Display;
255 struct tagSFG_Display
256 {
257 #if TARGET_HOST_UNIX_X11
258     Display*        Display;            /* The display we are being run in.  */
259     int             Screen;             /* The screen we are about to use.   */
260     Window          RootWindow;         /* The screen's root window.         */
261     int             Connection;         /* The display's connection number   */
262     Atom            DeleteWindow;       /* The window deletion atom          */
263
264 #ifdef X_XF86VidModeGetModeLine
265     /*
266      * XF86VidMode may be compilable even if it fails at runtime.  Therefore,
267      * the validity of the VidMode has to be tracked
268      */
269     int             DisplayModeValid;   /* Flag that indicates runtime status*/
270     XF86VidModeModeLine DisplayMode;    /* Current screen's display settings */
271     int             DisplayModeClock;   /* The display mode's refresh rate   */
272 #endif
273
274 #elif TARGET_HOST_WIN32
275     HINSTANCE        Instance;          /* The application's instance        */
276     DEVMODE         DisplayMode;        /* Desktop's display settings        */
277
278 #endif
279
280     int             ScreenWidth;        /* The screen's width in pixels      */
281     int             ScreenHeight;       /* The screen's height in pixels     */
282     int             ScreenWidthMM;      /* The screen's width in milimeters  */
283     int             ScreenHeightMM;     /* The screen's height in milimeters */
284 };
285
286
287 /*
288  * The user can create any number of timer hooks
289  */
290 typedef struct tagSFG_Timer SFG_Timer;
291 struct tagSFG_Timer
292 {
293     SFG_Node        Node;
294     int             ID;                 /* The timer ID integer              */
295     FGCBtimer       Callback;           /* The timer callback                */
296     long            TriggerTime;        /* The timer trigger time            */
297 };
298
299 /*
300  * A window and its OpenGL context. The contents of this structure
301  * are highly dependant on the target operating system we aim at...
302  */
303 typedef struct tagSFG_Context SFG_Context;
304 struct tagSFG_Context
305 {
306 #if TARGET_HOST_UNIX_X11
307     Window          Handle;             /* The window's handle                 */
308     GLXContext      Context;            /* The OpenGL context                  */
309     XVisualInfo*    VisualInfo;         /* The window's visual information     */
310
311 #elif TARGET_HOST_WIN32
312     HWND            Handle;             /* The window's handle                 */
313     HDC             Device;             /* The window's device context         */
314     HGLRC           Context;            /* The window's WGL context            */
315
316 #endif
317
318     int             DoubleBuffered;     /* Treat the window as double-buffered */
319 };
320
321 /*
322  * Window's state description. This structure should be kept portable.
323  */
324 typedef struct tagSFG_WindowState SFG_WindowState;
325 struct tagSFG_WindowState
326 {
327     int             Width;              /* Window's width in pixels          */
328     int             Height;             /* The same about the height         */
329
330     GLboolean       Redisplay;          /* Do we have to redisplay?          */
331     GLboolean       Visible;            /* Is the window visible now         */
332
333     int             Cursor;             /* The currently selected cursor     */
334     int             Modifiers;          /* The current ALT/SHIFT/CTRL state  */
335
336     long            JoystickPollRate;   /* The joystick polling rate         */
337     long            JoystickLastPoll;   /* When the last poll has happened   */
338
339     int             MouseX, MouseY;     /* The most recent mouse position    */
340
341     GLboolean       IsGameMode;         /* Is this the game mode window?     */
342
343 #if TARGET_HOST_WIN32
344     GLboolean       NeedToResize;       /* Do we need to explicitly resize?  */
345 #endif
346 };
347
348 /*
349  * The window callbacks the user can supply us with. Should be kept portable.
350  */
351 typedef struct tagSFG_WindowCallbacks SFG_WindowCallbacks;
352 struct tagSFG_WindowCallbacks
353 {
354     /*
355      * Following callbacks are fully supported right now
356      * and are ready to be tested for GLUT conformance:
357      */
358     FGCBdisplay         Display;
359     FGCBreshape         Reshape;
360     FGCBkeyboard        Keyboard;
361     FGCBkeyboardUp      KeyboardUp;
362     FGCBspecial         Special;
363     FGCBspecialUp       SpecialUp;
364     FGCBmouse           Mouse;
365     FGCBmotion          Motion;
366     FGCBpassive         Passive;
367     FGCBentry           Entry;
368     FGCBvisibility      Visibility;
369     FGCBwindowStatus    WindowStatus;
370     FGCBjoystick        Joystick;
371     FGCBdestroy         Destroy;
372
373     /*
374      * Those callbacks are being ignored for the moment
375      */
376     FGCBselect          Select;
377     FGCBoverlayDisplay  OverlayDisplay;
378     FGCBspaceMotion     SpaceMotion;
379     FGCBspaceRotate     SpaceRotation;
380     FGCBspaceButton     SpaceButton;
381     FGCBdials           Dials;
382     FGCBbuttonBox       ButtonBox;
383     FGCBtabletMotion    TabletMotion;
384     FGCBtabletButton    TabletButton;
385 };
386
387 /*
388  * This structure holds the OpenGL rendering context for all the menu windows
389  */
390 typedef struct tagSFG_MenuContext SFG_MenuContext;
391 struct tagSFG_MenuContext
392 {
393 #if TARGET_HOST_UNIX_X11
394     GLXContext          Context;                /* The menu OpenGL context   */
395     XVisualInfo*        VisualInfo;             /* The window's visual information */
396 #elif TARGET_HOST_WIN32
397     HGLRC               Context;                /* The menu window's WGL context    */
398 #endif
399
400 };
401
402 /*
403  * This structure describes a menu
404  */
405 typedef struct tagSFG_Window SFG_Window;
406 typedef struct tagSFG_MenuEntry SFG_MenuEntry;
407 typedef struct tagSFG_Menu SFG_Menu;
408 struct tagSFG_Menu
409 {
410     SFG_Node            Node;
411     void               *UserData ;              /* A. Donev:  User data passed back at callback */
412     int                 ID;                     /* The global menu ID        */
413     SFG_List            Entries;                /* The menu entries list     */
414     FGCBmenu            Callback;               /* The menu callback         */
415     FGCBdestroy         Destroy;                /* A. Donev:  Destruction callback         */
416     GLboolean           IsActive;               /* Is the menu selected?     */
417     int                 Width;                  /* Menu box width in pixels  */
418     int                 Height;                 /* Menu box height in pixels */
419     int                 X, Y;                   /* Menu box raster position  */
420
421     SFG_MenuEntry      *ActiveEntry ;           /* Currently active entry in the menu */
422     SFG_Window         *Window ;                /* OpenGL window for menu    */
423     SFG_Window         *ParentWindow ;          /* OpenGL window in which the menu is defined */
424 };
425
426 /*
427  * This is a menu entry
428  */
429 struct tagSFG_MenuEntry
430 {
431     SFG_Node            Node;
432     int                 ID;                     /* The menu entry ID (local) */
433     int                 Ordinal;                /* The menu's ordinal number */
434     char*               Text;                   /* The text to be displayed  */
435     SFG_Menu*           SubMenu;                /* Optional sub-menu tree    */
436     GLboolean           IsActive;               /* Is the entry highlighted? */
437     int                 Width;                  /* Label's width in pixels   */
438 };
439
440 /*
441  * A window, making part of freeglut windows hierarchy. Should be kept portable.
442  */
443 struct tagSFG_Window
444 {
445     SFG_Node            Node;
446     int                 ID;                     /* Window's ID number        */
447
448     SFG_Context         Window;                 /* Window and OpenGL context */
449     SFG_WindowState     State;                  /* The window state          */
450     SFG_WindowCallbacks Callbacks;              /* The window callbacks      */
451     void               *UserData ;              /* A. Donev:  A pointer to user data used in rendering */
452
453     SFG_Menu*       Menu[ FREEGLUT_MAX_MENUS ]; /* Menus appended to window  */
454     SFG_Menu*       ActiveMenu;                 /* The window's active menu  */
455
456     SFG_Window*         Parent;                 /* The parent to this window */
457     SFG_List            Children;               /* The subwindows d.l. list  */
458
459     GLboolean           IsMenu;                 /* Set to 1 if we are a menu */
460 };
461
462 /*
463  * A linked list structure of windows
464  */
465 typedef struct tagSFG_WindowList SFG_WindowList ;
466 struct tagSFG_WindowList
467 {
468   SFG_Window *window ;
469   GLboolean needToClose ;
470   SFG_WindowList *next ;
471 } ;
472
473 /*
474  * This holds information about all the windows, menus etc.
475  */
476 typedef struct tagSFG_Structure SFG_Structure;
477 struct tagSFG_Structure
478 {
479     SFG_List            Windows;                /* The global windows list   */
480     SFG_List            Menus;                  /* The global menus list     */
481
482     SFG_Window*         Window;                 /* The currently active win. */
483     SFG_Menu*           Menu;                   /* Same, but menu...         */
484
485     SFG_MenuContext*    MenuContext;            /* OpenGL rendering context for menus */
486
487     SFG_Window*         GameMode;               /* The game mode window      */
488
489     int                 WindowID;               /* The new current window ID */
490     int                 MenuID;                 /* The new current menu ID   */
491 };
492
493 /*
494  * This structure is used for the enumeration purposes.
495  * You can easily extend its functionalities by declaring
496  * a structure containing enumerator's contents and custom
497  * data, then casting its pointer to (SFG_Enumerator *).
498  */
499 typedef struct tagSFG_Enumerator SFG_Enumerator;
500 struct tagSFG_Enumerator
501 {
502     GLboolean   found;                          /* Used to terminate search  */
503     void*       data;                           /* Custom data pointer       */
504 };
505 typedef void (* FGCBenumerator  )( SFG_Window *, SFG_Enumerator * );
506
507 /*
508  * The bitmap font structure
509  */
510 typedef struct tagSFG_Font SFG_Font;
511 struct tagSFG_Font
512 {
513     char*           Name;                       /* The source font name      */
514     int             Quantity;                   /* Number of chars in font   */
515     int             Height;                     /* Height of the characters  */
516     const GLubyte** Characters;                 /* The characters mapping    */
517
518     float           xorig, yorig ;              /* The origin of the character relative to the draw location */
519 };
520
521 /*
522  * The stroke font structures
523  */
524
525 typedef struct tagSFG_StrokeVertex SFG_StrokeVertex;
526 struct tagSFG_StrokeVertex
527 {
528     GLfloat         X, Y;
529 };
530
531 typedef struct tagSFG_StrokeStrip SFG_StrokeStrip;
532 struct tagSFG_StrokeStrip
533 {
534     int             Number;
535     const SFG_StrokeVertex* Vertices;
536 };
537
538 typedef struct tagSFG_StrokeChar SFG_StrokeChar;
539 struct tagSFG_StrokeChar
540 {
541     GLfloat         Right;
542     int             Number;
543     const SFG_StrokeStrip* Strips;
544 };
545
546 typedef struct tagSFG_StrokeFont SFG_StrokeFont;
547 struct tagSFG_StrokeFont
548 {
549     char*           Name;                       /* The source font name      */
550     int             Quantity;                   /* Number of chars in font   */
551     GLfloat         Height;                     /* Height of the characters  */
552     const SFG_StrokeChar** Characters;          /* The characters mapping    */
553 };
554
555 /* -- GLOBAL VARIABLES EXPORTS --------------------------------------------- */
556
557 /*
558  * Freeglut display related stuff (initialized once per session)
559  */
560 extern SFG_Display fgDisplay;
561
562 /*
563  * Freeglut internal structure
564  */
565 extern SFG_Structure fgStructure;
566
567 /*
568  * The current freeglut settings
569  */
570 extern SFG_State fgState;
571
572
573 /* -- PRIVATE FUNCTION DECLARATIONS ---------------------------------------- */
574
575 /*
576  * A call to this function makes us sure that the Display and Structure
577  * subsystems have been properly initialized and are ready to be used
578  */
579 #define  freeglut_assert_ready                      assert( fgState.Time.Set );
580
581 /*
582  * Following definitions are somewhat similiar to GLib's,
583  * but do not generate any log messages:
584  */
585 #define  freeglut_return_if_fail( expr )            if( !(expr) ) return;
586 #define  freeglut_return_val_if_fail( expr, val )   if( !(expr) ) return( val );
587
588 /*
589  * A call to those macros assures us that there is a current
590  * window and menu set, respectively:
591  */
592 #define  freeglut_assert_window                     assert( fgStructure.Window != NULL );
593 #define  freeglut_assert_menu                       assert( fgStructure.Menu != NULL );
594
595 /*
596  * The initialize and deinitialize functions get called on glutInit()
597  * and glutMainLoop() end respectively. They should create/clean up
598  * everything inside of the freeglut
599  */
600 void fgInitialize( const char* displayName );
601 void fgDeinitialize( void );
602
603 /*
604  * Those two functions are used to create/destroy the freeglut internal
605  * structures. This actually happens when calling glutInit() and when
606  * quitting the glutMainLoop() (which actually happens, when all windows
607  * have been closed).
608  */
609 void fgCreateStructure( void );
610 void fgDestroyStructure( void );
611
612 /*
613  * A helper function to check if a display mode is possible to use
614  */
615 #if TARGET_HOST_UNIX_X11
616 XVisualInfo* fgChooseVisual( void );
617 #endif
618
619 /*
620  * The window procedure for Win32 events handling
621  */
622 #if TARGET_HOST_WIN32
623 LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
624 GLboolean fgSetupPixelFormat( SFG_Window* window, GLboolean checkOnly, unsigned char layer_type );
625 #endif
626
627 /*
628  * Window creation, opening, closing and destruction.
629  * Defined in freeglut_structure.c, freeglut_window.c.
630  */
631 SFG_Window* fgCreateWindow( SFG_Window* parent, const char* title, int x, int y, int w, int h, GLboolean gameMode );
632 void        fgSetWindow ( SFG_Window *window ) ;
633 void        fgOpenWindow( SFG_Window* window, const char* title, int x, int y, int w, int h, GLboolean gameMode, int isSubWindow );
634 void        fgCloseWindow( SFG_Window* window );
635 void        fgAddToWindowDestroyList ( SFG_Window* window, GLboolean needToClose ) ;
636 void        fgCloseWindows () ;
637 void        fgDestroyWindow( SFG_Window* window, GLboolean needToClose );
638
639 /*
640  * Menu creation and destruction. Defined in freeglut_structure.c
641  */
642 SFG_Menu*   fgCreateMenu( FGCBmenu menuCallback );
643 void        fgDestroyMenu( SFG_Menu* menu );
644
645 /*
646  * Joystick device management functions, defined in freeglut_joystick.c
647  */
648 void        fgJoystickInit( int ident );
649 void        fgJoystickClose( void );
650 void        fgJoystickPollWindow( SFG_Window* window );
651
652 /*
653  * Helper function to enumerate through all registered windows
654  * and one to enumerate all of a window's subwindows...
655  *
656  * The GFunc callback for those functions will be defined as:
657  *
658  *      void enumCallback( gpointer window, gpointer enumerator );
659  *
660  * where window is the enumerated (sub)window pointer (SFG_Window *),
661  * and userData is the a custom user-supplied pointer. Functions
662  * are defined and exported from freeglut_structure.c file.
663  */
664 void fgEnumWindows( FGCBenumerator enumCallback, SFG_Enumerator* enumerator );
665 void fgEnumSubWindows( SFG_Window* window, FGCBenumerator enumCallback, SFG_Enumerator* enumerator );
666
667 /*
668  * fgWindowByHandle returns a (SFG_Window *) value pointing to the
669  * first window in the queue matching the specified window handle.
670  * The function is defined in freeglut_structure.c file.
671  */
672 #if TARGET_HOST_UNIX_X11
673     SFG_Window* fgWindowByHandle( Window hWindow );
674 #elif TARGET_HOST_WIN32
675
676     SFG_Window* fgWindowByHandle( HWND hWindow );
677 #endif
678
679 /*
680  * This function is similiar to the previous one, except it is
681  * looking for a specified (sub)window identifier. The function
682  * is defined in freeglut_structure.c file.
683  */
684 SFG_Window* fgWindowByID( int windowID );
685
686 /*
687  * Looks up a menu given its ID. This is easier that fgWindowByXXX
688  * as all menus are placed in a single doubly linked list...
689  */
690 SFG_Menu* fgMenuByID( int menuID );
691
692 /*
693  * The menu activation and deactivation the code. This is the meat
694  * of the menu user interface handling code...
695  */
696 void fgActivateMenu( SFG_Window* window, int button );
697 void fgExecuteMenuCallback( SFG_Menu* menu ) ;
698 GLboolean fgCheckActiveMenu ( SFG_Window *window, SFG_Menu *menu ) ;
699 void fgDeactivateMenu( SFG_Window *window );
700 void fgDeactivateSubMenu( SFG_MenuEntry *menuEntry );
701
702 /*
703  * This function gets called just before the buffers swap, so that
704  * freeglut can display the pull-down menus via OpenGL. The function
705  * is defined in freeglut_menu.c file.
706  */
707 void fgDisplayMenu( void );
708
709 /*
710  * Display the mouse cursor using OpenGL calls. The function
711  * is defined in freeglut_cursor.c file.
712  */
713 void fgDisplayCursor( void );
714
715 /*
716  * Elapsed time as per glutGet(GLUT_ELAPSED_TIME).
717  */
718 long fgElapsedTime( void );
719
720 /*
721  * List functions
722  */
723 void fgListInit(SFG_List *list);
724 void fgListAppend(SFG_List *list, SFG_Node *node);
725 void fgListRemove(SFG_List *list, SFG_Node *node);
726 int fgListLength(SFG_List *list);
727
728 /*
729  * Error Messages functions
730  */
731 void fgError( const char *fmt, ... );
732 void fgWarning( const char *fmt, ... );
733
734 #endif /* FREEGLUT_INTERNAL_H */
735
736 /*** END OF FILE ***/