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

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