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 2
\r
37 #define VERSION_MINOR 7
\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 /* -- PLATFORM-SPECIFIC INCLUDES ------------------------------------------- */
\r
91 /* All Win32 headers depend on the huge windows.h recursive include.
\r
92 * Note: Lower-case header names are used, for best cross-platform
\r
95 #if TARGET_HOST_MS_WINDOWS && !defined(_WIN32_WCE)
\r
96 # include <windows.h>
\r
97 # include <windowsx.h>
\r
98 # include <mmsystem.h>
\r
99 /* CYGWIN does not have tchar.h, but has TEXT(x), defined in winnt.h. */
\r
100 # ifndef __CYGWIN__
\r
101 # include <tchar.h>
\r
103 # define _TEXT(x) TEXT(x)
\r
104 # define _T(x) TEXT(x)
\r
107 #elif TARGET_HOST_POSIX_X11
\r
108 # include <GL/glx.h>
\r
109 # include <X11/Xlib.h>
\r
110 # include <X11/Xatom.h>
\r
111 # include <X11/keysym.h>
\r
112 # include <X11/extensions/XInput.h>
\r
113 # ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H
\r
114 # include <X11/extensions/xf86vmode.h>
\r
116 # ifdef HAVE_X11_EXTENSIONS_XRANDR_H
\r
117 # include <X11/extensions/Xrandr.h>
\r
119 /* If GLX is too old, we will fail during runtime when multisampling
\r
120 is requested, but at least freeglut compiles. */
\r
121 # ifndef GLX_SAMPLE_BUFFERS
\r
122 # define GLX_SAMPLE_BUFFERS 0x80A8
\r
124 # ifndef GLX_SAMPLES
\r
125 # define GLX_SAMPLES 0x80A9
\r
130 /* These files should be available on every platform. */
\r
132 #include <string.h>
\r
134 #include <stdlib.h>
\r
135 #include <stdarg.h>
\r
137 /* These are included based on autoconf directives. */
\r
138 #ifdef HAVE_SYS_TYPES_H
\r
139 # include <sys/types.h>
\r
141 #ifdef HAVE_UNISTD_H
\r
142 # include <unistd.h>
\r
144 #ifdef TIME_WITH_SYS_TIME
\r
145 # include <sys/time.h>
\r
147 #elif defined(HAVE_SYS_TIME_H)
\r
148 # include <sys/time.h>
\r
153 /* -- AUTOCONF HACKS --------------------------------------------------------*/
\r
155 /* XXX: Update autoconf to avoid these.
\r
156 * XXX: Are non-POSIX platforms intended not to use autoconf?
\r
157 * If so, perhaps there should be a config_guess.h for them. Alternatively,
\r
158 * config guesses could be placed above, just after the config.h exclusion.
\r
160 #if defined(__FreeBSD__) || defined(__NetBSD__)
\r
161 # define HAVE_USB_JS 1
\r
162 # if defined(__NetBSD__) || ( defined(__FreeBSD__) && __FreeBSD_version >= 500000)
\r
163 # define HAVE_USBHID_H 1
\r
167 #if TARGET_HOST_MS_WINDOWS
\r
168 # define HAVE_VFPRINTF 1
\r
171 /* MinGW may lack a prototype for ChangeDisplaySettingsEx() (depending on the version?) */
\r
172 #if TARGET_HOST_MS_WINDOWS && !defined(ChangeDisplaySettingsEx)
\r
173 LONG WINAPI ChangeDisplaySettingsExA(LPCSTR,LPDEVMODEA,HWND,DWORD,LPVOID);
\r
174 LONG WINAPI ChangeDisplaySettingsExW(LPCWSTR,LPDEVMODEW,HWND,DWORD,LPVOID);
\r
176 # define ChangeDisplaySettingsEx ChangeDisplaySettingsExW
\r
178 # define ChangeDisplaySettingsEx ChangeDisplaySettingsExA
\r
182 #if defined(_MSC_VER) || defined(__WATCOMC__)
\r
183 /* strdup() is non-standard, for all but POSIX-2001 */
\r
184 #define strdup _strdup
\r
187 /* M_PI is non-standard (defined by BSD, not ISO-C) */
\r
189 # define M_PI 3.14159265358979323846
\r
192 #ifdef HAVE_STDBOOL_H
\r
193 # include <stdbool.h>
\r
198 # define FALSE false
\r
209 /* General defines */
\r
211 #define INVALID_MODIFIERS 0xffffffff
\r
215 /* Platform-specific includes */
\r
216 #if TARGET_HOST_POSIX_X11
\r
218 typedef struct tagSFG_PlatformDisplay SFG_PlatformDisplay;
\r
219 struct tagSFG_PlatformDisplay
\r
221 Display* Display; /* The display we are being run in. */
\r
222 int Screen; /* The screen we are about to use. */
\r
223 Window RootWindow; /* The screen's root window. */
\r
224 int Connection; /* The display's connection number */
\r
225 Atom DeleteWindow; /* The window deletion atom */
\r
226 Atom State; /* The state atom */
\r
227 Atom StateFullScreen; /* The full screen atom */
\r
229 #ifdef HAVE_X11_EXTENSIONS_XRANDR_H
\r
230 int prev_xsz, prev_ysz;
\r
232 int prev_size_valid;
\r
233 #endif /* HAVE_X11_EXTENSIONS_XRANDR_H */
\r
235 #ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H
\r
237 * XF86VidMode may be compilable even if it fails at runtime. Therefore,
\r
238 * the validity of the VidMode has to be tracked
\r
240 int DisplayModeValid; /* Flag that indicates runtime status*/
\r
241 XF86VidModeModeLine DisplayMode; /* Current screen's display settings */
\r
242 int DisplayModeClock; /* The display mode's refresh rate */
\r
243 int DisplayViewPortX; /* saved X location of the viewport */
\r
244 int DisplayViewPortY; /* saved Y location of the viewport */
\r
245 #endif /* HAVE_X11_EXTENSIONS_XF86VMODE_H */
\r
247 int DisplayPointerX; /* saved X location of the pointer */
\r
248 int DisplayPointerY; /* saved Y location of the pointer */
\r
253 * Make "freeglut" window handle and context types so that we don't need so
\r
254 * much conditionally-compiled code later in the library.
\r
256 typedef Window SFG_WindowHandleType ;
\r
257 typedef GLXContext SFG_WindowContextType ;
\r
258 typedef struct tagSFG_PlatformContext SFG_PlatformContext;
\r
259 struct tagSFG_PlatformContext
\r
261 GLXFBConfig* FBConfig; /* The window's FBConfig */
\r
267 #if TARGET_HOST_MS_WINDOWS
\r
268 #include "../mswin/freeglut_internal_mswin.h"
\r
272 /* -- GLOBAL TYPE DEFINITIONS ---------------------------------------------- */
\r
274 /* Freeglut callbacks type definitions */
\r
275 typedef void (* FGCBDisplay )( void );
\r
276 typedef void (* FGCBReshape )( int, int );
\r
277 typedef void (* FGCBVisibility )( int );
\r
278 typedef void (* FGCBKeyboard )( unsigned char, int, int );
\r
279 typedef void (* FGCBSpecial )( int, int, int );
\r
280 typedef void (* FGCBMouse )( int, int, int, int );
\r
281 typedef void (* FGCBMouseWheel )( int, int, int, int );
\r
282 typedef void (* FGCBMotion )( int, int );
\r
283 typedef void (* FGCBPassive )( int, int );
\r
284 typedef void (* FGCBEntry )( int );
\r
285 typedef void (* FGCBWindowStatus )( int );
\r
286 typedef void (* FGCBSelect )( int, int, int );
\r
287 typedef void (* FGCBJoystick )( unsigned int, int, int, int );
\r
288 typedef void (* FGCBKeyboardUp )( unsigned char, int, int );
\r
289 typedef void (* FGCBSpecialUp )( int, int, int );
\r
290 typedef void (* FGCBOverlayDisplay)( void );
\r
291 typedef void (* FGCBSpaceMotion )( int, int, int );
\r
292 typedef void (* FGCBSpaceRotation )( int, int, int );
\r
293 typedef void (* FGCBSpaceButton )( int, int );
\r
294 typedef void (* FGCBDials )( int, int );
\r
295 typedef void (* FGCBButtonBox )( int, int );
\r
296 typedef void (* FGCBTabletMotion )( int, int );
\r
297 typedef void (* FGCBTabletButton )( int, int, int, int );
\r
298 typedef void (* FGCBDestroy )( void );
\r
300 typedef void (* FGCBMultiEntry )( int, int );
\r
301 typedef void (* FGCBMultiButton )( int, int, int, int, int );
\r
302 typedef void (* FGCBMultiMotion )( int, int, int );
\r
303 typedef void (* FGCBMultiPassive )( int, int, int );
\r
305 /* The global callbacks type definitions */
\r
306 typedef void (* FGCBIdle )( void );
\r
307 typedef void (* FGCBTimer )( int );
\r
308 typedef void (* FGCBMenuState )( int );
\r
309 typedef void (* FGCBMenuStatus )( int, int, int );
\r
311 /* The callback used when creating/using menus */
\r
312 typedef void (* FGCBMenu )( int );
\r
314 /* The FreeGLUT error/warning handler type definition */
\r
315 typedef void (* FGError ) ( const char *fmt, va_list ap);
\r
316 typedef void (* FGWarning ) ( const char *fmt, va_list ap);
\r
319 /* A list structure */
\r
320 typedef struct tagSFG_List SFG_List;
\r
327 /* A list node structure */
\r
328 typedef struct tagSFG_Node SFG_Node;
\r
335 /* A helper structure holding two ints and a boolean */
\r
336 typedef struct tagSFG_XYUse SFG_XYUse;
\r
337 struct tagSFG_XYUse
\r
339 GLint X, Y; /* The two integers... */
\r
340 GLboolean Use; /* ...and a single boolean. */
\r
344 * An enumeration containing the state of the GLUT execution:
\r
345 * initializing, running, or stopping
\r
349 GLUT_EXEC_STATE_INIT,
\r
350 GLUT_EXEC_STATE_RUNNING,
\r
351 GLUT_EXEC_STATE_STOP
\r
352 } fgExecutionState ;
\r
354 /* This structure holds different freeglut settings */
\r
355 typedef struct tagSFG_State SFG_State;
\r
356 struct tagSFG_State
\r
358 SFG_XYUse Position; /* The default windows' position */
\r
359 SFG_XYUse Size; /* The default windows' size */
\r
360 unsigned int DisplayMode; /* Display mode for new windows */
\r
362 GLboolean Initialised; /* freeglut has been initialised */
\r
364 int DirectContext; /* Direct rendering state */
\r
366 GLboolean ForceIconic; /* New top windows are iconified */
\r
367 GLboolean UseCurrentContext; /* New windows share with current */
\r
369 GLboolean GLDebugSwitch; /* OpenGL state debugging switch */
\r
370 GLboolean XSyncSwitch; /* X11 sync protocol switch */
\r
372 int KeyRepeat; /* Global key repeat mode. */
\r
373 int Modifiers; /* Current ALT/SHIFT/CTRL state */
\r
375 GLuint FPSInterval; /* Interval between FPS printfs */
\r
376 GLuint SwapCount; /* Count of glutSwapBuffer calls */
\r
377 GLuint SwapTime; /* Time of last SwapBuffers */
\r
379 unsigned long Time; /* Time that glutInit was called */
\r
380 SFG_List Timers; /* The freeglut timer hooks */
\r
381 SFG_List FreeTimers; /* The unused timer hooks */
\r
383 FGCBIdle IdleCallback; /* The global idle callback */
\r
385 int ActiveMenus; /* Num. of currently active menus */
\r
386 FGCBMenuState MenuStateCallback; /* Menu callbacks are global */
\r
387 FGCBMenuStatus MenuStatusCallback;
\r
389 SFG_XYUse GameModeSize; /* Game mode screen's dimensions */
\r
390 int GameModeDepth; /* The pixel depth for game mode */
\r
391 int GameModeRefresh; /* The refresh rate for game mode */
\r
393 int ActionOnWindowClose; /* Action when user closes window */
\r
395 fgExecutionState ExecState; /* Used for GLUT termination */
\r
396 char *ProgramName; /* Name of the invoking program */
\r
397 GLboolean JoysticksInitialised; /* Only initialize if application calls for them */
\r
398 int NumActiveJoysticks; /* Number of active joysticks -- if zero, don't poll joysticks */
\r
399 GLboolean InputDevsInitialised; /* Only initialize if application calls for them */
\r
401 int MouseWheelTicks; /* Number of ticks the mouse wheel has turned */
\r
403 int AuxiliaryBufferNumber; /* Number of auxiliary buffers */
\r
404 int SampleNumber; /* Number of samples per pixel */
\r
406 int MajorVersion; /* Major OpenGL context version */
\r
407 int MinorVersion; /* Minor OpenGL context version */
\r
408 int ContextFlags; /* OpenGL context flags */
\r
409 int ContextProfile; /* OpenGL context profile */
\r
410 FGError ErrorFunc; /* User defined error handler */
\r
411 FGWarning WarningFunc; /* User defined warning handler */
\r
414 /* The structure used by display initialization in freeglut_init.c */
\r
415 typedef struct tagSFG_Display SFG_Display;
\r
416 struct tagSFG_Display
\r
418 SFG_PlatformDisplay pDisplay;
\r
420 int ScreenWidth; /* The screen's width in pixels */
\r
421 int ScreenHeight; /* The screen's height in pixels */
\r
422 int ScreenWidthMM; /* The screen's width in milimeters */
\r
423 int ScreenHeightMM; /* The screen's height in milimeters */
\r
427 /* The user can create any number of timer hooks */
\r
428 typedef struct tagSFG_Timer SFG_Timer;
\r
429 struct tagSFG_Timer
\r
432 int ID; /* The timer ID integer */
\r
433 FGCBTimer Callback; /* The timer callback */
\r
434 long TriggerTime; /* The timer trigger time */
\r
438 * A window and its OpenGL context. The contents of this structure
\r
439 * are highly dependant on the target operating system we aim at...
\r
441 typedef struct tagSFG_Context SFG_Context;
\r
442 struct tagSFG_Context
\r
444 SFG_WindowHandleType Handle; /* The window's handle */
\r
445 SFG_WindowContextType Context; /* The window's OpenGL/WGL context */
\r
447 SFG_PlatformContext pContext; /* The window's FBConfig (X11) or device context (Windows) */
\r
449 int DoubleBuffered; /* Treat the window as double-buffered */
\r
452 /* Window's state description. This structure should be kept portable. */
\r
453 typedef struct tagSFG_WindowState SFG_WindowState;
\r
454 struct tagSFG_WindowState
\r
456 /* Note that on Windows, sizes always refer to the client area, thus without the window decorations */
\r
457 int Width; /* Window's width in pixels */
\r
458 int Height; /* The same about the height */
\r
459 #if TARGET_HOST_POSIX_X11
\r
460 int OldWidth; /* Window width from before a resize */
\r
461 int OldHeight; /* " height " " " " */
\r
462 #elif TARGET_HOST_MS_WINDOWS
\r
463 RECT OldRect; /* window rect - stored before the window is made fullscreen */
\r
464 DWORD OldStyle; /* window style - stored before the window is made fullscreen */
\r
467 GLboolean Redisplay; /* Do we have to redisplay? */
\r
468 GLboolean Visible; /* Is the window visible now */
\r
470 int Cursor; /* The currently selected cursor */
\r
472 long JoystickPollRate; /* The joystick polling rate */
\r
473 long JoystickLastPoll; /* When the last poll happened */
\r
475 int MouseX, MouseY; /* The most recent mouse position */
\r
477 GLboolean IgnoreKeyRepeat; /* Whether to ignore key repeat. */
\r
478 GLboolean KeyRepeating; /* Currently in repeat mode */
\r
480 GLboolean NeedToResize; /* Do we need to resize the window? */
\r
482 GLboolean IsFullscreen; /* is the window fullscreen? */
\r
487 * A generic function pointer. We should really use the GLUTproc type
\r
488 * defined in freeglut_ext.h, but if we include that header in this file
\r
489 * a bunch of other stuff (font-related) blows up!
\r
491 typedef void (*SFG_Proc)();
\r
495 * SET_WCB() is used as:
\r
497 * SET_WCB( window, cbname, func );
\r
499 * ...where {window} is the freeglut window to set the callback,
\r
500 * {cbname} is the window-specific callback to set,
\r
501 * {func} is a function-pointer.
\r
503 * Originally, {FETCH_WCB( ... ) = func} was rather sloppily used,
\r
504 * but this can cause warnings because the FETCH_WCB() macro type-
\r
505 * casts its result, and a type-cast value shouldn't be an lvalue.
\r
507 * The {if( FETCH_WCB( ... ) != func )} test is to do type-checking
\r
508 * and for no other reason. Since it's hidden in the macro, the
\r
509 * ugliness is felt to be rather benign.
\r
511 #define SET_WCB(window,cbname,func) \
\r
514 if( FETCH_WCB( window, cbname ) != (SFG_Proc)(func) ) \
\r
515 (((window).CallBacks[CB_ ## cbname]) = (SFG_Proc)(func)); \
\r
519 * FETCH_WCB() is used as:
\r
521 * FETCH_WCB( window, cbname );
\r
523 * ...where {window} is the freeglut window to fetch the callback from,
\r
524 * {cbname} is the window-specific callback to fetch.
\r
526 * The result is correctly type-cast to the callback function pointer
\r
529 #define FETCH_WCB(window,cbname) \
\r
530 ((window).CallBacks[CB_ ## cbname])
\r
533 * INVOKE_WCB() is used as:
\r
535 * INVOKE_WCB( window, cbname, ( arg_list ) );
\r
537 * ...where {window} is the freeglut window,
\r
538 * {cbname} is the window-specific callback to be invoked,
\r
539 * {(arg_list)} is the parameter list.
\r
541 * The callback is invoked as:
\r
543 * callback( arg_list );
\r
545 * ...so the parentheses are REQUIRED in the {arg_list}.
\r
547 * NOTE that it does a sanity-check and also sets the
\r
551 #if TARGET_HOST_MS_WINDOWS && !defined(_WIN32_WCE) /* FIXME: also WinCE? */
\r
552 #define INVOKE_WCB(window,cbname,arg_list) \
\r
555 if( FETCH_WCB( window, cbname ) ) \
\r
557 FGCB ## cbname func = (FGCB ## cbname)(FETCH_WCB( window, cbname )); \
\r
558 fgSetWindow( &window ); \
\r
563 #define INVOKE_WCB(window,cbname,arg_list) \
\r
566 if( FETCH_WCB( window, cbname ) ) \
\r
568 fgSetWindow( &window ); \
\r
569 ((FGCB ## cbname)FETCH_WCB( window, cbname )) arg_list; \
\r
575 * The window callbacks the user can supply us with. Should be kept portable.
\r
577 * This enumeration provides the freeglut CallBack numbers.
\r
578 * The symbolic constants are indices into a window's array of
\r
579 * function callbacks. The names are formed by splicing a common
\r
580 * prefix onto the callback's base name. (This was originally
\r
581 * done so that an early stage of development could live side-by-
\r
582 * side with the old callback code. The old callback code used
\r
583 * the bare callback's name as a structure member, so I used a
\r
584 * prefix for the array index name.)
\r
586 * XXX For consistancy, perhaps the prefix should match the
\r
587 * XXX FETCH* and INVOKE* macro suffices. I.e., WCB_, rather than
\r
614 /* Presently ignored */
\r
617 CB_SpaceMotion, /* presently implemented only on UNIX/X11 */
\r
618 CB_SpaceRotation, /* presently implemented only on UNIX/X11 */
\r
619 CB_SpaceButton, /* presently implemented only on UNIX/X11 */
\r
625 /* Always make this the LAST one */
\r
630 /* This structure holds the OpenGL rendering context for all the menu windows */
\r
631 typedef struct tagSFG_MenuContext SFG_MenuContext;
\r
632 struct tagSFG_MenuContext
\r
634 SFG_WindowContextType MContext; /* The menu window's WGL context */
\r
637 /* This structure describes a menu */
\r
638 typedef struct tagSFG_Window SFG_Window;
\r
639 typedef struct tagSFG_MenuEntry SFG_MenuEntry;
\r
640 typedef struct tagSFG_Menu SFG_Menu;
\r
644 void *UserData; /* User data passed back at callback */
\r
645 int ID; /* The global menu ID */
\r
646 SFG_List Entries; /* The menu entries list */
\r
647 FGCBMenu Callback; /* The menu callback */
\r
648 FGCBDestroy Destroy; /* Destruction callback */
\r
649 GLboolean IsActive; /* Is the menu selected? */
\r
650 int Width; /* Menu box width in pixels */
\r
651 int Height; /* Menu box height in pixels */
\r
652 int X, Y; /* Menu box raster position */
\r
654 SFG_MenuEntry *ActiveEntry; /* Currently active entry in the menu */
\r
655 SFG_Window *Window; /* Window for menu */
\r
656 SFG_Window *ParentWindow; /* Window in which the menu is invoked */
\r
659 /* This is a menu entry */
\r
660 struct tagSFG_MenuEntry
\r
663 int ID; /* The menu entry ID (local) */
\r
664 int Ordinal; /* The menu's ordinal number */
\r
665 char* Text; /* The text to be displayed */
\r
666 SFG_Menu* SubMenu; /* Optional sub-menu tree */
\r
667 GLboolean IsActive; /* Is the entry highlighted? */
\r
668 int Width; /* Label's width in pixels */
\r
672 * A window, making part of freeglut windows hierarchy.
\r
673 * Should be kept portable.
\r
675 * NOTE that ActiveMenu is set to menu itself if the window is a menu.
\r
677 struct tagSFG_Window
\r
680 int ID; /* Window's ID number */
\r
682 SFG_Context Window; /* Window and OpenGL context */
\r
683 SFG_WindowState State; /* The window state */
\r
684 SFG_Proc CallBacks[ TOTAL_CALLBACKS ]; /* Array of window callbacks */
\r
685 void *UserData ; /* For use by user */
\r
687 SFG_Menu* Menu[ FREEGLUT_MAX_MENUS ]; /* Menus appended to window */
\r
688 SFG_Menu* ActiveMenu; /* The window's active menu */
\r
690 SFG_Window* Parent; /* The parent to this window */
\r
691 SFG_List Children; /* The subwindows d.l. list */
\r
693 GLboolean IsMenu; /* Set to 1 if we are a menu */
\r
697 /* A linked list structure of windows */
\r
698 typedef struct tagSFG_WindowList SFG_WindowList ;
\r
699 struct tagSFG_WindowList
\r
702 SFG_Window *window ;
\r
705 /* This holds information about all the windows, menus etc. */
\r
706 typedef struct tagSFG_Structure SFG_Structure;
\r
707 struct tagSFG_Structure
\r
709 SFG_List Windows; /* The global windows list */
\r
710 SFG_List Menus; /* The global menus list */
\r
711 SFG_List WindowsToDestroy;
\r
713 SFG_Window* CurrentWindow; /* The currently set window */
\r
714 SFG_Menu* CurrentMenu; /* Same, but menu... */
\r
716 SFG_MenuContext* MenuContext; /* OpenGL rendering context for menus */
\r
718 SFG_Window* GameModeWindow; /* The game mode window */
\r
720 int WindowID; /* The new current window ID */
\r
721 int MenuID; /* The new current menu ID */
\r
725 * This structure is used for the enumeration purposes.
\r
726 * You can easily extend its functionalities by declaring
\r
727 * a structure containing enumerator's contents and custom
\r
728 * data, then casting its pointer to (SFG_Enumerator *).
\r
730 typedef struct tagSFG_Enumerator SFG_Enumerator;
\r
731 struct tagSFG_Enumerator
\r
733 GLboolean found; /* Used to terminate search */
\r
734 void* data; /* Custom data pointer */
\r
736 typedef void (* FGCBenumerator )( SFG_Window *, SFG_Enumerator * );
\r
738 /* The bitmap font structure */
\r
739 typedef struct tagSFG_Font SFG_Font;
\r
742 char* Name; /* The source font name */
\r
743 int Quantity; /* Number of chars in font */
\r
744 int Height; /* Height of the characters */
\r
745 const GLubyte** Characters; /* The characters mapping */
\r
747 float xorig, yorig; /* Relative origin of the character */
\r
750 /* The stroke font structures */
\r
752 typedef struct tagSFG_StrokeVertex SFG_StrokeVertex;
\r
753 struct tagSFG_StrokeVertex
\r
758 typedef struct tagSFG_StrokeStrip SFG_StrokeStrip;
\r
759 struct tagSFG_StrokeStrip
\r
762 const SFG_StrokeVertex* Vertices;
\r
765 typedef struct tagSFG_StrokeChar SFG_StrokeChar;
\r
766 struct tagSFG_StrokeChar
\r
770 const SFG_StrokeStrip* Strips;
\r
773 typedef struct tagSFG_StrokeFont SFG_StrokeFont;
\r
774 struct tagSFG_StrokeFont
\r
776 char* Name; /* The source font name */
\r
777 int Quantity; /* Number of chars in font */
\r
778 GLfloat Height; /* Height of the characters */
\r
779 const SFG_StrokeChar** Characters; /* The characters mapping */
\r
783 /* -- JOYSTICK-SPECIFIC STRUCTURES AND TYPES ------------------------------- */
\r
784 /* XXX It might be better to poll the operating system for the numbers of buttons and
\r
785 * XXX axes and then dynamically allocate the arrays.
\r
787 #define _JS_MAX_BUTTONS 32
\r
789 #if TARGET_HOST_MACINTOSH
\r
790 # define _JS_MAX_AXES 9
\r
793 #if TARGET_HOST_MAC_OSX
\r
794 # define _JS_MAX_AXES 16
\r
797 #if TARGET_HOST_MS_WINDOWS && !defined(_WIN32_WCE)
\r
798 # define _JS_MAX_AXES 8
\r
801 #if TARGET_HOST_POSIX_X11
\r
802 # define _JS_MAX_AXES 16
\r
806 * Definition of "SFG_Joystick" structure -- based on JS's "jsJoystick" object class.
\r
807 * See "js.h" lines 80-178.
\r
809 typedef struct tagSFG_Joystick SFG_Joystick;
\r
810 struct tagSFG_Joystick
\r
812 #if TARGET_HOST_MACINTOSH
\r
813 #define ISP_NUM_AXIS 9
\r
814 #define ISP_NUM_NEEDS 41
\r
815 ISpElementReference isp_elem [ ISP_NUM_NEEDS ];
\r
816 ISpNeed isp_needs [ ISP_NUM_NEEDS ];
\r
819 #if TARGET_HOST_MAC_OSX
\r
820 IOHIDDeviceInterface ** hidDev;
\r
821 IOHIDElementCookie buttonCookies[41];
\r
822 IOHIDElementCookie axisCookies[_JS_MAX_AXES];
\r
823 long minReport[_JS_MAX_AXES],
\r
824 maxReport[_JS_MAX_AXES];
\r
827 #if TARGET_HOST_MS_WINDOWS && !defined(_WIN32_WCE)
\r
834 #if TARGET_HOST_POSIX_X11
\r
835 # if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
\r
836 struct os_specific_s *os;
\r
840 struct js_event js;
\r
842 float tmp_axes [ _JS_MAX_AXES ];
\r
844 struct JS_DATA_TYPE js;
\r
847 char fname [ 128 ];
\r
857 float dead_band[ _JS_MAX_AXES ];
\r
858 float saturate [ _JS_MAX_AXES ];
\r
859 float center [ _JS_MAX_AXES ];
\r
860 float max [ _JS_MAX_AXES ];
\r
861 float min [ _JS_MAX_AXES ];
\r
866 /* -- GLOBAL VARIABLES EXPORTS --------------------------------------------- */
\r
868 /* Freeglut display related stuff (initialized once per session) */
\r
869 extern SFG_Display fgDisplay;
\r
871 /* Freeglut internal structure */
\r
872 extern SFG_Structure fgStructure;
\r
874 /* The current freeglut settings */
\r
875 extern SFG_State fgState;
\r
878 /* -- PRIVATE FUNCTION DECLARATIONS ---------------------------------------- */
\r
881 * A call to this function makes us sure that the Display and Structure
\r
882 * subsystems have been properly initialized and are ready to be used
\r
884 #define FREEGLUT_EXIT_IF_NOT_INITIALISED( string ) \
\r
885 if ( ! fgState.Initialised ) \
\r
887 fgError ( " ERROR: Function <%s> called" \
\r
888 " without first calling 'glutInit'.", (string) ) ; \
\r
891 #define FREEGLUT_INTERNAL_ERROR_EXIT_IF_NOT_INITIALISED( string ) \
\r
892 if ( ! fgState.Initialised ) \
\r
894 fgError ( " ERROR: Internal <%s> function called" \
\r
895 " without first calling 'glutInit'.", (string) ) ; \
\r
898 #define FREEGLUT_INTERNAL_ERROR_EXIT( cond, string, function ) \
\r
899 if ( ! ( cond ) ) \
\r
901 fgError ( " ERROR: Internal error <%s> in function %s", \
\r
902 (string), (function) ) ; \
\r
906 * Following definitions are somewhat similiar to GLib's,
\r
907 * but do not generate any log messages:
\r
909 #define freeglut_return_if_fail( expr ) \
\r
912 #define freeglut_return_val_if_fail( expr, val ) \
\r
917 * A call to those macros assures us that there is a current
\r
918 * window set, respectively:
\r
920 #define FREEGLUT_EXIT_IF_NO_WINDOW( string ) \
\r
921 if ( ! fgStructure.CurrentWindow && \
\r
922 ( fgState.ActionOnWindowClose != GLUT_ACTION_CONTINUE_EXECUTION ) ) \
\r
924 fgError ( " ERROR: Function <%s> called" \
\r
925 " with no current window defined.", (string) ) ; \
\r
929 * The deinitialize function gets called on glutMainLoop() end. It should clean up
\r
930 * everything inside of the freeglut
\r
932 void fgDeinitialize( void );
\r
935 * Those two functions are used to create/destroy the freeglut internal
\r
936 * structures. This actually happens when calling glutInit() and when
\r
937 * quitting the glutMainLoop() (which actually happens, when all windows
\r
938 * have been closed).
\r
940 void fgCreateStructure( void );
\r
941 void fgDestroyStructure( void );
\r
944 * Window creation, opening, closing and destruction.
\r
945 * Also CallBack clearing/initialization.
\r
946 * Defined in freeglut_structure.c, freeglut_window.c.
\r
948 SFG_Window* fgCreateWindow( SFG_Window* parent, const char* title,
\r
949 GLboolean positionUse, int x, int y,
\r
950 GLboolean sizeUse, int w, int h,
\r
951 GLboolean gameMode, GLboolean isMenu );
\r
952 void fgSetWindow ( SFG_Window *window );
\r
953 void fgOpenWindow( SFG_Window* window, const char* title,
\r
954 GLboolean positionUse, int x, int y,
\r
955 GLboolean sizeUse, int w, int h,
\r
956 GLboolean gameMode, GLboolean isSubWindow );
\r
957 void fgCloseWindow( SFG_Window* window );
\r
958 void fgAddToWindowDestroyList ( SFG_Window* window );
\r
959 void fgCloseWindows ();
\r
960 void fgDestroyWindow( SFG_Window* window );
\r
962 /* Menu creation and destruction. Defined in freeglut_structure.c */
\r
963 SFG_Menu* fgCreateMenu( FGCBMenu menuCallback );
\r
964 void fgDestroyMenu( SFG_Menu* menu );
\r
966 /* Joystick device management functions, defined in freeglut_joystick.c */
\r
967 int fgJoystickDetect( void );
\r
968 void fgInitialiseJoysticks( void );
\r
969 void fgJoystickClose( void );
\r
970 void fgJoystickPollWindow( SFG_Window* window );
\r
972 /* InputDevice Initialisation and Closure */
\r
973 int fgInputDeviceDetect( void );
\r
974 void fgInitialiseInputDevices( void );
\r
975 void fgInputDeviceClose( void );
\r
977 /* spaceball device functions, defined in freeglut_spaceball.c */
\r
978 void fgInitialiseSpaceball( void );
\r
979 void fgSpaceballClose( void );
\r
980 void fgSpaceballSetWindow( SFG_Window *window );
\r
982 int fgHasSpaceball( void );
\r
983 int fgSpaceballNumButtons( void );
\r
985 #if TARGET_HOST_POSIX_X11
\r
986 int fgIsSpaceballXEvent( const XEvent *ev );
\r
987 void fgSpaceballHandleXEvent( const XEvent *ev );
\r
990 /* Setting the cursor for a given window */
\r
991 void fgSetCursor ( SFG_Window *window, int cursorID );
\r
994 * Helper function to enumerate through all registered windows
\r
995 * and one to enumerate all of a window's subwindows...
\r
997 * The GFunc callback for those functions will be defined as:
\r
999 * void enumCallback( gpointer window, gpointer enumerator );
\r
1001 * where window is the enumerated (sub)window pointer (SFG_Window *),
\r
1002 * and userData is the a custom user-supplied pointer. Functions
\r
1003 * are defined and exported from freeglut_structure.c file.
\r
1005 void fgEnumWindows( FGCBenumerator enumCallback, SFG_Enumerator* enumerator );
\r
1006 void fgEnumSubWindows( SFG_Window* window, FGCBenumerator enumCallback,
\r
1007 SFG_Enumerator* enumerator );
\r
1010 * fgWindowByHandle returns a (SFG_Window *) value pointing to the
\r
1011 * first window in the queue matching the specified window handle.
\r
1012 * The function is defined in freeglut_structure.c file.
\r
1014 SFG_Window* fgWindowByHandle( SFG_WindowHandleType hWindow );
\r
1017 * This function is similiar to the previous one, except it is
\r
1018 * looking for a specified (sub)window identifier. The function
\r
1019 * is defined in freeglut_structure.c file.
\r
1021 SFG_Window* fgWindowByID( int windowID );
\r
1024 * Looks up a menu given its ID. This is easier than fgWindowByXXX
\r
1025 * as all menus are placed in a single doubly linked list...
\r
1027 SFG_Menu* fgMenuByID( int menuID );
\r
1030 * The menu activation and deactivation the code. This is the meat
\r
1031 * of the menu user interface handling code...
\r
1033 void fgUpdateMenuHighlight ( SFG_Menu *menu );
\r
1034 GLboolean fgCheckActiveMenu ( SFG_Window *window, int button, GLboolean pressed,
\r
1035 int mouse_x, int mouse_y );
\r
1036 void fgDeactivateMenu( SFG_Window *window );
\r
1039 * This function gets called just before the buffers swap, so that
\r
1040 * freeglut can display the pull-down menus via OpenGL. The function
\r
1041 * is defined in freeglut_menu.c file.
\r
1043 void fgDisplayMenu( void );
\r
1045 /* Elapsed time as per glutGet(GLUT_ELAPSED_TIME). */
\r
1046 long fgElapsedTime( void );
\r
1048 /* System time in milliseconds */
\r
1049 long unsigned fgSystemTime(void);
\r
1051 /* List functions */
\r
1052 void fgListInit(SFG_List *list);
\r
1053 void fgListAppend(SFG_List *list, SFG_Node *node);
\r
1054 void fgListRemove(SFG_List *list, SFG_Node *node);
\r
1055 int fgListLength(SFG_List *list);
\r
1056 void fgListInsert(SFG_List *list, SFG_Node *next, SFG_Node *node);
\r
1058 /* Error Message functions */
\r
1059 void fgError( const char *fmt, ... );
\r
1060 void fgWarning( const char *fmt, ... );
\r
1063 * Check if "hint" is present in "property" for "window". See freeglut_init.c
\r
1065 #if TARGET_HOST_POSIX_X11
\r
1066 int fgHintPresent(Window window, Atom property, Atom hint);
\r
1068 /* Handler for X extension Events */
\r
1069 #ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
\r
1070 void fgHandleExtensionEvents( XEvent * ev );
\r
1071 void fgRegisterDevices( Display* dpy, Window* win );
\r
1076 SFG_Proc fghGetProcAddress( const char *procName );
\r
1078 #endif /* FREEGLUT_INTERNAL_H */
\r
1080 /*** END OF FILE ***/
\r