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 /* Freeglut is intended to function under all Unix/X11 and Win32 platforms. */
36 /* XXX: Don't all MS-Windows compilers (except Cygwin) have _WIN32 defined?
37 * XXX: If so, remove the first set of defined()'s below.
39 #if !defined(TARGET_HOST_POSIX_X11) && !defined(TARGET_HOST_MS_WINDOWS) && !defined(TARGET_HOST_MAC_OSX) && !defined(TARGET_HOST_SOLARIS)
40 #if defined(_MSC_VER) || defined(__WATCOMC__) || defined(__MINGW32__) \
41 || defined(_WIN32) || defined(_WIN32_WCE) \
42 || ( defined(__CYGWIN__) && defined(X_DISPLAY_MISSING) )
43 # define TARGET_HOST_MS_WINDOWS 1
45 #elif defined (ANDROID)
46 # define TARGET_HOST_ANDROID 1
48 #elif defined(__posix__) || defined(__unix__) || defined(__linux__) || defined(__sun)
49 # define TARGET_HOST_POSIX_X11 1
51 #elif defined(__APPLE__)
52 /* This is a placeholder until we get native OSX support ironed out -- JFF 11/18/09 */
53 # define TARGET_HOST_POSIX_X11 1
54 /* # define TARGET_HOST_MAC_OSX 1 */
57 # error "Unrecognized target host!"
62 /* Detect both SunPro and gcc compilers on Sun Solaris */
63 #if defined (__SVR4) && defined (__sun)
64 # define TARGET_HOST_SOLARIS 1
67 #ifndef TARGET_HOST_MS_WINDOWS
68 # define TARGET_HOST_MS_WINDOWS 0
71 #ifndef TARGET_HOST_POSIX_X11
72 # define TARGET_HOST_POSIX_X11 0
75 #ifndef TARGET_HOST_MAC_OSX
76 # define TARGET_HOST_MAC_OSX 0
79 #ifndef TARGET_HOST_SOLARIS
80 # define TARGET_HOST_SOLARIS 0
83 /* -- FIXED CONFIGURATION LIMITS ------------------------------------------- */
85 #define FREEGLUT_MAX_MENUS 3
87 /* These files should be available on every platform. */
94 /* These are included based on autoconf directives. */
95 #ifdef HAVE_SYS_TYPES_H
96 # include <sys/types.h>
101 #ifdef TIME_WITH_SYS_TIME
102 # include <sys/time.h>
104 #elif defined(HAVE_SYS_TIME_H)
105 # include <sys/time.h>
110 /* -- AUTOCONF HACKS --------------------------------------------------------*/
112 /* XXX: Update autoconf to avoid these.
113 * XXX: Are non-POSIX platforms intended not to use autoconf?
114 * If so, perhaps there should be a config_guess.h for them. Alternatively,
115 * config guesses could be placed above, just after the config.h exclusion.
117 #if defined(__FreeBSD__) || defined(__NetBSD__)
118 # define HAVE_USB_JS 1
119 # if defined(__NetBSD__) || ( defined(__FreeBSD__) && __FreeBSD_version >= 500000)
120 # define HAVE_USBHID_H 1
124 #if defined(_MSC_VER) || defined(__WATCOMC__)
125 /* strdup() is non-standard, for all but POSIX-2001 */
126 #define strdup _strdup
129 /* M_PI is non-standard (defined by BSD, not ISO-C) */
131 # define M_PI 3.14159265358979323846
134 #ifdef HAVE_STDBOOL_H
135 # include <stdbool.h>
151 /* General defines */
152 #define INVALID_MODIFIERS 0xffffffff
154 /* FreeGLUT internal time type */
155 #if defined(HAVE_STDINT_H)
157 typedef uint64_t fg_time_t;
158 #elif defined(HAVE_INTTYPES_H)
159 # include <inttypes.h>
160 typedef uint64_t fg_time_t;
161 #elif defined(HAVE_U__INT64)
162 typedef unsigned __int64 fg_time_t;
163 #elif defined(HAVE_ULONG_LONG)
164 typedef unsigned long long fg_time_t;
166 typedef unsigned long fg_time_t;
171 /* Platform-specific includes */
172 #if TARGET_HOST_POSIX_X11
173 #include "x11/fg_internal_x11.h"
175 #if TARGET_HOST_MS_WINDOWS
176 #include "mswin/fg_internal_mswin.h"
178 #if TARGET_HOST_ANDROID
179 #include "android/fg_internal_android.h"
183 /* -- GLOBAL TYPE DEFINITIONS ---------------------------------------------- */
185 /* Freeglut callbacks type definitions */
186 typedef void (* FGCBDisplay )( void );
187 typedef void (* FGCBReshape )( int, int );
188 typedef void (* FGCBVisibility )( int );
189 typedef void (* FGCBKeyboard )( unsigned char, int, int );
190 typedef void (* FGCBSpecial )( int, int, int );
191 typedef void (* FGCBMouse )( int, int, int, int );
192 typedef void (* FGCBMouseWheel )( int, int, int, int );
193 typedef void (* FGCBMotion )( int, int );
194 typedef void (* FGCBPassive )( int, int );
195 typedef void (* FGCBEntry )( int );
196 typedef void (* FGCBWindowStatus )( int );
197 typedef void (* FGCBSelect )( int, int, int );
198 typedef void (* FGCBJoystick )( unsigned int, int, int, int );
199 typedef void (* FGCBKeyboardUp )( unsigned char, int, int );
200 typedef void (* FGCBSpecialUp )( int, int, int );
201 typedef void (* FGCBOverlayDisplay)( void );
202 typedef void (* FGCBSpaceMotion )( int, int, int );
203 typedef void (* FGCBSpaceRotation )( int, int, int );
204 typedef void (* FGCBSpaceButton )( int, int );
205 typedef void (* FGCBDials )( int, int );
206 typedef void (* FGCBButtonBox )( int, int );
207 typedef void (* FGCBTabletMotion )( int, int );
208 typedef void (* FGCBTabletButton )( int, int, int, int );
209 typedef void (* FGCBDestroy )( void );
211 typedef void (* FGCBMultiEntry )( int, int );
212 typedef void (* FGCBMultiButton )( int, int, int, int, int );
213 typedef void (* FGCBMultiMotion )( int, int, int );
214 typedef void (* FGCBMultiPassive )( int, int, int );
216 /* The global callbacks type definitions */
217 typedef void (* FGCBIdle )( void );
218 typedef void (* FGCBTimer )( int );
219 typedef void (* FGCBMenuState )( int );
220 typedef void (* FGCBMenuStatus )( int, int, int );
222 /* The callback used when creating/using menus */
223 typedef void (* FGCBMenu )( int );
225 /* The FreeGLUT error/warning handler type definition */
226 typedef void (* FGError ) ( const char *fmt, va_list ap);
227 typedef void (* FGWarning ) ( const char *fmt, va_list ap);
230 /* A list structure */
231 typedef struct tagSFG_List SFG_List;
238 /* A list node structure */
239 typedef struct tagSFG_Node SFG_Node;
246 /* A helper structure holding two ints and a boolean */
247 typedef struct tagSFG_XYUse SFG_XYUse;
250 GLint X, Y; /* The two integers... */
251 GLboolean Use; /* ...and a single boolean. */
255 * An enumeration containing the state of the GLUT execution:
256 * initializing, running, or stopping
260 GLUT_EXEC_STATE_INIT,
261 GLUT_EXEC_STATE_RUNNING,
265 /* This structure holds different freeglut settings */
266 typedef struct tagSFG_State SFG_State;
269 SFG_XYUse Position; /* The default windows' position */
270 SFG_XYUse Size; /* The default windows' size */
271 unsigned int DisplayMode; /* Display mode for new windows */
273 GLboolean Initialised; /* freeglut has been initialised */
275 int DirectContext; /* Direct rendering state */
277 GLboolean ForceIconic; /* New top windows are iconified */
278 GLboolean UseCurrentContext; /* New windows share with current */
280 GLboolean GLDebugSwitch; /* OpenGL state debugging switch */
281 GLboolean XSyncSwitch; /* X11 sync protocol switch */
283 int KeyRepeat; /* Global key repeat mode. */
284 int Modifiers; /* Current ALT/SHIFT/CTRL state */
286 GLuint FPSInterval; /* Interval between FPS printfs */
287 GLuint SwapCount; /* Count of glutSwapBuffer calls */
288 GLuint SwapTime; /* Time of last SwapBuffers */
290 fg_time_t Time; /* Time that glutInit was called */
291 SFG_List Timers; /* The freeglut timer hooks */
292 SFG_List FreeTimers; /* The unused timer hooks */
294 FGCBIdle IdleCallback; /* The global idle callback */
296 int ActiveMenus; /* Num. of currently active menus */
297 FGCBMenuState MenuStateCallback; /* Menu callbacks are global */
298 FGCBMenuStatus MenuStatusCallback;
300 SFG_XYUse GameModeSize; /* Game mode screen's dimensions */
301 int GameModeDepth; /* The pixel depth for game mode */
302 int GameModeRefresh; /* The refresh rate for game mode */
304 int ActionOnWindowClose; /* Action when user closes window */
306 fgExecutionState ExecState; /* Used for GLUT termination */
307 char *ProgramName; /* Name of the invoking program */
308 GLboolean JoysticksInitialised; /* Only initialize if application calls for them */
309 int NumActiveJoysticks; /* Number of active joysticks -- if zero, don't poll joysticks */
310 GLboolean InputDevsInitialised; /* Only initialize if application calls for them */
312 int MouseWheelTicks; /* Number of ticks the mouse wheel has turned */
314 int AuxiliaryBufferNumber; /* Number of auxiliary buffers */
315 int SampleNumber; /* Number of samples per pixel */
317 int MajorVersion; /* Major OpenGL context version */
318 int MinorVersion; /* Minor OpenGL context version */
319 int ContextFlags; /* OpenGL context flags */
320 int ContextProfile; /* OpenGL context profile */
321 FGError ErrorFunc; /* User defined error handler */
322 FGWarning WarningFunc; /* User defined warning handler */
325 /* The structure used by display initialization in freeglut_init.c */
326 typedef struct tagSFG_Display SFG_Display;
327 struct tagSFG_Display
329 SFG_PlatformDisplay pDisplay;
331 int ScreenWidth; /* The screen's width in pixels */
332 int ScreenHeight; /* The screen's height in pixels */
333 int ScreenWidthMM; /* The screen's width in milimeters */
334 int ScreenHeightMM; /* The screen's height in milimeters */
338 /* The user can create any number of timer hooks */
339 typedef struct tagSFG_Timer SFG_Timer;
343 int ID; /* The timer ID integer */
344 FGCBTimer Callback; /* The timer callback */
345 fg_time_t TriggerTime; /* The timer trigger time */
349 * A window and its OpenGL context. The contents of this structure
350 * are highly dependant on the target operating system we aim at...
352 typedef struct tagSFG_Context SFG_Context;
353 struct tagSFG_Context
355 SFG_WindowHandleType Handle; /* The window's handle */
356 SFG_WindowContextType Context; /* The window's OpenGL/WGL context */
358 SFG_PlatformContext pContext; /* The window's FBConfig (X11) or device context (Windows) */
360 int DoubleBuffered; /* Treat the window as double-buffered */
364 typedef struct tagSFG_WindowState SFG_WindowState;
365 struct tagSFG_WindowState
367 /* Note that on Windows, sizes always refer to the client area, thus without the window decorations */
368 int Width; /* Window's width in pixels */
369 int Height; /* The same about the height */
371 SFG_PlatformWindowState pWState; /* Window width/height (X11) or rectangle/style (Windows) from before a resize */
373 GLboolean Redisplay; /* Do we have to redisplay? */
374 GLboolean Visible; /* Is the window visible now */
376 int Cursor; /* The currently selected cursor */
378 long JoystickPollRate; /* The joystick polling rate */
379 fg_time_t JoystickLastPoll; /* When the last poll happened */
381 int MouseX, MouseY; /* The most recent mouse position */
383 GLboolean IgnoreKeyRepeat; /* Whether to ignore key repeat. */
384 GLboolean KeyRepeating; /* Currently in repeat mode */
386 GLboolean NeedToResize; /* Do we need to resize the window? */
388 GLboolean IsFullscreen; /* is the window fullscreen? */
393 * A generic function pointer. We should really use the GLUTproc type
394 * defined in freeglut_ext.h, but if we include that header in this file
395 * a bunch of other stuff (font-related) blows up!
397 typedef void (*SFG_Proc)();
401 * SET_WCB() is used as:
403 * SET_WCB( window, cbname, func );
405 * ...where {window} is the freeglut window to set the callback,
406 * {cbname} is the window-specific callback to set,
407 * {func} is a function-pointer.
409 * Originally, {FETCH_WCB( ... ) = func} was rather sloppily used,
410 * but this can cause warnings because the FETCH_WCB() macro type-
411 * casts its result, and a type-cast value shouldn't be an lvalue.
413 * The {if( FETCH_WCB( ... ) != func )} test is to do type-checking
414 * and for no other reason. Since it's hidden in the macro, the
415 * ugliness is felt to be rather benign.
417 #define SET_WCB(window,cbname,func) \
420 if( FETCH_WCB( window, cbname ) != (SFG_Proc)(func) ) \
421 (((window).CallBacks[CB_ ## cbname]) = (SFG_Proc)(func)); \
425 * FETCH_WCB() is used as:
427 * FETCH_WCB( window, cbname );
429 * ...where {window} is the freeglut window to fetch the callback from,
430 * {cbname} is the window-specific callback to fetch.
432 * The result is correctly type-cast to the callback function pointer
435 #define FETCH_WCB(window,cbname) \
436 ((window).CallBacks[CB_ ## cbname])
439 * INVOKE_WCB() is used as:
441 * INVOKE_WCB( window, cbname, ( arg_list ) );
443 * ...where {window} is the freeglut window,
444 * {cbname} is the window-specific callback to be invoked,
445 * {(arg_list)} is the parameter list.
447 * The callback is invoked as:
449 * callback( arg_list );
451 * ...so the parentheses are REQUIRED in the {arg_list}.
453 * NOTE that it does a sanity-check and also sets the
457 #if TARGET_HOST_MS_WINDOWS && !defined(_WIN32_WCE) /* FIXME: also WinCE? */
458 #define INVOKE_WCB(window,cbname,arg_list) \
461 if( FETCH_WCB( window, cbname ) ) \
463 FGCB ## cbname func = (FGCB ## cbname)(FETCH_WCB( window, cbname )); \
464 fgSetWindow( &window ); \
469 #define INVOKE_WCB(window,cbname,arg_list) \
472 if( FETCH_WCB( window, cbname ) ) \
474 fgSetWindow( &window ); \
475 ((FGCB ## cbname)FETCH_WCB( window, cbname )) arg_list; \
481 * The window callbacks the user can supply us with. Should be kept portable.
483 * This enumeration provides the freeglut CallBack numbers.
484 * The symbolic constants are indices into a window's array of
485 * function callbacks. The names are formed by splicing a common
486 * prefix onto the callback's base name. (This was originally
487 * done so that an early stage of development could live side-by-
488 * side with the old callback code. The old callback code used
489 * the bare callback's name as a structure member, so I used a
490 * prefix for the array index name.)
492 * XXX For consistancy, perhaps the prefix should match the
493 * XXX FETCH* and INVOKE* macro suffices. I.e., WCB_, rather than
520 /* Presently ignored */
523 CB_SpaceMotion, /* presently implemented only on UNIX/X11 */
524 CB_SpaceRotation, /* presently implemented only on UNIX/X11 */
525 CB_SpaceButton, /* presently implemented only on UNIX/X11 */
531 /* Always make this the LAST one */
536 /* This structure holds the OpenGL rendering context for all the menu windows */
537 typedef struct tagSFG_MenuContext SFG_MenuContext;
538 struct tagSFG_MenuContext
540 SFG_WindowContextType MContext; /* The menu window's WGL context */
543 /* This structure describes a menu */
544 typedef struct tagSFG_Window SFG_Window;
545 typedef struct tagSFG_MenuEntry SFG_MenuEntry;
546 typedef struct tagSFG_Menu SFG_Menu;
550 void *UserData; /* User data passed back at callback */
551 int ID; /* The global menu ID */
552 SFG_List Entries; /* The menu entries list */
553 FGCBMenu Callback; /* The menu callback */
554 FGCBDestroy Destroy; /* Destruction callback */
555 GLboolean IsActive; /* Is the menu selected? */
556 int Width; /* Menu box width in pixels */
557 int Height; /* Menu box height in pixels */
558 int X, Y; /* Menu box raster position */
560 SFG_MenuEntry *ActiveEntry; /* Currently active entry in the menu */
561 SFG_Window *Window; /* Window for menu */
562 SFG_Window *ParentWindow; /* Window in which the menu is invoked */
565 /* This is a menu entry */
566 struct tagSFG_MenuEntry
569 int ID; /* The menu entry ID (local) */
570 int Ordinal; /* The menu's ordinal number */
571 char* Text; /* The text to be displayed */
572 SFG_Menu* SubMenu; /* Optional sub-menu tree */
573 GLboolean IsActive; /* Is the entry highlighted? */
574 int Width; /* Label's width in pixels */
578 * A window, making part of freeglut windows hierarchy.
579 * Should be kept portable.
581 * NOTE that ActiveMenu is set to menu itself if the window is a menu.
586 int ID; /* Window's ID number */
588 SFG_Context Window; /* Window and OpenGL context */
589 SFG_WindowState State; /* The window state */
590 SFG_Proc CallBacks[ TOTAL_CALLBACKS ]; /* Array of window callbacks */
591 void *UserData ; /* For use by user */
593 SFG_Menu* Menu[ FREEGLUT_MAX_MENUS ]; /* Menus appended to window */
594 SFG_Menu* ActiveMenu; /* The window's active menu */
596 SFG_Window* Parent; /* The parent to this window */
597 SFG_List Children; /* The subwindows d.l. list */
599 GLboolean IsMenu; /* Set to 1 if we are a menu */
603 /* A linked list structure of windows */
604 typedef struct tagSFG_WindowList SFG_WindowList ;
605 struct tagSFG_WindowList
611 /* This holds information about all the windows, menus etc. */
612 typedef struct tagSFG_Structure SFG_Structure;
613 struct tagSFG_Structure
615 SFG_List Windows; /* The global windows list */
616 SFG_List Menus; /* The global menus list */
617 SFG_List WindowsToDestroy;
619 SFG_Window* CurrentWindow; /* The currently set window */
620 SFG_Menu* CurrentMenu; /* Same, but menu... */
622 SFG_MenuContext* MenuContext; /* OpenGL rendering context for menus */
624 SFG_Window* GameModeWindow; /* The game mode window */
626 int WindowID; /* The new current window ID */
627 int MenuID; /* The new current menu ID */
631 * This structure is used for the enumeration purposes.
632 * You can easily extend its functionalities by declaring
633 * a structure containing enumerator's contents and custom
634 * data, then casting its pointer to (SFG_Enumerator *).
636 typedef struct tagSFG_Enumerator SFG_Enumerator;
637 struct tagSFG_Enumerator
639 GLboolean found; /* Used to terminate search */
640 void* data; /* Custom data pointer */
642 typedef void (* FGCBenumerator )( SFG_Window *, SFG_Enumerator * );
644 /* The bitmap font structure */
645 typedef struct tagSFG_Font SFG_Font;
648 char* Name; /* The source font name */
649 int Quantity; /* Number of chars in font */
650 int Height; /* Height of the characters */
651 const GLubyte** Characters; /* The characters mapping */
653 float xorig, yorig; /* Relative origin of the character */
656 /* The stroke font structures */
658 typedef struct tagSFG_StrokeVertex SFG_StrokeVertex;
659 struct tagSFG_StrokeVertex
664 typedef struct tagSFG_StrokeStrip SFG_StrokeStrip;
665 struct tagSFG_StrokeStrip
668 const SFG_StrokeVertex* Vertices;
671 typedef struct tagSFG_StrokeChar SFG_StrokeChar;
672 struct tagSFG_StrokeChar
676 const SFG_StrokeStrip* Strips;
679 typedef struct tagSFG_StrokeFont SFG_StrokeFont;
680 struct tagSFG_StrokeFont
682 char* Name; /* The source font name */
683 int Quantity; /* Number of chars in font */
684 GLfloat Height; /* Height of the characters */
685 const SFG_StrokeChar** Characters; /* The characters mapping */
689 /* -- JOYSTICK-SPECIFIC STRUCTURES AND TYPES ------------------------------- */
691 * Initial defines from "js.h" starting around line 33 with the existing "freeglut_joystick.c"
695 #if TARGET_HOST_MACINTOSH
696 # include <InputSprocket.h>
699 #if TARGET_HOST_MAC_OSX
700 # include <mach/mach.h>
701 # include <IOKit/IOkitLib.h>
702 # include <IOKit/hid/IOHIDLib.h>
705 /* XXX It might be better to poll the operating system for the numbers of buttons and
706 * XXX axes and then dynamically allocate the arrays.
708 #define _JS_MAX_BUTTONS 32
710 #if TARGET_HOST_MACINTOSH
711 # define _JS_MAX_AXES 9
712 typedef struct tagSFG_PlatformJoystick SFG_PlatformJoystick;
713 struct tagSFG_PlatformJoystick
715 #define ISP_NUM_AXIS 9
716 #define ISP_NUM_NEEDS 41
717 ISpElementReference isp_elem [ ISP_NUM_NEEDS ];
718 ISpNeed isp_needs [ ISP_NUM_NEEDS ];
722 #if TARGET_HOST_MAC_OSX
723 # define _JS_MAX_AXES 16
724 typedef struct tagSFG_PlatformJoystick SFG_PlatformJoystick;
725 struct tagSFG_PlatformJoystick
727 IOHIDDeviceInterface ** hidDev;
728 IOHIDElementCookie buttonCookies[41];
729 IOHIDElementCookie axisCookies[_JS_MAX_AXES];
730 /* The next two variables are not used anywhere */
731 /* long minReport[_JS_MAX_AXES],
732 * maxReport[_JS_MAX_AXES];
739 * Definition of "SFG_Joystick" structure -- based on JS's "jsJoystick" object class.
740 * See "js.h" lines 80-178.
742 typedef struct tagSFG_Joystick SFG_Joystick;
743 struct tagSFG_Joystick
745 SFG_PlatformJoystick pJoystick;
753 float dead_band[ _JS_MAX_AXES ];
754 float saturate [ _JS_MAX_AXES ];
755 float center [ _JS_MAX_AXES ];
756 float max [ _JS_MAX_AXES ];
757 float min [ _JS_MAX_AXES ];
762 /* -- GLOBAL VARIABLES EXPORTS --------------------------------------------- */
764 /* Freeglut display related stuff (initialized once per session) */
765 extern SFG_Display fgDisplay;
767 /* Freeglut internal structure */
768 extern SFG_Structure fgStructure;
770 /* The current freeglut settings */
771 extern SFG_State fgState;
774 /* -- PRIVATE FUNCTION DECLARATIONS ---------------------------------------- */
777 * A call to this function makes us sure that the Display and Structure
778 * subsystems have been properly initialized and are ready to be used
780 #define FREEGLUT_EXIT_IF_NOT_INITIALISED( string ) \
781 if ( ! fgState.Initialised ) \
783 fgError ( " ERROR: Function <%s> called" \
784 " without first calling 'glutInit'.", (string) ) ; \
787 #define FREEGLUT_INTERNAL_ERROR_EXIT_IF_NOT_INITIALISED( string ) \
788 if ( ! fgState.Initialised ) \
790 fgError ( " ERROR: Internal <%s> function called" \
791 " without first calling 'glutInit'.", (string) ) ; \
794 #define FREEGLUT_INTERNAL_ERROR_EXIT( cond, string, function ) \
797 fgError ( " ERROR: Internal error <%s> in function %s", \
798 (string), (function) ) ; \
802 * Following definitions are somewhat similiar to GLib's,
803 * but do not generate any log messages:
805 #define freeglut_return_if_fail( expr ) \
808 #define freeglut_return_val_if_fail( expr, val ) \
813 * A call to those macros assures us that there is a current
814 * window set, respectively:
816 #define FREEGLUT_EXIT_IF_NO_WINDOW( string ) \
817 if ( ! fgStructure.CurrentWindow && \
818 ( fgState.ActionOnWindowClose != GLUT_ACTION_CONTINUE_EXECUTION ) ) \
820 fgError ( " ERROR: Function <%s> called" \
821 " with no current window defined.", (string) ) ; \
825 * The deinitialize function gets called on glutMainLoop() end. It should clean up
826 * everything inside of the freeglut
828 void fgDeinitialize( void );
831 * Those two functions are used to create/destroy the freeglut internal
832 * structures. This actually happens when calling glutInit() and when
833 * quitting the glutMainLoop() (which actually happens, when all windows
836 void fgCreateStructure( void );
837 void fgDestroyStructure( void );
840 * Window creation, opening, closing and destruction.
841 * Also CallBack clearing/initialization.
842 * Defined in freeglut_structure.c, freeglut_window.c.
844 SFG_Window* fgCreateWindow( SFG_Window* parent, const char* title,
845 GLboolean positionUse, int x, int y,
846 GLboolean sizeUse, int w, int h,
847 GLboolean gameMode, GLboolean isMenu );
848 void fgSetWindow ( SFG_Window *window );
849 void fgOpenWindow( SFG_Window* window, const char* title,
850 GLboolean positionUse, int x, int y,
851 GLboolean sizeUse, int w, int h,
852 GLboolean gameMode, GLboolean isSubWindow );
853 void fgCloseWindow( SFG_Window* window );
854 void fgAddToWindowDestroyList ( SFG_Window* window );
855 void fgCloseWindows ();
856 void fgDestroyWindow( SFG_Window* window );
858 /* Menu creation and destruction. Defined in freeglut_structure.c */
859 SFG_Menu* fgCreateMenu( FGCBMenu menuCallback );
860 void fgDestroyMenu( SFG_Menu* menu );
862 /* Joystick device management functions, defined in freeglut_joystick.c */
863 int fgJoystickDetect( void );
864 void fgInitialiseJoysticks( void );
865 void fgJoystickClose( void );
866 void fgJoystickPollWindow( SFG_Window* window );
868 /* InputDevice Initialisation and Closure */
869 int fgInputDeviceDetect( void );
870 void fgInitialiseInputDevices( void );
871 void fgInputDeviceClose( void );
873 /* spaceball device functions, defined in freeglut_spaceball.c */
874 void fgInitialiseSpaceball( void );
875 void fgSpaceballClose( void );
876 void fgSpaceballSetWindow( SFG_Window *window );
878 int fgHasSpaceball( void );
879 int fgSpaceballNumButtons( void );
881 /* Setting the cursor for a given window */
882 void fgSetCursor ( SFG_Window *window, int cursorID );
885 * Helper function to enumerate through all registered windows
886 * and one to enumerate all of a window's subwindows...
888 * The GFunc callback for those functions will be defined as:
890 * void enumCallback( gpointer window, gpointer enumerator );
892 * where window is the enumerated (sub)window pointer (SFG_Window *),
893 * and userData is the a custom user-supplied pointer. Functions
894 * are defined and exported from freeglut_structure.c file.
896 void fgEnumWindows( FGCBenumerator enumCallback, SFG_Enumerator* enumerator );
897 void fgEnumSubWindows( SFG_Window* window, FGCBenumerator enumCallback,
898 SFG_Enumerator* enumerator );
901 * fgWindowByHandle returns a (SFG_Window *) value pointing to the
902 * first window in the queue matching the specified window handle.
903 * The function is defined in freeglut_structure.c file.
905 SFG_Window* fgWindowByHandle( SFG_WindowHandleType hWindow );
908 * This function is similiar to the previous one, except it is
909 * looking for a specified (sub)window identifier. The function
910 * is defined in freeglut_structure.c file.
912 SFG_Window* fgWindowByID( int windowID );
915 * Looks up a menu given its ID. This is easier than fgWindowByXXX
916 * as all menus are placed in a single doubly linked list...
918 SFG_Menu* fgMenuByID( int menuID );
921 * The menu activation and deactivation the code. This is the meat
922 * of the menu user interface handling code...
924 void fgUpdateMenuHighlight ( SFG_Menu *menu );
925 GLboolean fgCheckActiveMenu ( SFG_Window *window, int button, GLboolean pressed,
926 int mouse_x, int mouse_y );
927 void fgDeactivateMenu( SFG_Window *window );
930 * This function gets called just before the buffers swap, so that
931 * freeglut can display the pull-down menus via OpenGL. The function
932 * is defined in freeglut_menu.c file.
934 void fgDisplayMenu( void );
936 /* Elapsed time as per glutGet(GLUT_ELAPSED_TIME). */
937 fg_time_t fgElapsedTime( void );
939 /* System time in milliseconds */
940 fg_time_t fgSystemTime(void);
943 void fgListInit(SFG_List *list);
944 void fgListAppend(SFG_List *list, SFG_Node *node);
945 void fgListRemove(SFG_List *list, SFG_Node *node);
946 int fgListLength(SFG_List *list);
947 void fgListInsert(SFG_List *list, SFG_Node *next, SFG_Node *node);
949 /* Error Message functions */
950 void fgError( const char *fmt, ... );
951 void fgWarning( const char *fmt, ... );
953 SFG_Proc fgPlatformGetProcAddress( const char *procName );
955 /* pushing attribute/value pairs into an array */
956 #define ATTRIB(a) attributes[where++]=(a)
957 #define ATTRIB_VAL(a,v) {ATTRIB(a); ATTRIB(v);}
959 int fghIsLegacyContextVersionRequested( void );
960 int fghMapBit( int mask, int from, int to );
961 int fghIsLegacyContextRequested( void );
962 void fghContextCreationError( void );
963 int fghNumberOfAuxBuffersRequested( void );
965 #endif /* FREEGLUT_INTERNAL_H */
967 /*** END OF FILE ***/