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