Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

glcore.h 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  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. ** 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:
  12. **
  13. ** http://oss.sgi.com/projects/FreeB
  14. **
  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.
  20. **
  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.
  26. **
  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.
  36. **
  37. */
  38. #ifndef XFree86LOADER
  39. #include <sys/types.h>
  40. #endif
  41. #define GL_CORE_SGI 1
  42. #define GL_CORE_MESA 2
  43. typedef struct __GLcontextRec __GLcontext;
  44. typedef struct __GLinterfaceRec __GLinterface;
  45. /*
  46. ** This file defines the interface between the GL core and the surrounding
  47. ** "operating system" that supports it (currently the GLX or WGL extensions).
  48. **
  49. ** Members (data and function pointers) are documented as imported or
  50. ** exported according to how they are used by the core rendering functions.
  51. ** Imported members are initialized by the "operating system" and used by
  52. ** the core functions. Exported members are initialized by the core functions
  53. ** and used by the "operating system".
  54. */
  55. /*
  56. ** Mode and limit information for a context. This information is
  57. ** kept around in the context so that values can be used during
  58. ** command execution, and for returning information about the
  59. ** context to the application.
  60. */
  61. typedef struct __GLcontextModesRec {
  62. GLboolean rgbMode;
  63. GLboolean colorIndexMode;
  64. GLboolean doubleBufferMode;
  65. GLboolean stereoMode;
  66. GLboolean haveAccumBuffer;
  67. GLboolean haveDepthBuffer;
  68. GLboolean haveStencilBuffer;
  69. GLint redBits, greenBits, blueBits, alphaBits; /* bits per comp */
  70. GLuint redMask, greenMask, blueMask, alphaMask;
  71. GLint rgbBits; /* total bits for rgb */
  72. GLint indexBits; /* total bits for colorindex */
  73. GLint accumRedBits, accumGreenBits, accumBlueBits, accumAlphaBits;
  74. GLint depthBits;
  75. GLint stencilBits;
  76. GLint numAuxBuffers;
  77. GLint level;
  78. GLint pixmapMode;
  79. } __GLcontextModes;
  80. /************************************************************************/
  81. /*
  82. ** Structure used for allocating and freeing drawable private memory.
  83. ** (like software buffers, for example).
  84. **
  85. ** The memory allocation routines are provided by the surrounding
  86. ** "operating system" code, and they are to be used for allocating
  87. ** software buffers and things which are associated with the drawable,
  88. ** and used by any context which draws to that drawable. There are
  89. ** separate memory allocation functions for drawables and contexts
  90. ** since drawables and contexts can be created and destroyed independently
  91. ** of one another, and the "operating system" may want to use separate
  92. ** allocation arenas for each.
  93. **
  94. ** The freePrivate function is filled in by the core routines when they
  95. ** allocates software buffers, and stick them in "private". The freePrivate
  96. ** function will destroy anything allocated to this drawable (to be called
  97. ** when the drawable is destroyed).
  98. */
  99. typedef struct __GLdrawableRegionRec __GLdrawableRegion;
  100. typedef struct __GLdrawableBufferRec __GLdrawableBuffer;
  101. typedef struct __GLdrawablePrivateRec __GLdrawablePrivate;
  102. typedef struct __GLregionRectRec {
  103. /* lower left (inside the rectangle) */
  104. GLint x0, y0;
  105. /* upper right (outside the rectangle) */
  106. GLint x1, y1;
  107. } __GLregionRect;
  108. struct __GLdrawableRegionRec {
  109. GLint numRects;
  110. __GLregionRect *rects;
  111. __GLregionRect boundingRect;
  112. };
  113. /************************************************************************/
  114. /* masks for the buffers */
  115. #define __GL_FRONT_BUFFER_MASK 0x00000001
  116. #define __GL_FRONT_LEFT_BUFFER_MASK 0x00000001
  117. #define __GL_FRONT_RIGHT_BUFFER_MASK 0x00000002
  118. #define __GL_BACK_BUFFER_MASK 0x00000004
  119. #define __GL_BACK_LEFT_BUFFER_MASK 0x00000004
  120. #define __GL_BACK_RIGHT_BUFFER_MASK 0x00000008
  121. #define __GL_ACCUM_BUFFER_MASK 0x00000010
  122. #define __GL_DEPTH_BUFFER_MASK 0x00000020
  123. #define __GL_STENCIL_BUFFER_MASK 0x00000040
  124. #define __GL_AUX_BUFFER_MASK(i) (0x0000080 << (i))
  125. #define __GL_ALL_BUFFER_MASK 0xffffffff
  126. /* what Resize routines return if resize resorted to fallback case */
  127. #define __GL_BUFFER_FALLBACK 0x10
  128. typedef void (*__GLbufFallbackInitFn)(__GLdrawableBuffer *buf,
  129. __GLdrawablePrivate *glPriv, GLint bits);
  130. typedef void (*__GLbufMainInitFn)(__GLdrawableBuffer *buf,
  131. __GLdrawablePrivate *glPriv, GLint bits,
  132. __GLbufFallbackInitFn back);
  133. /*
  134. ** A drawable buffer
  135. **
  136. ** This data structure describes the context side of a drawable.
  137. **
  138. ** According to the spec there could be multiple contexts bound to the same
  139. ** drawable at the same time (from different threads). In order to avoid
  140. ** multiple-access conflicts, locks are used to serialize access. When a
  141. ** thread needs to access (read or write) a member of the drawable, it takes
  142. ** a lock first. Some of the entries in the drawable are treated "mostly
  143. ** constant", so we take the freedom of allowing access to them without
  144. ** taking a lock (for optimization reasons).
  145. **
  146. ** For more details regarding locking, see buffers.h in the GL core
  147. */
  148. struct __GLdrawableBufferRec {
  149. /*
  150. ** Buffer dimensions
  151. */
  152. GLint width, height, depth;
  153. /*
  154. ** Framebuffer base address
  155. */
  156. void *base;
  157. /*
  158. ** Framebuffer size (in bytes)
  159. */
  160. GLuint size;
  161. /*
  162. ** Size (in bytes) of each element in the framebuffer
  163. */
  164. GLuint elementSize;
  165. GLuint elementSizeLog2;
  166. /*
  167. ** Element skip from one scanline to the next.
  168. ** If the buffer is part of another buffer (for example, fullscreen
  169. ** front buffer), outerWidth is the width of that buffer.
  170. */
  171. GLint outerWidth;
  172. /*
  173. ** outerWidth * elementSize
  174. */
  175. GLint byteWidth;
  176. /*
  177. ** Allocation/deallocation is done based on this handle. A handle
  178. ** is conceptually different from the framebuffer 'base'.
  179. */
  180. void *handle;
  181. /* imported */
  182. GLboolean (*resize)(__GLdrawableBuffer *buf,
  183. GLint x, GLint y, GLuint width, GLuint height,
  184. __GLdrawablePrivate *glPriv, GLuint bufferMask);
  185. void (*lock)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv);
  186. void (*unlock)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv);
  187. void (*fill)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv,
  188. GLuint val, GLint x, GLint y, GLint w, GLint h);
  189. void (*free)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv);
  190. /* exported */
  191. void (*freePrivate)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv);
  192. #ifdef __cplusplus
  193. void *privatePtr;
  194. #else
  195. void *private;
  196. #endif
  197. /* private */
  198. void *other; /* implementation private data */
  199. __GLbufMainInitFn mainInit;
  200. __GLbufFallbackInitFn fallbackInit;
  201. };
  202. /*
  203. ** The context side of the drawable private
  204. */
  205. struct __GLdrawablePrivateRec {
  206. /*
  207. ** Drawable Modes
  208. */
  209. __GLcontextModes *modes;
  210. /*
  211. ** Drawable size
  212. */
  213. GLuint width, height;
  214. /*
  215. ** Origin in screen coordinates of the drawable
  216. */
  217. GLint xOrigin, yOrigin;
  218. #ifdef __GL_ALIGNED_BUFFERS
  219. /*
  220. ** Drawable offset from screen origin
  221. */
  222. GLint xOffset, yOffset;
  223. /*
  224. ** Alignment restriction
  225. */
  226. GLint xAlignment, yAlignment;
  227. #endif
  228. /*
  229. ** Should we invert the y axis?
  230. */
  231. GLint yInverted;
  232. /*
  233. ** Mask specifying which buffers are renderable by the hw
  234. */
  235. GLuint accelBufferMask;
  236. /*
  237. ** the buffers themselves
  238. */
  239. __GLdrawableBuffer frontBuffer;
  240. __GLdrawableBuffer backBuffer;
  241. __GLdrawableBuffer accumBuffer;
  242. __GLdrawableBuffer depthBuffer;
  243. __GLdrawableBuffer stencilBuffer;
  244. #if defined(__GL_NUMBER_OF_AUX_BUFFERS) && (__GL_NUMBER_OF_AUX_BUFFERS > 0)
  245. __GLdrawableBuffer *auxBuffer;
  246. #endif
  247. __GLdrawableRegion ownershipRegion;
  248. /*
  249. ** Lock for the drawable private structure
  250. */
  251. void *lock;
  252. #ifdef DEBUG
  253. /* lock debugging info */
  254. int lockRefCount;
  255. int lockLine[10];
  256. char *lockFile[10];
  257. #endif
  258. /* imported */
  259. void *(*malloc)(size_t size);
  260. void *(*calloc)(size_t numElem, size_t elemSize);
  261. void *(*realloc)(void *oldAddr, size_t newSize);
  262. void (*free)(void *addr);
  263. GLboolean (*addSwapRect)(__GLdrawablePrivate *glPriv,
  264. GLint x, GLint y, GLsizei width, GLsizei height);
  265. void (*setClipRect)(__GLdrawablePrivate *glPriv,
  266. GLint x, GLint y, GLsizei width, GLsizei height);
  267. void (*updateClipRegion)(__GLdrawablePrivate *glPriv);
  268. GLboolean (*resize)(__GLdrawablePrivate *glPriv);
  269. void (*getDrawableSize)(__GLdrawablePrivate *glPriv,
  270. GLint *x, GLint *y, GLuint *width, GLuint *height);
  271. void (*lockDP)(__GLdrawablePrivate *glPriv, __GLcontext *gc);
  272. void (*unlockDP)(__GLdrawablePrivate *glPriv);
  273. /* exported */
  274. #if 0 /* disable, just like in __GLimportsRec */
  275. void *wsPriv; /* pointer to the window system DrawablePrivate */
  276. #endif
  277. #ifdef __cplusplus
  278. void *privatePtr;
  279. #else
  280. void *private;
  281. #endif
  282. void (*freePrivate)(__GLdrawablePrivate *);
  283. /* client data */
  284. void *other;
  285. };
  286. /*
  287. ** Macros to lock/unlock the drawable private
  288. */
  289. #if defined(DEBUG)
  290. #define __GL_LOCK_DP(glPriv,gc) \
  291. (*(glPriv)->lockDP)(glPriv,gc); \
  292. (glPriv)->lockLine[(glPriv)->lockRefCount] = __LINE__; \
  293. (glPriv)->lockFile[(glPriv)->lockRefCount] = __FILE__; \
  294. (glPriv)->lockRefCount++
  295. #define __GL_UNLOCK_DP(glPriv) \
  296. (glPriv)->lockRefCount--; \
  297. (glPriv)->lockLine[(glPriv)->lockRefCount] = 0; \
  298. (glPriv)->lockFile[(glPriv)->lockRefCount] = NULL; \
  299. (*(glPriv)->unlockDP)(glPriv)
  300. #else /* DEBUG */
  301. #define __GL_LOCK_DP(glPriv,gc) (*(glPriv)->lockDP)(glPriv,gc)
  302. #define __GL_UNLOCK_DP(glPriv) (*(glPriv)->unlockDP)(glPriv)
  303. #endif /* DEBUG */
  304. /*
  305. ** Procedures which are imported by the GL from the surrounding
  306. ** "operating system". Math functions are not considered part of the
  307. ** "operating system".
  308. */
  309. typedef struct __GLimportsRec {
  310. /* Memory management */
  311. void * (*malloc)(__GLcontext *gc, size_t size);
  312. void *(*calloc)(__GLcontext *gc, size_t numElem, size_t elemSize);
  313. void *(*realloc)(__GLcontext *gc, void *oldAddr, size_t newSize);
  314. void (*free)(__GLcontext *gc, void *addr);
  315. /* Error handling */
  316. void (*warning)(__GLcontext *gc, char *fmt);
  317. void (*fatal)(__GLcontext *gc, char *fmt);
  318. /* other system calls */
  319. char *(CAPI *getenv)(__GLcontext *gc, const char *var);
  320. int (CAPI *atoi)(__GLcontext *gc, const char *str);
  321. int (CAPI *sprintf)(__GLcontext *gc, char *str, const char *fmt, ...);
  322. void *(CAPI *fopen)(__GLcontext *gc, const char *path, const char *mode);
  323. int (CAPI *fclose)(__GLcontext *gc, void *stream);
  324. int (CAPI *fprintf)(__GLcontext *gc, void *stream, const char *fmt, ...);
  325. /* Drawing surface management */
  326. __GLdrawablePrivate *(*getDrawablePrivate)(__GLcontext *gc);
  327. #if 0
  328. /* At some point, this field got removed from the XFree86 glcore.h file.
  329. * we're removing it here to prevent interop problems. (Brian)
  330. */
  331. /* Pointer to the window system context */
  332. void *wscx;
  333. #endif
  334. /* Operating system dependent data goes here */
  335. void *other;
  336. } __GLimports;
  337. /************************************************************************/
  338. /*
  339. ** Procedures which are exported by the GL to the surrounding "operating
  340. ** system" so that it can manage multiple GL context's.
  341. */
  342. typedef struct __GLexportsRec {
  343. /* Context management (return GL_FALSE on failure) */
  344. GLboolean (*destroyContext)(__GLcontext *gc);
  345. GLboolean (*loseCurrent)(__GLcontext *gc);
  346. GLboolean (*makeCurrent)(__GLcontext *gc);
  347. GLboolean (*shareContext)(__GLcontext *gc, __GLcontext *gcShare);
  348. GLboolean (*copyContext)(__GLcontext *dst, const __GLcontext *src, GLuint mask);
  349. GLboolean (*forceCurrent)(__GLcontext *gc);
  350. /* Drawing surface notification callbacks */
  351. GLboolean (*notifyResize)(__GLcontext *gc);
  352. void (*notifyDestroy)(__GLcontext *gc);
  353. void (*notifySwapBuffers)(__GLcontext *gc);
  354. /* Dispatch table override control for external agents like libGLS */
  355. struct __GLdispatchStateRec* (*dispatchExec)(__GLcontext *gc);
  356. void (*beginDispatchOverride)(__GLcontext *gc);
  357. void (*endDispatchOverride)(__GLcontext *gc);
  358. } __GLexports;
  359. /************************************************************************/
  360. /*
  361. ** This must be the first member of a __GLcontext structure. This is the
  362. ** only part of a context that is exposed to the outside world; everything
  363. ** else is opaque.
  364. */
  365. struct __GLinterfaceRec {
  366. __GLimports imports;
  367. __GLexports exports;
  368. };
  369. extern __GLcontext *__glCoreCreateContext(__GLimports *, __GLcontextModes *);
  370. extern void __glCoreNopDispatch(void);
  371. #endif /* __gl_core_h_ */