1 /* 2 * Copyright 1994-1997 Mark Kilgard, All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * GPL licensing not permitted. 6 * 7 * Authors: 8 * Mark Kilgard 9 */ 10 #ifndef __glutint_h__ 11 #define __glutint_h__ 12 13 14 #if defined(__CYGWIN32__) 15 #include <sys/time.h> 16 #endif 17 18 #if defined(_WIN32) 19 #include "glutwin32.h" 20 #elif !(defined(__BEOS__) || defined(__HAIKU__)) 21 #ifdef __sgi 22 #define SUPPORT_FORTRAN 23 #endif 24 #include <X11/Xlib.h> 25 #include <X11/Xutil.h> 26 #include <GL/glx.h> 27 #endif 28 29 #include <GL/glut.h> 30 31 /* Non-Win32 platforms need APIENTRY defined to nothing 32 because all the GLUT routines have the APIENTRY prefix 33 to make Win32 happy. */ 34 #ifndef APIENTRY 35 #define APIENTRY 36 #endif 37 38 #ifdef __vms 39 #if ( __VMS_VER < 70000000 ) 40 struct timeval { 41 __int64 val; 42 }; 43 extern int sys$gettim(struct timeval *); 44 #else 45 #include <time.h> 46 #endif 47 #else 48 #include <sys/types.h> 49 #if !defined(_WIN32) 50 #include <sys/time.h> 51 #else 52 #include <winsock.h> 53 #endif 54 #endif 55 #if defined(__vms) && ( __VMS_VER < 70000000 ) 56 57 /* For VMS6.2 or lower : 58 One TICK on VMS is 100 nanoseconds; 0.1 microseconds or 59 0.0001 milliseconds. This means that there are 0.01 60 ticks/ns, 10 ticks/us, 10,000 ticks/ms and 10,000,000 61 ticks/second. */ 62 63 #define TICKS_PER_MILLISECOND 10000 64 #define TICKS_PER_SECOND 10000000 65 66 #define GETTIMEOFDAY(_x) (void) sys$gettim (_x); 67 68 #define ADD_TIME(dest, src1, src2) { \ 69 (dest).val = (src1).val + (src2).val; \ 70 } 71 72 #define TIMEDELTA(dest, src1, src2) { \ 73 (dest).val = (src1).val - (src2).val; \ 74 } 75 76 #define IS_AFTER(t1, t2) ((t2).val > (t1).val) 77 78 #define IS_AT_OR_AFTER(t1, t2) ((t2).val >= (t1).val) 79 80 #else 81 #if defined(SVR4) && !defined(sun) /* Sun claims SVR4, but 82 wants 2 args. */ 83 #define GETTIMEOFDAY(_x) gettimeofday(_x) 84 #else 85 #define GETTIMEOFDAY(_x) gettimeofday(_x, NULL) 86 #endif 87 #define ADD_TIME(dest, src1, src2) { \ 88 if(((dest).tv_usec = \ 89 (src1).tv_usec + (src2).tv_usec) >= 1000000) { \ 90 (dest).tv_usec -= 1000000; \ 91 (dest).tv_sec = (src1).tv_sec + (src2).tv_sec + 1; \ 92 } else { \ 93 (dest).tv_sec = (src1).tv_sec + (src2).tv_sec; \ 94 if(((dest).tv_sec >= 1) && (((dest).tv_usec <0))) { \ 95 (dest).tv_sec --;(dest).tv_usec += 1000000; \ 96 } \ 97 } \ 98 } 99 #define TIMEDELTA(dest, src1, src2) { \ 100 if(((dest).tv_usec = (src1).tv_usec - (src2).tv_usec) < 0) { \ 101 (dest).tv_usec += 1000000; \ 102 (dest).tv_sec = (src1).tv_sec - (src2).tv_sec - 1; \ 103 } else { \ 104 (dest).tv_sec = (src1).tv_sec - (src2).tv_sec; \ 105 } \ 106 } 107 #define IS_AFTER(t1, t2) \ 108 (((t2).tv_sec > (t1).tv_sec) || \ 109 (((t2).tv_sec == (t1).tv_sec) && \ 110 ((t2).tv_usec > (t1).tv_usec))) 111 #define IS_AT_OR_AFTER(t1, t2) \ 112 (((t2).tv_sec > (t1).tv_sec) || \ 113 (((t2).tv_sec == (t1).tv_sec) && \ 114 ((t2).tv_usec >= (t1).tv_usec))) 115 #endif 116 117 #define IGNORE_IN_GAME_MODE() \ 118 { if (__glutGameModeWindow) return; } 119 120 /* BeOS doesn't need most of this file */ 121 #if (!defined(__BEOS__) && !defined(__HAIKU__)) 122 123 #define GLUT_WIND_IS_RGB(x) (((x) & GLUT_INDEX) == 0) 124 #define GLUT_WIND_IS_INDEX(x) (((x) & GLUT_INDEX) != 0) 125 #define GLUT_WIND_IS_SINGLE(x) (((x) & GLUT_DOUBLE) == 0) 126 #define GLUT_WIND_IS_DOUBLE(x) (((x) & GLUT_DOUBLE) != 0) 127 #define GLUT_WIND_HAS_ACCUM(x) (((x) & GLUT_ACCUM) != 0) 128 #define GLUT_WIND_HAS_ALPHA(x) (((x) & GLUT_ALPHA) != 0) 129 #define GLUT_WIND_HAS_DEPTH(x) (((x) & GLUT_DEPTH) != 0) 130 #define GLUT_WIND_HAS_STENCIL(x) (((x) & GLUT_STENCIL) != 0) 131 #define GLUT_WIND_IS_MULTISAMPLE(x) (((x) & GLUT_MULTISAMPLE) != 0) 132 #define GLUT_WIND_IS_STEREO(x) (((x) & GLUT_STEREO) != 0) 133 #define GLUT_WIND_IS_LUMINANCE(x) (((x) & GLUT_LUMINANCE) != 0) 134 #define GLUT_MAP_WORK (1 << 0) 135 #define GLUT_EVENT_MASK_WORK (1 << 1) 136 #define GLUT_REDISPLAY_WORK (1 << 2) 137 #define GLUT_CONFIGURE_WORK (1 << 3) 138 #define GLUT_COLORMAP_WORK (1 << 4) 139 #define GLUT_DEVICE_MASK_WORK (1 << 5) 140 #define GLUT_FINISH_WORK (1 << 6) 141 #define GLUT_DEBUG_WORK (1 << 7) 142 #define GLUT_DUMMY_WORK (1 << 8) 143 #define GLUT_FULL_SCREEN_WORK (1 << 9) 144 #define GLUT_OVERLAY_REDISPLAY_WORK (1 << 10) 145 #define GLUT_REPAIR_WORK (1 << 11) 146 #define GLUT_OVERLAY_REPAIR_WORK (1 << 12) 147 148 /* Frame buffer capability macros and types. */ 149 #define RGBA 0 150 #define BUFFER_SIZE 1 151 #define DOUBLEBUFFER 2 152 #define STEREO 3 153 #define AUX_BUFFERS 4 154 #define RED_SIZE 5 /* Used as mask bit for 155 "color selected". */ 156 #define GREEN_SIZE 6 157 #define BLUE_SIZE 7 158 #define ALPHA_SIZE 8 159 #define DEPTH_SIZE 9 160 #define STENCIL_SIZE 10 161 #define ACCUM_RED_SIZE 11 /* Used as mask bit for 162 "acc selected". */ 163 #define ACCUM_GREEN_SIZE 12 164 #define ACCUM_BLUE_SIZE 13 165 #define ACCUM_ALPHA_SIZE 14 166 #define LEVEL 15 167 168 #define NUM_GLXCAPS (LEVEL + 1) 169 170 #define XVISUAL (NUM_GLXCAPS + 0) 171 #define TRANSPARENT (NUM_GLXCAPS + 1) 172 #define SAMPLES (NUM_GLXCAPS + 2) 173 #define XSTATICGRAY (NUM_GLXCAPS + 3) /* Used as 174 mask bit 175 for "any 176 visual type 177 selected". */ 178 #define XGRAYSCALE (NUM_GLXCAPS + 4) 179 #define XSTATICCOLOR (NUM_GLXCAPS + 5) 180 #define XPSEUDOCOLOR (NUM_GLXCAPS + 6) 181 #define XTRUECOLOR (NUM_GLXCAPS + 7) 182 #define XDIRECTCOLOR (NUM_GLXCAPS + 8) 183 #define SLOW (NUM_GLXCAPS + 9) 184 #define CONFORMANT (NUM_GLXCAPS + 10) 185 186 #define NUM_CAPS (NUM_GLXCAPS + 11) 187 188 /* Frame buffer capablities that don't have a corresponding 189 FrameBufferMode entry. These get used as mask bits. */ 190 #define NUM (NUM_CAPS + 0) 191 #define RGBA_MODE (NUM_CAPS + 1) 192 #define CI_MODE (NUM_CAPS + 2) 193 #define LUMINANCE_MODE (NUM_CAPS + 3) 194 195 #define NONE 0 196 #define EQ 1 197 #define NEQ 2 198 #define LTE 3 199 #define GTE 4 200 #define GT 5 201 #define LT 6 202 #define MIN 7 203 204 typedef struct _Criterion { 205 int capability; 206 int comparison; 207 int value; 208 } Criterion; 209 210 typedef struct _FrameBufferMode { 211 XVisualInfo *vi; 212 #if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_fbconfig) 213 214 /* fbc is non-NULL when the XVisualInfo* is not OpenGL-capable 215 (ie, GLX_USE_GL is false), but the SGIX_fbconfig extension shows 216 the visual's fbconfig is OpenGL-capable. The reason for this is typically 217 an RGBA luminance fbconfig such as 16-bit StaticGray that could 218 not be advertised as a GLX visual since StaticGray visuals are 219 required (by the GLX specification) to be color index. The 220 SGIX_fbconfig allows StaticGray visuals to instead advertised as 221 fbconfigs that can provide RGBA luminance support. */ 222 223 GLXFBConfigSGIX fbc; 224 #endif 225 int valid; 226 int cap[NUM_CAPS]; 227 } FrameBufferMode; 228 229 /* DisplayMode capability macros for game mode. */ 230 #define DM_WIDTH 0 /* "width" */ 231 #define DM_HEIGHT 1 /* "height" */ 232 #define DM_PIXEL_DEPTH 2 /* "bpp" (bits per pixel) */ 233 #define DM_HERTZ 3 /* "hertz" */ 234 #define DM_NUM 4 /* "num" */ 235 236 #define NUM_DM_CAPS (DM_NUM+1) 237 238 typedef struct _DisplayMode { 239 #ifdef _WIN32 240 DEVMODE devmode; 241 #else 242 /* XXX The X Window System does not have a standard 243 mechanism for display setting changes. On SGI 244 systems, GLUT could use the XSGIvc (SGI X video 245 control extension). Perhaps this can be done in 246 a future release of GLUT. */ 247 #endif 248 int valid; 249 int cap[NUM_DM_CAPS]; 250 } DisplayMode; 251 252 #endif /* BeOS */ 253 254 /* GLUT function types */ 255 typedef void (*GLUTdisplayCB) (void); 256 typedef void (*GLUTreshapeCB) (int, int); 257 typedef void (*GLUTkeyboardCB) (unsigned char, int, int); 258 typedef void (*GLUTmouseCB) (int, int, int, int); 259 typedef void (*GLUTmotionCB) (int, int); 260 typedef void (*GLUTpassiveCB) (int, int); 261 typedef void (*GLUTentryCB) (int); 262 typedef void (*GLUTvisibilityCB) (int); 263 typedef void (*GLUTwindowStatusCB) (int); 264 typedef void (*GLUTidleCB) (void); 265 typedef void (*GLUTtimerCB) (int); 266 typedef void (*GLUTmenuStateCB) (int); /* DEPRICATED. */ 267 typedef void (*GLUTmenuStatusCB) (int, int, int); 268 typedef void (*GLUTselectCB) (int); 269 typedef void (*GLUTspecialCB) (int, int, int); 270 typedef void (*GLUTspaceMotionCB) (int, int, int); 271 typedef void (*GLUTspaceRotateCB) (int, int, int); 272 typedef void (*GLUTspaceButtonCB) (int, int); 273 typedef void (*GLUTdialsCB) (int, int); 274 typedef void (*GLUTbuttonBoxCB) (int, int); 275 typedef void (*GLUTtabletMotionCB) (int, int); 276 typedef void (*GLUTtabletButtonCB) (int, int, int, int); 277 typedef void (*GLUTjoystickCB) (unsigned int buttonMask, int x, int y, int z); 278 #ifdef SUPPORT_FORTRAN 279 typedef void (*GLUTdisplayFCB) (void); 280 typedef void (*GLUTreshapeFCB) (int *, int *); 281 /* NOTE the pressed key is int, not unsigned char for Fortran! */ 282 typedef void (*GLUTkeyboardFCB) (int *, int *, int *); 283 typedef void (*GLUTmouseFCB) (int *, int *, int *, int *); 284 typedef void (*GLUTmotionFCB) (int *, int *); 285 typedef void (*GLUTpassiveFCB) (int *, int *); 286 typedef void (*GLUTentryFCB) (int *); 287 typedef void (*GLUTvisibilityFCB) (int *); 288 typedef void (*GLUTwindowStatusFCB) (int *); 289 typedef void (*GLUTidleFCB) (void); 290 typedef void (*GLUTtimerFCB) (int *); 291 typedef void (*GLUTmenuStateFCB) (int *); /* DEPRICATED. */ 292 typedef void (*GLUTmenuStatusFCB) (int *, int *, int *); 293 typedef void (*GLUTselectFCB) (int *); 294 typedef void (*GLUTspecialFCB) (int *, int *, int *); 295 typedef void (*GLUTspaceMotionFCB) (int *, int *, int *); 296 typedef void (*GLUTspaceRotateFCB) (int *, int *, int *); 297 typedef void (*GLUTspaceButtonFCB) (int *, int *); 298 typedef void (*GLUTdialsFCB) (int *, int *); 299 typedef void (*GLUTbuttonBoxFCB) (int *, int *); 300 typedef void (*GLUTtabletMotionFCB) (int *, int *); 301 typedef void (*GLUTtabletButtonFCB) (int *, int *, int *, int *); 302 typedef void (*GLUTjoystickFCB) (unsigned int *buttonMask, int *x, int *y, int *z); 303 #endif 304 305 #if (!defined(__BEOS__) && !defined(__HAIKU__)) 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 /* Special Fortran display unneeded since no 412 parameters! */ 413 GLUTreshapeFCB freshape; /* Fortran reshape */ 414 GLUTmouseFCB fmouse; /* Fortran mouse */ 415 GLUTmotionFCB fmotion; /* Fortran motion */ 416 GLUTpassiveFCB fpassive; /* Fortran passive */ 417 GLUTentryFCB fentry; /* Fortran entry */ 418 GLUTkeyboardFCB fkeyboard; /* Fortran keyboard */ 419 GLUTkeyboardFCB fkeyboardUp; /* Fortran keyboard up */ 420 GLUTwindowStatusFCB fwindowStatus; /* Fortran visibility 421 */ 422 GLUTvisibilityFCB fvisibility; /* Fortran visibility 423 */ 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 */ 430 GLUTspaceRotateFCB fspaceRotate; /* Spaceball rotate 431 */ 432 GLUTspaceButtonFCB fspaceButton; /* Spaceball button 433 */ 434 GLUTtabletMotionFCB ftabletMotion; /* tablet motion 435 */ 436 GLUTtabletButtonFCB ftabletButton; /* tablet button 437 */ 438 #ifdef _WIN32 439 GLUTjoystickFCB fjoystick; /* joystick */ 440 #endif 441 #endif 442 }; 443 444 struct _GLUToverlay { 445 #if defined(_WIN32) 446 int pf; 447 HDC hdc; 448 #endif 449 Window win; 450 GLXContext ctx; 451 XVisualInfo *vis; /* visual for window */ 452 Bool visAlloced; /* if vis needs deallocate on destroy */ 453 Colormap cmap; /* RGB colormap for window; None if CI */ 454 GLUTcolormap *colormap; /* colormap; NULL if RGBA */ 455 int shownState; /* if overlay window mapped */ 456 Bool treatAsSingle; /* treat as single-buffered */ 457 #if !defined(_WIN32) 458 Bool isDirect; /* if direct context */ 459 #endif 460 int transparentPixel; /* transparent pixel value */ 461 GLUTdisplayCB display; /* redraw */ 462 /* Special Fortran display unneeded since no 463 parameters! */ 464 }; 465 466 typedef struct _GLUTstale GLUTstale; 467 struct _GLUTstale { 468 GLUTwindow *window; 469 Window win; 470 GLUTstale *next; 471 }; 472 473 extern GLUTstale *__glutStaleWindowList; 474 475 #define GLUT_OVERLAY_EVENT_FILTER_MASK \ 476 (ExposureMask | \ 477 StructureNotifyMask | \ 478 EnterWindowMask | \ 479 LeaveWindowMask) 480 #define GLUT_DONT_PROPAGATE_FILTER_MASK \ 481 (ButtonReleaseMask | \ 482 ButtonPressMask | \ 483 KeyPressMask | \ 484 KeyReleaseMask | \ 485 PointerMotionMask | \ 486 Button1MotionMask | \ 487 Button2MotionMask | \ 488 Button3MotionMask) 489 #define GLUT_HACK_STOP_PROPAGATE_MASK \ 490 (KeyPressMask | \ 491 KeyReleaseMask) 492 493 typedef struct _GLUTmenu GLUTmenu; 494 typedef struct _GLUTmenuItem GLUTmenuItem; 495 struct _GLUTmenu { 496 int id; /* small integer menu id (0-based) */ 497 Window win; /* X window for the menu */ 498 GLUTselectCB select; /* function of menu */ 499 GLUTmenuItem *list; /* list of menu entries */ 500 int num; /* number of entries */ 501 #if !defined(_WIN32) 502 Bool managed; /* are the InputOnly windows size 503 validated? */ 504 Bool searched; /* help detect menu loops */ 505 int pixheight; /* height of menu in pixels */ 506 int pixwidth; /* width of menu in pixels */ 507 #endif 508 int submenus; /* number of submenu entries */ 509 GLUTmenuItem *highlighted; /* pointer to highlighted menu 510 entry, NULL not highlighted */ 511 GLUTmenu *cascade; /* currently cascading this menu */ 512 GLUTmenuItem *anchor; /* currently anchored to this entry */ 513 int x; /* current x origin relative to the 514 root window */ 515 int y; /* current y origin relative to the 516 root window */ 517 #ifdef SUPPORT_FORTRAN 518 GLUTselectFCB fselect; /* function of menu */ 519 #endif 520 }; 521 522 struct _GLUTmenuItem { 523 Window win; /* InputOnly X window for entry */ 524 GLUTmenu *menu; /* menu entry belongs to */ 525 Bool isTrigger; /* is a submenu trigger? */ 526 int value; /* value to return for selecting this 527 entry; doubles as submenu id 528 (0-base) if submenu trigger */ 529 #if defined(_WIN32) 530 UINT unique; /* unique menu item id (Win32 only) */ 531 #endif 532 char *label; /* __glutStrdup'ed label string */ 533 int len; /* length of label string */ 534 int pixwidth; /* width of X window in pixels */ 535 GLUTmenuItem *next; /* next menu entry on list for menu */ 536 }; 537 538 typedef struct _GLUTtimer GLUTtimer; 539 struct _GLUTtimer { 540 GLUTtimer *next; /* list of timers */ 541 struct timeval timeout; /* time to be called */ 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 = wglGetCurrentContext(); \ 576 HDC currentDc = wglGetCurrentDC(); \ 577 \ 578 if (currentContext != window->renderCtx \ 579 || currentDc != window->renderDc) { \ 580 wglMakeCurrent(window->renderDc, window->renderCtx); \ 581 } \ 582 } 583 #define MAKE_CURRENT_WINDOW(window) \ 584 { \ 585 HGLRC currentContext = wglGetCurrentContext(); \ 586 HDC currentDc = wglGetCurrentDC(); \ 587 \ 588 if (currentContext != window->ctx || currentDc != window->hdc) { \ 589 wglMakeCurrent(window->hdc, window->ctx); \ 590 } \ 591 } 592 #define MAKE_CURRENT_OVERLAY(overlay) \ 593 wglMakeCurrent(overlay->hdc, overlay->ctx) 594 #define UNMAKE_CURRENT() \ 595 wglMakeCurrent(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 #endif /* BeOS */ 653 extern char *__glutProgramName; 654 #if (!defined(__BEOS__) && !defined(__HAIKU__)) 655 extern int __glutArgc; 656 extern int __glutConnectionFD; 657 extern int __glutInitHeight; 658 extern int __glutInitWidth; 659 extern int __glutInitX; 660 extern int __glutInitY; 661 extern int __glutScreen; 662 extern int __glutScreenHeight; 663 extern int __glutScreenWidth; 664 extern Atom __glutMotifHints; 665 extern unsigned int __glutModifierMask; 666 667 /* private variables from glut_menu.c */ 668 extern GLUTmenuItem *__glutItemSelected; 669 extern GLUTmenu **__glutMenuList; 670 extern void (*__glutMenuStatusFunc) (int, int, int); 671 extern void __glutMenuModificationError(void); 672 extern void __glutSetMenuItem(GLUTmenuItem * item, 673 const char *label, int value, Bool isTrigger); 674 675 /* private variables from glut_win.c */ 676 extern GLUTwindow **__glutWindowList; 677 extern GLUTwindow *__glutCurrentWindow; 678 extern GLUTwindow *__glutMenuWindow; 679 extern GLUTmenu *__glutCurrentMenu; 680 extern int __glutWindowListSize; 681 extern void (*__glutFreeOverlayFunc) (GLUToverlay *); 682 extern XVisualInfo *__glutDetermineWindowVisual(Bool * treatAsSingle, 683 Bool * visAlloced, void **fbc); 684 685 /* private variables from glut_mesa.c */ 686 extern int __glutMesaSwapHackSupport; 687 688 /* private variables from glut_gamemode.c */ 689 extern GLUTwindow *__glutGameModeWindow; 690 691 /* private routines from glut_cindex.c */ 692 extern GLUTcolormap * __glutAssociateNewColormap(XVisualInfo * vis); 693 extern void __glutFreeColormap(GLUTcolormap *); 694 695 /* private routines from glut_cmap.c */ 696 extern void __glutSetupColormap( 697 XVisualInfo * vi, 698 GLUTcolormap ** colormap, 699 Colormap * cmap); 700 #if !defined(_WIN32) 701 extern void __glutEstablishColormapsProperty( 702 GLUTwindow * window); 703 extern GLUTwindow *__glutToplevelOf(GLUTwindow * window); 704 #endif 705 706 /* private routines from glut_cursor.c */ 707 extern void __glutSetCursor(GLUTwindow *window); 708 709 /* private routines from glut_event.c */ 710 extern void __glutPutOnWorkList(GLUTwindow * window, 711 int work_mask); 712 extern void __glutRegisterEventParser(GLUTeventParser * parser); 713 extern void __glutPostRedisplay(GLUTwindow * window, int layerMask); 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 extern void __glutInitTime(struct timeval *beginning); 722 723 /* private routines for glut_menu.c (or win32_menu.c) */ 724 #if defined(_WIN32) 725 extern GLUTmenu *__glutGetMenu(Window win); 726 extern GLUTmenu *__glutGetMenuByNum(int menunum); 727 extern GLUTmenuItem *__glutGetMenuItem(GLUTmenu * menu, 728 Window win, int *which); 729 extern void __glutStartMenu(GLUTmenu * menu, 730 GLUTwindow * window, int x, int y, int x_win, int y_win); 731 extern void __glutFinishMenu(Window win, int x, int y); 732 #endif 733 extern void __glutSetMenu(GLUTmenu * menu); 734 735 #endif /* BeOS */ 736 #ifdef __cplusplus 737 extern "C" { 738 #endif 739 /* private routines from glut_util.c */ 740 extern char * __glutStrdup(const char *string); 741 extern void __glutWarning(const char *format,...); 742 extern void __glutFatalError(const char *format,...); 743 extern void __glutFatalUsage(const char *format,...); 744 #ifdef __cplusplus 745 } 746 #endif 747 #if (!defined(__BEOS__) && !defined(__HAIKU__)) 748 749 /* private routines from glut_win.c */ 750 extern GLUTwindow *__glutGetWindow(Window win); 751 extern void __glutChangeWindowEventMask(long mask, Bool add); 752 extern XVisualInfo *__glutDetermineVisual( 753 unsigned int mode, 754 Bool * fakeSingle, 755 XVisualInfo * (getVisualInfo) (unsigned int)); 756 extern XVisualInfo *__glutGetVisualInfo(unsigned int mode); 757 extern void __glutSetWindow(GLUTwindow * window); 758 extern void __glutReshapeFunc(GLUTreshapeCB reshapeFunc, 759 int callingConvention); 760 extern void __glutDefaultReshape(int, int); 761 extern GLUTwindow *__glutCreateWindow( 762 GLUTwindow * parent, 763 int x, int y, int width, int height, int gamemode); 764 extern void __glutDestroyWindow( 765 GLUTwindow * window, 766 GLUTwindow * initialWindow); 767 768 #if !defined(_WIN32) 769 /* private routines from glut_glxext.c */ 770 extern int __glutIsSupportedByGLX(char *); 771 #endif 772 773 /* private routines from glut_input.c */ 774 extern void __glutUpdateInputDeviceMask(GLUTwindow * window); 775 776 /* private routines from glut_mesa.c */ 777 extern void __glutDetermineMesaSwapHackSupport(void); 778 779 /* private routines from glut_gameglut.c */ 780 extern void __glutCloseDownGameMode(void); 781 782 #if defined(_WIN32) 783 /* private routines from win32_*.c */ 784 extern LONG WINAPI __glutWindowProc(HWND win, UINT msg, WPARAM w, LPARAM l); 785 extern HDC XHDC; 786 #endif 787 788 #else /* BeOS */ 789 /* BeOS specific C++ function prototypes */ 790 #ifdef __cplusplus 791 792 #include <SupportDefs.h> 793 794 /* private routines from glutInit.cpp */ 795 void __glutInitTime(bigtime_t *beginning); 796 void __glutInit(); 797 void __glutExitCleanup(); 798 799 /* private routines from glutMenu.cpp */ 800 class GlutMenu; // avoid including glutMenu.h 801 GlutMenu *__glutGetMenuByNum(int menunum); 802 803 /* private routines from glutWindow.cpp */ 804 int __glutConvertDisplayMode(unsigned long *options); 805 void __glutDefaultReshape(int width, int height); 806 class GlutWindow; // avoid including glutWindow.h in every source file 807 void __glutSetWindow(GlutWindow * window); 808 void __glutDestroyAllWindows(); 809 810 /* private routines from glutDstr.cpp */ 811 int __glutConvertDisplayModeFromString(unsigned long *options); 812 813 /* private routines from glutCursor.cpp */ 814 void __glutSetCursor(int cursor); 815 816 #endif /* __cplusplus */ 817 #endif /* BeOS */ 818 819 #endif /* __glutint_h__ */ 820