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

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