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