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