Debian Codegraph @

nx-X11/extras/Mesa/include/GL/internal/glcore.h

raw
1 /* $XFree86: xc/lib/GL/include/GL/internal/glcore.h,v 1.7 2001/03/25 05:32:00 tsi Exp $ */
2 #ifndef __gl_core_h_
3 #define __gl_core_h_
4
5 /*
6 ** License Applicability. Except to the extent portions of this file are
7 ** made subject to an alternative license as permitted in the SGI Free
8 ** Software License B, Version 1.1 (the "License"), the contents of this
9 ** file are subject only to the provisions of the License. You may not use
10 ** this file except in compliance with the License. You may obtain a copy
11 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
12 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
13 **
14 ** http://oss.sgi.com/projects/FreeB
15 **
16 ** Note that, as provided in the License, the Software is distributed on an
17 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
18 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
19 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
20 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
21 **
22 ** Original Code. The Original Code is: OpenGL Sample Implementation,
23 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
24 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
25 ** Copyright in any portions created by third parties is as indicated
26 ** elsewhere herein. All Rights Reserved.
27 **
28 ** Additional Notice Provisions: The application programming interfaces
29 ** established by SGI in conjunction with the Original Code are The
30 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
31 ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
32 ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
33 ** Window System(R) (Version 1.3), released October 19, 1998. This software
34 ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
35 ** published by SGI, but has not been independently verified as being
36 ** compliant with the OpenGL(R) version 1.2.1 Specification.
37 **
38 */
39
40 #ifndef XFree86LOADER
41 #include <sys/types.h>
42 #endif
43
44 #ifdef CAPI
45 #undef CAPI
46 #endif
47 #define CAPI
48
49 #define GL_CORE_SGI 1
50 #define GL_CORE_MESA 2
51 #define GL_CORE_APPLE 4
52
53 typedef struct __GLcontextRec __GLcontext;
54 typedef struct __GLinterfaceRec __GLinterface;
55
56 /*
57 ** This file defines the interface between the GL core and the surrounding
58 ** "operating system" that supports it (currently the GLX or WGL extensions).
59 **
60 ** Members (data and function pointers) are documented as imported or
61 ** exported according to how they are used by the core rendering functions.
62 ** Imported members are initialized by the "operating system" and used by
63 ** the core functions. Exported members are initialized by the core functions
64 ** and used by the "operating system".
65 */
66
67 /*
68 ** Mode and limit information for a context. This information is
69 ** kept around in the context so that values can be used during
70 ** command execution, and for returning information about the
71 ** context to the application.
72 */
73 typedef struct __GLcontextModesRec {
74 struct __GLcontextModesRec * next;
75
76 GLboolean rgbMode;
77 GLboolean floatMode;
78 GLboolean colorIndexMode;
79 GLuint doubleBufferMode;
80 GLuint stereoMode;
81
82 GLboolean haveAccumBuffer;
83 GLboolean haveDepthBuffer;
84 GLboolean haveStencilBuffer;
85
86 GLint redBits, greenBits, blueBits, alphaBits; /* bits per comp */
87 GLuint redMask, greenMask, blueMask, alphaMask;
88 GLint rgbBits; /* total bits for rgb */
89 GLint indexBits; /* total bits for colorindex */
90
91 GLint accumRedBits, accumGreenBits, accumBlueBits, accumAlphaBits;
92 GLint depthBits;
93 GLint stencilBits;
94
95 GLint numAuxBuffers;
96
97 GLint level;
98
99 GLint pixmapMode;
100
101 /* GLX */
102 GLint visualID;
103 GLint visualType; /**< One of the GLX X visual types. (i.e.,
104 * \c GLX_TRUE_COLOR, etc.)
105 */
106
107 /* EXT_visual_rating / GLX 1.2 */
108 GLint visualRating;
109
110 /* EXT_visual_info / GLX 1.2 */
111 GLint transparentPixel;
112 /* colors are floats scaled to ints */
113 GLint transparentRed, transparentGreen, transparentBlue, transparentAlpha;
114 GLint transparentIndex;
115
116 /* ARB_multisample / SGIS_multisample */
117 GLint sampleBuffers;
118 GLint samples;
119
120 /* SGIX_fbconfig / GLX 1.3 */
121 GLint drawableType;
122 GLint renderType;
123 GLint xRenderable;
124 GLint fbconfigID;
125
126 /* SGIX_pbuffer / GLX 1.3 */
127 GLint maxPbufferWidth;
128 GLint maxPbufferHeight;
129 GLint maxPbufferPixels;
130 GLint optimalPbufferWidth; /* Only for SGIX_pbuffer. */
131 GLint optimalPbufferHeight; /* Only for SGIX_pbuffer. */
132
133 /* SGIX_visual_select_group */
134 GLint visualSelectGroup;
135
136 /* OML_swap_method */
137 GLint swapMethod;
138
139 GLint screen;
140 } __GLcontextModes;
141
142 /* Several fields of __GLcontextModes can take these as values. Since
143 * GLX header files may not be available everywhere they need to be used,
144 * redefine them here.
145 */
146 #define GLX_NONE 0x8000
147 #define GLX_SLOW_CONFIG 0x8001
148 #define GLX_TRUE_COLOR 0x8002
149 #define GLX_DIRECT_COLOR 0x8003
150 #define GLX_PSEUDO_COLOR 0x8004
151 #define GLX_STATIC_COLOR 0x8005
152 #define GLX_GRAY_SCALE 0x8006
153 #define GLX_STATIC_GRAY 0x8007
154 #define GLX_TRANSPARENT_RGB 0x8008
155 #define GLX_TRANSPARENT_INDEX 0x8009
156 #define GLX_NON_CONFORMANT_CONFIG 0x800D
157 #define GLX_SWAP_EXCHANGE_OML 0x8061
158 #define GLX_SWAP_COPY_OML 0x8062
159 #define GLX_SWAP_UNDEFINED_OML 0x8063
160
161 #define GLX_DONT_CARE 0xFFFFFFFF
162
163 #define GLX_RGBA_BIT 0x00000001
164 #define GLX_COLOR_INDEX_BIT 0x00000002
165 #define GLX_WINDOW_BIT 0x00000001
166 #define GLX_PIXMAP_BIT 0x00000002
167 #define GLX_PBUFFER_BIT 0x00000004
168
169 /************************************************************************/
170
171 /*
172 ** Structure used for allocating and freeing drawable private memory.
173 ** (like software buffers, for example).
174 **
175 ** The memory allocation routines are provided by the surrounding
176 ** "operating system" code, and they are to be used for allocating
177 ** software buffers and things which are associated with the drawable,
178 ** and used by any context which draws to that drawable. There are
179 ** separate memory allocation functions for drawables and contexts
180 ** since drawables and contexts can be created and destroyed independently
181 ** of one another, and the "operating system" may want to use separate
182 ** allocation arenas for each.
183 **
184 ** The freePrivate function is filled in by the core routines when they
185 ** allocates software buffers, and stick them in "private". The freePrivate
186 ** function will destroy anything allocated to this drawable (to be called
187 ** when the drawable is destroyed).
188 */
189 typedef struct __GLdrawableRegionRec __GLdrawableRegion;
190 typedef struct __GLdrawableBufferRec __GLdrawableBuffer;
191 typedef struct __GLdrawablePrivateRec __GLdrawablePrivate;
192
193 typedef struct __GLregionRectRec {
194 /* lower left (inside the rectangle) */
195 GLint x0, y0;
196 /* upper right (outside the rectangle) */
197 GLint x1, y1;
198 } __GLregionRect;
199
200 struct __GLdrawableRegionRec {
201 GLint numRects;
202 __GLregionRect *rects;
203 __GLregionRect boundingRect;
204 };
205
206 /************************************************************************/
207
208 /* masks for the buffers */
209 #define __GL_FRONT_BUFFER_MASK 0x00000001
210 #define __GL_FRONT_LEFT_BUFFER_MASK 0x00000001
211 #define __GL_FRONT_RIGHT_BUFFER_MASK 0x00000002
212 #define __GL_BACK_BUFFER_MASK 0x00000004
213 #define __GL_BACK_LEFT_BUFFER_MASK 0x00000004
214 #define __GL_BACK_RIGHT_BUFFER_MASK 0x00000008
215 #define __GL_ACCUM_BUFFER_MASK 0x00000010
216 #define __GL_DEPTH_BUFFER_MASK 0x00000020
217 #define __GL_STENCIL_BUFFER_MASK 0x00000040
218 #define __GL_AUX_BUFFER_MASK(i) (0x0000080 << (i))
219
220 #define __GL_ALL_BUFFER_MASK 0xffffffff
221
222 /* what Resize routines return if resize resorted to fallback case */
223 #define __GL_BUFFER_FALLBACK 0x10
224
225 typedef void (*__GLbufFallbackInitFn)(__GLdrawableBuffer *buf,
226 __GLdrawablePrivate *glPriv, GLint bits);
227 typedef void (*__GLbufMainInitFn)(__GLdrawableBuffer *buf,
228 __GLdrawablePrivate *glPriv, GLint bits,
229 __GLbufFallbackInitFn back);
230
231 /*
232 ** A drawable buffer
233 **
234 ** This data structure describes the context side of a drawable.
235 **
236 ** According to the spec there could be multiple contexts bound to the same
237 ** drawable at the same time (from different threads). In order to avoid
238 ** multiple-access conflicts, locks are used to serialize access. When a
239 ** thread needs to access (read or write) a member of the drawable, it takes
240 ** a lock first. Some of the entries in the drawable are treated "mostly
241 ** constant", so we take the freedom of allowing access to them without
242 ** taking a lock (for optimization reasons).
243 **
244 ** For more details regarding locking, see buffers.h in the GL core
245 */
246 struct __GLdrawableBufferRec {
247 /*
248 ** Buffer dimensions
249 */
250 GLint width, height, depth;
251
252 /*
253 ** Framebuffer base address
254 */
255 void *base;
256
257 /*
258 ** Framebuffer size (in bytes)
259 */
260 GLuint size;
261
262 /*
263 ** Size (in bytes) of each element in the framebuffer
264 */
265 GLuint elementSize;
266 GLuint elementSizeLog2;
267
268 /*
269 ** Element skip from one scanline to the next.
270 ** If the buffer is part of another buffer (for example, fullscreen
271 ** front buffer), outerWidth is the width of that buffer.
272 */
273 GLint outerWidth;
274
275 /*
276 ** outerWidth * elementSize
277 */
278 GLint byteWidth;
279
280 /*
281 ** Allocation/deallocation is done based on this handle. A handle
282 ** is conceptually different from the framebuffer 'base'.
283 */
284 void *handle;
285
286 /* imported */
287 GLboolean (*resize)(__GLdrawableBuffer *buf,
288 GLint x, GLint y, GLuint width, GLuint height,
289 __GLdrawablePrivate *glPriv, GLuint bufferMask);
290 void (*lock)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv);
291 void (*unlock)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv);
292 void (*fill)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv,
293 GLuint val, GLint x, GLint y, GLint w, GLint h);
294 void (*free)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv);
295
296 /* exported */
297 void (*freePrivate)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv);
298 #ifdef __cplusplus
299 void *privatePtr;
300 #else
301 void *private;
302 #endif
303
304 /* private */
305 void *other; /* implementation private data */
306 __GLbufMainInitFn mainInit;
307 __GLbufFallbackInitFn fallbackInit;
308 };
309
310 /*
311 ** The context side of the drawable private
312 */
313 struct __GLdrawablePrivateRec {
314 /*
315 ** Drawable Modes
316 */
317 __GLcontextModes *modes;
318
319 /*
320 ** Drawable size
321 */
322 GLuint width, height;
323
324 /*
325 ** Origin in screen coordinates of the drawable
326 */
327 GLint xOrigin, yOrigin;
328 #ifdef __GL_ALIGNED_BUFFERS
329 /*
330 ** Drawable offset from screen origin
331 */
332 GLint xOffset, yOffset;
333
334 /*
335 ** Alignment restriction
336 */
337 GLint xAlignment, yAlignment;
338 #endif
339 /*
340 ** Should we invert the y axis?
341 */
342 GLint yInverted;
343
344 /*
345 ** Mask specifying which buffers are renderable by the hw
346 */
347 GLuint accelBufferMask;
348
349 /*
350 ** the buffers themselves
351 */
352 __GLdrawableBuffer frontBuffer;
353 __GLdrawableBuffer backBuffer;
354 __GLdrawableBuffer accumBuffer;
355 __GLdrawableBuffer depthBuffer;
356 __GLdrawableBuffer stencilBuffer;
357 #if defined(__GL_NUMBER_OF_AUX_BUFFERS) && (__GL_NUMBER_OF_AUX_BUFFERS > 0)
358 __GLdrawableBuffer *auxBuffer;
359 #endif
360
361 __GLdrawableRegion ownershipRegion;
362
363 /*
364 ** Lock for the drawable private structure
365 */
366 void *lock;
367 #ifdef DEBUG
368 /* lock debugging info */
369 int lockRefCount;
370 int lockLine[10];
371 char *lockFile[10];
372 #endif
373
374 /* imported */
375 void *(*malloc)(size_t size);
376 void *(*calloc)(size_t numElem, size_t elemSize);
377 void *(*realloc)(void *oldAddr, size_t newSize);
378 void (*free)(void *addr);
379
380 GLboolean (*addSwapRect)(__GLdrawablePrivate *glPriv,
381 GLint x, GLint y, GLsizei width, GLsizei height);
382 void (*setClipRect)(__GLdrawablePrivate *glPriv,
383 GLint x, GLint y, GLsizei width, GLsizei height);
384 void (*updateClipRegion)(__GLdrawablePrivate *glPriv);
385 GLboolean (*resize)(__GLdrawablePrivate *glPriv);
386 void (*getDrawableSize)(__GLdrawablePrivate *glPriv,
387 GLint *x, GLint *y, GLuint *width, GLuint *height);
388
389 void (*lockDP)(__GLdrawablePrivate *glPriv, __GLcontext *gc);
390 void (*unlockDP)(__GLdrawablePrivate *glPriv);
391
392 /* exported */
393 #ifdef __cplusplus
394 void *privatePtr;
395 #else
396 void *private;
397 #endif
398 void (*freePrivate)(__GLdrawablePrivate *);
399
400 /* client data */
401 void *other;
402 };
403
404 /*
405 ** Macros to lock/unlock the drawable private
406 */
407 #if defined(DEBUG)
408 #define __GL_LOCK_DP(glPriv,gc) \
409 (*(glPriv)->lockDP)(glPriv,gc); \
410 (glPriv)->lockLine[(glPriv)->lockRefCount] = __LINE__; \
411 (glPriv)->lockFile[(glPriv)->lockRefCount] = __FILE__; \
412 (glPriv)->lockRefCount++
413 #define __GL_UNLOCK_DP(glPriv) \
414 (glPriv)->lockRefCount--; \
415 (glPriv)->lockLine[(glPriv)->lockRefCount] = 0; \
416 (glPriv)->lockFile[(glPriv)->lockRefCount] = NULL; \
417 (*(glPriv)->unlockDP)(glPriv)
418 #else /* DEBUG */
419 #define __GL_LOCK_DP(glPriv,gc) (*(glPriv)->lockDP)(glPriv,gc)
420 #define __GL_UNLOCK_DP(glPriv) (*(glPriv)->unlockDP)(glPriv)
421 #endif /* DEBUG */
422
423
424 /*
425 ** Procedures which are imported by the GL from the surrounding
426 ** "operating system". Math functions are not considered part of the
427 ** "operating system".
428 */
429 typedef struct __GLimportsRec {
430 /* Memory management */
431 void * (*malloc)(__GLcontext *gc, size_t size);
432 void *(*calloc)(__GLcontext *gc, size_t numElem, size_t elemSize);
433 void *(*realloc)(__GLcontext *gc, void *oldAddr, size_t newSize);
434 void (*free)(__GLcontext *gc, void *addr);
435
436 /* Error handling */
437 void (*warning)(__GLcontext *gc, char *fmt);
438 void (*fatal)(__GLcontext *gc, char *fmt);
439
440 /* other system calls */
441 char *(CAPI *getenv)(__GLcontext *gc, const char *var);
442 int (CAPI *atoi)(__GLcontext *gc, const char *str);
443 int (CAPI *sprintf)(__GLcontext *gc, char *str, const char *fmt, ...);
444 void *(CAPI *fopen)(__GLcontext *gc, const char *path, const char *mode);
445 int (CAPI *fclose)(__GLcontext *gc, void *stream);
446 int (CAPI *fprintf)(__GLcontext *gc, void *stream, const char *fmt, ...);
447
448 /* Drawing surface management */
449 __GLdrawablePrivate *(*getDrawablePrivate)(__GLcontext *gc);
450 __GLdrawablePrivate *(*getReadablePrivate)(__GLcontext *gc);
451
452 /* Operating system dependent data goes here */
453 void *other;
454 } __GLimports;
455
456 /************************************************************************/
457
458 /*
459 ** Procedures which are exported by the GL to the surrounding "operating
460 ** system" so that it can manage multiple GL context's.
461 */
462 typedef struct __GLexportsRec {
463 /* Context management (return GL_FALSE on failure) */
464 GLboolean (*destroyContext)(__GLcontext *gc);
465 GLboolean (*loseCurrent)(__GLcontext *gc);
466 /* oldglPriv isn't used anymore, kept for backwards compatibility */
467 GLboolean (*makeCurrent)(__GLcontext *gc);
468 GLboolean (*shareContext)(__GLcontext *gc, __GLcontext *gcShare);
469 GLboolean (*copyContext)(__GLcontext *dst, const __GLcontext *src, GLuint mask);
470 GLboolean (*forceCurrent)(__GLcontext *gc);
471
472 /* Drawing surface notification callbacks */
473 GLboolean (*notifyResize)(__GLcontext *gc);
474 void (*notifyDestroy)(__GLcontext *gc);
475 void (*notifySwapBuffers)(__GLcontext *gc);
476
477 /* Dispatch table override control for external agents like libGLS */
478 struct __GLdispatchStateRec* (*dispatchExec)(__GLcontext *gc);
479 void (*beginDispatchOverride)(__GLcontext *gc);
480 void (*endDispatchOverride)(__GLcontext *gc);
481 } __GLexports;
482
483 /************************************************************************/
484
485 /*
486 ** This must be the first member of a __GLcontext structure. This is the
487 ** only part of a context that is exposed to the outside world; everything
488 ** else is opaque.
489 */
490 struct __GLinterfaceRec {
491 __GLimports imports;
492 __GLexports exports;
493 };
494
495 extern __GLcontext *__glCoreCreateContext(__GLimports *, __GLcontextModes *);
496 extern void __glCoreNopDispatch(void);
497
498 #endif /* __gl_core_h_ */