1/* 2 * Copyright 1994-1997 Mark Kilgard, All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Mark Kilgard 7 */ 8#ifndef __glutint_h__ 9#define __glutint_h__ 10 11 12#if defined(__CYGWIN32__) 13#include <sys/time.h> 14#endif 15 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 26 27#include <GL/glut.h> 28 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 35 36#ifdef __vms 37#if ( __VMS_VER < 70000000 ) 38struct timeval { 39 __int64 val; 40}; 41extern 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 ) 54 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. */ 60 61#define TICKS_PER_MILLISECOND 10000 62#define TICKS_PER_SECOND 10000000 63 64#define GETTIMEOFDAY(_x) (void) sys$gettim (_x); 65 66#define ADD_TIME(dest, src1, src2) { \ 67 (dest).val = (src1).val + (src2).val; \ 68} 69 70#define TIMEDELTA(dest, src1, src2) { \ 71 (dest).val = (src1).val - (src2).val; \ 72} 73 74#define IS_AFTER(t1, t2) ((t2).val > (t1).val) 75 76#define IS_AT_OR_AFTER(t1, t2) ((t2).val >= (t1).val) 77 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 } \ 96} 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; \ 103 } \ 104} 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 114 115#define IGNORE_IN_GAME_MODE() \ 116 { if (__glutGameModeWindow) return; } 117 118/* BeOS doesn't need most of this file */ 119#if (!defined(__BEOS__) && !defined(__HAIKU__)) 120 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) 145 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 165 166#define NUM_GLXCAPS (LEVEL + 1) 167 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) 183 184#define NUM_CAPS (NUM_GLXCAPS + 11) 185 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) 192 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 201 202typedef struct _Criterion { 203 int capability; 204 int comparison; 205 int value; 206} Criterion; 207 208typedef struct _FrameBufferMode { 209 XVisualInfo *vi; 210#if defined(GLX_VERSION_1_1) && defined(GLX_SGIX_fbconfig) 211 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. */ 220 221 GLXFBConfigSGIX fbc; 222#endif 223 int valid; 224 int cap[NUM_CAPS]; 225} FrameBufferMode; 226 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" */ 233 234#define NUM_DM_CAPS (DM_NUM+1) 235 236typedef 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; 249 250#endif /* BeOS */ 251 252/* GLUT function types */ 253typedef void (*GLUTdisplayCB) (void); 254typedef void (*GLUTreshapeCB) (int, int); 255typedef void (*GLUTkeyboardCB) (unsigned char, int, int); 256typedef void (*GLUTmouseCB) (int, int, int, int); 257typedef void (*GLUTmotionCB) (int, int); 258typedef void (*GLUTpassiveCB) (int, int); 259typedef void (*GLUTentryCB) (int); 260typedef void (*GLUTvisibilityCB) (int); 261typedef void (*GLUTwindowStatusCB) (int); 262typedef void (*GLUTidleCB) (void); 263typedef void (*GLUTtimerCB) (int); 264typedef void (*GLUTmenuStateCB) (int); /* DEPRICATED. */ 265typedef void (*GLUTmenuStatusCB) (int, int, int); 266typedef void (*GLUTselectCB) (int); 267typedef void (*GLUTspecialCB) (int, int, int); 268typedef void (*GLUTspaceMotionCB) (int, int, int); 269typedef void (*GLUTspaceRotateCB) (int, int, int); 270typedef void (*GLUTspaceButtonCB) (int, int); 271typedef void (*GLUTdialsCB) (int, int); 272typedef void (*GLUTbuttonBoxCB) (int, int); 273typedef void (*GLUTtabletMotionCB) (int, int); 274typedef void (*GLUTtabletButtonCB) (int, int, int, int); 275typedef void (*GLUTjoystickCB) (unsigned int buttonMask, int x, int y, int z); 276#ifdef SUPPORT_FORTRAN 277typedef void (*GLUTdisplayFCB) (void); 278typedef void (*GLUTreshapeFCB) (int *, int *); 279/* NOTE the pressed key is int, not unsigned char for Fortran! */ 280typedef void (*GLUTkeyboardFCB) (int *, int *, int *); 281typedef void (*GLUTmouseFCB) (int *, int *, int *, int *); 282typedef void (*GLUTmotionFCB) (int *, int *); 283typedef void (*GLUTpassiveFCB) (int *, int *); 284typedef void (*GLUTentryFCB) (int *); 285typedef void (*GLUTvisibilityFCB) (int *); 286typedef void (*GLUTwindowStatusFCB) (int *); 287typedef void (*GLUTidleFCB) (void); 288typedef void (*GLUTtimerFCB) (int *); 289typedef void (*GLUTmenuStateFCB) (int *); /* DEPRICATED. */ 290typedef void (*GLUTmenuStatusFCB) (int *, int *, int *); 291typedef void (*GLUTselectFCB) (int *); 292typedef void (*GLUTspecialFCB) (int *, int *, int *); 293typedef void (*GLUTspaceMotionFCB) (int *, int *, int *); 294typedef void (*GLUTspaceRotateFCB) (int *, int *, int *); 295typedef void (*GLUTspaceButtonFCB) (int *, int *); 296typedef void (*GLUTdialsFCB) (int *, int *); 297typedef void (*GLUTbuttonBoxFCB) (int *, int *); 298typedef void (*GLUTtabletMotionFCB) (int *, int *); 299typedef void (*GLUTtabletButtonFCB) (int *, int *, int *, int *); 300typedef void (*GLUTjoystickFCB) (unsigned int *buttonMask, int *x, int *y, int *z); 301#endif 302 303#if (!defined(__BEOS__) && !defined(__HAIKU__)) 304 305typedef struct _GLUTcolorcell GLUTcolorcell; 306struct _GLUTcolorcell { 307 /* GLUT_RED, GLUT_GREEN, GLUT_BLUE */ 308 GLfloat component[3]; 309}; 310 311typedef struct _GLUTcolormap GLUTcolormap; 312struct _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 */ 320}; 321 322typedef struct _GLUTwindow GLUTwindow; 323typedef struct _GLUToverlay GLUToverlay; 324struct _GLUTwindow { 325 int num; /* Small integer window id (0-based). */ 326 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 354 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 378 */ 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 419 */ 420 GLUTvisibilityFCB fvisibility; /* Fortran visibility 421 */ 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 427 */ 428 GLUTspaceRotateFCB fspaceRotate; /* Spaceball rotate 429 */ 430 GLUTspaceButtonFCB fspaceButton; /* Spaceball button 431 */ 432 GLUTtabletMotionFCB ftabletMotion; /* tablet motion 433 */ 434 GLUTtabletButtonFCB ftabletButton; /* tablet button 435 */ 436#ifdef _WIN32 437 GLUTjoystickFCB fjoystick; /* joystick */ 438#endif 439#endif 440}; 441 442struct _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! */ 462}; 463 464typedef struct _GLUTstale GLUTstale; 465struct _GLUTstale { 466 GLUTwindow *window; 467 Window win; 468 GLUTstale *next; 469}; 470 471extern GLUTstale *__glutStaleWindowList; 472 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) 490 491typedef struct _GLUTmenu GLUTmenu; 492typedef struct _GLUTmenuItem GLUTmenuItem; 493struct _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 518}; 519 520struct _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 */ 534}; 535 536typedef struct _GLUTtimer GLUTtimer; 537struct _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 545}; 546 547typedef struct _GLUTeventParser GLUTeventParser; 548struct _GLUTeventParser { 549 int (*func) (XEvent *); 550 GLUTeventParser *next; 551}; 552 553/* Declarations to implement glutFullScreen support with 554 mwm/4Dwm. */ 555 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. */ 561typedef struct { 562#define MWM_HINTS_DECORATIONS 2 563 long flags; 564 long functions; 565 long decorations; 566 long input_mode; 567} MotifWmHints; 568 569/* Make current and buffer swap macros. */ 570#ifdef _WIN32 571#define MAKE_CURRENT_LAYER(window) \ 572 { \ 573 HGLRC currentContext = wglGetCurrentContext(); \ 574 HDC currentDc = wglGetCurrentDC(); \ 575 \ 576 if (currentContext != window->renderCtx \ 577 || currentDc != window->renderDc) { \ 578 wglMakeCurrent(window->renderDc, window->renderCtx); \ 579 } \ 580 } 581#define MAKE_CURRENT_WINDOW(window) \ 582 { \ 583 HGLRC currentContext = wglGetCurrentContext(); \ 584 HDC currentDc = wglGetCurrentDC(); \ 585 \ 586 if (currentContext != window->ctx || currentDc != window->hdc) { \ 587 wglMakeCurrent(window->hdc, window->ctx); \ 588 } \ 589 } 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 612 613/* private variables from glut_event.c */ 614extern GLUTwindow *__glutWindowWorkList; 615extern int __glutWindowDamaged; 616#ifdef SUPPORT_FORTRAN 617extern GLUTtimer *__glutTimerList; 618extern GLUTtimer *__glutNewTimer; 619#endif 620extern GLUTmenu *__glutMappedMenu; 621 622extern void (*__glutUpdateInputDeviceMaskFunc) (GLUTwindow *); 623#if !defined(_WIN32) 624extern void (*__glutMenuItemEnterOrLeave)(GLUTmenuItem * item, 625 int num, int type); 626extern void (*__glutFinishMenu)(Window win, int x, int y); 627extern void (*__glutPaintMenu)(GLUTmenu * menu); 628extern void (*__glutStartMenu)(GLUTmenu * menu, 629 GLUTwindow * window, int x, int y, int x_win, int y_win); 630extern GLUTmenu * (*__glutGetMenuByNum)(int menunum); 631extern GLUTmenuItem * (*__glutGetMenuItem)(GLUTmenu * menu, 632 Window win, int *which); 633extern GLUTmenu * (*__glutGetMenu)(Window win); 634#endif 635 636/* private variables from glut_init.c */ 637extern Atom __glutWMDeleteWindow; 638extern Display *__glutDisplay; 639extern unsigned int __glutDisplayMode; 640extern char *__glutDisplayString; 641extern XVisualInfo *(*__glutDetermineVisualFromString) (char *string, Bool * treatAsSingle, 642 Criterion * requiredCriteria, int nRequired, int requiredMask, void **fbc); 643extern GLboolean __glutDebug; 644extern GLboolean __glutForceDirect; 645extern GLboolean __glutIconic; 646extern GLboolean __glutTryDirect; 647extern Window __glutRoot; 648extern XSizeHints __glutSizeHints; 649extern char **__glutArgv; 650#endif /* BeOS */ 651extern char *__glutProgramName; 652#if (!defined(__BEOS__) && !defined(__HAIKU__)) 653extern int __glutArgc; 654extern int __glutConnectionFD; 655extern int __glutInitHeight; 656extern int __glutInitWidth; 657extern int __glutInitX; 658extern int __glutInitY; 659extern int __glutScreen; 660extern int __glutScreenHeight; 661extern int __glutScreenWidth; 662extern Atom __glutMotifHints; 663extern unsigned int __glutModifierMask; 664 665/* private variables from glut_menu.c */ 666extern GLUTmenuItem *__glutItemSelected; 667extern GLUTmenu **__glutMenuList; 668extern void (*__glutMenuStatusFunc) (int, int, int); 669extern void __glutMenuModificationError(void); 670extern void __glutSetMenuItem(GLUTmenuItem * item, 671 const char *label, int value, Bool isTrigger); 672 673/* private variables from glut_win.c */ 674extern GLUTwindow **__glutWindowList; 675extern GLUTwindow *__glutCurrentWindow; 676extern GLUTwindow *__glutMenuWindow; 677extern GLUTmenu *__glutCurrentMenu; 678extern int __glutWindowListSize; 679extern void (*__glutFreeOverlayFunc) (GLUToverlay *); 680extern XVisualInfo *__glutDetermineWindowVisual(Bool * treatAsSingle, 681 Bool * visAlloced, void **fbc); 682 683/* private variables from glut_mesa.c */ 684extern int __glutMesaSwapHackSupport; 685 686/* private variables from glut_gamemode.c */ 687extern GLUTwindow *__glutGameModeWindow; 688 689/* private routines from glut_cindex.c */ 690extern GLUTcolormap * __glutAssociateNewColormap(XVisualInfo * vis); 691extern void __glutFreeColormap(GLUTcolormap *); 692 693/* private routines from glut_cmap.c */ 694extern void __glutSetupColormap( 695 XVisualInfo * vi, 696 GLUTcolormap ** colormap, 697 Colormap * cmap); 698#if !defined(_WIN32) 699extern void __glutEstablishColormapsProperty( 700 GLUTwindow * window); 701extern GLUTwindow *__glutToplevelOf(GLUTwindow * window); 702#endif 703 704/* private routines from glut_cursor.c */ 705extern void __glutSetCursor(GLUTwindow *window); 706 707/* private routines from glut_event.c */ 708extern void __glutPutOnWorkList(GLUTwindow * window, 709 int work_mask); 710extern void __glutRegisterEventParser(GLUTeventParser * parser); 711extern void __glutPostRedisplay(GLUTwindow * window, int layerMask); 712 713/* private routines from glut_init.c */ 714#if !defined(_WIN32) 715extern void __glutOpenXConnection(char *display); 716#else 717extern void __glutOpenWin32Connection(char *display); 718#endif 719extern void __glutInitTime(struct timeval *beginning); 720 721/* private routines for glut_menu.c (or win32_menu.c) */ 722#if defined(_WIN32) 723extern GLUTmenu *__glutGetMenu(Window win); 724extern GLUTmenu *__glutGetMenuByNum(int menunum); 725extern GLUTmenuItem *__glutGetMenuItem(GLUTmenu * menu, 726 Window win, int *which); 727extern void __glutStartMenu(GLUTmenu * menu, 728 GLUTwindow * window, int x, int y, int x_win, int y_win); 729extern void __glutFinishMenu(Window win, int x, int y); 730#endif 731extern void __glutSetMenu(GLUTmenu * menu); 732 733#endif /* BeOS */ 734#ifdef __cplusplus 735extern "C" { 736#endif 737/* private routines from glut_util.c */ 738extern char * __glutStrdup(const char *string); 739extern void __glutWarning(const char *format,...); 740extern void __glutFatalError(const char *format,...); 741extern void __glutFatalUsage(const char *format,...); 742#ifdef __cplusplus 743} 744#endif 745#if (!defined(__BEOS__) && !defined(__HAIKU__)) 746 747/* private routines from glut_win.c */ 748extern GLUTwindow *__glutGetWindow(Window win); 749extern void __glutChangeWindowEventMask(long mask, Bool add); 750extern XVisualInfo *__glutDetermineVisual( 751 unsigned int mode, 752 Bool * fakeSingle, 753 XVisualInfo * (getVisualInfo) (unsigned int)); 754extern XVisualInfo *__glutGetVisualInfo(unsigned int mode); 755extern void __glutSetWindow(GLUTwindow * window); 756extern void __glutReshapeFunc(GLUTreshapeCB reshapeFunc, 757 int callingConvention); 758extern void __glutDefaultReshape(int, int); 759extern GLUTwindow *__glutCreateWindow( 760 GLUTwindow * parent, 761 int x, int y, int width, int height, int gamemode); 762extern void __glutDestroyWindow( 763 GLUTwindow * window, 764 GLUTwindow * initialWindow); 765 766#if !defined(_WIN32) 767/* private routines from glut_glxext.c */ 768extern int __glutIsSupportedByGLX(char *); 769#endif 770 771/* private routines from glut_input.c */ 772extern void __glutUpdateInputDeviceMask(GLUTwindow * window); 773 774/* private routines from glut_mesa.c */ 775extern void __glutDetermineMesaSwapHackSupport(void); 776 777/* private routines from glut_gameglut.c */ 778extern void __glutCloseDownGameMode(void); 779 780#if defined(_WIN32) 781/* private routines from win32_*.c */ 782extern LONG WINAPI __glutWindowProc(HWND win, UINT msg, WPARAM w, LPARAM l); 783extern HDC XHDC; 784#endif 785 786#else /* BeOS */ 787/* BeOS specific C++ function prototypes */ 788#ifdef __cplusplus 789 790#include <SupportDefs.h> 791 792/* private routines from glutInit.cpp */ 793void __glutInitTime(bigtime_t *beginning); 794void __glutInit(); 795void __glutExitCleanup(); 796 797/* private routines from glutMenu.cpp */ 798class GlutMenu; // avoid including glutMenu.h 799GlutMenu *__glutGetMenuByNum(int menunum); 800 801/* private routines from glutWindow.cpp */ 802int __glutConvertDisplayMode(unsigned long *options); 803void __glutDefaultReshape(int width, int height); 804class GlutWindow; // avoid including glutWindow.h in every source file 805void __glutSetWindow(GlutWindow * window); 806void __glutDestroyAllWindows(); 807 808/* private routines from glutDstr.cpp */ 809int __glutConvertDisplayModeFromString(unsigned long *options); 810 811/* private routines from glutCursor.cpp */ 812void __glutSetCursor(int cursor); 813 814#endif /* __cplusplus */ 815#endif /* BeOS */ 816 817#endif /* __glutint_h__ */ 818