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-new.h 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  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/08 03:56:53 $ $Revision: 1.1 $
  37. ** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/include/GL/internal/Attic/glcore-new.h,v 1.1 2001/01/08 03:56:53 keithw Exp $
  38. */
  39. #ifdef XFree86LOADER
  40. #include "xf86_ansic.h"
  41. #else
  42. #include <sys/types.h>
  43. #endif
  44. typedef struct __GLcontextRec __GLcontext;
  45. typedef struct __GLinterfaceRec __GLinterface;
  46. /*
  47. ** This file defines the interface between the GL core and the surrounding
  48. ** "operating system" that supports it (currently the GLX or WGL extensions).
  49. **
  50. ** Members (data and function pointers) are documented as imported or
  51. ** exported according to how they are used by the core rendering functions.
  52. ** Imported members are initialized by the "operating system" and used by
  53. ** the core functions. Exported members are initialized by the core functions
  54. ** and used by the "operating system".
  55. */
  56. /*
  57. ** Mode and limit information for a context. This information is
  58. ** kept around in the context so that values can be used during
  59. ** command execution, and for returning information about the
  60. ** context to the application.
  61. */
  62. typedef struct __GLcontextModesRec {
  63. GLboolean rgbMode;
  64. GLboolean colorIndexMode;
  65. GLboolean doubleBufferMode;
  66. GLboolean stereoMode;
  67. GLboolean haveAccumBuffer;
  68. GLboolean haveDepthBuffer;
  69. GLboolean haveStencilBuffer;
  70. GLint redBits, greenBits, blueBits, alphaBits; /* bits per comp */
  71. GLuint redMask, greenMask, blueMask, alphaMask;
  72. GLint rgbBits; /* total bits for rgb */
  73. GLint indexBits; /* total bits for colorindex */
  74. GLint accumRedBits, accumGreenBits, accumBlueBits, accumAlphaBits;
  75. GLint depthBits;
  76. GLint stencilBits;
  77. GLint numAuxBuffers;
  78. GLint level;
  79. GLint pixmapMode;
  80. } __GLcontextModes;
  81. /************************************************************************/
  82. /*
  83. ** Structure used for allocating and freeing drawable private memory.
  84. ** (like software buffers, for example).
  85. **
  86. ** The memory allocation routines are provided by the surrounding
  87. ** "operating system" code, and they are to be used for allocating
  88. ** software buffers and things which are associated with the drawable,
  89. ** and used by any context which draws to that drawable. There are
  90. ** separate memory allocation functions for drawables and contexts
  91. ** since drawables and contexts can be created and destroyed independently
  92. ** of one another, and the "operating system" may want to use separate
  93. ** allocation arenas for each.
  94. **
  95. ** The freePrivate function is filled in by the core routines when they
  96. ** allocates software buffers, and stick them in "private". The freePrivate
  97. ** function will destroy anything allocated to this drawable (to be called
  98. ** when the drawable is destroyed).
  99. */
  100. typedef struct __GLdrawableRegionRec __GLdrawableRegion;
  101. typedef struct __GLdrawableBufferRec __GLdrawableBuffer;
  102. typedef struct __GLdrawablePrivateRec __GLdrawablePrivate;
  103. typedef struct __GLregionRectRec {
  104. /* lower left (inside the rectangle) */
  105. GLint x0, y0;
  106. /* upper right (outside the rectangle) */
  107. GLint x1, y1;
  108. } __GLregionRect;
  109. struct __GLdrawableRegionRec {
  110. GLint numRects;
  111. __GLregionRect *rects;
  112. __GLregionRect boundingRect;
  113. };
  114. /************************************************************************/
  115. /* masks for the buffers */
  116. #define __GL_FRONT_BUFFER_MASK 0x00000001
  117. #define __GL_FRONT_LEFT_BUFFER_MASK 0x00000001
  118. #define __GL_FRONT_RIGHT_BUFFER_MASK 0x00000002
  119. #define __GL_BACK_BUFFER_MASK 0x00000004
  120. #define __GL_BACK_LEFT_BUFFER_MASK 0x00000004
  121. #define __GL_BACK_RIGHT_BUFFER_MASK 0x00000008
  122. #define __GL_ACCUM_BUFFER_MASK 0x00000010
  123. #define __GL_DEPTH_BUFFER_MASK 0x00000020
  124. #define __GL_STENCIL_BUFFER_MASK 0x00000040
  125. #define __GL_AUX_BUFFER_MASK(i) (0x0000080 << (i))
  126. #define __GL_ALL_BUFFER_MASK 0xffffffff
  127. /* what Resize routines return if resize resorted to fallback case */
  128. #define __GL_BUFFER_FALLBACK 0x10
  129. typedef void (*__GLbufFallbackInitFn)(__GLdrawableBuffer *buf,
  130. __GLdrawablePrivate *glPriv, GLint bits);
  131. typedef void (*__GLbufMainInitFn)(__GLdrawableBuffer *buf,
  132. __GLdrawablePrivate *glPriv, GLint bits,
  133. __GLbufFallbackInitFn back);
  134. /*
  135. ** A drawable buffer
  136. **
  137. ** This data structure describes the context side of a drawable.
  138. **
  139. ** According to the spec there could be multiple contexts bound to the same
  140. ** drawable at the same time (from different threads). In order to avoid
  141. ** multiple-access conflicts, locks are used to serialize access. When a
  142. ** thread needs to access (read or write) a member of the drawable, it takes
  143. ** a lock first. Some of the entries in the drawable are treated "mostly
  144. ** constant", so we take the freedom of allowing access to them without
  145. ** taking a lock (for optimization reasons).
  146. **
  147. ** For more details regarding locking, see buffers.h in the GL core
  148. */
  149. struct __GLdrawableBufferRec {
  150. /*
  151. ** Buffer dimensions
  152. */
  153. GLint width, height, depth;
  154. /*
  155. ** Framebuffer base address
  156. */
  157. void *base;
  158. /*
  159. ** Framebuffer size (in bytes)
  160. */
  161. GLuint size;
  162. /*
  163. ** Size (in bytes) of each element in the framebuffer
  164. */
  165. GLuint elementSize;
  166. GLuint elementSizeLog2;
  167. /*
  168. ** Element skip from one scanline to the next.
  169. ** If the buffer is part of another buffer (for example, fullscreen
  170. ** front buffer), outerWidth is the width of that buffer.
  171. */
  172. GLint outerWidth;
  173. /*
  174. ** outerWidth * elementSize
  175. */
  176. GLint byteWidth;
  177. /*
  178. ** Allocation/deallocation is done based on this handle. A handle
  179. ** is conceptually different from the framebuffer 'base'.
  180. */
  181. void *handle;
  182. /* imported */
  183. GLboolean (*resize)(__GLdrawableBuffer *buf,
  184. GLint x, GLint y, GLuint width, GLuint height,
  185. __GLdrawablePrivate *glPriv, GLuint bufferMask);
  186. void (*lock)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv);
  187. void (*unlock)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv);
  188. void (*fill)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv,
  189. GLuint val, GLint x, GLint y, GLint w, GLint h);
  190. void (*free)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv);
  191. /* exported */
  192. void (*freePrivate)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv);
  193. #ifdef __cplusplus
  194. void *privatePtr;
  195. #else
  196. void *private;
  197. #endif
  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 *wsPriv; /* pointer to the window system DrawablePrivate */
  276. #ifdef __cplusplus
  277. void *privatePtr;
  278. #else
  279. void *private;
  280. #endif
  281. void (*freePrivate)(__GLdrawablePrivate *);
  282. /* client data */
  283. void *other;
  284. };
  285. /*
  286. ** Macros to lock/unlock the drawable private
  287. */
  288. #if defined(DEBUG)
  289. #define __GL_LOCK_DP(glPriv,gc) \
  290. (*(glPriv)->lockDP)(glPriv,gc); \
  291. (glPriv)->lockLine[(glPriv)->lockRefCount] = __LINE__; \
  292. (glPriv)->lockFile[(glPriv)->lockRefCount] = __FILE__; \
  293. (glPriv)->lockRefCount++
  294. #define __GL_UNLOCK_DP(glPriv) \
  295. (glPriv)->lockRefCount--; \
  296. (glPriv)->lockLine[(glPriv)->lockRefCount] = 0; \
  297. (glPriv)->lockFile[(glPriv)->lockRefCount] = NULL; \
  298. (*(glPriv)->unlockDP)(glPriv)
  299. #else /* DEBUG */
  300. #define __GL_LOCK_DP(glPriv,gc) (*(glPriv)->lockDP)(glPriv,gc)
  301. #define __GL_UNLOCK_DP(glPriv) (*(glPriv)->unlockDP)(glPriv)
  302. #endif /* DEBUG */
  303. /*
  304. ** Procedures which are imported by the GL from the surrounding
  305. ** "operating system". Math functions are not considered part of the
  306. ** "operating system".
  307. */
  308. typedef struct __GLimportsRec {
  309. /* Memory management */
  310. void * (*malloc)(__GLcontext *gc, size_t size);
  311. void *(*calloc)(__GLcontext *gc, size_t numElem, size_t elemSize);
  312. void *(*realloc)(__GLcontext *gc, void *oldAddr, size_t newSize);
  313. void (*free)(__GLcontext *gc, void *addr);
  314. /* Error handling */
  315. void (*warning)(__GLcontext *gc, char *fmt);
  316. void (*fatal)(__GLcontext *gc, char *fmt);
  317. /* other system calls */
  318. char *(CAPI *getenv)(__GLcontext *gc, const char *var);
  319. int (CAPI *atoi)(__GLcontext *gc, const char *str);
  320. int (CAPI *sprintf)(__GLcontext *gc, char *str, const char *fmt, ...);
  321. void *(CAPI *fopen)(__GLcontext *gc, const char *path, const char *mode);
  322. int (CAPI *fclose)(__GLcontext *gc, void *stream);
  323. int (CAPI *fprintf)(__GLcontext *gc, void *stream, const char *fmt, ...);
  324. /* Drawing surface management */
  325. __GLdrawablePrivate *(*getDrawablePrivate)(__GLcontext *gc);
  326. /* Pointer to the window system context */
  327. void *wscx;
  328. /* Operating system dependent data goes here */
  329. void *other;
  330. } __GLimports;
  331. /************************************************************************/
  332. /*
  333. ** Procedures which are exported by the GL to the surrounding "operating
  334. ** system" so that it can manage multiple GL context's.
  335. */
  336. typedef struct __GLexportsRec {
  337. /* Context management (return GL_FALSE on failure) */
  338. GLboolean (*destroyContext)(__GLcontext *gc);
  339. GLboolean (*loseCurrent)(__GLcontext *gc);
  340. GLboolean (*makeCurrent)(__GLcontext *gc);
  341. GLboolean (*shareContext)(__GLcontext *gc, __GLcontext *gcShare);
  342. GLboolean (*copyContext)(__GLcontext *dst, const __GLcontext *src, GLuint mask);
  343. GLboolean (*forceCurrent)(__GLcontext *gc);
  344. /* Drawing surface notification callbacks */
  345. GLboolean (*notifyResize)(__GLcontext *gc);
  346. void (*notifyDestroy)(__GLcontext *gc);
  347. void (*notifySwapBuffers)(__GLcontext *gc);
  348. /* Dispatch table override control for external agents like libGLS */
  349. struct __GLdispatchStateRec* (*dispatchExec)(__GLcontext *gc);
  350. void (*beginDispatchOverride)(__GLcontext *gc);
  351. void (*endDispatchOverride)(__GLcontext *gc);
  352. } __GLexports;
  353. /************************************************************************/
  354. /*
  355. ** This must be the first member of a __GLcontext structure. This is the
  356. ** only part of a context that is exposed to the outside world; everything
  357. ** else is opaque.
  358. */
  359. struct __GLinterfaceRec {
  360. __GLimports imports;
  361. __GLexports exports;
  362. };
  363. extern __GLcontext *__glCoreCreateContext(__GLimports *, __GLcontextModes *);
  364. extern void __glCoreNopDispatch(void);
  365. #endif /* __gl_core_h_ */