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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. /*
  2. * Mesa 3-D graphics library
  3. * Version: 4.1
  4. *
  5. * Copyright (C) 1999-2002 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 4
  67. #define XMESA_MINOR_VERSION 1
  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. /*
  139. * Create an XMesaBuffer from an X window.
  140. */
  141. extern XMesaBuffer XMesaCreateWindowBuffer( XMesaVisual v, XMesaWindow w );
  142. /*
  143. * Create an XMesaBuffer from an X pixmap.
  144. */
  145. extern XMesaBuffer XMesaCreatePixmapBuffer( XMesaVisual v,
  146. XMesaPixmap p,
  147. XMesaColormap cmap );
  148. /*
  149. * Destroy an XMesaBuffer, but not the corresponding window or pixmap.
  150. */
  151. extern void XMesaDestroyBuffer( XMesaBuffer b );
  152. /*
  153. * Return the XMesaBuffer handle which corresponds to an X drawable, if any.
  154. *
  155. * New in Mesa 2.3.
  156. */
  157. extern XMesaBuffer XMesaFindBuffer( XMesaDisplay *dpy,
  158. XMesaDrawable d );
  159. /*
  160. * Bind a buffer to a context and make the context the current one.
  161. */
  162. extern GLboolean XMesaMakeCurrent( XMesaContext c,
  163. XMesaBuffer b );
  164. /*
  165. * Bind two buffers (read and draw) to a context and make the
  166. * context the current one.
  167. * New in Mesa 3.3
  168. */
  169. extern GLboolean XMesaMakeCurrent2( XMesaContext c,
  170. XMesaBuffer drawBuffer,
  171. XMesaBuffer readBuffer );
  172. /*
  173. * Unbind the current context from its buffer.
  174. */
  175. extern GLboolean XMesaUnbindContext( XMesaContext c );
  176. /*
  177. * Return a handle to the current context.
  178. */
  179. extern XMesaContext XMesaGetCurrentContext( void );
  180. /*
  181. * Return handle to the current (draw) buffer.
  182. */
  183. extern XMesaBuffer XMesaGetCurrentBuffer( void );
  184. /*
  185. * Return handle to the current read buffer.
  186. * New in Mesa 3.3
  187. */
  188. extern XMesaBuffer XMesaGetCurrentReadBuffer( void );
  189. /*
  190. * Swap the front and back buffers for the given buffer. No action is
  191. * taken if the buffer is not double buffered.
  192. */
  193. extern void XMesaSwapBuffers( XMesaBuffer b );
  194. /*
  195. * Copy a sub-region of the back buffer to the front buffer.
  196. *
  197. * New in Mesa 2.6
  198. */
  199. extern void XMesaCopySubBuffer( XMesaBuffer b,
  200. int x,
  201. int y,
  202. int width,
  203. int height );
  204. /*
  205. * Return a pointer to the the Pixmap or XImage being used as the back
  206. * color buffer of an XMesaBuffer. This function is a way to get "under
  207. * the hood" of X/Mesa so one can manipulate the back buffer directly.
  208. * Input: b - the XMesaBuffer
  209. * Output: pixmap - pointer to back buffer's Pixmap, or 0
  210. * ximage - pointer to back buffer's XImage, or NULL
  211. * Return: GL_TRUE = context is double buffered
  212. * GL_FALSE = context is single buffered
  213. */
  214. extern GLboolean XMesaGetBackBuffer( XMesaBuffer b,
  215. XMesaPixmap *pixmap,
  216. XMesaImage **ximage );
  217. /*
  218. * Return the depth buffer associated with an XMesaBuffer.
  219. * Input: b - the XMesa buffer handle
  220. * Output: width, height - size of buffer in pixels
  221. * bytesPerValue - bytes per depth value (2 or 4)
  222. * buffer - pointer to depth buffer values
  223. * Return: GL_TRUE or GL_FALSE to indicate success or failure.
  224. *
  225. * New in Mesa 2.4.
  226. */
  227. extern GLboolean XMesaGetDepthBuffer( XMesaBuffer b,
  228. GLint *width,
  229. GLint *height,
  230. GLint *bytesPerValue,
  231. void **buffer );
  232. /*
  233. * Flush/sync a context
  234. */
  235. extern void XMesaFlush( XMesaContext c );
  236. /*
  237. * Get an X/Mesa-specific string.
  238. * Input: name - either XMESA_VERSION or XMESA_EXTENSIONS
  239. */
  240. extern const char *XMesaGetString( XMesaContext c, int name );
  241. /*
  242. * Scan for XMesaBuffers whose window/pixmap has been destroyed, then free
  243. * any memory used by that buffer.
  244. *
  245. * New in Mesa 2.3.
  246. */
  247. extern void XMesaGarbageCollect( void );
  248. /*
  249. * Return a dithered pixel value.
  250. * Input: c - XMesaContext
  251. * x, y - window coordinate
  252. * red, green, blue, alpha - color components in [0,1]
  253. * Return: pixel value
  254. *
  255. * New in Mesa 2.3.
  256. */
  257. extern unsigned long XMesaDitherColor( XMesaContext xmesa,
  258. GLint x,
  259. GLint y,
  260. GLfloat red,
  261. GLfloat green,
  262. GLfloat blue,
  263. GLfloat alpha );
  264. /*
  265. * 3Dfx Glide driver only!
  266. * Set 3Dfx/Glide full-screen or window rendering mode.
  267. * Input: mode - either XMESA_FX_WINDOW (window rendering mode) or
  268. * XMESA_FX_FULLSCREEN (full-screen rendering mode)
  269. * Return: GL_TRUE if success
  270. * GL_FALSE if invalid mode or if not using 3Dfx driver
  271. *
  272. * New in Mesa 2.6.
  273. */
  274. extern GLboolean XMesaSetFXmode( GLint mode );
  275. /*
  276. * Reallocate the back/depth/stencil/accum/etc/ buffers associated with
  277. * buffer <b> if its size has changed.
  278. *
  279. * New in Mesa 4.0.2
  280. */
  281. extern void XMesaResizeBuffers( XMesaBuffer b );
  282. /*
  283. * Create a pbuffer.
  284. * New in Mesa 4.1
  285. */
  286. extern XMesaBuffer XMesaCreatePBuffer(XMesaVisual v, XMesaColormap cmap,
  287. unsigned int width, unsigned int height);
  288. #ifdef __cplusplus
  289. }
  290. #endif
  291. #endif