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