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