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