2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2005 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 #define _mesa_sprintf sprintf
59 /* This indicates the client-side GLX API and GLX encoder version. */
60 #define CLIENT_MAJOR_VERSION 1
61 #define CLIENT_MINOR_VERSION 4 /* but don't have 1.3's pbuffers, etc yet */
63 /* This indicates the server-side GLX decoder version.
64 * GLX 1.4 indicates OpenGL 1.3 support
66 #define SERVER_MAJOR_VERSION 1
67 #define SERVER_MINOR_VERSION 4
69 /* This is appended onto the glXGetClient/ServerString version strings. */
70 #define MESA_GLX_VERSION "Mesa " MESA_VERSION_STRING
72 /* Who implemented this GLX? */
73 #define VENDOR "Brian Paul"
76 "GLX_MESA_set_3dfx_mode " \
77 "GLX_MESA_copy_sub_buffer " \
78 "GLX_MESA_pixmap_colormap " \
79 "GLX_MESA_release_buffers " \
80 "GLX_ARB_get_proc_address " \
81 "GLX_EXT_visual_info " \
82 "GLX_EXT_visual_rating " \
83 "GLX_SGI_video_sync " \
84 "GLX_SGIX_fbconfig " \
88 * Our fake GLX context will contain a "real" GLX context and an XMesa context.
90 * Note that a pointer to a __GLXcontext is a pointer to a fake_glx_context,
93 * We really just need this structure in order to make the libGL functions
94 * glXGetCurrentContext(), glXGetCurrentDrawable() and glXGetCurrentDisplay()
97 struct fake_glx_context
{
98 __GLXcontext glxContext
; /* this MUST be first! */
99 XMesaContext xmesaContext
;
104 /**********************************************************************/
105 /*** GLX Visual Code ***/
106 /**********************************************************************/
111 static XMesaVisual
*VisualTable
= NULL
;
112 static int NumVisuals
= 0;
116 * This struct and some code fragments borrowed
117 * from Mark Kilgard's GLUT library.
119 typedef struct _OverlayInfo
{
120 /* Avoid 64-bit portability problems by being careful to use
121 longs due to the way XGetWindowProperty is specified. Note
122 that these parameters are passed as CARD32s over X
124 unsigned long overlay_visual
;
125 long transparent_type
;
132 /* Macro to handle c_class vs class field name in XVisualInfo struct */
133 #if defined(__cplusplus) || defined(c_plusplus)
134 #define CLASS c_class
142 * Test if the given XVisualInfo is usable for Mesa rendering.
145 is_usable_visual( XVisualInfo
*vinfo
)
147 switch (vinfo
->CLASS
) {
150 /* Any StaticGray/GrayScale visual works in RGB or CI mode */
154 /* Any StaticColor/PseudoColor visual of at least 4 bits */
155 if (vinfo
->depth
>=4) {
163 /* Any depth of TrueColor or DirectColor works in RGB mode */
166 /* This should never happen */
174 * Get an array OverlayInfo records for specified screen.
175 * \param dpy the display
176 * \param screen screen number
177 * \param numOverlays returns numver of OverlayInfo records
178 * \return pointer to OverlayInfo array, free with XFree()
181 GetOverlayInfo(Display
*dpy
, int screen
, int *numOverlays
)
183 Atom overlayVisualsAtom
;
186 unsigned char *ovInfo
;
187 unsigned long sizeData
, bytesLeft
;
191 * The SERVER_OVERLAY_VISUALS property on the root window contains
192 * a list of overlay visuals. Get that list now.
194 overlayVisualsAtom
= XInternAtom(dpy
,"SERVER_OVERLAY_VISUALS", True
);
195 if (overlayVisualsAtom
== None
) {
199 status
= XGetWindowProperty(dpy
, RootWindow(dpy
, screen
),
200 overlayVisualsAtom
, 0L, (long) 10000, False
,
201 overlayVisualsAtom
, &actualType
, &actualFormat
,
202 &sizeData
, &bytesLeft
,
205 if (status
!= Success
|| actualType
!= overlayVisualsAtom
||
206 actualFormat
!= 32 || sizeData
< 4) {
207 /* something went wrong */
208 XFree((void *) ovInfo
);
213 *numOverlays
= sizeData
/ 4;
214 return (OverlayInfo
*) ovInfo
;
220 * Return the level (overlay, normal, underlay) of a given XVisualInfo.
221 * Input: dpy - the X display
222 * vinfo - the XVisualInfo to test
223 * Return: level of the visual:
225 * >0 = overlay planes
226 * <0 = underlay planes
229 level_of_visual( Display
*dpy
, XVisualInfo
*vinfo
)
231 OverlayInfo
*overlay_info
;
232 int numOverlaysPerScreen
, i
;
234 overlay_info
= GetOverlayInfo(dpy
, vinfo
->screen
, &numOverlaysPerScreen
);
239 /* search the overlay visual list for the visual ID of interest */
240 for (i
= 0; i
< numOverlaysPerScreen
; i
++) {
241 const OverlayInfo
*ov
= overlay_info
+ i
;
242 if (ov
->overlay_visual
== vinfo
->visualid
) {
243 /* found the visual */
244 if (/*ov->transparent_type==1 &&*/ ov
->layer
!=0) {
245 int level
= ov
->layer
;
246 XFree((void *) overlay_info
);
250 XFree((void *) overlay_info
);
256 /* The visual ID was not found in the overlay list. */
257 XFree((void *) overlay_info
);
265 * Given an XVisualInfo and RGB, Double, and Depth buffer flags, save the
266 * configuration in our list of GLX visuals.
269 save_glx_visual( Display
*dpy
, XVisualInfo
*vinfo
,
270 GLboolean rgbFlag
, GLboolean alphaFlag
, GLboolean dbFlag
,
271 GLboolean stereoFlag
,
272 GLint depth_size
, GLint stencil_size
,
273 GLint accumRedSize
, GLint accumGreenSize
,
274 GLint accumBlueSize
, GLint accumAlphaSize
,
275 GLint level
, GLint numAuxBuffers
)
277 GLboolean ximageFlag
= GL_TRUE
;
280 GLboolean comparePointers
;
283 /* Check if the MESA_BACK_BUFFER env var is set */
284 char *backbuffer
= _mesa_getenv("MESA_BACK_BUFFER");
286 if (backbuffer
[0]=='p' || backbuffer
[0]=='P') {
287 ximageFlag
= GL_FALSE
;
289 else if (backbuffer
[0]=='x' || backbuffer
[0]=='X') {
290 ximageFlag
= GL_TRUE
;
293 _mesa_warning(NULL
, "Mesa: invalid value for MESA_BACK_BUFFER environment variable, using an XImage.");
298 /* Comparing IDs uses less memory but sometimes fails. */
299 /* XXX revisit this after 3.0 is finished. */
300 if (_mesa_getenv("MESA_GLX_VISUAL_HACK"))
301 comparePointers
= GL_TRUE
;
303 comparePointers
= GL_FALSE
;
305 /* Force the visual to have an alpha channel */
306 if (rgbFlag
&& _mesa_getenv("MESA_GLX_FORCE_ALPHA"))
309 /* First check if a matching visual is already in the list */
310 for (i
=0; i
<NumVisuals
; i
++) {
311 XMesaVisual v
= VisualTable
[i
];
312 if (v
->display
== dpy
313 && v
->mesa_visual
.level
== level
314 && v
->mesa_visual
.numAuxBuffers
== numAuxBuffers
315 && v
->ximage_flag
== ximageFlag
316 && v
->mesa_visual
.rgbMode
== rgbFlag
317 && v
->mesa_visual
.doubleBufferMode
== dbFlag
318 && v
->mesa_visual
.stereoMode
== stereoFlag
319 && (v
->mesa_visual
.alphaBits
> 0) == alphaFlag
320 && (v
->mesa_visual
.depthBits
>= depth_size
|| depth_size
== 0)
321 && (v
->mesa_visual
.stencilBits
>= stencil_size
|| stencil_size
== 0)
322 && (v
->mesa_visual
.accumRedBits
>= accumRedSize
|| accumRedSize
== 0)
323 && (v
->mesa_visual
.accumGreenBits
>= accumGreenSize
|| accumGreenSize
== 0)
324 && (v
->mesa_visual
.accumBlueBits
>= accumBlueSize
|| accumBlueSize
== 0)
325 && (v
->mesa_visual
.accumAlphaBits
>= accumAlphaSize
|| accumAlphaSize
== 0)) {
326 /* now either compare XVisualInfo pointers or visual IDs */
327 if ((!comparePointers
&& v
->visinfo
->visualid
== vinfo
->visualid
)
328 || (comparePointers
&& v
->vishandle
== vinfo
)) {
334 /* Create a new visual and add it to the list. */
336 xmvis
= XMesaCreateVisual( dpy
, vinfo
, rgbFlag
, alphaFlag
, dbFlag
,
337 stereoFlag
, ximageFlag
,
338 depth_size
, stencil_size
,
339 accumRedSize
, accumBlueSize
,
340 accumBlueSize
, accumAlphaSize
, 0, level
,
343 /* Save a copy of the pointer now so we can find this visual again
344 * if we need to search for it in find_glx_visual().
346 xmvis
->vishandle
= vinfo
;
347 /* Allocate more space for additional visual */
348 VisualTable
= _mesa_realloc( VisualTable
,
349 sizeof(XMesaVisual
) * NumVisuals
,
350 sizeof(XMesaVisual
) * (NumVisuals
+ 1));
351 /* add xmvis to the list */
352 VisualTable
[NumVisuals
] = xmvis
;
354 /* XXX minor hack, because XMesaCreateVisual doesn't support an
355 * aux buffers parameter.
357 xmvis
->mesa_visual
.numAuxBuffers
= numAuxBuffers
;
364 * Return the default number of bits for the Z buffer.
365 * If defined, use the MESA_GLX_DEPTH_BITS env var value.
366 * Otherwise, use the DEFAULT_SOFTWARE_DEPTH_BITS constant.
367 * XXX probably do the same thing for stencil, accum, etc.
370 default_depth_bits(void)
373 const char *zEnv
= _mesa_getenv("MESA_GLX_DEPTH_BITS");
375 zBits
= _mesa_atoi(zEnv
);
377 zBits
= DEFAULT_SOFTWARE_DEPTH_BITS
;
384 * Create a GLX visual from a regular XVisualInfo.
385 * This is called when Fake GLX is given an XVisualInfo which wasn't
386 * returned by glXChooseVisual. Since this is the first time we're
387 * considering this visual we'll take a guess at reasonable values
388 * for depth buffer size, stencil size, accum size, etc.
389 * This is the best we can do with a client-side emulation of GLX.
392 create_glx_visual( Display
*dpy
, XVisualInfo
*visinfo
)
395 GLint zBits
= default_depth_bits();
397 vislevel
= level_of_visual( dpy
, visinfo
);
399 /* Configure this visual as a CI, single-buffered overlay */
400 return save_glx_visual( dpy
, visinfo
,
402 GL_FALSE
, /* alpha */
403 GL_FALSE
, /* double */
404 GL_FALSE
, /* stereo */
406 0, /* stencil bits */
407 0,0,0,0, /* accum bits */
408 vislevel
, /* level */
412 else if (is_usable_visual( visinfo
)) {
413 if (_mesa_getenv("MESA_GLX_FORCE_CI")) {
414 /* Configure this visual as a COLOR INDEX visual. */
415 return save_glx_visual( dpy
, visinfo
,
417 GL_FALSE
, /* alpha */
418 GL_TRUE
, /* double */
419 GL_FALSE
, /* stereo */
422 0, 0, 0, 0, /* accum bits */
428 /* Configure this visual as RGB, double-buffered, depth-buffered. */
429 /* This is surely wrong for some people's needs but what else */
430 /* can be done? They should use glXChooseVisual(). */
431 return save_glx_visual( dpy
, visinfo
,
433 GL_FALSE
, /* alpha */
434 GL_TRUE
, /* double */
435 GL_FALSE
, /* stereo */
448 _mesa_warning(NULL
, "Mesa: error in glXCreateContext: bad visual\n");
456 * Find the GLX visual associated with an XVisualInfo.
459 find_glx_visual( Display
*dpy
, XVisualInfo
*vinfo
)
463 /* try to match visual id */
464 for (i
=0;i
<NumVisuals
;i
++) {
465 if (VisualTable
[i
]->display
==dpy
466 && VisualTable
[i
]->visinfo
->visualid
== vinfo
->visualid
) {
467 return VisualTable
[i
];
471 /* if that fails, try to match pointers */
472 for (i
=0;i
<NumVisuals
;i
++) {
473 if (VisualTable
[i
]->display
==dpy
&& VisualTable
[i
]->vishandle
==vinfo
) {
474 return VisualTable
[i
];
484 * Return the transparent pixel value for a GLX visual.
485 * Input: glxvis - the glx_visual
486 * Return: a pixel value or -1 if no transparent pixel
489 transparent_pixel( XMesaVisual glxvis
)
491 Display
*dpy
= glxvis
->display
;
492 XVisualInfo
*vinfo
= glxvis
->visinfo
;
493 OverlayInfo
*overlay_info
;
494 int numOverlaysPerScreen
, i
;
496 overlay_info
= GetOverlayInfo(dpy
, vinfo
->screen
, &numOverlaysPerScreen
);
501 for (i
= 0; i
< numOverlaysPerScreen
; i
++) {
502 const OverlayInfo
*ov
= overlay_info
+ i
;
503 if (ov
->overlay_visual
== vinfo
->visualid
) {
505 if (ov
->transparent_type
== 0) {
506 /* type 0 indicates no transparency */
507 XFree((void *) overlay_info
);
511 /* ov->value is the transparent pixel */
512 XFree((void *) overlay_info
);
518 /* The visual ID was not found in the overlay list. */
519 XFree((void *) overlay_info
);
526 * Try to get an X visual which matches the given arguments.
529 get_visual( Display
*dpy
, int scr
, unsigned int depth
, int xclass
)
531 XVisualInfo temp
, *vis
;
534 unsigned int default_depth
;
537 mask
= VisualScreenMask
| VisualDepthMask
| VisualClassMask
;
542 default_depth
= DefaultDepth(dpy
,scr
);
543 default_class
= DefaultVisual(dpy
,scr
)->CLASS
;
545 if (depth
==default_depth
&& xclass
==default_class
) {
546 /* try to get root window's visual */
547 temp
.visualid
= DefaultVisual(dpy
,scr
)->visualid
;
548 mask
|= VisualIDMask
;
551 vis
= XGetVisualInfo( dpy
, mask
, &temp
, &n
);
553 /* In case bits/pixel > 24, make sure color channels are still <=8 bits.
554 * An SGI Infinite Reality system, for example, can have 30bpp pixels:
555 * 10 bits per color channel. Mesa's limited to a max of 8 bits/channel.
557 if (vis
&& depth
> 24 && (xclass
==TrueColor
|| xclass
==DirectColor
)) {
558 if (_mesa_bitcount((GLuint
) vis
->red_mask
) <= 8 &&
559 _mesa_bitcount((GLuint
) vis
->green_mask
) <= 8 &&
560 _mesa_bitcount((GLuint
) vis
->blue_mask
) <= 8) {
575 * Retrieve the value of the given environment variable and find
576 * the X visual which matches it.
577 * Input: dpy - the display
578 * screen - the screen number
579 * varname - the name of the environment variable
580 * Return: an XVisualInfo pointer to NULL if error.
583 get_env_visual(Display
*dpy
, int scr
, const char *varname
)
585 char value
[100], type
[100];
586 int depth
, xclass
= -1;
589 if (!_mesa_getenv( varname
)) {
593 _mesa_strncpy( value
, _mesa_getenv(varname
), 100 );
596 sscanf( value
, "%s %d", type
, &depth
);
598 if (_mesa_strcmp(type
,"TrueColor")==0) xclass
= TrueColor
;
599 else if (_mesa_strcmp(type
,"DirectColor")==0) xclass
= DirectColor
;
600 else if (_mesa_strcmp(type
,"PseudoColor")==0) xclass
= PseudoColor
;
601 else if (_mesa_strcmp(type
,"StaticColor")==0) xclass
= StaticColor
;
602 else if (_mesa_strcmp(type
,"GrayScale")==0) xclass
= GrayScale
;
603 else if (_mesa_strcmp(type
,"StaticGray")==0) xclass
= StaticGray
;
605 if (xclass
>-1 && depth
>0) {
606 vis
= get_visual( dpy
, scr
, depth
, xclass
);
612 _mesa_warning(NULL
, "GLX unable to find visual class=%s, depth=%d.",
621 * Select an X visual which satisfies the RGBA/CI flag and minimum depth.
622 * Input: dpy, screen - X display and screen number
623 * rgba - GL_TRUE = RGBA mode, GL_FALSE = CI mode
624 * min_depth - minimum visual depth
625 * preferred_class - preferred GLX visual class or DONT_CARE
626 * Return: pointer to an XVisualInfo or NULL.
629 choose_x_visual( Display
*dpy
, int screen
, GLboolean rgba
, int min_depth
,
630 int preferred_class
)
633 int xclass
, visclass
= 0;
637 Atom hp_cr_maps
= XInternAtom(dpy
, "_HP_RGB_SMOOTH_MAP_LIST", True
);
638 /* First see if the MESA_RGB_VISUAL env var is defined */
639 vis
= get_env_visual( dpy
, screen
, "MESA_RGB_VISUAL" );
643 /* Otherwise, search for a suitable visual */
644 if (preferred_class
==DONT_CARE
) {
645 for (xclass
=0;xclass
<6;xclass
++) {
647 case 0: visclass
= TrueColor
; break;
648 case 1: visclass
= DirectColor
; break;
649 case 2: visclass
= PseudoColor
; break;
650 case 3: visclass
= StaticColor
; break;
651 case 4: visclass
= GrayScale
; break;
652 case 5: visclass
= StaticGray
; break;
655 /* start with shallowest */
656 for (depth
=0;depth
<=32;depth
++) {
657 if (visclass
==TrueColor
&& depth
==8 && !hp_cr_maps
) {
658 /* Special case: try to get 8-bit PseudoColor before */
659 /* 8-bit TrueColor */
660 vis
= get_visual( dpy
, screen
, 8, PseudoColor
);
665 vis
= get_visual( dpy
, screen
, depth
, visclass
);
672 /* start with deepest */
673 for (depth
=32;depth
>=min_depth
;depth
--) {
674 if (visclass
==TrueColor
&& depth
==8 && !hp_cr_maps
) {
675 /* Special case: try to get 8-bit PseudoColor before */
676 /* 8-bit TrueColor */
677 vis
= get_visual( dpy
, screen
, 8, PseudoColor
);
682 vis
= get_visual( dpy
, screen
, depth
, visclass
);
691 /* search for a specific visual class */
692 switch (preferred_class
) {
693 case GLX_TRUE_COLOR_EXT
: visclass
= TrueColor
; break;
694 case GLX_DIRECT_COLOR_EXT
: visclass
= DirectColor
; break;
695 case GLX_PSEUDO_COLOR_EXT
: visclass
= PseudoColor
; break;
696 case GLX_STATIC_COLOR_EXT
: visclass
= StaticColor
; break;
697 case GLX_GRAY_SCALE_EXT
: visclass
= GrayScale
; break;
698 case GLX_STATIC_GRAY_EXT
: visclass
= StaticGray
; break;
699 default: return NULL
;
702 /* start with shallowest */
703 for (depth
=0;depth
<=32;depth
++) {
704 vis
= get_visual( dpy
, screen
, depth
, visclass
);
711 /* start with deepest */
712 for (depth
=32;depth
>=min_depth
;depth
--) {
713 vis
= get_visual( dpy
, screen
, depth
, visclass
);
722 /* First see if the MESA_CI_VISUAL env var is defined */
723 vis
= get_env_visual( dpy
, screen
, "MESA_CI_VISUAL" );
727 /* Otherwise, search for a suitable visual, starting with shallowest */
728 if (preferred_class
==DONT_CARE
) {
729 for (xclass
=0;xclass
<4;xclass
++) {
731 case 0: visclass
= PseudoColor
; break;
732 case 1: visclass
= StaticColor
; break;
733 case 2: visclass
= GrayScale
; break;
734 case 3: visclass
= StaticGray
; break;
736 /* try 8-bit up through 16-bit */
737 for (depth
=8;depth
<=16;depth
++) {
738 vis
= get_visual( dpy
, screen
, depth
, visclass
);
743 /* try min_depth up to 8-bit */
744 for (depth
=min_depth
;depth
<8;depth
++) {
745 vis
= get_visual( dpy
, screen
, depth
, visclass
);
753 /* search for a specific visual class */
754 switch (preferred_class
) {
755 case GLX_TRUE_COLOR_EXT
: visclass
= TrueColor
; break;
756 case GLX_DIRECT_COLOR_EXT
: visclass
= DirectColor
; break;
757 case GLX_PSEUDO_COLOR_EXT
: visclass
= PseudoColor
; break;
758 case GLX_STATIC_COLOR_EXT
: visclass
= StaticColor
; break;
759 case GLX_GRAY_SCALE_EXT
: visclass
= GrayScale
; break;
760 case GLX_STATIC_GRAY_EXT
: visclass
= StaticGray
; break;
761 default: return NULL
;
763 /* try 8-bit up through 16-bit */
764 for (depth
=8;depth
<=16;depth
++) {
765 vis
= get_visual( dpy
, screen
, depth
, visclass
);
770 /* try min_depth up to 8-bit */
771 for (depth
=min_depth
;depth
<8;depth
++) {
772 vis
= get_visual( dpy
, screen
, depth
, visclass
);
780 /* didn't find a visual */
787 * Find the deepest X over/underlay visual of at least min_depth.
788 * Input: dpy, screen - X display and screen number
789 * level - the over/underlay level
790 * trans_type - transparent pixel type: GLX_NONE_EXT,
791 * GLX_TRANSPARENT_RGB_EXT, GLX_TRANSPARENT_INDEX_EXT,
793 * trans_value - transparent pixel value or DONT_CARE
794 * min_depth - minimum visual depth
795 * preferred_class - preferred GLX visual class or DONT_CARE
796 * Return: pointer to an XVisualInfo or NULL.
799 choose_x_overlay_visual( Display
*dpy
, int scr
, GLboolean rgbFlag
,
800 int level
, int trans_type
, int trans_value
,
801 int min_depth
, int preferred_class
)
803 OverlayInfo
*overlay_info
;
804 int numOverlaysPerScreen
;
806 XVisualInfo
*deepvis
;
809 /*DEBUG int tt, tv; */
811 switch (preferred_class
) {
812 case GLX_TRUE_COLOR_EXT
: preferred_class
= TrueColor
; break;
813 case GLX_DIRECT_COLOR_EXT
: preferred_class
= DirectColor
; break;
814 case GLX_PSEUDO_COLOR_EXT
: preferred_class
= PseudoColor
; break;
815 case GLX_STATIC_COLOR_EXT
: preferred_class
= StaticColor
; break;
816 case GLX_GRAY_SCALE_EXT
: preferred_class
= GrayScale
; break;
817 case GLX_STATIC_GRAY_EXT
: preferred_class
= StaticGray
; break;
818 default: preferred_class
= DONT_CARE
;
821 overlay_info
= GetOverlayInfo(dpy
, scr
, &numOverlaysPerScreen
);
826 /* Search for the deepest overlay which satisifies all criteria. */
830 for (i
= 0; i
< numOverlaysPerScreen
; i
++) {
831 const OverlayInfo
*ov
= overlay_info
+ i
;
832 XVisualInfo
*vislist
, vistemplate
;
835 if (ov
->layer
!=level
) {
836 /* failed overlay level criteria */
839 if (!(trans_type
==DONT_CARE
840 || (trans_type
==GLX_TRANSPARENT_INDEX_EXT
841 && ov
->transparent_type
>0)
842 || (trans_type
==GLX_NONE_EXT
&& ov
->transparent_type
==0))) {
843 /* failed transparent pixel type criteria */
846 if (trans_value
!=DONT_CARE
&& trans_value
!=ov
->value
) {
847 /* failed transparent pixel value criteria */
851 /* get XVisualInfo and check the depth */
852 vistemplate
.visualid
= ov
->overlay_visual
;
853 vistemplate
.screen
= scr
;
854 vislist
= XGetVisualInfo( dpy
, VisualIDMask
| VisualScreenMask
,
855 &vistemplate
, &count
);
858 /* something went wrong */
861 if (preferred_class
!=DONT_CARE
&& preferred_class
!=vislist
->CLASS
) {
862 /* wrong visual class */
866 /* if RGB was requested, make sure we have True/DirectColor */
867 if (rgbFlag
&& vislist
->CLASS
!= TrueColor
868 && vislist
->CLASS
!= DirectColor
)
871 /* if CI was requested, make sure we have a color indexed visual */
873 && (vislist
->CLASS
== TrueColor
|| vislist
->CLASS
== DirectColor
))
876 if (deepvis
==NULL
|| vislist
->depth
> deepest
) {
877 /* YES! found a satisfactory visual */
881 deepest
= vislist
->depth
;
883 /* DEBUG tt = ov->transparent_type;*/
884 /* DEBUG tv = ov->value; */
890 printf("chose 0x%x: layer=%d depth=%d trans_type=%d trans_value=%d\n",
891 deepvis->visualid, level, deepvis->depth, tt, tv );
898 /**********************************************************************/
899 /*** Begin Fake GLX API Functions ***/
900 /**********************************************************************/
904 * Helper used by glXChooseVisual and glXChooseFBConfig.
905 * The fbConfig parameter must be GL_FALSE for the former and GL_TRUE for
907 * In either case, the attribute list is terminated with the value 'None'.
910 choose_visual( Display
*dpy
, int screen
, const int *list
, GLboolean fbConfig
)
912 const GLboolean rgbModeDefault
= fbConfig
;
913 const int *parselist
;
916 int min_red
=0, min_green
=0, min_blue
=0;
917 GLboolean rgb_flag
= rgbModeDefault
;
918 GLboolean alpha_flag
= GL_FALSE
;
919 GLboolean double_flag
= GL_FALSE
;
920 GLboolean stereo_flag
= GL_FALSE
;
921 GLint depth_size
= 0;
922 GLint stencil_size
= 0;
923 GLint accumRedSize
= 0;
924 GLint accumGreenSize
= 0;
925 GLint accumBlueSize
= 0;
926 GLint accumAlphaSize
= 0;
928 int visual_type
= DONT_CARE
;
929 int trans_type
= DONT_CARE
;
930 int trans_value
= DONT_CARE
;
931 GLint caveat
= DONT_CARE
;
932 XMesaVisual xmvis
= NULL
;
933 int desiredVisualID
= -1;
940 switch (*parselist
) {
951 case GLX_BUFFER_SIZE
:
953 min_ci
= *parselist
++;
957 level
= *parselist
++;
969 case GLX_DOUBLEBUFFER
:
972 double_flag
= *parselist
++;
975 double_flag
= GL_TRUE
;
981 stereo_flag
= *parselist
++;
984 stereo_flag
= GL_TRUE
;
986 return NULL
; /* stereo not supported */
987 case GLX_AUX_BUFFERS
:
989 numAux
= *parselist
++;
990 if (numAux
> MAX_AUX_BUFFERS
)
995 min_red
= *parselist
++;
999 min_green
= *parselist
++;
1003 min_blue
= *parselist
++;
1005 case GLX_ALPHA_SIZE
:
1008 GLint size
= *parselist
++;
1009 alpha_flag
= size
>0 ? 1 : 0;
1012 case GLX_DEPTH_SIZE
:
1014 depth_size
= *parselist
++;
1016 case GLX_STENCIL_SIZE
:
1018 stencil_size
= *parselist
++;
1020 case GLX_ACCUM_RED_SIZE
:
1023 GLint size
= *parselist
++;
1024 accumRedSize
= MAX2( accumRedSize
, size
);
1027 case GLX_ACCUM_GREEN_SIZE
:
1030 GLint size
= *parselist
++;
1031 accumGreenSize
= MAX2( accumGreenSize
, size
);
1034 case GLX_ACCUM_BLUE_SIZE
:
1037 GLint size
= *parselist
++;
1038 accumBlueSize
= MAX2( accumBlueSize
, size
);
1041 case GLX_ACCUM_ALPHA_SIZE
:
1044 GLint size
= *parselist
++;
1045 accumAlphaSize
= MAX2( accumAlphaSize
, size
);
1050 * GLX_EXT_visual_info extension
1052 case GLX_X_VISUAL_TYPE_EXT
:
1054 visual_type
= *parselist
++;
1056 case GLX_TRANSPARENT_TYPE_EXT
:
1058 trans_type
= *parselist
++;
1060 case GLX_TRANSPARENT_INDEX_VALUE_EXT
:
1062 trans_value
= *parselist
++;
1064 case GLX_TRANSPARENT_RED_VALUE_EXT
:
1065 case GLX_TRANSPARENT_GREEN_VALUE_EXT
:
1066 case GLX_TRANSPARENT_BLUE_VALUE_EXT
:
1067 case GLX_TRANSPARENT_ALPHA_VALUE_EXT
:
1074 * GLX_EXT_visual_info extension
1076 case GLX_VISUAL_CAVEAT_EXT
:
1078 caveat
= *parselist
++; /* ignored for now */
1082 * GLX_ARB_multisample
1084 case GLX_SAMPLE_BUFFERS_ARB
:
1085 /* ms not supported */
1087 case GLX_SAMPLES_ARB
:
1088 /* ms not supported */
1094 case GLX_RENDER_TYPE
:
1098 if (*parselist
== GLX_RGBA_BIT
) {
1101 else if (*parselist
== GLX_COLOR_INDEX_BIT
) {
1102 rgb_flag
= GL_FALSE
;
1104 else if (*parselist
== 0) {
1109 case GLX_DRAWABLE_TYPE
:
1113 if (*parselist
& ~(GLX_WINDOW_BIT
| GLX_PIXMAP_BIT
| GLX_PBUFFER_BIT
)) {
1114 return NULL
; /* bad bit */
1118 case GLX_FBCONFIG_ID
:
1122 desiredVisualID
= *parselist
++;
1124 case GLX_X_RENDERABLE
:
1136 /* undefined attribute */
1137 _mesa_warning(NULL
, "unexpected attrib 0x%x in choose_visual()",
1146 * Since we're only simulating the GLX extension this function will never
1147 * find any real GL visuals. Instead, all we can do is try to find an RGB
1148 * or CI visual of appropriate depth. Other requested attributes such as
1149 * double buffering, depth buffer, etc. will be associated with the X
1150 * visual and stored in the VisualTable[].
1152 if (desiredVisualID
!= -1) {
1153 /* try to get a specific visual, by visualID */
1156 temp
.visualid
= desiredVisualID
;
1157 temp
.screen
= screen
;
1158 vis
= XGetVisualInfo(dpy
, VisualIDMask
| VisualScreenMask
, &temp
, &n
);
1160 /* give the visual some useful GLX attributes */
1161 double_flag
= GL_TRUE
;
1164 depth_size
= default_depth_bits();
1165 stencil_size
= STENCIL_BITS
;
1169 else if (level
==0) {
1170 /* normal color planes */
1172 /* Get an RGB visual */
1173 int min_rgb
= min_red
+ min_green
+ min_blue
;
1174 if (min_rgb
>1 && min_rgb
<8) {
1175 /* a special case to be sure we can get a monochrome visual */
1178 vis
= choose_x_visual( dpy
, screen
, rgb_flag
, min_rgb
, visual_type
);
1181 /* Get a color index visual */
1182 vis
= choose_x_visual( dpy
, screen
, rgb_flag
, min_ci
, visual_type
);
1183 accumRedSize
= accumGreenSize
= accumBlueSize
= accumAlphaSize
= 0;
1187 /* over/underlay planes */
1190 int min_rgb
= min_red
+ min_green
+ min_blue
;
1191 if (min_rgb
>1 && min_rgb
<8) {
1192 /* a special case to be sure we can get a monochrome visual */
1195 vis
= choose_x_overlay_visual( dpy
, screen
, rgb_flag
, level
,
1196 trans_type
, trans_value
, min_rgb
, visual_type
);
1199 /* color index overlay */
1200 vis
= choose_x_overlay_visual( dpy
, screen
, rgb_flag
, level
,
1201 trans_type
, trans_value
, min_ci
, visual_type
);
1206 /* Note: we're not exactly obeying the glXChooseVisual rules here.
1207 * When GLX_DEPTH_SIZE = 1 is specified we're supposed to choose the
1208 * largest depth buffer size, which is 32bits/value. Instead, we
1209 * return 16 to maintain performance with earlier versions of Mesa.
1211 if (depth_size
> 24)
1212 depth_size
= 31; /* 32 causes int overflow problems */
1213 else if (depth_size
> 16)
1215 else if (depth_size
> 0) {
1216 depth_size
= default_depth_bits();
1219 /* we only support one size of stencil and accum buffers. */
1220 if (stencil_size
> 0)
1221 stencil_size
= STENCIL_BITS
;
1222 if (accumRedSize
> 0 || accumGreenSize
> 0 || accumBlueSize
> 0 ||
1223 accumAlphaSize
> 0) {
1224 accumRedSize
= ACCUM_BITS
;
1225 accumGreenSize
= ACCUM_BITS
;
1226 accumBlueSize
= ACCUM_BITS
;
1227 accumAlphaSize
= alpha_flag
? ACCUM_BITS
: 0;
1230 xmvis
= save_glx_visual( dpy
, vis
, rgb_flag
, alpha_flag
, double_flag
,
1231 stereo_flag
, depth_size
, stencil_size
,
1232 accumRedSize
, accumGreenSize
,
1233 accumBlueSize
, accumAlphaSize
, level
, numAux
);
1240 static XVisualInfo
*
1241 Fake_glXChooseVisual( Display
*dpy
, int screen
, int *list
)
1243 XMesaVisual xmvis
= choose_visual(dpy
, screen
, list
, GL_FALSE
);
1246 return xmvis
->vishandle
;
1248 /* create a new vishandle - the cached one may be stale */
1249 xmvis
->vishandle
= (XVisualInfo
*) _mesa_malloc(sizeof(XVisualInfo
));
1250 if (xmvis
->vishandle
) {
1251 _mesa_memcpy(xmvis
->vishandle
, xmvis
->visinfo
, sizeof(XVisualInfo
));
1253 return xmvis
->vishandle
;
1262 Fake_glXCreateContext( Display
*dpy
, XVisualInfo
*visinfo
,
1263 GLXContext share_list
, Bool direct
)
1266 struct fake_glx_context
*glxCtx
;
1267 struct fake_glx_context
*shareCtx
= (struct fake_glx_context
*) share_list
;
1269 if (!dpy
|| !visinfo
)
1272 glxCtx
= CALLOC_STRUCT(fake_glx_context
);
1276 /* deallocate unused windows/buffers */
1277 XMesaGarbageCollect();
1279 xmvis
= find_glx_visual( dpy
, visinfo
);
1281 /* This visual wasn't found with glXChooseVisual() */
1282 xmvis
= create_glx_visual( dpy
, visinfo
);
1284 /* unusable visual */
1290 glxCtx
->xmesaContext
= XMesaCreateContext(xmvis
,
1291 shareCtx
? shareCtx
->xmesaContext
: NULL
);
1292 if (!glxCtx
->xmesaContext
) {
1297 glxCtx
->xmesaContext
->direct
= GL_FALSE
;
1298 glxCtx
->glxContext
.isDirect
= GL_FALSE
;
1299 glxCtx
->glxContext
.currentDpy
= dpy
;
1300 glxCtx
->glxContext
.xid
= (XID
) glxCtx
; /* self pointer */
1302 assert((void *) glxCtx
== (void *) &(glxCtx
->glxContext
));
1304 return (GLXContext
) glxCtx
;
1308 /* XXX these may have to be removed due to thread-safety issues. */
1309 static GLXContext MakeCurrent_PrevContext
= 0;
1310 static GLXDrawable MakeCurrent_PrevDrawable
= 0;
1311 static GLXDrawable MakeCurrent_PrevReadable
= 0;
1312 static XMesaBuffer MakeCurrent_PrevDrawBuffer
= 0;
1313 static XMesaBuffer MakeCurrent_PrevReadBuffer
= 0;
1316 /* GLX 1.3 and later */
1318 Fake_glXMakeContextCurrent( Display
*dpy
, GLXDrawable draw
,
1319 GLXDrawable read
, GLXContext ctx
)
1321 struct fake_glx_context
*glxCtx
= (struct fake_glx_context
*) ctx
;
1323 if (ctx
&& draw
&& read
) {
1324 XMesaBuffer drawBuffer
, readBuffer
;
1325 XMesaContext xmctx
= glxCtx
->xmesaContext
;
1327 /* Find the XMesaBuffer which corresponds to the GLXDrawable 'draw' */
1328 if (ctx
== MakeCurrent_PrevContext
1329 && draw
== MakeCurrent_PrevDrawable
) {
1330 drawBuffer
= MakeCurrent_PrevDrawBuffer
;
1333 drawBuffer
= XMesaFindBuffer( dpy
, draw
);
1336 /* drawable must be a new window! */
1337 drawBuffer
= XMesaCreateWindowBuffer2( xmctx
->xm_visual
, draw
, xmctx
);
1339 /* Out of memory, or context/drawable depth mismatch */
1344 /* Find the XMesaBuffer which corresponds to the GLXDrawable 'read' */
1345 if (ctx
== MakeCurrent_PrevContext
1346 && read
== MakeCurrent_PrevReadable
) {
1347 readBuffer
= MakeCurrent_PrevReadBuffer
;
1350 readBuffer
= XMesaFindBuffer( dpy
, read
);
1353 /* drawable must be a new window! */
1354 readBuffer
= XMesaCreateWindowBuffer2(glxCtx
->xmesaContext
->xm_visual
,
1357 /* Out of memory, or context/drawable depth mismatch */
1362 MakeCurrent_PrevContext
= ctx
;
1363 MakeCurrent_PrevDrawable
= draw
;
1364 MakeCurrent_PrevReadable
= read
;
1365 MakeCurrent_PrevDrawBuffer
= drawBuffer
;
1366 MakeCurrent_PrevReadBuffer
= readBuffer
;
1368 /* Now make current! */
1369 if (XMesaMakeCurrent2(xmctx
, drawBuffer
, readBuffer
)) {
1370 ((__GLXcontext
*) ctx
)->currentDpy
= dpy
;
1371 ((__GLXcontext
*) ctx
)->currentDrawable
= draw
;
1372 ((__GLXcontext
*) ctx
)->currentReadable
= read
;
1379 else if (!ctx
&& !draw
&& !read
) {
1380 /* release current context w/out assigning new one. */
1381 XMesaMakeCurrent( NULL
, NULL
);
1382 MakeCurrent_PrevContext
= 0;
1383 MakeCurrent_PrevDrawable
= 0;
1384 MakeCurrent_PrevReadable
= 0;
1385 MakeCurrent_PrevDrawBuffer
= 0;
1386 MakeCurrent_PrevReadBuffer
= 0;
1390 /* The args must either all be non-zero or all zero.
1399 Fake_glXMakeCurrent( Display
*dpy
, GLXDrawable drawable
, GLXContext ctx
)
1401 return Fake_glXMakeContextCurrent( dpy
, drawable
, drawable
, ctx
);
1406 Fake_glXCreateGLXPixmap( Display
*dpy
, XVisualInfo
*visinfo
, Pixmap pixmap
)
1411 v
= find_glx_visual( dpy
, visinfo
);
1413 v
= create_glx_visual( dpy
, visinfo
);
1415 /* unusable visual */
1420 b
= XMesaCreatePixmapBuffer( v
, pixmap
, 0 );
1424 return b
->frontxrb
->pixmap
;
1428 /*** GLX_MESA_pixmap_colormap ***/
1431 Fake_glXCreateGLXPixmapMESA( Display
*dpy
, XVisualInfo
*visinfo
,
1432 Pixmap pixmap
, Colormap cmap
)
1437 v
= find_glx_visual( dpy
, visinfo
);
1439 v
= create_glx_visual( dpy
, visinfo
);
1441 /* unusable visual */
1446 b
= XMesaCreatePixmapBuffer( v
, pixmap
, cmap
);
1450 return b
->frontxrb
->pixmap
;
1455 Fake_glXDestroyGLXPixmap( Display
*dpy
, GLXPixmap pixmap
)
1457 XMesaBuffer b
= XMesaFindBuffer(dpy
, pixmap
);
1459 XMesaDestroyBuffer(b
);
1461 else if (_mesa_getenv("MESA_DEBUG")) {
1462 _mesa_warning(NULL
, "Mesa: glXDestroyGLXPixmap: invalid pixmap\n");
1468 Fake_glXCopyContext( Display
*dpy
, GLXContext src
, GLXContext dst
,
1469 unsigned long mask
)
1471 struct fake_glx_context
*fakeSrc
= (struct fake_glx_context
*) src
;
1472 struct fake_glx_context
*fakeDst
= (struct fake_glx_context
*) dst
;
1473 XMesaContext xm_src
= fakeSrc
->xmesaContext
;
1474 XMesaContext xm_dst
= fakeDst
->xmesaContext
;
1476 _mesa_copy_context( &(xm_src
->mesa
), &(xm_dst
->mesa
), (GLuint
) mask
);
1481 Fake_glXQueryExtension( Display
*dpy
, int *errorb
, int *event
)
1483 /* Mesa's GLX isn't really an X extension but we try to act like one. */
1491 extern void _kw_ungrab_all( Display
*dpy
);
1492 void _kw_ungrab_all( Display
*dpy
)
1494 XUngrabPointer( dpy
, CurrentTime
);
1495 XUngrabKeyboard( dpy
, CurrentTime
);
1500 Fake_glXDestroyContext( Display
*dpy
, GLXContext ctx
)
1502 struct fake_glx_context
*glxCtx
= (struct fake_glx_context
*) ctx
;
1504 MakeCurrent_PrevContext
= 0;
1505 MakeCurrent_PrevDrawable
= 0;
1506 MakeCurrent_PrevReadable
= 0;
1507 MakeCurrent_PrevDrawBuffer
= 0;
1508 MakeCurrent_PrevReadBuffer
= 0;
1509 XMesaDestroyContext( glxCtx
->xmesaContext
);
1510 XMesaGarbageCollect();
1515 Fake_glXIsDirect( Display
*dpy
, GLXContext ctx
)
1517 struct fake_glx_context
*glxCtx
= (struct fake_glx_context
*) ctx
;
1519 return glxCtx
->xmesaContext
->direct
;
1525 Fake_glXSwapBuffers( Display
*dpy
, GLXDrawable drawable
)
1527 XMesaBuffer buffer
= XMesaFindBuffer( dpy
, drawable
);
1530 XMesaSwapBuffers(buffer
);
1532 else if (_mesa_getenv("MESA_DEBUG")) {
1533 _mesa_warning(NULL
, "glXSwapBuffers: invalid drawable 0x%x\n",
1540 /*** GLX_MESA_copy_sub_buffer ***/
1543 Fake_glXCopySubBufferMESA( Display
*dpy
, GLXDrawable drawable
,
1544 int x
, int y
, int width
, int height
)
1546 XMesaBuffer buffer
= XMesaFindBuffer( dpy
, drawable
);
1548 XMesaCopySubBuffer(buffer
, x
, y
, width
, height
);
1550 else if (_mesa_getenv("MESA_DEBUG")) {
1551 _mesa_warning(NULL
, "Mesa: glXCopySubBufferMESA: invalid drawable\n");
1557 Fake_glXQueryVersion( Display
*dpy
, int *maj
, int *min
)
1560 /* Return GLX version, not Mesa version */
1561 assert(CLIENT_MAJOR_VERSION
== SERVER_MAJOR_VERSION
);
1562 *maj
= CLIENT_MAJOR_VERSION
;
1563 *min
= MIN2( CLIENT_MINOR_VERSION
, SERVER_MINOR_VERSION
);
1569 * Query the GLX attributes of the given XVisualInfo.
1572 get_config( XMesaVisual xmvis
, int attrib
, int *value
, GLboolean fbconfig
)
1578 return GLX_BAD_ATTRIBUTE
;
1579 *value
= (int) True
;
1581 case GLX_BUFFER_SIZE
:
1582 *value
= xmvis
->visinfo
->depth
;
1585 *value
= xmvis
->mesa_visual
.level
;
1589 return GLX_BAD_ATTRIBUTE
;
1590 if (xmvis
->mesa_visual
.rgbMode
) {
1597 case GLX_DOUBLEBUFFER
:
1598 *value
= (int) xmvis
->mesa_visual
.doubleBufferMode
;
1601 *value
= (int) xmvis
->mesa_visual
.stereoMode
;
1603 case GLX_AUX_BUFFERS
:
1604 *value
= xmvis
->mesa_visual
.numAuxBuffers
;
1607 *value
= xmvis
->mesa_visual
.redBits
;
1609 case GLX_GREEN_SIZE
:
1610 *value
= xmvis
->mesa_visual
.greenBits
;
1613 *value
= xmvis
->mesa_visual
.blueBits
;
1615 case GLX_ALPHA_SIZE
:
1616 *value
= xmvis
->mesa_visual
.alphaBits
;
1618 case GLX_DEPTH_SIZE
:
1619 *value
= xmvis
->mesa_visual
.depthBits
;
1621 case GLX_STENCIL_SIZE
:
1622 *value
= xmvis
->mesa_visual
.stencilBits
;
1624 case GLX_ACCUM_RED_SIZE
:
1625 *value
= xmvis
->mesa_visual
.accumRedBits
;
1627 case GLX_ACCUM_GREEN_SIZE
:
1628 *value
= xmvis
->mesa_visual
.accumGreenBits
;
1630 case GLX_ACCUM_BLUE_SIZE
:
1631 *value
= xmvis
->mesa_visual
.accumBlueBits
;
1633 case GLX_ACCUM_ALPHA_SIZE
:
1634 *value
= xmvis
->mesa_visual
.accumAlphaBits
;
1638 * GLX_EXT_visual_info extension
1640 case GLX_X_VISUAL_TYPE_EXT
:
1641 switch (xmvis
->visinfo
->CLASS
) {
1642 case StaticGray
: *value
= GLX_STATIC_GRAY_EXT
; return 0;
1643 case GrayScale
: *value
= GLX_GRAY_SCALE_EXT
; return 0;
1644 case StaticColor
: *value
= GLX_STATIC_GRAY_EXT
; return 0;
1645 case PseudoColor
: *value
= GLX_PSEUDO_COLOR_EXT
; return 0;
1646 case TrueColor
: *value
= GLX_TRUE_COLOR_EXT
; return 0;
1647 case DirectColor
: *value
= GLX_DIRECT_COLOR_EXT
; return 0;
1650 case GLX_TRANSPARENT_TYPE_EXT
:
1651 if (xmvis
->mesa_visual
.level
==0) {
1653 *value
= GLX_NONE_EXT
;
1655 else if (xmvis
->mesa_visual
.level
>0) {
1657 if (xmvis
->mesa_visual
.rgbMode
) {
1658 *value
= GLX_TRANSPARENT_RGB_EXT
;
1661 *value
= GLX_TRANSPARENT_INDEX_EXT
;
1664 else if (xmvis
->mesa_visual
.level
<0) {
1666 *value
= GLX_NONE_EXT
;
1669 case GLX_TRANSPARENT_INDEX_VALUE_EXT
:
1671 int pixel
= transparent_pixel( xmvis
);
1675 /* else undefined */
1678 case GLX_TRANSPARENT_RED_VALUE_EXT
:
1681 case GLX_TRANSPARENT_GREEN_VALUE_EXT
:
1684 case GLX_TRANSPARENT_BLUE_VALUE_EXT
:
1687 case GLX_TRANSPARENT_ALPHA_VALUE_EXT
:
1692 * GLX_EXT_visual_info extension
1694 case GLX_VISUAL_CAVEAT_EXT
:
1695 /* test for zero, just in case */
1696 if (xmvis
->mesa_visual
.visualRating
> 0)
1697 *value
= xmvis
->mesa_visual
.visualRating
;
1699 *value
= GLX_NONE_EXT
;
1703 * GLX_ARB_multisample
1705 case GLX_SAMPLE_BUFFERS_ARB
:
1708 case GLX_SAMPLES_ARB
:
1715 case GLX_SCREEN_EXT
:
1717 return GLX_BAD_ATTRIBUTE
;
1718 *value
= xmvis
->visinfo
->screen
;
1720 case GLX_DRAWABLE_TYPE
: /*SGIX too */
1722 return GLX_BAD_ATTRIBUTE
;
1723 *value
= GLX_WINDOW_BIT
| GLX_PIXMAP_BIT
| GLX_PBUFFER_BIT
;
1725 case GLX_RENDER_TYPE_SGIX
:
1727 return GLX_BAD_ATTRIBUTE
;
1728 if (xmvis
->mesa_visual
.rgbMode
)
1729 *value
= GLX_RGBA_BIT
;
1731 *value
= GLX_COLOR_INDEX_BIT
;
1733 case GLX_X_RENDERABLE_SGIX
:
1735 return GLX_BAD_ATTRIBUTE
;
1736 *value
= True
; /* XXX really? */
1738 case GLX_FBCONFIG_ID_SGIX
:
1740 return GLX_BAD_ATTRIBUTE
;
1741 *value
= xmvis
->visinfo
->visualid
;
1743 case GLX_MAX_PBUFFER_WIDTH
:
1745 return GLX_BAD_ATTRIBUTE
;
1746 /* XXX or MAX_WIDTH? */
1747 *value
= DisplayWidth(xmvis
->display
, xmvis
->visinfo
->screen
);
1749 case GLX_MAX_PBUFFER_HEIGHT
:
1751 return GLX_BAD_ATTRIBUTE
;
1752 *value
= DisplayHeight(xmvis
->display
, xmvis
->visinfo
->screen
);
1754 case GLX_MAX_PBUFFER_PIXELS
:
1756 return GLX_BAD_ATTRIBUTE
;
1757 *value
= DisplayWidth(xmvis
->display
, xmvis
->visinfo
->screen
) *
1758 DisplayHeight(xmvis
->display
, xmvis
->visinfo
->screen
);
1762 return GLX_BAD_ATTRIBUTE
;
1763 *value
= xmvis
->visinfo
->visualid
;
1767 return GLX_BAD_ATTRIBUTE
;
1774 Fake_glXGetConfig( Display
*dpy
, XVisualInfo
*visinfo
,
1775 int attrib
, int *value
)
1779 if (!dpy
|| !visinfo
)
1780 return GLX_BAD_ATTRIBUTE
;
1782 xmvis
= find_glx_visual( dpy
, visinfo
);
1784 /* this visual wasn't obtained with glXChooseVisual */
1785 xmvis
= create_glx_visual( dpy
, visinfo
);
1787 /* this visual can't be used for GL rendering */
1788 if (attrib
==GLX_USE_GL
) {
1789 *value
= (int) False
;
1793 return GLX_BAD_VISUAL
;
1798 k
= get_config(xmvis
, attrib
, value
, GL_FALSE
);
1804 Fake_glXWaitGL( void )
1806 XMesaContext xmesa
= XMesaGetCurrentContext();
1807 XMesaFlush( xmesa
);
1813 Fake_glXWaitX( void )
1815 XMesaContext xmesa
= XMesaGetCurrentContext();
1816 XMesaFlush( xmesa
);
1821 get_extensions( void )
1824 const char *fx
= _mesa_getenv("MESA_GLX_FX");
1825 if (fx
&& fx
[0] != 'd') {
1829 return EXTENSIONS
+ 23; /* skip "GLX_MESA_set_3dfx_mode" */
1834 /* GLX 1.1 and later */
1836 Fake_glXQueryExtensionsString( Display
*dpy
, int screen
)
1840 return get_extensions();
1845 /* GLX 1.1 and later */
1847 Fake_glXQueryServerString( Display
*dpy
, int screen
, int name
)
1849 static char version
[1000];
1850 _mesa_sprintf(version
, "%d.%d %s",
1851 SERVER_MAJOR_VERSION
, SERVER_MINOR_VERSION
, MESA_GLX_VERSION
);
1857 case GLX_EXTENSIONS
:
1858 return get_extensions();
1870 /* GLX 1.1 and later */
1872 Fake_glXGetClientString( Display
*dpy
, int name
)
1874 static char version
[1000];
1875 _mesa_sprintf(version
, "%d.%d %s", CLIENT_MAJOR_VERSION
,
1876 CLIENT_MINOR_VERSION
, MESA_GLX_VERSION
);
1881 case GLX_EXTENSIONS
:
1882 return get_extensions();
1900 Fake_glXGetFBConfigAttrib( Display
*dpy
, GLXFBConfig config
,
1901 int attribute
, int *value
)
1903 XMesaVisual v
= (XMesaVisual
) config
;
1907 if (!dpy
|| !config
|| !value
)
1910 return get_config(v
, attribute
, value
, GL_TRUE
);
1914 static GLXFBConfig
*
1915 Fake_glXGetFBConfigs( Display
*dpy
, int screen
, int *nelements
)
1917 XVisualInfo
*visuals
, visTemplate
;
1918 const long visMask
= VisualScreenMask
;
1921 /* Get list of all X visuals */
1922 visTemplate
.screen
= screen
;
1923 visuals
= XGetVisualInfo(dpy
, visMask
, &visTemplate
, nelements
);
1924 if (*nelements
> 0) {
1925 XMesaVisual
*results
;
1926 results
= (XMesaVisual
*) _mesa_malloc(*nelements
* sizeof(XMesaVisual
));
1931 for (i
= 0; i
< *nelements
; i
++) {
1932 results
[i
] = create_glx_visual(dpy
, visuals
+ i
);
1934 return (GLXFBConfig
*) results
;
1940 static GLXFBConfig
*
1941 Fake_glXChooseFBConfig( Display
*dpy
, int screen
,
1942 const int *attribList
, int *nitems
)
1946 if (!attribList
|| !attribList
[0]) {
1947 /* return list of all configs (per GLX_SGIX_fbconfig spec) */
1948 return Fake_glXGetFBConfigs(dpy
, screen
, nitems
);
1951 xmvis
= choose_visual(dpy
, screen
, attribList
, GL_TRUE
);
1953 GLXFBConfig
*config
= (GLXFBConfig
*) _mesa_malloc(sizeof(XMesaVisual
));
1959 config
[0] = (GLXFBConfig
) xmvis
;
1960 return (GLXFBConfig
*) config
;
1969 static XVisualInfo
*
1970 Fake_glXGetVisualFromFBConfig( Display
*dpy
, GLXFBConfig config
)
1972 if (dpy
&& config
) {
1973 XMesaVisual xmvis
= (XMesaVisual
) config
;
1975 return xmvis
->vishandle
;
1977 /* create a new vishandle - the cached one may be stale */
1978 xmvis
->vishandle
= (XVisualInfo
*) _mesa_malloc(sizeof(XVisualInfo
));
1979 if (xmvis
->vishandle
) {
1980 _mesa_memcpy(xmvis
->vishandle
, xmvis
->visinfo
, sizeof(XVisualInfo
));
1982 return xmvis
->vishandle
;
1992 Fake_glXCreateWindow( Display
*dpy
, GLXFBConfig config
, Window win
,
1993 const int *attribList
)
1995 XMesaVisual xmvis
= (XMesaVisual
) config
;
2000 xmbuf
= XMesaCreateWindowBuffer2(xmvis
, win
, NULL
);
2005 (void) attribList
; /* Ignored in GLX 1.3 */
2007 return win
; /* A hack for now */
2012 Fake_glXDestroyWindow( Display
*dpy
, GLXWindow window
)
2014 XMesaBuffer b
= XMesaFindBuffer(dpy
, (XMesaDrawable
) window
);
2016 XMesaDestroyBuffer(b
);
2017 /* don't destroy X window */
2023 Fake_glXCreatePixmap( Display
*dpy
, GLXFBConfig config
, Pixmap pixmap
,
2024 const int *attribList
)
2026 XMesaVisual v
= (XMesaVisual
) config
;
2032 (void) attribList
; /* Ignored in GLX 1.3 */
2034 if (!dpy
|| !config
|| !pixmap
)
2037 b
= XMesaCreatePixmapBuffer( v
, pixmap
, 0 );
2047 Fake_glXDestroyPixmap( Display
*dpy
, GLXPixmap pixmap
)
2049 XMesaBuffer b
= XMesaFindBuffer(dpy
, (XMesaDrawable
)pixmap
);
2051 XMesaDestroyBuffer(b
);
2052 /* don't destroy X pixmap */
2057 Fake_glXCreatePbuffer( Display
*dpy
, GLXFBConfig config
,
2058 const int *attribList
)
2060 XMesaVisual xmvis
= (XMesaVisual
) config
;
2063 int width
= 0, height
= 0;
2064 GLboolean useLargest
= GL_FALSE
, preserveContents
= GL_FALSE
;
2068 for (attrib
= attribList
; *attrib
; attrib
++) {
2070 case GLX_PBUFFER_WIDTH
:
2074 case GLX_PBUFFER_HEIGHT
:
2078 case GLX_PRESERVED_CONTENTS
:
2080 preserveContents
= *attrib
; /* ignored */
2082 case GLX_LARGEST_PBUFFER
:
2084 useLargest
= *attrib
; /* ignored */
2091 /* not used at this time */
2093 (void) preserveContents
;
2095 if (width
== 0 || height
== 0)
2098 xmbuf
= XMesaCreatePBuffer( xmvis
, 0, width
, height
);
2099 /* A GLXPbuffer handle must be an X Drawable because that's what
2100 * glXMakeCurrent takes.
2102 return (GLXPbuffer
) xmbuf
->frontxrb
->pixmap
;
2107 Fake_glXDestroyPbuffer( Display
*dpy
, GLXPbuffer pbuf
)
2109 XMesaBuffer b
= XMesaFindBuffer(dpy
, pbuf
);
2111 XMesaDestroyBuffer(b
);
2117 Fake_glXQueryDrawable( Display
*dpy
, GLXDrawable draw
, int attribute
,
2118 unsigned int *value
)
2120 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, draw
);
2124 switch (attribute
) {
2126 *value
= xmbuf
->mesa_buffer
.Width
;
2129 *value
= xmbuf
->mesa_buffer
.Height
;
2131 case GLX_PRESERVED_CONTENTS
:
2134 case GLX_LARGEST_PBUFFER
:
2135 *value
= xmbuf
->mesa_buffer
.Width
* xmbuf
->mesa_buffer
.Height
;
2137 case GLX_FBCONFIG_ID
:
2138 *value
= xmbuf
->xm_visual
->visinfo
->visualid
;
2141 return; /* GLX_BAD_ATTRIBUTE? */
2147 Fake_glXCreateNewContext( Display
*dpy
, GLXFBConfig config
,
2148 int renderType
, GLXContext shareList
, Bool direct
)
2150 struct fake_glx_context
*glxCtx
;
2151 struct fake_glx_context
*shareCtx
= (struct fake_glx_context
*) shareList
;
2152 XMesaVisual xmvis
= (XMesaVisual
) config
;
2154 if (!dpy
|| !config
||
2155 (renderType
!= GLX_RGBA_TYPE
&& renderType
!= GLX_COLOR_INDEX_TYPE
))
2158 glxCtx
= CALLOC_STRUCT(fake_glx_context
);
2162 /* deallocate unused windows/buffers */
2163 XMesaGarbageCollect();
2165 glxCtx
->xmesaContext
= XMesaCreateContext(xmvis
,
2166 shareCtx
? shareCtx
->xmesaContext
: NULL
);
2167 if (!glxCtx
->xmesaContext
) {
2172 glxCtx
->xmesaContext
->direct
= GL_FALSE
;
2173 glxCtx
->glxContext
.isDirect
= GL_FALSE
;
2174 glxCtx
->glxContext
.currentDpy
= dpy
;
2175 glxCtx
->glxContext
.xid
= (XID
) glxCtx
; /* self pointer */
2177 assert((void *) glxCtx
== (void *) &(glxCtx
->glxContext
));
2179 return (GLXContext
) glxCtx
;
2184 Fake_glXQueryContext( Display
*dpy
, GLXContext ctx
, int attribute
, int *value
)
2186 struct fake_glx_context
*glxCtx
= (struct fake_glx_context
*) ctx
;
2187 XMesaContext xmctx
= glxCtx
->xmesaContext
;
2192 switch (attribute
) {
2193 case GLX_FBCONFIG_ID
:
2194 *value
= xmctx
->xm_visual
->visinfo
->visualid
;
2196 case GLX_RENDER_TYPE
:
2197 if (xmctx
->xm_visual
->mesa_visual
.rgbMode
)
2198 *value
= GLX_RGBA_BIT
;
2200 *value
= GLX_COLOR_INDEX_BIT
;
2206 return GLX_BAD_ATTRIBUTE
;
2213 Fake_glXSelectEvent( Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
2215 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, drawable
);
2217 xmbuf
->selectedEvents
= mask
;
2222 Fake_glXGetSelectedEvent( Display
*dpy
, GLXDrawable drawable
,
2223 unsigned long *mask
)
2225 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, drawable
);
2227 *mask
= xmbuf
->selectedEvents
;
2234 /*** GLX_SGI_swap_control ***/
2237 Fake_glXSwapIntervalSGI(int interval
)
2245 /*** GLX_SGI_video_sync ***/
2248 Fake_glXGetVideoSyncSGI(unsigned int *count
)
2255 Fake_glXWaitVideoSyncSGI(int divisor
, int remainder
, unsigned int *count
)
2265 /*** GLX_SGI_make_current_read ***/
2268 Fake_glXMakeCurrentReadSGI(Display
*dpy
, GLXDrawable draw
, GLXDrawable read
, GLXContext ctx
)
2270 return Fake_glXMakeContextCurrent( dpy
, draw
, read
, ctx
);
2275 Fake_glXGetCurrentReadDrawableSGI(void)
2282 /*** GLX_SGIX_video_source ***/
2285 static GLXVideoSourceSGIX
2286 Fake_glXCreateGLXVideoSourceSGIX(Display
*dpy
, int screen
, VLServer server
, VLPath path
, int nodeClass
, VLNode drainNode
)
2298 Fake_glXDestroyGLXVideoSourceSGIX(Display
*dpy
, GLXVideoSourceSGIX src
)
2307 /*** GLX_EXT_import_context ***/
2310 Fake_glXFreeContextEXT(Display
*dpy
, GLXContext context
)
2317 Fake_glXGetContextIDEXT(const GLXContext context
)
2324 Fake_glXImportContextEXT(Display
*dpy
, GLXContextID contextID
)
2332 Fake_glXQueryContextInfoEXT(Display
*dpy
, GLXContext context
, int attribute
, int *value
)
2343 /*** GLX_SGIX_fbconfig ***/
2346 Fake_glXGetFBConfigAttribSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int attribute
, int *value
)
2348 return Fake_glXGetFBConfigAttrib(dpy
, config
, attribute
, value
);
2351 static GLXFBConfigSGIX
*
2352 Fake_glXChooseFBConfigSGIX(Display
*dpy
, int screen
, int *attrib_list
, int *nelements
)
2354 return (GLXFBConfig
*) Fake_glXChooseFBConfig(dpy
, screen
, attrib_list
, nelements
);
2359 Fake_glXCreateGLXPixmapWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, Pixmap pixmap
)
2361 XMesaVisual xmvis
= (XMesaVisual
) config
;
2362 XMesaBuffer xmbuf
= XMesaCreatePixmapBuffer(xmvis
, pixmap
, 0);
2363 return xmbuf
->frontxrb
->pixmap
; /* need to return an X ID */
2368 Fake_glXCreateContextWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int render_type
, GLXContext share_list
, Bool direct
)
2370 XMesaVisual xmvis
= (XMesaVisual
) config
;
2371 struct fake_glx_context
*glxCtx
;
2372 struct fake_glx_context
*shareCtx
= (struct fake_glx_context
*) share_list
;
2374 glxCtx
= CALLOC_STRUCT(fake_glx_context
);
2378 /* deallocate unused windows/buffers */
2379 XMesaGarbageCollect();
2381 glxCtx
->xmesaContext
= XMesaCreateContext(xmvis
,
2382 shareCtx
? shareCtx
->xmesaContext
: NULL
);
2383 if (!glxCtx
->xmesaContext
) {
2388 glxCtx
->xmesaContext
->direct
= GL_FALSE
;
2389 glxCtx
->glxContext
.isDirect
= GL_FALSE
;
2390 glxCtx
->glxContext
.currentDpy
= dpy
;
2391 glxCtx
->glxContext
.xid
= (XID
) glxCtx
; /* self pointer */
2393 assert((void *) glxCtx
== (void *) &(glxCtx
->glxContext
));
2395 return (GLXContext
) glxCtx
;
2399 static XVisualInfo
*
2400 Fake_glXGetVisualFromFBConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
)
2402 return Fake_glXGetVisualFromFBConfig(dpy
, config
);
2406 static GLXFBConfigSGIX
2407 Fake_glXGetFBConfigFromVisualSGIX(Display
*dpy
, XVisualInfo
*vis
)
2409 XMesaVisual xmvis
= find_glx_visual(dpy
, vis
);
2411 /* This visual wasn't found with glXChooseVisual() */
2412 xmvis
= create_glx_visual(dpy
, vis
);
2415 return (GLXFBConfigSGIX
) xmvis
;
2420 /*** GLX_SGIX_pbuffer ***/
2422 static GLXPbufferSGIX
2423 Fake_glXCreateGLXPbufferSGIX(Display
*dpy
, GLXFBConfigSGIX config
,
2424 unsigned int width
, unsigned int height
,
2427 XMesaVisual xmvis
= (XMesaVisual
) config
;
2430 GLboolean useLargest
= GL_FALSE
, preserveContents
= GL_FALSE
;
2434 for (attrib
= attribList
; attrib
&& *attrib
; attrib
++) {
2436 case GLX_PRESERVED_CONTENTS_SGIX
:
2438 preserveContents
= *attrib
; /* ignored */
2440 case GLX_LARGEST_PBUFFER_SGIX
:
2442 useLargest
= *attrib
; /* ignored */
2449 /* not used at this time */
2451 (void) preserveContents
;
2453 xmbuf
= XMesaCreatePBuffer( xmvis
, 0, width
, height
);
2454 /* A GLXPbuffer handle must be an X Drawable because that's what
2455 * glXMakeCurrent takes.
2457 return (GLXPbuffer
) xmbuf
->frontxrb
->pixmap
;
2462 Fake_glXDestroyGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
)
2464 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, pbuf
);
2466 XMesaDestroyBuffer(xmbuf
);
2472 Fake_glXQueryGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
, int attribute
, unsigned int *value
)
2474 const XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, pbuf
);
2477 /* Generate GLXBadPbufferSGIX for bad pbuffer */
2481 switch (attribute
) {
2482 case GLX_PRESERVED_CONTENTS_SGIX
:
2485 case GLX_LARGEST_PBUFFER_SGIX
:
2486 *value
= xmbuf
->mesa_buffer
.Width
* xmbuf
->mesa_buffer
.Height
;
2488 case GLX_WIDTH_SGIX
:
2489 *value
= xmbuf
->mesa_buffer
.Width
;
2491 case GLX_HEIGHT_SGIX
:
2492 *value
= xmbuf
->mesa_buffer
.Height
;
2494 case GLX_EVENT_MASK_SGIX
:
2495 *value
= 0; /* XXX might be wrong */
2505 Fake_glXSelectEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
2507 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, drawable
);
2509 /* Note: we'll never generate clobber events */
2510 xmbuf
->selectedEvents
= mask
;
2516 Fake_glXGetSelectedEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long *mask
)
2518 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, drawable
);
2520 *mask
= xmbuf
->selectedEvents
;
2529 /*** GLX_SGI_cushion ***/
2532 Fake_glXCushionSGI(Display
*dpy
, Window win
, float cushion
)
2541 /*** GLX_SGIX_video_resize ***/
2544 Fake_glXBindChannelToWindowSGIX(Display
*dpy
, int screen
, int channel
, Window window
)
2554 Fake_glXChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int x
, int y
, int w
, int h
)
2567 Fake_glXQueryChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int *x
, int *y
, int *w
, int *h
)
2580 Fake_glXQueryChannelDeltasSGIX(Display
*dpy
, int screen
, int channel
, int *dx
, int *dy
, int *dw
, int *dh
)
2593 Fake_glXChannelRectSyncSGIX(Display
*dpy
, int screen
, int channel
, GLenum synctype
)
2604 /*** GLX_SGIX_dmbuffer **/
2606 #if defined(_DM_BUFFER_H_)
2608 Fake_glXAssociateDMPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuffer
, DMparams
*params
, DMbuffer dmbuffer
)
2619 /*** GLX_SGIX_swap_group ***/
2622 Fake_glXJoinSwapGroupSGIX(Display
*dpy
, GLXDrawable drawable
, GLXDrawable member
)
2631 /*** GLX_SGIX_swap_barrier ***/
2634 Fake_glXBindSwapBarrierSGIX(Display
*dpy
, GLXDrawable drawable
, int barrier
)
2642 Fake_glXQueryMaxSwapBarriersSGIX(Display
*dpy
, int screen
, int *max
)
2652 /*** GLX_SUN_get_transparent_index ***/
2655 Fake_glXGetTransparentIndexSUN(Display
*dpy
, Window overlay
, Window underlay
, long *pTransparent
)
2660 (void) pTransparent
;
2666 /*** GLX_MESA_release_buffers ***/
2669 * Release the depth, stencil, accum buffers attached to a GLXDrawable
2670 * (a window or pixmap) prior to destroying the GLXDrawable.
2673 Fake_glXReleaseBuffersMESA( Display
*dpy
, GLXDrawable d
)
2675 XMesaBuffer b
= XMesaFindBuffer(dpy
, d
);
2677 XMesaDestroyBuffer(b
);
2685 /*** GLX_MESA_set_3dfx_mode ***/
2688 Fake_glXSet3DfxModeMESA( int mode
)
2690 return XMesaSetFXmode( mode
);
2695 /*** GLX_NV_vertex_array range ***/
2697 Fake_glXAllocateMemoryNV( GLsizei size
,
2698 GLfloat readFrequency
,
2699 GLfloat writeFrequency
,
2703 (void) readFrequency
;
2704 (void) writeFrequency
;
2711 Fake_glXFreeMemoryNV( GLvoid
*pointer
)
2717 /*** GLX_MESA_agp_offset ***/
2720 Fake_glXGetAGPOffsetMESA( const GLvoid
*pointer
)
2727 /* silence warning */
2728 extern struct _glxapi_table
*_mesa_GetGLXDispatchTable(void);
2732 * Create a new GLX API dispatch table with its function pointers
2733 * initialized to point to Mesa's "fake" GLX API functions.
2734 * Note: there's a similar function (_real_GetGLXDispatchTable) that
2735 * returns a new dispatch table with all pointers initalized to point
2736 * to "real" GLX functions (which understand GLX wire protocol, etc).
2738 struct _glxapi_table
*
2739 _mesa_GetGLXDispatchTable(void)
2741 static struct _glxapi_table glx
;
2743 /* be sure our dispatch table size <= libGL's table */
2745 GLuint size
= sizeof(struct _glxapi_table
) / sizeof(void *);
2747 assert(_glxapi_get_dispatch_table_size() >= size
);
2750 /* initialize the whole table to no-ops */
2751 _glxapi_set_no_op_table(&glx
);
2753 /* now initialize the table with the functions I implement */
2754 glx
.ChooseVisual
= Fake_glXChooseVisual
;
2755 glx
.CopyContext
= Fake_glXCopyContext
;
2756 glx
.CreateContext
= Fake_glXCreateContext
;
2757 glx
.CreateGLXPixmap
= Fake_glXCreateGLXPixmap
;
2758 glx
.DestroyContext
= Fake_glXDestroyContext
;
2759 glx
.DestroyGLXPixmap
= Fake_glXDestroyGLXPixmap
;
2760 glx
.GetConfig
= Fake_glXGetConfig
;
2761 /*glx.GetCurrentContext = Fake_glXGetCurrentContext;*/
2762 /*glx.GetCurrentDrawable = Fake_glXGetCurrentDrawable;*/
2763 glx
.IsDirect
= Fake_glXIsDirect
;
2764 glx
.MakeCurrent
= Fake_glXMakeCurrent
;
2765 glx
.QueryExtension
= Fake_glXQueryExtension
;
2766 glx
.QueryVersion
= Fake_glXQueryVersion
;
2767 glx
.SwapBuffers
= Fake_glXSwapBuffers
;
2768 glx
.UseXFont
= Fake_glXUseXFont
;
2769 glx
.WaitGL
= Fake_glXWaitGL
;
2770 glx
.WaitX
= Fake_glXWaitX
;
2772 /*** GLX_VERSION_1_1 ***/
2773 glx
.GetClientString
= Fake_glXGetClientString
;
2774 glx
.QueryExtensionsString
= Fake_glXQueryExtensionsString
;
2775 glx
.QueryServerString
= Fake_glXQueryServerString
;
2777 /*** GLX_VERSION_1_2 ***/
2778 /*glx.GetCurrentDisplay = Fake_glXGetCurrentDisplay;*/
2780 /*** GLX_VERSION_1_3 ***/
2781 glx
.ChooseFBConfig
= Fake_glXChooseFBConfig
;
2782 glx
.CreateNewContext
= Fake_glXCreateNewContext
;
2783 glx
.CreatePbuffer
= Fake_glXCreatePbuffer
;
2784 glx
.CreatePixmap
= Fake_glXCreatePixmap
;
2785 glx
.CreateWindow
= Fake_glXCreateWindow
;
2786 glx
.DestroyPbuffer
= Fake_glXDestroyPbuffer
;
2787 glx
.DestroyPixmap
= Fake_glXDestroyPixmap
;
2788 glx
.DestroyWindow
= Fake_glXDestroyWindow
;
2789 /*glx.GetCurrentReadDrawable = Fake_glXGetCurrentReadDrawable;*/
2790 glx
.GetFBConfigAttrib
= Fake_glXGetFBConfigAttrib
;
2791 glx
.GetFBConfigs
= Fake_glXGetFBConfigs
;
2792 glx
.GetSelectedEvent
= Fake_glXGetSelectedEvent
;
2793 glx
.GetVisualFromFBConfig
= Fake_glXGetVisualFromFBConfig
;
2794 glx
.MakeContextCurrent
= Fake_glXMakeContextCurrent
;
2795 glx
.QueryContext
= Fake_glXQueryContext
;
2796 glx
.QueryDrawable
= Fake_glXQueryDrawable
;
2797 glx
.SelectEvent
= Fake_glXSelectEvent
;
2799 /*** GLX_SGI_swap_control ***/
2800 glx
.SwapIntervalSGI
= Fake_glXSwapIntervalSGI
;
2802 /*** GLX_SGI_video_sync ***/
2803 glx
.GetVideoSyncSGI
= Fake_glXGetVideoSyncSGI
;
2804 glx
.WaitVideoSyncSGI
= Fake_glXWaitVideoSyncSGI
;
2806 /*** GLX_SGI_make_current_read ***/
2807 glx
.MakeCurrentReadSGI
= Fake_glXMakeCurrentReadSGI
;
2808 /*glx.GetCurrentReadDrawableSGI = Fake_glXGetCurrentReadDrawableSGI;*/
2810 /*** GLX_SGIX_video_source ***/
2812 glx
.CreateGLXVideoSourceSGIX
= Fake_glXCreateGLXVideoSourceSGIX
;
2813 glx
.DestroyGLXVideoSourceSGIX
= Fake_glXDestroyGLXVideoSourceSGIX
;
2816 /*** GLX_EXT_import_context ***/
2817 glx
.FreeContextEXT
= Fake_glXFreeContextEXT
;
2818 glx
.GetContextIDEXT
= Fake_glXGetContextIDEXT
;
2819 /*glx.GetCurrentDisplayEXT = Fake_glXGetCurrentDisplayEXT;*/
2820 glx
.ImportContextEXT
= Fake_glXImportContextEXT
;
2821 glx
.QueryContextInfoEXT
= Fake_glXQueryContextInfoEXT
;
2823 /*** GLX_SGIX_fbconfig ***/
2824 glx
.GetFBConfigAttribSGIX
= Fake_glXGetFBConfigAttribSGIX
;
2825 glx
.ChooseFBConfigSGIX
= Fake_glXChooseFBConfigSGIX
;
2826 glx
.CreateGLXPixmapWithConfigSGIX
= Fake_glXCreateGLXPixmapWithConfigSGIX
;
2827 glx
.CreateContextWithConfigSGIX
= Fake_glXCreateContextWithConfigSGIX
;
2828 glx
.GetVisualFromFBConfigSGIX
= Fake_glXGetVisualFromFBConfigSGIX
;
2829 glx
.GetFBConfigFromVisualSGIX
= Fake_glXGetFBConfigFromVisualSGIX
;
2831 /*** GLX_SGIX_pbuffer ***/
2832 glx
.CreateGLXPbufferSGIX
= Fake_glXCreateGLXPbufferSGIX
;
2833 glx
.DestroyGLXPbufferSGIX
= Fake_glXDestroyGLXPbufferSGIX
;
2834 glx
.QueryGLXPbufferSGIX
= Fake_glXQueryGLXPbufferSGIX
;
2835 glx
.SelectEventSGIX
= Fake_glXSelectEventSGIX
;
2836 glx
.GetSelectedEventSGIX
= Fake_glXGetSelectedEventSGIX
;
2838 /*** GLX_SGI_cushion ***/
2839 glx
.CushionSGI
= Fake_glXCushionSGI
;
2841 /*** GLX_SGIX_video_resize ***/
2842 glx
.BindChannelToWindowSGIX
= Fake_glXBindChannelToWindowSGIX
;
2843 glx
.ChannelRectSGIX
= Fake_glXChannelRectSGIX
;
2844 glx
.QueryChannelRectSGIX
= Fake_glXQueryChannelRectSGIX
;
2845 glx
.QueryChannelDeltasSGIX
= Fake_glXQueryChannelDeltasSGIX
;
2846 glx
.ChannelRectSyncSGIX
= Fake_glXChannelRectSyncSGIX
;
2848 /*** GLX_SGIX_dmbuffer **/
2849 #if defined(_DM_BUFFER_H_)
2850 glx
.AssociateDMPbufferSGIX
= NULL
;
2853 /*** GLX_SGIX_swap_group ***/
2854 glx
.JoinSwapGroupSGIX
= Fake_glXJoinSwapGroupSGIX
;
2856 /*** GLX_SGIX_swap_barrier ***/
2857 glx
.BindSwapBarrierSGIX
= Fake_glXBindSwapBarrierSGIX
;
2858 glx
.QueryMaxSwapBarriersSGIX
= Fake_glXQueryMaxSwapBarriersSGIX
;
2860 /*** GLX_SUN_get_transparent_index ***/
2861 glx
.GetTransparentIndexSUN
= Fake_glXGetTransparentIndexSUN
;
2863 /*** GLX_MESA_copy_sub_buffer ***/
2864 glx
.CopySubBufferMESA
= Fake_glXCopySubBufferMESA
;
2866 /*** GLX_MESA_release_buffers ***/
2867 glx
.ReleaseBuffersMESA
= Fake_glXReleaseBuffersMESA
;
2869 /*** GLX_MESA_pixmap_colormap ***/
2870 glx
.CreateGLXPixmapMESA
= Fake_glXCreateGLXPixmapMESA
;
2872 /*** GLX_MESA_set_3dfx_mode ***/
2873 glx
.Set3DfxModeMESA
= Fake_glXSet3DfxModeMESA
;
2875 /*** GLX_NV_vertex_array_range ***/
2876 glx
.AllocateMemoryNV
= Fake_glXAllocateMemoryNV
;
2877 glx
.FreeMemoryNV
= Fake_glXFreeMemoryNV
;
2879 /*** GLX_MESA_agp_offset ***/
2880 glx
.GetAGPOffsetMESA
= Fake_glXGetAGPOffsetMESA
;