1 /*
2  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3  *
4  * This code is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License version 2 only, as
6  * published by the Free Software Foundation.  Oracle designates this
7  * particular file as subject to the "Classpath" exception as provided
8  * by Oracle in the LICENSE file that accompanied this code.
9  *
10  * This code is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13  * version 2 for more details (a copy is included in the LICENSE file that
14  * accompanied this code).
15  *
16  * You should have received a copy of the GNU General Public License version
17  * 2 along with this work; if not, write to the Free Software Foundation,
18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19  *
20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21  * or visit www.oracle.com if you need additional information or have any
22  * questions.
23  */
24 
25 
26 /*
27  * This file is available under and governed by the GNU General Public
28  * License version 2 only, as published by the Free Software Foundation.
29  * However, the following notice accompanied the original version of this
30  * file:
31  *
32  * Mesa 3-D graphics library
33  *
34  * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
35  *
36  * Permission is hereby granted, free of charge, to any person obtaining a
37  * copy of this software and associated documentation files (the "Software"),
38  * to deal in the Software without restriction, including without limitation
39  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
40  * and/or sell copies of the Software, and to permit persons to whom the
41  * Software is furnished to do so, subject to the following conditions:
42  *
43  * The above copyright notice and this permission notice shall be included
44  * in all copies or substantial portions of the Software.
45  *
46  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
47  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
48  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
49  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
50  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
51  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
52  * OTHER DEALINGS IN THE SOFTWARE.
53  */
54 
55 
56 #ifndef GLX_H
57 #define GLX_H
58 
59 
60 #include <X11/Xlib.h>
61 #include <X11/Xutil.h>
62 /* JDK modification of include path to be sure to pick up the correct file */
63 #include "J2D_GL/gl.h"
64 
65 
66 #ifdef __cplusplus
67 extern "C" {
68 #endif
69 
70 
71 #define GLX_VERSION_1_1         1
72 #define GLX_VERSION_1_2         1
73 #define GLX_VERSION_1_3         1
74 #define GLX_VERSION_1_4         1
75 
76 #define GLX_EXTENSION_NAME   "GLX"
77 
78 
79 
80 /*
81  * Tokens for glXChooseVisual and glXGetConfig:
82  */
83 #define GLX_USE_GL              1
84 #define GLX_BUFFER_SIZE         2
85 #define GLX_LEVEL               3
86 #define GLX_RGBA                4
87 #define GLX_DOUBLEBUFFER        5
88 #define GLX_STEREO              6
89 #define GLX_AUX_BUFFERS         7
90 #define GLX_RED_SIZE            8
91 #define GLX_GREEN_SIZE          9
92 #define GLX_BLUE_SIZE           10
93 #define GLX_ALPHA_SIZE          11
94 #define GLX_DEPTH_SIZE          12
95 #define GLX_STENCIL_SIZE        13
96 #define GLX_ACCUM_RED_SIZE      14
97 #define GLX_ACCUM_GREEN_SIZE    15
98 #define GLX_ACCUM_BLUE_SIZE     16
99 #define GLX_ACCUM_ALPHA_SIZE    17
100 
101 
102 /*
103  * Error codes returned by glXGetConfig:
104  */
105 #define GLX_BAD_SCREEN          1
106 #define GLX_BAD_ATTRIBUTE       2
107 #define GLX_NO_EXTENSION        3
108 #define GLX_BAD_VISUAL          4
109 #define GLX_BAD_CONTEXT         5
110 #define GLX_BAD_VALUE           6
111 #define GLX_BAD_ENUM            7
112 
113 
114 /*
115  * GLX 1.1 and later:
116  */
117 #define GLX_VENDOR              1
118 #define GLX_VERSION             2
119 #define GLX_EXTENSIONS          3
120 
121 
122 /*
123  * GLX 1.3 and later:
124  */
125 #define GLX_CONFIG_CAVEAT               0x20
126 #define GLX_DONT_CARE                   0xFFFFFFFF
127 #define GLX_X_VISUAL_TYPE               0x22
128 #define GLX_TRANSPARENT_TYPE            0x23
129 #define GLX_TRANSPARENT_INDEX_VALUE     0x24
130 #define GLX_TRANSPARENT_RED_VALUE       0x25
131 #define GLX_TRANSPARENT_GREEN_VALUE     0x26
132 #define GLX_TRANSPARENT_BLUE_VALUE      0x27
133 #define GLX_TRANSPARENT_ALPHA_VALUE     0x28
134 #define GLX_WINDOW_BIT                  0x00000001
135 #define GLX_PIXMAP_BIT                  0x00000002
136 #define GLX_PBUFFER_BIT                 0x00000004
137 #define GLX_AUX_BUFFERS_BIT             0x00000010
138 #define GLX_FRONT_LEFT_BUFFER_BIT       0x00000001
139 #define GLX_FRONT_RIGHT_BUFFER_BIT      0x00000002
140 #define GLX_BACK_LEFT_BUFFER_BIT        0x00000004
141 #define GLX_BACK_RIGHT_BUFFER_BIT       0x00000008
142 #define GLX_DEPTH_BUFFER_BIT            0x00000020
143 #define GLX_STENCIL_BUFFER_BIT          0x00000040
144 #define GLX_ACCUM_BUFFER_BIT            0x00000080
145 #define GLX_NONE                        0x8000
146 #define GLX_SLOW_CONFIG                 0x8001
147 #define GLX_TRUE_COLOR                  0x8002
148 #define GLX_DIRECT_COLOR                0x8003
149 #define GLX_PSEUDO_COLOR                0x8004
150 #define GLX_STATIC_COLOR                0x8005
151 #define GLX_GRAY_SCALE                  0x8006
152 #define GLX_STATIC_GRAY                 0x8007
153 #define GLX_TRANSPARENT_RGB             0x8008
154 #define GLX_TRANSPARENT_INDEX           0x8009
155 #define GLX_VISUAL_ID                   0x800B
156 #define GLX_SCREEN                      0x800C
157 #define GLX_NON_CONFORMANT_CONFIG       0x800D
158 #define GLX_DRAWABLE_TYPE               0x8010
159 #define GLX_RENDER_TYPE                 0x8011
160 #define GLX_X_RENDERABLE                0x8012
161 #define GLX_FBCONFIG_ID                 0x8013
162 #define GLX_RGBA_TYPE                   0x8014
163 #define GLX_COLOR_INDEX_TYPE            0x8015
164 #define GLX_MAX_PBUFFER_WIDTH           0x8016
165 #define GLX_MAX_PBUFFER_HEIGHT          0x8017
166 #define GLX_MAX_PBUFFER_PIXELS          0x8018
167 #define GLX_PRESERVED_CONTENTS          0x801B
168 #define GLX_LARGEST_PBUFFER             0x801C
169 #define GLX_WIDTH                       0x801D
170 #define GLX_HEIGHT                      0x801E
171 #define GLX_EVENT_MASK                  0x801F
172 #define GLX_DAMAGED                     0x8020
173 #define GLX_SAVED                       0x8021
174 #define GLX_WINDOW                      0x8022
175 #define GLX_PBUFFER                     0x8023
176 #define GLX_PBUFFER_HEIGHT              0x8040
177 #define GLX_PBUFFER_WIDTH               0x8041
178 #define GLX_RGBA_BIT                    0x00000001
179 #define GLX_COLOR_INDEX_BIT             0x00000002
180 #define GLX_PBUFFER_CLOBBER_MASK        0x08000000
181 
182 
183 /*
184  * GLX 1.4 and later:
185  */
186 #define GLX_SAMPLE_BUFFERS              0x186a0 /*100000*/
187 #define GLX_SAMPLES                     0x186a1 /*100001*/
188 
189 
190 
191 typedef struct __GLXcontextRec *GLXContext;
192 typedef XID GLXPixmap;
193 typedef XID GLXDrawable;
194 /* GLX 1.3 and later */
195 typedef struct __GLXFBConfigRec *GLXFBConfig;
196 typedef XID GLXFBConfigID;
197 typedef XID GLXContextID;
198 typedef XID GLXWindow;
199 typedef XID GLXPbuffer;
200 
201 
202 /*
203 ** Events.
204 ** __GLX_NUMBER_EVENTS is set to 17 to account for the BufferClobberSGIX
205 **  event - this helps initialization if the server supports the pbuffer
206 **  extension and the client doesn't.
207 */
208 #define GLX_PbufferClobber      0
209 #define GLX_BufferSwapComplete  1
210 
211 #define __GLX_NUMBER_EVENTS 17
212 
213 extern XVisualInfo* glXChooseVisual( Display *dpy, int screen,
214                                      int *attribList );
215 
216 extern GLXContext glXCreateContext( Display *dpy, XVisualInfo *vis,
217                                     GLXContext shareList, Bool direct );
218 
219 extern void glXDestroyContext( Display *dpy, GLXContext ctx );
220 
221 extern Bool glXMakeCurrent( Display *dpy, GLXDrawable drawable,
222                             GLXContext ctx);
223 
224 extern void glXCopyContext( Display *dpy, GLXContext src, GLXContext dst,
225                             unsigned long mask );
226 
227 extern void glXSwapBuffers( Display *dpy, GLXDrawable drawable );
228 
229 extern GLXPixmap glXCreateGLXPixmap( Display *dpy, XVisualInfo *visual,
230                                      Pixmap pixmap );
231 
232 extern void glXDestroyGLXPixmap( Display *dpy, GLXPixmap pixmap );
233 
234 extern Bool glXQueryExtension( Display *dpy, int *errorb, int *event );
235 
236 extern Bool glXQueryVersion( Display *dpy, int *maj, int *min );
237 
238 extern Bool glXIsDirect( Display *dpy, GLXContext ctx );
239 
240 extern int glXGetConfig( Display *dpy, XVisualInfo *visual,
241                          int attrib, int *value );
242 
243 extern GLXContext glXGetCurrentContext( void );
244 
245 extern GLXDrawable glXGetCurrentDrawable( void );
246 
247 extern void glXWaitGL( void );
248 
249 extern void glXWaitX( void );
250 
251 extern void glXUseXFont( Font font, int first, int count, int list );
252 
253 
254 
255 /* GLX 1.1 and later */
256 extern const char *glXQueryExtensionsString( Display *dpy, int screen );
257 
258 extern const char *glXQueryServerString( Display *dpy, int screen, int name );
259 
260 extern const char *glXGetClientString( Display *dpy, int name );
261 
262 
263 /* GLX 1.2 and later */
264 extern Display *glXGetCurrentDisplay( void );
265 
266 
267 /* GLX 1.3 and later */
268 extern GLXFBConfig *glXChooseFBConfig( Display *dpy, int screen,
269                                        const int *attribList, int *nitems );
270 
271 extern int glXGetFBConfigAttrib( Display *dpy, GLXFBConfig config,
272                                  int attribute, int *value );
273 
274 extern GLXFBConfig *glXGetFBConfigs( Display *dpy, int screen,
275                                      int *nelements );
276 
277 extern XVisualInfo *glXGetVisualFromFBConfig( Display *dpy,
278                                               GLXFBConfig config );
279 
280 extern GLXWindow glXCreateWindow( Display *dpy, GLXFBConfig config,
281                                   Window win, const int *attribList );
282 
283 extern void glXDestroyWindow( Display *dpy, GLXWindow window );
284 
285 extern GLXPixmap glXCreatePixmap( Display *dpy, GLXFBConfig config,
286                                   Pixmap pixmap, const int *attribList );
287 
288 extern void glXDestroyPixmap( Display *dpy, GLXPixmap pixmap );
289 
290 extern GLXPbuffer glXCreatePbuffer( Display *dpy, GLXFBConfig config,
291                                     const int *attribList );
292 
293 extern void glXDestroyPbuffer( Display *dpy, GLXPbuffer pbuf );
294 
295 extern void glXQueryDrawable( Display *dpy, GLXDrawable draw, int attribute,
296                               unsigned int *value );
297 
298 extern GLXContext glXCreateNewContext( Display *dpy, GLXFBConfig config,
299                                        int renderType, GLXContext shareList,
300                                        Bool direct );
301 
302 extern Bool glXMakeContextCurrent( Display *dpy, GLXDrawable draw,
303                                    GLXDrawable read, GLXContext ctx );
304 
305 extern GLXDrawable glXGetCurrentReadDrawable( void );
306 
307 extern int glXQueryContext( Display *dpy, GLXContext ctx, int attribute,
308                             int *value );
309 
310 extern void glXSelectEvent( Display *dpy, GLXDrawable drawable,
311                             unsigned long mask );
312 
313 extern void glXGetSelectedEvent( Display *dpy, GLXDrawable drawable,
314                                  unsigned long *mask );
315 
316 /* GLX 1.3 function pointer typedefs */
317 typedef GLXFBConfig * (* PFNGLXGETFBCONFIGSPROC) (Display *dpy, int screen, int *nelements);
318 typedef GLXFBConfig * (* PFNGLXCHOOSEFBCONFIGPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements);
319 typedef int (* PFNGLXGETFBCONFIGATTRIBPROC) (Display *dpy, GLXFBConfig config, int attribute, int *value);
320 typedef XVisualInfo * (* PFNGLXGETVISUALFROMFBCONFIGPROC) (Display *dpy, GLXFBConfig config);
321 typedef GLXWindow (* PFNGLXCREATEWINDOWPROC) (Display *dpy, GLXFBConfig config, Window win, const int *attrib_list);
322 typedef void (* PFNGLXDESTROYWINDOWPROC) (Display *dpy, GLXWindow win);
323 typedef GLXPixmap (* PFNGLXCREATEPIXMAPPROC) (Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list);
324 typedef void (* PFNGLXDESTROYPIXMAPPROC) (Display *dpy, GLXPixmap pixmap);
325 typedef GLXPbuffer (* PFNGLXCREATEPBUFFERPROC) (Display *dpy, GLXFBConfig config, const int *attrib_list);
326 typedef void (* PFNGLXDESTROYPBUFFERPROC) (Display *dpy, GLXPbuffer pbuf);
327 typedef void (* PFNGLXQUERYDRAWABLEPROC) (Display *dpy, GLXDrawable draw, int attribute, unsigned int *value);
328 typedef GLXContext (* PFNGLXCREATENEWCONTEXTPROC) (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct);
329 typedef Bool (* PFNGLXMAKECONTEXTCURRENTPROC) (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
330 typedef GLXDrawable (* PFNGLXGETCURRENTREADDRAWABLEPROC) (void);
331 typedef Display * (* PFNGLXGETCURRENTDISPLAYPROC) (void);
332 typedef int (* PFNGLXQUERYCONTEXTPROC) (Display *dpy, GLXContext ctx, int attribute, int *value);
333 typedef void (* PFNGLXSELECTEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long event_mask);
334 typedef void (* PFNGLXGETSELECTEDEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long *event_mask);
335 
336 
337 /*
338  * ARB 2. GLX_ARB_get_proc_address
339  */
340 #ifndef GLX_ARB_get_proc_address
341 #define GLX_ARB_get_proc_address 1
342 
343 typedef void (*__GLXextFuncPtr)(void);
344 extern __GLXextFuncPtr glXGetProcAddressARB (const GLubyte *);
345 
346 #endif /* GLX_ARB_get_proc_address */
347 
348 
349 
350 /* GLX 1.4 and later */
351 extern void (*glXGetProcAddress(const GLubyte *procname))( void );
352 
353 /* GLX 1.4 function pointer typedefs */
354 typedef __GLXextFuncPtr (* PFNGLXGETPROCADDRESSPROC) (const GLubyte *procName);
355 
356 
357 #ifndef GLX_GLXEXT_LEGACY
358 
359 /* JDK modification of include path to be sure to pick up the correct file */
360 #include "J2D_GL/glxext.h"
361 
362 #endif /* GLX_GLXEXT_LEGACY */
363 
364 
365 /**
366  ** The following aren't in glxext.h yet.
367  **/
368 
369 
370 /*
371  * ???. GLX_NV_vertex_array_range
372  */
373 #ifndef GLX_NV_vertex_array_range
374 #define GLX_NV_vertex_array_range
375 
376 extern void *glXAllocateMemoryNV(GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority);
377 extern void glXFreeMemoryNV(GLvoid *pointer);
378 typedef void * ( * PFNGLXALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority);
379 typedef void ( * PFNGLXFREEMEMORYNVPROC) (GLvoid *pointer);
380 
381 #endif /* GLX_NV_vertex_array_range */
382 
383 
384 /*
385  * ARB ?. GLX_ARB_render_texture
386  * XXX This was never finalized!
387  */
388 #ifndef GLX_ARB_render_texture
389 #define GLX_ARB_render_texture 1
390 
391 extern Bool glXBindTexImageARB(Display *dpy, GLXPbuffer pbuffer, int buffer);
392 extern Bool glXReleaseTexImageARB(Display *dpy, GLXPbuffer pbuffer, int buffer);
393 extern Bool glXDrawableAttribARB(Display *dpy, GLXDrawable draw, const int *attribList);
394 
395 #endif /* GLX_ARB_render_texture */
396 
397 
398 /*
399  * #?. GLX_MESA_swap_frame_usage
400  */
401 #ifndef GLX_MESA_swap_frame_usage
402 #define GLX_MESA_swap_frame_usage 1
403 
404 extern int glXGetFrameUsageMESA(Display *dpy, GLXDrawable drawable, float *usage);
405 extern int glXBeginFrameTrackingMESA(Display *dpy, GLXDrawable drawable);
406 extern int glXEndFrameTrackingMESA(Display *dpy, GLXDrawable drawable);
407 extern int glXQueryFrameTrackingMESA(Display *dpy, GLXDrawable drawable, int64_t *swapCount, int64_t *missedFrames, float *lastMissedUsage);
408 
409 typedef int (*PFNGLXGETFRAMEUSAGEMESAPROC) (Display *dpy, GLXDrawable drawable, float *usage);
410 typedef int (*PFNGLXBEGINFRAMETRACKINGMESAPROC)(Display *dpy, GLXDrawable drawable);
411 typedef int (*PFNGLXENDFRAMETRACKINGMESAPROC)(Display *dpy, GLXDrawable drawable);
412 typedef int (*PFNGLXQUERYFRAMETRACKINGMESAPROC)(Display *dpy, GLXDrawable drawable, int64_t *swapCount, int64_t *missedFrames, float *lastMissedUsage);
413 
414 #endif /* GLX_MESA_swap_frame_usage */
415 
416 
417 
418 /*
419  * #?. GLX_MESA_swap_control
420  */
421 #ifndef GLX_MESA_swap_control
422 #define GLX_MESA_swap_control 1
423 
424 extern int glXSwapIntervalMESA(unsigned int interval);
425 extern int glXGetSwapIntervalMESA(void);
426 
427 typedef int (*PFNGLXSWAPINTERVALMESAPROC)(unsigned int interval);
428 typedef int (*PFNGLXGETSWAPINTERVALMESAPROC)(void);
429 
430 #endif /* GLX_MESA_swap_control */
431 
432 
433 /*** Should these go here, or in another header? */
434 /*
435 ** GLX Events
436 */
437 typedef struct {
438     int event_type;             /* GLX_DAMAGED or GLX_SAVED */
439     int draw_type;              /* GLX_WINDOW or GLX_PBUFFER */
440     unsigned long serial;       /* # of last request processed by server */
441     Bool send_event;            /* true if this came for SendEvent request */
442     Display *display;           /* display the event was read from */
443     GLXDrawable drawable;       /* XID of Drawable */
444     unsigned int buffer_mask;   /* mask indicating which buffers are affected */
445     unsigned int aux_buffer;    /* which aux buffer was affected */
446     int x, y;
447     int width, height;
448     int count;                  /* if nonzero, at least this many more */
449 } GLXPbufferClobberEvent;
450 
451 typedef struct {
452     int type;
453     unsigned long serial;       /* # of last request processed by server */
454     Bool send_event;            /* true if this came from a SendEvent request */
455     Display *display;           /* Display the event was read from */
456     Drawable drawable;  /* drawable on which event was requested in event mask */
457     int event_type;
458     int64_t ust;
459     int64_t msc;
460     int64_t sbc;
461 } GLXBufferSwapComplete;
462 
463 typedef union __GLXEvent {
464     GLXPbufferClobberEvent glxpbufferclobber;
465     GLXBufferSwapComplete glxbufferswapcomplete;
466     long pad[24];
467 } GLXEvent;
468 
469 #ifdef __cplusplus
470 }
471 #endif
472 
473 #endif
474