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