5 ** License Applicability. Except to the extent portions of this file are
6 ** made subject to an alternative license as permitted in the SGI Free
7 ** Software License B, Version 1.1 (the "License"), the contents of this
8 ** file are subject only to the provisions of the License. You may not use
9 ** this file except in compliance with the License. You may obtain a copy
10 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
11 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
13 ** http://oss.sgi.com/projects/FreeB
15 ** Note that, as provided in the License, the Software is distributed on an
16 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
17 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
18 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
19 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
21 ** Original Code. The Original Code is: OpenGL Sample Implementation,
22 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
23 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
24 ** Copyright in any portions created by third parties is as indicated
25 ** elsewhere herein. All Rights Reserved.
27 ** Additional Notice Provisions: The application programming interfaces
28 ** established by SGI in conjunction with the Original Code are The
29 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
30 ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
31 ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
32 ** Window System(R) (Version 1.3), released October 19, 1998. This software
33 ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
34 ** published by SGI, but has not been independently verified as being
35 ** compliant with the OpenGL(R) version 1.2.1 Specification.
39 #include <sys/types.h>
47 #define GL_CORE_MESA 2
48 #define GL_CORE_APPLE 4
50 typedef struct __GLcontextRec __GLcontext
;
51 typedef struct __GLinterfaceRec __GLinterface
;
54 ** This file defines the interface between the GL core and the surrounding
55 ** "operating system" that supports it (currently the GLX or WGL extensions).
57 ** Members (data and function pointers) are documented as imported or
58 ** exported according to how they are used by the core rendering functions.
59 ** Imported members are initialized by the "operating system" and used by
60 ** the core functions. Exported members are initialized by the core functions
61 ** and used by the "operating system".
65 * Mode and limit information for a context. This information is
66 * kept around in the context so that values can be used during
67 * command execution, and for returning information about the
68 * context to the application.
70 * Instances of this structure are shared by the driver and the loader. To
71 * maintain binary compatability, new fields \b must be added only to the
72 * end of the structure.
74 * \sa _gl_context_modes_create
76 typedef struct __GLcontextModesRec
{
77 struct __GLcontextModesRec
* next
;
81 GLboolean colorIndexMode
;
82 GLuint doubleBufferMode
;
85 GLboolean haveAccumBuffer
;
86 GLboolean haveDepthBuffer
;
87 GLboolean haveStencilBuffer
;
89 GLint redBits
, greenBits
, blueBits
, alphaBits
; /* bits per comp */
90 GLuint redMask
, greenMask
, blueMask
, alphaMask
;
91 GLint rgbBits
; /* total bits for rgb */
92 GLint indexBits
; /* total bits for colorindex */
94 GLint accumRedBits
, accumGreenBits
, accumBlueBits
, accumAlphaBits
;
106 GLint visualType
; /**< One of the GLX X visual types. (i.e.,
107 * \c GLX_TRUE_COLOR, etc.)
110 /* EXT_visual_rating / GLX 1.2 */
113 /* EXT_visual_info / GLX 1.2 */
114 GLint transparentPixel
;
115 /* colors are floats scaled to ints */
116 GLint transparentRed
, transparentGreen
, transparentBlue
, transparentAlpha
;
117 GLint transparentIndex
;
119 /* ARB_multisample / SGIS_multisample */
123 /* SGIX_fbconfig / GLX 1.3 */
129 /* SGIX_pbuffer / GLX 1.3 */
130 GLint maxPbufferWidth
;
131 GLint maxPbufferHeight
;
132 GLint maxPbufferPixels
;
133 GLint optimalPbufferWidth
; /* Only for SGIX_pbuffer. */
134 GLint optimalPbufferHeight
; /* Only for SGIX_pbuffer. */
136 /* SGIX_visual_select_group */
137 GLint visualSelectGroup
;
139 /* OML_swap_method */
144 /* EXT_texture_from_pixmap */
145 GLint bindToTextureRgb
;
146 GLint bindToTextureRgba
;
147 GLint bindToMipmapTexture
;
148 GLint bindToTextureTargets
;
152 /* Several fields of __GLcontextModes can take these as values. Since
153 * GLX header files may not be available everywhere they need to be used,
154 * redefine them here.
156 #define GLX_NONE 0x8000
157 #define GLX_SLOW_CONFIG 0x8001
158 #define GLX_TRUE_COLOR 0x8002
159 #define GLX_DIRECT_COLOR 0x8003
160 #define GLX_PSEUDO_COLOR 0x8004
161 #define GLX_STATIC_COLOR 0x8005
162 #define GLX_GRAY_SCALE 0x8006
163 #define GLX_STATIC_GRAY 0x8007
164 #define GLX_TRANSPARENT_RGB 0x8008
165 #define GLX_TRANSPARENT_INDEX 0x8009
166 #define GLX_NON_CONFORMANT_CONFIG 0x800D
167 #define GLX_SWAP_EXCHANGE_OML 0x8061
168 #define GLX_SWAP_COPY_OML 0x8062
169 #define GLX_SWAP_UNDEFINED_OML 0x8063
171 #define GLX_DONT_CARE 0xFFFFFFFF
173 #define GLX_RGBA_BIT 0x00000001
174 #define GLX_COLOR_INDEX_BIT 0x00000002
175 #define GLX_WINDOW_BIT 0x00000001
176 #define GLX_PIXMAP_BIT 0x00000002
177 #define GLX_PBUFFER_BIT 0x00000004
179 #define GLX_BIND_TO_TEXTURE_RGB_EXT 0x20D0
180 #define GLX_BIND_TO_TEXTURE_RGBA_EXT 0x20D1
181 #define GLX_BIND_TO_MIPMAP_TEXTURE_EXT 0x20D2
182 #define GLX_BIND_TO_TEXTURE_TARGETS_EXT 0x20D3
183 #define GLX_Y_INVERTED_EXT 0x20D4
185 #define GLX_TEXTURE_1D_BIT_EXT 0x00000001
186 #define GLX_TEXTURE_2D_BIT_EXT 0x00000002
187 #define GLX_TEXTURE_RECTANGLE_BIT_EXT 0x00000004
190 /************************************************************************/
193 ** Structure used for allocating and freeing drawable private memory.
194 ** (like software buffers, for example).
196 ** The memory allocation routines are provided by the surrounding
197 ** "operating system" code, and they are to be used for allocating
198 ** software buffers and things which are associated with the drawable,
199 ** and used by any context which draws to that drawable. There are
200 ** separate memory allocation functions for drawables and contexts
201 ** since drawables and contexts can be created and destroyed independently
202 ** of one another, and the "operating system" may want to use separate
203 ** allocation arenas for each.
205 ** The freePrivate function is filled in by the core routines when they
206 ** allocates software buffers, and stick them in "private". The freePrivate
207 ** function will destroy anything allocated to this drawable (to be called
208 ** when the drawable is destroyed).
210 typedef struct __GLdrawableRegionRec __GLdrawableRegion
;
211 typedef struct __GLdrawableBufferRec __GLdrawableBuffer
;
212 typedef struct __GLdrawablePrivateRec __GLdrawablePrivate
;
214 typedef struct __GLregionRectRec
{
215 /* lower left (inside the rectangle) */
217 /* upper right (outside the rectangle) */
221 struct __GLdrawableRegionRec
{
223 __GLregionRect
*rects
;
224 __GLregionRect boundingRect
;
227 /************************************************************************/
229 /* masks for the buffers */
230 #define __GL_FRONT_BUFFER_MASK 0x00000001
231 #define __GL_FRONT_LEFT_BUFFER_MASK 0x00000001
232 #define __GL_FRONT_RIGHT_BUFFER_MASK 0x00000002
233 #define __GL_BACK_BUFFER_MASK 0x00000004
234 #define __GL_BACK_LEFT_BUFFER_MASK 0x00000004
235 #define __GL_BACK_RIGHT_BUFFER_MASK 0x00000008
236 #define __GL_ACCUM_BUFFER_MASK 0x00000010
237 #define __GL_DEPTH_BUFFER_MASK 0x00000020
238 #define __GL_STENCIL_BUFFER_MASK 0x00000040
239 #define __GL_AUX_BUFFER_MASK(i) (0x0000080 << (i))
241 #define __GL_ALL_BUFFER_MASK 0xffffffff
243 /* what Resize routines return if resize resorted to fallback case */
244 #define __GL_BUFFER_FALLBACK 0x10
246 typedef void (*__GLbufFallbackInitFn
)(__GLdrawableBuffer
*buf
,
247 __GLdrawablePrivate
*glPriv
, GLint bits
);
248 typedef void (*__GLbufMainInitFn
)(__GLdrawableBuffer
*buf
,
249 __GLdrawablePrivate
*glPriv
, GLint bits
,
250 __GLbufFallbackInitFn back
);
255 ** This data structure describes the context side of a drawable.
257 ** According to the spec there could be multiple contexts bound to the same
258 ** drawable at the same time (from different threads). In order to avoid
259 ** multiple-access conflicts, locks are used to serialize access. When a
260 ** thread needs to access (read or write) a member of the drawable, it takes
261 ** a lock first. Some of the entries in the drawable are treated "mostly
262 ** constant", so we take the freedom of allowing access to them without
263 ** taking a lock (for optimization reasons).
265 ** For more details regarding locking, see buffers.h in the GL core
267 struct __GLdrawableBufferRec
{
271 GLint width
, height
, depth
;
274 ** Framebuffer base address
279 ** Framebuffer size (in bytes)
284 ** Size (in bytes) of each element in the framebuffer
287 GLuint elementSizeLog2
;
290 ** Element skip from one scanline to the next.
291 ** If the buffer is part of another buffer (for example, fullscreen
292 ** front buffer), outerWidth is the width of that buffer.
297 ** outerWidth * elementSize
302 ** Allocation/deallocation is done based on this handle. A handle
303 ** is conceptually different from the framebuffer 'base'.
308 GLboolean (*resize
)(__GLdrawableBuffer
*buf
,
309 GLint x
, GLint y
, GLuint width
, GLuint height
,
310 __GLdrawablePrivate
*glPriv
, GLuint bufferMask
);
311 void (*lock
)(__GLdrawableBuffer
*buf
, __GLdrawablePrivate
*glPriv
);
312 void (*unlock
)(__GLdrawableBuffer
*buf
, __GLdrawablePrivate
*glPriv
);
313 void (*fill
)(__GLdrawableBuffer
*buf
, __GLdrawablePrivate
*glPriv
,
314 GLuint val
, GLint x
, GLint y
, GLint w
, GLint h
);
315 void (*free
)(__GLdrawableBuffer
*buf
, __GLdrawablePrivate
*glPriv
);
318 void (*freePrivate
)(__GLdrawableBuffer
*buf
, __GLdrawablePrivate
*glPriv
);
326 void *other
; /* implementation private data */
327 __GLbufMainInitFn mainInit
;
328 __GLbufFallbackInitFn fallbackInit
;
332 ** The context side of the drawable private
334 struct __GLdrawablePrivateRec
{
338 __GLcontextModes
*modes
;
343 GLuint width
, height
;
346 ** Origin in screen coordinates of the drawable
348 GLint xOrigin
, yOrigin
;
349 #ifdef __GL_ALIGNED_BUFFERS
351 ** Drawable offset from screen origin
353 GLint xOffset
, yOffset
;
356 ** Alignment restriction
358 GLint xAlignment
, yAlignment
;
361 ** Should we invert the y axis?
366 ** Mask specifying which buffers are renderable by the hw
368 GLuint accelBufferMask
;
371 ** the buffers themselves
373 __GLdrawableBuffer frontBuffer
;
374 __GLdrawableBuffer backBuffer
;
375 __GLdrawableBuffer accumBuffer
;
376 __GLdrawableBuffer depthBuffer
;
377 __GLdrawableBuffer stencilBuffer
;
378 #if defined(__GL_NUMBER_OF_AUX_BUFFERS) && (__GL_NUMBER_OF_AUX_BUFFERS > 0)
379 __GLdrawableBuffer
*auxBuffer
;
382 __GLdrawableRegion ownershipRegion
;
385 ** Lock for the drawable private structure
389 /* lock debugging info */
396 void *(*malloc
)(size_t size
);
397 void *(*calloc
)(size_t numElem
, size_t elemSize
);
398 void *(*realloc
)(void *oldAddr
, size_t newSize
);
399 void (*free
)(void *addr
);
401 GLboolean (*addSwapRect
)(__GLdrawablePrivate
*glPriv
,
402 GLint x
, GLint y
, GLsizei width
, GLsizei height
);
403 void (*setClipRect
)(__GLdrawablePrivate
*glPriv
,
404 GLint x
, GLint y
, GLsizei width
, GLsizei height
);
405 void (*updateClipRegion
)(__GLdrawablePrivate
*glPriv
);
406 GLboolean (*resize
)(__GLdrawablePrivate
*glPriv
);
407 void (*getDrawableSize
)(__GLdrawablePrivate
*glPriv
,
408 GLint
*x
, GLint
*y
, GLuint
*width
, GLuint
*height
);
410 void (*lockDP
)(__GLdrawablePrivate
*glPriv
, __GLcontext
*gc
);
411 void (*unlockDP
)(__GLdrawablePrivate
*glPriv
);
419 void (*freePrivate
)(__GLdrawablePrivate
*);
426 ** Macros to lock/unlock the drawable private
429 #define __GL_LOCK_DP(glPriv,gc) \
430 (*(glPriv)->lockDP)(glPriv,gc); \
431 (glPriv)->lockLine[(glPriv)->lockRefCount] = __LINE__; \
432 (glPriv)->lockFile[(glPriv)->lockRefCount] = __FILE__; \
433 (glPriv)->lockRefCount++
434 #define __GL_UNLOCK_DP(glPriv) \
435 (glPriv)->lockRefCount--; \
436 (glPriv)->lockLine[(glPriv)->lockRefCount] = 0; \
437 (glPriv)->lockFile[(glPriv)->lockRefCount] = NULL; \
438 (*(glPriv)->unlockDP)(glPriv)
440 #define __GL_LOCK_DP(glPriv,gc) (*(glPriv)->lockDP)(glPriv,gc)
441 #define __GL_UNLOCK_DP(glPriv) (*(glPriv)->unlockDP)(glPriv)
446 ** Procedures which are imported by the GL from the surrounding
447 ** "operating system". Math functions are not considered part of the
448 ** "operating system".
450 typedef struct __GLimportsRec
{
451 /* Memory management */
452 void * (*malloc
)(__GLcontext
*gc
, size_t size
);
453 void *(*calloc
)(__GLcontext
*gc
, size_t numElem
, size_t elemSize
);
454 void *(*realloc
)(__GLcontext
*gc
, void *oldAddr
, size_t newSize
);
455 void (*free
)(__GLcontext
*gc
, void *addr
);
458 void (*warning
)(__GLcontext
*gc
, char *fmt
);
459 void (*fatal
)(__GLcontext
*gc
, char *fmt
);
461 /* other system calls */
462 char *(CAPI
*getenv
)(__GLcontext
*gc
, const char *var
);
463 int (CAPI
*atoi
)(__GLcontext
*gc
, const char *str
);
464 int (CAPI
*sprintf
)(__GLcontext
*gc
, char *str
, const char *fmt
, ...);
465 void *(CAPI
*fopen
)(__GLcontext
*gc
, const char *path
, const char *mode
);
466 int (CAPI
*fclose
)(__GLcontext
*gc
, void *stream
);
467 int (CAPI
*fprintf
)(__GLcontext
*gc
, void *stream
, const char *fmt
, ...);
469 /* Drawing surface management */
470 __GLdrawablePrivate
*(*getDrawablePrivate
)(__GLcontext
*gc
);
471 __GLdrawablePrivate
*(*getReadablePrivate
)(__GLcontext
*gc
);
473 /* Operating system dependent data goes here */
477 /************************************************************************/
480 ** Procedures which are exported by the GL to the surrounding "operating
481 ** system" so that it can manage multiple GL context's.
483 typedef struct __GLexportsRec
{
484 /* Context management (return GL_FALSE on failure) */
485 GLboolean (*destroyContext
)(__GLcontext
*gc
);
486 GLboolean (*loseCurrent
)(__GLcontext
*gc
);
487 /* oldglPriv isn't used anymore, kept for backwards compatibility */
488 GLboolean (*makeCurrent
)(__GLcontext
*gc
);
489 GLboolean (*shareContext
)(__GLcontext
*gc
, __GLcontext
*gcShare
);
490 GLboolean (*copyContext
)(__GLcontext
*dst
, const __GLcontext
*src
, GLuint mask
);
491 GLboolean (*forceCurrent
)(__GLcontext
*gc
);
493 /* Drawing surface notification callbacks */
494 GLboolean (*notifyResize
)(__GLcontext
*gc
);
495 void (*notifyDestroy
)(__GLcontext
*gc
);
496 void (*notifySwapBuffers
)(__GLcontext
*gc
);
498 /* Dispatch table override control for external agents like libGLS */
499 struct __GLdispatchStateRec
* (*dispatchExec
)(__GLcontext
*gc
);
500 void (*beginDispatchOverride
)(__GLcontext
*gc
);
501 void (*endDispatchOverride
)(__GLcontext
*gc
);
504 /************************************************************************/
507 ** This must be the first member of a __GLcontext structure. This is the
508 ** only part of a context that is exposed to the outside world; everything
511 struct __GLinterfaceRec
{
516 extern __GLcontext
*__glCoreCreateContext(__GLimports
*, __GLcontextModes
*);
517 extern void __glCoreNopDispatch(void);
519 #endif /* __gl_core_h_ */