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