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