home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / OpenGL 1.0 SDK / Source / Libraries / glut / glutint.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-05-18  |  12.1 KB  |  359 lines  |  [TEXT/CWIE]

  1. #ifndef __glutint_h__
  2. #define __glutint_h__
  3.  
  4. /* Copyright (c) Mark J. Kilgard, 1994. */
  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. #include <timer.h>
  11.  
  12. #include "gl.h"
  13. #include "agl.h"
  14.  
  15. typedef int Bool;
  16.    
  17. #define ADD_TIME(dest, src1, src2) { \
  18.     dest = src1 + src2;\
  19. }
  20.  
  21. #define TIMEDELTA(dest, src1, src2) { \
  22.     dest = src1 - src2;\
  23. }
  24.  
  25. #define IS_AFTER(t1, t2) ((t2) > (t1))
  26. #define IS_AT_OR_AFTER(t1, t2) ((t2) >= (t1))
  27.  
  28. /* Windows: */
  29. #define kMainWindow        128
  30. #define kPlainWindow    129
  31. /* Dilogs: */
  32. #define kAboutDialog    128
  33. /* Menus: */
  34. #define rMenuBar    128
  35. /* Apple menu: */
  36. #define mApple        128
  37. #define    iAbout        1
  38. /* File menu: */
  39. #define mFile        129
  40. #define iQuit        1
  41. /* Edit menu: */
  42. #define mEdit        130
  43. #define    iUndo        1
  44. #define iCut        3
  45. #define    iCopy        4
  46. #define iPaste        5
  47. #define iClear        6
  48. /* Mouse menu items */
  49. #define mMouseMenuStart    131
  50.  
  51.   
  52. #define CWX      0x0001
  53. #define CWY      0x0002
  54. #define CWWidth  0x0004
  55. #define CWHeight 0x0008
  56.  
  57. #define GLUT_WIND_IS_RGB(x)         (((x) & GLUT_INDEX) == 0)
  58. #define GLUT_WIND_IS_INDEX(x)       (((x) & GLUT_INDEX) != 0)
  59. #define GLUT_WIND_IS_SINGLE(x)      (((x) & GLUT_DOUBLE) == 0)
  60. #define GLUT_WIND_IS_DOUBLE(x)      (((x) & GLUT_DOUBLE) != 0)
  61. #define GLUT_WIND_HAS_ACCUM(x)      (((x) & GLUT_ACCUM) != 0)
  62. #define GLUT_WIND_HAS_ALPHA(x)      (((x) & GLUT_ALPHA) != 0)
  63. #define GLUT_WIND_HAS_DEPTH(x)      (((x) & GLUT_DEPTH) != 0)
  64. #define GLUT_WIND_HAS_STENCIL(x)    (((x) & GLUT_STENCIL) != 0)
  65. #define GLUT_WIND_IS_MULTISAMPLE(x) (((x) & GLUT_MULTISAMPLE) != 0)
  66. #define GLUT_WIND_IS_STEREO(x)      (((x) & GLUT_STEREO) != 0)
  67. #define GLUT_WIND_IS_LUMINANCE(x)   (((x) & GLUT_LUMINANCE) != 0)
  68. #define GLUT_WIND_IS_FULLSCREEN(x)  (((x) & GLUT_FULLSCREEN) != 0)
  69.  
  70. #define GLUT_NO_WORK                0x00
  71. #define GLUT_REDISPLAY_WORK         0x01
  72. #define GLUT_COLORMAP_WORK          0x02
  73. #define GLUT_FINISH_WORK            0x04
  74. #define GLUT_DEBUG_WORK                0x08
  75. #define GLUT_BUTTON_WORK            0x10
  76. #define GLUT_PASSIVE_WORK            0x20
  77. #define GLUT_ENTRY_WORK                0x40
  78.  
  79. /* GLUT callback function types */
  80. typedef void (*GLUTdisplayCB) (void);
  81. typedef void (*GLUTreshapeCB) (int, int);
  82. typedef void (*GLUTkeyboardCB) (unsigned char, int, int);
  83. typedef void (*GLUTmouseCB) (int, int, int, int);
  84. typedef void (*GLUTmotionCB) (int, int);
  85. typedef void (*GLUTpassiveCB) (int, int);
  86. typedef void (*GLUTentryCB) (int);
  87. typedef void (*GLUTwindowStatusCB) (int);
  88. typedef void (*GLUTvisibilityCB) (int);
  89. typedef void (*GLUTidleCB) (void);
  90. typedef void (*GLUTtimerCB) (int);
  91. typedef void (*GLUTmenuStateCB) (int);  /* DEPRICATED. */
  92. typedef void (*GLUTmenuStatusCB) (int, int, int);
  93. typedef void (*GLUTselectCB) (int);
  94. typedef void (*GLUTspecialCB) (int, int, int);
  95. typedef void (*GLUTspaceMotionCB) (int, int, int);
  96. typedef void (*GLUTspaceRotateCB) (int, int, int);
  97. typedef void (*GLUTspaceButtonCB) (int, int);
  98. typedef void (*GLUTdialsCB) (int, int);
  99. typedef void (*GLUTbuttonBoxCB) (int, int);
  100. typedef void (*GLUTtabletMotionCB) (int, int);
  101. typedef void (*GLUTtabletButtonCB) (int, int, int, int);
  102. #ifdef SUPPORT_FORTRAN
  103. typedef void (*GLUTdisplayFCB) (void);
  104. typedef void (*GLUTreshapeFCB) (int *, int *);
  105. /* NOTE the pressed key is int, not unsigned char for Fortran! */
  106. typedef void (*GLUTkeyboardFCB) (int *, int *, int *);
  107. typedef void (*GLUTmouseFCB) (int *, int *, int *, int *);
  108. typedef void (*GLUTmotionFCB) (int *, int *);
  109. typedef void (*GLUTpassiveFCB) (int *, int *);
  110. typedef void (*GLUTentryFCB) (int *);
  111. typedef void (*GLUTvisibilityFCB) (int *);
  112. typedef void (*GLUTidleFCB) (void);
  113. typedef void (*GLUTtimerFCB) (int *);
  114. typedef void (*GLUTmenuStateFCB) (int *);  /* DEPRICATED. */
  115. typedef void (*GLUTmenuStatusFCB) (int *, int *, int *);
  116. typedef void (*GLUTselectFCB) (int *);
  117. typedef void (*GLUTspecialFCB) (int *, int *, int *);
  118. typedef void (*GLUTspaceMotionFCB) (int *, int *, int *);
  119. typedef void (*GLUTspaceRotateFCB) (int *, int *, int *);
  120. typedef void (*GLUTspaceButtonFCB) (int *, int *);
  121. typedef void (*GLUTdialsFCB) (int *, int *);
  122. typedef void (*GLUTbuttonBoxFCB) (int *, int *);
  123. typedef void (*GLUTtabletMotionFCB) (int *, int *);
  124. typedef void (*GLUTtabletButtonFCB) (int *, int *, int *, int *);
  125. #endif
  126.  
  127. typedef struct _GLUTcolorcell GLUTcolorcell;
  128. struct _GLUTcolorcell {
  129.   /* GLUT_RED, GLUT_GREEN, GLUT_BLUE */
  130.   GLfloat component[3];
  131. };
  132.  
  133. typedef struct _GLUTcolormap GLUTcolormap;
  134. struct _GLUTcolormap {
  135.   CSpecArray cmap;      /* Macintosh colormap ID */
  136.   int refcnt;           /* number of windows using colormap */
  137.   int size;             /* number of cells in colormap */
  138.   int transparent;      /* transparent pixel, or -1 if opaque */
  139.   GLUTcolorcell *cells; /* array of cells */
  140.   GLUTcolormap *next;   /* next colormap in list */
  141. };
  142.  
  143. typedef struct _GLUTwindow GLUTwindow;
  144.  
  145. struct _GLUTwindow {
  146.   int num;              /* small integer window id (0-based) */
  147.   /* CWindowPtr system related state. */
  148.   CWindowPtr win;           /* X window for GLUT window */
  149.   AGLContext ctx;       /* OpenGL context GLUT glut window */
  150.   AGLPixelFormat vis;     /* visual for window */
  151.   char title[100];
  152.  
  153.   CSpecArray cmap;        /* RGB colormap for window; None if CI */
  154.   GLUTcolormap *colormap;  /* colormap; NULL if RGBA */
  155.  
  156.   CWindowPtr renderWin;     /* AGL window for rendering (might be
  157.                            overlay) */
  158.   AGLContext renderCtx; /* OpenGL context for rendering (might
  159.                            be overlay) */
  160.                            
  161.   GLboolean fullscreen;
  162.   /* GLUT settable or visible window state. */
  163.   int width;            /* window width in pixels */
  164.   int height;           /* window height in pixels */
  165.   int cursor;           /* cursor name */
  166.  
  167.   #define               MAX_MENUS 3
  168.   int                   menus[MAX_MENUS];
  169.  
  170.   /* CWindowPtr relationship state. */
  171.   GLUTwindow *parent;   /* parent window */
  172.   GLUTwindow *children; /* list of children */
  173.   GLUTwindow *siblings; /* list of siblings */
  174.   /* Misc. non-API visible (hidden) state. */
  175.   Bool treatAsSingle;   /* treat this window as single-buffered
  176.                            (it might be "fake" though) */
  177.   Bool forceReshape;    /* force reshape before display */
  178.  
  179.   int button_press;
  180.   
  181.   /* Work list related state. */
  182.   unsigned int workMask;  /* mask of window work to be done */
  183.   GLUTwindow *prevWorkWin;  /* link list of windows to work on */
  184.   
  185.   /* Callbacks */
  186.   GLUTdisplayCB display;  /* redraw callback */
  187.   GLUTreshapeCB reshape;  /* resize callback (width,height) */
  188.   GLUTvisibilityCB visibility;
  189.   GLUTmouseCB mouse;    /* mouse callback (button,state,x,y) */
  190.   GLUTmotionCB motion;  /* motion callback (x,y) */
  191.   GLUTpassiveCB passive;  /* passive motion callback (x,y) */
  192.   GLUTkeyboardCB keyboard;  /* keyboard callback (ASCII,x,y) */
  193.   GLUTspecialCB special;  /* special key callback */
  194.   GLUTentryCB entry;  /* entry callback */
  195.   GLUTmenuStateCB menu_state;
  196.   GLUTmenuStatusCB menu_status;
  197.   GLUTwindowStatusCB window_status;
  198.   unsigned int entry_mode;  /* last entry mode */
  199. #ifdef SUPPORT_FORTRAN
  200.   /* Special Fortran display callback unneeded since no
  201.      parameters! */
  202.   GLUTreshapeFCB freshape;  /* Fortran reshape callback */
  203.   GLUTmouseFCB fmouse;  /* Fortran mouse callback */
  204.   GLUTmotionFCB fmotion;  /* Fortran motion callback */
  205.   GLUTpassiveFCB fpassive;  /* Fortran passive callback */
  206.   GLUTkeyboardFCB fkeyboard;  /* Fortran keyboard callback */
  207.   GLUTspecialFCB fspecial;  /* special key callback */
  208. #endif
  209. };
  210.  
  211. typedef struct _GLUTtimer GLUTtimer;
  212. struct _GLUTtimer {
  213.   GLUTtimer *next;      /* list of timers */
  214.   double timeout;       /* time to be called */
  215.   GLUTtimerCB func;     /* timer callback (value) */
  216.   int value;            /* callback return value */
  217. #ifdef SUPPORT_FORTRAN
  218.   GLUTtimerFCB ffunc;   /* Fortran timer callback */
  219. #endif
  220. };
  221.  
  222. /* Frame buffer capability macros and types. */
  223. #define BUFFER_SIZE             0
  224. #define RGBA                    1
  225. #define DOUBLEBUFFER            2
  226. #define STEREO                  3
  227. #define AUX_BUFFERS             4
  228. #define RED_SIZE                5  /* Used as mask bit for
  229.                                       "color selected". */
  230. #define GREEN_SIZE              6
  231. #define BLUE_SIZE               7
  232. #define ALPHA_SIZE              8
  233. #define DEPTH_SIZE              9
  234. #define STENCIL_SIZE            10
  235. #define ACCUM_RED_SIZE          11  /* Used as mask bit for
  236.                                        "acc selected". */
  237. #define ACCUM_GREEN_SIZE        12
  238. #define ACCUM_BLUE_SIZE         13
  239. #define ACCUM_ALPHA_SIZE        14
  240. #define LEVEL                   15
  241.  
  242. #define CONFORMANT              16
  243. #define SAMPLES                 17
  244. #define SLOW                    18
  245.  
  246. #define FULLSCREEN              19
  247.  
  248. #define NUM_CAPS                (FULLSCREEN + 1)
  249.  
  250. /* Frame buffer capablities that don't have a corresponding
  251.    FrameBufferMode entry.  These get used as mask bits. */
  252. #define NUM                     NUM_CAPS + 0
  253. #define RGBA_MODE               NUM_CAPS + 1
  254. #define CI_MODE                 NUM_CAPS + 2
  255.  
  256. #define NONE            0
  257. #define EQ            1
  258. #define NEQ            2
  259. #define LTE            3
  260. #define GTE            4
  261. #define GT            5
  262. #define LT            6
  263. #define MIN            7
  264.  
  265. typedef struct _Criterion {
  266.   int capability;
  267.   int comparison;
  268.   int value;
  269. } Criterion;
  270.  
  271. /* private variables from glut_event.c */
  272. extern GLUTwindow *__glutWindowWorkList;
  273. extern int __glutWindowDamaged;
  274. extern GLUTtimer *freeTimerList;
  275. #ifdef SUPPORT_FORTRAN
  276. extern GLUTtimer *__glutTimerList;
  277. extern GLUTtimer *__glutNewTimer;
  278. #endif
  279.  
  280. /* private variables from glut_init.c */
  281. extern unsigned int __glutDisplayMode;
  282. extern char *__glutDisplayString;
  283. extern GLboolean __glutDebug;
  284. extern char **__glutArgv;
  285. extern char *__glutProgramName;
  286. extern int __glutArgc;
  287. extern int __glutInitHeight;
  288. extern int __glutInitWidth;
  289. extern int __glutInitX;
  290. extern int __glutInitY;
  291. extern unsigned int __glutModifierMask;
  292.  
  293. /* private variables from glut_menu.c */
  294. extern void (*__glutMenuStatusFunc) (int, int, int);
  295. extern void __glutMenuKeyCommand(void);
  296. extern void __glutBuildMenuBar(void);
  297. extern void __glutMenuCommand(short menuNum, short itemNum);
  298.  
  299. /* private variables from glut_win.c */
  300. extern GLUTwindow **__glutWindowList;
  301. extern GLUTwindow *__glutCurrentWindow;
  302. extern int __glutWindowListSize;
  303. extern void __glutWindowReshape(GLUTwindow *gwindow, int width,int height);
  304.  
  305. /* private routines from glut_cindex.c */
  306. extern GLUTcolormap *__glutAssociateColormap(AGLPixelFormat vis);
  307. extern void __glutFreeColormap(GLUTcolormap *);
  308.  
  309. /* private routines from glut_init.c */
  310. extern void __glutInitTime(double *beginning);
  311. extern double __glutTime(void);
  312.  
  313. /* private routines from glut_util.c */
  314. extern void __glutWarning(const char *format,...);
  315. extern void __glutFatalError(const char *format,...);
  316. extern void __glutFatalUsage(const char *format,...);
  317.  
  318. /* private routines from glut_win.c */
  319. extern GLUTwindow *__glutGetWindow(CWindowPtr win);
  320. extern void __glutRemoveFromWorkList(GLUTwindow *window);
  321. extern void __glutEstablishColormapsProperty(
  322.   GLUTwindow * window);
  323. extern AGLPixelFormat __glutDetermineVisual(
  324.   unsigned int mode,
  325.   Bool * fakeSingle,
  326.   AGLPixelFormat (getVisualInfo) (unsigned int));
  327. extern AGLPixelFormat __glutGetVisualInfo(unsigned int mode);
  328. extern int __glutSetCurrentWindow(GLUTwindow * window);
  329. extern void __glutDefaultReshape(int, int);
  330.  
  331. extern GLboolean __glutPointInWindow(GLUTwindow *window, Point *point);
  332. extern void __glutCToStr255(const char *cs, Str255 ps);
  333.  
  334. extern void __glutSetupColormap(
  335.   AGLPixelFormat vi,
  336.   GLUTcolormap ** colormap,
  337.   CSpecArray * cmap);
  338.   
  339. extern void __glutRebuildMenuBar(void);
  340. extern int __glutGetCurNumMenuItems(void);
  341.   
  342. extern void __glutDefaultDisplay(void);
  343. extern void __glutCToPStr(const char *cs, Str255 ps);
  344.  
  345. extern void __glutInitApp(void);
  346.  
  347. extern GLUTwindow *__glutCreateWindow(GLUTwindow * parent, const char *title, int x, int y, int width, int height, int win_type);
  348. extern void __glutDestroyWindow(GLUTwindow * window, GLUTwindow * initialWindow);
  349.  
  350. /* private routines from glut_ext.c */
  351. extern int __glutIsSupportedByAGL(const char *);
  352.  
  353. extern void __glutPutOnWorkList(GLUTwindow * window, int workMask);
  354.  
  355. extern char * __glutStrdup(const char *string);
  356. extern AGLPixelFormat __glutVisualInfoFromString(char *string);
  357.  
  358. #endif /* __glutint_h__ */
  359.