1
/* $XFree86: xc/lib/GL/include/GL/internal/glcore.h,v 1.7 2001/03/25 05:32:00 tsi Exp $ */
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:
14
** http://oss.sgi.com/projects/FreeB
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.
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.
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.
41
#include <sys/types.h>
50
#define GL_CORE_MESA 2
51
#define GL_CORE_APPLE 4
52
#define GL_CORE_WINDOWS 8
54
typedef struct __GLcontextRec __GLcontext;
55
typedef struct __GLinterfaceRec __GLinterface;
58
** This file defines the interface between the GL core and the surrounding
59
** "operating system" that supports it (currently the GLX or WGL extensions).
61
** Members (data and function pointers) are documented as imported or
62
** exported according to how they are used by the core rendering functions.
63
** Imported members are initialized by the "operating system" and used by
64
** the core functions. Exported members are initialized by the core functions
65
** and used by the "operating system".
69
** Mode and limit information for a context. This information is
70
** kept around in the context so that values can be used during
71
** command execution, and for returning information about the
72
** context to the application.
74
typedef struct __GLcontextModesRec {
75
struct __GLcontextModesRec * next;
79
GLboolean colorIndexMode;
80
GLuint doubleBufferMode;
83
GLboolean haveAccumBuffer;
84
GLboolean haveDepthBuffer;
85
GLboolean haveStencilBuffer;
87
GLint redBits, greenBits, blueBits, alphaBits; /* bits per comp */
88
GLuint redMask, greenMask, blueMask, alphaMask;
89
GLint rgbBits; /* total bits for rgb */
90
GLint indexBits; /* total bits for colorindex */
92
GLint accumRedBits, accumGreenBits, accumBlueBits, accumAlphaBits;
104
GLint visualType; /**< One of the GLX X visual types. (i.e.,
105
* \c GLX_TRUE_COLOR, etc.)
108
/* EXT_visual_rating / GLX 1.2 */
111
/* EXT_visual_info / GLX 1.2 */
112
GLint transparentPixel;
113
/* colors are floats scaled to ints */
114
GLint transparentRed, transparentGreen, transparentBlue, transparentAlpha;
115
GLint transparentIndex;
117
/* ARB_multisample / SGIS_multisample */
121
/* SGIX_fbconfig / GLX 1.3 */
127
/* SGIX_pbuffer / GLX 1.3 */
128
GLint maxPbufferWidth;
129
GLint maxPbufferHeight;
130
GLint maxPbufferPixels;
131
GLint optimalPbufferWidth; /* Only for SGIX_pbuffer. */
132
GLint optimalPbufferHeight; /* Only for SGIX_pbuffer. */
134
/* SGIX_visual_select_group */
135
GLint visualSelectGroup;
137
/* OML_swap_method */
143
/* Several fields of __GLcontextModes can take these as values. Since
144
* GLX header files may not be available everywhere they need to be used,
145
* redefine them here.
147
#define GLX_NONE 0x8000
148
#define GLX_SLOW_CONFIG 0x8001
149
#define GLX_TRUE_COLOR 0x8002
150
#define GLX_DIRECT_COLOR 0x8003
151
#define GLX_PSEUDO_COLOR 0x8004
152
#define GLX_STATIC_COLOR 0x8005
153
#define GLX_GRAY_SCALE 0x8006
154
#define GLX_STATIC_GRAY 0x8007
155
#define GLX_TRANSPARENT_RGB 0x8008
156
#define GLX_TRANSPARENT_INDEX 0x8009
157
#define GLX_NON_CONFORMANT_CONFIG 0x800D
158
#define GLX_SWAP_EXCHANGE_OML 0x8061
159
#define GLX_SWAP_COPY_OML 0x8062
160
#define GLX_SWAP_UNDEFINED_OML 0x8063
162
#define GLX_DONT_CARE 0xFFFFFFFF
164
#define GLX_RGBA_BIT 0x00000001
165
#define GLX_COLOR_INDEX_BIT 0x00000002
166
#define GLX_WINDOW_BIT 0x00000001
167
#define GLX_PIXMAP_BIT 0x00000002
168
#define GLX_PBUFFER_BIT 0x00000004
170
/************************************************************************/
173
** Structure used for allocating and freeing drawable private memory.
174
** (like software buffers, for example).
176
** The memory allocation routines are provided by the surrounding
177
** "operating system" code, and they are to be used for allocating
178
** software buffers and things which are associated with the drawable,
179
** and used by any context which draws to that drawable. There are
180
** separate memory allocation functions for drawables and contexts
181
** since drawables and contexts can be created and destroyed independently
182
** of one another, and the "operating system" may want to use separate
183
** allocation arenas for each.
185
** The freePrivate function is filled in by the core routines when they
186
** allocates software buffers, and stick them in "private". The freePrivate
187
** function will destroy anything allocated to this drawable (to be called
188
** when the drawable is destroyed).
190
typedef struct __GLdrawableRegionRec __GLdrawableRegion;
191
typedef struct __GLdrawableBufferRec __GLdrawableBuffer;
192
typedef struct __GLdrawablePrivateRec __GLdrawablePrivate;
194
typedef struct __GLregionRectRec {
195
/* lower left (inside the rectangle) */
197
/* upper right (outside the rectangle) */
201
struct __GLdrawableRegionRec {
203
__GLregionRect *rects;
204
__GLregionRect boundingRect;
207
/************************************************************************/
209
/* masks for the buffers */
210
#define __GL_FRONT_BUFFER_MASK 0x00000001
211
#define __GL_FRONT_LEFT_BUFFER_MASK 0x00000001
212
#define __GL_FRONT_RIGHT_BUFFER_MASK 0x00000002
213
#define __GL_BACK_BUFFER_MASK 0x00000004
214
#define __GL_BACK_LEFT_BUFFER_MASK 0x00000004
215
#define __GL_BACK_RIGHT_BUFFER_MASK 0x00000008
216
#define __GL_ACCUM_BUFFER_MASK 0x00000010
217
#define __GL_DEPTH_BUFFER_MASK 0x00000020
218
#define __GL_STENCIL_BUFFER_MASK 0x00000040
219
#define __GL_AUX_BUFFER_MASK(i) (0x0000080 << (i))
221
#define __GL_ALL_BUFFER_MASK 0xffffffff
223
/* what Resize routines return if resize resorted to fallback case */
224
#define __GL_BUFFER_FALLBACK 0x10
226
typedef void (*__GLbufFallbackInitFn)(__GLdrawableBuffer *buf,
227
__GLdrawablePrivate *glPriv, GLint bits);
228
typedef void (*__GLbufMainInitFn)(__GLdrawableBuffer *buf,
229
__GLdrawablePrivate *glPriv, GLint bits,
230
__GLbufFallbackInitFn back);
235
** This data structure describes the context side of a drawable.
237
** According to the spec there could be multiple contexts bound to the same
238
** drawable at the same time (from different threads). In order to avoid
239
** multiple-access conflicts, locks are used to serialize access. When a
240
** thread needs to access (read or write) a member of the drawable, it takes
241
** a lock first. Some of the entries in the drawable are treated "mostly
242
** constant", so we take the freedom of allowing access to them without
243
** taking a lock (for optimization reasons).
245
** For more details regarding locking, see buffers.h in the GL core
247
struct __GLdrawableBufferRec {
251
GLint width, height, depth;
254
** Framebuffer base address
259
** Framebuffer size (in bytes)
264
** Size (in bytes) of each element in the framebuffer
267
GLuint elementSizeLog2;
270
** Element skip from one scanline to the next.
271
** If the buffer is part of another buffer (for example, fullscreen
272
** front buffer), outerWidth is the width of that buffer.
277
** outerWidth * elementSize
282
** Allocation/deallocation is done based on this handle. A handle
283
** is conceptually different from the framebuffer 'base'.
288
GLboolean (*resize)(__GLdrawableBuffer *buf,
289
GLint x, GLint y, GLuint width, GLuint height,
290
__GLdrawablePrivate *glPriv, GLuint bufferMask);
291
void (*lock)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv);
292
void (*unlock)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv);
293
void (*fill)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv,
294
GLuint val, GLint x, GLint y, GLint w, GLint h);
295
void (*free)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv);
298
void (*freePrivate)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv);
306
void *other; /* implementation private data */
307
__GLbufMainInitFn mainInit;
308
__GLbufFallbackInitFn fallbackInit;
312
** The context side of the drawable private
314
struct __GLdrawablePrivateRec {
318
__GLcontextModes *modes;
323
GLuint width, height;
326
** Origin in screen coordinates of the drawable
328
GLint xOrigin, yOrigin;
329
#ifdef __GL_ALIGNED_BUFFERS
331
** Drawable offset from screen origin
333
GLint xOffset, yOffset;
336
** Alignment restriction
338
GLint xAlignment, yAlignment;
341
** Should we invert the y axis?
346
** Mask specifying which buffers are renderable by the hw
348
GLuint accelBufferMask;
351
** the buffers themselves
353
__GLdrawableBuffer frontBuffer;
354
__GLdrawableBuffer backBuffer;
355
__GLdrawableBuffer accumBuffer;
356
__GLdrawableBuffer depthBuffer;
357
__GLdrawableBuffer stencilBuffer;
358
#if defined(__GL_NUMBER_OF_AUX_BUFFERS) && (__GL_NUMBER_OF_AUX_BUFFERS > 0)
359
__GLdrawableBuffer *auxBuffer;
362
__GLdrawableRegion ownershipRegion;
365
** Lock for the drawable private structure
369
/* lock debugging info */
376
void *(*malloc)(size_t size);
377
void *(*calloc)(size_t numElem, size_t elemSize);
378
void *(*realloc)(void *oldAddr, size_t newSize);
379
void (*free)(void *addr);
381
GLboolean (*addSwapRect)(__GLdrawablePrivate *glPriv,
382
GLint x, GLint y, GLsizei width, GLsizei height);
383
void (*setClipRect)(__GLdrawablePrivate *glPriv,
384
GLint x, GLint y, GLsizei width, GLsizei height);
385
void (*updateClipRegion)(__GLdrawablePrivate *glPriv);
386
GLboolean (*resize)(__GLdrawablePrivate *glPriv);
387
void (*getDrawableSize)(__GLdrawablePrivate *glPriv,
388
GLint *x, GLint *y, GLuint *width, GLuint *height);
390
void (*lockDP)(__GLdrawablePrivate *glPriv, __GLcontext *gc);
391
void (*unlockDP)(__GLdrawablePrivate *glPriv);
399
void (*freePrivate)(__GLdrawablePrivate *);
406
** Macros to lock/unlock the drawable private
409
#define __GL_LOCK_DP(glPriv,gc) \
410
(*(glPriv)->lockDP)(glPriv,gc); \
411
(glPriv)->lockLine[(glPriv)->lockRefCount] = __LINE__; \
412
(glPriv)->lockFile[(glPriv)->lockRefCount] = __FILE__; \
413
(glPriv)->lockRefCount++
414
#define __GL_UNLOCK_DP(glPriv) \
415
(glPriv)->lockRefCount--; \
416
(glPriv)->lockLine[(glPriv)->lockRefCount] = 0; \
417
(glPriv)->lockFile[(glPriv)->lockRefCount] = NULL; \
418
(*(glPriv)->unlockDP)(glPriv)
420
#define __GL_LOCK_DP(glPriv,gc) (*(glPriv)->lockDP)(glPriv,gc)
421
#define __GL_UNLOCK_DP(glPriv) (*(glPriv)->unlockDP)(glPriv)
426
** Procedures which are imported by the GL from the surrounding
427
** "operating system". Math functions are not considered part of the
428
** "operating system".
430
typedef struct __GLimportsRec {
431
/* Memory management */
432
void * (*malloc)(__GLcontext *gc, size_t size);
433
void *(*calloc)(__GLcontext *gc, size_t numElem, size_t elemSize);
434
void *(*realloc)(__GLcontext *gc, void *oldAddr, size_t newSize);
435
void (*free)(__GLcontext *gc, void *addr);
438
void (*warning)(__GLcontext *gc, char *fmt);
439
void (*fatal)(__GLcontext *gc, char *fmt);
441
/* other system calls */
442
char *(CAPI *getenv)(__GLcontext *gc, const char *var);
443
int (CAPI *atoi)(__GLcontext *gc, const char *str);
444
int (CAPI *sprintf)(__GLcontext *gc, char *str, const char *fmt, ...);
445
void *(CAPI *fopen)(__GLcontext *gc, const char *path, const char *mode);
446
int (CAPI *fclose)(__GLcontext *gc, void *stream);
447
int (CAPI *fprintf)(__GLcontext *gc, void *stream, const char *fmt, ...);
449
/* Drawing surface management */
450
__GLdrawablePrivate *(*getDrawablePrivate)(__GLcontext *gc);
451
__GLdrawablePrivate *(*getReadablePrivate)(__GLcontext *gc);
453
/* Operating system dependent data goes here */
457
/************************************************************************/
460
** Procedures which are exported by the GL to the surrounding "operating
461
** system" so that it can manage multiple GL context's.
463
typedef struct __GLexportsRec {
464
/* Context management (return GL_FALSE on failure) */
465
GLboolean (*destroyContext)(__GLcontext *gc);
466
GLboolean (*loseCurrent)(__GLcontext *gc);
467
/* oldglPriv isn't used anymore, kept for backwards compatibility */
468
GLboolean (*makeCurrent)(__GLcontext *gc);
469
GLboolean (*shareContext)(__GLcontext *gc, __GLcontext *gcShare);
470
GLboolean (*copyContext)(__GLcontext *dst, const __GLcontext *src, GLuint mask);
471
GLboolean (*forceCurrent)(__GLcontext *gc);
473
/* Drawing surface notification callbacks */
474
GLboolean (*notifyResize)(__GLcontext *gc);
475
void (*notifyDestroy)(__GLcontext *gc);
476
void (*notifySwapBuffers)(__GLcontext *gc);
478
/* Dispatch table override control for external agents like libGLS */
479
struct __GLdispatchStateRec* (*dispatchExec)(__GLcontext *gc);
480
void (*beginDispatchOverride)(__GLcontext *gc);
481
void (*endDispatchOverride)(__GLcontext *gc);
484
/************************************************************************/
487
** This must be the first member of a __GLcontext structure. This is the
488
** only part of a context that is exposed to the outside world; everything
491
struct __GLinterfaceRec {
496
extern __GLcontext *__glCoreCreateContext(__GLimports *, __GLcontextModes *);
497
extern void __glCoreNopDispatch(void);
499
#endif /* __gl_core_h_ */