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 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  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. #ifdef CAPI
  42. #undef CAPI
  43. #endif
  44. #define CAPI
  45. #define GL_CORE_SGI 1
  46. #define GL_CORE_MESA 2
  47. #define GL_CORE_APPLE 4
  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. struct __GLcontextModesRec * next;
  68. GLboolean rgbMode;
  69. GLboolean floatMode;
  70. GLboolean colorIndexMode;
  71. GLuint doubleBufferMode;
  72. GLuint stereoMode;
  73. GLboolean haveAccumBuffer;
  74. GLboolean haveDepthBuffer;
  75. GLboolean haveStencilBuffer;
  76. GLint redBits, greenBits, blueBits, alphaBits; /* bits per comp */
  77. GLuint redMask, greenMask, blueMask, alphaMask;
  78. GLint rgbBits; /* total bits for rgb */
  79. GLint indexBits; /* total bits for colorindex */
  80. GLint accumRedBits, accumGreenBits, accumBlueBits, accumAlphaBits;
  81. GLint depthBits;
  82. GLint stencilBits;
  83. GLint numAuxBuffers;
  84. GLint level;
  85. GLint pixmapMode;
  86. /* GLX */
  87. GLint visualID;
  88. GLint visualType; /**< One of the GLX X visual types. (i.e.,
  89. * \c GLX_TRUE_COLOR, etc.)
  90. */
  91. /* EXT_visual_rating / GLX 1.2 */
  92. GLint visualRating;
  93. /* EXT_visual_info / GLX 1.2 */
  94. GLint transparentPixel;
  95. /* colors are floats scaled to ints */
  96. GLint transparentRed, transparentGreen, transparentBlue, transparentAlpha;
  97. GLint transparentIndex;
  98. /* ARB_multisample / SGIS_multisample */
  99. GLint sampleBuffers;
  100. GLint samples;
  101. /* SGIX_fbconfig / GLX 1.3 */
  102. GLint drawableType;
  103. GLint renderType;
  104. GLint xRenderable;
  105. GLint fbconfigID;
  106. /* SGIX_pbuffer / GLX 1.3 */
  107. GLint maxPbufferWidth;
  108. GLint maxPbufferHeight;
  109. GLint maxPbufferPixels;
  110. GLint optimalPbufferWidth; /* Only for SGIX_pbuffer. */
  111. GLint optimalPbufferHeight; /* Only for SGIX_pbuffer. */
  112. /* SGIX_visual_select_group */
  113. GLint visualSelectGroup;
  114. /* OML_swap_method */
  115. GLint swapMethod;
  116. GLint screen;
  117. } __GLcontextModes;
  118. /* Several fields of __GLcontextModes can take these as values. Since
  119. * GLX header files may not be available everywhere they need to be used,
  120. * redefine them here.
  121. */
  122. #define GLX_NONE 0x8000
  123. #define GLX_SLOW_CONFIG 0x8001
  124. #define GLX_TRUE_COLOR 0x8002
  125. #define GLX_DIRECT_COLOR 0x8003
  126. #define GLX_PSEUDO_COLOR 0x8004
  127. #define GLX_STATIC_COLOR 0x8005
  128. #define GLX_GRAY_SCALE 0x8006
  129. #define GLX_STATIC_GRAY 0x8007
  130. #define GLX_TRANSPARENT_RGB 0x8008
  131. #define GLX_TRANSPARENT_INDEX 0x8009
  132. #define GLX_NON_CONFORMANT_CONFIG 0x800D
  133. #define GLX_SWAP_EXCHANGE_OML 0x8061
  134. #define GLX_SWAP_COPY_OML 0x8062
  135. #define GLX_SWAP_UNDEFINED_OML 0x8063
  136. #define GLX_DONT_CARE 0xFFFFFFFF
  137. #define GLX_RGBA_BIT 0x00000001
  138. #define GLX_COLOR_INDEX_BIT 0x00000002
  139. #define GLX_WINDOW_BIT 0x00000001
  140. #define GLX_PIXMAP_BIT 0x00000002
  141. #define GLX_PBUFFER_BIT 0x00000004
  142. /************************************************************************/
  143. /*
  144. ** Structure used for allocating and freeing drawable private memory.
  145. ** (like software buffers, for example).
  146. **
  147. ** The memory allocation routines are provided by the surrounding
  148. ** "operating system" code, and they are to be used for allocating
  149. ** software buffers and things which are associated with the drawable,
  150. ** and used by any context which draws to that drawable. There are
  151. ** separate memory allocation functions for drawables and contexts
  152. ** since drawables and contexts can be created and destroyed independently
  153. ** of one another, and the "operating system" may want to use separate
  154. ** allocation arenas for each.
  155. **
  156. ** The freePrivate function is filled in by the core routines when they
  157. ** allocates software buffers, and stick them in "private". The freePrivate
  158. ** function will destroy anything allocated to this drawable (to be called
  159. ** when the drawable is destroyed).
  160. */
  161. typedef struct __GLdrawableRegionRec __GLdrawableRegion;
  162. typedef struct __GLdrawableBufferRec __GLdrawableBuffer;
  163. typedef struct __GLdrawablePrivateRec __GLdrawablePrivate;
  164. typedef struct __GLregionRectRec {
  165. /* lower left (inside the rectangle) */
  166. GLint x0, y0;
  167. /* upper right (outside the rectangle) */
  168. GLint x1, y1;
  169. } __GLregionRect;
  170. struct __GLdrawableRegionRec {
  171. GLint numRects;
  172. __GLregionRect *rects;
  173. __GLregionRect boundingRect;
  174. };
  175. /************************************************************************/
  176. /* masks for the buffers */
  177. #define __GL_FRONT_BUFFER_MASK 0x00000001
  178. #define __GL_FRONT_LEFT_BUFFER_MASK 0x00000001
  179. #define __GL_FRONT_RIGHT_BUFFER_MASK 0x00000002
  180. #define __GL_BACK_BUFFER_MASK 0x00000004
  181. #define __GL_BACK_LEFT_BUFFER_MASK 0x00000004
  182. #define __GL_BACK_RIGHT_BUFFER_MASK 0x00000008
  183. #define __GL_ACCUM_BUFFER_MASK 0x00000010
  184. #define __GL_DEPTH_BUFFER_MASK 0x00000020
  185. #define __GL_STENCIL_BUFFER_MASK 0x00000040
  186. #define __GL_AUX_BUFFER_MASK(i) (0x0000080 << (i))
  187. #define __GL_ALL_BUFFER_MASK 0xffffffff
  188. /* what Resize routines return if resize resorted to fallback case */
  189. #define __GL_BUFFER_FALLBACK 0x10
  190. typedef void (*__GLbufFallbackInitFn)(__GLdrawableBuffer *buf,
  191. __GLdrawablePrivate *glPriv, GLint bits);
  192. typedef void (*__GLbufMainInitFn)(__GLdrawableBuffer *buf,
  193. __GLdrawablePrivate *glPriv, GLint bits,
  194. __GLbufFallbackInitFn back);
  195. /*
  196. ** A drawable buffer
  197. **
  198. ** This data structure describes the context side of a drawable.
  199. **
  200. ** According to the spec there could be multiple contexts bound to the same
  201. ** drawable at the same time (from different threads). In order to avoid
  202. ** multiple-access conflicts, locks are used to serialize access. When a
  203. ** thread needs to access (read or write) a member of the drawable, it takes
  204. ** a lock first. Some of the entries in the drawable are treated "mostly
  205. ** constant", so we take the freedom of allowing access to them without
  206. ** taking a lock (for optimization reasons).
  207. **
  208. ** For more details regarding locking, see buffers.h in the GL core
  209. */
  210. struct __GLdrawableBufferRec {
  211. /*
  212. ** Buffer dimensions
  213. */
  214. GLint width, height, depth;
  215. /*
  216. ** Framebuffer base address
  217. */
  218. void *base;
  219. /*
  220. ** Framebuffer size (in bytes)
  221. */
  222. GLuint size;
  223. /*
  224. ** Size (in bytes) of each element in the framebuffer
  225. */
  226. GLuint elementSize;
  227. GLuint elementSizeLog2;
  228. /*
  229. ** Element skip from one scanline to the next.
  230. ** If the buffer is part of another buffer (for example, fullscreen
  231. ** front buffer), outerWidth is the width of that buffer.
  232. */
  233. GLint outerWidth;
  234. /*
  235. ** outerWidth * elementSize
  236. */
  237. GLint byteWidth;
  238. /*
  239. ** Allocation/deallocation is done based on this handle. A handle
  240. ** is conceptually different from the framebuffer 'base'.
  241. */
  242. void *handle;
  243. /* imported */
  244. GLboolean (*resize)(__GLdrawableBuffer *buf,
  245. GLint x, GLint y, GLuint width, GLuint height,
  246. __GLdrawablePrivate *glPriv, GLuint bufferMask);
  247. void (*lock)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv);
  248. void (*unlock)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv);
  249. void (*fill)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv,
  250. GLuint val, GLint x, GLint y, GLint w, GLint h);
  251. void (*free)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv);
  252. /* exported */
  253. void (*freePrivate)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv);
  254. #ifdef __cplusplus
  255. void *privatePtr;
  256. #else
  257. void *private;
  258. #endif
  259. /* private */
  260. void *other; /* implementation private data */
  261. __GLbufMainInitFn mainInit;
  262. __GLbufFallbackInitFn fallbackInit;
  263. };
  264. /*
  265. ** The context side of the drawable private
  266. */
  267. struct __GLdrawablePrivateRec {
  268. /*
  269. ** Drawable Modes
  270. */
  271. __GLcontextModes *modes;
  272. /*
  273. ** Drawable size
  274. */
  275. GLuint width, height;
  276. /*
  277. ** Origin in screen coordinates of the drawable
  278. */
  279. GLint xOrigin, yOrigin;
  280. #ifdef __GL_ALIGNED_BUFFERS
  281. /*
  282. ** Drawable offset from screen origin
  283. */
  284. GLint xOffset, yOffset;
  285. /*
  286. ** Alignment restriction
  287. */
  288. GLint xAlignment, yAlignment;
  289. #endif
  290. /*
  291. ** Should we invert the y axis?
  292. */
  293. GLint yInverted;
  294. /*
  295. ** Mask specifying which buffers are renderable by the hw
  296. */
  297. GLuint accelBufferMask;
  298. /*
  299. ** the buffers themselves
  300. */
  301. __GLdrawableBuffer frontBuffer;
  302. __GLdrawableBuffer backBuffer;
  303. __GLdrawableBuffer accumBuffer;
  304. __GLdrawableBuffer depthBuffer;
  305. __GLdrawableBuffer stencilBuffer;
  306. #if defined(__GL_NUMBER_OF_AUX_BUFFERS) && (__GL_NUMBER_OF_AUX_BUFFERS > 0)
  307. __GLdrawableBuffer *auxBuffer;
  308. #endif
  309. __GLdrawableRegion ownershipRegion;
  310. /*
  311. ** Lock for the drawable private structure
  312. */
  313. void *lock;
  314. #ifdef DEBUG
  315. /* lock debugging info */
  316. int lockRefCount;
  317. int lockLine[10];
  318. char *lockFile[10];
  319. #endif
  320. /* imported */
  321. void *(*malloc)(size_t size);
  322. void *(*calloc)(size_t numElem, size_t elemSize);
  323. void *(*realloc)(void *oldAddr, size_t newSize);
  324. void (*free)(void *addr);
  325. GLboolean (*addSwapRect)(__GLdrawablePrivate *glPriv,
  326. GLint x, GLint y, GLsizei width, GLsizei height);
  327. void (*setClipRect)(__GLdrawablePrivate *glPriv,
  328. GLint x, GLint y, GLsizei width, GLsizei height);
  329. void (*updateClipRegion)(__GLdrawablePrivate *glPriv);
  330. GLboolean (*resize)(__GLdrawablePrivate *glPriv);
  331. void (*getDrawableSize)(__GLdrawablePrivate *glPriv,
  332. GLint *x, GLint *y, GLuint *width, GLuint *height);
  333. void (*lockDP)(__GLdrawablePrivate *glPriv, __GLcontext *gc);
  334. void (*unlockDP)(__GLdrawablePrivate *glPriv);
  335. /* exported */
  336. #ifdef __cplusplus
  337. void *privatePtr;
  338. #else
  339. void *private;
  340. #endif
  341. void (*freePrivate)(__GLdrawablePrivate *);
  342. /* client data */
  343. void *other;
  344. };
  345. /*
  346. ** Macros to lock/unlock the drawable private
  347. */
  348. #if defined(DEBUG)
  349. #define __GL_LOCK_DP(glPriv,gc) \
  350. (*(glPriv)->lockDP)(glPriv,gc); \
  351. (glPriv)->lockLine[(glPriv)->lockRefCount] = __LINE__; \
  352. (glPriv)->lockFile[(glPriv)->lockRefCount] = __FILE__; \
  353. (glPriv)->lockRefCount++
  354. #define __GL_UNLOCK_DP(glPriv) \
  355. (glPriv)->lockRefCount--; \
  356. (glPriv)->lockLine[(glPriv)->lockRefCount] = 0; \
  357. (glPriv)->lockFile[(glPriv)->lockRefCount] = NULL; \
  358. (*(glPriv)->unlockDP)(glPriv)
  359. #else /* DEBUG */
  360. #define __GL_LOCK_DP(glPriv,gc) (*(glPriv)->lockDP)(glPriv,gc)
  361. #define __GL_UNLOCK_DP(glPriv) (*(glPriv)->unlockDP)(glPriv)
  362. #endif /* DEBUG */
  363. /*
  364. ** Procedures which are imported by the GL from the surrounding
  365. ** "operating system". Math functions are not considered part of the
  366. ** "operating system".
  367. */
  368. typedef struct __GLimportsRec {
  369. /* Memory management */
  370. void * (*malloc)(__GLcontext *gc, size_t size);
  371. void *(*calloc)(__GLcontext *gc, size_t numElem, size_t elemSize);
  372. void *(*realloc)(__GLcontext *gc, void *oldAddr, size_t newSize);
  373. void (*free)(__GLcontext *gc, void *addr);
  374. /* Error handling */
  375. void (*warning)(__GLcontext *gc, char *fmt);
  376. void (*fatal)(__GLcontext *gc, char *fmt);
  377. /* other system calls */
  378. char *(CAPI *getenv)(__GLcontext *gc, const char *var);
  379. int (CAPI *atoi)(__GLcontext *gc, const char *str);
  380. int (CAPI *sprintf)(__GLcontext *gc, char *str, const char *fmt, ...);
  381. void *(CAPI *fopen)(__GLcontext *gc, const char *path, const char *mode);
  382. int (CAPI *fclose)(__GLcontext *gc, void *stream);
  383. int (CAPI *fprintf)(__GLcontext *gc, void *stream, const char *fmt, ...);
  384. /* Drawing surface management */
  385. __GLdrawablePrivate *(*getDrawablePrivate)(__GLcontext *gc);
  386. __GLdrawablePrivate *(*getReadablePrivate)(__GLcontext *gc);
  387. /* Operating system dependent data goes here */
  388. void *other;
  389. } __GLimports;
  390. /************************************************************************/
  391. /*
  392. ** Procedures which are exported by the GL to the surrounding "operating
  393. ** system" so that it can manage multiple GL context's.
  394. */
  395. typedef struct __GLexportsRec {
  396. /* Context management (return GL_FALSE on failure) */
  397. GLboolean (*destroyContext)(__GLcontext *gc);
  398. GLboolean (*loseCurrent)(__GLcontext *gc);
  399. /* oldglPriv isn't used anymore, kept for backwards compatibility */
  400. GLboolean (*makeCurrent)(__GLcontext *gc);
  401. GLboolean (*shareContext)(__GLcontext *gc, __GLcontext *gcShare);
  402. GLboolean (*copyContext)(__GLcontext *dst, const __GLcontext *src, GLuint mask);
  403. GLboolean (*forceCurrent)(__GLcontext *gc);
  404. /* Drawing surface notification callbacks */
  405. GLboolean (*notifyResize)(__GLcontext *gc);
  406. void (*notifyDestroy)(__GLcontext *gc);
  407. void (*notifySwapBuffers)(__GLcontext *gc);
  408. /* Dispatch table override control for external agents like libGLS */
  409. struct __GLdispatchStateRec* (*dispatchExec)(__GLcontext *gc);
  410. void (*beginDispatchOverride)(__GLcontext *gc);
  411. void (*endDispatchOverride)(__GLcontext *gc);
  412. } __GLexports;
  413. /************************************************************************/
  414. /*
  415. ** This must be the first member of a __GLcontext structure. This is the
  416. ** only part of a context that is exposed to the outside world; everything
  417. ** else is opaque.
  418. */
  419. struct __GLinterfaceRec {
  420. __GLimports imports;
  421. __GLexports exports;
  422. };
  423. extern __GLcontext *__glCoreCreateContext(__GLimports *, __GLcontextModes *);
  424. extern void __glCoreNopDispatch(void);
  425. #endif /* __gl_core_h_ */