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

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