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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. /* $Id: xmesa.h,v 1.3 1999/11/24 18:45:44 brianp Exp $ */
  2. /*
  3. * Mesa 3-D graphics library
  4. * Version: 3.3
  5. *
  6. * Copyright (C) 1999 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. See the demos/xdemo.c and xmesa1.c files for examples.
  47. */
  48. #ifndef XMESA_H
  49. #define XMESA_H
  50. #ifdef __cplusplus
  51. extern "C" {
  52. #endif
  53. #ifdef XFree86Server
  54. #include "xmesa_xf86.h"
  55. #else
  56. #include <X11/Xlib.h>
  57. #include <X11/Xutil.h>
  58. #include "xmesa_x.h"
  59. #endif
  60. #include "GL/gl.h"
  61. #ifdef AMIWIN
  62. #include <pragmas/xlib_pragmas.h>
  63. extern struct Library *XLibBase;
  64. #endif
  65. #define XMESA_MAJOR_VERSION 3
  66. #define XMESA_MINOR_VERSION 3
  67. /*
  68. * Values passed to XMesaGetString:
  69. */
  70. #define XMESA_VERSION 1
  71. #define XMESA_EXTENSIONS 2
  72. /*
  73. * Values passed to XMesaSetFXmode:
  74. */
  75. #define XMESA_FX_WINDOW 1
  76. #define XMESA_FX_FULLSCREEN 2
  77. typedef struct xmesa_context *XMesaContext;
  78. typedef struct xmesa_visual *XMesaVisual;
  79. typedef struct xmesa_buffer *XMesaBuffer;
  80. /*
  81. * Create a new X/Mesa visual.
  82. * Input: display - X11 display
  83. * visinfo - an XVisualInfo pointer
  84. * rgb_flag - GL_TRUE = RGB mode,
  85. * GL_FALSE = color index mode
  86. * alpha_flag - alpha buffer requested?
  87. * db_flag - GL_TRUE = double-buffered,
  88. * GL_FALSE = single buffered
  89. * stereo_flag - stereo visual?
  90. * depth_size - requested bits/depth values, or zero
  91. * stencil_size - requested bits/stencil values, or zero
  92. * accum_size - requested bits/component values, or zero
  93. * ximage_flag - GL_TRUE = use an XImage for back buffer,
  94. * GL_FALSE = use an off-screen pixmap for back buffer
  95. * Return; a new XMesaVisual or 0 if error.
  96. */
  97. extern XMesaVisual XMesaCreateVisual( XMesaDisplay *display,
  98. XMesaVisualInfo visinfo,
  99. GLboolean rgb_flag,
  100. GLboolean alpha_flag,
  101. GLboolean db_flag,
  102. GLboolean stereo_flag,
  103. GLboolean ximage_flag,
  104. GLint depth_size,
  105. GLint stencil_size,
  106. GLint accum_size,
  107. GLint level );
  108. /*
  109. * Destroy an XMesaVisual, but not the associated XVisualInfo.
  110. */
  111. extern void XMesaDestroyVisual( XMesaVisual v );
  112. /*
  113. * Create a new XMesaContext for rendering into an X11 window.
  114. *
  115. * Input: visual - an XMesaVisual
  116. * share_list - another XMesaContext with which to share display
  117. * lists or NULL if no sharing is wanted.
  118. * Return: an XMesaContext or NULL if error.
  119. */
  120. extern XMesaContext XMesaCreateContext( XMesaVisual v,
  121. XMesaContext share_list );
  122. /*
  123. * Destroy a rendering context as returned by XMesaCreateContext()
  124. */
  125. extern void XMesaDestroyContext( XMesaContext c );
  126. /*
  127. * Create an XMesaBuffer from an X window.
  128. */
  129. extern XMesaBuffer XMesaCreateWindowBuffer( XMesaVisual v,
  130. XMesaWindow w );
  131. /*
  132. * Create an XMesaBuffer from an X pixmap.
  133. */
  134. extern XMesaBuffer XMesaCreatePixmapBuffer( XMesaVisual v,
  135. XMesaPixmap p,
  136. XMesaColormap cmap );
  137. /*
  138. * Destroy an XMesaBuffer, but not the corresponding window or pixmap.
  139. */
  140. extern void XMesaDestroyBuffer( XMesaBuffer b );
  141. /*
  142. * Return the XMesaBuffer handle which corresponds to an X drawable, if any.
  143. *
  144. * New in Mesa 2.3.
  145. */
  146. extern XMesaBuffer XMesaFindBuffer( XMesaDisplay *dpy,
  147. XMesaDrawable d );
  148. /*
  149. * Bind a buffer to a context and make the context the current one.
  150. */
  151. extern GLboolean XMesaMakeCurrent( XMesaContext c,
  152. XMesaBuffer b );
  153. /*
  154. * Bind two buffers (read and draw) to a context and make the
  155. * context the current one.
  156. * New in Mesa 3.3
  157. */
  158. extern GLboolean XMesaMakeCurrent2( XMesaContext c,
  159. XMesaBuffer drawBuffer,
  160. XMesaBuffer readBuffer );
  161. /*
  162. * Return a handle to the current context.
  163. */
  164. extern XMesaContext XMesaGetCurrentContext( void );
  165. /*
  166. * Return handle to the current (draw) buffer.
  167. */
  168. extern XMesaBuffer XMesaGetCurrentBuffer( void );
  169. /*
  170. * Return handle to the current read buffer.
  171. * New in Mesa 3.3
  172. */
  173. extern XMesaBuffer XMesaGetCurrentReadBuffer( void );
  174. /*
  175. * Swap the front and back buffers for the given buffer. No action is
  176. * taken if the buffer is not double buffered.
  177. */
  178. extern void XMesaSwapBuffers( XMesaBuffer b );
  179. /*
  180. * Copy a sub-region of the back buffer to the front buffer.
  181. *
  182. * New in Mesa 2.6
  183. */
  184. extern void XMesaCopySubBuffer( XMesaBuffer b,
  185. int x,
  186. int y,
  187. int width,
  188. int height );
  189. /*
  190. * Return a pointer to the the Pixmap or XImage being used as the back
  191. * color buffer of an XMesaBuffer. This function is a way to get "under
  192. * the hood" of X/Mesa so one can manipulate the back buffer directly.
  193. * Input: b - the XMesaBuffer
  194. * Output: pixmap - pointer to back buffer's Pixmap, or 0
  195. * ximage - pointer to back buffer's XImage, or NULL
  196. * Return: GL_TRUE = context is double buffered
  197. * GL_FALSE = context is single buffered
  198. */
  199. extern GLboolean XMesaGetBackBuffer( XMesaBuffer b,
  200. XMesaPixmap *pixmap,
  201. XMesaImage **ximage );
  202. /*
  203. * Return the depth buffer associated with an XMesaBuffer.
  204. * Input: b - the XMesa buffer handle
  205. * Output: width, height - size of buffer in pixels
  206. * bytesPerValue - bytes per depth value (2 or 4)
  207. * buffer - pointer to depth buffer values
  208. * Return: GL_TRUE or GL_FALSE to indicate success or failure.
  209. *
  210. * New in Mesa 2.4.
  211. */
  212. extern GLboolean XMesaGetDepthBuffer( XMesaBuffer b,
  213. GLint *width,
  214. GLint *height,
  215. GLint *bytesPerValue,
  216. void **buffer );
  217. /*
  218. * Flush/sync a context
  219. */
  220. extern void XMesaFlush( XMesaContext c );
  221. /*
  222. * Get an X/Mesa-specific string.
  223. * Input: name - either XMESA_VERSION or XMESA_EXTENSIONS
  224. */
  225. extern const char *XMesaGetString( XMesaContext c, int name );
  226. /*
  227. * Scan for XMesaBuffers whose window/pixmap has been destroyed, then free
  228. * any memory used by that buffer.
  229. *
  230. * New in Mesa 2.3.
  231. */
  232. extern void XMesaGarbageCollect( void );
  233. /*
  234. * Return a dithered pixel value.
  235. * Input: c - XMesaContext
  236. * x, y - window coordinate
  237. * red, green, blue, alpha - color components in [0,1]
  238. * Return: pixel value
  239. *
  240. * New in Mesa 2.3.
  241. */
  242. extern unsigned long XMesaDitherColor( XMesaContext xmesa,
  243. GLint x,
  244. GLint y,
  245. GLfloat red,
  246. GLfloat green,
  247. GLfloat blue,
  248. GLfloat alpha );
  249. /*
  250. * 3Dfx Glide driver only!
  251. * Set 3Dfx/Glide full-screen or window rendering mode.
  252. * Input: mode - either XMESA_FX_WINDOW (window rendering mode) or
  253. * XMESA_FX_FULLSCREEN (full-screen rendering mode)
  254. * Return: GL_TRUE if success
  255. * GL_FALSE if invalid mode or if not using 3Dfx driver
  256. *
  257. * New in Mesa 2.6.
  258. */
  259. extern GLboolean XMesaSetFXmode( GLint mode );
  260. #ifdef __cplusplus
  261. }
  262. #endif
  263. #endif