glx.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. /*
  2. * Mesa 3-D graphics library
  3. *
  4. * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a
  7. * copy of this software and associated documentation files (the "Software"),
  8. * to deal in the Software without restriction, including without limitation
  9. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  10. * and/or sell copies of the Software, and to permit persons to whom the
  11. * Software is furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included
  14. * in all copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  17. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  19. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  20. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  21. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  22. * OTHER DEALINGS IN THE SOFTWARE.
  23. */
  24. #ifndef GLX_H
  25. #define GLX_H
  26. #include <X11/Xlib.h>
  27. #include <X11/Xutil.h>
  28. #include <GL/gl.h>
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. #define GLX_VERSION_1_1 1
  33. #define GLX_VERSION_1_2 1
  34. #define GLX_VERSION_1_3 1
  35. #define GLX_VERSION_1_4 1
  36. #define GLX_EXTENSION_NAME "GLX"
  37. /*
  38. * Tokens for glXChooseVisual and glXGetConfig:
  39. */
  40. #define GLX_USE_GL 1
  41. #define GLX_BUFFER_SIZE 2
  42. #define GLX_LEVEL 3
  43. #define GLX_RGBA 4
  44. #define GLX_DOUBLEBUFFER 5
  45. #define GLX_STEREO 6
  46. #define GLX_AUX_BUFFERS 7
  47. #define GLX_RED_SIZE 8
  48. #define GLX_GREEN_SIZE 9
  49. #define GLX_BLUE_SIZE 10
  50. #define GLX_ALPHA_SIZE 11
  51. #define GLX_DEPTH_SIZE 12
  52. #define GLX_STENCIL_SIZE 13
  53. #define GLX_ACCUM_RED_SIZE 14
  54. #define GLX_ACCUM_GREEN_SIZE 15
  55. #define GLX_ACCUM_BLUE_SIZE 16
  56. #define GLX_ACCUM_ALPHA_SIZE 17
  57. /*
  58. * Error codes returned by glXGetConfig:
  59. */
  60. #define GLX_BAD_SCREEN 1
  61. #define GLX_BAD_ATTRIBUTE 2
  62. #define GLX_NO_EXTENSION 3
  63. #define GLX_BAD_VISUAL 4
  64. #define GLX_BAD_CONTEXT 5
  65. #define GLX_BAD_VALUE 6
  66. #define GLX_BAD_ENUM 7
  67. /*
  68. * GLX 1.1 and later:
  69. */
  70. #define GLX_VENDOR 1
  71. #define GLX_VERSION 2
  72. #define GLX_EXTENSIONS 3
  73. /*
  74. * GLX 1.3 and later:
  75. */
  76. #define GLX_CONFIG_CAVEAT 0x20
  77. #define GLX_DONT_CARE 0xFFFFFFFF
  78. #define GLX_X_VISUAL_TYPE 0x22
  79. #define GLX_TRANSPARENT_TYPE 0x23
  80. #define GLX_TRANSPARENT_INDEX_VALUE 0x24
  81. #define GLX_TRANSPARENT_RED_VALUE 0x25
  82. #define GLX_TRANSPARENT_GREEN_VALUE 0x26
  83. #define GLX_TRANSPARENT_BLUE_VALUE 0x27
  84. #define GLX_TRANSPARENT_ALPHA_VALUE 0x28
  85. #define GLX_WINDOW_BIT 0x00000001
  86. #define GLX_PIXMAP_BIT 0x00000002
  87. #define GLX_PBUFFER_BIT 0x00000004
  88. #define GLX_AUX_BUFFERS_BIT 0x00000010
  89. #define GLX_FRONT_LEFT_BUFFER_BIT 0x00000001
  90. #define GLX_FRONT_RIGHT_BUFFER_BIT 0x00000002
  91. #define GLX_BACK_LEFT_BUFFER_BIT 0x00000004
  92. #define GLX_BACK_RIGHT_BUFFER_BIT 0x00000008
  93. #define GLX_DEPTH_BUFFER_BIT 0x00000020
  94. #define GLX_STENCIL_BUFFER_BIT 0x00000040
  95. #define GLX_ACCUM_BUFFER_BIT 0x00000080
  96. #define GLX_NONE 0x8000
  97. #define GLX_SLOW_CONFIG 0x8001
  98. #define GLX_TRUE_COLOR 0x8002
  99. #define GLX_DIRECT_COLOR 0x8003
  100. #define GLX_PSEUDO_COLOR 0x8004
  101. #define GLX_STATIC_COLOR 0x8005
  102. #define GLX_GRAY_SCALE 0x8006
  103. #define GLX_STATIC_GRAY 0x8007
  104. #define GLX_TRANSPARENT_RGB 0x8008
  105. #define GLX_TRANSPARENT_INDEX 0x8009
  106. #define GLX_VISUAL_ID 0x800B
  107. #define GLX_SCREEN 0x800C
  108. #define GLX_NON_CONFORMANT_CONFIG 0x800D
  109. #define GLX_DRAWABLE_TYPE 0x8010
  110. #define GLX_RENDER_TYPE 0x8011
  111. #define GLX_X_RENDERABLE 0x8012
  112. #define GLX_FBCONFIG_ID 0x8013
  113. #define GLX_RGBA_TYPE 0x8014
  114. #define GLX_COLOR_INDEX_TYPE 0x8015
  115. #define GLX_MAX_PBUFFER_WIDTH 0x8016
  116. #define GLX_MAX_PBUFFER_HEIGHT 0x8017
  117. #define GLX_MAX_PBUFFER_PIXELS 0x8018
  118. #define GLX_PRESERVED_CONTENTS 0x801B
  119. #define GLX_LARGEST_PBUFFER 0x801C
  120. #define GLX_WIDTH 0x801D
  121. #define GLX_HEIGHT 0x801E
  122. #define GLX_EVENT_MASK 0x801F
  123. #define GLX_DAMAGED 0x8020
  124. #define GLX_SAVED 0x8021
  125. #define GLX_WINDOW 0x8022
  126. #define GLX_PBUFFER 0x8023
  127. #define GLX_PBUFFER_HEIGHT 0x8040
  128. #define GLX_PBUFFER_WIDTH 0x8041
  129. #define GLX_RGBA_BIT 0x00000001
  130. #define GLX_COLOR_INDEX_BIT 0x00000002
  131. #define GLX_PBUFFER_CLOBBER_MASK 0x08000000
  132. /*
  133. * GLX 1.4 and later:
  134. */
  135. #define GLX_SAMPLE_BUFFERS 0x186a0 /*100000*/
  136. #define GLX_SAMPLES 0x186a1 /*100001*/
  137. typedef struct __GLXcontextRec *GLXContext;
  138. typedef XID GLXPixmap;
  139. typedef XID GLXDrawable;
  140. /* GLX 1.3 and later */
  141. typedef struct __GLXFBConfigRec *GLXFBConfig;
  142. typedef XID GLXFBConfigID;
  143. typedef XID GLXContextID;
  144. typedef XID GLXWindow;
  145. typedef XID GLXPbuffer;
  146. /*
  147. ** Events.
  148. ** __GLX_NUMBER_EVENTS is set to 17 to account for the BufferClobberSGIX
  149. ** event - this helps initialization if the server supports the pbuffer
  150. ** extension and the client doesn't.
  151. */
  152. #define GLX_PbufferClobber 0
  153. #define GLX_BufferSwapComplete 1
  154. #define __GLX_NUMBER_EVENTS 17
  155. extern XVisualInfo* glXChooseVisual( Display *dpy, int screen,
  156. int *attribList );
  157. extern GLXContext glXCreateContext( Display *dpy, XVisualInfo *vis,
  158. GLXContext shareList, Bool direct );
  159. extern void glXDestroyContext( Display *dpy, GLXContext ctx );
  160. extern Bool glXMakeCurrent( Display *dpy, GLXDrawable drawable,
  161. GLXContext ctx);
  162. extern void glXCopyContext( Display *dpy, GLXContext src, GLXContext dst,
  163. unsigned long mask );
  164. extern void glXSwapBuffers( Display *dpy, GLXDrawable drawable );
  165. extern GLXPixmap glXCreateGLXPixmap( Display *dpy, XVisualInfo *visual,
  166. Pixmap pixmap );
  167. extern void glXDestroyGLXPixmap( Display *dpy, GLXPixmap pixmap );
  168. extern Bool glXQueryExtension( Display *dpy, int *errorb, int *event );
  169. extern Bool glXQueryVersion( Display *dpy, int *maj, int *min );
  170. extern Bool glXIsDirect( Display *dpy, GLXContext ctx );
  171. extern int glXGetConfig( Display *dpy, XVisualInfo *visual,
  172. int attrib, int *value );
  173. extern GLXContext glXGetCurrentContext( void );
  174. extern GLXDrawable glXGetCurrentDrawable( void );
  175. extern void glXWaitGL( void );
  176. extern void glXWaitX( void );
  177. extern void glXUseXFont( Font font, int first, int count, int list );
  178. /* GLX 1.1 and later */
  179. extern const char *glXQueryExtensionsString( Display *dpy, int screen );
  180. extern const char *glXQueryServerString( Display *dpy, int screen, int name );
  181. extern const char *glXGetClientString( Display *dpy, int name );
  182. /* GLX 1.2 and later */
  183. extern Display *glXGetCurrentDisplay( void );
  184. /* GLX 1.3 and later */
  185. extern GLXFBConfig *glXChooseFBConfig( Display *dpy, int screen,
  186. const int *attribList, int *nitems );
  187. extern int glXGetFBConfigAttrib( Display *dpy, GLXFBConfig config,
  188. int attribute, int *value );
  189. extern GLXFBConfig *glXGetFBConfigs( Display *dpy, int screen,
  190. int *nelements );
  191. extern XVisualInfo *glXGetVisualFromFBConfig( Display *dpy,
  192. GLXFBConfig config );
  193. extern GLXWindow glXCreateWindow( Display *dpy, GLXFBConfig config,
  194. Window win, const int *attribList );
  195. extern void glXDestroyWindow( Display *dpy, GLXWindow window );
  196. extern GLXPixmap glXCreatePixmap( Display *dpy, GLXFBConfig config,
  197. Pixmap pixmap, const int *attribList );
  198. extern void glXDestroyPixmap( Display *dpy, GLXPixmap pixmap );
  199. extern GLXPbuffer glXCreatePbuffer( Display *dpy, GLXFBConfig config,
  200. const int *attribList );
  201. extern void glXDestroyPbuffer( Display *dpy, GLXPbuffer pbuf );
  202. extern void glXQueryDrawable( Display *dpy, GLXDrawable draw, int attribute,
  203. unsigned int *value );
  204. extern GLXContext glXCreateNewContext( Display *dpy, GLXFBConfig config,
  205. int renderType, GLXContext shareList,
  206. Bool direct );
  207. extern Bool glXMakeContextCurrent( Display *dpy, GLXDrawable draw,
  208. GLXDrawable read, GLXContext ctx );
  209. extern GLXDrawable glXGetCurrentReadDrawable( void );
  210. extern int glXQueryContext( Display *dpy, GLXContext ctx, int attribute,
  211. int *value );
  212. extern void glXSelectEvent( Display *dpy, GLXDrawable drawable,
  213. unsigned long mask );
  214. extern void glXGetSelectedEvent( Display *dpy, GLXDrawable drawable,
  215. unsigned long *mask );
  216. /* GLX 1.3 function pointer typedefs */
  217. typedef GLXFBConfig * (* PFNGLXGETFBCONFIGSPROC) (Display *dpy, int screen, int *nelements);
  218. typedef GLXFBConfig * (* PFNGLXCHOOSEFBCONFIGPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements);
  219. typedef int (* PFNGLXGETFBCONFIGATTRIBPROC) (Display *dpy, GLXFBConfig config, int attribute, int *value);
  220. typedef XVisualInfo * (* PFNGLXGETVISUALFROMFBCONFIGPROC) (Display *dpy, GLXFBConfig config);
  221. typedef GLXWindow (* PFNGLXCREATEWINDOWPROC) (Display *dpy, GLXFBConfig config, Window win, const int *attrib_list);
  222. typedef void (* PFNGLXDESTROYWINDOWPROC) (Display *dpy, GLXWindow win);
  223. typedef GLXPixmap (* PFNGLXCREATEPIXMAPPROC) (Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list);
  224. typedef void (* PFNGLXDESTROYPIXMAPPROC) (Display *dpy, GLXPixmap pixmap);
  225. typedef GLXPbuffer (* PFNGLXCREATEPBUFFERPROC) (Display *dpy, GLXFBConfig config, const int *attrib_list);
  226. typedef void (* PFNGLXDESTROYPBUFFERPROC) (Display *dpy, GLXPbuffer pbuf);
  227. typedef void (* PFNGLXQUERYDRAWABLEPROC) (Display *dpy, GLXDrawable draw, int attribute, unsigned int *value);
  228. typedef GLXContext (* PFNGLXCREATENEWCONTEXTPROC) (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct);
  229. typedef Bool (* PFNGLXMAKECONTEXTCURRENTPROC) (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
  230. typedef GLXDrawable (* PFNGLXGETCURRENTREADDRAWABLEPROC) (void);
  231. typedef Display * (* PFNGLXGETCURRENTDISPLAYPROC) (void);
  232. typedef int (* PFNGLXQUERYCONTEXTPROC) (Display *dpy, GLXContext ctx, int attribute, int *value);
  233. typedef void (* PFNGLXSELECTEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long event_mask);
  234. typedef void (* PFNGLXGETSELECTEDEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long *event_mask);
  235. /*
  236. * ARB 2. GLX_ARB_get_proc_address
  237. */
  238. #ifndef GLX_ARB_get_proc_address
  239. #define GLX_ARB_get_proc_address 1
  240. typedef void (*__GLXextFuncPtr)(void);
  241. extern __GLXextFuncPtr glXGetProcAddressARB (const GLubyte *);
  242. #endif /* GLX_ARB_get_proc_address */
  243. /* GLX 1.4 and later */
  244. extern void (*glXGetProcAddress(const GLubyte *procname))( void );
  245. /* GLX 1.4 function pointer typedefs */
  246. typedef __GLXextFuncPtr (* PFNGLXGETPROCADDRESSPROC) (const GLubyte *procName);
  247. #ifndef GLX_GLXEXT_LEGACY
  248. #include <GL/glxext.h>
  249. #endif /* GLX_GLXEXT_LEGACY */
  250. /**
  251. ** The following aren't in glxext.h yet.
  252. **/
  253. /*
  254. * ???. GLX_NV_vertex_array_range
  255. */
  256. #ifndef GLX_NV_vertex_array_range
  257. #define GLX_NV_vertex_array_range
  258. extern void *glXAllocateMemoryNV(GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority);
  259. extern void glXFreeMemoryNV(GLvoid *pointer);
  260. typedef void * ( * PFNGLXALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority);
  261. typedef void ( * PFNGLXFREEMEMORYNVPROC) (GLvoid *pointer);
  262. #endif /* GLX_NV_vertex_array_range */
  263. /*
  264. * ARB ?. GLX_ARB_render_texture
  265. * XXX This was never finalized!
  266. */
  267. #ifndef GLX_ARB_render_texture
  268. #define GLX_ARB_render_texture 1
  269. extern Bool glXBindTexImageARB(Display *dpy, GLXPbuffer pbuffer, int buffer);
  270. extern Bool glXReleaseTexImageARB(Display *dpy, GLXPbuffer pbuffer, int buffer);
  271. extern Bool glXDrawableAttribARB(Display *dpy, GLXDrawable draw, const int *attribList);
  272. #endif /* GLX_ARB_render_texture */
  273. /*
  274. * #?. GLX_MESA_swap_frame_usage
  275. */
  276. #ifndef GLX_MESA_swap_frame_usage
  277. #define GLX_MESA_swap_frame_usage 1
  278. extern int glXGetFrameUsageMESA(Display *dpy, GLXDrawable drawable, float *usage);
  279. extern int glXBeginFrameTrackingMESA(Display *dpy, GLXDrawable drawable);
  280. extern int glXEndFrameTrackingMESA(Display *dpy, GLXDrawable drawable);
  281. extern int glXQueryFrameTrackingMESA(Display *dpy, GLXDrawable drawable, int64_t *swapCount, int64_t *missedFrames, float *lastMissedUsage);
  282. typedef int (*PFNGLXGETFRAMEUSAGEMESAPROC) (Display *dpy, GLXDrawable drawable, float *usage);
  283. typedef int (*PFNGLXBEGINFRAMETRACKINGMESAPROC)(Display *dpy, GLXDrawable drawable);
  284. typedef int (*PFNGLXENDFRAMETRACKINGMESAPROC)(Display *dpy, GLXDrawable drawable);
  285. typedef int (*PFNGLXQUERYFRAMETRACKINGMESAPROC)(Display *dpy, GLXDrawable drawable, int64_t *swapCount, int64_t *missedFrames, float *lastMissedUsage);
  286. #endif /* GLX_MESA_swap_frame_usage */
  287. /*
  288. * #?. GLX_MESA_swap_control
  289. */
  290. #ifndef GLX_MESA_swap_control
  291. #define GLX_MESA_swap_control 1
  292. extern int glXSwapIntervalMESA(unsigned int interval);
  293. extern int glXGetSwapIntervalMESA(void);
  294. typedef int (*PFNGLXSWAPINTERVALMESAPROC)(unsigned int interval);
  295. typedef int (*PFNGLXGETSWAPINTERVALMESAPROC)(void);
  296. #endif /* GLX_MESA_swap_control */
  297. /*** Should these go here, or in another header? */
  298. /*
  299. ** GLX Events
  300. */
  301. typedef struct {
  302. int event_type; /* GLX_DAMAGED or GLX_SAVED */
  303. int draw_type; /* GLX_WINDOW or GLX_PBUFFER */
  304. unsigned long serial; /* # of last request processed by server */
  305. Bool send_event; /* true if this came for SendEvent request */
  306. Display *display; /* display the event was read from */
  307. GLXDrawable drawable; /* XID of Drawable */
  308. unsigned int buffer_mask; /* mask indicating which buffers are affected */
  309. unsigned int aux_buffer; /* which aux buffer was affected */
  310. int x, y;
  311. int width, height;
  312. int count; /* if nonzero, at least this many more */
  313. } GLXPbufferClobberEvent;
  314. typedef struct {
  315. int type;
  316. unsigned long serial; /* # of last request processed by server */
  317. Bool send_event; /* true if this came from a SendEvent request */
  318. Display *display; /* Display the event was read from */
  319. Drawable drawable; /* drawable on which event was requested in event mask */
  320. int event_type;
  321. int64_t ust;
  322. int64_t msc;
  323. int64_t sbc;
  324. } GLXBufferSwapComplete;
  325. typedef union __GLXEvent {
  326. GLXPbufferClobberEvent glxpbufferclobber;
  327. GLXBufferSwapComplete glxbufferswapcomplete;
  328. long pad[24];
  329. } GLXEvent;
  330. #ifdef __cplusplus
  331. }
  332. #endif
  333. #endif