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
:
1096 if (*parselist
== GLX_RGBA_BIT
) {
1099 else if (*parselist
== GLX_COLOR_INDEX_BIT
) {
1100 rgb_flag
= GL_FALSE
;
1102 else if (*parselist
== 0) {
1107 case GLX_DRAWABLE_TYPE
:
1109 if (*parselist
& ~(GLX_WINDOW_BIT
| GLX_PIXMAP_BIT
| GLX_PBUFFER_BIT
)) {
1110 return NULL
; /* bad bit */
1114 case GLX_FBCONFIG_ID
:
1116 desiredVisualID
= *parselist
;
1124 /* undefined attribute */
1125 _mesa_warning(NULL
, "unexpected attrib 0x%x in choose_visual()",
1134 * Since we're only simulating the GLX extension this function will never
1135 * find any real GL visuals. Instead, all we can do is try to find an RGB
1136 * or CI visual of appropriate depth. Other requested attributes such as
1137 * double buffering, depth buffer, etc. will be associated with the X
1138 * visual and stored in the VisualTable[].
1140 if (desiredVisualID
!= -1) {
1141 /* try to get a specific visual, by visualID */
1144 temp
.visualid
= desiredVisualID
;
1145 temp
.screen
= screen
;
1146 vis
= XGetVisualInfo(dpy
, VisualIDMask
| VisualScreenMask
, &temp
, &n
);
1148 /* give the visual some useful GLX attributes */
1149 double_flag
= GL_TRUE
;
1152 depth_size
= default_depth_bits();
1153 stencil_size
= STENCIL_BITS
;
1157 else if (level
==0) {
1158 /* normal color planes */
1160 /* Get an RGB visual */
1161 int min_rgb
= min_red
+ min_green
+ min_blue
;
1162 if (min_rgb
>1 && min_rgb
<8) {
1163 /* a special case to be sure we can get a monochrome visual */
1166 vis
= choose_x_visual( dpy
, screen
, rgb_flag
, min_rgb
, visual_type
);
1169 /* Get a color index visual */
1170 vis
= choose_x_visual( dpy
, screen
, rgb_flag
, min_ci
, visual_type
);
1171 accumRedSize
= accumGreenSize
= accumBlueSize
= accumAlphaSize
= 0;
1175 /* over/underlay planes */
1178 int min_rgb
= min_red
+ min_green
+ min_blue
;
1179 if (min_rgb
>1 && min_rgb
<8) {
1180 /* a special case to be sure we can get a monochrome visual */
1183 vis
= choose_x_overlay_visual( dpy
, screen
, rgb_flag
, level
,
1184 trans_type
, trans_value
, min_rgb
, visual_type
);
1187 /* color index overlay */
1188 vis
= choose_x_overlay_visual( dpy
, screen
, rgb_flag
, level
,
1189 trans_type
, trans_value
, min_ci
, visual_type
);
1194 /* Note: we're not exactly obeying the glXChooseVisual rules here.
1195 * When GLX_DEPTH_SIZE = 1 is specified we're supposed to choose the
1196 * largest depth buffer size, which is 32bits/value. Instead, we
1197 * return 16 to maintain performance with earlier versions of Mesa.
1199 if (depth_size
> 24)
1200 depth_size
= 31; /* 32 causes int overflow problems */
1201 else if (depth_size
> 16)
1203 else if (depth_size
> 0) {
1204 depth_size
= default_depth_bits();
1207 /* we only support one size of stencil and accum buffers. */
1208 if (stencil_size
> 0)
1209 stencil_size
= STENCIL_BITS
;
1210 if (accumRedSize
> 0 || accumGreenSize
> 0 || accumBlueSize
> 0 ||
1211 accumAlphaSize
> 0) {
1212 accumRedSize
= ACCUM_BITS
;
1213 accumGreenSize
= ACCUM_BITS
;
1214 accumBlueSize
= ACCUM_BITS
;
1215 accumAlphaSize
= alpha_flag
? ACCUM_BITS
: 0;
1218 xmvis
= save_glx_visual( dpy
, vis
, rgb_flag
, alpha_flag
, double_flag
,
1219 stereo_flag
, depth_size
, stencil_size
,
1220 accumRedSize
, accumGreenSize
,
1221 accumBlueSize
, accumAlphaSize
, level
, numAux
);
1228 static XVisualInfo
*
1229 Fake_glXChooseVisual( Display
*dpy
, int screen
, int *list
)
1231 XMesaVisual xmvis
= choose_visual(dpy
, screen
, list
, GL_FALSE
);
1234 return xmvis
->vishandle
;
1236 /* create a new vishandle - the cached one may be stale */
1237 xmvis
->vishandle
= (XVisualInfo
*) _mesa_malloc(sizeof(XVisualInfo
));
1238 if (xmvis
->vishandle
) {
1239 _mesa_memcpy(xmvis
->vishandle
, xmvis
->visinfo
, sizeof(XVisualInfo
));
1241 return xmvis
->vishandle
;
1250 Fake_glXCreateContext( Display
*dpy
, XVisualInfo
*visinfo
,
1251 GLXContext share_list
, Bool direct
)
1254 struct fake_glx_context
*glxCtx
;
1255 struct fake_glx_context
*shareCtx
= (struct fake_glx_context
*) share_list
;
1257 if (!dpy
|| !visinfo
)
1260 glxCtx
= CALLOC_STRUCT(fake_glx_context
);
1264 /* deallocate unused windows/buffers */
1265 XMesaGarbageCollect();
1267 xmvis
= find_glx_visual( dpy
, visinfo
);
1269 /* This visual wasn't found with glXChooseVisual() */
1270 xmvis
= create_glx_visual( dpy
, visinfo
);
1272 /* unusable visual */
1278 glxCtx
->xmesaContext
= XMesaCreateContext(xmvis
,
1279 shareCtx
? shareCtx
->xmesaContext
: NULL
);
1280 if (!glxCtx
->xmesaContext
) {
1285 glxCtx
->xmesaContext
->direct
= GL_FALSE
;
1286 glxCtx
->glxContext
.isDirect
= GL_FALSE
;
1287 glxCtx
->glxContext
.currentDpy
= dpy
;
1288 glxCtx
->glxContext
.xid
= (XID
) glxCtx
; /* self pointer */
1290 assert((void *) glxCtx
== (void *) &(glxCtx
->glxContext
));
1292 return (GLXContext
) glxCtx
;
1296 /* XXX these may have to be removed due to thread-safety issues. */
1297 static GLXContext MakeCurrent_PrevContext
= 0;
1298 static GLXDrawable MakeCurrent_PrevDrawable
= 0;
1299 static GLXDrawable MakeCurrent_PrevReadable
= 0;
1300 static XMesaBuffer MakeCurrent_PrevDrawBuffer
= 0;
1301 static XMesaBuffer MakeCurrent_PrevReadBuffer
= 0;
1304 /* GLX 1.3 and later */
1306 Fake_glXMakeContextCurrent( Display
*dpy
, GLXDrawable draw
,
1307 GLXDrawable read
, GLXContext ctx
)
1309 struct fake_glx_context
*glxCtx
= (struct fake_glx_context
*) ctx
;
1311 if (ctx
&& draw
&& read
) {
1312 XMesaBuffer drawBuffer
, readBuffer
;
1313 XMesaContext xmctx
= glxCtx
->xmesaContext
;
1315 /* Find the XMesaBuffer which corresponds to the GLXDrawable 'draw' */
1316 if (ctx
== MakeCurrent_PrevContext
1317 && draw
== MakeCurrent_PrevDrawable
) {
1318 drawBuffer
= MakeCurrent_PrevDrawBuffer
;
1321 drawBuffer
= XMesaFindBuffer( dpy
, draw
);
1324 /* drawable must be a new window! */
1325 drawBuffer
= XMesaCreateWindowBuffer2( xmctx
->xm_visual
, draw
, xmctx
);
1327 /* Out of memory, or context/drawable depth mismatch */
1332 /* Find the XMesaBuffer which corresponds to the GLXDrawable 'read' */
1333 if (ctx
== MakeCurrent_PrevContext
1334 && read
== MakeCurrent_PrevReadable
) {
1335 readBuffer
= MakeCurrent_PrevReadBuffer
;
1338 readBuffer
= XMesaFindBuffer( dpy
, read
);
1341 /* drawable must be a new window! */
1342 readBuffer
= XMesaCreateWindowBuffer2(glxCtx
->xmesaContext
->xm_visual
,
1345 /* Out of memory, or context/drawable depth mismatch */
1350 MakeCurrent_PrevContext
= ctx
;
1351 MakeCurrent_PrevDrawable
= draw
;
1352 MakeCurrent_PrevReadable
= read
;
1353 MakeCurrent_PrevDrawBuffer
= drawBuffer
;
1354 MakeCurrent_PrevReadBuffer
= readBuffer
;
1356 /* Now make current! */
1357 if (XMesaMakeCurrent2(xmctx
, drawBuffer
, readBuffer
)) {
1358 ((__GLXcontext
*) ctx
)->currentDpy
= dpy
;
1359 ((__GLXcontext
*) ctx
)->currentDrawable
= draw
;
1360 ((__GLXcontext
*) ctx
)->currentReadable
= read
;
1367 else if (!ctx
&& !draw
&& !read
) {
1368 /* release current context w/out assigning new one. */
1369 XMesaMakeCurrent( NULL
, NULL
);
1370 MakeCurrent_PrevContext
= 0;
1371 MakeCurrent_PrevDrawable
= 0;
1372 MakeCurrent_PrevReadable
= 0;
1373 MakeCurrent_PrevDrawBuffer
= 0;
1374 MakeCurrent_PrevReadBuffer
= 0;
1378 /* The args must either all be non-zero or all zero.
1387 Fake_glXMakeCurrent( Display
*dpy
, GLXDrawable drawable
, GLXContext ctx
)
1389 return Fake_glXMakeContextCurrent( dpy
, drawable
, drawable
, ctx
);
1394 Fake_glXCreateGLXPixmap( Display
*dpy
, XVisualInfo
*visinfo
, Pixmap pixmap
)
1399 v
= find_glx_visual( dpy
, visinfo
);
1401 v
= create_glx_visual( dpy
, visinfo
);
1403 /* unusable visual */
1408 b
= XMesaCreatePixmapBuffer( v
, pixmap
, 0 );
1412 return b
->frontxrb
->pixmap
;
1416 /*** GLX_MESA_pixmap_colormap ***/
1419 Fake_glXCreateGLXPixmapMESA( Display
*dpy
, XVisualInfo
*visinfo
,
1420 Pixmap pixmap
, Colormap cmap
)
1425 v
= find_glx_visual( dpy
, visinfo
);
1427 v
= create_glx_visual( dpy
, visinfo
);
1429 /* unusable visual */
1434 b
= XMesaCreatePixmapBuffer( v
, pixmap
, cmap
);
1438 return b
->frontxrb
->pixmap
;
1443 Fake_glXDestroyGLXPixmap( Display
*dpy
, GLXPixmap pixmap
)
1445 XMesaBuffer b
= XMesaFindBuffer(dpy
, pixmap
);
1447 XMesaDestroyBuffer(b
);
1449 else if (_mesa_getenv("MESA_DEBUG")) {
1450 _mesa_warning(NULL
, "Mesa: glXDestroyGLXPixmap: invalid pixmap\n");
1456 Fake_glXCopyContext( Display
*dpy
, GLXContext src
, GLXContext dst
,
1457 unsigned long mask
)
1459 struct fake_glx_context
*fakeSrc
= (struct fake_glx_context
*) src
;
1460 struct fake_glx_context
*fakeDst
= (struct fake_glx_context
*) dst
;
1461 XMesaContext xm_src
= fakeSrc
->xmesaContext
;
1462 XMesaContext xm_dst
= fakeDst
->xmesaContext
;
1464 _mesa_copy_context( &(xm_src
->mesa
), &(xm_dst
->mesa
), (GLuint
) mask
);
1469 Fake_glXQueryExtension( Display
*dpy
, int *errorb
, int *event
)
1471 /* Mesa's GLX isn't really an X extension but we try to act like one. */
1479 extern void _kw_ungrab_all( Display
*dpy
);
1480 void _kw_ungrab_all( Display
*dpy
)
1482 XUngrabPointer( dpy
, CurrentTime
);
1483 XUngrabKeyboard( dpy
, CurrentTime
);
1488 Fake_glXDestroyContext( Display
*dpy
, GLXContext ctx
)
1490 struct fake_glx_context
*glxCtx
= (struct fake_glx_context
*) ctx
;
1492 MakeCurrent_PrevContext
= 0;
1493 MakeCurrent_PrevDrawable
= 0;
1494 MakeCurrent_PrevReadable
= 0;
1495 MakeCurrent_PrevDrawBuffer
= 0;
1496 MakeCurrent_PrevReadBuffer
= 0;
1497 XMesaDestroyContext( glxCtx
->xmesaContext
);
1498 XMesaGarbageCollect();
1503 Fake_glXIsDirect( Display
*dpy
, GLXContext ctx
)
1505 struct fake_glx_context
*glxCtx
= (struct fake_glx_context
*) ctx
;
1507 return glxCtx
->xmesaContext
->direct
;
1513 Fake_glXSwapBuffers( Display
*dpy
, GLXDrawable drawable
)
1515 XMesaBuffer buffer
= XMesaFindBuffer( dpy
, drawable
);
1518 XMesaSwapBuffers(buffer
);
1520 else if (_mesa_getenv("MESA_DEBUG")) {
1521 _mesa_warning(NULL
, "glXSwapBuffers: invalid drawable 0x%x\n",
1528 /*** GLX_MESA_copy_sub_buffer ***/
1531 Fake_glXCopySubBufferMESA( Display
*dpy
, GLXDrawable drawable
,
1532 int x
, int y
, int width
, int height
)
1534 XMesaBuffer buffer
= XMesaFindBuffer( dpy
, drawable
);
1536 XMesaCopySubBuffer(buffer
, x
, y
, width
, height
);
1538 else if (_mesa_getenv("MESA_DEBUG")) {
1539 _mesa_warning(NULL
, "Mesa: glXCopySubBufferMESA: invalid drawable\n");
1545 Fake_glXQueryVersion( Display
*dpy
, int *maj
, int *min
)
1548 /* Return GLX version, not Mesa version */
1549 assert(CLIENT_MAJOR_VERSION
== SERVER_MAJOR_VERSION
);
1550 *maj
= CLIENT_MAJOR_VERSION
;
1551 *min
= MIN2( CLIENT_MINOR_VERSION
, SERVER_MINOR_VERSION
);
1557 * Query the GLX attributes of the given XVisualInfo.
1560 get_config( XMesaVisual xmvis
, int attrib
, int *value
, GLboolean fbconfig
)
1566 return GLX_BAD_ATTRIBUTE
;
1567 *value
= (int) True
;
1569 case GLX_BUFFER_SIZE
:
1570 *value
= xmvis
->visinfo
->depth
;
1573 *value
= xmvis
->mesa_visual
.level
;
1577 return GLX_BAD_ATTRIBUTE
;
1578 if (xmvis
->mesa_visual
.rgbMode
) {
1585 case GLX_DOUBLEBUFFER
:
1586 *value
= (int) xmvis
->mesa_visual
.doubleBufferMode
;
1589 *value
= (int) xmvis
->mesa_visual
.stereoMode
;
1591 case GLX_AUX_BUFFERS
:
1592 *value
= xmvis
->mesa_visual
.numAuxBuffers
;
1595 *value
= xmvis
->mesa_visual
.redBits
;
1597 case GLX_GREEN_SIZE
:
1598 *value
= xmvis
->mesa_visual
.greenBits
;
1601 *value
= xmvis
->mesa_visual
.blueBits
;
1603 case GLX_ALPHA_SIZE
:
1604 *value
= xmvis
->mesa_visual
.alphaBits
;
1606 case GLX_DEPTH_SIZE
:
1607 *value
= xmvis
->mesa_visual
.depthBits
;
1609 case GLX_STENCIL_SIZE
:
1610 *value
= xmvis
->mesa_visual
.stencilBits
;
1612 case GLX_ACCUM_RED_SIZE
:
1613 *value
= xmvis
->mesa_visual
.accumRedBits
;
1615 case GLX_ACCUM_GREEN_SIZE
:
1616 *value
= xmvis
->mesa_visual
.accumGreenBits
;
1618 case GLX_ACCUM_BLUE_SIZE
:
1619 *value
= xmvis
->mesa_visual
.accumBlueBits
;
1621 case GLX_ACCUM_ALPHA_SIZE
:
1622 *value
= xmvis
->mesa_visual
.accumAlphaBits
;
1626 * GLX_EXT_visual_info extension
1628 case GLX_X_VISUAL_TYPE_EXT
:
1629 switch (xmvis
->visinfo
->CLASS
) {
1630 case StaticGray
: *value
= GLX_STATIC_GRAY_EXT
; return 0;
1631 case GrayScale
: *value
= GLX_GRAY_SCALE_EXT
; return 0;
1632 case StaticColor
: *value
= GLX_STATIC_GRAY_EXT
; return 0;
1633 case PseudoColor
: *value
= GLX_PSEUDO_COLOR_EXT
; return 0;
1634 case TrueColor
: *value
= GLX_TRUE_COLOR_EXT
; return 0;
1635 case DirectColor
: *value
= GLX_DIRECT_COLOR_EXT
; return 0;
1638 case GLX_TRANSPARENT_TYPE_EXT
:
1639 if (xmvis
->mesa_visual
.level
==0) {
1641 *value
= GLX_NONE_EXT
;
1643 else if (xmvis
->mesa_visual
.level
>0) {
1645 if (xmvis
->mesa_visual
.rgbMode
) {
1646 *value
= GLX_TRANSPARENT_RGB_EXT
;
1649 *value
= GLX_TRANSPARENT_INDEX_EXT
;
1652 else if (xmvis
->mesa_visual
.level
<0) {
1654 *value
= GLX_NONE_EXT
;
1657 case GLX_TRANSPARENT_INDEX_VALUE_EXT
:
1659 int pixel
= transparent_pixel( xmvis
);
1663 /* else undefined */
1666 case GLX_TRANSPARENT_RED_VALUE_EXT
:
1669 case GLX_TRANSPARENT_GREEN_VALUE_EXT
:
1672 case GLX_TRANSPARENT_BLUE_VALUE_EXT
:
1675 case GLX_TRANSPARENT_ALPHA_VALUE_EXT
:
1680 * GLX_EXT_visual_info extension
1682 case GLX_VISUAL_CAVEAT_EXT
:
1683 /* test for zero, just in case */
1684 if (xmvis
->mesa_visual
.visualRating
> 0)
1685 *value
= xmvis
->mesa_visual
.visualRating
;
1687 *value
= GLX_NONE_EXT
;
1691 * GLX_ARB_multisample
1693 case GLX_SAMPLE_BUFFERS_ARB
:
1696 case GLX_SAMPLES_ARB
:
1703 case GLX_SCREEN_EXT
:
1705 return GLX_BAD_ATTRIBUTE
;
1706 *value
= xmvis
->visinfo
->screen
;
1708 case GLX_DRAWABLE_TYPE
: /*SGIX too */
1710 return GLX_BAD_ATTRIBUTE
;
1711 *value
= GLX_WINDOW_BIT
| GLX_PIXMAP_BIT
| GLX_PBUFFER_BIT
;
1713 case GLX_RENDER_TYPE_SGIX
:
1715 return GLX_BAD_ATTRIBUTE
;
1716 if (xmvis
->mesa_visual
.rgbMode
)
1717 *value
= GLX_RGBA_BIT
;
1719 *value
= GLX_COLOR_INDEX_BIT
;
1721 case GLX_X_RENDERABLE_SGIX
:
1723 return GLX_BAD_ATTRIBUTE
;
1724 *value
= True
; /* XXX really? */
1726 case GLX_FBCONFIG_ID_SGIX
:
1728 return GLX_BAD_ATTRIBUTE
;
1729 *value
= xmvis
->visinfo
->visualid
;
1731 case GLX_MAX_PBUFFER_WIDTH
:
1733 return GLX_BAD_ATTRIBUTE
;
1734 /* XXX or MAX_WIDTH? */
1735 *value
= DisplayWidth(xmvis
->display
, xmvis
->visinfo
->screen
);
1737 case GLX_MAX_PBUFFER_HEIGHT
:
1739 return GLX_BAD_ATTRIBUTE
;
1740 *value
= DisplayHeight(xmvis
->display
, xmvis
->visinfo
->screen
);
1742 case GLX_MAX_PBUFFER_PIXELS
:
1744 return GLX_BAD_ATTRIBUTE
;
1745 *value
= DisplayWidth(xmvis
->display
, xmvis
->visinfo
->screen
) *
1746 DisplayHeight(xmvis
->display
, xmvis
->visinfo
->screen
);
1750 return GLX_BAD_ATTRIBUTE
;
1751 *value
= xmvis
->visinfo
->visualid
;
1755 return GLX_BAD_ATTRIBUTE
;
1762 Fake_glXGetConfig( Display
*dpy
, XVisualInfo
*visinfo
,
1763 int attrib
, int *value
)
1767 if (!dpy
|| !visinfo
)
1768 return GLX_BAD_ATTRIBUTE
;
1770 xmvis
= find_glx_visual( dpy
, visinfo
);
1772 /* this visual wasn't obtained with glXChooseVisual */
1773 xmvis
= create_glx_visual( dpy
, visinfo
);
1775 /* this visual can't be used for GL rendering */
1776 if (attrib
==GLX_USE_GL
) {
1777 *value
= (int) False
;
1781 return GLX_BAD_VISUAL
;
1786 k
= get_config(xmvis
, attrib
, value
, GL_FALSE
);
1792 Fake_glXWaitGL( void )
1794 XMesaContext xmesa
= XMesaGetCurrentContext();
1795 XMesaFlush( xmesa
);
1801 Fake_glXWaitX( void )
1803 XMesaContext xmesa
= XMesaGetCurrentContext();
1804 XMesaFlush( xmesa
);
1809 get_extensions( void )
1812 const char *fx
= _mesa_getenv("MESA_GLX_FX");
1813 if (fx
&& fx
[0] != 'd') {
1817 return EXTENSIONS
+ 23; /* skip "GLX_MESA_set_3dfx_mode" */
1822 /* GLX 1.1 and later */
1824 Fake_glXQueryExtensionsString( Display
*dpy
, int screen
)
1828 return get_extensions();
1833 /* GLX 1.1 and later */
1835 Fake_glXQueryServerString( Display
*dpy
, int screen
, int name
)
1837 static char version
[1000];
1838 _mesa_sprintf(version
, "%d.%d %s",
1839 SERVER_MAJOR_VERSION
, SERVER_MINOR_VERSION
, MESA_GLX_VERSION
);
1845 case GLX_EXTENSIONS
:
1846 return get_extensions();
1858 /* GLX 1.1 and later */
1860 Fake_glXGetClientString( Display
*dpy
, int name
)
1862 static char version
[1000];
1863 _mesa_sprintf(version
, "%d.%d %s", CLIENT_MAJOR_VERSION
,
1864 CLIENT_MINOR_VERSION
, MESA_GLX_VERSION
);
1869 case GLX_EXTENSIONS
:
1870 return get_extensions();
1888 Fake_glXGetFBConfigAttrib( Display
*dpy
, GLXFBConfig config
,
1889 int attribute
, int *value
)
1891 XMesaVisual v
= (XMesaVisual
) config
;
1895 if (!dpy
|| !config
|| !value
)
1898 return get_config(v
, attribute
, value
, GL_TRUE
);
1902 static GLXFBConfig
*
1903 Fake_glXGetFBConfigs( Display
*dpy
, int screen
, int *nelements
)
1905 XVisualInfo
*visuals
, visTemplate
;
1906 const long visMask
= VisualScreenMask
;
1909 /* Get list of all X visuals */
1910 visTemplate
.screen
= screen
;
1911 visuals
= XGetVisualInfo(dpy
, visMask
, &visTemplate
, nelements
);
1912 if (*nelements
> 0) {
1913 XMesaVisual
*results
;
1914 results
= (XMesaVisual
*) _mesa_malloc(*nelements
* sizeof(XMesaVisual
));
1919 for (i
= 0; i
< *nelements
; i
++) {
1920 results
[i
] = create_glx_visual(dpy
, visuals
+ i
);
1922 return (GLXFBConfig
*) results
;
1928 static GLXFBConfig
*
1929 Fake_glXChooseFBConfig( Display
*dpy
, int screen
,
1930 const int *attribList
, int *nitems
)
1934 if (!attribList
|| !attribList
[0]) {
1935 /* return list of all configs (per GLX_SGIX_fbconfig spec) */
1936 return Fake_glXGetFBConfigs(dpy
, screen
, nitems
);
1939 xmvis
= choose_visual(dpy
, screen
, attribList
, GL_TRUE
);
1941 GLXFBConfig
*config
= (GLXFBConfig
*) _mesa_malloc(sizeof(XMesaVisual
));
1947 config
[0] = (GLXFBConfig
) xmvis
;
1948 return (GLXFBConfig
*) config
;
1957 static XVisualInfo
*
1958 Fake_glXGetVisualFromFBConfig( Display
*dpy
, GLXFBConfig config
)
1960 if (dpy
&& config
) {
1961 XMesaVisual xmvis
= (XMesaVisual
) config
;
1963 return xmvis
->vishandle
;
1965 /* create a new vishandle - the cached one may be stale */
1966 xmvis
->vishandle
= (XVisualInfo
*) _mesa_malloc(sizeof(XVisualInfo
));
1967 if (xmvis
->vishandle
) {
1968 _mesa_memcpy(xmvis
->vishandle
, xmvis
->visinfo
, sizeof(XVisualInfo
));
1970 return xmvis
->vishandle
;
1980 Fake_glXCreateWindow( Display
*dpy
, GLXFBConfig config
, Window win
,
1981 const int *attribList
)
1983 XMesaVisual xmvis
= (XMesaVisual
) config
;
1988 xmbuf
= XMesaCreateWindowBuffer2(xmvis
, win
, NULL
);
1993 (void) attribList
; /* Ignored in GLX 1.3 */
1995 return win
; /* A hack for now */
2000 Fake_glXDestroyWindow( Display
*dpy
, GLXWindow window
)
2002 XMesaBuffer b
= XMesaFindBuffer(dpy
, (XMesaDrawable
) window
);
2004 XMesaDestroyBuffer(b
);
2005 /* don't destroy X window */
2011 Fake_glXCreatePixmap( Display
*dpy
, GLXFBConfig config
, Pixmap pixmap
,
2012 const int *attribList
)
2014 XMesaVisual v
= (XMesaVisual
) config
;
2020 (void) attribList
; /* Ignored in GLX 1.3 */
2022 if (!dpy
|| !config
|| !pixmap
)
2025 b
= XMesaCreatePixmapBuffer( v
, pixmap
, 0 );
2035 Fake_glXDestroyPixmap( Display
*dpy
, GLXPixmap pixmap
)
2037 XMesaBuffer b
= XMesaFindBuffer(dpy
, (XMesaDrawable
)pixmap
);
2039 XMesaDestroyBuffer(b
);
2040 /* don't destroy X pixmap */
2045 Fake_glXCreatePbuffer( Display
*dpy
, GLXFBConfig config
,
2046 const int *attribList
)
2048 XMesaVisual xmvis
= (XMesaVisual
) config
;
2051 int width
= 0, height
= 0;
2052 GLboolean useLargest
= GL_FALSE
, preserveContents
= GL_FALSE
;
2056 for (attrib
= attribList
; *attrib
; attrib
++) {
2058 case GLX_PBUFFER_WIDTH
:
2062 case GLX_PBUFFER_HEIGHT
:
2066 case GLX_PRESERVED_CONTENTS
:
2068 preserveContents
= *attrib
; /* ignored */
2070 case GLX_LARGEST_PBUFFER
:
2072 useLargest
= *attrib
; /* ignored */
2079 /* not used at this time */
2081 (void) preserveContents
;
2083 if (width
== 0 || height
== 0)
2086 xmbuf
= XMesaCreatePBuffer( xmvis
, 0, width
, height
);
2087 /* A GLXPbuffer handle must be an X Drawable because that's what
2088 * glXMakeCurrent takes.
2090 return (GLXPbuffer
) xmbuf
->frontxrb
->pixmap
;
2095 Fake_glXDestroyPbuffer( Display
*dpy
, GLXPbuffer pbuf
)
2097 XMesaBuffer b
= XMesaFindBuffer(dpy
, pbuf
);
2099 XMesaDestroyBuffer(b
);
2105 Fake_glXQueryDrawable( Display
*dpy
, GLXDrawable draw
, int attribute
,
2106 unsigned int *value
)
2108 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, draw
);
2112 switch (attribute
) {
2114 *value
= xmbuf
->mesa_buffer
.Width
;
2117 *value
= xmbuf
->mesa_buffer
.Height
;
2119 case GLX_PRESERVED_CONTENTS
:
2122 case GLX_LARGEST_PBUFFER
:
2123 *value
= xmbuf
->mesa_buffer
.Width
* xmbuf
->mesa_buffer
.Height
;
2125 case GLX_FBCONFIG_ID
:
2126 *value
= xmbuf
->xm_visual
->visinfo
->visualid
;
2129 return; /* GLX_BAD_ATTRIBUTE? */
2135 Fake_glXCreateNewContext( Display
*dpy
, GLXFBConfig config
,
2136 int renderType
, GLXContext shareList
, Bool direct
)
2138 struct fake_glx_context
*glxCtx
;
2139 struct fake_glx_context
*shareCtx
= (struct fake_glx_context
*) shareList
;
2140 XMesaVisual xmvis
= (XMesaVisual
) config
;
2142 if (!dpy
|| !config
||
2143 (renderType
!= GLX_RGBA_TYPE
&& renderType
!= GLX_COLOR_INDEX_TYPE
))
2146 glxCtx
= CALLOC_STRUCT(fake_glx_context
);
2150 /* deallocate unused windows/buffers */
2151 XMesaGarbageCollect();
2153 glxCtx
->xmesaContext
= XMesaCreateContext(xmvis
,
2154 shareCtx
? shareCtx
->xmesaContext
: NULL
);
2155 if (!glxCtx
->xmesaContext
) {
2160 glxCtx
->xmesaContext
->direct
= GL_FALSE
;
2161 glxCtx
->glxContext
.isDirect
= GL_FALSE
;
2162 glxCtx
->glxContext
.currentDpy
= dpy
;
2163 glxCtx
->glxContext
.xid
= (XID
) glxCtx
; /* self pointer */
2165 assert((void *) glxCtx
== (void *) &(glxCtx
->glxContext
));
2167 return (GLXContext
) glxCtx
;
2172 Fake_glXQueryContext( Display
*dpy
, GLXContext ctx
, int attribute
, int *value
)
2174 struct fake_glx_context
*glxCtx
= (struct fake_glx_context
*) ctx
;
2175 XMesaContext xmctx
= glxCtx
->xmesaContext
;
2180 switch (attribute
) {
2181 case GLX_FBCONFIG_ID
:
2182 *value
= xmctx
->xm_visual
->visinfo
->visualid
;
2184 case GLX_RENDER_TYPE
:
2185 if (xmctx
->xm_visual
->mesa_visual
.rgbMode
)
2186 *value
= GLX_RGBA_BIT
;
2188 *value
= GLX_COLOR_INDEX_BIT
;
2194 return GLX_BAD_ATTRIBUTE
;
2201 Fake_glXSelectEvent( Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
2203 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, drawable
);
2205 xmbuf
->selectedEvents
= mask
;
2210 Fake_glXGetSelectedEvent( Display
*dpy
, GLXDrawable drawable
,
2211 unsigned long *mask
)
2213 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, drawable
);
2215 *mask
= xmbuf
->selectedEvents
;
2222 /*** GLX_SGI_swap_control ***/
2225 Fake_glXSwapIntervalSGI(int interval
)
2233 /*** GLX_SGI_video_sync ***/
2236 Fake_glXGetVideoSyncSGI(unsigned int *count
)
2243 Fake_glXWaitVideoSyncSGI(int divisor
, int remainder
, unsigned int *count
)
2253 /*** GLX_SGI_make_current_read ***/
2256 Fake_glXMakeCurrentReadSGI(Display
*dpy
, GLXDrawable draw
, GLXDrawable read
, GLXContext ctx
)
2258 return Fake_glXMakeContextCurrent( dpy
, draw
, read
, ctx
);
2263 Fake_glXGetCurrentReadDrawableSGI(void)
2270 /*** GLX_SGIX_video_source ***/
2273 static GLXVideoSourceSGIX
2274 Fake_glXCreateGLXVideoSourceSGIX(Display
*dpy
, int screen
, VLServer server
, VLPath path
, int nodeClass
, VLNode drainNode
)
2286 Fake_glXDestroyGLXVideoSourceSGIX(Display
*dpy
, GLXVideoSourceSGIX src
)
2295 /*** GLX_EXT_import_context ***/
2298 Fake_glXFreeContextEXT(Display
*dpy
, GLXContext context
)
2305 Fake_glXGetContextIDEXT(const GLXContext context
)
2312 Fake_glXImportContextEXT(Display
*dpy
, GLXContextID contextID
)
2320 Fake_glXQueryContextInfoEXT(Display
*dpy
, GLXContext context
, int attribute
, int *value
)
2331 /*** GLX_SGIX_fbconfig ***/
2334 Fake_glXGetFBConfigAttribSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int attribute
, int *value
)
2336 return Fake_glXGetFBConfigAttrib(dpy
, config
, attribute
, value
);
2339 static GLXFBConfigSGIX
*
2340 Fake_glXChooseFBConfigSGIX(Display
*dpy
, int screen
, int *attrib_list
, int *nelements
)
2342 return (GLXFBConfig
*) Fake_glXChooseFBConfig(dpy
, screen
, attrib_list
, nelements
);
2347 Fake_glXCreateGLXPixmapWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, Pixmap pixmap
)
2349 XMesaVisual xmvis
= (XMesaVisual
) config
;
2350 XMesaBuffer xmbuf
= XMesaCreatePixmapBuffer(xmvis
, pixmap
, 0);
2351 return xmbuf
->frontxrb
->pixmap
; /* need to return an X ID */
2356 Fake_glXCreateContextWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int render_type
, GLXContext share_list
, Bool direct
)
2358 XMesaVisual xmvis
= (XMesaVisual
) config
;
2359 struct fake_glx_context
*glxCtx
;
2360 struct fake_glx_context
*shareCtx
= (struct fake_glx_context
*) share_list
;
2362 glxCtx
= CALLOC_STRUCT(fake_glx_context
);
2366 /* deallocate unused windows/buffers */
2367 XMesaGarbageCollect();
2369 glxCtx
->xmesaContext
= XMesaCreateContext(xmvis
,
2370 shareCtx
? shareCtx
->xmesaContext
: NULL
);
2371 if (!glxCtx
->xmesaContext
) {
2376 glxCtx
->xmesaContext
->direct
= GL_FALSE
;
2377 glxCtx
->glxContext
.isDirect
= GL_FALSE
;
2378 glxCtx
->glxContext
.currentDpy
= dpy
;
2379 glxCtx
->glxContext
.xid
= (XID
) glxCtx
; /* self pointer */
2381 assert((void *) glxCtx
== (void *) &(glxCtx
->glxContext
));
2383 return (GLXContext
) glxCtx
;
2387 static XVisualInfo
*
2388 Fake_glXGetVisualFromFBConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
)
2390 return Fake_glXGetVisualFromFBConfig(dpy
, config
);
2394 static GLXFBConfigSGIX
2395 Fake_glXGetFBConfigFromVisualSGIX(Display
*dpy
, XVisualInfo
*vis
)
2397 XMesaVisual xmvis
= find_glx_visual(dpy
, vis
);
2399 /* This visual wasn't found with glXChooseVisual() */
2400 xmvis
= create_glx_visual(dpy
, vis
);
2403 return (GLXFBConfigSGIX
) xmvis
;
2408 /*** GLX_SGIX_pbuffer ***/
2410 static GLXPbufferSGIX
2411 Fake_glXCreateGLXPbufferSGIX(Display
*dpy
, GLXFBConfigSGIX config
,
2412 unsigned int width
, unsigned int height
,
2415 XMesaVisual xmvis
= (XMesaVisual
) config
;
2418 GLboolean useLargest
= GL_FALSE
, preserveContents
= GL_FALSE
;
2422 for (attrib
= attribList
; attrib
&& *attrib
; attrib
++) {
2424 case GLX_PRESERVED_CONTENTS_SGIX
:
2426 preserveContents
= *attrib
; /* ignored */
2428 case GLX_LARGEST_PBUFFER_SGIX
:
2430 useLargest
= *attrib
; /* ignored */
2437 /* not used at this time */
2439 (void) preserveContents
;
2441 xmbuf
= XMesaCreatePBuffer( xmvis
, 0, width
, height
);
2442 /* A GLXPbuffer handle must be an X Drawable because that's what
2443 * glXMakeCurrent takes.
2445 return (GLXPbuffer
) xmbuf
->frontxrb
->pixmap
;
2450 Fake_glXDestroyGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
)
2452 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, pbuf
);
2454 XMesaDestroyBuffer(xmbuf
);
2460 Fake_glXQueryGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
, int attribute
, unsigned int *value
)
2462 const XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, pbuf
);
2465 /* Generate GLXBadPbufferSGIX for bad pbuffer */
2469 switch (attribute
) {
2470 case GLX_PRESERVED_CONTENTS_SGIX
:
2473 case GLX_LARGEST_PBUFFER_SGIX
:
2474 *value
= xmbuf
->mesa_buffer
.Width
* xmbuf
->mesa_buffer
.Height
;
2476 case GLX_WIDTH_SGIX
:
2477 *value
= xmbuf
->mesa_buffer
.Width
;
2479 case GLX_HEIGHT_SGIX
:
2480 *value
= xmbuf
->mesa_buffer
.Height
;
2482 case GLX_EVENT_MASK_SGIX
:
2483 *value
= 0; /* XXX might be wrong */
2493 Fake_glXSelectEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
2495 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, drawable
);
2497 /* Note: we'll never generate clobber events */
2498 xmbuf
->selectedEvents
= mask
;
2504 Fake_glXGetSelectedEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long *mask
)
2506 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, drawable
);
2508 *mask
= xmbuf
->selectedEvents
;
2517 /*** GLX_SGI_cushion ***/
2520 Fake_glXCushionSGI(Display
*dpy
, Window win
, float cushion
)
2529 /*** GLX_SGIX_video_resize ***/
2532 Fake_glXBindChannelToWindowSGIX(Display
*dpy
, int screen
, int channel
, Window window
)
2542 Fake_glXChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int x
, int y
, int w
, int h
)
2555 Fake_glXQueryChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int *x
, int *y
, int *w
, int *h
)
2568 Fake_glXQueryChannelDeltasSGIX(Display
*dpy
, int screen
, int channel
, int *dx
, int *dy
, int *dw
, int *dh
)
2581 Fake_glXChannelRectSyncSGIX(Display
*dpy
, int screen
, int channel
, GLenum synctype
)
2592 /*** GLX_SGIX_dmbuffer **/
2594 #if defined(_DM_BUFFER_H_)
2596 Fake_glXAssociateDMPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuffer
, DMparams
*params
, DMbuffer dmbuffer
)
2607 /*** GLX_SGIX_swap_group ***/
2610 Fake_glXJoinSwapGroupSGIX(Display
*dpy
, GLXDrawable drawable
, GLXDrawable member
)
2619 /*** GLX_SGIX_swap_barrier ***/
2622 Fake_glXBindSwapBarrierSGIX(Display
*dpy
, GLXDrawable drawable
, int barrier
)
2630 Fake_glXQueryMaxSwapBarriersSGIX(Display
*dpy
, int screen
, int *max
)
2640 /*** GLX_SUN_get_transparent_index ***/
2643 Fake_glXGetTransparentIndexSUN(Display
*dpy
, Window overlay
, Window underlay
, long *pTransparent
)
2648 (void) pTransparent
;
2654 /*** GLX_MESA_release_buffers ***/
2657 * Release the depth, stencil, accum buffers attached to a GLXDrawable
2658 * (a window or pixmap) prior to destroying the GLXDrawable.
2661 Fake_glXReleaseBuffersMESA( Display
*dpy
, GLXDrawable d
)
2663 XMesaBuffer b
= XMesaFindBuffer(dpy
, d
);
2665 XMesaDestroyBuffer(b
);
2673 /*** GLX_MESA_set_3dfx_mode ***/
2676 Fake_glXSet3DfxModeMESA( int mode
)
2678 return XMesaSetFXmode( mode
);
2683 /*** GLX_NV_vertex_array range ***/
2685 Fake_glXAllocateMemoryNV( GLsizei size
,
2686 GLfloat readFrequency
,
2687 GLfloat writeFrequency
,
2691 (void) readFrequency
;
2692 (void) writeFrequency
;
2699 Fake_glXFreeMemoryNV( GLvoid
*pointer
)
2705 /*** GLX_MESA_agp_offset ***/
2708 Fake_glXGetAGPOffsetMESA( const GLvoid
*pointer
)
2715 /* silence warning */
2716 extern struct _glxapi_table
*_mesa_GetGLXDispatchTable(void);
2720 * Create a new GLX API dispatch table with its function pointers
2721 * initialized to point to Mesa's "fake" GLX API functions.
2722 * Note: there's a similar function (_real_GetGLXDispatchTable) that
2723 * returns a new dispatch table with all pointers initalized to point
2724 * to "real" GLX functions (which understand GLX wire protocol, etc).
2726 struct _glxapi_table
*
2727 _mesa_GetGLXDispatchTable(void)
2729 static struct _glxapi_table glx
;
2731 /* be sure our dispatch table size <= libGL's table */
2733 GLuint size
= sizeof(struct _glxapi_table
) / sizeof(void *);
2735 assert(_glxapi_get_dispatch_table_size() >= size
);
2738 /* initialize the whole table to no-ops */
2739 _glxapi_set_no_op_table(&glx
);
2741 /* now initialize the table with the functions I implement */
2742 glx
.ChooseVisual
= Fake_glXChooseVisual
;
2743 glx
.CopyContext
= Fake_glXCopyContext
;
2744 glx
.CreateContext
= Fake_glXCreateContext
;
2745 glx
.CreateGLXPixmap
= Fake_glXCreateGLXPixmap
;
2746 glx
.DestroyContext
= Fake_glXDestroyContext
;
2747 glx
.DestroyGLXPixmap
= Fake_glXDestroyGLXPixmap
;
2748 glx
.GetConfig
= Fake_glXGetConfig
;
2749 /*glx.GetCurrentContext = Fake_glXGetCurrentContext;*/
2750 /*glx.GetCurrentDrawable = Fake_glXGetCurrentDrawable;*/
2751 glx
.IsDirect
= Fake_glXIsDirect
;
2752 glx
.MakeCurrent
= Fake_glXMakeCurrent
;
2753 glx
.QueryExtension
= Fake_glXQueryExtension
;
2754 glx
.QueryVersion
= Fake_glXQueryVersion
;
2755 glx
.SwapBuffers
= Fake_glXSwapBuffers
;
2756 glx
.UseXFont
= Fake_glXUseXFont
;
2757 glx
.WaitGL
= Fake_glXWaitGL
;
2758 glx
.WaitX
= Fake_glXWaitX
;
2760 /*** GLX_VERSION_1_1 ***/
2761 glx
.GetClientString
= Fake_glXGetClientString
;
2762 glx
.QueryExtensionsString
= Fake_glXQueryExtensionsString
;
2763 glx
.QueryServerString
= Fake_glXQueryServerString
;
2765 /*** GLX_VERSION_1_2 ***/
2766 /*glx.GetCurrentDisplay = Fake_glXGetCurrentDisplay;*/
2768 /*** GLX_VERSION_1_3 ***/
2769 glx
.ChooseFBConfig
= Fake_glXChooseFBConfig
;
2770 glx
.CreateNewContext
= Fake_glXCreateNewContext
;
2771 glx
.CreatePbuffer
= Fake_glXCreatePbuffer
;
2772 glx
.CreatePixmap
= Fake_glXCreatePixmap
;
2773 glx
.CreateWindow
= Fake_glXCreateWindow
;
2774 glx
.DestroyPbuffer
= Fake_glXDestroyPbuffer
;
2775 glx
.DestroyPixmap
= Fake_glXDestroyPixmap
;
2776 glx
.DestroyWindow
= Fake_glXDestroyWindow
;
2777 /*glx.GetCurrentReadDrawable = Fake_glXGetCurrentReadDrawable;*/
2778 glx
.GetFBConfigAttrib
= Fake_glXGetFBConfigAttrib
;
2779 glx
.GetFBConfigs
= Fake_glXGetFBConfigs
;
2780 glx
.GetSelectedEvent
= Fake_glXGetSelectedEvent
;
2781 glx
.GetVisualFromFBConfig
= Fake_glXGetVisualFromFBConfig
;
2782 glx
.MakeContextCurrent
= Fake_glXMakeContextCurrent
;
2783 glx
.QueryContext
= Fake_glXQueryContext
;
2784 glx
.QueryDrawable
= Fake_glXQueryDrawable
;
2785 glx
.SelectEvent
= Fake_glXSelectEvent
;
2787 /*** GLX_SGI_swap_control ***/
2788 glx
.SwapIntervalSGI
= Fake_glXSwapIntervalSGI
;
2790 /*** GLX_SGI_video_sync ***/
2791 glx
.GetVideoSyncSGI
= Fake_glXGetVideoSyncSGI
;
2792 glx
.WaitVideoSyncSGI
= Fake_glXWaitVideoSyncSGI
;
2794 /*** GLX_SGI_make_current_read ***/
2795 glx
.MakeCurrentReadSGI
= Fake_glXMakeCurrentReadSGI
;
2796 /*glx.GetCurrentReadDrawableSGI = Fake_glXGetCurrentReadDrawableSGI;*/
2798 /*** GLX_SGIX_video_source ***/
2800 glx
.CreateGLXVideoSourceSGIX
= Fake_glXCreateGLXVideoSourceSGIX
;
2801 glx
.DestroyGLXVideoSourceSGIX
= Fake_glXDestroyGLXVideoSourceSGIX
;
2804 /*** GLX_EXT_import_context ***/
2805 glx
.FreeContextEXT
= Fake_glXFreeContextEXT
;
2806 glx
.GetContextIDEXT
= Fake_glXGetContextIDEXT
;
2807 /*glx.GetCurrentDisplayEXT = Fake_glXGetCurrentDisplayEXT;*/
2808 glx
.ImportContextEXT
= Fake_glXImportContextEXT
;
2809 glx
.QueryContextInfoEXT
= Fake_glXQueryContextInfoEXT
;
2811 /*** GLX_SGIX_fbconfig ***/
2812 glx
.GetFBConfigAttribSGIX
= Fake_glXGetFBConfigAttribSGIX
;
2813 glx
.ChooseFBConfigSGIX
= Fake_glXChooseFBConfigSGIX
;
2814 glx
.CreateGLXPixmapWithConfigSGIX
= Fake_glXCreateGLXPixmapWithConfigSGIX
;
2815 glx
.CreateContextWithConfigSGIX
= Fake_glXCreateContextWithConfigSGIX
;
2816 glx
.GetVisualFromFBConfigSGIX
= Fake_glXGetVisualFromFBConfigSGIX
;
2817 glx
.GetFBConfigFromVisualSGIX
= Fake_glXGetFBConfigFromVisualSGIX
;
2819 /*** GLX_SGIX_pbuffer ***/
2820 glx
.CreateGLXPbufferSGIX
= Fake_glXCreateGLXPbufferSGIX
;
2821 glx
.DestroyGLXPbufferSGIX
= Fake_glXDestroyGLXPbufferSGIX
;
2822 glx
.QueryGLXPbufferSGIX
= Fake_glXQueryGLXPbufferSGIX
;
2823 glx
.SelectEventSGIX
= Fake_glXSelectEventSGIX
;
2824 glx
.GetSelectedEventSGIX
= Fake_glXGetSelectedEventSGIX
;
2826 /*** GLX_SGI_cushion ***/
2827 glx
.CushionSGI
= Fake_glXCushionSGI
;
2829 /*** GLX_SGIX_video_resize ***/
2830 glx
.BindChannelToWindowSGIX
= Fake_glXBindChannelToWindowSGIX
;
2831 glx
.ChannelRectSGIX
= Fake_glXChannelRectSGIX
;
2832 glx
.QueryChannelRectSGIX
= Fake_glXQueryChannelRectSGIX
;
2833 glx
.QueryChannelDeltasSGIX
= Fake_glXQueryChannelDeltasSGIX
;
2834 glx
.ChannelRectSyncSGIX
= Fake_glXChannelRectSyncSGIX
;
2836 /*** GLX_SGIX_dmbuffer **/
2837 #if defined(_DM_BUFFER_H_)
2838 glx
.AssociateDMPbufferSGIX
= NULL
;
2841 /*** GLX_SGIX_swap_group ***/
2842 glx
.JoinSwapGroupSGIX
= Fake_glXJoinSwapGroupSGIX
;
2844 /*** GLX_SGIX_swap_barrier ***/
2845 glx
.BindSwapBarrierSGIX
= Fake_glXBindSwapBarrierSGIX
;
2846 glx
.QueryMaxSwapBarriersSGIX
= Fake_glXQueryMaxSwapBarriersSGIX
;
2848 /*** GLX_SUN_get_transparent_index ***/
2849 glx
.GetTransparentIndexSUN
= Fake_glXGetTransparentIndexSUN
;
2851 /*** GLX_MESA_copy_sub_buffer ***/
2852 glx
.CopySubBufferMESA
= Fake_glXCopySubBufferMESA
;
2854 /*** GLX_MESA_release_buffers ***/
2855 glx
.ReleaseBuffersMESA
= Fake_glXReleaseBuffersMESA
;
2857 /*** GLX_MESA_pixmap_colormap ***/
2858 glx
.CreateGLXPixmapMESA
= Fake_glXCreateGLXPixmapMESA
;
2860 /*** GLX_MESA_set_3dfx_mode ***/
2861 glx
.Set3DfxModeMESA
= Fake_glXSet3DfxModeMESA
;
2863 /*** GLX_NV_vertex_array_range ***/
2864 glx
.AllocateMemoryNV
= Fake_glXAllocateMemoryNV
;
2865 glx
.FreeMemoryNV
= Fake_glXFreeMemoryNV
;
2867 /*** GLX_MESA_agp_offset ***/
2868 glx
.GetAGPOffsetMESA
= Fake_glXGetAGPOffsetMESA
;