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

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