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