Merge commit 'origin/gallium-0.1' into gallium-0.2
[platform/upstream/mesa.git] / include / GL / glx.h
1 /*
2  * Mesa 3-D graphics library
3  * Version:  6.5
4  * 
5  * Copyright (C) 1999-2006  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
26 #ifndef GLX_H
27 #define GLX_H
28
29
30 #ifdef __VMS
31 #include <GL/vms_x_fix.h>
32 # ifdef __cplusplus
33 /* VMS Xlib.h gives problems with C++.
34  * this avoids a bunch of trivial warnings */
35 #pragma message disable nosimpint
36 #endif
37 #endif
38 #include <X11/Xlib.h>
39 #include <X11/Xutil.h>
40 #ifdef __VMS
41 # ifdef __cplusplus
42 #pragma message enable nosimpint
43 #endif
44 #endif
45 #include <GL/gl.h>
46
47
48 #if defined(USE_MGL_NAMESPACE)
49 #include "glx_mangle.h"
50 #endif
51
52
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56
57
58 #define GLX_VERSION_1_1         1
59 #define GLX_VERSION_1_2         1
60 #define GLX_VERSION_1_3         1
61 #define GLX_VERSION_1_4         1
62
63 #define GLX_EXTENSION_NAME   "GLX"
64
65
66
67 /*
68  * Tokens for glXChooseVisual and glXGetConfig:
69  */
70 #define GLX_USE_GL              1
71 #define GLX_BUFFER_SIZE         2
72 #define GLX_LEVEL               3
73 #define GLX_RGBA                4
74 #define GLX_DOUBLEBUFFER        5
75 #define GLX_STEREO              6
76 #define GLX_AUX_BUFFERS         7
77 #define GLX_RED_SIZE            8
78 #define GLX_GREEN_SIZE          9
79 #define GLX_BLUE_SIZE           10
80 #define GLX_ALPHA_SIZE          11
81 #define GLX_DEPTH_SIZE          12
82 #define GLX_STENCIL_SIZE        13
83 #define GLX_ACCUM_RED_SIZE      14
84 #define GLX_ACCUM_GREEN_SIZE    15
85 #define GLX_ACCUM_BLUE_SIZE     16
86 #define GLX_ACCUM_ALPHA_SIZE    17
87
88
89 /*
90  * Error codes returned by glXGetConfig:
91  */
92 #define GLX_BAD_SCREEN          1
93 #define GLX_BAD_ATTRIBUTE       2
94 #define GLX_NO_EXTENSION        3
95 #define GLX_BAD_VISUAL          4
96 #define GLX_BAD_CONTEXT         5
97 #define GLX_BAD_VALUE           6
98 #define GLX_BAD_ENUM            7
99
100
101 /*
102  * GLX 1.1 and later:
103  */
104 #define GLX_VENDOR              1
105 #define GLX_VERSION             2
106 #define GLX_EXTENSIONS          3
107
108
109 /*
110  * GLX 1.3 and later:
111  */
112 #define GLX_CONFIG_CAVEAT               0x20
113 #define GLX_DONT_CARE                   0xFFFFFFFF
114 #define GLX_X_VISUAL_TYPE               0x22
115 #define GLX_TRANSPARENT_TYPE            0x23
116 #define GLX_TRANSPARENT_INDEX_VALUE     0x24
117 #define GLX_TRANSPARENT_RED_VALUE       0x25
118 #define GLX_TRANSPARENT_GREEN_VALUE     0x26
119 #define GLX_TRANSPARENT_BLUE_VALUE      0x27
120 #define GLX_TRANSPARENT_ALPHA_VALUE     0x28
121 #define GLX_WINDOW_BIT                  0x00000001
122 #define GLX_PIXMAP_BIT                  0x00000002
123 #define GLX_PBUFFER_BIT                 0x00000004
124 #define GLX_AUX_BUFFERS_BIT             0x00000010
125 #define GLX_FRONT_LEFT_BUFFER_BIT       0x00000001
126 #define GLX_FRONT_RIGHT_BUFFER_BIT      0x00000002
127 #define GLX_BACK_LEFT_BUFFER_BIT        0x00000004
128 #define GLX_BACK_RIGHT_BUFFER_BIT       0x00000008
129 #define GLX_DEPTH_BUFFER_BIT            0x00000020
130 #define GLX_STENCIL_BUFFER_BIT          0x00000040
131 #define GLX_ACCUM_BUFFER_BIT            0x00000080
132 #define GLX_NONE                        0x8000
133 #define GLX_SLOW_CONFIG                 0x8001
134 #define GLX_TRUE_COLOR                  0x8002
135 #define GLX_DIRECT_COLOR                0x8003
136 #define GLX_PSEUDO_COLOR                0x8004
137 #define GLX_STATIC_COLOR                0x8005
138 #define GLX_GRAY_SCALE                  0x8006
139 #define GLX_STATIC_GRAY                 0x8007
140 #define GLX_TRANSPARENT_RGB             0x8008
141 #define GLX_TRANSPARENT_INDEX           0x8009
142 #define GLX_VISUAL_ID                   0x800B
143 #define GLX_SCREEN                      0x800C
144 #define GLX_NON_CONFORMANT_CONFIG       0x800D
145 #define GLX_DRAWABLE_TYPE               0x8010
146 #define GLX_RENDER_TYPE                 0x8011
147 #define GLX_X_RENDERABLE                0x8012
148 #define GLX_FBCONFIG_ID                 0x8013
149 #define GLX_RGBA_TYPE                   0x8014
150 #define GLX_COLOR_INDEX_TYPE            0x8015
151 #define GLX_MAX_PBUFFER_WIDTH           0x8016
152 #define GLX_MAX_PBUFFER_HEIGHT          0x8017
153 #define GLX_MAX_PBUFFER_PIXELS          0x8018
154 #define GLX_PRESERVED_CONTENTS          0x801B
155 #define GLX_LARGEST_PBUFFER             0x801C
156 #define GLX_WIDTH                       0x801D
157 #define GLX_HEIGHT                      0x801E
158 #define GLX_EVENT_MASK                  0x801F
159 #define GLX_DAMAGED                     0x8020
160 #define GLX_SAVED                       0x8021
161 #define GLX_WINDOW                      0x8022
162 #define GLX_PBUFFER                     0x8023
163 #define GLX_PBUFFER_HEIGHT              0x8040
164 #define GLX_PBUFFER_WIDTH               0x8041
165 #define GLX_RGBA_BIT                    0x00000001
166 #define GLX_COLOR_INDEX_BIT             0x00000002
167 #define GLX_PBUFFER_CLOBBER_MASK        0x08000000
168
169
170 /*
171  * GLX 1.4 and later:
172  */
173 #define GLX_SAMPLE_BUFFERS              0x186a0 /*100000*/
174 #define GLX_SAMPLES                     0x186a1 /*100001*/
175
176
177
178 typedef struct __GLXcontextRec *GLXContext;
179 typedef XID GLXPixmap;
180 typedef XID GLXDrawable;
181 /* GLX 1.3 and later */
182 typedef struct __GLXFBConfigRec *GLXFBConfig;
183 typedef XID GLXFBConfigID;
184 typedef XID GLXContextID;
185 typedef XID GLXWindow;
186 typedef XID GLXPbuffer;
187
188
189
190 extern XVisualInfo* glXChooseVisual( Display *dpy, int screen,
191                                      int *attribList );
192
193 extern GLXContext glXCreateContext( Display *dpy, XVisualInfo *vis,
194                                     GLXContext shareList, Bool direct );
195
196 extern void glXDestroyContext( Display *dpy, GLXContext ctx );
197
198 extern Bool glXMakeCurrent( Display *dpy, GLXDrawable drawable,
199                             GLXContext ctx);
200
201 extern void glXCopyContext( Display *dpy, GLXContext src, GLXContext dst,
202                             unsigned long mask );
203
204 extern void glXSwapBuffers( Display *dpy, GLXDrawable drawable );
205
206 extern GLXPixmap glXCreateGLXPixmap( Display *dpy, XVisualInfo *visual,
207                                      Pixmap pixmap );
208
209 extern void glXDestroyGLXPixmap( Display *dpy, GLXPixmap pixmap );
210
211 extern Bool glXQueryExtension( Display *dpy, int *errorb, int *event );
212
213 extern Bool glXQueryVersion( Display *dpy, int *maj, int *min );
214
215 extern Bool glXIsDirect( Display *dpy, GLXContext ctx );
216
217 extern int glXGetConfig( Display *dpy, XVisualInfo *visual,
218                          int attrib, int *value );
219
220 extern GLXContext glXGetCurrentContext( void );
221
222 extern GLXDrawable glXGetCurrentDrawable( void );
223
224 extern void glXWaitGL( void );
225
226 extern void glXWaitX( void );
227
228 extern void glXUseXFont( Font font, int first, int count, int list );
229
230
231
232 /* GLX 1.1 and later */
233 extern const char *glXQueryExtensionsString( Display *dpy, int screen );
234
235 extern const char *glXQueryServerString( Display *dpy, int screen, int name );
236
237 extern const char *glXGetClientString( Display *dpy, int name );
238
239
240 /* GLX 1.2 and later */
241 extern Display *glXGetCurrentDisplay( void );
242
243
244 /* GLX 1.3 and later */
245 extern GLXFBConfig *glXChooseFBConfig( Display *dpy, int screen,
246                                        const int *attribList, int *nitems );
247
248 extern int glXGetFBConfigAttrib( Display *dpy, GLXFBConfig config,
249                                  int attribute, int *value );
250
251 extern GLXFBConfig *glXGetFBConfigs( Display *dpy, int screen,
252                                      int *nelements );
253
254 extern XVisualInfo *glXGetVisualFromFBConfig( Display *dpy,
255                                               GLXFBConfig config );
256
257 extern GLXWindow glXCreateWindow( Display *dpy, GLXFBConfig config,
258                                   Window win, const int *attribList );
259
260 extern void glXDestroyWindow( Display *dpy, GLXWindow window );
261
262 extern GLXPixmap glXCreatePixmap( Display *dpy, GLXFBConfig config,
263                                   Pixmap pixmap, const int *attribList );
264
265 extern void glXDestroyPixmap( Display *dpy, GLXPixmap pixmap );
266
267 extern GLXPbuffer glXCreatePbuffer( Display *dpy, GLXFBConfig config,
268                                     const int *attribList );
269
270 extern void glXDestroyPbuffer( Display *dpy, GLXPbuffer pbuf );
271
272 extern void glXQueryDrawable( Display *dpy, GLXDrawable draw, int attribute,
273                               unsigned int *value );
274
275 extern GLXContext glXCreateNewContext( Display *dpy, GLXFBConfig config,
276                                        int renderType, GLXContext shareList,
277                                        Bool direct );
278
279 extern Bool glXMakeContextCurrent( Display *dpy, GLXDrawable draw,
280                                    GLXDrawable read, GLXContext ctx );
281
282 extern GLXDrawable glXGetCurrentReadDrawable( void );
283
284 extern int glXQueryContext( Display *dpy, GLXContext ctx, int attribute,
285                             int *value );
286
287 extern void glXSelectEvent( Display *dpy, GLXDrawable drawable,
288                             unsigned long mask );
289
290 extern void glXGetSelectedEvent( Display *dpy, GLXDrawable drawable,
291                                  unsigned long *mask );
292
293 /* GLX 1.3 function pointer typedefs */
294 typedef GLXFBConfig * (* PFNGLXGETFBCONFIGSPROC) (Display *dpy, int screen, int *nelements);
295 typedef GLXFBConfig * (* PFNGLXCHOOSEFBCONFIGPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements);
296 typedef int (* PFNGLXGETFBCONFIGATTRIBPROC) (Display *dpy, GLXFBConfig config, int attribute, int *value);
297 typedef XVisualInfo * (* PFNGLXGETVISUALFROMFBCONFIGPROC) (Display *dpy, GLXFBConfig config);
298 typedef GLXWindow (* PFNGLXCREATEWINDOWPROC) (Display *dpy, GLXFBConfig config, Window win, const int *attrib_list);
299 typedef void (* PFNGLXDESTROYWINDOWPROC) (Display *dpy, GLXWindow win);
300 typedef GLXPixmap (* PFNGLXCREATEPIXMAPPROC) (Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list);
301 typedef void (* PFNGLXDESTROYPIXMAPPROC) (Display *dpy, GLXPixmap pixmap);
302 typedef GLXPbuffer (* PFNGLXCREATEPBUFFERPROC) (Display *dpy, GLXFBConfig config, const int *attrib_list);
303 typedef void (* PFNGLXDESTROYPBUFFERPROC) (Display *dpy, GLXPbuffer pbuf);
304 typedef void (* PFNGLXQUERYDRAWABLEPROC) (Display *dpy, GLXDrawable draw, int attribute, unsigned int *value);
305 typedef GLXContext (* PFNGLXCREATENEWCONTEXTPROC) (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct);
306 typedef Bool (* PFNGLXMAKECONTEXTCURRENTPROC) (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
307 typedef GLXDrawable (* PFNGLXGETCURRENTREADDRAWABLEPROC) (void);
308 typedef Display * (* PFNGLXGETCURRENTDISPLAYPROC) (void);
309 typedef int (* PFNGLXQUERYCONTEXTPROC) (Display *dpy, GLXContext ctx, int attribute, int *value);
310 typedef void (* PFNGLXSELECTEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long event_mask);
311 typedef void (* PFNGLXGETSELECTEDEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long *event_mask);
312
313
314 /*
315  * ARB 2. GLX_ARB_get_proc_address
316  */
317 #ifndef GLX_ARB_get_proc_address
318 #define GLX_ARB_get_proc_address 1
319
320 typedef void (*__GLXextFuncPtr)(void);
321 extern __GLXextFuncPtr glXGetProcAddressARB (const GLubyte *);
322
323 #endif /* GLX_ARB_get_proc_address */
324
325
326
327 /* GLX 1.4 and later */
328 extern void (*glXGetProcAddress(const GLubyte *procname))( void );
329
330 /* GLX 1.4 function pointer typedefs */
331 typedef __GLXextFuncPtr (* PFNGLXGETPROCADDRESSPROC) (const GLubyte *procName);
332
333
334 #ifndef GLX_GLXEXT_LEGACY
335
336 #include <GL/glxext.h>
337
338 #endif /* GLX_GLXEXT_LEGACY */
339
340
341 /**
342  ** The following aren't in glxext.h yet.
343  **/
344
345
346 /*
347  * ???. GLX_NV_vertex_array_range
348  */
349 #ifndef GLX_NV_vertex_array_range
350 #define GLX_NV_vertex_array_range
351
352 extern void *glXAllocateMemoryNV(GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority);
353 extern void glXFreeMemoryNV(GLvoid *pointer);
354 typedef void * ( * PFNGLXALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority);
355 typedef void ( * PFNGLXFREEMEMORYNVPROC) (GLvoid *pointer);
356
357 #endif /* GLX_NV_vertex_array_range */
358
359
360 /*
361  * ???. GLX_MESA_allocate_memory
362  */ 
363 #ifndef GLX_MESA_allocate_memory
364 #define GLX_MESA_allocate_memory 1
365
366 extern void *glXAllocateMemoryMESA(Display *dpy, int scrn, size_t size, float readfreq, float writefreq, float priority);
367 extern void glXFreeMemoryMESA(Display *dpy, int scrn, void *pointer);
368 extern GLuint glXGetMemoryOffsetMESA(Display *dpy, int scrn, const void *pointer);
369 typedef void * ( * PFNGLXALLOCATEMEMORYMESAPROC) (Display *dpy, int scrn, size_t size, float readfreq, float writefreq, float priority);
370 typedef void ( * PFNGLXFREEMEMORYMESAPROC) (Display *dpy, int scrn, void *pointer);
371 typedef GLuint (* PFNGLXGETMEMORYOFFSETMESAPROC) (Display *dpy, int scrn, const void *pointer);
372
373 #endif /* GLX_MESA_allocate_memory */
374
375
376 /*
377  * ARB ?. GLX_ARB_render_texture
378  * XXX This was never finalized!
379  */
380 #ifndef GLX_ARB_render_texture
381 #define GLX_ARB_render_texture 1
382
383 extern Bool glXBindTexImageARB(Display *dpy, GLXPbuffer pbuffer, int buffer);
384 extern Bool glXReleaseTexImageARB(Display *dpy, GLXPbuffer pbuffer, int buffer);
385 extern Bool glXDrawableAttribARB(Display *dpy, GLXDrawable draw, const int *attribList);
386
387 #endif /* GLX_ARB_render_texture */
388
389
390 /*
391  * Remove this when glxext.h is updated.
392  */
393 #ifndef GLX_NV_float_buffer
394 #define GLX_NV_float_buffer 1
395
396 #define GLX_FLOAT_COMPONENTS_NV         0x20B0
397
398 #endif /* GLX_NV_float_buffer */
399
400
401
402 /*
403  * #?. GLX_MESA_swap_frame_usage
404  */
405 #ifndef GLX_MESA_swap_frame_usage
406 #define GLX_MESA_swap_frame_usage 1
407
408 extern int glXGetFrameUsageMESA(Display *dpy, GLXDrawable drawable, float *usage);
409 extern int glXBeginFrameTrackingMESA(Display *dpy, GLXDrawable drawable);
410 extern int glXEndFrameTrackingMESA(Display *dpy, GLXDrawable drawable);
411 extern int glXQueryFrameTrackingMESA(Display *dpy, GLXDrawable drawable, int64_t *swapCount, int64_t *missedFrames, float *lastMissedUsage);
412
413 typedef int (*PFNGLXGETFRAMEUSAGEMESAPROC) (Display *dpy, GLXDrawable drawable, float *usage);
414 typedef int (*PFNGLXBEGINFRAMETRACKINGMESAPROC)(Display *dpy, GLXDrawable drawable);
415 typedef int (*PFNGLXENDFRAMETRACKINGMESAPROC)(Display *dpy, GLXDrawable drawable);
416 typedef int (*PFNGLXQUERYFRAMETRACKINGMESAPROC)(Display *dpy, GLXDrawable drawable, int64_t *swapCount, int64_t *missedFrames, float *lastMissedUsage);
417
418 #endif /* GLX_MESA_swap_frame_usage */
419
420
421
422 /*
423  * #?. GLX_MESA_swap_control
424  */
425 #ifndef GLX_MESA_swap_control
426 #define GLX_MESA_swap_control 1
427
428 extern int glXSwapIntervalMESA(unsigned int interval);
429 extern int glXGetSwapIntervalMESA(void);
430
431 typedef int (*PFNGLXSWAPINTERVALMESAPROC)(unsigned int interval);
432 typedef int (*PFNGLXGETSWAPINTERVALMESAPROC)(void);
433
434 #endif /* GLX_MESA_swap_control */
435
436
437
438 /*
439  * #?. GLX_EXT_texture_from_pixmap
440  * XXX not finished?
441  */
442 #ifndef GLX_EXT_texture_from_pixmap
443 #define GLX_EXT_texture_from_pixmap 1
444
445 #define GLX_BIND_TO_TEXTURE_RGB_EXT        0x20D0
446 #define GLX_BIND_TO_TEXTURE_RGBA_EXT       0x20D1
447 #define GLX_BIND_TO_MIPMAP_TEXTURE_EXT     0x20D2
448 #define GLX_BIND_TO_TEXTURE_TARGETS_EXT    0x20D3
449 #define GLX_Y_INVERTED_EXT                 0x20D4
450
451 #define GLX_TEXTURE_FORMAT_EXT             0x20D5
452 #define GLX_TEXTURE_TARGET_EXT             0x20D6
453 #define GLX_MIPMAP_TEXTURE_EXT             0x20D7
454
455 #define GLX_TEXTURE_FORMAT_NONE_EXT        0x20D8
456 #define GLX_TEXTURE_FORMAT_RGB_EXT         0x20D9
457 #define GLX_TEXTURE_FORMAT_RGBA_EXT        0x20DA
458
459 #define GLX_TEXTURE_1D_BIT_EXT             0x00000001
460 #define GLX_TEXTURE_2D_BIT_EXT             0x00000002
461 #define GLX_TEXTURE_RECTANGLE_BIT_EXT      0x00000004
462
463 #define GLX_TEXTURE_1D_EXT                 0x20DB
464 #define GLX_TEXTURE_2D_EXT                 0x20DC
465 #define GLX_TEXTURE_RECTANGLE_EXT          0x20DD
466
467 #define GLX_FRONT_LEFT_EXT                 0x20DE
468 #define GLX_FRONT_RIGHT_EXT                0x20DF
469 #define GLX_BACK_LEFT_EXT                  0x20E0
470 #define GLX_BACK_RIGHT_EXT                 0x20E1
471 #define GLX_FRONT_EXT                      GLX_FRONT_LEFT_EXT
472 #define GLX_BACK_EXT                       GLX_BACK_LEFT_EXT
473 #define GLX_AUX0_EXT                       0x20E2
474 #define GLX_AUX1_EXT                       0x20E3 
475 #define GLX_AUX2_EXT                       0x20E4 
476 #define GLX_AUX3_EXT                       0x20E5 
477 #define GLX_AUX4_EXT                       0x20E6 
478 #define GLX_AUX5_EXT                       0x20E7 
479 #define GLX_AUX6_EXT                       0x20E8
480 #define GLX_AUX7_EXT                       0x20E9 
481 #define GLX_AUX8_EXT                       0x20EA 
482 #define GLX_AUX9_EXT                       0x20EB
483
484 extern void glXBindTexImageEXT(Display *dpy, GLXDrawable drawable, int buffer, const int *attrib_list);
485 extern void glXReleaseTexImageEXT(Display *dpy, GLXDrawable drawable, int buffer);
486
487 #endif /* GLX_EXT_texture_from_pixmap */
488
489
490
491
492 /*** Should these go here, or in another header? */
493 /*
494 ** GLX Events
495 */
496 typedef struct {
497     int event_type;             /* GLX_DAMAGED or GLX_SAVED */
498     int draw_type;              /* GLX_WINDOW or GLX_PBUFFER */
499     unsigned long serial;       /* # of last request processed by server */
500     Bool send_event;            /* true if this came for SendEvent request */
501     Display *display;           /* display the event was read from */
502     GLXDrawable drawable;       /* XID of Drawable */
503     unsigned int buffer_mask;   /* mask indicating which buffers are affected */
504     unsigned int aux_buffer;    /* which aux buffer was affected */
505     int x, y;
506     int width, height;
507     int count;                  /* if nonzero, at least this many more */
508 } GLXPbufferClobberEvent;
509
510 typedef union __GLXEvent {
511     GLXPbufferClobberEvent glxpbufferclobber;
512     long pad[24];
513 } GLXEvent;
514
515 #ifdef __cplusplus
516 }
517 #endif
518
519 #endif