home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mesa5.zip / mesa5src.zip / MesaDLL / GL / glutint.h < prev    next >
C/C++ Source or Header  |  2002-12-25  |  32KB  |  847 lines

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