Clone of mesa.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

miniglx.h 12KB

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