xref: /haiku/src/libs/glut/glutint.h (revision f2b4344867e97c3f4e742a1b4a15e6879644601a)
1 #ifndef __glutint_h__
2 #define __glutint_h__
3 
4 /* Copyright (c) Mark J. Kilgard, 1994, 1997, 1998. */
5 
6 /* This program is freely distributable without licensing fees
7    and is provided without guarantee or warrantee expressed or
8    implied. This program is -not- in the public domain. */
9 
10 #if defined(__CYGWIN32__)
11 #include <sys/time.h>
12 #endif
13 
14 #if defined(_WIN32)
15 #include "glutwin32.h"
16 #elif !(defined(__BEOS__) || defined(__HAIKU__))
17 #ifdef __sgi
18 #define SUPPORT_FORTRAN
19 #endif
20 #include <X11/Xlib.h>
21 #include <X11/Xutil.h>
22 #include <GL/glx.h>
23 #endif
24 
25 #include <GL/glut.h>
26 
27 /* Non-Win32 platforms need APIENTRY defined to nothing
28    because all the GLUT routines have the APIENTRY prefix
29    to make Win32 happy. */
30 #ifndef APIENTRY
31 #define APIENTRY
32 #endif
33 
34 #ifdef __vms
35 #if ( __VMS_VER < 70000000 )
36 struct timeval {
37   __int64 val;
38 };
39 extern int sys$gettim(struct timeval *);
40 #else
41 #include <time.h>
42 #endif
43 #else
44 #include <sys/types.h>
45 #if !defined(_WIN32)
46 #include <sys/time.h>
47 #else
48 #include <winsock.h>
49 #endif
50 #endif
51 #if defined(__vms) && ( __VMS_VER < 70000000 )
52 
53 /* For VMS6.2 or lower :
54    One TICK on VMS is 100 nanoseconds; 0.1 microseconds or
55    0.0001 milliseconds. This means that there are 0.01
56    ticks/ns, 10 ticks/us, 10,000 ticks/ms and 10,000,000
57    ticks/second. */
58 
59 #define TICKS_PER_MILLISECOND 10000
60 #define TICKS_PER_SECOND      10000000
61 
62 #define GETTIMEOFDAY(_x) (void) sys$gettim (_x);
63 
64 #define ADD_TIME(dest, src1, src2) { \
65   (dest).val = (src1).val + (src2).val; \
66 }
67 
68 #define TIMEDELTA(dest, src1, src2) { \
69   (dest).val = (src1).val - (src2).val; \
70 }
71 
72 #define IS_AFTER(t1, t2) ((t2).val > (t1).val)
73 
74 #define IS_AT_OR_AFTER(t1, t2) ((t2).val >= (t1).val)
75 
76 #else
77 #if defined(SVR4) && !defined(sun)  /* Sun claims SVR4, but
78                                        wants 2 args. */
79 #define GETTIMEOFDAY(_x) gettimeofday(_x)
80 #else
81 #define GETTIMEOFDAY(_x) gettimeofday(_x, NULL)
82 #endif
83 #define ADD_TIME(dest, src1, src2) { \
84   if(((dest).tv_usec = \
85     (src1).tv_usec + (src2).tv_usec) >= 1000000) { \
86     (dest).tv_usec -= 1000000; \
87     (dest).tv_sec = (src1).tv_sec + (src2).tv_sec + 1; \
88   } else { \
89     (dest).tv_sec = (src1).tv_sec + (src2).tv_sec; \
90     if(((dest).tv_sec >= 1) && (((dest).tv_usec <0))) { \
91       (dest).tv_sec --;(dest).tv_usec += 1000000; \
92     } \
93   } \
94 }
95 #define TIMEDELTA(dest, src1, src2) { \
96   if(((dest).tv_usec = (src1).tv_usec - (src2).tv_usec) < 0) { \
97     (dest).tv_usec += 1000000; \
98     (dest).tv_sec = (src1).tv_sec - (src2).tv_sec - 1; \
99   } else { \
100      (dest).tv_sec = (src1).tv_sec - (src2).tv_sec; \
101   } \
102 }
103 #define IS_AFTER(t1, t2) \
104   (((t2).tv_sec > (t1).tv_sec) || \
105   (((t2).tv_sec == (t1).tv_sec) && \
106   ((t2).tv_usec > (t1).tv_usec)))
107 #define IS_AT_OR_AFTER(t1, t2) \
108   (((t2).tv_sec > (t1).tv_sec) || \
109   (((t2).tv_sec == (t1).tv_sec) && \
110   ((t2).tv_usec >= (t1).tv_usec)))
111 #endif
112 
113 #define IGNORE_IN_GAME_MODE() \
114   { if (__glutGameModeWindow) return; }
115 
116 /* BeOS doesn't need most of this file */
117 #if (!defined(__BEOS__) && !defined(__HAIKU__))
118 
119 #define GLUT_WIND_IS_RGB(x)         (((x) & GLUT_INDEX) == 0)
120 #define GLUT_WIND_IS_INDEX(x)       (((x) & GLUT_INDEX) != 0)
121 #define GLUT_WIND_IS_SINGLE(x)      (((x) & GLUT_DOUBLE) == 0)
122 #define GLUT_WIND_IS_DOUBLE(x)      (((x) & GLUT_DOUBLE) != 0)
123 #define GLUT_WIND_HAS_ACCUM(x)      (((x) & GLUT_ACCUM) != 0)
124 #define GLUT_WIND_HAS_ALPHA(x)      (((x) & GLUT_ALPHA) != 0)
125 #define GLUT_WIND_HAS_DEPTH(x)      (((x) & GLUT_DEPTH) != 0)
126 #define GLUT_WIND_HAS_STENCIL(x)    (((x) & GLUT_STENCIL) != 0)
127 #define GLUT_WIND_IS_MULTISAMPLE(x) (((x) & GLUT_MULTISAMPLE) != 0)
128 #define GLUT_WIND_IS_STEREO(x)      (((x) & GLUT_STEREO) != 0)
129 #define GLUT_WIND_IS_LUMINANCE(x)   (((x) & GLUT_LUMINANCE) != 0)
130 #define GLUT_MAP_WORK               (1 << 0)
131 #define GLUT_EVENT_MASK_WORK        (1 << 1)
132 #define GLUT_REDISPLAY_WORK         (1 << 2)
133 #define GLUT_CONFIGURE_WORK         (1 << 3)
134 #define GLUT_COLORMAP_WORK          (1 << 4)
135 #define GLUT_DEVICE_MASK_WORK	    (1 << 5)
136 #define GLUT_FINISH_WORK	    (1 << 6)
137 #define GLUT_DEBUG_WORK		    (1 << 7)
138 #define GLUT_DUMMY_WORK		    (1 << 8)
139 #define GLUT_FULL_SCREEN_WORK       (1 << 9)
140 #define GLUT_OVERLAY_REDISPLAY_WORK (1 << 10)
141 #define GLUT_REPAIR_WORK            (1 << 11)
142 #define GLUT_OVERLAY_REPAIR_WORK    (1 << 12)
143 
144 /* Frame buffer capability macros and types. */
145 #define RGBA                    0
146 #define BUFFER_SIZE             1
147 #define DOUBLEBUFFER            2
148 #define STEREO                  3
149 #define AUX_BUFFERS             4
150 #define RED_SIZE                5  /* Used as mask bit for
151                                       "color selected". */
152 #define GREEN_SIZE              6
153 #define BLUE_SIZE               7
154 #define ALPHA_SIZE              8
155 #define DEPTH_SIZE              9
156 #define STENCIL_SIZE            10
157 #define ACCUM_RED_SIZE          11  /* Used as mask bit for
158                                        "acc selected". */
159 #define ACCUM_GREEN_SIZE        12
160 #define ACCUM_BLUE_SIZE         13
161 #define ACCUM_ALPHA_SIZE        14
162 #define LEVEL                   15
163 
164 #define NUM_GLXCAPS             (LEVEL + 1)
165 
166 #define XVISUAL                 (NUM_GLXCAPS + 0)
167 #define TRANSPARENT             (NUM_GLXCAPS + 1)
168 #define SAMPLES                 (NUM_GLXCAPS + 2)
169 #define XSTATICGRAY             (NUM_GLXCAPS + 3)  /* Used as
170                                                       mask bit
171                                                       for "any
172                                                       visual type
173                                                       selected". */
174 #define XGRAYSCALE              (NUM_GLXCAPS + 4)
175 #define XSTATICCOLOR            (NUM_GLXCAPS + 5)
176 #define XPSEUDOCOLOR            (NUM_GLXCAPS + 6)
177 #define XTRUECOLOR              (NUM_GLXCAPS + 7)
178 #define XDIRECTCOLOR            (NUM_GLXCAPS + 8)
179 #define SLOW                    (NUM_GLXCAPS + 9)
180 #define CONFORMANT              (NUM_GLXCAPS + 10)
181 
182 #define NUM_CAPS                (NUM_GLXCAPS + 11)
183 
184 /* Frame buffer capablities that don't have a corresponding
185    FrameBufferMode entry.  These get used as mask bits. */
186 #define NUM                     (NUM_CAPS + 0)
187 #define RGBA_MODE               (NUM_CAPS + 1)
188 #define CI_MODE                 (NUM_CAPS + 2)
189 #define LUMINANCE_MODE		(NUM_CAPS + 3)
190 
191 #define NONE			0
192 #define EQ			1
193 #define NEQ			2
194 #define LTE			3
195 #define GTE			4
196 #define GT			5
197 #define LT			6
198 #define MIN			7
199 
200 typedef struct _Criterion {
201   int capability;
202   int comparison;
203   int value;
204 } Criterion;
205 
206 typedef struct _FrameBufferMode {
207   XVisualInfo *vi;
208 #if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_fbconfig)
209 
210   /* fbc is non-NULL when the XVisualInfo* is not OpenGL-capable
211      (ie, GLX_USE_GL is false), but the SGIX_fbconfig extension shows
212      the visual's fbconfig is OpenGL-capable.  The reason for this is typically
213      an RGBA luminance fbconfig such as 16-bit StaticGray that could
214      not be advertised as a GLX visual since StaticGray visuals are
215      required (by the GLX specification) to be color index.  The
216      SGIX_fbconfig allows StaticGray visuals to instead advertised as
217      fbconfigs that can provide RGBA luminance support. */
218 
219   GLXFBConfigSGIX fbc;
220 #endif
221   int valid;
222   int cap[NUM_CAPS];
223 } FrameBufferMode;
224 
225 /* DisplayMode capability macros for game mode. */
226 #define DM_WIDTH        0  /* "width" */
227 #define DM_HEIGHT       1  /* "height" */
228 #define DM_PIXEL_DEPTH  2  /* "bpp" (bits per pixel) */
229 #define DM_HERTZ        3  /* "hertz" */
230 #define DM_NUM          4  /* "num" */
231 
232 #define NUM_DM_CAPS     (DM_NUM+1)
233 
234 typedef struct _DisplayMode {
235 #ifdef _WIN32
236   DEVMODE devmode;
237 #else
238   /* XXX The X Window System does not have a standard
239      mechanism for display setting changes.  On SGI
240      systems, GLUT could use the XSGIvc (SGI X video
241      control extension).  Perhaps this can be done in
242      a future release of GLUT. */
243 #endif
244   int valid;
245   int cap[NUM_DM_CAPS];
246 } DisplayMode;
247 
248 #endif  /* BeOS */
249 
250 /* GLUT  function types */
251 typedef void (*GLUTdisplayCB) (void);
252 typedef void (*GLUTreshapeCB) (int, int);
253 typedef void (*GLUTkeyboardCB) (unsigned char, int, int);
254 typedef void (*GLUTmouseCB) (int, int, int, int);
255 typedef void (*GLUTmotionCB) (int, int);
256 typedef void (*GLUTpassiveCB) (int, int);
257 typedef void (*GLUTentryCB) (int);
258 typedef void (*GLUTvisibilityCB) (int);
259 typedef void (*GLUTwindowStatusCB) (int);
260 typedef void (*GLUTidleCB) (void);
261 typedef void (*GLUTtimerCB) (int);
262 typedef void (*GLUTmenuStateCB) (int);  /* DEPRICATED. */
263 typedef void (*GLUTmenuStatusCB) (int, int, int);
264 typedef void (*GLUTselectCB) (int);
265 typedef void (*GLUTspecialCB) (int, int, int);
266 typedef void (*GLUTspaceMotionCB) (int, int, int);
267 typedef void (*GLUTspaceRotateCB) (int, int, int);
268 typedef void (*GLUTspaceButtonCB) (int, int);
269 typedef void (*GLUTdialsCB) (int, int);
270 typedef void (*GLUTbuttonBoxCB) (int, int);
271 typedef void (*GLUTtabletMotionCB) (int, int);
272 typedef void (*GLUTtabletButtonCB) (int, int, int, int);
273 typedef void (*GLUTjoystickCB) (unsigned int buttonMask, int x, int y, int z);
274 #ifdef SUPPORT_FORTRAN
275 typedef void (*GLUTdisplayFCB) (void);
276 typedef void (*GLUTreshapeFCB) (int *, int *);
277 /* NOTE the pressed key is int, not unsigned char for Fortran! */
278 typedef void (*GLUTkeyboardFCB) (int *, int *, int *);
279 typedef void (*GLUTmouseFCB) (int *, int *, int *, int *);
280 typedef void (*GLUTmotionFCB) (int *, int *);
281 typedef void (*GLUTpassiveFCB) (int *, int *);
282 typedef void (*GLUTentryFCB) (int *);
283 typedef void (*GLUTvisibilityFCB) (int *);
284 typedef void (*GLUTwindowStatusFCB) (int *);
285 typedef void (*GLUTidleFCB) (void);
286 typedef void (*GLUTtimerFCB) (int *);
287 typedef void (*GLUTmenuStateFCB) (int *);  /* DEPRICATED. */
288 typedef void (*GLUTmenuStatusFCB) (int *, int *, int *);
289 typedef void (*GLUTselectFCB) (int *);
290 typedef void (*GLUTspecialFCB) (int *, int *, int *);
291 typedef void (*GLUTspaceMotionFCB) (int *, int *, int *);
292 typedef void (*GLUTspaceRotateFCB) (int *, int *, int *);
293 typedef void (*GLUTspaceButtonFCB) (int *, int *);
294 typedef void (*GLUTdialsFCB) (int *, int *);
295 typedef void (*GLUTbuttonBoxFCB) (int *, int *);
296 typedef void (*GLUTtabletMotionFCB) (int *, int *);
297 typedef void (*GLUTtabletButtonFCB) (int *, int *, int *, int *);
298 typedef void (*GLUTjoystickFCB) (unsigned int *buttonMask, int *x, int *y, int *z);
299 #endif
300 
301 #if (!defined(__BEOS__) && !defined(__HAIKU__))
302 
303 typedef struct _GLUTcolorcell GLUTcolorcell;
304 struct _GLUTcolorcell {
305   /* GLUT_RED, GLUT_GREEN, GLUT_BLUE */
306   GLfloat component[3];
307 };
308 
309 typedef struct _GLUTcolormap GLUTcolormap;
310 struct _GLUTcolormap {
311   Visual *visual;       /* visual of the colormap */
312   Colormap cmap;        /* X colormap ID */
313   int refcnt;           /* number of windows using colormap */
314   int size;             /* number of cells in colormap */
315   int transparent;      /* transparent pixel, or -1 if opaque */
316   GLUTcolorcell *cells; /* array of cells */
317   GLUTcolormap *next;   /* next colormap in list */
318 };
319 
320 typedef struct _GLUTwindow GLUTwindow;
321 typedef struct _GLUToverlay GLUToverlay;
322 struct _GLUTwindow {
323   int num;              /* Small integer window id (0-based). */
324 
325   /* Window system related state. */
326 #if defined(_WIN32)
327   int pf;               /* Pixel format. */
328   HDC hdc;              /* Window's Win32 device context. */
329 #endif
330   Window win;           /* X window for GLUT window */
331   GLXContext ctx;       /* OpenGL context GLUT glut window */
332   XVisualInfo *vis;     /* visual for window */
333   Bool visAlloced;      /* if vis needs deallocate on destroy */
334   Colormap cmap;        /* RGB colormap for window; None if CI */
335   GLUTcolormap *colormap;  /* colormap; NULL if RGBA */
336   GLUToverlay *overlay; /* overlay; NULL if no overlay */
337 #if defined(_WIN32)
338   HDC renderDc;         /* Win32's device context for rendering. */
339 #endif
340   Window renderWin;     /* X window for rendering (might be
341                            overlay) */
342   GLXContext renderCtx; /* OpenGL context for rendering (might
343                            be overlay) */
344   /* GLUT settable or visible window state. */
345   int width;            /* window width in pixels */
346   int height;           /* window height in pixels */
347   int cursor;           /* cursor name */
348   int visState;         /* visibility state (-1 is unknown) */
349   int shownState;       /* if window mapped */
350   int entryState;       /* entry state (-1 is unknown) */
351 #define GLUT_MAX_MENUS              3
352 
353   int menu[GLUT_MAX_MENUS];  /* attatched menu nums */
354   /* Window relationship state. */
355   GLUTwindow *parent;   /* parent window */
356   GLUTwindow *children; /* list of children */
357   GLUTwindow *siblings; /* list of siblings */
358   /* Misc. non-API visible (hidden) state. */
359   Bool treatAsSingle;   /* treat this window as single-buffered
360                            (it might be "fake" though) */
361   Bool forceReshape;    /* force reshape before display */
362 #if !defined(_WIN32)
363   Bool isDirect;        /* if direct context (X11 only) */
364 #endif
365   Bool usedSwapBuffers; /* if swap buffers used last display */
366   long eventMask;       /* mask of X events selected for */
367   int buttonUses;       /* number of button uses, ref cnt */
368   int tabletPos[2];     /* tablet position (-1 is invalid) */
369   /* Work list related state. */
370   unsigned int workMask;  /* mask of window work to be done */
371   GLUTwindow *prevWorkWin;  /* link list of windows to work on */
372   Bool desiredMapState; /* how to mapped window if on map work
373                            list */
374   Bool ignoreKeyRepeat;  /* if window ignores autorepeat */
375   int desiredConfMask;  /* mask of desired window configuration
376                          */
377   int desiredX;         /* desired X location */
378   int desiredY;         /* desired Y location */
379   int desiredWidth;     /* desired window width */
380   int desiredHeight;    /* desired window height */
381   int desiredStack;     /* desired window stack */
382   /* Per-window callbacks. */
383   GLUTdisplayCB display;  /* redraw */
384   GLUTreshapeCB reshape;  /* resize (width,height) */
385   GLUTmouseCB mouse;    /* mouse (button,state,x,y) */
386   GLUTmotionCB motion;  /* motion (x,y) */
387   GLUTpassiveCB passive;  /* passive motion (x,y) */
388   GLUTentryCB entry;    /* window entry/exit (state) */
389   GLUTkeyboardCB keyboard;  /* keyboard (ASCII,x,y) */
390   GLUTkeyboardCB keyboardUp;  /* keyboard up (ASCII,x,y) */
391   GLUTwindowStatusCB windowStatus;  /* window status */
392   GLUTvisibilityCB visibility;  /* visibility */
393   GLUTspecialCB special;  /* special key */
394   GLUTspecialCB specialUp;  /* special up key */
395   GLUTbuttonBoxCB buttonBox;  /* button box */
396   GLUTdialsCB dials;    /* dials */
397   GLUTspaceMotionCB spaceMotion;  /* Spaceball motion */
398   GLUTspaceRotateCB spaceRotate;  /* Spaceball rotate */
399   GLUTspaceButtonCB spaceButton;  /* Spaceball button */
400   GLUTtabletMotionCB tabletMotion;  /* tablet motion */
401   GLUTtabletButtonCB tabletButton;  /* tablet button */
402 #ifdef _WIN32
403   GLUTjoystickCB joystick;  /* joystick */
404   int joyPollInterval; /* joystick polling interval */
405 #endif
406 #ifdef SUPPORT_FORTRAN
407   /* Special Fortran display  unneeded since no
408      parameters! */
409   GLUTreshapeFCB freshape;  /* Fortran reshape  */
410   GLUTmouseFCB fmouse;  /* Fortran mouse  */
411   GLUTmotionFCB fmotion;  /* Fortran motion  */
412   GLUTpassiveFCB fpassive;  /* Fortran passive  */
413   GLUTentryFCB fentry;  /* Fortran entry  */
414   GLUTkeyboardFCB fkeyboard;  /* Fortran keyboard  */
415   GLUTkeyboardFCB fkeyboardUp;  /* Fortran keyboard up */
416   GLUTwindowStatusFCB fwindowStatus;  /* Fortran visibility
417                                           */
418   GLUTvisibilityFCB fvisibility;  /* Fortran visibility
419                                       */
420   GLUTspecialFCB fspecial;  /* special key */
421   GLUTspecialFCB fspecialUp;  /* special key up */
422   GLUTbuttonBoxFCB fbuttonBox;  /* button box */
423   GLUTdialsFCB fdials;  /* dials */
424   GLUTspaceMotionFCB fspaceMotion;  /* Spaceball motion
425                                         */
426   GLUTspaceRotateFCB fspaceRotate;  /* Spaceball rotate
427                                         */
428   GLUTspaceButtonFCB fspaceButton;  /* Spaceball button
429                                         */
430   GLUTtabletMotionFCB ftabletMotion;  /* tablet motion
431                                        */
432   GLUTtabletButtonFCB ftabletButton;  /* tablet button
433                                        */
434 #ifdef _WIN32
435   GLUTjoystickFCB fjoystick;  /* joystick */
436 #endif
437 #endif
438 };
439 
440 struct _GLUToverlay {
441 #if defined(_WIN32)
442   int pf;
443   HDC hdc;
444 #endif
445   Window win;
446   GLXContext ctx;
447   XVisualInfo *vis;     /* visual for window */
448   Bool visAlloced;      /* if vis needs deallocate on destroy */
449   Colormap cmap;        /* RGB colormap for window; None if CI */
450   GLUTcolormap *colormap;  /* colormap; NULL if RGBA */
451   int shownState;       /* if overlay window mapped */
452   Bool treatAsSingle;   /* treat as single-buffered */
453 #if !defined(_WIN32)
454   Bool isDirect;        /* if direct context */
455 #endif
456   int transparentPixel; /* transparent pixel value */
457   GLUTdisplayCB display;  /* redraw  */
458   /* Special Fortran display  unneeded since no
459      parameters! */
460 };
461 
462 typedef struct _GLUTstale GLUTstale;
463 struct _GLUTstale {
464   GLUTwindow *window;
465   Window win;
466   GLUTstale *next;
467 };
468 
469 extern GLUTstale *__glutStaleWindowList;
470 
471 #define GLUT_OVERLAY_EVENT_FILTER_MASK \
472   (ExposureMask | \
473   StructureNotifyMask | \
474   EnterWindowMask | \
475   LeaveWindowMask)
476 #define GLUT_DONT_PROPAGATE_FILTER_MASK \
477   (ButtonReleaseMask | \
478   ButtonPressMask | \
479   KeyPressMask | \
480   KeyReleaseMask | \
481   PointerMotionMask | \
482   Button1MotionMask | \
483   Button2MotionMask | \
484   Button3MotionMask)
485 #define GLUT_HACK_STOP_PROPAGATE_MASK \
486   (KeyPressMask | \
487   KeyReleaseMask)
488 
489 typedef struct _GLUTmenu GLUTmenu;
490 typedef struct _GLUTmenuItem GLUTmenuItem;
491 struct _GLUTmenu {
492   int id;               /* small integer menu id (0-based) */
493   Window win;           /* X window for the menu */
494   GLUTselectCB select;  /*  function of menu */
495   GLUTmenuItem *list;   /* list of menu entries */
496   int num;              /* number of entries */
497 #if !defined(_WIN32)
498   Bool managed;         /* are the InputOnly windows size
499                            validated? */
500   Bool searched;	/* help detect menu loops */
501   int pixheight;        /* height of menu in pixels */
502   int pixwidth;         /* width of menu in pixels */
503 #endif
504   int submenus;         /* number of submenu entries */
505   GLUTmenuItem *highlighted;  /* pointer to highlighted menu
506                                  entry, NULL not highlighted */
507   GLUTmenu *cascade;    /* currently cascading this menu  */
508   GLUTmenuItem *anchor; /* currently anchored to this entry */
509   int x;                /* current x origin relative to the
510                            root window */
511   int y;                /* current y origin relative to the
512                            root window */
513 #ifdef SUPPORT_FORTRAN
514   GLUTselectFCB fselect;  /*  function of menu */
515 #endif
516 };
517 
518 struct _GLUTmenuItem {
519   Window win;           /* InputOnly X window for entry */
520   GLUTmenu *menu;       /* menu entry belongs to */
521   Bool isTrigger;       /* is a submenu trigger? */
522   int value;            /* value to return for selecting this
523                            entry; doubles as submenu id
524                            (0-base) if submenu trigger */
525 #if defined(_WIN32)
526   UINT unique;          /* unique menu item id (Win32 only) */
527 #endif
528   char *label;          /* __glutStrdup'ed label string */
529   int len;              /* length of label string */
530   int pixwidth;         /* width of X window in pixels */
531   GLUTmenuItem *next;   /* next menu entry on list for menu */
532 };
533 
534 typedef struct _GLUTtimer GLUTtimer;
535 struct _GLUTtimer {
536   GLUTtimer *next;      /* list of timers */
537   struct timeval timeout;  /* time to be called */
538   GLUTtimerCB func;     /* timer  (value) */
539   int value;            /*  return value */
540 #ifdef SUPPORT_FORTRAN
541   GLUTtimerFCB ffunc;   /* Fortran timer  */
542 #endif
543 };
544 
545 typedef struct _GLUTeventParser GLUTeventParser;
546 struct _GLUTeventParser {
547   int (*func) (XEvent *);
548   GLUTeventParser *next;
549 };
550 
551 /* Declarations to implement glutFullScreen support with
552    mwm/4Dwm. */
553 
554 /* The following X property format is defined in Motif 1.1's
555    Xm/MwmUtils.h, but GLUT should not depend on that header
556    file. Note: Motif 1.2 expanded this structure with
557    uninteresting fields (to GLUT) so just stick with the
558    smaller Motif 1.1 structure. */
559 typedef struct {
560 #define MWM_HINTS_DECORATIONS   2
561   long flags;
562   long functions;
563   long decorations;
564   long input_mode;
565 } MotifWmHints;
566 
567 /* Make current and buffer swap macros. */
568 #ifdef _WIN32
569 #define MAKE_CURRENT_LAYER(window)                                    \
570   {                                                                   \
571     HGLRC currentContext = wglGetCurrentContext();                    \
572     HDC currentDc = wglGetCurrentDC();                                \
573                                                                       \
574     if (currentContext != window->renderCtx                           \
575       || currentDc != window->renderDc) {                             \
576       wglMakeCurrent(window->renderDc, window->renderCtx);            \
577     }                                                                 \
578   }
579 #define MAKE_CURRENT_WINDOW(window)                                   \
580   {                                                                   \
581     HGLRC currentContext = wglGetCurrentContext();                    \
582     HDC currentDc = wglGetCurrentDC();                                \
583                                                                       \
584     if (currentContext != window->ctx || currentDc != window->hdc) {  \
585       wglMakeCurrent(window->hdc, window->ctx);                       \
586     }                                                                 \
587   }
588 #define MAKE_CURRENT_OVERLAY(overlay) \
589   wglMakeCurrent(overlay->hdc, overlay->ctx)
590 #define UNMAKE_CURRENT() \
591   wglMakeCurrent(NULL, NULL)
592 #define SWAP_BUFFERS_WINDOW(window) \
593   SwapBuffers(window->hdc)
594 #define SWAP_BUFFERS_LAYER(window) \
595   SwapBuffers(window->renderDc)
596 #else
597 #define MAKE_CURRENT_LAYER(window) \
598   glXMakeCurrent(__glutDisplay, window->renderWin, window->renderCtx)
599 #define MAKE_CURRENT_WINDOW(window) \
600   glXMakeCurrent(__glutDisplay, window->win, window->ctx)
601 #define MAKE_CURRENT_OVERLAY(overlay) \
602   glXMakeCurrent(__glutDisplay, overlay->win, overlay->ctx)
603 #define UNMAKE_CURRENT() \
604   glXMakeCurrent(__glutDisplay, None, NULL)
605 #define SWAP_BUFFERS_WINDOW(window) \
606   glXSwapBuffers(__glutDisplay, window->win)
607 #define SWAP_BUFFERS_LAYER(window) \
608   glXSwapBuffers(__glutDisplay, window->renderWin)
609 #endif
610 
611 /* private variables from glut_event.c */
612 extern GLUTwindow *__glutWindowWorkList;
613 extern int __glutWindowDamaged;
614 #ifdef SUPPORT_FORTRAN
615 extern GLUTtimer *__glutTimerList;
616 extern GLUTtimer *__glutNewTimer;
617 #endif
618 extern GLUTmenu *__glutMappedMenu;
619 
620 extern void (*__glutUpdateInputDeviceMaskFunc) (GLUTwindow *);
621 #if !defined(_WIN32)
622 extern void (*__glutMenuItemEnterOrLeave)(GLUTmenuItem * item,
623   int num, int type);
624 extern void (*__glutFinishMenu)(Window win, int x, int y);
625 extern void (*__glutPaintMenu)(GLUTmenu * menu);
626 extern void (*__glutStartMenu)(GLUTmenu * menu,
627   GLUTwindow * window, int x, int y, int x_win, int y_win);
628 extern GLUTmenu * (*__glutGetMenuByNum)(int menunum);
629 extern GLUTmenuItem * (*__glutGetMenuItem)(GLUTmenu * menu,
630   Window win, int *which);
631 extern GLUTmenu * (*__glutGetMenu)(Window win);
632 #endif
633 
634 /* private variables from glut_init.c */
635 extern Atom __glutWMDeleteWindow;
636 extern Display *__glutDisplay;
637 extern unsigned int __glutDisplayMode;
638 extern char *__glutDisplayString;
639 extern XVisualInfo *(*__glutDetermineVisualFromString) (char *string, Bool * treatAsSingle,
640   Criterion * requiredCriteria, int nRequired, int requiredMask, void **fbc);
641 extern GLboolean __glutDebug;
642 extern GLboolean __glutForceDirect;
643 extern GLboolean __glutIconic;
644 extern GLboolean __glutTryDirect;
645 extern Window __glutRoot;
646 extern XSizeHints __glutSizeHints;
647 extern char **__glutArgv;
648 #endif  /* BeOS */
649 extern char *__glutProgramName;
650 #if (!defined(__BEOS__) && !defined(__HAIKU__))
651 extern int __glutArgc;
652 extern int __glutConnectionFD;
653 extern int __glutInitHeight;
654 extern int __glutInitWidth;
655 extern int __glutInitX;
656 extern int __glutInitY;
657 extern int __glutScreen;
658 extern int __glutScreenHeight;
659 extern int __glutScreenWidth;
660 extern Atom __glutMotifHints;
661 extern unsigned int __glutModifierMask;
662 
663 /* private variables from glut_menu.c */
664 extern GLUTmenuItem *__glutItemSelected;
665 extern GLUTmenu **__glutMenuList;
666 extern void (*__glutMenuStatusFunc) (int, int, int);
667 extern void __glutMenuModificationError(void);
668 extern void __glutSetMenuItem(GLUTmenuItem * item,
669   const char *label, int value, Bool isTrigger);
670 
671 /* private variables from glut_win.c */
672 extern GLUTwindow **__glutWindowList;
673 extern GLUTwindow *__glutCurrentWindow;
674 extern GLUTwindow *__glutMenuWindow;
675 extern GLUTmenu *__glutCurrentMenu;
676 extern int __glutWindowListSize;
677 extern void (*__glutFreeOverlayFunc) (GLUToverlay *);
678 extern XVisualInfo *__glutDetermineWindowVisual(Bool * treatAsSingle,
679   Bool * visAlloced, void **fbc);
680 
681 /* private variables from glut_mesa.c */
682 extern int __glutMesaSwapHackSupport;
683 
684 /* private variables from glut_gamemode.c */
685 extern GLUTwindow *__glutGameModeWindow;
686 
687 /* private routines from glut_cindex.c */
688 extern GLUTcolormap * __glutAssociateNewColormap(XVisualInfo * vis);
689 extern void __glutFreeColormap(GLUTcolormap *);
690 
691 /* private routines from glut_cmap.c */
692 extern void __glutSetupColormap(
693   XVisualInfo * vi,
694   GLUTcolormap ** colormap,
695   Colormap * cmap);
696 #if !defined(_WIN32)
697 extern void __glutEstablishColormapsProperty(
698   GLUTwindow * window);
699 extern GLUTwindow *__glutToplevelOf(GLUTwindow * window);
700 #endif
701 
702 /* private routines from glut_cursor.c */
703 extern void __glutSetCursor(GLUTwindow *window);
704 
705 /* private routines from glut_event.c */
706 extern void __glutPutOnWorkList(GLUTwindow * window,
707   int work_mask);
708 extern void __glutRegisterEventParser(GLUTeventParser * parser);
709 extern void __glutPostRedisplay(GLUTwindow * window, int layerMask);
710 
711 /* private routines from glut_init.c */
712 #if !defined(_WIN32)
713 extern void __glutOpenXConnection(char *display);
714 #else
715 extern void __glutOpenWin32Connection(char *display);
716 #endif
717 extern void __glutInitTime(struct timeval *beginning);
718 
719 /* private routines for glut_menu.c (or win32_menu.c) */
720 #if defined(_WIN32)
721 extern GLUTmenu *__glutGetMenu(Window win);
722 extern GLUTmenu *__glutGetMenuByNum(int menunum);
723 extern GLUTmenuItem *__glutGetMenuItem(GLUTmenu * menu,
724   Window win, int *which);
725 extern void __glutStartMenu(GLUTmenu * menu,
726   GLUTwindow * window, int x, int y, int x_win, int y_win);
727 extern void __glutFinishMenu(Window win, int x, int y);
728 #endif
729 extern void __glutSetMenu(GLUTmenu * menu);
730 
731 #endif  /* BeOS */
732 #ifdef __cplusplus
733 extern "C" {
734 #endif
735 /* private routines from glut_util.c */
736 extern char * __glutStrdup(const char *string);
737 extern void __glutWarning(const char *format,...);
738 extern void __glutFatalError(const char *format,...);
739 extern void __glutFatalUsage(const char *format,...);
740 #ifdef __cplusplus
741 }
742 #endif
743 #if (!defined(__BEOS__) && !defined(__HAIKU__))
744 
745 /* private routines from glut_win.c */
746 extern GLUTwindow *__glutGetWindow(Window win);
747 extern void __glutChangeWindowEventMask(long mask, Bool add);
748 extern XVisualInfo *__glutDetermineVisual(
749   unsigned int mode,
750   Bool * fakeSingle,
751   XVisualInfo * (getVisualInfo) (unsigned int));
752 extern XVisualInfo *__glutGetVisualInfo(unsigned int mode);
753 extern void __glutSetWindow(GLUTwindow * window);
754 extern void __glutReshapeFunc(GLUTreshapeCB reshapeFunc,
755   int callingConvention);
756 extern void  __glutDefaultReshape(int, int);
757 extern GLUTwindow *__glutCreateWindow(
758   GLUTwindow * parent,
759   int x, int y, int width, int height, int gamemode);
760 extern void __glutDestroyWindow(
761   GLUTwindow * window,
762   GLUTwindow * initialWindow);
763 
764 #if !defined(_WIN32)
765 /* private routines from glut_glxext.c */
766 extern int __glutIsSupportedByGLX(char *);
767 #endif
768 
769 /* private routines from glut_input.c */
770 extern void  __glutUpdateInputDeviceMask(GLUTwindow * window);
771 
772 /* private routines from glut_mesa.c */
773 extern void __glutDetermineMesaSwapHackSupport(void);
774 
775 /* private routines from glut_gameglut.c */
776 extern void __glutCloseDownGameMode(void);
777 
778 #if defined(_WIN32)
779 /* private routines from win32_*.c */
780 extern LONG WINAPI __glutWindowProc(HWND win, UINT msg, WPARAM w, LPARAM l);
781 extern HDC XHDC;
782 #endif
783 
784 #else  /* BeOS */
785 /* BeOS specific C++ function prototypes */
786 #ifdef __cplusplus
787 
788 #include <SupportDefs.h>
789 
790 /* private routines from glutInit.cpp */
791 void __glutInitTime(bigtime_t *beginning);
792 void __glutInit();
793 void __glutExitCleanup();
794 
795 /* private routines from glutMenu.cpp */
796 class GlutMenu;         // avoid including glutMenu.h
797 GlutMenu *__glutGetMenuByNum(int menunum);
798 
799 /* private routines from glutWindow.cpp */
800 int __glutConvertDisplayMode(unsigned long *options);
801 void __glutDefaultReshape(int width, int height);
802 class GlutWindow;       // avoid including glutWindow.h in every source file
803 void __glutSetWindow(GlutWindow * window);
804 void __glutDestroyAllWindows();
805 
806 /* private routines from glutDstr.cpp */
807 int __glutConvertDisplayModeFromString(unsigned long *options);
808 
809 /* private routines from glutCursor.cpp */
810 void __glutSetCursor(int cursor);
811 
812 #endif /* __cplusplus */
813 #endif  /* BeOS */
814 
815 #endif /* __glutint_h__ */
816