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