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
53 typedef struct __GLcontextRec __GLcontext
;
54 typedef struct __GLinterfaceRec __GLinterface
;
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).
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".
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.
73 typedef struct __GLcontextModesRec
{
74 struct __GLcontextModesRec
* next
;
78 GLboolean colorIndexMode
;
79 GLuint doubleBufferMode
;
82 GLboolean haveAccumBuffer
;
83 GLboolean haveDepthBuffer
;
84 GLboolean haveStencilBuffer
;
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 */
91 GLint accumRedBits
, accumGreenBits
, accumBlueBits
, accumAlphaBits
;
103 GLint visualType
; /**< One of the GLX X visual types. (i.e.,
104 * \c GLX_TRUE_COLOR, etc.)
107 /* EXT_visual_rating / GLX 1.2 */
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
;
116 /* ARB_multisample / SGIS_multisample */
120 /* SGIX_fbconfig / GLX 1.3 */
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. */
133 /* SGIX_visual_select_group */
134 GLint visualSelectGroup
;
136 /* OML_swap_method */
141 /* EXT_texture_from_pixmap */
142 GLint bindToTextureRgb
;
143 GLint bindToTextureRgba
;
144 GLint bindToMipmapTexture
;
145 GLint bindToTextureTargets
;
149 /* Several fields of __GLcontextModes can take these as values. Since
150 * GLX header files may not be available everywhere they need to be used,
151 * redefine them here.
153 #define GLX_NONE 0x8000
154 #define GLX_SLOW_CONFIG 0x8001
155 #define GLX_TRUE_COLOR 0x8002
156 #define GLX_DIRECT_COLOR 0x8003
157 #define GLX_PSEUDO_COLOR 0x8004
158 #define GLX_STATIC_COLOR 0x8005
159 #define GLX_GRAY_SCALE 0x8006
160 #define GLX_STATIC_GRAY 0x8007
161 #define GLX_TRANSPARENT_RGB 0x8008
162 #define GLX_TRANSPARENT_INDEX 0x8009
163 #define GLX_NON_CONFORMANT_CONFIG 0x800D
164 #define GLX_SWAP_EXCHANGE_OML 0x8061
165 #define GLX_SWAP_COPY_OML 0x8062
166 #define GLX_SWAP_UNDEFINED_OML 0x8063
168 #define GLX_DONT_CARE 0xFFFFFFFF
170 #define GLX_RGBA_BIT 0x00000001
171 #define GLX_COLOR_INDEX_BIT 0x00000002
172 #define GLX_WINDOW_BIT 0x00000001
173 #define GLX_PIXMAP_BIT 0x00000002
174 #define GLX_PBUFFER_BIT 0x00000004
176 #define GLX_Y_INVERTED_EXT 0x6009
177 #define GLX_BIND_TO_TEXTURE_RGB_EXT 0x600A
178 #define GLX_BIND_TO_TEXTURE_RGBA_EXT 0x600B
179 #define GLX_BIND_TO_MIPMAP_TEXTURE_EXT 0x600C
180 #define GLX_BIND_TO_TEXTURE_TARGETS_EXT 0x600D
182 #define GLX_TEXTURE_1D_BIT_EXT 0x00000001
183 #define GLX_TEXTURE_2D_BIT_EXT 0x00000002
184 #define GLX_TEXTURE_RECTANGLE_BIT_EXT 0x00000004
187 /************************************************************************/
190 ** Structure used for allocating and freeing drawable private memory.
191 ** (like software buffers, for example).
193 ** The memory allocation routines are provided by the surrounding
194 ** "operating system" code, and they are to be used for allocating
195 ** software buffers and things which are associated with the drawable,
196 ** and used by any context which draws to that drawable. There are
197 ** separate memory allocation functions for drawables and contexts
198 ** since drawables and contexts can be created and destroyed independently
199 ** of one another, and the "operating system" may want to use separate
200 ** allocation arenas for each.
202 ** The freePrivate function is filled in by the core routines when they
203 ** allocates software buffers, and stick them in "private". The freePrivate
204 ** function will destroy anything allocated to this drawable (to be called
205 ** when the drawable is destroyed).
207 typedef struct __GLdrawableRegionRec __GLdrawableRegion
;
208 typedef struct __GLdrawableBufferRec __GLdrawableBuffer
;
209 typedef struct __GLdrawablePrivateRec __GLdrawablePrivate
;
211 typedef struct __GLregionRectRec
{
212 /* lower left (inside the rectangle) */
214 /* upper right (outside the rectangle) */
218 struct __GLdrawableRegionRec
{
220 __GLregionRect
*rects
;
221 __GLregionRect boundingRect
;
224 /************************************************************************/
226 /* masks for the buffers */
227 #define __GL_FRONT_BUFFER_MASK 0x00000001
228 #define __GL_FRONT_LEFT_BUFFER_MASK 0x00000001
229 #define __GL_FRONT_RIGHT_BUFFER_MASK 0x00000002
230 #define __GL_BACK_BUFFER_MASK 0x00000004
231 #define __GL_BACK_LEFT_BUFFER_MASK 0x00000004
232 #define __GL_BACK_RIGHT_BUFFER_MASK 0x00000008
233 #define __GL_ACCUM_BUFFER_MASK 0x00000010
234 #define __GL_DEPTH_BUFFER_MASK 0x00000020
235 #define __GL_STENCIL_BUFFER_MASK 0x00000040
236 #define __GL_AUX_BUFFER_MASK(i) (0x0000080 << (i))
238 #define __GL_ALL_BUFFER_MASK 0xffffffff
240 /* what Resize routines return if resize resorted to fallback case */
241 #define __GL_BUFFER_FALLBACK 0x10
243 typedef void (*__GLbufFallbackInitFn
)(__GLdrawableBuffer
*buf
,
244 __GLdrawablePrivate
*glPriv
, GLint bits
);
245 typedef void (*__GLbufMainInitFn
)(__GLdrawableBuffer
*buf
,
246 __GLdrawablePrivate
*glPriv
, GLint bits
,
247 __GLbufFallbackInitFn back
);
252 ** This data structure describes the context side of a drawable.
254 ** According to the spec there could be multiple contexts bound to the same
255 ** drawable at the same time (from different threads). In order to avoid
256 ** multiple-access conflicts, locks are used to serialize access. When a
257 ** thread needs to access (read or write) a member of the drawable, it takes
258 ** a lock first. Some of the entries in the drawable are treated "mostly
259 ** constant", so we take the freedom of allowing access to them without
260 ** taking a lock (for optimization reasons).
262 ** For more details regarding locking, see buffers.h in the GL core
264 struct __GLdrawableBufferRec
{
268 GLint width
, height
, depth
;
271 ** Framebuffer base address
276 ** Framebuffer size (in bytes)
281 ** Size (in bytes) of each element in the framebuffer
284 GLuint elementSizeLog2
;
287 ** Element skip from one scanline to the next.
288 ** If the buffer is part of another buffer (for example, fullscreen
289 ** front buffer), outerWidth is the width of that buffer.
294 ** outerWidth * elementSize
299 ** Allocation/deallocation is done based on this handle. A handle
300 ** is conceptually different from the framebuffer 'base'.
305 GLboolean (*resize
)(__GLdrawableBuffer
*buf
,
306 GLint x
, GLint y
, GLuint width
, GLuint height
,
307 __GLdrawablePrivate
*glPriv
, GLuint bufferMask
);
308 void (*lock
)(__GLdrawableBuffer
*buf
, __GLdrawablePrivate
*glPriv
);
309 void (*unlock
)(__GLdrawableBuffer
*buf
, __GLdrawablePrivate
*glPriv
);
310 void (*fill
)(__GLdrawableBuffer
*buf
, __GLdrawablePrivate
*glPriv
,
311 GLuint val
, GLint x
, GLint y
, GLint w
, GLint h
);
312 void (*free
)(__GLdrawableBuffer
*buf
, __GLdrawablePrivate
*glPriv
);
315 void (*freePrivate
)(__GLdrawableBuffer
*buf
, __GLdrawablePrivate
*glPriv
);
323 void *other
; /* implementation private data */
324 __GLbufMainInitFn mainInit
;
325 __GLbufFallbackInitFn fallbackInit
;
329 ** The context side of the drawable private
331 struct __GLdrawablePrivateRec
{
335 __GLcontextModes
*modes
;
340 GLuint width
, height
;
343 ** Origin in screen coordinates of the drawable
345 GLint xOrigin
, yOrigin
;
346 #ifdef __GL_ALIGNED_BUFFERS
348 ** Drawable offset from screen origin
350 GLint xOffset
, yOffset
;
353 ** Alignment restriction
355 GLint xAlignment
, yAlignment
;
358 ** Should we invert the y axis?
363 ** Mask specifying which buffers are renderable by the hw
365 GLuint accelBufferMask
;
368 ** the buffers themselves
370 __GLdrawableBuffer frontBuffer
;
371 __GLdrawableBuffer backBuffer
;
372 __GLdrawableBuffer accumBuffer
;
373 __GLdrawableBuffer depthBuffer
;
374 __GLdrawableBuffer stencilBuffer
;
375 #if defined(__GL_NUMBER_OF_AUX_BUFFERS) && (__GL_NUMBER_OF_AUX_BUFFERS > 0)
376 __GLdrawableBuffer
*auxBuffer
;
379 __GLdrawableRegion ownershipRegion
;
382 ** Lock for the drawable private structure
386 /* lock debugging info */
393 void *(*malloc
)(size_t size
);
394 void *(*calloc
)(size_t numElem
, size_t elemSize
);
395 void *(*realloc
)(void *oldAddr
, size_t newSize
);
396 void (*free
)(void *addr
);
398 GLboolean (*addSwapRect
)(__GLdrawablePrivate
*glPriv
,
399 GLint x
, GLint y
, GLsizei width
, GLsizei height
);
400 void (*setClipRect
)(__GLdrawablePrivate
*glPriv
,
401 GLint x
, GLint y
, GLsizei width
, GLsizei height
);
402 void (*updateClipRegion
)(__GLdrawablePrivate
*glPriv
);
403 GLboolean (*resize
)(__GLdrawablePrivate
*glPriv
);
404 void (*getDrawableSize
)(__GLdrawablePrivate
*glPriv
,
405 GLint
*x
, GLint
*y
, GLuint
*width
, GLuint
*height
);
407 void (*lockDP
)(__GLdrawablePrivate
*glPriv
, __GLcontext
*gc
);
408 void (*unlockDP
)(__GLdrawablePrivate
*glPriv
);
416 void (*freePrivate
)(__GLdrawablePrivate
*);
423 ** Macros to lock/unlock the drawable private
426 #define __GL_LOCK_DP(glPriv,gc) \
427 (*(glPriv)->lockDP)(glPriv,gc); \
428 (glPriv)->lockLine[(glPriv)->lockRefCount] = __LINE__; \
429 (glPriv)->lockFile[(glPriv)->lockRefCount] = __FILE__; \
430 (glPriv)->lockRefCount++
431 #define __GL_UNLOCK_DP(glPriv) \
432 (glPriv)->lockRefCount--; \
433 (glPriv)->lockLine[(glPriv)->lockRefCount] = 0; \
434 (glPriv)->lockFile[(glPriv)->lockRefCount] = NULL; \
435 (*(glPriv)->unlockDP)(glPriv)
437 #define __GL_LOCK_DP(glPriv,gc) (*(glPriv)->lockDP)(glPriv,gc)
438 #define __GL_UNLOCK_DP(glPriv) (*(glPriv)->unlockDP)(glPriv)
443 ** Procedures which are imported by the GL from the surrounding
444 ** "operating system". Math functions are not considered part of the
445 ** "operating system".
447 typedef struct __GLimportsRec
{
448 /* Memory management */
449 void * (*malloc
)(__GLcontext
*gc
, size_t size
);
450 void *(*calloc
)(__GLcontext
*gc
, size_t numElem
, size_t elemSize
);
451 void *(*realloc
)(__GLcontext
*gc
, void *oldAddr
, size_t newSize
);
452 void (*free
)(__GLcontext
*gc
, void *addr
);
455 void (*warning
)(__GLcontext
*gc
, char *fmt
);
456 void (*fatal
)(__GLcontext
*gc
, char *fmt
);
458 /* other system calls */
459 char *(CAPI
*getenv
)(__GLcontext
*gc
, const char *var
);
460 int (CAPI
*atoi
)(__GLcontext
*gc
, const char *str
);
461 int (CAPI
*sprintf
)(__GLcontext
*gc
, char *str
, const char *fmt
, ...);
462 void *(CAPI
*fopen
)(__GLcontext
*gc
, const char *path
, const char *mode
);
463 int (CAPI
*fclose
)(__GLcontext
*gc
, void *stream
);
464 int (CAPI
*fprintf
)(__GLcontext
*gc
, void *stream
, const char *fmt
, ...);
466 /* Drawing surface management */
467 __GLdrawablePrivate
*(*getDrawablePrivate
)(__GLcontext
*gc
);
468 __GLdrawablePrivate
*(*getReadablePrivate
)(__GLcontext
*gc
);
470 /* Operating system dependent data goes here */
474 /************************************************************************/
477 ** Procedures which are exported by the GL to the surrounding "operating
478 ** system" so that it can manage multiple GL context's.
480 typedef struct __GLexportsRec
{
481 /* Context management (return GL_FALSE on failure) */
482 GLboolean (*destroyContext
)(__GLcontext
*gc
);
483 GLboolean (*loseCurrent
)(__GLcontext
*gc
);
484 /* oldglPriv isn't used anymore, kept for backwards compatibility */
485 GLboolean (*makeCurrent
)(__GLcontext
*gc
);
486 GLboolean (*shareContext
)(__GLcontext
*gc
, __GLcontext
*gcShare
);
487 GLboolean (*copyContext
)(__GLcontext
*dst
, const __GLcontext
*src
, GLuint mask
);
488 GLboolean (*forceCurrent
)(__GLcontext
*gc
);
490 /* Drawing surface notification callbacks */
491 GLboolean (*notifyResize
)(__GLcontext
*gc
);
492 void (*notifyDestroy
)(__GLcontext
*gc
);
493 void (*notifySwapBuffers
)(__GLcontext
*gc
);
495 /* Dispatch table override control for external agents like libGLS */
496 struct __GLdispatchStateRec
* (*dispatchExec
)(__GLcontext
*gc
);
497 void (*beginDispatchOverride
)(__GLcontext
*gc
);
498 void (*endDispatchOverride
)(__GLcontext
*gc
);
501 /************************************************************************/
504 ** This must be the first member of a __GLcontext structure. This is the
505 ** only part of a context that is exposed to the outside world; everything
508 struct __GLinterfaceRec
{
513 extern __GLcontext
*__glCoreCreateContext(__GLimports
*, __GLcontextModes
*);
514 extern void __glCoreNopDispatch(void);
516 #endif /* __gl_core_h_ */