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