BTRFS: Reimplement TreeIterator, add some error checks and remove redundancies.
[haiku.git] / src / libs / glut / glutint.h
blob6f3d7241ef6391ba65002b50d286a3135fa0cc88
1 /*
2 * Copyright 1994-1997 Mark Kilgard, All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Mark Kilgard
7 */
8 #ifndef __glutint_h__
9 #define __glutint_h__
12 #if defined(__CYGWIN32__)
13 #include <sys/time.h>
14 #endif
16 #if defined(_WIN32)
17 #include "glutwin32.h"
18 #elif !(defined(__BEOS__) || defined(__HAIKU__))
19 #ifdef __sgi
20 #define SUPPORT_FORTRAN
21 #endif
22 #include <X11/Xlib.h>
23 #include <X11/Xutil.h>
24 #include <GL/glx.h>
25 #endif
27 #include <GL/glut.h>
29 /* Non-Win32 platforms need APIENTRY defined to nothing
30 because all the GLUT routines have the APIENTRY prefix
31 to make Win32 happy. */
32 #ifndef APIENTRY
33 #define APIENTRY
34 #endif
36 #ifdef __vms
37 #if ( __VMS_VER < 70000000 )
38 struct timeval {
39 __int64 val;
41 extern int sys$gettim(struct timeval *);
42 #else
43 #include <time.h>
44 #endif
45 #else
46 #include <sys/types.h>
47 #if !defined(_WIN32)
48 #include <sys/time.h>
49 #else
50 #include <winsock.h>
51 #endif
52 #endif
53 #if defined(__vms) && ( __VMS_VER < 70000000 )
55 /* For VMS6.2 or lower :
56 One TICK on VMS is 100 nanoseconds; 0.1 microseconds or
57 0.0001 milliseconds. This means that there are 0.01
58 ticks/ns, 10 ticks/us, 10,000 ticks/ms and 10,000,000
59 ticks/second. */
61 #define TICKS_PER_MILLISECOND 10000
62 #define TICKS_PER_SECOND 10000000
64 #define GETTIMEOFDAY(_x) (void) sys$gettim (_x);
66 #define ADD_TIME(dest, src1, src2) { \
67 (dest).val = (src1).val + (src2).val; \
70 #define TIMEDELTA(dest, src1, src2) { \
71 (dest).val = (src1).val - (src2).val; \
74 #define IS_AFTER(t1, t2) ((t2).val > (t1).val)
76 #define IS_AT_OR_AFTER(t1, t2) ((t2).val >= (t1).val)
78 #else
79 #if defined(SVR4) && !defined(sun) /* Sun claims SVR4, but
80 wants 2 args. */
81 #define GETTIMEOFDAY(_x) gettimeofday(_x)
82 #else
83 #define GETTIMEOFDAY(_x) gettimeofday(_x, NULL)
84 #endif
85 #define ADD_TIME(dest, src1, src2) { \
86 if(((dest).tv_usec = \
87 (src1).tv_usec + (src2).tv_usec) >= 1000000) { \
88 (dest).tv_usec -= 1000000; \
89 (dest).tv_sec = (src1).tv_sec + (src2).tv_sec + 1; \
90 } else { \
91 (dest).tv_sec = (src1).tv_sec + (src2).tv_sec; \
92 if(((dest).tv_sec >= 1) && (((dest).tv_usec <0))) { \
93 (dest).tv_sec --;(dest).tv_usec += 1000000; \
94 } \
95 } \
97 #define TIMEDELTA(dest, src1, src2) { \
98 if(((dest).tv_usec = (src1).tv_usec - (src2).tv_usec) < 0) { \
99 (dest).tv_usec += 1000000; \
100 (dest).tv_sec = (src1).tv_sec - (src2).tv_sec - 1; \
101 } else { \
102 (dest).tv_sec = (src1).tv_sec - (src2).tv_sec; \
105 #define IS_AFTER(t1, t2) \
106 (((t2).tv_sec > (t1).tv_sec) || \
107 (((t2).tv_sec == (t1).tv_sec) && \
108 ((t2).tv_usec > (t1).tv_usec)))
109 #define IS_AT_OR_AFTER(t1, t2) \
110 (((t2).tv_sec > (t1).tv_sec) || \
111 (((t2).tv_sec == (t1).tv_sec) && \
112 ((t2).tv_usec >= (t1).tv_usec)))
113 #endif
115 #define IGNORE_IN_GAME_MODE() \
116 { if (__glutGameModeWindow) return; }
118 /* BeOS doesn't need most of this file */
119 #if (!defined(__BEOS__) && !defined(__HAIKU__))
121 #define GLUT_WIND_IS_RGB(x) (((x) & GLUT_INDEX) == 0)
122 #define GLUT_WIND_IS_INDEX(x) (((x) & GLUT_INDEX) != 0)
123 #define GLUT_WIND_IS_SINGLE(x) (((x) & GLUT_DOUBLE) == 0)
124 #define GLUT_WIND_IS_DOUBLE(x) (((x) & GLUT_DOUBLE) != 0)
125 #define GLUT_WIND_HAS_ACCUM(x) (((x) & GLUT_ACCUM) != 0)
126 #define GLUT_WIND_HAS_ALPHA(x) (((x) & GLUT_ALPHA) != 0)
127 #define GLUT_WIND_HAS_DEPTH(x) (((x) & GLUT_DEPTH) != 0)
128 #define GLUT_WIND_HAS_STENCIL(x) (((x) & GLUT_STENCIL) != 0)
129 #define GLUT_WIND_IS_MULTISAMPLE(x) (((x) & GLUT_MULTISAMPLE) != 0)
130 #define GLUT_WIND_IS_STEREO(x) (((x) & GLUT_STEREO) != 0)
131 #define GLUT_WIND_IS_LUMINANCE(x) (((x) & GLUT_LUMINANCE) != 0)
132 #define GLUT_MAP_WORK (1 << 0)
133 #define GLUT_EVENT_MASK_WORK (1 << 1)
134 #define GLUT_REDISPLAY_WORK (1 << 2)
135 #define GLUT_CONFIGURE_WORK (1 << 3)
136 #define GLUT_COLORMAP_WORK (1 << 4)
137 #define GLUT_DEVICE_MASK_WORK (1 << 5)
138 #define GLUT_FINISH_WORK (1 << 6)
139 #define GLUT_DEBUG_WORK (1 << 7)
140 #define GLUT_DUMMY_WORK (1 << 8)
141 #define GLUT_FULL_SCREEN_WORK (1 << 9)
142 #define GLUT_OVERLAY_REDISPLAY_WORK (1 << 10)
143 #define GLUT_REPAIR_WORK (1 << 11)
144 #define GLUT_OVERLAY_REPAIR_WORK (1 << 12)
146 /* Frame buffer capability macros and types. */
147 #define RGBA 0
148 #define BUFFER_SIZE 1
149 #define DOUBLEBUFFER 2
150 #define STEREO 3
151 #define AUX_BUFFERS 4
152 #define RED_SIZE 5 /* Used as mask bit for
153 "color selected". */
154 #define GREEN_SIZE 6
155 #define BLUE_SIZE 7
156 #define ALPHA_SIZE 8
157 #define DEPTH_SIZE 9
158 #define STENCIL_SIZE 10
159 #define ACCUM_RED_SIZE 11 /* Used as mask bit for
160 "acc selected". */
161 #define ACCUM_GREEN_SIZE 12
162 #define ACCUM_BLUE_SIZE 13
163 #define ACCUM_ALPHA_SIZE 14
164 #define LEVEL 15
166 #define NUM_GLXCAPS (LEVEL + 1)
168 #define XVISUAL (NUM_GLXCAPS + 0)
169 #define TRANSPARENT (NUM_GLXCAPS + 1)
170 #define SAMPLES (NUM_GLXCAPS + 2)
171 #define XSTATICGRAY (NUM_GLXCAPS + 3) /* Used as
172 mask bit
173 for "any
174 visual type
175 selected". */
176 #define XGRAYSCALE (NUM_GLXCAPS + 4)
177 #define XSTATICCOLOR (NUM_GLXCAPS + 5)
178 #define XPSEUDOCOLOR (NUM_GLXCAPS + 6)
179 #define XTRUECOLOR (NUM_GLXCAPS + 7)
180 #define XDIRECTCOLOR (NUM_GLXCAPS + 8)
181 #define SLOW (NUM_GLXCAPS + 9)
182 #define CONFORMANT (NUM_GLXCAPS + 10)
184 #define NUM_CAPS (NUM_GLXCAPS + 11)
186 /* Frame buffer capablities that don't have a corresponding
187 FrameBufferMode entry. These get used as mask bits. */
188 #define NUM (NUM_CAPS + 0)
189 #define RGBA_MODE (NUM_CAPS + 1)
190 #define CI_MODE (NUM_CAPS + 2)
191 #define LUMINANCE_MODE (NUM_CAPS + 3)
193 #define NONE 0
194 #define EQ 1
195 #define NEQ 2
196 #define LTE 3
197 #define GTE 4
198 #define GT 5
199 #define LT 6
200 #define MIN 7
202 typedef struct _Criterion {
203 int capability;
204 int comparison;
205 int value;
206 } Criterion;
208 typedef struct _FrameBufferMode {
209 XVisualInfo *vi;
210 #if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_fbconfig)
212 /* fbc is non-NULL when the XVisualInfo* is not OpenGL-capable
213 (ie, GLX_USE_GL is false), but the SGIX_fbconfig extension shows
214 the visual's fbconfig is OpenGL-capable. The reason for this is typically
215 an RGBA luminance fbconfig such as 16-bit StaticGray that could
216 not be advertised as a GLX visual since StaticGray visuals are
217 required (by the GLX specification) to be color index. The
218 SGIX_fbconfig allows StaticGray visuals to instead advertised as
219 fbconfigs that can provide RGBA luminance support. */
221 GLXFBConfigSGIX fbc;
222 #endif
223 int valid;
224 int cap[NUM_CAPS];
225 } FrameBufferMode;
227 /* DisplayMode capability macros for game mode. */
228 #define DM_WIDTH 0 /* "width" */
229 #define DM_HEIGHT 1 /* "height" */
230 #define DM_PIXEL_DEPTH 2 /* "bpp" (bits per pixel) */
231 #define DM_HERTZ 3 /* "hertz" */
232 #define DM_NUM 4 /* "num" */
234 #define NUM_DM_CAPS (DM_NUM+1)
236 typedef struct _DisplayMode {
237 #ifdef _WIN32
238 DEVMODE devmode;
239 #else
240 /* XXX The X Window System does not have a standard
241 mechanism for display setting changes. On SGI
242 systems, GLUT could use the XSGIvc (SGI X video
243 control extension). Perhaps this can be done in
244 a future release of GLUT. */
245 #endif
246 int valid;
247 int cap[NUM_DM_CAPS];
248 } DisplayMode;
250 #endif /* BeOS */
252 /* GLUT function types */
253 typedef void (*GLUTdisplayCB) (void);
254 typedef void (*GLUTreshapeCB) (int, int);
255 typedef void (*GLUTkeyboardCB) (unsigned char, int, int);
256 typedef void (*GLUTmouseCB) (int, int, int, int);
257 typedef void (*GLUTmotionCB) (int, int);
258 typedef void (*GLUTpassiveCB) (int, int);
259 typedef void (*GLUTentryCB) (int);
260 typedef void (*GLUTvisibilityCB) (int);
261 typedef void (*GLUTwindowStatusCB) (int);
262 typedef void (*GLUTidleCB) (void);
263 typedef void (*GLUTtimerCB) (int);
264 typedef void (*GLUTmenuStateCB) (int); /* DEPRICATED. */
265 typedef void (*GLUTmenuStatusCB) (int, int, int);
266 typedef void (*GLUTselectCB) (int);
267 typedef void (*GLUTspecialCB) (int, int, int);
268 typedef void (*GLUTspaceMotionCB) (int, int, int);
269 typedef void (*GLUTspaceRotateCB) (int, int, int);
270 typedef void (*GLUTspaceButtonCB) (int, int);
271 typedef void (*GLUTdialsCB) (int, int);
272 typedef void (*GLUTbuttonBoxCB) (int, int);
273 typedef void (*GLUTtabletMotionCB) (int, int);
274 typedef void (*GLUTtabletButtonCB) (int, int, int, int);
275 typedef void (*GLUTjoystickCB) (unsigned int buttonMask, int x, int y, int z);
276 #ifdef SUPPORT_FORTRAN
277 typedef void (*GLUTdisplayFCB) (void);
278 typedef void (*GLUTreshapeFCB) (int *, int *);
279 /* NOTE the pressed key is int, not unsigned char for Fortran! */
280 typedef void (*GLUTkeyboardFCB) (int *, int *, int *);
281 typedef void (*GLUTmouseFCB) (int *, int *, int *, int *);
282 typedef void (*GLUTmotionFCB) (int *, int *);
283 typedef void (*GLUTpassiveFCB) (int *, int *);
284 typedef void (*GLUTentryFCB) (int *);
285 typedef void (*GLUTvisibilityFCB) (int *);
286 typedef void (*GLUTwindowStatusFCB) (int *);
287 typedef void (*GLUTidleFCB) (void);
288 typedef void (*GLUTtimerFCB) (int *);
289 typedef void (*GLUTmenuStateFCB) (int *); /* DEPRICATED. */
290 typedef void (*GLUTmenuStatusFCB) (int *, int *, int *);
291 typedef void (*GLUTselectFCB) (int *);
292 typedef void (*GLUTspecialFCB) (int *, int *, int *);
293 typedef void (*GLUTspaceMotionFCB) (int *, int *, int *);
294 typedef void (*GLUTspaceRotateFCB) (int *, int *, int *);
295 typedef void (*GLUTspaceButtonFCB) (int *, int *);
296 typedef void (*GLUTdialsFCB) (int *, int *);
297 typedef void (*GLUTbuttonBoxFCB) (int *, int *);
298 typedef void (*GLUTtabletMotionFCB) (int *, int *);
299 typedef void (*GLUTtabletButtonFCB) (int *, int *, int *, int *);
300 typedef void (*GLUTjoystickFCB) (unsigned int *buttonMask, int *x, int *y, int *z);
301 #endif
303 #if (!defined(__BEOS__) && !defined(__HAIKU__))
305 typedef struct _GLUTcolorcell GLUTcolorcell;
306 struct _GLUTcolorcell {
307 /* GLUT_RED, GLUT_GREEN, GLUT_BLUE */
308 GLfloat component[3];
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 */
322 typedef struct _GLUTwindow GLUTwindow;
323 typedef struct _GLUToverlay GLUToverlay;
324 struct _GLUTwindow {
325 int num; /* Small integer window id (0-based). */
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
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
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 /* Special Fortran display unneeded since no
410 parameters! */
411 GLUTreshapeFCB freshape; /* Fortran reshape */
412 GLUTmouseFCB fmouse; /* Fortran mouse */
413 GLUTmotionFCB fmotion; /* Fortran motion */
414 GLUTpassiveFCB fpassive; /* Fortran passive */
415 GLUTentryFCB fentry; /* Fortran entry */
416 GLUTkeyboardFCB fkeyboard; /* Fortran keyboard */
417 GLUTkeyboardFCB fkeyboardUp; /* Fortran keyboard up */
418 GLUTwindowStatusFCB fwindowStatus; /* Fortran visibility
420 GLUTvisibilityFCB fvisibility; /* Fortran visibility
422 GLUTspecialFCB fspecial; /* special key */
423 GLUTspecialFCB fspecialUp; /* special key up */
424 GLUTbuttonBoxFCB fbuttonBox; /* button box */
425 GLUTdialsFCB fdials; /* dials */
426 GLUTspaceMotionFCB fspaceMotion; /* Spaceball motion
428 GLUTspaceRotateFCB fspaceRotate; /* Spaceball rotate
430 GLUTspaceButtonFCB fspaceButton; /* Spaceball button
432 GLUTtabletMotionFCB ftabletMotion; /* tablet motion
434 GLUTtabletButtonFCB ftabletButton; /* tablet button
436 #ifdef _WIN32
437 GLUTjoystickFCB fjoystick; /* joystick */
438 #endif
439 #endif
442 struct _GLUToverlay {
443 #if defined(_WIN32)
444 int pf;
445 HDC hdc;
446 #endif
447 Window win;
448 GLXContext ctx;
449 XVisualInfo *vis; /* visual for window */
450 Bool visAlloced; /* if vis needs deallocate on destroy */
451 Colormap cmap; /* RGB colormap for window; None if CI */
452 GLUTcolormap *colormap; /* colormap; NULL if RGBA */
453 int shownState; /* if overlay window mapped */
454 Bool treatAsSingle; /* treat as single-buffered */
455 #if !defined(_WIN32)
456 Bool isDirect; /* if direct context */
457 #endif
458 int transparentPixel; /* transparent pixel value */
459 GLUTdisplayCB display; /* redraw */
460 /* Special Fortran display unneeded since no
461 parameters! */
464 typedef struct _GLUTstale GLUTstale;
465 struct _GLUTstale {
466 GLUTwindow *window;
467 Window win;
468 GLUTstale *next;
471 extern GLUTstale *__glutStaleWindowList;
473 #define GLUT_OVERLAY_EVENT_FILTER_MASK \
474 (ExposureMask | \
475 StructureNotifyMask | \
476 EnterWindowMask | \
477 LeaveWindowMask)
478 #define GLUT_DONT_PROPAGATE_FILTER_MASK \
479 (ButtonReleaseMask | \
480 ButtonPressMask | \
481 KeyPressMask | \
482 KeyReleaseMask | \
483 PointerMotionMask | \
484 Button1MotionMask | \
485 Button2MotionMask | \
486 Button3MotionMask)
487 #define GLUT_HACK_STOP_PROPAGATE_MASK \
488 (KeyPressMask | \
489 KeyReleaseMask)
491 typedef struct _GLUTmenu GLUTmenu;
492 typedef struct _GLUTmenuItem GLUTmenuItem;
493 struct _GLUTmenu {
494 int id; /* small integer menu id (0-based) */
495 Window win; /* X window for the menu */
496 GLUTselectCB select; /* function of menu */
497 GLUTmenuItem *list; /* list of menu entries */
498 int num; /* number of entries */
499 #if !defined(_WIN32)
500 Bool managed; /* are the InputOnly windows size
501 validated? */
502 Bool searched; /* help detect menu loops */
503 int pixheight; /* height of menu in pixels */
504 int pixwidth; /* width of menu in pixels */
505 #endif
506 int submenus; /* number of submenu entries */
507 GLUTmenuItem *highlighted; /* pointer to highlighted menu
508 entry, NULL not highlighted */
509 GLUTmenu *cascade; /* currently cascading this menu */
510 GLUTmenuItem *anchor; /* currently anchored to this entry */
511 int x; /* current x origin relative to the
512 root window */
513 int y; /* current y origin relative to the
514 root window */
515 #ifdef SUPPORT_FORTRAN
516 GLUTselectFCB fselect; /* function of menu */
517 #endif
520 struct _GLUTmenuItem {
521 Window win; /* InputOnly X window for entry */
522 GLUTmenu *menu; /* menu entry belongs to */
523 Bool isTrigger; /* is a submenu trigger? */
524 int value; /* value to return for selecting this
525 entry; doubles as submenu id
526 (0-base) if submenu trigger */
527 #if defined(_WIN32)
528 UINT unique; /* unique menu item id (Win32 only) */
529 #endif
530 char *label; /* __glutStrdup'ed label string */
531 int len; /* length of label string */
532 int pixwidth; /* width of X window in pixels */
533 GLUTmenuItem *next; /* next menu entry on list for menu */
536 typedef struct _GLUTtimer GLUTtimer;
537 struct _GLUTtimer {
538 GLUTtimer *next; /* list of timers */
539 struct timeval timeout; /* time to be called */
540 GLUTtimerCB func; /* timer (value) */
541 int value; /* return value */
542 #ifdef SUPPORT_FORTRAN
543 GLUTtimerFCB ffunc; /* Fortran timer */
544 #endif
547 typedef struct _GLUTeventParser GLUTeventParser;
548 struct _GLUTeventParser {
549 int (*func) (XEvent *);
550 GLUTeventParser *next;
553 /* Declarations to implement glutFullScreen support with
554 mwm/4Dwm. */
556 /* The following X property format is defined in Motif 1.1's
557 Xm/MwmUtils.h, but GLUT should not depend on that header
558 file. Note: Motif 1.2 expanded this structure with
559 uninteresting fields (to GLUT) so just stick with the
560 smaller Motif 1.1 structure. */
561 typedef struct {
562 #define MWM_HINTS_DECORATIONS 2
563 long flags;
564 long functions;
565 long decorations;
566 long input_mode;
567 } MotifWmHints;
569 /* Make current and buffer swap macros. */
570 #ifdef _WIN32
571 #define MAKE_CURRENT_LAYER(window) \
573 HGLRC currentContext = wglGetCurrentContext(); \
574 HDC currentDc = wglGetCurrentDC(); \
576 if (currentContext != window->renderCtx \
577 || currentDc != window->renderDc) { \
578 wglMakeCurrent(window->renderDc, window->renderCtx); \
581 #define MAKE_CURRENT_WINDOW(window) \
583 HGLRC currentContext = wglGetCurrentContext(); \
584 HDC currentDc = wglGetCurrentDC(); \
586 if (currentContext != window->ctx || currentDc != window->hdc) { \
587 wglMakeCurrent(window->hdc, window->ctx); \
590 #define MAKE_CURRENT_OVERLAY(overlay) \
591 wglMakeCurrent(overlay->hdc, overlay->ctx)
592 #define UNMAKE_CURRENT() \
593 wglMakeCurrent(NULL, NULL)
594 #define SWAP_BUFFERS_WINDOW(window) \
595 SwapBuffers(window->hdc)
596 #define SWAP_BUFFERS_LAYER(window) \
597 SwapBuffers(window->renderDc)
598 #else
599 #define MAKE_CURRENT_LAYER(window) \
600 glXMakeCurrent(__glutDisplay, window->renderWin, window->renderCtx)
601 #define MAKE_CURRENT_WINDOW(window) \
602 glXMakeCurrent(__glutDisplay, window->win, window->ctx)
603 #define MAKE_CURRENT_OVERLAY(overlay) \
604 glXMakeCurrent(__glutDisplay, overlay->win, overlay->ctx)
605 #define UNMAKE_CURRENT() \
606 glXMakeCurrent(__glutDisplay, None, NULL)
607 #define SWAP_BUFFERS_WINDOW(window) \
608 glXSwapBuffers(__glutDisplay, window->win)
609 #define SWAP_BUFFERS_LAYER(window) \
610 glXSwapBuffers(__glutDisplay, window->renderWin)
611 #endif
613 /* private variables from glut_event.c */
614 extern GLUTwindow *__glutWindowWorkList;
615 extern int __glutWindowDamaged;
616 #ifdef SUPPORT_FORTRAN
617 extern GLUTtimer *__glutTimerList;
618 extern GLUTtimer *__glutNewTimer;
619 #endif
620 extern GLUTmenu *__glutMappedMenu;
622 extern void (*__glutUpdateInputDeviceMaskFunc) (GLUTwindow *);
623 #if !defined(_WIN32)
624 extern void (*__glutMenuItemEnterOrLeave)(GLUTmenuItem * item,
625 int num, int type);
626 extern void (*__glutFinishMenu)(Window win, int x, int y);
627 extern void (*__glutPaintMenu)(GLUTmenu * menu);
628 extern void (*__glutStartMenu)(GLUTmenu * menu,
629 GLUTwindow * window, int x, int y, int x_win, int y_win);
630 extern GLUTmenu * (*__glutGetMenuByNum)(int menunum);
631 extern GLUTmenuItem * (*__glutGetMenuItem)(GLUTmenu * menu,
632 Window win, int *which);
633 extern GLUTmenu * (*__glutGetMenu)(Window win);
634 #endif
636 /* private variables from glut_init.c */
637 extern Atom __glutWMDeleteWindow;
638 extern Display *__glutDisplay;
639 extern unsigned int __glutDisplayMode;
640 extern char *__glutDisplayString;
641 extern XVisualInfo *(*__glutDetermineVisualFromString) (char *string, Bool * treatAsSingle,
642 Criterion * requiredCriteria, int nRequired, int requiredMask, void **fbc);
643 extern GLboolean __glutDebug;
644 extern GLboolean __glutForceDirect;
645 extern GLboolean __glutIconic;
646 extern GLboolean __glutTryDirect;
647 extern Window __glutRoot;
648 extern XSizeHints __glutSizeHints;
649 extern char **__glutArgv;
650 #endif /* BeOS */
651 extern char *__glutProgramName;
652 #if (!defined(__BEOS__) && !defined(__HAIKU__))
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;
665 /* private variables from glut_menu.c */
666 extern GLUTmenuItem *__glutItemSelected;
667 extern GLUTmenu **__glutMenuList;
668 extern void (*__glutMenuStatusFunc) (int, int, int);
669 extern void __glutMenuModificationError(void);
670 extern void __glutSetMenuItem(GLUTmenuItem * item,
671 const char *label, int value, Bool isTrigger);
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 XVisualInfo *__glutDetermineWindowVisual(Bool * treatAsSingle,
681 Bool * visAlloced, void **fbc);
683 /* private variables from glut_mesa.c */
684 extern int __glutMesaSwapHackSupport;
686 /* private variables from glut_gamemode.c */
687 extern GLUTwindow *__glutGameModeWindow;
689 /* private routines from glut_cindex.c */
690 extern GLUTcolormap * __glutAssociateNewColormap(XVisualInfo * vis);
691 extern void __glutFreeColormap(GLUTcolormap *);
693 /* private routines from glut_cmap.c */
694 extern void __glutSetupColormap(
695 XVisualInfo * vi,
696 GLUTcolormap ** colormap,
697 Colormap * cmap);
698 #if !defined(_WIN32)
699 extern void __glutEstablishColormapsProperty(
700 GLUTwindow * window);
701 extern GLUTwindow *__glutToplevelOf(GLUTwindow * window);
702 #endif
704 /* private routines from glut_cursor.c */
705 extern void __glutSetCursor(GLUTwindow *window);
707 /* private routines from glut_event.c */
708 extern void __glutPutOnWorkList(GLUTwindow * window,
709 int work_mask);
710 extern void __glutRegisterEventParser(GLUTeventParser * parser);
711 extern void __glutPostRedisplay(GLUTwindow * window, int layerMask);
713 /* private routines from glut_init.c */
714 #if !defined(_WIN32)
715 extern void __glutOpenXConnection(char *display);
716 #else
717 extern void __glutOpenWin32Connection(char *display);
718 #endif
719 extern void __glutInitTime(struct timeval *beginning);
721 /* private routines for glut_menu.c (or win32_menu.c) */
722 #if defined(_WIN32)
723 extern GLUTmenu *__glutGetMenu(Window win);
724 extern GLUTmenu *__glutGetMenuByNum(int menunum);
725 extern GLUTmenuItem *__glutGetMenuItem(GLUTmenu * menu,
726 Window win, int *which);
727 extern void __glutStartMenu(GLUTmenu * menu,
728 GLUTwindow * window, int x, int y, int x_win, int y_win);
729 extern void __glutFinishMenu(Window win, int x, int y);
730 #endif
731 extern void __glutSetMenu(GLUTmenu * menu);
733 #endif /* BeOS */
734 #ifdef __cplusplus
735 extern "C" {
736 #endif
737 /* private routines from glut_util.c */
738 extern char * __glutStrdup(const char *string);
739 extern void __glutWarning(const char *format,...);
740 extern void __glutFatalError(const char *format,...);
741 extern void __glutFatalUsage(const char *format,...);
742 #ifdef __cplusplus
744 #endif
745 #if (!defined(__BEOS__) && !defined(__HAIKU__))
747 /* private routines from glut_win.c */
748 extern GLUTwindow *__glutGetWindow(Window win);
749 extern void __glutChangeWindowEventMask(long mask, Bool add);
750 extern XVisualInfo *__glutDetermineVisual(
751 unsigned int mode,
752 Bool * fakeSingle,
753 XVisualInfo * (getVisualInfo) (unsigned int));
754 extern XVisualInfo *__glutGetVisualInfo(unsigned int mode);
755 extern void __glutSetWindow(GLUTwindow * window);
756 extern void __glutReshapeFunc(GLUTreshapeCB reshapeFunc,
757 int callingConvention);
758 extern void __glutDefaultReshape(int, int);
759 extern GLUTwindow *__glutCreateWindow(
760 GLUTwindow * parent,
761 int x, int y, int width, int height, int gamemode);
762 extern void __glutDestroyWindow(
763 GLUTwindow * window,
764 GLUTwindow * initialWindow);
766 #if !defined(_WIN32)
767 /* private routines from glut_glxext.c */
768 extern int __glutIsSupportedByGLX(char *);
769 #endif
771 /* private routines from glut_input.c */
772 extern void __glutUpdateInputDeviceMask(GLUTwindow * window);
774 /* private routines from glut_mesa.c */
775 extern void __glutDetermineMesaSwapHackSupport(void);
777 /* private routines from glut_gameglut.c */
778 extern void __glutCloseDownGameMode(void);
780 #if defined(_WIN32)
781 /* private routines from win32_*.c */
782 extern LONG WINAPI __glutWindowProc(HWND win, UINT msg, WPARAM w, LPARAM l);
783 extern HDC XHDC;
784 #endif
786 #else /* BeOS */
787 /* BeOS specific C++ function prototypes */
788 #ifdef __cplusplus
790 #include <SupportDefs.h>
792 /* private routines from glutInit.cpp */
793 void __glutInitTime(bigtime_t *beginning);
794 void __glutInit();
795 void __glutExitCleanup();
797 /* private routines from glutMenu.cpp */
798 class GlutMenu; // avoid including glutMenu.h
799 GlutMenu *__glutGetMenuByNum(int menunum);
801 /* private routines from glutWindow.cpp */
802 int __glutConvertDisplayMode(unsigned long *options);
803 void __glutDefaultReshape(int width, int height);
804 class GlutWindow; // avoid including glutWindow.h in every source file
805 void __glutSetWindow(GlutWindow * window);
806 void __glutDestroyAllWindows();
808 /* private routines from glutDstr.cpp */
809 int __glutConvertDisplayModeFromString(unsigned long *options);
811 /* private routines from glutCursor.cpp */
812 void __glutSetCursor(int cursor);
814 #endif /* __cplusplus */
815 #endif /* BeOS */
817 #endif /* __glutint_h__ */