2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
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:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
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.
27 * This is an emulation of the GLX API which allows Mesa/GLX-based programs
28 * to run on X servers which do not have the real GLX extension.
30 * Thanks to the contributors:
32 * Initial version: Philip Brown (phil@bolthole.com)
33 * Better glXGetConfig() support: Armin Liebchen (liebchen@asylum.cs.utah.edu)
34 * Further visual-handling refinements: Wolfram Gloger
35 * (wmglo@Dent.MED.Uni-Muenchen.DE).
38 * Don't be fooled, stereo isn't supported yet.
43 #include "glxheader.h"
56 /* This indicates the client-side GLX API and GLX encoder version. */
57 #define CLIENT_MAJOR_VERSION 1
58 #define CLIENT_MINOR_VERSION 4 /* but don't have 1.3's pbuffers, etc yet */
60 /* This indicates the server-side GLX decoder version.
61 * GLX 1.4 indicates OpenGL 1.3 support
63 #define SERVER_MAJOR_VERSION 1
64 #define SERVER_MINOR_VERSION 4
66 /* This is appended onto the glXGetClient/ServerString version strings. */
67 #define MESA_GLX_VERSION "Mesa " MESA_VERSION_STRING
69 /* Who implemented this GLX? */
70 #define VENDOR "Brian Paul"
73 "GLX_MESA_set_3dfx_mode " \
74 "GLX_MESA_copy_sub_buffer " \
75 "GLX_MESA_pixmap_colormap " \
76 "GLX_MESA_release_buffers " \
77 "GLX_ARB_get_proc_address " \
78 "GLX_EXT_visual_info " \
79 "GLX_EXT_visual_rating " \
80 "GLX_SGI_video_sync " \
81 "GLX_SGIX_fbconfig " \
84 "GLX_ARB_render_texture"
87 /* Silence compiler warnings */
88 extern void Fake_glXDummyFunc( void );
89 void Fake_glXDummyFunc( void )
99 * Our fake GLX context will contain a "real" GLX context and an XMesa context.
101 * Note that a pointer to a __GLXcontext is a pointer to a fake_glx_context,
104 * We really just need this structure in order to make the libGL functions
105 * glXGetCurrentContext(), glXGetCurrentDrawable() and glXGetCurrentDisplay()
108 struct fake_glx_context
{
109 __GLXcontext glxContext
; /* this MUST be first! */
110 XMesaContext xmesaContext
;
115 /**********************************************************************/
116 /*** GLX Visual Code ***/
117 /**********************************************************************/
122 #define MAX_VISUALS 100
123 static XMesaVisual VisualTable
[MAX_VISUALS
];
124 static int NumVisuals
= 0;
128 * This struct and some code fragments borrowed
129 * from Mark Kilgard's GLUT library.
131 typedef struct _OverlayInfo
{
132 /* Avoid 64-bit portability problems by being careful to use
133 longs due to the way XGetWindowProperty is specified. Note
134 that these parameters are passed as CARD32s over X
136 unsigned long overlay_visual
;
137 long transparent_type
;
144 /* Macro to handle c_class vs class field name in XVisualInfo struct */
145 #if defined(__cplusplus) || defined(c_plusplus)
146 #define CLASS c_class
155 * Test if the given XVisualInfo is usable for Mesa rendering.
157 static GLboolean
is_usable_visual( XVisualInfo
*vinfo
)
159 switch (vinfo
->CLASS
) {
162 /* Any StaticGray/GrayScale visual works in RGB or CI mode */
166 /* Any StaticColor/PseudoColor visual of at least 4 bits */
167 if (vinfo
->depth
>=4) {
175 /* Any depth of TrueColor or DirectColor works in RGB mode */
178 /* This should never happen */
186 * Return the level (overlay, normal, underlay) of a given XVisualInfo.
187 * Input: dpy - the X display
188 * vinfo - the XVisualInfo to test
189 * Return: level of the visual:
191 * >0 = overlay planes
192 * <0 = underlay planes
194 static int level_of_visual( Display
*dpy
, XVisualInfo
*vinfo
)
196 Atom overlayVisualsAtom
;
197 OverlayInfo
*overlay_info
= NULL
;
198 int numOverlaysPerScreen
;
202 unsigned long sizeData
, bytesLeft
;
206 * The SERVER_OVERLAY_VISUALS property on the root window contains
207 * a list of overlay visuals. Get that list now.
209 overlayVisualsAtom
= XInternAtom(dpy
,"SERVER_OVERLAY_VISUALS", True
);
210 if (overlayVisualsAtom
== None
) {
214 status
= XGetWindowProperty(dpy
, RootWindow( dpy
, vinfo
->screen
),
215 overlayVisualsAtom
, 0L, (long) 10000, False
,
216 overlayVisualsAtom
, &actualType
, &actualFormat
,
217 &sizeData
, &bytesLeft
,
218 (unsigned char **) &overlay_info
);
220 if (status
!= Success
|| actualType
!= overlayVisualsAtom
||
221 actualFormat
!= 32 || sizeData
< 4) {
222 /* something went wrong */
223 XFree((void *) overlay_info
);
227 /* search the overlay visual list for the visual ID of interest */
228 numOverlaysPerScreen
= (int) (sizeData
/ 4);
229 for (i
=0;i
<numOverlaysPerScreen
;i
++) {
231 ov
= overlay_info
+ i
;
232 if (ov
->overlay_visual
==vinfo
->visualid
) {
233 /* found the visual */
234 if (/*ov->transparent_type==1 &&*/ ov
->layer
!=0) {
235 int level
= ov
->layer
;
236 XFree((void *) overlay_info
);
240 XFree((void *) overlay_info
);
246 /* The visual ID was not found in the overlay list. */
247 XFree((void *) overlay_info
);
255 * Given an XVisualInfo and RGB, Double, and Depth buffer flags, save the
256 * configuration in our list of GLX visuals.
259 save_glx_visual( Display
*dpy
, XVisualInfo
*vinfo
,
260 GLboolean rgbFlag
, GLboolean alphaFlag
, GLboolean dbFlag
,
261 GLboolean stereoFlag
,
262 GLint depth_size
, GLint stencil_size
,
263 GLint accumRedSize
, GLint accumGreenSize
,
264 GLint accumBlueSize
, GLint accumAlphaSize
,
267 GLboolean ximageFlag
= GL_TRUE
;
270 GLboolean comparePointers
;
273 /* Check if the MESA_BACK_BUFFER env var is set */
274 char *backbuffer
= _mesa_getenv("MESA_BACK_BUFFER");
276 if (backbuffer
[0]=='p' || backbuffer
[0]=='P') {
277 ximageFlag
= GL_FALSE
;
279 else if (backbuffer
[0]=='x' || backbuffer
[0]=='X') {
280 ximageFlag
= GL_TRUE
;
283 _mesa_warning(NULL
, "Mesa: invalid value for MESA_BACK_BUFFER environment variable, using an XImage.");
288 /* Comparing IDs uses less memory but sometimes fails. */
289 /* XXX revisit this after 3.0 is finished. */
290 if (_mesa_getenv("MESA_GLX_VISUAL_HACK"))
291 comparePointers
= GL_TRUE
;
293 comparePointers
= GL_FALSE
;
295 /* First check if a matching visual is already in the list */
296 for (i
=0; i
<NumVisuals
; i
++) {
297 XMesaVisual v
= VisualTable
[i
];
298 if (v
->display
== dpy
300 && v
->ximage_flag
== ximageFlag
301 && v
->mesa_visual
.rgbMode
== rgbFlag
302 && v
->mesa_visual
.doubleBufferMode
== dbFlag
303 && v
->mesa_visual
.stereoMode
== stereoFlag
304 && (v
->mesa_visual
.alphaBits
> 0) == alphaFlag
305 && (v
->mesa_visual
.depthBits
>= depth_size
|| depth_size
== 0)
306 && (v
->mesa_visual
.stencilBits
>= stencil_size
|| stencil_size
== 0)
307 && (v
->mesa_visual
.accumRedBits
>= accumRedSize
|| accumRedSize
== 0)
308 && (v
->mesa_visual
.accumGreenBits
>= accumGreenSize
|| accumGreenSize
== 0)
309 && (v
->mesa_visual
.accumBlueBits
>= accumBlueSize
|| accumBlueSize
== 0)
310 && (v
->mesa_visual
.accumAlphaBits
>= accumAlphaSize
|| accumAlphaSize
== 0)) {
311 /* now either compare XVisualInfo pointers or visual IDs */
312 if ((!comparePointers
&& v
->visinfo
->visualid
== vinfo
->visualid
)
313 || (comparePointers
&& v
->vishandle
== vinfo
)) {
319 /* Create a new visual and add it to the list. */
321 if (NumVisuals
>= MAX_VISUALS
) {
322 _mesa_problem(NULL
, "GLX Error: maximum number of visuals exceeded");
326 xmvis
= XMesaCreateVisual( dpy
, vinfo
, rgbFlag
, alphaFlag
, dbFlag
,
327 stereoFlag
, ximageFlag
,
328 depth_size
, stencil_size
,
329 accumRedSize
, accumBlueSize
,
330 accumBlueSize
, accumAlphaSize
, 0, level
,
333 /* Save a copy of the pointer now so we can find this visual again
334 * if we need to search for it in find_glx_visual().
336 xmvis
->vishandle
= vinfo
;
337 /* add xmvis to the list */
338 VisualTable
[NumVisuals
] = xmvis
;
347 * Create a GLX visual from a regular XVisualInfo.
348 * This is called when Fake GLX is given an XVisualInfo which wasn't
349 * returned by glXChooseVisual. Since this is the first time we're
350 * considering this visual we'll take a guess at reasonable values
351 * for depth buffer size, stencil size, accum size, etc.
352 * This is the best we can do with a client-side emulation of GLX.
355 create_glx_visual( Display
*dpy
, XVisualInfo
*visinfo
)
359 vislevel
= level_of_visual( dpy
, visinfo
);
361 /* Configure this visual as a CI, single-buffered overlay */
362 return save_glx_visual( dpy
, visinfo
,
364 GL_FALSE
, /* alpha */
365 GL_FALSE
, /* double */
366 GL_FALSE
, /* stereo */
368 0, /* stencil bits */
369 0,0,0,0, /* accum bits */
373 else if (is_usable_visual( visinfo
)) {
374 if (_mesa_getenv("MESA_GLX_FORCE_CI")) {
375 /* Configure this visual as a COLOR INDEX visual. */
376 return save_glx_visual( dpy
, visinfo
,
378 GL_FALSE
, /* alpha */
379 GL_TRUE
, /* double */
380 GL_FALSE
, /* stereo */
381 DEFAULT_SOFTWARE_DEPTH_BITS
,
382 8 * sizeof(GLstencil
),
383 0 * sizeof(GLaccum
), /* r */
384 0 * sizeof(GLaccum
), /* g */
385 0 * sizeof(GLaccum
), /* b */
386 0 * sizeof(GLaccum
), /* a */
391 /* Configure this visual as RGB, double-buffered, depth-buffered. */
392 /* This is surely wrong for some people's needs but what else */
393 /* can be done? They should use glXChooseVisual(). */
394 return save_glx_visual( dpy
, visinfo
,
396 GL_FALSE
, /* alpha */
397 GL_TRUE
, /* double */
398 GL_FALSE
, /* stereo */
399 DEFAULT_SOFTWARE_DEPTH_BITS
,
400 8 * sizeof(GLstencil
),
401 8 * sizeof(GLaccum
), /* r */
402 8 * sizeof(GLaccum
), /* g */
403 8 * sizeof(GLaccum
), /* b */
404 8 * sizeof(GLaccum
), /* a */
410 _mesa_warning(NULL
, "Mesa: error in glXCreateContext: bad visual\n");
418 * Find the GLX visual associated with an XVisualInfo.
421 find_glx_visual( Display
*dpy
, XVisualInfo
*vinfo
)
425 /* try to match visual id */
426 for (i
=0;i
<NumVisuals
;i
++) {
427 if (VisualTable
[i
]->display
==dpy
428 && VisualTable
[i
]->visinfo
->visualid
== vinfo
->visualid
) {
429 return VisualTable
[i
];
433 /* if that fails, try to match pointers */
434 for (i
=0;i
<NumVisuals
;i
++) {
435 if (VisualTable
[i
]->display
==dpy
&& VisualTable
[i
]->vishandle
==vinfo
) {
436 return VisualTable
[i
];
446 * Return the transparent pixel value for a GLX visual.
447 * Input: glxvis - the glx_visual
448 * Return: a pixel value or -1 if no transparent pixel
450 static int transparent_pixel( XMesaVisual glxvis
)
452 Display
*dpy
= glxvis
->display
;
453 XVisualInfo
*vinfo
= glxvis
->visinfo
;
454 Atom overlayVisualsAtom
;
455 OverlayInfo
*overlay_info
= NULL
;
456 int numOverlaysPerScreen
;
460 unsigned long sizeData
, bytesLeft
;
464 * The SERVER_OVERLAY_VISUALS property on the root window contains
465 * a list of overlay visuals. Get that list now.
467 overlayVisualsAtom
= XInternAtom(dpy
,"SERVER_OVERLAY_VISUALS", True
);
468 if (overlayVisualsAtom
== None
) {
472 status
= XGetWindowProperty(dpy
, RootWindow( dpy
, vinfo
->screen
),
473 overlayVisualsAtom
, 0L, (long) 10000, False
,
474 overlayVisualsAtom
, &actualType
, &actualFormat
,
475 &sizeData
, &bytesLeft
,
476 (unsigned char **) &overlay_info
);
478 if (status
!= Success
|| actualType
!= overlayVisualsAtom
||
479 actualFormat
!= 32 || sizeData
< 4) {
480 /* something went wrong */
481 XFree((void *) overlay_info
);
485 /* search the overlay visual list for the visual ID of interest */
486 numOverlaysPerScreen
= (int) (sizeData
/ 4);
487 for (i
=0;i
<numOverlaysPerScreen
;i
++) {
489 ov
= overlay_info
+ i
;
490 if (ov
->overlay_visual
==vinfo
->visualid
) {
492 if (ov
->transparent_type
==0) {
493 /* type 0 indicates no transparency */
494 XFree((void *) overlay_info
);
498 /* ov->value is the transparent pixel */
499 XFree((void *) overlay_info
);
505 /* The visual ID was not found in the overlay list. */
506 XFree((void *) overlay_info
);
513 * Try to get an X visual which matches the given arguments.
515 static XVisualInfo
*get_visual( Display
*dpy
, int scr
,
516 unsigned int depth
, int xclass
)
518 XVisualInfo temp
, *vis
;
521 unsigned int default_depth
;
524 mask
= VisualScreenMask
| VisualDepthMask
| VisualClassMask
;
529 default_depth
= DefaultDepth(dpy
,scr
);
530 default_class
= DefaultVisual(dpy
,scr
)->CLASS
;
532 if (depth
==default_depth
&& xclass
==default_class
) {
533 /* try to get root window's visual */
534 temp
.visualid
= DefaultVisual(dpy
,scr
)->visualid
;
535 mask
|= VisualIDMask
;
538 vis
= XGetVisualInfo( dpy
, mask
, &temp
, &n
);
540 /* In case bits/pixel > 24, make sure color channels are still <=8 bits.
541 * An SGI Infinite Reality system, for example, can have 30bpp pixels:
542 * 10 bits per color channel. Mesa's limited to a max of 8 bits/channel.
544 if (vis
&& depth
> 24 && (xclass
==TrueColor
|| xclass
==DirectColor
)) {
545 if (_mesa_bitcount((GLuint
) vis
->red_mask
) <= 8 &&
546 _mesa_bitcount((GLuint
) vis
->green_mask
) <= 8 &&
547 _mesa_bitcount((GLuint
) vis
->blue_mask
) <= 8) {
562 * Retrieve the value of the given environment variable and find
563 * the X visual which matches it.
564 * Input: dpy - the display
565 * screen - the screen number
566 * varname - the name of the environment variable
567 * Return: an XVisualInfo pointer to NULL if error.
569 static XVisualInfo
*get_env_visual(Display
*dpy
, int scr
, const char *varname
)
571 char value
[100], type
[100];
572 int depth
, xclass
= -1;
575 if (!_mesa_getenv( varname
)) {
579 _mesa_strncpy( value
, _mesa_getenv(varname
), 100 );
582 sscanf( value
, "%s %d", type
, &depth
);
584 if (_mesa_strcmp(type
,"TrueColor")==0) xclass
= TrueColor
;
585 else if (_mesa_strcmp(type
,"DirectColor")==0) xclass
= DirectColor
;
586 else if (_mesa_strcmp(type
,"PseudoColor")==0) xclass
= PseudoColor
;
587 else if (_mesa_strcmp(type
,"StaticColor")==0) xclass
= StaticColor
;
588 else if (_mesa_strcmp(type
,"GrayScale")==0) xclass
= GrayScale
;
589 else if (_mesa_strcmp(type
,"StaticGray")==0) xclass
= StaticGray
;
591 if (xclass
>-1 && depth
>0) {
592 vis
= get_visual( dpy
, scr
, depth
, xclass
);
598 _mesa_warning(NULL
, "GLX unable to find visual class=%s, depth=%d.",
607 * Select an X visual which satisfies the RGBA/CI flag and minimum depth.
608 * Input: dpy, screen - X display and screen number
609 * rgba - GL_TRUE = RGBA mode, GL_FALSE = CI mode
610 * min_depth - minimum visual depth
611 * preferred_class - preferred GLX visual class or DONT_CARE
612 * Return: pointer to an XVisualInfo or NULL.
614 static XVisualInfo
*choose_x_visual( Display
*dpy
, int screen
,
615 GLboolean rgba
, int min_depth
,
616 int preferred_class
)
619 int xclass
, visclass
= 0;
623 Atom hp_cr_maps
= XInternAtom(dpy
, "_HP_RGB_SMOOTH_MAP_LIST", True
);
624 /* First see if the MESA_RGB_VISUAL env var is defined */
625 vis
= get_env_visual( dpy
, screen
, "MESA_RGB_VISUAL" );
629 /* Otherwise, search for a suitable visual */
630 if (preferred_class
==DONT_CARE
) {
631 for (xclass
=0;xclass
<6;xclass
++) {
633 case 0: visclass
= TrueColor
; break;
634 case 1: visclass
= DirectColor
; break;
635 case 2: visclass
= PseudoColor
; break;
636 case 3: visclass
= StaticColor
; break;
637 case 4: visclass
= GrayScale
; break;
638 case 5: visclass
= StaticGray
; break;
641 /* start with shallowest */
642 for (depth
=0;depth
<=32;depth
++) {
643 if (visclass
==TrueColor
&& depth
==8 && !hp_cr_maps
) {
644 /* Special case: try to get 8-bit PseudoColor before */
645 /* 8-bit TrueColor */
646 vis
= get_visual( dpy
, screen
, 8, PseudoColor
);
651 vis
= get_visual( dpy
, screen
, depth
, visclass
);
658 /* start with deepest */
659 for (depth
=32;depth
>=min_depth
;depth
--) {
660 if (visclass
==TrueColor
&& depth
==8 && !hp_cr_maps
) {
661 /* Special case: try to get 8-bit PseudoColor before */
662 /* 8-bit TrueColor */
663 vis
= get_visual( dpy
, screen
, 8, PseudoColor
);
668 vis
= get_visual( dpy
, screen
, depth
, visclass
);
677 /* search for a specific visual class */
678 switch (preferred_class
) {
679 case GLX_TRUE_COLOR_EXT
: visclass
= TrueColor
; break;
680 case GLX_DIRECT_COLOR_EXT
: visclass
= DirectColor
; break;
681 case GLX_PSEUDO_COLOR_EXT
: visclass
= PseudoColor
; break;
682 case GLX_STATIC_COLOR_EXT
: visclass
= StaticColor
; break;
683 case GLX_GRAY_SCALE_EXT
: visclass
= GrayScale
; break;
684 case GLX_STATIC_GRAY_EXT
: visclass
= StaticGray
; break;
685 default: return NULL
;
688 /* start with shallowest */
689 for (depth
=0;depth
<=32;depth
++) {
690 vis
= get_visual( dpy
, screen
, depth
, visclass
);
697 /* start with deepest */
698 for (depth
=32;depth
>=min_depth
;depth
--) {
699 vis
= get_visual( dpy
, screen
, depth
, visclass
);
708 /* First see if the MESA_CI_VISUAL env var is defined */
709 vis
= get_env_visual( dpy
, screen
, "MESA_CI_VISUAL" );
713 /* Otherwise, search for a suitable visual, starting with shallowest */
714 if (preferred_class
==DONT_CARE
) {
715 for (xclass
=0;xclass
<4;xclass
++) {
717 case 0: visclass
= PseudoColor
; break;
718 case 1: visclass
= StaticColor
; break;
719 case 2: visclass
= GrayScale
; break;
720 case 3: visclass
= StaticGray
; break;
722 /* try 8-bit up through 16-bit */
723 for (depth
=8;depth
<=16;depth
++) {
724 vis
= get_visual( dpy
, screen
, depth
, visclass
);
729 /* try min_depth up to 8-bit */
730 for (depth
=min_depth
;depth
<8;depth
++) {
731 vis
= get_visual( dpy
, screen
, depth
, visclass
);
739 /* search for a specific visual class */
740 switch (preferred_class
) {
741 case GLX_TRUE_COLOR_EXT
: visclass
= TrueColor
; break;
742 case GLX_DIRECT_COLOR_EXT
: visclass
= DirectColor
; break;
743 case GLX_PSEUDO_COLOR_EXT
: visclass
= PseudoColor
; break;
744 case GLX_STATIC_COLOR_EXT
: visclass
= StaticColor
; break;
745 case GLX_GRAY_SCALE_EXT
: visclass
= GrayScale
; break;
746 case GLX_STATIC_GRAY_EXT
: visclass
= StaticGray
; break;
747 default: return NULL
;
749 /* try 8-bit up through 16-bit */
750 for (depth
=8;depth
<=16;depth
++) {
751 vis
= get_visual( dpy
, screen
, depth
, visclass
);
756 /* try min_depth up to 8-bit */
757 for (depth
=min_depth
;depth
<8;depth
++) {
758 vis
= get_visual( dpy
, screen
, depth
, visclass
);
766 /* didn't find a visual */
773 * Find the deepest X over/underlay visual of at least min_depth.
774 * Input: dpy, screen - X display and screen number
775 * level - the over/underlay level
776 * trans_type - transparent pixel type: GLX_NONE_EXT,
777 * GLX_TRANSPARENT_RGB_EXT, GLX_TRANSPARENT_INDEX_EXT,
779 * trans_value - transparent pixel value or DONT_CARE
780 * min_depth - minimum visual depth
781 * preferred_class - preferred GLX visual class or DONT_CARE
782 * Return: pointer to an XVisualInfo or NULL.
784 static XVisualInfo
*choose_x_overlay_visual( Display
*dpy
, int scr
,
786 int level
, int trans_type
,
789 int preferred_class
)
791 Atom overlayVisualsAtom
;
792 OverlayInfo
*overlay_info
;
793 int numOverlaysPerScreen
;
797 unsigned long sizeData
, bytesLeft
;
799 XVisualInfo
*deepvis
;
802 /*DEBUG int tt, tv; */
804 switch (preferred_class
) {
805 case GLX_TRUE_COLOR_EXT
: preferred_class
= TrueColor
; break;
806 case GLX_DIRECT_COLOR_EXT
: preferred_class
= DirectColor
; break;
807 case GLX_PSEUDO_COLOR_EXT
: preferred_class
= PseudoColor
; break;
808 case GLX_STATIC_COLOR_EXT
: preferred_class
= StaticColor
; break;
809 case GLX_GRAY_SCALE_EXT
: preferred_class
= GrayScale
; break;
810 case GLX_STATIC_GRAY_EXT
: preferred_class
= StaticGray
; break;
811 default: preferred_class
= DONT_CARE
;
815 * The SERVER_OVERLAY_VISUALS property on the root window contains
816 * a list of overlay visuals. Get that list now.
818 overlayVisualsAtom
= XInternAtom(dpy
,"SERVER_OVERLAY_VISUALS", True
);
819 if (overlayVisualsAtom
== (Atom
) None
) {
823 status
= XGetWindowProperty(dpy
, RootWindow( dpy
, scr
),
824 overlayVisualsAtom
, 0L, (long) 10000, False
,
825 overlayVisualsAtom
, &actualType
, &actualFormat
,
826 &sizeData
, &bytesLeft
,
827 (unsigned char **) &overlay_info
);
829 if (status
!= Success
|| actualType
!= overlayVisualsAtom
||
830 actualFormat
!= 32 || sizeData
< 4) {
831 /* something went wrong */
835 /* Search for the deepest overlay which satisifies all criteria. */
839 numOverlaysPerScreen
= (int) (sizeData
/ 4);
840 for (i
=0;i
<numOverlaysPerScreen
;i
++) {
841 XVisualInfo
*vislist
, vistemplate
;
844 ov
= overlay_info
+ i
;
846 if (ov
->layer
!=level
) {
847 /* failed overlay level criteria */
850 if (!(trans_type
==DONT_CARE
851 || (trans_type
==GLX_TRANSPARENT_INDEX_EXT
852 && ov
->transparent_type
>0)
853 || (trans_type
==GLX_NONE_EXT
&& ov
->transparent_type
==0))) {
854 /* failed transparent pixel type criteria */
857 if (trans_value
!=DONT_CARE
&& trans_value
!=ov
->value
) {
858 /* failed transparent pixel value criteria */
862 /* get XVisualInfo and check the depth */
863 vistemplate
.visualid
= ov
->overlay_visual
;
864 vistemplate
.screen
= scr
;
865 vislist
= XGetVisualInfo( dpy
, VisualIDMask
| VisualScreenMask
,
866 &vistemplate
, &count
);
869 /* something went wrong */
872 if (preferred_class
!=DONT_CARE
&& preferred_class
!=vislist
->CLASS
) {
873 /* wrong visual class */
877 /* if RGB was requested, make sure we have True/DirectColor */
878 if (rgbFlag
&& vislist
->CLASS
!= TrueColor
879 && vislist
->CLASS
!= DirectColor
)
882 /* if CI was requested, make sure we have a color indexed visual */
884 && (vislist
->CLASS
== TrueColor
|| vislist
->CLASS
== DirectColor
))
887 if (deepvis
==NULL
|| vislist
->depth
> deepest
) {
888 /* YES! found a satisfactory visual */
892 deepest
= vislist
->depth
;
894 /* DEBUG tt = ov->transparent_type;*/
895 /* DEBUG tv = ov->value; */
901 printf("chose 0x%x: layer=%d depth=%d trans_type=%d trans_value=%d\n",
902 deepvis->visualid, level, deepvis->depth, tt, tv );
909 /**********************************************************************/
910 /*** Begin Fake GLX API Functions ***/
911 /**********************************************************************/
914 static XMesaVisual
choose_visual( Display
*dpy
, int screen
, const int *list
)
916 const int *parselist
;
919 int min_red
=0, min_green
=0, min_blue
=0;
920 GLboolean rgb_flag
= GL_FALSE
;
921 GLboolean alpha_flag
= GL_FALSE
;
922 GLboolean double_flag
= GL_FALSE
;
923 GLboolean stereo_flag
= GL_FALSE
;
924 GLint depth_size
= 0;
925 GLint stencil_size
= 0;
926 GLint accumRedSize
= 0;
927 GLint accumGreenSize
= 0;
928 GLint accumBlueSize
= 0;
929 GLint accumAlphaSize
= 0;
931 int visual_type
= DONT_CARE
;
932 int trans_type
= DONT_CARE
;
933 int trans_value
= DONT_CARE
;
934 GLint caveat
= DONT_CARE
;
935 XMesaVisual xmvis
= NULL
;
941 switch (*parselist
) {
946 case GLX_BUFFER_SIZE
:
948 min_ci
= *parselist
++;
952 level
= *parselist
++;
958 case GLX_DOUBLEBUFFER
:
959 double_flag
= GL_TRUE
;
963 stereo_flag
= GL_TRUE
;
965 case GLX_AUX_BUFFERS
:
972 min_red
= *parselist
++;
976 min_green
= *parselist
++;
980 min_blue
= *parselist
++;
985 GLint size
= *parselist
++;
986 alpha_flag
= size
>0 ? 1 : 0;
991 depth_size
= *parselist
++;
993 case GLX_STENCIL_SIZE
:
995 stencil_size
= *parselist
++;
997 case GLX_ACCUM_RED_SIZE
:
1000 GLint size
= *parselist
++;
1001 accumRedSize
= MAX2( accumRedSize
, size
);
1004 case GLX_ACCUM_GREEN_SIZE
:
1007 GLint size
= *parselist
++;
1008 accumGreenSize
= MAX2( accumGreenSize
, size
);
1011 case GLX_ACCUM_BLUE_SIZE
:
1014 GLint size
= *parselist
++;
1015 accumBlueSize
= MAX2( accumBlueSize
, size
);
1018 case GLX_ACCUM_ALPHA_SIZE
:
1021 GLint size
= *parselist
++;
1022 accumAlphaSize
= MAX2( accumAlphaSize
, size
);
1027 * GLX_EXT_visual_info extension
1029 case GLX_X_VISUAL_TYPE_EXT
:
1031 visual_type
= *parselist
++;
1033 case GLX_TRANSPARENT_TYPE_EXT
:
1035 trans_type
= *parselist
++;
1037 case GLX_TRANSPARENT_INDEX_VALUE_EXT
:
1039 trans_value
= *parselist
++;
1041 case GLX_TRANSPARENT_RED_VALUE_EXT
:
1042 case GLX_TRANSPARENT_GREEN_VALUE_EXT
:
1043 case GLX_TRANSPARENT_BLUE_VALUE_EXT
:
1044 case GLX_TRANSPARENT_ALPHA_VALUE_EXT
:
1051 * GLX_EXT_visual_info extension
1053 case GLX_VISUAL_CAVEAT_EXT
:
1055 caveat
= *parselist
++; /* ignored for now */
1059 * GLX_ARB_multisample
1061 case GLX_SAMPLE_BUFFERS_ARB
:
1062 /* ms not supported */
1064 case GLX_SAMPLES_ARB
:
1065 /* ms not supported */
1071 case GLX_RENDER_TYPE
:
1073 if (*parselist
== GLX_RGBA_BIT
) {
1076 else if (*parselist
== GLX_COLOR_INDEX_BIT
) {
1077 rgb_flag
= GL_FALSE
;
1079 else if (*parselist
== 0) {
1084 case GLX_DRAWABLE_TYPE
:
1086 if (*parselist
& ~(GLX_WINDOW_BIT
| GLX_PIXMAP_BIT
| GLX_PBUFFER_BIT
)) {
1087 return NULL
; /* bad bit */
1096 /* undefined attribute */
1097 _mesa_warning(NULL
, "unexpected attrib 0x%x in choose_visual()",
1106 * Since we're only simulating the GLX extension this function will never
1107 * find any real GL visuals. Instead, all we can do is try to find an RGB
1108 * or CI visual of appropriate depth. Other requested attributes such as
1109 * double buffering, depth buffer, etc. will be associated with the X
1110 * visual and stored in the VisualTable[].
1113 /* normal color planes */
1115 /* Get an RGB visual */
1116 int min_rgb
= min_red
+ min_green
+ min_blue
;
1117 if (min_rgb
>1 && min_rgb
<8) {
1118 /* a special case to be sure we can get a monochrome visual */
1121 vis
= choose_x_visual( dpy
, screen
, rgb_flag
, min_rgb
, visual_type
);
1124 /* Get a color index visual */
1125 vis
= choose_x_visual( dpy
, screen
, rgb_flag
, min_ci
, visual_type
);
1126 accumRedSize
= accumGreenSize
= accumBlueSize
= accumAlphaSize
= 0;
1130 /* over/underlay planes */
1133 int min_rgb
= min_red
+ min_green
+ min_blue
;
1134 if (min_rgb
>1 && min_rgb
<8) {
1135 /* a special case to be sure we can get a monochrome visual */
1138 vis
= choose_x_overlay_visual( dpy
, screen
, rgb_flag
, level
,
1139 trans_type
, trans_value
, min_rgb
, visual_type
);
1142 /* color index overlay */
1143 vis
= choose_x_overlay_visual( dpy
, screen
, rgb_flag
, level
,
1144 trans_type
, trans_value
, min_ci
, visual_type
);
1149 /* Note: we're not exactly obeying the glXChooseVisual rules here.
1150 * When GLX_DEPTH_SIZE = 1 is specified we're supposed to choose the
1151 * largest depth buffer size, which is 32bits/value. Instead, we
1152 * return 16 to maintain performance with earlier versions of Mesa.
1154 if (depth_size
> 24)
1155 depth_size
= 31; /* 32 causes int overflow problems */
1156 else if (depth_size
> 16)
1158 else if (depth_size
> 0)
1159 depth_size
= DEFAULT_SOFTWARE_DEPTH_BITS
; /*16*/
1161 /* we only support one size of stencil and accum buffers. */
1162 if (stencil_size
> 0)
1163 stencil_size
= STENCIL_BITS
;
1164 if (accumRedSize
> 0 || accumGreenSize
> 0 || accumBlueSize
> 0 ||
1165 accumAlphaSize
> 0) {
1166 accumRedSize
= ACCUM_BITS
;
1167 accumGreenSize
= ACCUM_BITS
;
1168 accumBlueSize
= ACCUM_BITS
;
1169 accumAlphaSize
= alpha_flag
? ACCUM_BITS
: 0;
1172 xmvis
= save_glx_visual( dpy
, vis
, rgb_flag
, alpha_flag
, double_flag
,
1173 stereo_flag
, depth_size
, stencil_size
,
1174 accumRedSize
, accumGreenSize
,
1175 accumBlueSize
, accumAlphaSize
, level
);
1182 static XVisualInfo
*
1183 Fake_glXChooseVisual( Display
*dpy
, int screen
, int *list
)
1185 XMesaVisual xmvis
= choose_visual(dpy
, screen
, list
);
1188 return xmvis
->vishandle
;
1190 /* create a new vishandle - the cached one may be stale */
1191 xmvis
->vishandle
= (XVisualInfo
*) _mesa_malloc(sizeof(XVisualInfo
));
1192 if (xmvis
->vishandle
) {
1193 _mesa_memcpy(xmvis
->vishandle
, xmvis
->visinfo
, sizeof(XVisualInfo
));
1195 return xmvis
->vishandle
;
1204 Fake_glXCreateContext( Display
*dpy
, XVisualInfo
*visinfo
,
1205 GLXContext share_list
, Bool direct
)
1208 struct fake_glx_context
*glxCtx
;
1209 struct fake_glx_context
*shareCtx
= (struct fake_glx_context
*) share_list
;
1211 if (!dpy
|| !visinfo
)
1214 glxCtx
= CALLOC_STRUCT(fake_glx_context
);
1218 /* deallocate unused windows/buffers */
1219 XMesaGarbageCollect();
1221 xmvis
= find_glx_visual( dpy
, visinfo
);
1223 /* This visual wasn't found with glXChooseVisual() */
1224 xmvis
= create_glx_visual( dpy
, visinfo
);
1226 /* unusable visual */
1232 glxCtx
->xmesaContext
= XMesaCreateContext(xmvis
,
1233 shareCtx
? shareCtx
->xmesaContext
: NULL
);
1234 if (!glxCtx
->xmesaContext
) {
1239 glxCtx
->xmesaContext
->direct
= GL_FALSE
;
1240 glxCtx
->glxContext
.isDirect
= GL_FALSE
;
1241 glxCtx
->glxContext
.currentDpy
= dpy
;
1242 glxCtx
->glxContext
.xid
= (XID
) glxCtx
; /* self pointer */
1244 assert((void *) glxCtx
== (void *) &(glxCtx
->glxContext
));
1246 return (GLXContext
) glxCtx
;
1250 /* XXX these may have to be removed due to thread-safety issues. */
1251 static GLXContext MakeCurrent_PrevContext
= 0;
1252 static GLXDrawable MakeCurrent_PrevDrawable
= 0;
1253 static GLXDrawable MakeCurrent_PrevReadable
= 0;
1254 static XMesaBuffer MakeCurrent_PrevDrawBuffer
= 0;
1255 static XMesaBuffer MakeCurrent_PrevReadBuffer
= 0;
1258 /* GLX 1.3 and later */
1260 Fake_glXMakeContextCurrent( Display
*dpy
, GLXDrawable draw
,
1261 GLXDrawable read
, GLXContext ctx
)
1263 struct fake_glx_context
*glxCtx
= (struct fake_glx_context
*) ctx
;
1265 if (ctx
&& draw
&& read
) {
1266 XMesaBuffer drawBuffer
, readBuffer
;
1267 XMesaContext xmctx
= glxCtx
->xmesaContext
;
1269 /* Find the XMesaBuffer which corresponds to the GLXDrawable 'draw' */
1270 if (ctx
== MakeCurrent_PrevContext
1271 && draw
== MakeCurrent_PrevDrawable
) {
1272 drawBuffer
= MakeCurrent_PrevDrawBuffer
;
1275 drawBuffer
= XMesaFindBuffer( dpy
, draw
);
1278 /* drawable must be a new window! */
1279 drawBuffer
= XMesaCreateWindowBuffer2( xmctx
->xm_visual
, draw
, xmctx
);
1281 /* Out of memory, or context/drawable depth mismatch */
1286 /* Find the XMesaBuffer which corresponds to the GLXDrawable 'read' */
1287 if (ctx
== MakeCurrent_PrevContext
1288 && read
== MakeCurrent_PrevReadable
) {
1289 readBuffer
= MakeCurrent_PrevReadBuffer
;
1292 readBuffer
= XMesaFindBuffer( dpy
, read
);
1295 /* drawable must be a new window! */
1296 readBuffer
= XMesaCreateWindowBuffer2(glxCtx
->xmesaContext
->xm_visual
,
1299 /* Out of memory, or context/drawable depth mismatch */
1304 MakeCurrent_PrevContext
= ctx
;
1305 MakeCurrent_PrevDrawable
= draw
;
1306 MakeCurrent_PrevReadable
= read
;
1307 MakeCurrent_PrevDrawBuffer
= drawBuffer
;
1308 MakeCurrent_PrevReadBuffer
= readBuffer
;
1310 /* Now make current! */
1311 if (XMesaMakeCurrent2(xmctx
, drawBuffer
, readBuffer
)) {
1312 ((__GLXcontext
*) ctx
)->currentDpy
= dpy
;
1313 ((__GLXcontext
*) ctx
)->currentDrawable
= draw
;
1314 #ifndef GLX_BUILT_IN_XMESA
1315 ((__GLXcontext
*) ctx
)->currentReadable
= read
;
1317 __glXSetCurrentContext(ctx
);
1325 else if (!ctx
&& !draw
&& !read
) {
1326 /* release current context w/out assigning new one. */
1327 XMesaMakeCurrent( NULL
, NULL
);
1328 MakeCurrent_PrevContext
= 0;
1329 MakeCurrent_PrevDrawable
= 0;
1330 MakeCurrent_PrevReadable
= 0;
1331 MakeCurrent_PrevDrawBuffer
= 0;
1332 MakeCurrent_PrevReadBuffer
= 0;
1333 #ifdef GLX_BUILT_IN_XMESA
1334 /* XXX bind dummy context with __glXSetCurrentContext(ctx); */
1339 /* The args must either all be non-zero or all zero.
1349 Fake_glXMakeCurrent( Display
*dpy
, GLXDrawable drawable
, GLXContext ctx
)
1351 return Fake_glXMakeContextCurrent( dpy
, drawable
, drawable
, ctx
);
1357 Fake_glXCreateGLXPixmap( Display
*dpy
, XVisualInfo
*visinfo
, Pixmap pixmap
)
1362 v
= find_glx_visual( dpy
, visinfo
);
1364 v
= create_glx_visual( dpy
, visinfo
);
1366 /* unusable visual */
1371 b
= XMesaCreatePixmapBuffer( v
, pixmap
, 0 );
1375 return b
->frontbuffer
;
1379 /*** GLX_MESA_pixmap_colormap ***/
1382 Fake_glXCreateGLXPixmapMESA( Display
*dpy
, XVisualInfo
*visinfo
,
1383 Pixmap pixmap
, Colormap cmap
)
1388 v
= find_glx_visual( dpy
, visinfo
);
1390 v
= create_glx_visual( dpy
, visinfo
);
1392 /* unusable visual */
1397 b
= XMesaCreatePixmapBuffer( v
, pixmap
, cmap
);
1401 return b
->frontbuffer
;
1406 Fake_glXDestroyGLXPixmap( Display
*dpy
, GLXPixmap pixmap
)
1408 XMesaBuffer b
= XMesaFindBuffer(dpy
, pixmap
);
1410 XMesaDestroyBuffer(b
);
1412 else if (_mesa_getenv("MESA_DEBUG")) {
1413 _mesa_warning(NULL
, "Mesa: glXDestroyGLXPixmap: invalid pixmap\n");
1420 Fake_glXCopyContext( Display
*dpy
, GLXContext src
, GLXContext dst
,
1421 unsigned long mask
)
1423 struct fake_glx_context
*fakeSrc
= (struct fake_glx_context
*) src
;
1424 struct fake_glx_context
*fakeDst
= (struct fake_glx_context
*) dst
;
1425 XMesaContext xm_src
= fakeSrc
->xmesaContext
;
1426 XMesaContext xm_dst
= fakeDst
->xmesaContext
;
1428 _mesa_copy_context( &(xm_src
->mesa
), &(xm_dst
->mesa
), (GLuint
) mask
);
1434 Fake_glXQueryExtension( Display
*dpy
, int *errorb
, int *event
)
1436 /* Mesa's GLX isn't really an X extension but we try to act like one. */
1444 extern void _kw_ungrab_all( Display
*dpy
);
1445 void _kw_ungrab_all( Display
*dpy
)
1447 XUngrabPointer( dpy
, CurrentTime
);
1448 XUngrabKeyboard( dpy
, CurrentTime
);
1453 Fake_glXDestroyContext( Display
*dpy
, GLXContext ctx
)
1455 struct fake_glx_context
*glxCtx
= (struct fake_glx_context
*) ctx
;
1457 MakeCurrent_PrevContext
= 0;
1458 MakeCurrent_PrevDrawable
= 0;
1459 MakeCurrent_PrevReadable
= 0;
1460 MakeCurrent_PrevDrawBuffer
= 0;
1461 MakeCurrent_PrevReadBuffer
= 0;
1462 XMesaDestroyContext( glxCtx
->xmesaContext
);
1463 XMesaGarbageCollect();
1469 Fake_glXIsDirect( Display
*dpy
, GLXContext ctx
)
1471 struct fake_glx_context
*glxCtx
= (struct fake_glx_context
*) ctx
;
1473 return glxCtx
->xmesaContext
->direct
;
1479 Fake_glXSwapBuffers( Display
*dpy
, GLXDrawable drawable
)
1481 XMesaBuffer buffer
= XMesaFindBuffer( dpy
, drawable
);
1484 XMesaSwapBuffers(buffer
);
1486 else if (_mesa_getenv("MESA_DEBUG")) {
1487 _mesa_warning(NULL
, "Mesa: glXSwapBuffers: invalid drawable\n");
1493 /*** GLX_MESA_copy_sub_buffer ***/
1496 Fake_glXCopySubBufferMESA( Display
*dpy
, GLXDrawable drawable
,
1497 int x
, int y
, int width
, int height
)
1499 XMesaBuffer buffer
= XMesaFindBuffer( dpy
, drawable
);
1501 XMesaCopySubBuffer(buffer
, x
, y
, width
, height
);
1503 else if (_mesa_getenv("MESA_DEBUG")) {
1504 _mesa_warning(NULL
, "Mesa: glXCopySubBufferMESA: invalid drawable\n");
1511 Fake_glXQueryVersion( Display
*dpy
, int *maj
, int *min
)
1514 /* Return GLX version, not Mesa version */
1515 assert(CLIENT_MAJOR_VERSION
== SERVER_MAJOR_VERSION
);
1516 *maj
= CLIENT_MAJOR_VERSION
;
1517 *min
= MIN2( CLIENT_MINOR_VERSION
, SERVER_MINOR_VERSION
);
1524 * Query the GLX attributes of the given XVisualInfo.
1527 get_config( XMesaVisual xmvis
, int attrib
, int *value
, GLboolean fbconfig
)
1532 *value
= (int) True
;
1534 case GLX_BUFFER_SIZE
:
1535 *value
= xmvis
->visinfo
->depth
;
1538 *value
= xmvis
->level
;
1541 if (xmvis
->mesa_visual
.rgbMode
) {
1548 case GLX_DOUBLEBUFFER
:
1549 *value
= (int) xmvis
->mesa_visual
.doubleBufferMode
;
1552 *value
= (int) xmvis
->mesa_visual
.stereoMode
;
1554 case GLX_AUX_BUFFERS
:
1555 *value
= (int) False
;
1558 *value
= xmvis
->mesa_visual
.redBits
;
1560 case GLX_GREEN_SIZE
:
1561 *value
= xmvis
->mesa_visual
.greenBits
;
1564 *value
= xmvis
->mesa_visual
.blueBits
;
1566 case GLX_ALPHA_SIZE
:
1567 *value
= xmvis
->mesa_visual
.alphaBits
;
1569 case GLX_DEPTH_SIZE
:
1570 *value
= xmvis
->mesa_visual
.depthBits
;
1572 case GLX_STENCIL_SIZE
:
1573 *value
= xmvis
->mesa_visual
.stencilBits
;
1575 case GLX_ACCUM_RED_SIZE
:
1576 *value
= xmvis
->mesa_visual
.accumRedBits
;
1578 case GLX_ACCUM_GREEN_SIZE
:
1579 *value
= xmvis
->mesa_visual
.accumGreenBits
;
1581 case GLX_ACCUM_BLUE_SIZE
:
1582 *value
= xmvis
->mesa_visual
.accumBlueBits
;
1584 case GLX_ACCUM_ALPHA_SIZE
:
1585 *value
= xmvis
->mesa_visual
.accumAlphaBits
;
1589 * GLX_EXT_visual_info extension
1591 case GLX_X_VISUAL_TYPE_EXT
:
1592 switch (xmvis
->visinfo
->CLASS
) {
1593 case StaticGray
: *value
= GLX_STATIC_GRAY_EXT
; return 0;
1594 case GrayScale
: *value
= GLX_GRAY_SCALE_EXT
; return 0;
1595 case StaticColor
: *value
= GLX_STATIC_GRAY_EXT
; return 0;
1596 case PseudoColor
: *value
= GLX_PSEUDO_COLOR_EXT
; return 0;
1597 case TrueColor
: *value
= GLX_TRUE_COLOR_EXT
; return 0;
1598 case DirectColor
: *value
= GLX_DIRECT_COLOR_EXT
; return 0;
1601 case GLX_TRANSPARENT_TYPE_EXT
:
1602 if (xmvis
->level
==0) {
1604 *value
= GLX_NONE_EXT
;
1606 else if (xmvis
->level
>0) {
1608 if (xmvis
->mesa_visual
.rgbMode
) {
1609 *value
= GLX_TRANSPARENT_RGB_EXT
;
1612 *value
= GLX_TRANSPARENT_INDEX_EXT
;
1615 else if (xmvis
->level
<0) {
1617 *value
= GLX_NONE_EXT
;
1620 case GLX_TRANSPARENT_INDEX_VALUE_EXT
:
1622 int pixel
= transparent_pixel( xmvis
);
1626 /* else undefined */
1629 case GLX_TRANSPARENT_RED_VALUE_EXT
:
1632 case GLX_TRANSPARENT_GREEN_VALUE_EXT
:
1635 case GLX_TRANSPARENT_BLUE_VALUE_EXT
:
1638 case GLX_TRANSPARENT_ALPHA_VALUE_EXT
:
1643 * GLX_EXT_visual_info extension
1645 case GLX_VISUAL_CAVEAT_EXT
:
1646 /* test for zero, just in case */
1647 if (xmvis
->VisualCaveat
> 0)
1648 *value
= xmvis
->VisualCaveat
;
1650 *value
= GLX_NONE_EXT
;
1654 * GLX_ARB_multisample
1656 case GLX_SAMPLE_BUFFERS_ARB
:
1659 case GLX_SAMPLES_ARB
:
1666 case GLX_SCREEN_EXT
:
1668 return GLX_BAD_ATTRIBUTE
;
1669 *value
= xmvis
->visinfo
->screen
;
1671 case GLX_DRAWABLE_TYPE
: /*SGIX too */
1673 return GLX_BAD_ATTRIBUTE
;
1674 *value
= GLX_WINDOW_BIT
| GLX_PIXMAP_BIT
| GLX_PBUFFER_BIT
;
1676 case GLX_RENDER_TYPE_SGIX
:
1678 return GLX_BAD_ATTRIBUTE
;
1679 if (xmvis
->mesa_visual
.rgbMode
)
1680 *value
= GLX_RGBA_BIT
;
1682 *value
= GLX_COLOR_INDEX_BIT
;
1684 case GLX_X_RENDERABLE_SGIX
:
1686 return GLX_BAD_ATTRIBUTE
;
1687 *value
= True
; /* XXX really? */
1689 case GLX_FBCONFIG_ID_SGIX
:
1691 return GLX_BAD_ATTRIBUTE
;
1692 *value
= xmvis
->visinfo
->visualid
;
1694 case GLX_MAX_PBUFFER_WIDTH
:
1696 return GLX_BAD_ATTRIBUTE
;
1697 /* XXX or MAX_WIDTH? */
1698 *value
= DisplayWidth(xmvis
->display
, xmvis
->visinfo
->screen
);
1700 case GLX_MAX_PBUFFER_HEIGHT
:
1702 return GLX_BAD_ATTRIBUTE
;
1703 *value
= DisplayHeight(xmvis
->display
, xmvis
->visinfo
->screen
);
1705 case GLX_MAX_PBUFFER_PIXELS
:
1707 return GLX_BAD_ATTRIBUTE
;
1708 *value
= DisplayWidth(xmvis
->display
, xmvis
->visinfo
->screen
) *
1709 DisplayHeight(xmvis
->display
, xmvis
->visinfo
->screen
);
1713 return GLX_BAD_ATTRIBUTE
;
1714 *value
= xmvis
->visinfo
->visualid
;
1718 return GLX_BAD_ATTRIBUTE
;
1725 Fake_glXGetConfig( Display
*dpy
, XVisualInfo
*visinfo
,
1726 int attrib
, int *value
)
1730 xmvis
= find_glx_visual( dpy
, visinfo
);
1732 /* this visual wasn't obtained with glXChooseVisual */
1733 xmvis
= create_glx_visual( dpy
, visinfo
);
1735 /* this visual can't be used for GL rendering */
1736 if (attrib
==GLX_USE_GL
) {
1737 *value
= (int) False
;
1741 return GLX_BAD_VISUAL
;
1746 return get_config(xmvis
, attrib
, value
, GL_FALSE
);
1751 Fake_glXWaitGL( void )
1753 XMesaContext xmesa
= XMesaGetCurrentContext();
1754 XMesaFlush( xmesa
);
1760 Fake_glXWaitX( void )
1762 XMesaContext xmesa
= XMesaGetCurrentContext();
1763 XMesaFlush( xmesa
);
1768 get_extensions( void )
1771 const char *fx
= _mesa_getenv("MESA_GLX_FX");
1772 if (fx
&& fx
[0] != 'd') {
1776 return EXTENSIONS
+ 23; /* skip "GLX_MESA_set_3dfx_mode" */
1781 /* GLX 1.1 and later */
1783 Fake_glXQueryExtensionsString( Display
*dpy
, int screen
)
1787 return get_extensions();
1792 /* GLX 1.1 and later */
1794 Fake_glXQueryServerString( Display
*dpy
, int screen
, int name
)
1796 static char version
[1000];
1797 _mesa_sprintf(version
, "%d.%d %s",
1798 SERVER_MAJOR_VERSION
, SERVER_MINOR_VERSION
, MESA_GLX_VERSION
);
1804 case GLX_EXTENSIONS
:
1805 return get_extensions();
1817 /* GLX 1.1 and later */
1819 Fake_glXGetClientString( Display
*dpy
, int name
)
1821 static char version
[1000];
1822 _mesa_sprintf(version
, "%d.%d %s", CLIENT_MAJOR_VERSION
,
1823 CLIENT_MINOR_VERSION
, MESA_GLX_VERSION
);
1828 case GLX_EXTENSIONS
:
1829 return get_extensions();
1846 static GLXFBConfig
*
1847 Fake_glXChooseFBConfig( Display
*dpy
, int screen
,
1848 const int *attribList
, int *nitems
)
1850 XMesaVisual xmvis
= choose_visual(dpy
, screen
, attribList
);
1852 GLXFBConfig
*config
= (GLXFBConfig
*) _mesa_malloc(sizeof(XMesaVisual
));
1858 config
[0] = (GLXFBConfig
) xmvis
;
1859 return (GLXFBConfig
*) config
;
1869 Fake_glXGetFBConfigAttrib( Display
*dpy
, GLXFBConfig config
,
1870 int attribute
, int *value
)
1872 XMesaVisual v
= (XMesaVisual
) config
;
1876 if (!dpy
|| !config
|| !value
)
1879 return get_config(v
, attribute
, value
, GL_TRUE
);
1883 static GLXFBConfig
*
1884 Fake_glXGetFBConfigs( Display
*dpy
, int screen
, int *nelements
)
1886 XVisualInfo
*visuals
, visTemplate
;
1887 const long visMask
= VisualScreenMask
;
1890 /* Get list of all X visuals */
1891 visTemplate
.screen
= screen
;
1892 visuals
= XGetVisualInfo(dpy
, visMask
, &visTemplate
, nelements
);
1893 if (*nelements
> 0) {
1894 XMesaVisual
*results
;
1895 results
= (XMesaVisual
*) _mesa_malloc(*nelements
* sizeof(XMesaVisual
));
1900 for (i
= 0; i
< *nelements
; i
++) {
1901 results
[i
] = create_glx_visual(dpy
, visuals
+ i
);
1903 return (GLXFBConfig
*) results
;
1909 static XVisualInfo
*
1910 Fake_glXGetVisualFromFBConfig( Display
*dpy
, GLXFBConfig config
)
1912 if (dpy
&& config
) {
1913 XMesaVisual xmvis
= (XMesaVisual
) config
;
1915 return xmvis
->vishandle
;
1917 /* create a new vishandle - the cached one may be stale */
1918 xmvis
->vishandle
= (XVisualInfo
*) _mesa_malloc(sizeof(XVisualInfo
));
1919 if (xmvis
->vishandle
) {
1920 _mesa_memcpy(xmvis
->vishandle
, xmvis
->visinfo
, sizeof(XVisualInfo
));
1922 return xmvis
->vishandle
;
1932 Fake_glXCreateWindow( Display
*dpy
, GLXFBConfig config
, Window win
,
1933 const int *attribList
)
1938 (void) attribList
; /* Ignored in GLX 1.3 */
1940 return win
; /* A hack for now */
1945 Fake_glXDestroyWindow( Display
*dpy
, GLXWindow window
)
1947 XMesaBuffer b
= XMesaFindBuffer(dpy
, (XMesaDrawable
) window
);
1949 XMesaDestroyBuffer(b
);
1950 /* don't destroy X window */
1956 Fake_glXCreatePixmap( Display
*dpy
, GLXFBConfig config
, Pixmap pixmap
,
1957 const int *attribList
)
1959 XMesaVisual v
= (XMesaVisual
) config
;
1965 (void) attribList
; /* Ignored in GLX 1.3 */
1967 if (!dpy
|| !config
|| !pixmap
)
1970 b
= XMesaCreatePixmapBuffer( v
, pixmap
, 0 );
1980 Fake_glXDestroyPixmap( Display
*dpy
, GLXPixmap pixmap
)
1982 XMesaBuffer b
= XMesaFindBuffer(dpy
, (XMesaDrawable
)pixmap
);
1984 XMesaDestroyBuffer(b
);
1985 /* don't destroy X pixmap */
1990 Fake_glXCreatePbuffer( Display
*dpy
, GLXFBConfig config
,
1991 const int *attribList
)
1993 XMesaVisual xmvis
= (XMesaVisual
) config
;
1996 int width
= 0, height
= 0;
1997 GLboolean useLargest
= GL_FALSE
, preserveContents
= GL_FALSE
;
2001 for (attrib
= attribList
; *attrib
; attrib
++) {
2003 case GLX_PBUFFER_WIDTH
:
2007 case GLX_PBUFFER_HEIGHT
:
2011 case GLX_PRESERVED_CONTENTS
:
2013 preserveContents
= *attrib
; /* ignored */
2015 case GLX_LARGEST_PBUFFER
:
2017 useLargest
= *attrib
; /* ignored */
2024 /* not used at this time */
2026 (void) preserveContents
;
2028 if (width
== 0 || height
== 0)
2031 xmbuf
= XMesaCreatePBuffer( xmvis
, 0, width
, height
);
2032 /* A GLXPbuffer handle must be an X Drawable because that's what
2033 * glXMakeCurrent takes.
2035 return (GLXPbuffer
) xmbuf
->frontbuffer
;
2040 Fake_glXDestroyPbuffer( Display
*dpy
, GLXPbuffer pbuf
)
2042 XMesaBuffer b
= XMesaFindBuffer(dpy
, pbuf
);
2044 XMesaDestroyBuffer(b
);
2050 Fake_glXQueryDrawable( Display
*dpy
, GLXDrawable draw
, int attribute
,
2051 unsigned int *value
)
2053 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, draw
);
2057 switch (attribute
) {
2059 *value
= xmbuf
->width
;
2062 *value
= xmbuf
->height
;
2064 case GLX_PRESERVED_CONTENTS
:
2067 case GLX_LARGEST_PBUFFER
:
2068 *value
= xmbuf
->width
* xmbuf
->height
;
2070 case GLX_FBCONFIG_ID
:
2071 *value
= xmbuf
->xm_visual
->visinfo
->visualid
;
2074 return; /* GLX_BAD_ATTRIBUTE? */
2080 Fake_glXCreateNewContext( Display
*dpy
, GLXFBConfig config
,
2081 int renderType
, GLXContext shareList
, Bool direct
)
2083 struct fake_glx_context
*glxCtx
;
2084 struct fake_glx_context
*shareCtx
= (struct fake_glx_context
*) shareList
;
2085 XMesaVisual xmvis
= (XMesaVisual
) config
;
2087 if (!dpy
|| !config
||
2088 (renderType
!= GLX_RGBA_TYPE
&& renderType
!= GLX_COLOR_INDEX_TYPE
))
2091 glxCtx
= CALLOC_STRUCT(fake_glx_context
);
2095 /* deallocate unused windows/buffers */
2096 XMesaGarbageCollect();
2098 glxCtx
->xmesaContext
= XMesaCreateContext(xmvis
,
2099 shareCtx
? shareCtx
->xmesaContext
: NULL
);
2100 if (!glxCtx
->xmesaContext
) {
2105 glxCtx
->xmesaContext
->direct
= GL_FALSE
;
2106 glxCtx
->glxContext
.isDirect
= GL_FALSE
;
2107 glxCtx
->glxContext
.currentDpy
= dpy
;
2108 glxCtx
->glxContext
.xid
= (XID
) glxCtx
; /* self pointer */
2110 assert((void *) glxCtx
== (void *) &(glxCtx
->glxContext
));
2112 return (GLXContext
) glxCtx
;
2117 Fake_glXQueryContext( Display
*dpy
, GLXContext ctx
, int attribute
, int *value
)
2119 struct fake_glx_context
*glxCtx
= (struct fake_glx_context
*) ctx
;
2120 XMesaContext xmctx
= glxCtx
->xmesaContext
;
2125 switch (attribute
) {
2126 case GLX_FBCONFIG_ID
:
2127 *value
= xmctx
->xm_visual
->visinfo
->visualid
;
2129 case GLX_RENDER_TYPE
:
2130 if (xmctx
->xm_visual
->mesa_visual
.rgbMode
)
2131 *value
= GLX_RGBA_BIT
;
2133 *value
= GLX_COLOR_INDEX_BIT
;
2139 return GLX_BAD_ATTRIBUTE
;
2146 Fake_glXSelectEvent( Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
2148 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, drawable
);
2150 xmbuf
->selectedEvents
= mask
;
2155 Fake_glXGetSelectedEvent( Display
*dpy
, GLXDrawable drawable
,
2156 unsigned long *mask
)
2158 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, drawable
);
2160 *mask
= xmbuf
->selectedEvents
;
2167 /*** GLX_SGI_swap_control ***/
2170 Fake_glXSwapIntervalSGI(int interval
)
2178 /*** GLX_SGI_video_sync ***/
2181 Fake_glXGetVideoSyncSGI(unsigned int *count
)
2188 Fake_glXWaitVideoSyncSGI(int divisor
, int remainder
, unsigned int *count
)
2198 /*** GLX_SGI_make_current_read ***/
2201 Fake_glXMakeCurrentReadSGI(Display
*dpy
, GLXDrawable draw
, GLXDrawable read
, GLXContext ctx
)
2203 return Fake_glXMakeContextCurrent( dpy
, draw
, read
, ctx
);
2208 Fake_glXGetCurrentReadDrawableSGI(void)
2215 /*** GLX_SGIX_video_source ***/
2218 static GLXVideoSourceSGIX
2219 Fake_glXCreateGLXVideoSourceSGIX(Display
*dpy
, int screen
, VLServer server
, VLPath path
, int nodeClass
, VLNode drainNode
)
2231 Fake_glXDestroyGLXVideoSourceSGIX(Display
*dpy
, GLXVideoSourceSGIX src
)
2240 /*** GLX_EXT_import_context ***/
2243 Fake_glXFreeContextEXT(Display
*dpy
, GLXContext context
)
2250 Fake_glXGetContextIDEXT(const GLXContext context
)
2257 Fake_glXImportContextEXT(Display
*dpy
, GLXContextID contextID
)
2265 Fake_glXQueryContextInfoEXT(Display
*dpy
, GLXContext context
, int attribute
, int *value
)
2276 /*** GLX_SGIX_fbconfig ***/
2279 Fake_glXGetFBConfigAttribSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int attribute
, int *value
)
2281 return Fake_glXGetFBConfigAttrib(dpy
, config
, attribute
, value
);
2284 static GLXFBConfigSGIX
*
2285 Fake_glXChooseFBConfigSGIX(Display
*dpy
, int screen
, int *attrib_list
, int *nelements
)
2287 return (GLXFBConfig
*) Fake_glXChooseFBConfig(dpy
, screen
, attrib_list
, nelements
);
2292 Fake_glXCreateGLXPixmapWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, Pixmap pixmap
)
2294 XMesaVisual xmvis
= (XMesaVisual
) config
;
2295 XMesaBuffer xmbuf
= XMesaCreatePixmapBuffer(xmvis
, pixmap
, 0);
2296 return xmbuf
->frontbuffer
; /* need to return an X ID */
2301 Fake_glXCreateContextWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int render_type
, GLXContext share_list
, Bool direct
)
2303 XMesaVisual xmvis
= (XMesaVisual
) config
;
2304 struct fake_glx_context
*glxCtx
;
2305 struct fake_glx_context
*shareCtx
= (struct fake_glx_context
*) share_list
;
2307 glxCtx
= CALLOC_STRUCT(fake_glx_context
);
2311 /* deallocate unused windows/buffers */
2312 XMesaGarbageCollect();
2314 glxCtx
->xmesaContext
= XMesaCreateContext(xmvis
,
2315 shareCtx
? shareCtx
->xmesaContext
: NULL
);
2316 if (!glxCtx
->xmesaContext
) {
2321 glxCtx
->xmesaContext
->direct
= GL_FALSE
;
2322 glxCtx
->glxContext
.isDirect
= GL_FALSE
;
2323 glxCtx
->glxContext
.currentDpy
= dpy
;
2324 glxCtx
->glxContext
.xid
= (XID
) glxCtx
; /* self pointer */
2326 assert((void *) glxCtx
== (void *) &(glxCtx
->glxContext
));
2328 return (GLXContext
) glxCtx
;
2332 static XVisualInfo
*
2333 Fake_glXGetVisualFromFBConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
)
2335 return Fake_glXGetVisualFromFBConfig(dpy
, config
);
2339 static GLXFBConfigSGIX
2340 Fake_glXGetFBConfigFromVisualSGIX(Display
*dpy
, XVisualInfo
*vis
)
2342 XMesaVisual xmvis
= find_glx_visual(dpy
, vis
);
2344 /* This visual wasn't found with glXChooseVisual() */
2345 xmvis
= create_glx_visual(dpy
, vis
);
2348 return (GLXFBConfigSGIX
) xmvis
;
2353 /*** GLX_SGIX_pbuffer ***/
2355 static GLXPbufferSGIX
2356 Fake_glXCreateGLXPbufferSGIX(Display
*dpy
, GLXFBConfigSGIX config
,
2357 unsigned int width
, unsigned int height
,
2360 XMesaVisual xmvis
= (XMesaVisual
) config
;
2363 GLboolean useLargest
= GL_FALSE
, preserveContents
= GL_FALSE
;
2367 for (attrib
= attribList
; *attrib
; attrib
++) {
2369 case GLX_PRESERVED_CONTENTS_SGIX
:
2371 preserveContents
= *attrib
; /* ignored */
2373 case GLX_LARGEST_PBUFFER_SGIX
:
2375 useLargest
= *attrib
; /* ignored */
2382 /* not used at this time */
2384 (void) preserveContents
;
2386 xmbuf
= XMesaCreatePBuffer( xmvis
, 0, width
, height
);
2387 /* A GLXPbuffer handle must be an X Drawable because that's what
2388 * glXMakeCurrent takes.
2390 return (GLXPbuffer
) xmbuf
->frontbuffer
;
2395 Fake_glXDestroyGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
)
2397 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, pbuf
);
2399 XMesaDestroyBuffer(xmbuf
);
2405 Fake_glXQueryGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
, int attribute
, unsigned int *value
)
2407 const XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, pbuf
);
2410 /* Generate GLXBadPbufferSGIX for bad pbuffer */
2414 switch (attribute
) {
2415 case GLX_PRESERVED_CONTENTS_SGIX
:
2418 case GLX_LARGEST_PBUFFER_SGIX
:
2419 *value
= xmbuf
->width
* xmbuf
->height
;
2421 case GLX_WIDTH_SGIX
:
2422 *value
= xmbuf
->width
;
2424 case GLX_HEIGHT_SGIX
:
2425 *value
= xmbuf
->height
;
2427 case GLX_EVENT_MASK_SGIX
:
2428 *value
= 0; /* XXX might be wrong */
2438 Fake_glXSelectEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
2440 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, drawable
);
2442 /* Note: we'll never generate clobber events */
2443 xmbuf
->selectedEvents
= mask
;
2449 Fake_glXGetSelectedEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long *mask
)
2451 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, drawable
);
2453 *mask
= xmbuf
->selectedEvents
;
2462 /*** GLX_SGI_cushion ***/
2465 Fake_glXCushionSGI(Display
*dpy
, Window win
, float cushion
)
2474 /*** GLX_SGIX_video_resize ***/
2477 Fake_glXBindChannelToWindowSGIX(Display
*dpy
, int screen
, int channel
, Window window
)
2487 Fake_glXChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int x
, int y
, int w
, int h
)
2500 Fake_glXQueryChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int *x
, int *y
, int *w
, int *h
)
2513 Fake_glXQueryChannelDeltasSGIX(Display
*dpy
, int screen
, int channel
, int *dx
, int *dy
, int *dw
, int *dh
)
2526 Fake_glXChannelRectSyncSGIX(Display
*dpy
, int screen
, int channel
, GLenum synctype
)
2537 /*** GLX_SGIX_dmbuffer **/
2539 #if defined(_DM_BUFFER_H_)
2541 Fake_glXAssociateDMPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuffer
, DMparams
*params
, DMbuffer dmbuffer
)
2552 /*** GLX_SGIX_swap_group ***/
2555 Fake_glXJoinSwapGroupSGIX(Display
*dpy
, GLXDrawable drawable
, GLXDrawable member
)
2564 /*** GLX_SGIX_swap_barrier ***/
2567 Fake_glXBindSwapBarrierSGIX(Display
*dpy
, GLXDrawable drawable
, int barrier
)
2575 Fake_glXQueryMaxSwapBarriersSGIX(Display
*dpy
, int screen
, int *max
)
2585 /*** GLX_SUN_get_transparent_index ***/
2588 Fake_glXGetTransparentIndexSUN(Display
*dpy
, Window overlay
, Window underlay
, long *pTransparent
)
2593 (void) pTransparent
;
2599 /*** GLX_MESA_release_buffers ***/
2602 * Release the depth, stencil, accum buffers attached to a GLXDrawable
2603 * (a window or pixmap) prior to destroying the GLXDrawable.
2606 Fake_glXReleaseBuffersMESA( Display
*dpy
, GLXDrawable d
)
2608 XMesaBuffer b
= XMesaFindBuffer(dpy
, d
);
2610 XMesaDestroyBuffer(b
);
2618 /*** GLX_MESA_set_3dfx_mode ***/
2621 Fake_glXSet3DfxModeMESA( int mode
)
2623 return XMesaSetFXmode( mode
);
2628 /*** GLX_NV_vertex_array range ***/
2630 Fake_glXAllocateMemoryNV( GLsizei size
,
2631 GLfloat readFrequency
,
2632 GLfloat writeFrequency
,
2636 (void) readFrequency
;
2637 (void) writeFrequency
;
2644 Fake_glXFreeMemoryNV( GLvoid
*pointer
)
2650 /*** GLX_MESA_agp_offset ***/
2653 Fake_glXGetAGPOffsetMESA( const GLvoid
*pointer
)
2660 /*** GLX_ARB_render_texture ***/
2663 Fake_glXBindTexImageARB( Display
*dpy
, GLXPbuffer pbuffer
, int buffer
)
2670 Fake_glXReleaseTexImageARB(Display
*dpy
, GLXPbuffer pbuffer
, int buffer
)
2677 Fake_glXDrawableAttribARB( Display
*dpy
, GLXDrawable draw
, const int *attribList
)
2684 extern struct _glxapi_table
*_mesa_GetGLXDispatchTable(void);
2685 struct _glxapi_table
*_mesa_GetGLXDispatchTable(void)
2687 static struct _glxapi_table glx
;
2689 /* be sure our dispatch table size <= libGL's table */
2691 GLuint size
= sizeof(struct _glxapi_table
) / sizeof(void *);
2693 assert(_glxapi_get_dispatch_table_size() >= size
);
2696 /* initialize the whole table to no-ops */
2697 _glxapi_set_no_op_table(&glx
);
2699 /* now initialize the table with the functions I implement */
2700 glx
.ChooseVisual
= Fake_glXChooseVisual
;
2701 glx
.CopyContext
= Fake_glXCopyContext
;
2702 glx
.CreateContext
= Fake_glXCreateContext
;
2703 glx
.CreateGLXPixmap
= Fake_glXCreateGLXPixmap
;
2704 glx
.DestroyContext
= Fake_glXDestroyContext
;
2705 glx
.DestroyGLXPixmap
= Fake_glXDestroyGLXPixmap
;
2706 glx
.GetConfig
= Fake_glXGetConfig
;
2707 /*glx.GetCurrentContext = Fake_glXGetCurrentContext;*/
2708 /*glx.GetCurrentDrawable = Fake_glXGetCurrentDrawable;*/
2709 glx
.IsDirect
= Fake_glXIsDirect
;
2710 glx
.MakeCurrent
= Fake_glXMakeCurrent
;
2711 glx
.QueryExtension
= Fake_glXQueryExtension
;
2712 glx
.QueryVersion
= Fake_glXQueryVersion
;
2713 glx
.SwapBuffers
= Fake_glXSwapBuffers
;
2714 glx
.UseXFont
= Fake_glXUseXFont
;
2715 glx
.WaitGL
= Fake_glXWaitGL
;
2716 glx
.WaitX
= Fake_glXWaitX
;
2718 /*** GLX_VERSION_1_1 ***/
2719 glx
.GetClientString
= Fake_glXGetClientString
;
2720 glx
.QueryExtensionsString
= Fake_glXQueryExtensionsString
;
2721 glx
.QueryServerString
= Fake_glXQueryServerString
;
2723 /*** GLX_VERSION_1_2 ***/
2724 /*glx.GetCurrentDisplay = Fake_glXGetCurrentDisplay;*/
2726 /*** GLX_VERSION_1_3 ***/
2727 glx
.ChooseFBConfig
= Fake_glXChooseFBConfig
;
2728 glx
.CreateNewContext
= Fake_glXCreateNewContext
;
2729 glx
.CreatePbuffer
= Fake_glXCreatePbuffer
;
2730 glx
.CreatePixmap
= Fake_glXCreatePixmap
;
2731 glx
.CreateWindow
= Fake_glXCreateWindow
;
2732 glx
.DestroyPbuffer
= Fake_glXDestroyPbuffer
;
2733 glx
.DestroyPixmap
= Fake_glXDestroyPixmap
;
2734 glx
.DestroyWindow
= Fake_glXDestroyWindow
;
2735 /*glx.GetCurrentReadDrawable = Fake_glXGetCurrentReadDrawable;*/
2736 glx
.GetFBConfigAttrib
= Fake_glXGetFBConfigAttrib
;
2737 glx
.GetFBConfigs
= Fake_glXGetFBConfigs
;
2738 glx
.GetSelectedEvent
= Fake_glXGetSelectedEvent
;
2739 glx
.GetVisualFromFBConfig
= Fake_glXGetVisualFromFBConfig
;
2740 glx
.MakeContextCurrent
= Fake_glXMakeContextCurrent
;
2741 glx
.QueryContext
= Fake_glXQueryContext
;
2742 glx
.QueryDrawable
= Fake_glXQueryDrawable
;
2743 glx
.SelectEvent
= Fake_glXSelectEvent
;
2745 /*** GLX_SGI_swap_control ***/
2746 glx
.SwapIntervalSGI
= Fake_glXSwapIntervalSGI
;
2748 /*** GLX_SGI_video_sync ***/
2749 glx
.GetVideoSyncSGI
= Fake_glXGetVideoSyncSGI
;
2750 glx
.WaitVideoSyncSGI
= Fake_glXWaitVideoSyncSGI
;
2752 /*** GLX_SGI_make_current_read ***/
2753 glx
.MakeCurrentReadSGI
= Fake_glXMakeCurrentReadSGI
;
2754 /*glx.GetCurrentReadDrawableSGI = Fake_glXGetCurrentReadDrawableSGI;*/
2756 /*** GLX_SGIX_video_source ***/
2758 glx
.CreateGLXVideoSourceSGIX
= Fake_glXCreateGLXVideoSourceSGIX
;
2759 glx
.DestroyGLXVideoSourceSGIX
= Fake_glXDestroyGLXVideoSourceSGIX
;
2762 /*** GLX_EXT_import_context ***/
2763 glx
.FreeContextEXT
= Fake_glXFreeContextEXT
;
2764 glx
.GetContextIDEXT
= Fake_glXGetContextIDEXT
;
2765 /*glx.GetCurrentDisplayEXT = Fake_glXGetCurrentDisplayEXT;*/
2766 glx
.ImportContextEXT
= Fake_glXImportContextEXT
;
2767 glx
.QueryContextInfoEXT
= Fake_glXQueryContextInfoEXT
;
2769 /*** GLX_SGIX_fbconfig ***/
2770 glx
.GetFBConfigAttribSGIX
= Fake_glXGetFBConfigAttribSGIX
;
2771 glx
.ChooseFBConfigSGIX
= Fake_glXChooseFBConfigSGIX
;
2772 glx
.CreateGLXPixmapWithConfigSGIX
= Fake_glXCreateGLXPixmapWithConfigSGIX
;
2773 glx
.CreateContextWithConfigSGIX
= Fake_glXCreateContextWithConfigSGIX
;
2774 glx
.GetVisualFromFBConfigSGIX
= Fake_glXGetVisualFromFBConfigSGIX
;
2775 glx
.GetFBConfigFromVisualSGIX
= Fake_glXGetFBConfigFromVisualSGIX
;
2777 /*** GLX_SGIX_pbuffer ***/
2778 glx
.CreateGLXPbufferSGIX
= Fake_glXCreateGLXPbufferSGIX
;
2779 glx
.DestroyGLXPbufferSGIX
= Fake_glXDestroyGLXPbufferSGIX
;
2780 glx
.QueryGLXPbufferSGIX
= Fake_glXQueryGLXPbufferSGIX
;
2781 glx
.SelectEventSGIX
= Fake_glXSelectEventSGIX
;
2782 glx
.GetSelectedEventSGIX
= Fake_glXGetSelectedEventSGIX
;
2784 /*** GLX_SGI_cushion ***/
2785 glx
.CushionSGI
= Fake_glXCushionSGI
;
2787 /*** GLX_SGIX_video_resize ***/
2788 glx
.BindChannelToWindowSGIX
= Fake_glXBindChannelToWindowSGIX
;
2789 glx
.ChannelRectSGIX
= Fake_glXChannelRectSGIX
;
2790 glx
.QueryChannelRectSGIX
= Fake_glXQueryChannelRectSGIX
;
2791 glx
.QueryChannelDeltasSGIX
= Fake_glXQueryChannelDeltasSGIX
;
2792 glx
.ChannelRectSyncSGIX
= Fake_glXChannelRectSyncSGIX
;
2794 /*** GLX_SGIX_dmbuffer **/
2795 #if defined(_DM_BUFFER_H_)
2796 glx
.AssociateDMPbufferSGIX
= NULL
;
2799 /*** GLX_SGIX_swap_group ***/
2800 glx
.JoinSwapGroupSGIX
= Fake_glXJoinSwapGroupSGIX
;
2802 /*** GLX_SGIX_swap_barrier ***/
2803 glx
.BindSwapBarrierSGIX
= Fake_glXBindSwapBarrierSGIX
;
2804 glx
.QueryMaxSwapBarriersSGIX
= Fake_glXQueryMaxSwapBarriersSGIX
;
2806 /*** GLX_SUN_get_transparent_index ***/
2807 glx
.GetTransparentIndexSUN
= Fake_glXGetTransparentIndexSUN
;
2809 /*** GLX_MESA_copy_sub_buffer ***/
2810 glx
.CopySubBufferMESA
= Fake_glXCopySubBufferMESA
;
2812 /*** GLX_MESA_release_buffers ***/
2813 glx
.ReleaseBuffersMESA
= Fake_glXReleaseBuffersMESA
;
2815 /*** GLX_MESA_pixmap_colormap ***/
2816 glx
.CreateGLXPixmapMESA
= Fake_glXCreateGLXPixmapMESA
;
2818 /*** GLX_MESA_set_3dfx_mode ***/
2819 glx
.Set3DfxModeMESA
= Fake_glXSet3DfxModeMESA
;
2821 /*** GLX_NV_vertex_array_range ***/
2822 glx
.AllocateMemoryNV
= Fake_glXAllocateMemoryNV
;
2823 glx
.FreeMemoryNV
= Fake_glXFreeMemoryNV
;
2825 /*** GLX_MESA_agp_offset ***/
2826 glx
.GetAGPOffsetMESA
= Fake_glXGetAGPOffsetMESA
;
2828 /*** GLX_ARB_render_texture ***/
2829 glx
.BindTexImageARB
= Fake_glXBindTexImageARB
;
2830 glx
.ReleaseTexImageARB
= Fake_glXReleaseTexImageARB
;
2831 glx
.DrawableAttribARB
= Fake_glXDrawableAttribARB
;