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 # define __fg_unused __attribute__((unused))
177 /* Platform-specific includes */
178 #if TARGET_HOST_POSIX_X11
179 #include "x11/fg_internal_x11.h"
181 #if TARGET_HOST_MS_WINDOWS
182 #include "mswin/fg_internal_mswin.h"
184 #if TARGET_HOST_ANDROID
185 #include "android/fg_internal_android.h"
189 /* -- GLOBAL TYPE DEFINITIONS ---------------------------------------------- */
191 /* Freeglut callbacks type definitions */
192 typedef void (* FGCBDisplay )( void );
193 typedef void (* FGCBReshape )( int, int );
194 typedef void (* FGCBPosition )( int, int );
195 typedef void (* FGCBVisibility )( int );
196 typedef void (* FGCBKeyboard )( unsigned char, int, int );
197 typedef void (* FGCBKeyboardUp )( unsigned char, int, int );
198 typedef void (* FGCBSpecial )( int, int, int );
199 typedef void (* FGCBSpecialUp )( int, int, int );
200 typedef void (* FGCBMouse )( int, int, int, int );
201 typedef void (* FGCBMouseWheel )( int, int, int, int );
202 typedef void (* FGCBMotion )( int, int );
203 typedef void (* FGCBPassive )( int, int );
204 typedef void (* FGCBEntry )( int );
205 typedef void (* FGCBWindowStatus )( int );
206 typedef void (* FGCBJoystick )( unsigned int, int, int, int );
207 typedef void (* FGCBOverlayDisplay)( void );
208 typedef void (* FGCBSpaceMotion )( int, int, int );
209 typedef void (* FGCBSpaceRotation )( int, int, int );
210 typedef void (* FGCBSpaceButton )( int, int );
211 typedef void (* FGCBDials )( int, int );
212 typedef void (* FGCBButtonBox )( int, int );
213 typedef void (* FGCBTabletMotion )( int, int );
214 typedef void (* FGCBTabletButton )( int, int, int, int );
215 typedef void (* FGCBDestroy )( void ); /* Used for both window and menu destroy callbacks */
217 typedef void (* FGCBMultiEntry )( int, int );
218 typedef void (* FGCBMultiButton )( int, int, int, int, int );
219 typedef void (* FGCBMultiMotion )( int, int, int );
220 typedef void (* FGCBMultiPassive )( int, int, int );
222 typedef void (* FGCBInitContext)();
223 typedef void (* FGCBAppStatus)(int);
225 /* The global callbacks type definitions */
226 typedef void (* FGCBIdle )( void );
227 typedef void (* FGCBTimer )( int );
228 typedef void (* FGCBMenuState )( int );
229 typedef void (* FGCBMenuStatus )( int, int, int );
231 /* The callback used when creating/using menus */
232 typedef void (* FGCBMenu )( int );
234 /* The FreeGLUT error/warning handler type definition */
235 typedef void (* FGError ) ( const char *fmt, va_list ap);
236 typedef void (* FGWarning ) ( const char *fmt, va_list ap);
239 /* A list structure */
240 typedef struct tagSFG_List SFG_List;
247 /* A list node structure */
248 typedef struct tagSFG_Node SFG_Node;
255 /* A helper structure holding two ints and a boolean */
256 typedef struct tagSFG_XYUse SFG_XYUse;
259 GLint X, Y; /* The two integers... */
260 GLboolean Use; /* ...and a single boolean. */
264 * An enumeration containing the state of the GLUT execution:
265 * initializing, running, or stopping
269 GLUT_EXEC_STATE_INIT,
270 GLUT_EXEC_STATE_RUNNING,
274 /* This structure holds different freeglut settings */
275 typedef struct tagSFG_State SFG_State;
278 SFG_XYUse Position; /* The default windows' position */
279 SFG_XYUse Size; /* The default windows' size */
280 unsigned int DisplayMode; /* Display mode for new windows */
282 GLboolean Initialised; /* freeglut has been initialised */
284 int DirectContext; /* Direct rendering state */
286 GLboolean ForceIconic; /* New top windows are iconified */
287 GLboolean UseCurrentContext; /* New windows share with current */
289 GLboolean GLDebugSwitch; /* OpenGL state debugging switch */
290 GLboolean XSyncSwitch; /* X11 sync protocol switch */
292 int KeyRepeat; /* Global key repeat mode. */
293 int Modifiers; /* Current ALT/SHIFT/CTRL state */
295 GLuint FPSInterval; /* Interval between FPS printfs */
296 GLuint SwapCount; /* Count of glutSwapBuffer calls */
297 GLuint SwapTime; /* Time of last SwapBuffers */
299 fg_time_t Time; /* Time that glutInit was called */
300 SFG_List Timers; /* The freeglut timer hooks */
301 SFG_List FreeTimers; /* The unused timer hooks */
303 FGCBIdle IdleCallback; /* The global idle callback */
305 int ActiveMenus; /* Num. of currently active menus */
306 FGCBMenuState MenuStateCallback; /* Menu callbacks are global */
307 FGCBMenuStatus MenuStatusCallback;
308 void* MenuFont; /* Font to be used for newly created menus */
310 SFG_XYUse GameModeSize; /* Game mode screen's dimensions */
311 int GameModeDepth; /* The pixel depth for game mode */
312 int GameModeRefresh; /* The refresh rate for game mode */
314 int ActionOnWindowClose; /* Action when user closes window */
316 fgExecutionState ExecState; /* Used for GLUT termination */
317 char *ProgramName; /* Name of the invoking program */
318 GLboolean JoysticksInitialised; /* Only initialize if application calls for them */
319 int NumActiveJoysticks; /* Number of active joysticks (callback defined and positive pollrate) -- if zero, don't poll joysticks */
320 GLboolean InputDevsInitialised; /* Only initialize if application calls for them */
322 int MouseWheelTicks; /* Number of ticks the mouse wheel has turned */
324 int AuxiliaryBufferNumber; /* Number of auxiliary buffers */
325 int SampleNumber; /* Number of samples per pixel */
327 GLboolean SkipStaleMotion; /* skip stale motion events */
329 int MajorVersion; /* Major OpenGL context version */
330 int MinorVersion; /* Minor OpenGL context version */
331 int ContextFlags; /* OpenGL context flags */
332 int ContextProfile; /* OpenGL context profile */
333 int HasOpenGL20; /* fgInitGL2 could find all OpenGL 2.0 functions */
334 FGError ErrorFunc; /* User defined error handler */
335 FGWarning WarningFunc; /* User defined warning handler */
338 /* The structure used by display initialization in freeglut_init.c */
339 typedef struct tagSFG_Display SFG_Display;
340 struct tagSFG_Display
342 SFG_PlatformDisplay pDisplay;
344 int ScreenWidth; /* The screen's width in pixels */
345 int ScreenHeight; /* The screen's height in pixels */
346 int ScreenWidthMM; /* The screen's width in milimeters */
347 int ScreenHeightMM; /* The screen's height in milimeters */
351 /* The user can create any number of timer hooks */
352 typedef struct tagSFG_Timer SFG_Timer;
356 int ID; /* The timer ID integer */
357 FGCBTimer Callback; /* The timer callback */
358 fg_time_t TriggerTime; /* The timer trigger time */
362 * A window and its OpenGL context. The contents of this structure
363 * are highly dependant on the target operating system we aim at...
365 typedef struct tagSFG_Context SFG_Context;
366 struct tagSFG_Context
368 SFG_WindowHandleType Handle; /* The window's handle */
369 SFG_WindowContextType Context; /* The window's OpenGL/WGL context */
371 SFG_PlatformContext pContext; /* The window's FBConfig (X11) or device context (Windows) */
373 int DoubleBuffered; /* Treat the window as double-buffered */
375 /* When drawing geometry to vertex attribute buffers, user specifies
376 * the attribute indices for vertices, normals and/or texture coords
377 * to freeglut. Those are stored here
379 GLint attribute_v_coord;
380 GLint attribute_v_normal;
381 GLint attribute_v_texture;
386 * Bitmasks indicating the different kinds of
387 * actions that can be scheduled for a window.
389 #define GLUT_INIT_WORK (1<<0)
390 #define GLUT_VISIBILITY_WORK (1<<1)
391 #define GLUT_POSITION_WORK (1<<2)
392 #define GLUT_SIZE_WORK (1<<3)
393 #define GLUT_ZORDER_WORK (1<<4)
394 #define GLUT_FULL_SCREEN_WORK (1<<5)
395 #define GLUT_DISPLAY_WORK (1<<6)
398 * An enumeration containing the state of the GLUT execution:
399 * initializing, running, or stopping
406 } fgDesiredVisibility ;
409 * There is considerable confusion about the "right thing to
410 * do" concerning window size and position. GLUT itself is
411 * not consistent between Windows and UNIX/X11; since
412 * platform independence is a virtue for "freeglut", we
413 * decided to break with GLUT's behaviour.
415 * Under UNIX/X11, it is apparently not possible to get the
416 * window border sizes in order to subtract them off the
417 * window's initial position until some time after the window
418 * has been created. Therefore we decided on the following
419 * behaviour, both under Windows and under UNIX/X11:
420 * - When you create a window with position (x,y) and size
421 * (w,h), the upper left hand corner of the outside of the
422 * window is at (x,y) and the size of the drawable area is
424 * - When you query the size and position of the window--as
425 * is happening here for Windows--"freeglut" will return
426 * the size of the drawable area--the (w,h) that you
427 * specified when you created the window--and the coordinates
428 * of the upper left hand corner of the drawable area, i.e.
429 * of the client rect--which is NOT the (x,y) you specified.
431 typedef struct tagSFG_WindowState SFG_WindowState;
432 struct tagSFG_WindowState /* as per notes above, sizes always refer to the client area (thus without the window decorations) */
434 /* window state - size, position, look */
435 int Xpos; /* Window's top-left of client area, X-coordinate */
436 int Ypos; /* Window's top-left of client area, Y-coordinate */
437 int Width; /* Window's width in pixels */
438 int Height; /* The same about the height */
439 GLboolean Visible; /* Is the window visible now? Not using fgVisibilityState as we only care if visible or not */
440 int Cursor; /* The currently selected cursor style */
441 GLboolean IsFullscreen; /* is the window fullscreen? */
443 /* FreeGLUT operations are deferred, that is, window moving, resizing,
444 * Z-order changing, making full screen or not do not happen immediately
445 * upon the user's request, but only in the next iteration of the main
446 * loop, before the display callback is called. This allows multiple
447 * reshape, position, etc requests to be combined into one and is
448 * compatible with the way GLUT does things. Callbacks get triggered
449 * based on the feedback/messages/notifications from the window manager.
450 * Below here we define what work should be done, as well as the relevant
451 * parameters for this work.
453 unsigned int WorkMask; /* work (resize, etc) to be done on the window */
454 int DesiredXpos; /* desired X location */
455 int DesiredYpos; /* desired Y location */
456 int DesiredWidth; /* desired window width */
457 int DesiredHeight; /* desired window height */
458 int DesiredZOrder; /* desired window Z Order position */
459 fgDesiredVisibility DesiredVisibility;/* desired visibility (hidden, iconic, shown/normal) */
461 SFG_PlatformWindowState pWState; /* Window width/height (X11) or rectangle/style (Windows) from before a resize, and other stuff only needed on specific platforms */
463 long JoystickPollRate; /* The joystick polling rate */
464 fg_time_t JoystickLastPoll; /* When the last poll happened */
466 int MouseX, MouseY; /* The most recent mouse position */
468 GLboolean IgnoreKeyRepeat; /* Whether to ignore key repeat. */
470 GLboolean VisualizeNormals; /* When drawing objects, draw vectors representing the normals as well? */
475 * A generic function pointer. We should really use the GLUTproc type
476 * defined in freeglut_ext.h, but if we include that header in this file
477 * a bunch of other stuff (font-related) blows up!
479 typedef void (*SFG_Proc)();
483 * SET_WCB() is used as:
485 * SET_WCB( window, cbname, func );
487 * ...where {window} is the freeglut window to set the callback,
488 * {cbname} is the window-specific callback to set,
489 * {func} is a function-pointer.
491 * Originally, {FETCH_WCB( ... ) = func} was rather sloppily used,
492 * but this can cause warnings because the FETCH_WCB() macro type-
493 * casts its result, and a type-cast value shouldn't be an lvalue.
495 * The {if( FETCH_WCB( ... ) != func )} test is to do type-checking
496 * and for no other reason. Since it's hidden in the macro, the
497 * ugliness is felt to be rather benign.
499 #define SET_WCB(window,cbname,func) \
502 if( FETCH_WCB( window, cbname ) != (SFG_Proc)(func) ) \
503 (((window).CallBacks[WCB_ ## cbname]) = (SFG_Proc)(func)); \
507 * FETCH_WCB() is used as:
509 * FETCH_WCB( window, cbname );
511 * ...where {window} is the freeglut window to fetch the callback from,
512 * {cbname} is the window-specific callback to fetch.
514 * The result is correctly type-cast to the callback function pointer
517 #define FETCH_WCB(window,cbname) \
518 ((window).CallBacks[WCB_ ## cbname])
521 * INVOKE_WCB() is used as:
523 * INVOKE_WCB( window, cbname, ( arg_list ) );
525 * ...where {window} is the freeglut window,
526 * {cbname} is the window-specific callback to be invoked,
527 * {(arg_list)} is the parameter list.
529 * The callback is invoked as:
531 * callback( arg_list );
533 * ...so the parentheses are REQUIRED in the {arg_list}.
535 * NOTE that it does a sanity-check and also sets the
539 #if TARGET_HOST_MS_WINDOWS && !defined(_WIN32_WCE) /* FIXME: also WinCE? */
540 #define INVOKE_WCB(window,cbname,arg_list) \
543 if( FETCH_WCB( window, cbname ) ) \
545 FGCB ## cbname func = (FGCB ## cbname)(FETCH_WCB( window, cbname )); \
546 fgSetWindow( &window ); \
551 #define INVOKE_WCB(window,cbname,arg_list) \
554 if( FETCH_WCB( window, cbname ) ) \
556 fgSetWindow( &window ); \
557 ((FGCB ## cbname)FETCH_WCB( window, cbname )) arg_list; \
563 * The window callbacks the user can supply us with. Should be kept portable.
565 * This enumeration provides the freeglut CallBack numbers.
566 * The symbolic constants are indices into a window's array of
567 * function callbacks. The names are formed by splicing a common
568 * prefix onto the callback's base name. (This was originally
569 * done so that an early stage of development could live side-by-
570 * side with the old callback code. The old callback code used
571 * the bare callback's name as a structure member, so I used a
572 * prefix for the array index name.)
593 /* Multi-Pointer X and touch related */
599 /* Mobile platforms LifeCycle */
603 /* Presently ignored */
606 WCB_SpaceMotion, /* presently implemented only on UNIX/X11 */
607 WCB_SpaceRotation, /* presently implemented only on UNIX/X11 */
608 WCB_SpaceButton, /* presently implemented only on UNIX/X11 */
614 /* Always make this the LAST one */
619 /* This structure holds the OpenGL rendering context for all the menu windows */
620 typedef struct tagSFG_MenuContext SFG_MenuContext;
621 struct tagSFG_MenuContext
623 SFG_WindowContextType MContext; /* The menu window's WGL context */
626 /* This structure describes a menu */
627 typedef struct tagSFG_Window SFG_Window;
628 typedef struct tagSFG_MenuEntry SFG_MenuEntry;
629 typedef struct tagSFG_Menu SFG_Menu;
633 void *UserData; /* User data passed back at callback */
634 int ID; /* The global menu ID */
635 SFG_List Entries; /* The menu entries list */
636 FGCBMenu Callback; /* The menu callback */
637 FGCBDestroy Destroy; /* Destruction callback */
638 GLboolean IsActive; /* Is the menu selected? */
639 void* Font; /* Font to be used for displaying this menu */
640 int Width; /* Menu box width in pixels */
641 int Height; /* Menu box height in pixels */
642 int X, Y; /* Menu box raster position */
644 SFG_MenuEntry *ActiveEntry; /* Currently active entry in the menu */
645 SFG_Window *Window; /* Window for menu */
646 SFG_Window *ParentWindow; /* Window in which the menu is invoked */
649 /* This is a menu entry */
650 struct tagSFG_MenuEntry
653 int ID; /* The menu entry ID (local) */
654 int Ordinal; /* The menu's ordinal number */
655 char* Text; /* The text to be displayed */
656 SFG_Menu* SubMenu; /* Optional sub-menu tree */
657 GLboolean IsActive; /* Is the entry highlighted? */
658 int Width; /* Label's width in pixels */
662 * A window, making part of freeglut windows hierarchy.
663 * Should be kept portable.
665 * NOTE that ActiveMenu is set to menu itself if the window is a menu.
670 int ID; /* Window's ID number */
672 SFG_Context Window; /* Window and OpenGL context */
673 SFG_WindowState State; /* The window state */
674 SFG_Proc CallBacks[ TOTAL_CALLBACKS ]; /* Array of window callbacks */
675 void *UserData ; /* For use by user */
677 SFG_Menu* Menu[ FREEGLUT_MAX_MENUS ]; /* Menus appended to window */
678 SFG_Menu* ActiveMenu; /* The window's active menu */
680 SFG_Window* Parent; /* The parent to this window */
681 SFG_List Children; /* The subwindows d.l. list */
683 GLboolean IsMenu; /* Set to 1 if we are a menu */
687 /* A linked list structure of windows */
688 typedef struct tagSFG_WindowList SFG_WindowList ;
689 struct tagSFG_WindowList
695 /* This holds information about all the windows, menus etc. */
696 typedef struct tagSFG_Structure SFG_Structure;
697 struct tagSFG_Structure
699 SFG_List Windows; /* The global windows list */
700 SFG_List Menus; /* The global menus list */
701 SFG_List WindowsToDestroy;
703 SFG_Window* CurrentWindow; /* The currently set window */
704 SFG_Menu* CurrentMenu; /* Same, but menu... */
706 SFG_MenuContext* MenuContext; /* OpenGL rendering context for menus */
708 SFG_Window* GameModeWindow; /* The game mode window */
710 int WindowID; /* The window ID for the next window to be created */
711 int MenuID; /* The menu ID for the next menu to be created */
715 * This structure is used for the enumeration purposes.
716 * You can easily extend its functionalities by declaring
717 * a structure containing enumerator's contents and custom
718 * data, then casting its pointer to (SFG_Enumerator *).
720 typedef struct tagSFG_Enumerator SFG_Enumerator;
721 struct tagSFG_Enumerator
723 GLboolean found; /* Used to terminate search */
724 void* data; /* Custom data pointer */
726 typedef void (* FGCBWindowEnumerator )( SFG_Window *, SFG_Enumerator * );
727 typedef void (* FGCBMenuEnumerator )( SFG_Menu *, SFG_Enumerator * );
729 /* The bitmap font structure */
730 typedef struct tagSFG_Font SFG_Font;
733 char* Name; /* The source font name */
734 int Quantity; /* Number of chars in font */
735 int Height; /* Height of the characters */
736 const GLubyte** Characters; /* The characters mapping */
738 float xorig, yorig; /* Relative origin of the character */
741 /* The stroke font structures */
743 typedef struct tagSFG_StrokeVertex SFG_StrokeVertex;
744 struct tagSFG_StrokeVertex
749 typedef struct tagSFG_StrokeStrip SFG_StrokeStrip;
750 struct tagSFG_StrokeStrip
753 const SFG_StrokeVertex* Vertices;
756 typedef struct tagSFG_StrokeChar SFG_StrokeChar;
757 struct tagSFG_StrokeChar
761 const SFG_StrokeStrip* Strips;
764 typedef struct tagSFG_StrokeFont SFG_StrokeFont;
765 struct tagSFG_StrokeFont
767 char* Name; /* The source font name */
768 int Quantity; /* Number of chars in font */
769 GLfloat Height; /* Height of the characters */
770 const SFG_StrokeChar** Characters; /* The characters mapping */
774 /* -- JOYSTICK-SPECIFIC STRUCTURES AND TYPES ------------------------------- */
776 * Initial defines from "js.h" starting around line 33 with the existing "freeglut_joystick.c"
780 #if TARGET_HOST_MACINTOSH
781 # include <InputSprocket.h>
784 #if TARGET_HOST_MAC_OSX
785 # include <mach/mach.h>
786 # include <IOKit/IOkitLib.h>
787 # include <IOKit/hid/IOHIDLib.h>
790 /* XXX It might be better to poll the operating system for the numbers of buttons and
791 * XXX axes and then dynamically allocate the arrays.
793 #define _JS_MAX_BUTTONS 32
795 #if TARGET_HOST_MACINTOSH
796 # define _JS_MAX_AXES 9
797 typedef struct tagSFG_PlatformJoystick SFG_PlatformJoystick;
798 struct tagSFG_PlatformJoystick
800 #define ISP_NUM_AXIS 9
801 #define ISP_NUM_NEEDS 41
802 ISpElementReference isp_elem [ ISP_NUM_NEEDS ];
803 ISpNeed isp_needs [ ISP_NUM_NEEDS ];
807 #if TARGET_HOST_MAC_OSX
808 # define _JS_MAX_AXES 16
809 typedef struct tagSFG_PlatformJoystick SFG_PlatformJoystick;
810 struct tagSFG_PlatformJoystick
812 IOHIDDeviceInterface ** hidDev;
813 IOHIDElementCookie buttonCookies[41];
814 IOHIDElementCookie axisCookies[_JS_MAX_AXES];
815 /* The next two variables are not used anywhere */
816 /* long minReport[_JS_MAX_AXES],
817 * maxReport[_JS_MAX_AXES];
824 * Definition of "SFG_Joystick" structure -- based on JS's "jsJoystick" object class.
825 * See "js.h" lines 80-178.
827 typedef struct tagSFG_Joystick SFG_Joystick;
828 struct tagSFG_Joystick
830 SFG_PlatformJoystick pJoystick;
838 float dead_band[ _JS_MAX_AXES ];
839 float saturate [ _JS_MAX_AXES ];
840 float center [ _JS_MAX_AXES ];
841 float max [ _JS_MAX_AXES ];
842 float min [ _JS_MAX_AXES ];
847 /* -- GLOBAL VARIABLES EXPORTS --------------------------------------------- */
849 /* Freeglut display related stuff (initialized once per session) */
850 extern SFG_Display fgDisplay;
852 /* Freeglut internal structure */
853 extern SFG_Structure fgStructure;
855 /* The current freeglut settings */
856 extern SFG_State fgState;
859 /* -- PRIVATE FUNCTION DECLARATIONS ---------------------------------------- */
862 * A call to this function makes us sure that the Display and Structure
863 * subsystems have been properly initialized and are ready to be used
865 #define FREEGLUT_EXIT_IF_NOT_INITIALISED( string ) \
866 if ( ! fgState.Initialised ) \
868 fgError ( " ERROR: Function <%s> called" \
869 " without first calling 'glutInit'.", (string) ) ; \
872 #define FREEGLUT_INTERNAL_ERROR_EXIT_IF_NOT_INITIALISED( string ) \
873 if ( ! fgState.Initialised ) \
875 fgError ( " ERROR: Internal <%s> function called" \
876 " without first calling 'glutInit'.", (string) ) ; \
879 #define FREEGLUT_INTERNAL_ERROR_EXIT( cond, string, function ) \
882 fgError ( " ERROR: Internal error <%s> in function %s", \
883 (string), (function) ) ; \
887 * Following definitions are somewhat similiar to GLib's,
888 * but do not generate any log messages:
890 #define freeglut_return_if_fail( expr ) \
893 #define freeglut_return_val_if_fail( expr, val ) \
898 * A call to those macros assures us that there is a current
899 * window set, respectively:
901 #define FREEGLUT_EXIT_IF_NO_WINDOW( string ) \
902 if ( ! fgStructure.CurrentWindow && \
903 ( fgState.ActionOnWindowClose != GLUT_ACTION_CONTINUE_EXECUTION ) ) \
905 fgError ( " ERROR: Function <%s> called" \
906 " with no current window defined.", (string) ) ; \
910 * The deinitialize function gets called on glutMainLoop() end. It should clean up
911 * everything inside of the freeglut
913 void fgDeinitialize( void );
916 * Those two functions are used to create/destroy the freeglut internal
917 * structures. This actually happens when calling glutInit() and when
918 * quitting the glutMainLoop() (which actually happens, when all windows
921 void fgCreateStructure( void );
922 void fgDestroyStructure( void );
925 * Window creation, opening, closing and destruction.
926 * Also CallBack clearing/initialization.
927 * Defined in freeglut_structure.c, freeglut_window.c.
929 SFG_Window* fgCreateWindow( SFG_Window* parent, const char* title,
930 GLboolean positionUse, int x, int y,
931 GLboolean sizeUse, int w, int h,
932 GLboolean gameMode, GLboolean isMenu );
933 void fgSetWindow ( SFG_Window *window );
934 void fgOpenWindow( SFG_Window* window, const char* title,
935 GLboolean positionUse, int x, int y,
936 GLboolean sizeUse, int w, int h,
937 GLboolean gameMode, GLboolean isSubWindow );
938 void fgCloseWindow( SFG_Window* window );
939 void fgAddToWindowDestroyList ( SFG_Window* window );
940 void fgCloseWindows ();
941 void fgDestroyWindow( SFG_Window* window );
943 /* Menu creation and destruction. Defined in freeglut_structure.c */
944 SFG_Menu* fgCreateMenu( FGCBMenu menuCallback );
945 void fgDestroyMenu( SFG_Menu* menu );
947 /* Joystick device management functions, defined in freeglut_joystick.c */
948 int fgJoystickDetect( void );
949 void fgInitialiseJoysticks( void );
950 void fgJoystickClose( void );
951 void fgJoystickPollWindow( SFG_Window* window );
953 /* InputDevice Initialisation and Closure */
954 int fgInputDeviceDetect( void );
955 void fgInitialiseInputDevices( void );
956 void fgInputDeviceClose( void );
958 /* spaceball device functions, defined in freeglut_spaceball.c */
959 void fgInitialiseSpaceball( void );
960 void fgSpaceballClose( void );
961 void fgSpaceballSetWindow( SFG_Window *window );
963 int fgHasSpaceball( void );
964 int fgSpaceballNumButtons( void );
966 /* Setting the cursor for a given window */
967 void fgSetCursor ( SFG_Window *window, int cursorID );
970 * Helper function to enumerate through all registered windows
971 * and one to enumerate all of a window's subwindows...
973 * The GFunc callback for those functions will be defined as:
975 * void enumCallback( gpointer window, gpointer enumerator );
977 * where window is the enumerated (sub)window pointer (SFG_Window *),
978 * and userData is the a custom user-supplied pointer. Functions
979 * are defined and exported from freeglut_structure.c file.
981 void fgEnumWindows( FGCBWindowEnumerator enumCallback, SFG_Enumerator* enumerator );
982 void fgEnumSubWindows( SFG_Window* window, FGCBWindowEnumerator enumCallback,
983 SFG_Enumerator* enumerator );
986 * fgWindowByHandle returns a (SFG_Window *) value pointing to the
987 * first window in the queue matching the specified window handle.
988 * The function is defined in freeglut_structure.c file.
990 SFG_Window* fgWindowByHandle( SFG_WindowHandleType hWindow );
993 * This function is similiar to the previous one, except it is
994 * looking for a specified (sub)window identifier. The function
995 * is defined in freeglut_structure.c file.
997 SFG_Window* fgWindowByID( int windowID );
1000 * Looks up a menu given its ID. This is easier than fgWindowByXXX
1001 * as all menus are placed in a single doubly linked list...
1003 SFG_Menu* fgMenuByID( int menuID );
1006 * Returns active menu, if any. Assumption: only one menu active throughout application at any one time.
1007 * This is easier than fgWindowByXXX as all menus are placed in one doubly linked list...
1009 SFG_Menu* fgGetActiveMenu( );
1012 * The menu activation and deactivation the code. This is the meat
1013 * of the menu user interface handling code...
1015 void fgUpdateMenuHighlight ( SFG_Menu *menu );
1016 GLboolean fgCheckActiveMenu ( SFG_Window *window, int button, GLboolean pressed,
1017 int mouse_x, int mouse_y );
1018 void fgDeactivateMenu( SFG_Window *window );
1021 * This function gets called just before the buffers swap, so that
1022 * freeglut can display the pull-down menus via OpenGL. The function
1023 * is defined in freeglut_menu.c file.
1025 void fgDisplayMenu( void );
1027 /* Elapsed time as per glutGet(GLUT_ELAPSED_TIME). */
1028 fg_time_t fgElapsedTime( void );
1030 /* System time in milliseconds */
1031 fg_time_t fgSystemTime(void);
1033 /* List functions */
1034 void fgListInit(SFG_List *list);
1035 void fgListAppend(SFG_List *list, SFG_Node *node);
1036 void fgListRemove(SFG_List *list, SFG_Node *node);
1037 int fgListLength(SFG_List *list);
1038 void fgListInsert(SFG_List *list, SFG_Node *next, SFG_Node *node);
1040 /* Error Message functions */
1041 void fgError( const char *fmt, ... );
1042 void fgWarning( const char *fmt, ... );
1044 SFG_Proc fgPlatformGetProcAddress( const char *procName );
1046 /* pushing attribute/value pairs into an array */
1047 #define ATTRIB(a) attributes[where++]=(a)
1048 #define ATTRIB_VAL(a,v) {ATTRIB(a); ATTRIB(v);}
1050 int fghMapBit( int mask, int from, int to );
1051 int fghIsLegacyContextRequested( void );
1052 void fghContextCreationError( void );
1053 int fghNumberOfAuxBuffersRequested( void );
1055 #endif /* FREEGLUT_INTERNAL_H */
1057 /*** END OF FILE ***/