4 * The freeglut library private include file.
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
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:
17 * The above copyright notice and this permission notice shall be included
18 * in all copies or substantial portions of the Software.
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.
28 #ifndef FREEGLUT_INTERNAL_H
29 #define FREEGLUT_INTERNAL_H
35 /* XXX Update these for each release! */
36 #define VERSION_MAJOR 3
37 #define VERSION_MINOR 0
38 #define VERSION_PATCH 0
40 /* Freeglut is intended to function under all Unix/X11 and Win32 platforms. */
41 /* XXX: Don't all MS-Windows compilers (except Cygwin) have _WIN32 defined?
42 * XXX: If so, remove the first set of defined()'s below.
44 #if !defined(TARGET_HOST_POSIX_X11) && !defined(TARGET_HOST_MS_WINDOWS) && !defined(TARGET_HOST_MAC_OSX) && !defined(TARGET_HOST_SOLARIS)
45 #if defined(_MSC_VER) || defined(__WATCOMC__) || defined(__MINGW32__) \
46 || defined(_WIN32) || defined(_WIN32_WCE) \
47 || ( defined(__CYGWIN__) && defined(X_DISPLAY_MISSING) )
48 # define TARGET_HOST_MS_WINDOWS 1
50 #elif defined(__posix__) || defined(__unix__) || defined(__linux__) || defined(__sun)
51 # define TARGET_HOST_POSIX_X11 1
53 #elif defined(__APPLE__)
54 /* This is a placeholder until we get native OSX support ironed out -- JFF 11/18/09 */
55 # define TARGET_HOST_POSIX_X11 1
56 /* # define TARGET_HOST_MAC_OSX 1 */
59 # error "Unrecognized target host!"
64 /* Detect both SunPro and gcc compilers on Sun Solaris */
65 #if defined (__SVR4) && defined (__sun)
66 # define TARGET_HOST_SOLARIS 1
69 #ifndef TARGET_HOST_MS_WINDOWS
70 # define TARGET_HOST_MS_WINDOWS 0
73 #ifndef TARGET_HOST_POSIX_X11
74 # define TARGET_HOST_POSIX_X11 0
77 #ifndef TARGET_HOST_MAC_OSX
78 # define TARGET_HOST_MAC_OSX 0
81 #ifndef TARGET_HOST_SOLARIS
82 # define TARGET_HOST_SOLARIS 0
85 /* -- FIXED CONFIGURATION LIMITS ------------------------------------------- */
87 #define FREEGLUT_MAX_MENUS 3
89 /* These files should be available on every platform. */
96 /* These are included based on autoconf directives. */
97 #ifdef HAVE_SYS_TYPES_H
98 # include <sys/types.h>
103 #ifdef TIME_WITH_SYS_TIME
104 # include <sys/time.h>
106 #elif defined(HAVE_SYS_TIME_H)
107 # include <sys/time.h>
112 /* -- AUTOCONF HACKS --------------------------------------------------------*/
114 /* XXX: Update autoconf to avoid these.
115 * XXX: Are non-POSIX platforms intended not to use autoconf?
116 * If so, perhaps there should be a config_guess.h for them. Alternatively,
117 * config guesses could be placed above, just after the config.h exclusion.
119 #if defined(__FreeBSD__) || defined(__NetBSD__)
120 # define HAVE_USB_JS 1
121 # if defined(__NetBSD__) || ( defined(__FreeBSD__) && __FreeBSD_version >= 500000)
122 # define HAVE_USBHID_H 1
126 #if defined(_MSC_VER) || defined(__WATCOMC__)
127 /* strdup() is non-standard, for all but POSIX-2001 */
128 #define strdup _strdup
131 /* M_PI is non-standard (defined by BSD, not ISO-C) */
133 # define M_PI 3.14159265358979323846
136 #ifdef HAVE_STDBOOL_H
137 # include <stdbool.h>
153 /* General defines */
155 #define INVALID_MODIFIERS 0xffffffff
159 /* Platform-specific includes */
160 #if TARGET_HOST_POSIX_X11
161 #include "../x11/freeglut_internal_x11.h"
163 #if TARGET_HOST_MS_WINDOWS
164 #include "../mswin/freeglut_internal_mswin.h"
168 /* -- GLOBAL TYPE DEFINITIONS ---------------------------------------------- */
170 /* Freeglut callbacks type definitions */
171 typedef void (* FGCBDisplay )( void );
172 typedef void (* FGCBReshape )( int, int );
173 typedef void (* FGCBVisibility )( int );
174 typedef void (* FGCBKeyboard )( unsigned char, int, int );
175 typedef void (* FGCBSpecial )( int, int, int );
176 typedef void (* FGCBMouse )( int, int, int, int );
177 typedef void (* FGCBMouseWheel )( int, int, int, int );
178 typedef void (* FGCBMotion )( int, int );
179 typedef void (* FGCBPassive )( int, int );
180 typedef void (* FGCBEntry )( int );
181 typedef void (* FGCBWindowStatus )( int );
182 typedef void (* FGCBSelect )( int, int, int );
183 typedef void (* FGCBJoystick )( unsigned int, int, int, int );
184 typedef void (* FGCBKeyboardUp )( unsigned char, int, int );
185 typedef void (* FGCBSpecialUp )( int, int, int );
186 typedef void (* FGCBOverlayDisplay)( void );
187 typedef void (* FGCBSpaceMotion )( int, int, int );
188 typedef void (* FGCBSpaceRotation )( int, int, int );
189 typedef void (* FGCBSpaceButton )( int, int );
190 typedef void (* FGCBDials )( int, int );
191 typedef void (* FGCBButtonBox )( int, int );
192 typedef void (* FGCBTabletMotion )( int, int );
193 typedef void (* FGCBTabletButton )( int, int, int, int );
194 typedef void (* FGCBDestroy )( void );
196 typedef void (* FGCBMultiEntry )( int, int );
197 typedef void (* FGCBMultiButton )( int, int, int, int, int );
198 typedef void (* FGCBMultiMotion )( int, int, int );
199 typedef void (* FGCBMultiPassive )( int, int, int );
201 /* The global callbacks type definitions */
202 typedef void (* FGCBIdle )( void );
203 typedef void (* FGCBTimer )( int );
204 typedef void (* FGCBMenuState )( int );
205 typedef void (* FGCBMenuStatus )( int, int, int );
207 /* The callback used when creating/using menus */
208 typedef void (* FGCBMenu )( int );
210 /* The FreeGLUT error/warning handler type definition */
211 typedef void (* FGError ) ( const char *fmt, va_list ap);
212 typedef void (* FGWarning ) ( const char *fmt, va_list ap);
215 /* A list structure */
216 typedef struct tagSFG_List SFG_List;
223 /* A list node structure */
224 typedef struct tagSFG_Node SFG_Node;
231 /* A helper structure holding two ints and a boolean */
232 typedef struct tagSFG_XYUse SFG_XYUse;
235 GLint X, Y; /* The two integers... */
236 GLboolean Use; /* ...and a single boolean. */
240 * An enumeration containing the state of the GLUT execution:
241 * initializing, running, or stopping
245 GLUT_EXEC_STATE_INIT,
246 GLUT_EXEC_STATE_RUNNING,
250 /* This structure holds different freeglut settings */
251 typedef struct tagSFG_State SFG_State;
254 SFG_XYUse Position; /* The default windows' position */
255 SFG_XYUse Size; /* The default windows' size */
256 unsigned int DisplayMode; /* Display mode for new windows */
258 GLboolean Initialised; /* freeglut has been initialised */
260 int DirectContext; /* Direct rendering state */
262 GLboolean ForceIconic; /* New top windows are iconified */
263 GLboolean UseCurrentContext; /* New windows share with current */
265 GLboolean GLDebugSwitch; /* OpenGL state debugging switch */
266 GLboolean XSyncSwitch; /* X11 sync protocol switch */
268 int KeyRepeat; /* Global key repeat mode. */
269 int Modifiers; /* Current ALT/SHIFT/CTRL state */
271 GLuint FPSInterval; /* Interval between FPS printfs */
272 GLuint SwapCount; /* Count of glutSwapBuffer calls */
273 GLuint SwapTime; /* Time of last SwapBuffers */
275 unsigned long Time; /* Time that glutInit was called */
276 SFG_List Timers; /* The freeglut timer hooks */
277 SFG_List FreeTimers; /* The unused timer hooks */
279 FGCBIdle IdleCallback; /* The global idle callback */
281 int ActiveMenus; /* Num. of currently active menus */
282 FGCBMenuState MenuStateCallback; /* Menu callbacks are global */
283 FGCBMenuStatus MenuStatusCallback;
285 SFG_XYUse GameModeSize; /* Game mode screen's dimensions */
286 int GameModeDepth; /* The pixel depth for game mode */
287 int GameModeRefresh; /* The refresh rate for game mode */
289 int ActionOnWindowClose; /* Action when user closes window */
291 fgExecutionState ExecState; /* Used for GLUT termination */
292 char *ProgramName; /* Name of the invoking program */
293 GLboolean JoysticksInitialised; /* Only initialize if application calls for them */
294 int NumActiveJoysticks; /* Number of active joysticks -- if zero, don't poll joysticks */
295 GLboolean InputDevsInitialised; /* Only initialize if application calls for them */
297 int MouseWheelTicks; /* Number of ticks the mouse wheel has turned */
299 int AuxiliaryBufferNumber; /* Number of auxiliary buffers */
300 int SampleNumber; /* Number of samples per pixel */
302 int MajorVersion; /* Major OpenGL context version */
303 int MinorVersion; /* Minor OpenGL context version */
304 int ContextFlags; /* OpenGL context flags */
305 int ContextProfile; /* OpenGL context profile */
306 FGError ErrorFunc; /* User defined error handler */
307 FGWarning WarningFunc; /* User defined warning handler */
310 /* The structure used by display initialization in freeglut_init.c */
311 typedef struct tagSFG_Display SFG_Display;
312 struct tagSFG_Display
314 SFG_PlatformDisplay pDisplay;
316 int ScreenWidth; /* The screen's width in pixels */
317 int ScreenHeight; /* The screen's height in pixels */
318 int ScreenWidthMM; /* The screen's width in milimeters */
319 int ScreenHeightMM; /* The screen's height in milimeters */
323 /* The user can create any number of timer hooks */
324 typedef struct tagSFG_Timer SFG_Timer;
328 int ID; /* The timer ID integer */
329 FGCBTimer Callback; /* The timer callback */
330 long TriggerTime; /* The timer trigger time */
334 * A window and its OpenGL context. The contents of this structure
335 * are highly dependant on the target operating system we aim at...
337 typedef struct tagSFG_Context SFG_Context;
338 struct tagSFG_Context
340 SFG_WindowHandleType Handle; /* The window's handle */
341 SFG_WindowContextType Context; /* The window's OpenGL/WGL context */
343 SFG_PlatformContext pContext; /* The window's FBConfig (X11) or device context (Windows) */
345 int DoubleBuffered; /* Treat the window as double-buffered */
349 typedef struct tagSFG_WindowState SFG_WindowState;
350 struct tagSFG_WindowState
352 /* Note that on Windows, sizes always refer to the client area, thus without the window decorations */
353 int Width; /* Window's width in pixels */
354 int Height; /* The same about the height */
356 SFG_PlatformWindowState pWState; /* Window width/height (X11) or rectangle/style (Windows) from before a resize */
358 GLboolean Redisplay; /* Do we have to redisplay? */
359 GLboolean Visible; /* Is the window visible now */
361 int Cursor; /* The currently selected cursor */
363 long JoystickPollRate; /* The joystick polling rate */
364 long JoystickLastPoll; /* When the last poll happened */
366 int MouseX, MouseY; /* The most recent mouse position */
368 GLboolean IgnoreKeyRepeat; /* Whether to ignore key repeat. */
369 GLboolean KeyRepeating; /* Currently in repeat mode */
371 GLboolean NeedToResize; /* Do we need to resize the window? */
373 GLboolean IsFullscreen; /* is the window fullscreen? */
378 * A generic function pointer. We should really use the GLUTproc type
379 * defined in freeglut_ext.h, but if we include that header in this file
380 * a bunch of other stuff (font-related) blows up!
382 typedef void (*SFG_Proc)();
386 * SET_WCB() is used as:
388 * SET_WCB( window, cbname, func );
390 * ...where {window} is the freeglut window to set the callback,
391 * {cbname} is the window-specific callback to set,
392 * {func} is a function-pointer.
394 * Originally, {FETCH_WCB( ... ) = func} was rather sloppily used,
395 * but this can cause warnings because the FETCH_WCB() macro type-
396 * casts its result, and a type-cast value shouldn't be an lvalue.
398 * The {if( FETCH_WCB( ... ) != func )} test is to do type-checking
399 * and for no other reason. Since it's hidden in the macro, the
400 * ugliness is felt to be rather benign.
402 #define SET_WCB(window,cbname,func) \
405 if( FETCH_WCB( window, cbname ) != (SFG_Proc)(func) ) \
406 (((window).CallBacks[CB_ ## cbname]) = (SFG_Proc)(func)); \
410 * FETCH_WCB() is used as:
412 * FETCH_WCB( window, cbname );
414 * ...where {window} is the freeglut window to fetch the callback from,
415 * {cbname} is the window-specific callback to fetch.
417 * The result is correctly type-cast to the callback function pointer
420 #define FETCH_WCB(window,cbname) \
421 ((window).CallBacks[CB_ ## cbname])
424 * INVOKE_WCB() is used as:
426 * INVOKE_WCB( window, cbname, ( arg_list ) );
428 * ...where {window} is the freeglut window,
429 * {cbname} is the window-specific callback to be invoked,
430 * {(arg_list)} is the parameter list.
432 * The callback is invoked as:
434 * callback( arg_list );
436 * ...so the parentheses are REQUIRED in the {arg_list}.
438 * NOTE that it does a sanity-check and also sets the
442 #if TARGET_HOST_MS_WINDOWS && !defined(_WIN32_WCE) /* FIXME: also WinCE? */
443 #define INVOKE_WCB(window,cbname,arg_list) \
446 if( FETCH_WCB( window, cbname ) ) \
448 FGCB ## cbname func = (FGCB ## cbname)(FETCH_WCB( window, cbname )); \
449 fgSetWindow( &window ); \
454 #define INVOKE_WCB(window,cbname,arg_list) \
457 if( FETCH_WCB( window, cbname ) ) \
459 fgSetWindow( &window ); \
460 ((FGCB ## cbname)FETCH_WCB( window, cbname )) arg_list; \
466 * The window callbacks the user can supply us with. Should be kept portable.
468 * This enumeration provides the freeglut CallBack numbers.
469 * The symbolic constants are indices into a window's array of
470 * function callbacks. The names are formed by splicing a common
471 * prefix onto the callback's base name. (This was originally
472 * done so that an early stage of development could live side-by-
473 * side with the old callback code. The old callback code used
474 * the bare callback's name as a structure member, so I used a
475 * prefix for the array index name.)
477 * XXX For consistancy, perhaps the prefix should match the
478 * XXX FETCH* and INVOKE* macro suffices. I.e., WCB_, rather than
505 /* Presently ignored */
508 CB_SpaceMotion, /* presently implemented only on UNIX/X11 */
509 CB_SpaceRotation, /* presently implemented only on UNIX/X11 */
510 CB_SpaceButton, /* presently implemented only on UNIX/X11 */
516 /* Always make this the LAST one */
521 /* This structure holds the OpenGL rendering context for all the menu windows */
522 typedef struct tagSFG_MenuContext SFG_MenuContext;
523 struct tagSFG_MenuContext
525 SFG_WindowContextType MContext; /* The menu window's WGL context */
528 /* This structure describes a menu */
529 typedef struct tagSFG_Window SFG_Window;
530 typedef struct tagSFG_MenuEntry SFG_MenuEntry;
531 typedef struct tagSFG_Menu SFG_Menu;
535 void *UserData; /* User data passed back at callback */
536 int ID; /* The global menu ID */
537 SFG_List Entries; /* The menu entries list */
538 FGCBMenu Callback; /* The menu callback */
539 FGCBDestroy Destroy; /* Destruction callback */
540 GLboolean IsActive; /* Is the menu selected? */
541 int Width; /* Menu box width in pixels */
542 int Height; /* Menu box height in pixels */
543 int X, Y; /* Menu box raster position */
545 SFG_MenuEntry *ActiveEntry; /* Currently active entry in the menu */
546 SFG_Window *Window; /* Window for menu */
547 SFG_Window *ParentWindow; /* Window in which the menu is invoked */
550 /* This is a menu entry */
551 struct tagSFG_MenuEntry
554 int ID; /* The menu entry ID (local) */
555 int Ordinal; /* The menu's ordinal number */
556 char* Text; /* The text to be displayed */
557 SFG_Menu* SubMenu; /* Optional sub-menu tree */
558 GLboolean IsActive; /* Is the entry highlighted? */
559 int Width; /* Label's width in pixels */
563 * A window, making part of freeglut windows hierarchy.
564 * Should be kept portable.
566 * NOTE that ActiveMenu is set to menu itself if the window is a menu.
571 int ID; /* Window's ID number */
573 SFG_Context Window; /* Window and OpenGL context */
574 SFG_WindowState State; /* The window state */
575 SFG_Proc CallBacks[ TOTAL_CALLBACKS ]; /* Array of window callbacks */
576 void *UserData ; /* For use by user */
578 SFG_Menu* Menu[ FREEGLUT_MAX_MENUS ]; /* Menus appended to window */
579 SFG_Menu* ActiveMenu; /* The window's active menu */
581 SFG_Window* Parent; /* The parent to this window */
582 SFG_List Children; /* The subwindows d.l. list */
584 GLboolean IsMenu; /* Set to 1 if we are a menu */
588 /* A linked list structure of windows */
589 typedef struct tagSFG_WindowList SFG_WindowList ;
590 struct tagSFG_WindowList
596 /* This holds information about all the windows, menus etc. */
597 typedef struct tagSFG_Structure SFG_Structure;
598 struct tagSFG_Structure
600 SFG_List Windows; /* The global windows list */
601 SFG_List Menus; /* The global menus list */
602 SFG_List WindowsToDestroy;
604 SFG_Window* CurrentWindow; /* The currently set window */
605 SFG_Menu* CurrentMenu; /* Same, but menu... */
607 SFG_MenuContext* MenuContext; /* OpenGL rendering context for menus */
609 SFG_Window* GameModeWindow; /* The game mode window */
611 int WindowID; /* The new current window ID */
612 int MenuID; /* The new current menu ID */
616 * This structure is used for the enumeration purposes.
617 * You can easily extend its functionalities by declaring
618 * a structure containing enumerator's contents and custom
619 * data, then casting its pointer to (SFG_Enumerator *).
621 typedef struct tagSFG_Enumerator SFG_Enumerator;
622 struct tagSFG_Enumerator
624 GLboolean found; /* Used to terminate search */
625 void* data; /* Custom data pointer */
627 typedef void (* FGCBenumerator )( SFG_Window *, SFG_Enumerator * );
629 /* The bitmap font structure */
630 typedef struct tagSFG_Font SFG_Font;
633 char* Name; /* The source font name */
634 int Quantity; /* Number of chars in font */
635 int Height; /* Height of the characters */
636 const GLubyte** Characters; /* The characters mapping */
638 float xorig, yorig; /* Relative origin of the character */
641 /* The stroke font structures */
643 typedef struct tagSFG_StrokeVertex SFG_StrokeVertex;
644 struct tagSFG_StrokeVertex
649 typedef struct tagSFG_StrokeStrip SFG_StrokeStrip;
650 struct tagSFG_StrokeStrip
653 const SFG_StrokeVertex* Vertices;
656 typedef struct tagSFG_StrokeChar SFG_StrokeChar;
657 struct tagSFG_StrokeChar
661 const SFG_StrokeStrip* Strips;
664 typedef struct tagSFG_StrokeFont SFG_StrokeFont;
665 struct tagSFG_StrokeFont
667 char* Name; /* The source font name */
668 int Quantity; /* Number of chars in font */
669 GLfloat Height; /* Height of the characters */
670 const SFG_StrokeChar** Characters; /* The characters mapping */
674 /* -- JOYSTICK-SPECIFIC STRUCTURES AND TYPES ------------------------------- */
676 * Initial defines from "js.h" starting around line 33 with the existing "freeglut_joystick.c"
680 #if TARGET_HOST_MACINTOSH
681 # include <InputSprocket.h>
684 #if TARGET_HOST_MAC_OSX
685 # include <mach/mach.h>
686 # include <IOKit/IOkitLib.h>
687 # include <IOKit/hid/IOHIDLib.h>
690 /* XXX It might be better to poll the operating system for the numbers of buttons and
691 * XXX axes and then dynamically allocate the arrays.
693 #define _JS_MAX_BUTTONS 32
695 #if TARGET_HOST_MACINTOSH
696 # define _JS_MAX_AXES 9
697 typedef struct tagSFG_PlatformJoystick SFG_PlatformJoystick;
698 struct tagSFG_PlatformJoystick
700 #define ISP_NUM_AXIS 9
701 #define ISP_NUM_NEEDS 41
702 ISpElementReference isp_elem [ ISP_NUM_NEEDS ];
703 ISpNeed isp_needs [ ISP_NUM_NEEDS ];
707 #if TARGET_HOST_MAC_OSX
708 # define _JS_MAX_AXES 16
709 typedef struct tagSFG_PlatformJoystick SFG_PlatformJoystick;
710 struct tagSFG_PlatformJoystick
712 IOHIDDeviceInterface ** hidDev;
713 IOHIDElementCookie buttonCookies[41];
714 IOHIDElementCookie axisCookies[_JS_MAX_AXES];
715 /* The next two variables are not used anywhere */
716 /* long minReport[_JS_MAX_AXES],
717 * maxReport[_JS_MAX_AXES];
724 * Definition of "SFG_Joystick" structure -- based on JS's "jsJoystick" object class.
725 * See "js.h" lines 80-178.
727 typedef struct tagSFG_Joystick SFG_Joystick;
728 struct tagSFG_Joystick
730 SFG_PlatformJoystick pJoystick;
738 float dead_band[ _JS_MAX_AXES ];
739 float saturate [ _JS_MAX_AXES ];
740 float center [ _JS_MAX_AXES ];
741 float max [ _JS_MAX_AXES ];
742 float min [ _JS_MAX_AXES ];
747 /* -- GLOBAL VARIABLES EXPORTS --------------------------------------------- */
749 /* Freeglut display related stuff (initialized once per session) */
750 extern SFG_Display fgDisplay;
752 /* Freeglut internal structure */
753 extern SFG_Structure fgStructure;
755 /* The current freeglut settings */
756 extern SFG_State fgState;
759 /* -- PRIVATE FUNCTION DECLARATIONS ---------------------------------------- */
762 * A call to this function makes us sure that the Display and Structure
763 * subsystems have been properly initialized and are ready to be used
765 #define FREEGLUT_EXIT_IF_NOT_INITIALISED( string ) \
766 if ( ! fgState.Initialised ) \
768 fgError ( " ERROR: Function <%s> called" \
769 " without first calling 'glutInit'.", (string) ) ; \
772 #define FREEGLUT_INTERNAL_ERROR_EXIT_IF_NOT_INITIALISED( string ) \
773 if ( ! fgState.Initialised ) \
775 fgError ( " ERROR: Internal <%s> function called" \
776 " without first calling 'glutInit'.", (string) ) ; \
779 #define FREEGLUT_INTERNAL_ERROR_EXIT( cond, string, function ) \
782 fgError ( " ERROR: Internal error <%s> in function %s", \
783 (string), (function) ) ; \
787 * Following definitions are somewhat similiar to GLib's,
788 * but do not generate any log messages:
790 #define freeglut_return_if_fail( expr ) \
793 #define freeglut_return_val_if_fail( expr, val ) \
798 * A call to those macros assures us that there is a current
799 * window set, respectively:
801 #define FREEGLUT_EXIT_IF_NO_WINDOW( string ) \
802 if ( ! fgStructure.CurrentWindow && \
803 ( fgState.ActionOnWindowClose != GLUT_ACTION_CONTINUE_EXECUTION ) ) \
805 fgError ( " ERROR: Function <%s> called" \
806 " with no current window defined.", (string) ) ; \
810 * The deinitialize function gets called on glutMainLoop() end. It should clean up
811 * everything inside of the freeglut
813 void fgDeinitialize( void );
816 * Those two functions are used to create/destroy the freeglut internal
817 * structures. This actually happens when calling glutInit() and when
818 * quitting the glutMainLoop() (which actually happens, when all windows
821 void fgCreateStructure( void );
822 void fgDestroyStructure( void );
825 * Window creation, opening, closing and destruction.
826 * Also CallBack clearing/initialization.
827 * Defined in freeglut_structure.c, freeglut_window.c.
829 SFG_Window* fgCreateWindow( SFG_Window* parent, const char* title,
830 GLboolean positionUse, int x, int y,
831 GLboolean sizeUse, int w, int h,
832 GLboolean gameMode, GLboolean isMenu );
833 void fgSetWindow ( SFG_Window *window );
834 void fgOpenWindow( SFG_Window* window, const char* title,
835 GLboolean positionUse, int x, int y,
836 GLboolean sizeUse, int w, int h,
837 GLboolean gameMode, GLboolean isSubWindow );
838 void fgCloseWindow( SFG_Window* window );
839 void fgAddToWindowDestroyList ( SFG_Window* window );
840 void fgCloseWindows ();
841 void fgDestroyWindow( SFG_Window* window );
843 /* Menu creation and destruction. Defined in freeglut_structure.c */
844 SFG_Menu* fgCreateMenu( FGCBMenu menuCallback );
845 void fgDestroyMenu( SFG_Menu* menu );
847 /* Joystick device management functions, defined in freeglut_joystick.c */
848 int fgJoystickDetect( void );
849 void fgInitialiseJoysticks( void );
850 void fgJoystickClose( void );
851 void fgJoystickPollWindow( SFG_Window* window );
853 /* InputDevice Initialisation and Closure */
854 int fgInputDeviceDetect( void );
855 void fgInitialiseInputDevices( void );
856 void fgInputDeviceClose( void );
858 /* spaceball device functions, defined in freeglut_spaceball.c */
859 void fgInitialiseSpaceball( void );
860 void fgSpaceballClose( void );
861 void fgSpaceballSetWindow( SFG_Window *window );
863 int fgHasSpaceball( void );
864 int fgSpaceballNumButtons( void );
866 /* Setting the cursor for a given window */
867 void fgSetCursor ( SFG_Window *window, int cursorID );
870 * Helper function to enumerate through all registered windows
871 * and one to enumerate all of a window's subwindows...
873 * The GFunc callback for those functions will be defined as:
875 * void enumCallback( gpointer window, gpointer enumerator );
877 * where window is the enumerated (sub)window pointer (SFG_Window *),
878 * and userData is the a custom user-supplied pointer. Functions
879 * are defined and exported from freeglut_structure.c file.
881 void fgEnumWindows( FGCBenumerator enumCallback, SFG_Enumerator* enumerator );
882 void fgEnumSubWindows( SFG_Window* window, FGCBenumerator enumCallback,
883 SFG_Enumerator* enumerator );
886 * fgWindowByHandle returns a (SFG_Window *) value pointing to the
887 * first window in the queue matching the specified window handle.
888 * The function is defined in freeglut_structure.c file.
890 SFG_Window* fgWindowByHandle( SFG_WindowHandleType hWindow );
893 * This function is similiar to the previous one, except it is
894 * looking for a specified (sub)window identifier. The function
895 * is defined in freeglut_structure.c file.
897 SFG_Window* fgWindowByID( int windowID );
900 * Looks up a menu given its ID. This is easier than fgWindowByXXX
901 * as all menus are placed in a single doubly linked list...
903 SFG_Menu* fgMenuByID( int menuID );
906 * The menu activation and deactivation the code. This is the meat
907 * of the menu user interface handling code...
909 void fgUpdateMenuHighlight ( SFG_Menu *menu );
910 GLboolean fgCheckActiveMenu ( SFG_Window *window, int button, GLboolean pressed,
911 int mouse_x, int mouse_y );
912 void fgDeactivateMenu( SFG_Window *window );
915 * This function gets called just before the buffers swap, so that
916 * freeglut can display the pull-down menus via OpenGL. The function
917 * is defined in freeglut_menu.c file.
919 void fgDisplayMenu( void );
921 /* Elapsed time as per glutGet(GLUT_ELAPSED_TIME). */
922 long fgElapsedTime( void );
924 /* System time in milliseconds */
925 long unsigned fgSystemTime(void);
928 void fgListInit(SFG_List *list);
929 void fgListAppend(SFG_List *list, SFG_Node *node);
930 void fgListRemove(SFG_List *list, SFG_Node *node);
931 int fgListLength(SFG_List *list);
932 void fgListInsert(SFG_List *list, SFG_Node *next, SFG_Node *node);
934 /* Error Message functions */
935 void fgError( const char *fmt, ... );
936 void fgWarning( const char *fmt, ... );
938 SFG_Proc fgPlatformGetProcAddress( const char *procName );
940 /* pushing attribute/value pairs into an array */
941 #define ATTRIB(a) attributes[where++]=(a)
942 #define ATTRIB_VAL(a,v) {ATTRIB(a); ATTRIB(v);}
944 int fghIsLegacyContextVersionRequested( void );
945 int fghMapBit( int mask, int from, int to );
946 int fghIsLegacyContextRequested( void );
947 void fghContextCreationError( void );
948 int fghNumberOfAuxBuffersRequested( void );
950 #endif /* FREEGLUT_INTERNAL_H */
952 /*** END OF FILE ***/