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