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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. /* $Id: miniglx.h,v 1.1 2003/08/23 01:25:30 jonsmirl 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 Display handle.
  85. *
  86. * Alias for the private ::MiniGLXDisplayRec structure.
  87. *
  88. * \sa \ref datatypes.
  89. */
  90. typedef struct MiniGLXDisplayRec Display;
  91. /**
  92. * \brief Window handle.
  93. *
  94. * Alias for the private ::MiniGLXWindowRec structure.
  95. *
  96. * \sa \ref datatypes.
  97. */
  98. typedef struct MiniGLXWindowRec *Window;
  99. /**
  100. * \brief Drawable.
  101. *
  102. * Alias for the private ::MiniGLXWindowRec structure.
  103. *
  104. * For Mini GLX only the full-screen window can be used as source and
  105. * destination in graphics operations.
  106. *
  107. * \sa \ref datatypes.
  108. */
  109. typedef struct MiniGLXWindowRec *Drawable;
  110. /**
  111. * \brief GLX drawable.
  112. *
  113. * Alias for the private ::MiniGLXWindowRec structure.
  114. *
  115. * Same as #Drawable.
  116. *
  117. * \sa \ref datatypes.
  118. */
  119. typedef struct MiniGLXWindowRec *GLXDrawable;
  120. /**
  121. * \brief GLX context.
  122. *
  123. * Alias for the private ::MiniGLXContext structure.
  124. *
  125. * \sa \ref datatypes.
  126. */
  127. typedef struct MiniGLXContextRec *GLXContext;
  128. /*@}*/
  129. typedef struct {
  130. int type;
  131. unsigned long serial; /* # of last request processed by server */
  132. Bool send_event; /* true if this came from a SendEvent request */
  133. Display *display; /* Display the event was read from */
  134. Window window;
  135. int x, y;
  136. int width, height;
  137. int count; /* if non-zero, at least this many more */
  138. } XExposeEvent;
  139. typedef struct {
  140. int type;
  141. unsigned long serial; /* # of last request processed by server */
  142. Bool send_event; /* true if this came from a SendEvent request */
  143. Display *display; /* Display the event was read from */
  144. Window parent; /* parent of the window */
  145. Window window; /* window id of window created */
  146. int x, y; /* window location */
  147. int width, height; /* size of window */
  148. int border_width; /* border width */
  149. Bool override_redirect; /* creation should be overridden */
  150. } XCreateWindowEvent;
  151. typedef struct {
  152. int type;
  153. unsigned long serial; /* # of last request processed by server */
  154. Bool send_event; /* true if this came from a SendEvent request */
  155. Display *display; /* Display the event was read from */
  156. Window event;
  157. Window window;
  158. } XDestroyWindowEvent;
  159. typedef struct {
  160. int type;
  161. unsigned long serial; /* # of last request processed by server */
  162. Bool send_event; /* true if this came from a SendEvent request */
  163. Display *display; /* Display the event was read from */
  164. Window event;
  165. Window window;
  166. Bool from_configure;
  167. } XUnmapEvent;
  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. Bool override_redirect; /* boolean, is override set... */
  176. } XMapEvent;
  177. typedef struct {
  178. int type;
  179. unsigned long serial; /* # of last request processed by server */
  180. Bool send_event; /* true if this came from a SendEvent request */
  181. Display *display; /* Display the event was read from */
  182. Window parent;
  183. Window window;
  184. } XMapRequestEvent;
  185. typedef union _XEvent {
  186. int type; /* must not be changed; first element */
  187. XExposeEvent xexpose;
  188. XCreateWindowEvent xcreatewindow;
  189. XDestroyWindowEvent xdestroywindow;
  190. XUnmapEvent xunmap;
  191. XMapEvent xmap;
  192. XMapRequestEvent xmaprequest;
  193. long pad[24];
  194. } XEvent;
  195. /**
  196. * \name Xlib constants
  197. */
  198. /*@{*/
  199. #define False 0
  200. #define True 1
  201. #define None 0
  202. #define AllocNone 0
  203. #define InputOutput 1
  204. #define ExposureMask (1L<<15)
  205. #define StructureNotifyMask (1L<<17)
  206. #define CWBackPixel (1L<<1)
  207. #define CWBorderPixel (1L<<3)
  208. #define CWEventMask (1L<<11)
  209. #define CWColormap (1L<<13)
  210. #define PseudoColor 3
  211. #define TrueColor 4
  212. #define VisualScreenMask 0x2
  213. #define Expose 12
  214. #define CreateNotify 16
  215. #define DestroyNotify 17
  216. #define UnmapNotify 18
  217. #define MapNotify 19
  218. #define MapRequest 20
  219. /*@}*/
  220. /**
  221. * \name Standard GLX tokens
  222. */
  223. /*@{*/
  224. #define GLX_USE_GL 1
  225. #define GLX_BUFFER_SIZE 2
  226. #define GLX_LEVEL 3
  227. #define GLX_RGBA 4
  228. #define GLX_DOUBLEBUFFER 5
  229. #define GLX_STEREO 6
  230. #define GLX_AUX_BUFFERS 7
  231. #define GLX_RED_SIZE 8
  232. #define GLX_GREEN_SIZE 9
  233. #define GLX_BLUE_SIZE 10
  234. #define GLX_ALPHA_SIZE 11
  235. #define GLX_DEPTH_SIZE 12
  236. #define GLX_STENCIL_SIZE 13
  237. #define GLX_ACCUM_RED_SIZE 14
  238. #define GLX_ACCUM_GREEN_SIZE 15
  239. #define GLX_ACCUM_BLUE_SIZE 16
  240. #define GLX_ACCUM_ALPHA_SIZE 17
  241. #define GLX_BAD_ATTRIBUTE 1
  242. #define GLX_BAD_VISUAL 4
  243. /*@}*/
  244. /**
  245. * \name Unique to Mini GLX
  246. *
  247. * At compile time, the Mini GLX interface version can be tested with the
  248. * MINI_GLX_VERSION_1_x preprocessor tokens.
  249. *
  250. * \sa glXQueryVersion()
  251. */
  252. /*@{*/
  253. /** \brief Defined if version 1.0 of Mini GLX is supported. */
  254. #define MINI_GLX_VERSION_1_0 1
  255. /*@}*/
  256. /**
  257. * \name Server-specific functions
  258. */
  259. extern Display *
  260. __miniglx_StartServer( const char *display_name );
  261. extern int
  262. __miniglx_Select( Display *dpy, int maxfd,
  263. fd_set *rfds, fd_set *wfds, fd_set *xfds,
  264. struct timeval *tv );
  265. /**
  266. * \name Simulated Xlib functions
  267. */
  268. /*@{*/
  269. extern Display *
  270. XOpenDisplay( const char *dpy_name );
  271. extern void
  272. XCloseDisplay( Display *display );
  273. extern Window
  274. XCreateWindow( Display *display, Window parent, int x, int y,
  275. unsigned int width, unsigned int height,
  276. unsigned int border_width, int depth, unsigned int class,
  277. Visual *visual, unsigned long valuemask,
  278. XSetWindowAttributes *attributes );
  279. extern int
  280. XNextEvent(Display *display, XEvent *event_return);
  281. extern Bool
  282. XCheckMaskEvent( Display *dpy, long event_mask, XEvent *event_return );
  283. /**
  284. * \brief Return the root window.
  285. *
  286. * \param display the display handle. It is ignored by Mini GLX, but should be
  287. * the value returned by XOpenDisplay().
  288. * \param screen the screen number on the host server. It is ignored by Mini
  289. * GLX but should be zero.
  290. *
  291. * \return the root window. Always zero on Mini GLX.
  292. */
  293. #define RootWindow(display, screen) 0
  294. #define DefaultScreen(dpy) 0
  295. extern void
  296. XDestroyWindow( Display *display, Window w );
  297. extern void
  298. XMapWindow( Display *display, Window w );
  299. /* Should clients have access to this?
  300. */
  301. extern void
  302. XUnmapWindow( Display *display, Window w );
  303. extern Colormap
  304. XCreateColormap( Display *display, Window w, Visual *visual, int alloc );
  305. extern void
  306. XFreeColormap( Display *display, Colormap cmap );
  307. extern void
  308. XFree( void *data );
  309. extern XVisualInfo *
  310. XGetVisualInfo( Display *display, long vinfo_mask, XVisualInfo *vinfo_template, int *nitems_return );
  311. /*@}*/
  312. /**
  313. * \name GLX functions
  314. */
  315. /*@{*/
  316. extern XVisualInfo*
  317. glXChooseVisual( Display *dpy, int screen, int *attribList );
  318. extern int
  319. glXGetConfig( Display *dpy, XVisualInfo *vis, int attrib, int *value );
  320. extern GLXContext
  321. glXCreateContext( Display *dpy, XVisualInfo *vis,
  322. GLXContext shareList, Bool direct );
  323. extern void
  324. glXDestroyContext( Display *dpy, GLXContext ctx );
  325. extern Bool
  326. glXMakeCurrent( Display *dpy, GLXDrawable drawable, GLXContext ctx);
  327. extern void
  328. glXSwapBuffers( Display *dpy, GLXDrawable drawable );
  329. extern GLXContext
  330. glXGetCurrentContext( void );
  331. extern GLXDrawable
  332. glXGetCurrentDrawable( void );
  333. extern const void *
  334. glXGetProcAddress( const GLubyte *procname );
  335. extern Bool
  336. glXQueryVersion( Display *dpy, int *major, int *minor );
  337. /*@}*/
  338. #endif /* MINIGLX_H */