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.

miniglx.h 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. /*
  2. * Mesa 3-D graphics library
  3. * Version: 6.1
  4. *
  5. * Copyright (C) 1999-2004 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. * \file miniglx.h
  26. * \brief Mini GLX interface functions.
  27. * \author Brian Paul
  28. *
  29. * See comments miniglx.c for more information.
  30. */
  31. #ifndef MINIGLX_H
  32. #define MINIGLX_H
  33. #include <GL/gl.h>
  34. #include <stdlib.h>
  35. #ifdef __cplusplus
  36. extern "C" {
  37. #endif
  38. /**
  39. * \name Replacement Xlib/GLX types
  40. */
  41. /*@{*/
  42. /**
  43. * \brief Boolean type.
  44. *
  45. * It can have the values #True or #False.
  46. */
  47. typedef int Bool;
  48. /**
  49. * \brief Color map.
  50. *
  51. * Alias for private ::MiniGLXColormapRec structure.
  52. */
  53. typedef struct MiniGLXColormapRec *Colormap;
  54. /**
  55. * \brief Window attributes.
  56. */
  57. typedef struct MiniGLXSetWindowAttributesRec {
  58. int background_pixel; /**< \brief background pixel */
  59. int border_pixel; /**< \brief border pixel value */
  60. Colormap colormap; /**< \brief color map to be associated with window */
  61. int event_mask; /**< \brief set of events that should be saved */
  62. } XSetWindowAttributes;
  63. /**
  64. * \brief Visual.
  65. *
  66. * Alias for the private ::MiniGLXVisualRec structure.
  67. *
  68. * \sa \ref datatypes.
  69. */
  70. typedef struct MiniGLXVisualRec Visual;
  71. /**
  72. * \brief Visual information.
  73. *
  74. * \sa \ref datatypes.
  75. */
  76. typedef unsigned int VisualID;
  77. typedef struct MiniGLXXVisualInfoRec {
  78. Visual *visual; /**< \brief pointer to the GLX Visual */
  79. VisualID visualid; /**< \brief visual ID */
  80. int screen; /**< \brief screen number */
  81. int depth; /**< \brief bit depth */
  82. #if defined(__cplusplus) || defined(c_plusplus)
  83. int c_class; /**< \brief class */
  84. #else
  85. int class; /**< \brief class */
  86. #endif
  87. int bits_per_rgb; /**< \brief total bits per pixel */
  88. } XVisualInfo;
  89. /**
  90. * \brief GLX Frame Buffer Configuration (for pbuffers)
  91. * \sa \ref datatypes.
  92. */
  93. typedef struct MiniGLXFBConfigRec {
  94. XVisualInfo *visInfo;
  95. } GLXFBConfig;
  96. /**
  97. * \brief Display handle.
  98. *
  99. * Alias for the private ::MiniGLXDisplayRec structure.
  100. *
  101. * \sa \ref datatypes.
  102. */
  103. typedef struct MiniGLXDisplayRec Display;
  104. /**
  105. * \brief Window handle.
  106. *
  107. * Alias for the private ::MiniGLXWindowRec structure.
  108. *
  109. * \sa \ref datatypes.
  110. */
  111. typedef struct MiniGLXWindowRec *Window;
  112. /**
  113. * \brief Drawable.
  114. *
  115. * Alias for the private ::MiniGLXWindowRec structure.
  116. *
  117. * For Mini GLX only the full-screen window can be used as source and
  118. * destination in graphics operations.
  119. *
  120. * \sa \ref datatypes.
  121. */
  122. typedef struct MiniGLXWindowRec *Drawable;
  123. /**
  124. * \brief GLX drawable.
  125. *
  126. * Alias for the private ::MiniGLXWindowRec structure.
  127. *
  128. * Same as #Drawable.
  129. *
  130. * \sa \ref datatypes.
  131. */
  132. typedef struct MiniGLXWindowRec *GLXDrawable;
  133. /**
  134. * \brief GLX pbuffer.
  135. *
  136. * Alias for the private ::MiniGLXWindowRec structure.
  137. *
  138. * Same as #Drawable.
  139. *
  140. * \sa \ref datatypes.
  141. */
  142. typedef struct MiniGLXWindowRec *GLXPbuffer;
  143. /**
  144. * \brief GLX context.
  145. *
  146. * Alias for the private ::MiniGLXContext structure.
  147. *
  148. * \sa \ref datatypes.
  149. */
  150. typedef struct MiniGLXContextRec *GLXContext;
  151. /*@}*/
  152. typedef struct {
  153. int type;
  154. unsigned long serial; /* # of last request processed by server */
  155. Bool send_event; /* true if this came from a SendEvent request */
  156. Display *display; /* Display the event was read from */
  157. Window window;
  158. int x, y;
  159. int width, height;
  160. int count; /* if non-zero, at least this many more */
  161. } XExposeEvent;
  162. typedef struct {
  163. int type;
  164. unsigned long serial; /* # of last request processed by server */
  165. Bool send_event; /* true if this came from a SendEvent request */
  166. Display *display; /* Display the event was read from */
  167. Window parent; /* parent of the window */
  168. Window window; /* window id of window created */
  169. int x, y; /* window location */
  170. int width, height; /* size of window */
  171. int border_width; /* border width */
  172. Bool override_redirect; /* creation should be overridden */
  173. } XCreateWindowEvent;
  174. typedef struct {
  175. int type;
  176. unsigned long serial; /* # of last request processed by server */
  177. Bool send_event; /* true if this came from a SendEvent request */
  178. Display *display; /* Display the event was read from */
  179. Window event;
  180. Window window;
  181. } XDestroyWindowEvent;
  182. typedef struct {
  183. int type;
  184. unsigned long serial; /* # of last request processed by server */
  185. Bool send_event; /* true if this came from a SendEvent request */
  186. Display *display; /* Display the event was read from */
  187. Window event;
  188. Window window;
  189. Bool from_configure;
  190. } XUnmapEvent;
  191. typedef struct {
  192. int type;
  193. unsigned long serial; /* # of last request processed by server */
  194. Bool send_event; /* true if this came from a SendEvent request */
  195. Display *display; /* Display the event was read from */
  196. Window event;
  197. Window window;
  198. Bool override_redirect; /* boolean, is override set... */
  199. } XMapEvent;
  200. typedef struct {
  201. int type;
  202. unsigned long serial; /* # of last request processed by server */
  203. Bool send_event; /* true if this came from a SendEvent request */
  204. Display *display; /* Display the event was read from */
  205. Window parent;
  206. Window window;
  207. } XMapRequestEvent;
  208. typedef union _XEvent {
  209. int type; /* must not be changed; first element */
  210. XExposeEvent xexpose;
  211. XCreateWindowEvent xcreatewindow;
  212. XDestroyWindowEvent xdestroywindow;
  213. XUnmapEvent xunmap;
  214. XMapEvent xmap;
  215. XMapRequestEvent xmaprequest;
  216. long pad[24];
  217. } XEvent;
  218. /**
  219. * \name Xlib constants
  220. */
  221. /*@{*/
  222. #define False 0
  223. #define True 1
  224. #define None 0
  225. #define AllocNone 0
  226. #define InputOutput 1
  227. #define ExposureMask (1L<<15)
  228. #define StructureNotifyMask (1L<<17)
  229. #define CWBackPixel (1L<<1)
  230. #define CWBorderPixel (1L<<3)
  231. #define CWEventMask (1L<<11)
  232. #define CWColormap (1L<<13)
  233. #define PseudoColor 3
  234. #define TrueColor 4
  235. #define VisualScreenMask 0x2
  236. #define Expose 12
  237. #define CreateNotify 16
  238. #define DestroyNotify 17
  239. #define UnmapNotify 18
  240. #define MapNotify 19
  241. #define MapRequest 20
  242. /*@}*/
  243. /**
  244. * \name Standard GLX tokens
  245. */
  246. /*@{*/
  247. #define GLX_USE_GL 1
  248. #define GLX_BUFFER_SIZE 2
  249. #define GLX_LEVEL 3
  250. #define GLX_RGBA 4
  251. #define GLX_DOUBLEBUFFER 5
  252. #define GLX_STEREO 6
  253. #define GLX_AUX_BUFFERS 7
  254. #define GLX_RED_SIZE 8
  255. #define GLX_GREEN_SIZE 9
  256. #define GLX_BLUE_SIZE 10
  257. #define GLX_ALPHA_SIZE 11
  258. #define GLX_DEPTH_SIZE 12
  259. #define GLX_STENCIL_SIZE 13
  260. #define GLX_ACCUM_RED_SIZE 14
  261. #define GLX_ACCUM_GREEN_SIZE 15
  262. #define GLX_ACCUM_BLUE_SIZE 16
  263. #define GLX_ACCUM_ALPHA_SIZE 17
  264. #define GLX_BAD_ATTRIBUTE 1
  265. #define GLX_BAD_VISUAL 4
  266. /*@}*/
  267. /**
  268. * \name Unique to Mini GLX
  269. *
  270. * At compile time, the Mini GLX interface version can be tested with the
  271. * MINI_GLX_VERSION_1_x preprocessor tokens.
  272. *
  273. * \sa glXQueryVersion()
  274. */
  275. /*@{*/
  276. /** \brief Defined if version 1.0 of Mini GLX is supported. */
  277. #define MINI_GLX_VERSION_1_0 1
  278. /** \brief Defined if version 1.1 of Mini GLX is supported. */
  279. #define MINI_GLX_VERSION_1_1 1
  280. /*@}*/
  281. /**
  282. * \name Server-specific functions
  283. */
  284. extern Display *
  285. __miniglx_StartServer( const char *display_name );
  286. extern int
  287. __miniglx_Select( Display *dpy, int maxfd,
  288. fd_set *rfds, fd_set *wfds, fd_set *xfds,
  289. struct timeval *tv );
  290. /**
  291. * \name Simulated Xlib functions
  292. */
  293. /*@{*/
  294. extern Display *
  295. XOpenDisplay( const char *dpy_name );
  296. extern void
  297. XCloseDisplay( Display *display );
  298. extern Window
  299. XCreateWindow( Display *display, Window parent, int x, int y,
  300. unsigned int width, unsigned int height,
  301. unsigned int border_width, int depth, unsigned int winclass,
  302. Visual *visual, unsigned long valuemask,
  303. XSetWindowAttributes *attributes );
  304. extern int
  305. XNextEvent(Display *display, XEvent *event_return);
  306. extern Bool
  307. XCheckMaskEvent( Display *dpy, long event_mask, XEvent *event_return );
  308. /**
  309. * \brief Return the root window.
  310. *
  311. * \param display the display handle. It is ignored by Mini GLX, but should be
  312. * the value returned by XOpenDisplay().
  313. * \param screen the screen number on the host server. It is ignored by Mini
  314. * GLX but should be zero.
  315. *
  316. * \return the root window. Always zero on Mini GLX.
  317. */
  318. #define RootWindow(display, screen) 0
  319. #define DefaultScreen(dpy) 0
  320. extern void
  321. XDestroyWindow( Display *display, Window w );
  322. extern void
  323. XMapWindow( Display *display, Window w );
  324. /* Should clients have access to this?
  325. */
  326. extern void
  327. XUnmapWindow( Display *display, Window w );
  328. extern Colormap
  329. XCreateColormap( Display *display, Window w, Visual *visual, int alloc );
  330. extern void
  331. XFreeColormap( Display *display, Colormap cmap );
  332. extern void
  333. XFree( void *data );
  334. extern XVisualInfo *
  335. XGetVisualInfo( Display *display, long vinfo_mask,
  336. XVisualInfo *vinfo_template, int *nitems_return );
  337. /*@}*/
  338. /**
  339. * \name GLX functions
  340. */
  341. /*@{*/
  342. extern XVisualInfo*
  343. glXChooseVisual( Display *dpy, int screen, int *attribList );
  344. extern int
  345. glXGetConfig( Display *dpy, XVisualInfo *vis, int attrib, int *value );
  346. extern GLXContext
  347. glXCreateContext( Display *dpy, XVisualInfo *vis,
  348. GLXContext shareList, Bool direct );
  349. extern void
  350. glXDestroyContext( Display *dpy, GLXContext ctx );
  351. extern Bool
  352. glXMakeCurrent( Display *dpy, GLXDrawable drawable, GLXContext ctx);
  353. extern void
  354. glXSwapBuffers( Display *dpy, GLXDrawable drawable );
  355. extern GLXContext
  356. glXGetCurrentContext( void );
  357. extern GLXDrawable
  358. glXGetCurrentDrawable( void );
  359. extern const void *
  360. glXGetProcAddress( const GLubyte *procname );
  361. extern Bool
  362. glXQueryVersion( Display *dpy, int *major, int *minor );
  363. /* Added in MiniGLX 1.1 */
  364. extern GLXPbuffer
  365. glXCreatePbuffer( Display *dpy, GLXFBConfig config, const int *attribList );
  366. extern void
  367. glXDestroyPbuffer( Display *dpy, GLXPbuffer pbuf );
  368. extern GLXFBConfig *
  369. glXChooseFBConfig( Display *dpy, int screen, const int *attribList,
  370. int *nitems );
  371. extern XVisualInfo *
  372. glXGetVisualFromFBConfig( Display *dpy, GLXFBConfig config );
  373. /*@}*/
  374. #ifdef __cplusplus
  375. }
  376. #endif
  377. #endif /* MINIGLX_H */