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