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

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