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.

xmesa.h 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. /*
  2. * Mesa 3-D graphics library
  3. * Version: 7.1
  4. *
  5. * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
  6. *
  7. * Permission is hereby granted, free of charge, to any person obtaining a
  8. * copy of this software and associated documentation files (the "Software"),
  9. * to deal in the Software without restriction, including without limitation
  10. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  11. * and/or sell copies of the Software, and to permit persons to whom the
  12. * Software is furnished to do so, subject to the following conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be included
  15. * in all copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  18. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  20. * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  21. * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  22. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  23. */
  24. /*
  25. * Mesa/X11 interface. This header file serves as the documentation for
  26. * the Mesa/X11 interface functions.
  27. *
  28. * Note: this interface isn't intended for user programs. It's primarily
  29. * just for implementing the pseudo-GLX interface.
  30. */
  31. /* Sample Usage:
  32. In addition to the usual X calls to select a visual, create a colormap
  33. and create a window, you must do the following to use the X/Mesa interface:
  34. 1. Call XMesaCreateVisual() to make an XMesaVisual from an XVisualInfo.
  35. 2. Call XMesaCreateContext() to create an X/Mesa rendering context, given
  36. the XMesaVisual.
  37. 3. Call XMesaCreateWindowBuffer() to create an XMesaBuffer from an X window
  38. and XMesaVisual.
  39. 4. Call XMesaMakeCurrent() to bind the XMesaBuffer to an XMesaContext and
  40. to make the context the current one.
  41. 5. Make gl* calls to render your graphics.
  42. 6. Use XMesaSwapBuffers() when double buffering to swap front/back buffers.
  43. 7. Before the X window is destroyed, call XMesaDestroyBuffer().
  44. 8. Before exiting, call XMesaDestroyVisual and XMesaDestroyContext.
  45. */
  46. #ifndef XMESA_H
  47. #define XMESA_H
  48. #ifdef __VMS
  49. #include <GL/vms_x_fix.h>
  50. #endif
  51. #ifdef __cplusplus
  52. extern "C" {
  53. #endif
  54. #ifdef XFree86Server
  55. #include "xmesa_xf86.h"
  56. #else
  57. #include <X11/Xlib.h>
  58. #include <X11/Xutil.h>
  59. #include "xmesa_x.h"
  60. #endif
  61. #include "GL/gl.h"
  62. #ifdef AMIWIN
  63. #include <pragmas/xlib_pragmas.h>
  64. extern struct Library *XLibBase;
  65. #endif
  66. #define XMESA_MAJOR_VERSION 6
  67. #define XMESA_MINOR_VERSION 3
  68. /*
  69. * Values passed to XMesaGetString:
  70. */
  71. #define XMESA_VERSION 1
  72. #define XMESA_EXTENSIONS 2
  73. /*
  74. * Values passed to XMesaSetFXmode:
  75. */
  76. #define XMESA_FX_WINDOW 1
  77. #define XMESA_FX_FULLSCREEN 2
  78. typedef struct xmesa_context *XMesaContext;
  79. typedef struct xmesa_visual *XMesaVisual;
  80. typedef struct xmesa_buffer *XMesaBuffer;
  81. /*
  82. * Create a new X/Mesa visual.
  83. * Input: display - X11 display
  84. * visinfo - an XVisualInfo pointer
  85. * rgb_flag - GL_TRUE = RGB mode,
  86. * GL_FALSE = color index mode
  87. * alpha_flag - alpha buffer requested?
  88. * db_flag - GL_TRUE = double-buffered,
  89. * GL_FALSE = single buffered
  90. * stereo_flag - stereo visual?
  91. * ximage_flag - GL_TRUE = use an XImage for back buffer,
  92. * GL_FALSE = use an off-screen pixmap for back buffer
  93. * depth_size - requested bits/depth values, or zero
  94. * stencil_size - requested bits/stencil values, or zero
  95. * accum_red_size - requested bits/red accum values, or zero
  96. * accum_green_size - requested bits/green accum values, or zero
  97. * accum_blue_size - requested bits/blue accum values, or zero
  98. * accum_alpha_size - requested bits/alpha accum values, or zero
  99. * num_samples - number of samples/pixel if multisampling, or zero
  100. * level - visual level, usually 0
  101. * visualCaveat - ala the GLX extension, usually GLX_NONE_EXT
  102. * Return; a new XMesaVisual or 0 if error.
  103. */
  104. extern XMesaVisual XMesaCreateVisual( XMesaDisplay *display,
  105. XMesaVisualInfo visinfo,
  106. GLboolean rgb_flag,
  107. GLboolean alpha_flag,
  108. GLboolean db_flag,
  109. GLboolean stereo_flag,
  110. GLboolean ximage_flag,
  111. GLint depth_size,
  112. GLint stencil_size,
  113. GLint accum_red_size,
  114. GLint accum_green_size,
  115. GLint accum_blue_size,
  116. GLint accum_alpha_size,
  117. GLint num_samples,
  118. GLint level,
  119. GLint visualCaveat );
  120. /*
  121. * Destroy an XMesaVisual, but not the associated XVisualInfo.
  122. */
  123. extern void XMesaDestroyVisual( XMesaVisual v );
  124. /*
  125. * Create a new XMesaContext for rendering into an X11 window.
  126. *
  127. * Input: visual - an XMesaVisual
  128. * share_list - another XMesaContext with which to share display
  129. * lists or NULL if no sharing is wanted.
  130. * Return: an XMesaContext or NULL if error.
  131. */
  132. extern XMesaContext XMesaCreateContext( XMesaVisual v,
  133. XMesaContext share_list );
  134. /*
  135. * Destroy a rendering context as returned by XMesaCreateContext()
  136. */
  137. extern void XMesaDestroyContext( XMesaContext c );
  138. #ifdef XFree86Server
  139. /*
  140. * These are the extra routines required for integration with XFree86.
  141. * None of these routines should be user visible. -KEM
  142. */
  143. extern GLboolean XMesaForceCurrent( XMesaContext c );
  144. extern GLboolean XMesaLoseCurrent( XMesaContext c );
  145. extern GLboolean XMesaCopyContext( XMesaContext src,
  146. XMesaContext dst,
  147. GLuint mask );
  148. #endif /* XFree86Server */
  149. /*
  150. * Create an XMesaBuffer from an X window.
  151. */
  152. extern XMesaBuffer XMesaCreateWindowBuffer( XMesaVisual v, XMesaWindow w );
  153. /*
  154. * Create an XMesaBuffer from an X pixmap.
  155. */
  156. extern XMesaBuffer XMesaCreatePixmapBuffer( XMesaVisual v,
  157. XMesaPixmap p,
  158. XMesaColormap cmap );
  159. /*
  160. * Destroy an XMesaBuffer, but not the corresponding window or pixmap.
  161. */
  162. extern void XMesaDestroyBuffer( XMesaBuffer b );
  163. /*
  164. * Return the XMesaBuffer handle which corresponds to an X drawable, if any.
  165. *
  166. * New in Mesa 2.3.
  167. */
  168. extern XMesaBuffer XMesaFindBuffer( XMesaDisplay *dpy,
  169. XMesaDrawable d );
  170. /*
  171. * Bind a buffer to a context and make the context the current one.
  172. */
  173. extern GLboolean XMesaMakeCurrent( XMesaContext c,
  174. XMesaBuffer b );
  175. /*
  176. * Bind two buffers (read and draw) to a context and make the
  177. * context the current one.
  178. * New in Mesa 3.3
  179. */
  180. extern GLboolean XMesaMakeCurrent2( XMesaContext c,
  181. XMesaBuffer drawBuffer,
  182. XMesaBuffer readBuffer );
  183. /*
  184. * Unbind the current context from its buffer.
  185. */
  186. extern GLboolean XMesaUnbindContext( XMesaContext c );
  187. /*
  188. * Return a handle to the current context.
  189. */
  190. extern XMesaContext XMesaGetCurrentContext( void );
  191. /*
  192. * Return handle to the current (draw) buffer.
  193. */
  194. extern XMesaBuffer XMesaGetCurrentBuffer( void );
  195. /*
  196. * Return handle to the current read buffer.
  197. * New in Mesa 3.3
  198. */
  199. extern XMesaBuffer XMesaGetCurrentReadBuffer( void );
  200. /*
  201. * Swap the front and back buffers for the given buffer. No action is
  202. * taken if the buffer is not double buffered.
  203. */
  204. extern void XMesaSwapBuffers( XMesaBuffer b );
  205. /*
  206. * Copy a sub-region of the back buffer to the front buffer.
  207. *
  208. * New in Mesa 2.6
  209. */
  210. extern void XMesaCopySubBuffer( XMesaBuffer b,
  211. int x,
  212. int y,
  213. int width,
  214. int height );
  215. /*
  216. * Return a pointer to the the Pixmap or XImage being used as the back
  217. * color buffer of an XMesaBuffer. This function is a way to get "under
  218. * the hood" of X/Mesa so one can manipulate the back buffer directly.
  219. * Input: b - the XMesaBuffer
  220. * Output: pixmap - pointer to back buffer's Pixmap, or 0
  221. * ximage - pointer to back buffer's XImage, or NULL
  222. * Return: GL_TRUE = context is double buffered
  223. * GL_FALSE = context is single buffered
  224. */
  225. extern GLboolean XMesaGetBackBuffer( XMesaBuffer b,
  226. XMesaPixmap *pixmap,
  227. XMesaImage **ximage );
  228. /*
  229. * Return the depth buffer associated with an XMesaBuffer.
  230. * Input: b - the XMesa buffer handle
  231. * Output: width, height - size of buffer in pixels
  232. * bytesPerValue - bytes per depth value (2 or 4)
  233. * buffer - pointer to depth buffer values
  234. * Return: GL_TRUE or GL_FALSE to indicate success or failure.
  235. *
  236. * New in Mesa 2.4.
  237. */
  238. extern GLboolean XMesaGetDepthBuffer( XMesaBuffer b,
  239. GLint *width,
  240. GLint *height,
  241. GLint *bytesPerValue,
  242. void **buffer );
  243. /*
  244. * Flush/sync a context
  245. */
  246. extern void XMesaFlush( XMesaContext c );
  247. /*
  248. * Get an X/Mesa-specific string.
  249. * Input: name - either XMESA_VERSION or XMESA_EXTENSIONS
  250. */
  251. extern const char *XMesaGetString( XMesaContext c, int name );
  252. /*
  253. * Scan for XMesaBuffers whose window/pixmap has been destroyed, then free
  254. * any memory used by that buffer.
  255. *
  256. * New in Mesa 2.3.
  257. */
  258. extern void XMesaGarbageCollect( void );
  259. /*
  260. * Return a dithered pixel value.
  261. * Input: c - XMesaContext
  262. * x, y - window coordinate
  263. * red, green, blue, alpha - color components in [0,1]
  264. * Return: pixel value
  265. *
  266. * New in Mesa 2.3.
  267. */
  268. extern unsigned long XMesaDitherColor( XMesaContext xmesa,
  269. GLint x,
  270. GLint y,
  271. GLfloat red,
  272. GLfloat green,
  273. GLfloat blue,
  274. GLfloat alpha );
  275. /*
  276. * 3Dfx Glide driver only!
  277. * Set 3Dfx/Glide full-screen or window rendering mode.
  278. * Input: mode - either XMESA_FX_WINDOW (window rendering mode) or
  279. * XMESA_FX_FULLSCREEN (full-screen rendering mode)
  280. * Return: GL_TRUE if success
  281. * GL_FALSE if invalid mode or if not using 3Dfx driver
  282. *
  283. * New in Mesa 2.6.
  284. */
  285. extern GLboolean XMesaSetFXmode( GLint mode );
  286. /*
  287. * Reallocate the back/depth/stencil/accum/etc/ buffers associated with
  288. * buffer <b> if its size has changed.
  289. *
  290. * New in Mesa 4.0.2
  291. */
  292. extern void XMesaResizeBuffers( XMesaBuffer b );
  293. /*
  294. * Create a pbuffer.
  295. * New in Mesa 4.1
  296. */
  297. extern XMesaBuffer XMesaCreatePBuffer(XMesaVisual v, XMesaColormap cmap,
  298. unsigned int width, unsigned int height);
  299. /*
  300. * Texture from Pixmap
  301. * New in Mesa 7.1
  302. */
  303. extern void
  304. XMesaBindTexImage(XMesaDisplay *dpy, XMesaBuffer drawable, int buffer,
  305. const int *attrib_list);
  306. extern void
  307. XMesaReleaseTexImage(XMesaDisplay *dpy, XMesaBuffer drawable, int buffer);
  308. extern XMesaBuffer
  309. XMesaCreatePixmapTextureBuffer(XMesaVisual v, XMesaPixmap p,
  310. XMesaColormap cmap,
  311. int format, int target, int mipmap);
  312. #ifdef __cplusplus
  313. }
  314. #endif
  315. #endif