2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 * This is an emulation of the GLX API which allows Mesa/GLX-based programs
28 * to run on X servers which do not have the real GLX extension.
30 * Thanks to the contributors:
32 * Initial version: Philip Brown (phil@bolthole.com)
33 * Better glXGetConfig() support: Armin Liebchen (liebchen@asylum.cs.utah.edu)
34 * Further visual-handling refinements: Wolfram Gloger
35 * (wmglo@Dent.MED.Uni-Muenchen.DE).
38 * Don't be fooled, stereo isn't supported yet.
43 #include "glxheader.h"
56 /* This indicates the client-side GLX API and GLX encoder version. */
57 #define CLIENT_MAJOR_VERSION 1
58 #define CLIENT_MINOR_VERSION 4 /* but don't have 1.3's pbuffers, etc yet */
60 /* This indicates the server-side GLX decoder version.
61 * GLX 1.4 indicates OpenGL 1.3 support
63 #define SERVER_MAJOR_VERSION 1
64 #define SERVER_MINOR_VERSION 4
66 /* This is appended onto the glXGetClient/ServerString version strings. */
67 #define MESA_GLX_VERSION "Mesa " MESA_VERSION_STRING
69 /* Who implemented this GLX? */
70 #define VENDOR "Brian Paul"
73 "GLX_MESA_set_3dfx_mode " \
74 "GLX_MESA_copy_sub_buffer " \
75 "GLX_MESA_pixmap_colormap " \
76 "GLX_MESA_release_buffers " \
77 "GLX_ARB_get_proc_address " \
78 "GLX_EXT_visual_info " \
79 "GLX_EXT_visual_rating " \
80 "GLX_SGI_video_sync " \
81 "GLX_SGIX_fbconfig " \
84 "GLX_ARB_render_texture"
89 * Our fake GLX context will contain a "real" GLX context and an XMesa context.
91 * Note that a pointer to a __GLXcontext is a pointer to a fake_glx_context,
94 * We really just need this structure in order to make the libGL functions
95 * glXGetCurrentContext(), glXGetCurrentDrawable() and glXGetCurrentDisplay()
98 struct fake_glx_context
{
99 __GLXcontext glxContext
; /* this MUST be first! */
100 XMesaContext xmesaContext
;
105 /**********************************************************************/
106 /*** GLX Visual Code ***/
107 /**********************************************************************/
112 #define MAX_VISUALS 100
113 static XMesaVisual VisualTable
[MAX_VISUALS
];
114 static int NumVisuals
= 0;
118 * This struct and some code fragments borrowed
119 * from Mark Kilgard's GLUT library.
121 typedef struct _OverlayInfo
{
122 /* Avoid 64-bit portability problems by being careful to use
123 longs due to the way XGetWindowProperty is specified. Note
124 that these parameters are passed as CARD32s over X
126 unsigned long overlay_visual
;
127 long transparent_type
;
134 /* Macro to handle c_class vs class field name in XVisualInfo struct */
135 #if defined(__cplusplus) || defined(c_plusplus)
136 #define CLASS c_class
145 * Test if the given XVisualInfo is usable for Mesa rendering.
147 static GLboolean
is_usable_visual( XVisualInfo
*vinfo
)
149 switch (vinfo
->CLASS
) {
152 /* Any StaticGray/GrayScale visual works in RGB or CI mode */
156 /* Any StaticColor/PseudoColor visual of at least 4 bits */
157 if (vinfo
->depth
>=4) {
165 /* Any depth of TrueColor or DirectColor works in RGB mode */
168 /* This should never happen */
176 * Return the level (overlay, normal, underlay) of a given XVisualInfo.
177 * Input: dpy - the X display
178 * vinfo - the XVisualInfo to test
179 * Return: level of the visual:
181 * >0 = overlay planes
182 * <0 = underlay planes
184 static int level_of_visual( Display
*dpy
, XVisualInfo
*vinfo
)
186 Atom overlayVisualsAtom
;
187 OverlayInfo
*overlay_info
= NULL
;
188 int numOverlaysPerScreen
;
192 unsigned long sizeData
, bytesLeft
;
196 * The SERVER_OVERLAY_VISUALS property on the root window contains
197 * a list of overlay visuals. Get that list now.
199 overlayVisualsAtom
= XInternAtom(dpy
,"SERVER_OVERLAY_VISUALS", True
);
200 if (overlayVisualsAtom
== None
) {
204 status
= XGetWindowProperty(dpy
, RootWindow( dpy
, vinfo
->screen
),
205 overlayVisualsAtom
, 0L, (long) 10000, False
,
206 overlayVisualsAtom
, &actualType
, &actualFormat
,
207 &sizeData
, &bytesLeft
,
208 (unsigned char **) &overlay_info
);
210 if (status
!= Success
|| actualType
!= overlayVisualsAtom
||
211 actualFormat
!= 32 || sizeData
< 4) {
212 /* something went wrong */
213 XFree((void *) overlay_info
);
217 /* search the overlay visual list for the visual ID of interest */
218 numOverlaysPerScreen
= (int) (sizeData
/ 4);
219 for (i
=0;i
<numOverlaysPerScreen
;i
++) {
221 ov
= overlay_info
+ i
;
222 if (ov
->overlay_visual
==vinfo
->visualid
) {
223 /* found the visual */
224 if (/*ov->transparent_type==1 &&*/ ov
->layer
!=0) {
225 int level
= ov
->layer
;
226 XFree((void *) overlay_info
);
230 XFree((void *) overlay_info
);
236 /* The visual ID was not found in the overlay list. */
237 XFree((void *) overlay_info
);
245 * Given an XVisualInfo and RGB, Double, and Depth buffer flags, save the
246 * configuration in our list of GLX visuals.
249 save_glx_visual( Display
*dpy
, XVisualInfo
*vinfo
,
250 GLboolean rgbFlag
, GLboolean alphaFlag
, GLboolean dbFlag
,
251 GLboolean stereoFlag
,
252 GLint depth_size
, GLint stencil_size
,
253 GLint accumRedSize
, GLint accumGreenSize
,
254 GLint accumBlueSize
, GLint accumAlphaSize
,
257 GLboolean ximageFlag
= GL_TRUE
;
260 GLboolean comparePointers
;
263 /* Check if the MESA_BACK_BUFFER env var is set */
264 char *backbuffer
= _mesa_getenv("MESA_BACK_BUFFER");
266 if (backbuffer
[0]=='p' || backbuffer
[0]=='P') {
267 ximageFlag
= GL_FALSE
;
269 else if (backbuffer
[0]=='x' || backbuffer
[0]=='X') {
270 ximageFlag
= GL_TRUE
;
273 _mesa_warning(NULL
, "Mesa: invalid value for MESA_BACK_BUFFER environment variable, using an XImage.");
278 /* Comparing IDs uses less memory but sometimes fails. */
279 /* XXX revisit this after 3.0 is finished. */
280 if (_mesa_getenv("MESA_GLX_VISUAL_HACK"))
281 comparePointers
= GL_TRUE
;
283 comparePointers
= GL_FALSE
;
285 /* First check if a matching visual is already in the list */
286 for (i
=0; i
<NumVisuals
; i
++) {
287 XMesaVisual v
= VisualTable
[i
];
288 if (v
->display
== dpy
289 && v
->mesa_visual
.level
== level
290 && v
->ximage_flag
== ximageFlag
291 && v
->mesa_visual
.rgbMode
== rgbFlag
292 && v
->mesa_visual
.doubleBufferMode
== dbFlag
293 && v
->mesa_visual
.stereoMode
== stereoFlag
294 && (v
->mesa_visual
.alphaBits
> 0) == alphaFlag
295 && (v
->mesa_visual
.depthBits
>= depth_size
|| depth_size
== 0)
296 && (v
->mesa_visual
.stencilBits
>= stencil_size
|| stencil_size
== 0)
297 && (v
->mesa_visual
.accumRedBits
>= accumRedSize
|| accumRedSize
== 0)
298 && (v
->mesa_visual
.accumGreenBits
>= accumGreenSize
|| accumGreenSize
== 0)
299 && (v
->mesa_visual
.accumBlueBits
>= accumBlueSize
|| accumBlueSize
== 0)
300 && (v
->mesa_visual
.accumAlphaBits
>= accumAlphaSize
|| accumAlphaSize
== 0)) {
301 /* now either compare XVisualInfo pointers or visual IDs */
302 if ((!comparePointers
&& v
->visinfo
->visualid
== vinfo
->visualid
)
303 || (comparePointers
&& v
->vishandle
== vinfo
)) {
309 /* Create a new visual and add it to the list. */
311 if (NumVisuals
>= MAX_VISUALS
) {
312 _mesa_problem(NULL
, "GLX Error: maximum number of visuals exceeded");
316 xmvis
= XMesaCreateVisual( dpy
, vinfo
, rgbFlag
, alphaFlag
, dbFlag
,
317 stereoFlag
, ximageFlag
,
318 depth_size
, stencil_size
,
319 accumRedSize
, accumBlueSize
,
320 accumBlueSize
, accumAlphaSize
, 0, level
,
323 /* Save a copy of the pointer now so we can find this visual again
324 * if we need to search for it in find_glx_visual().
326 xmvis
->vishandle
= vinfo
;
327 /* add xmvis to the list */
328 VisualTable
[NumVisuals
] = xmvis
;
337 * Create a GLX visual from a regular XVisualInfo.
338 * This is called when Fake GLX is given an XVisualInfo which wasn't
339 * returned by glXChooseVisual. Since this is the first time we're
340 * considering this visual we'll take a guess at reasonable values
341 * for depth buffer size, stencil size, accum size, etc.
342 * This is the best we can do with a client-side emulation of GLX.
345 create_glx_visual( Display
*dpy
, XVisualInfo
*visinfo
)
349 vislevel
= level_of_visual( dpy
, visinfo
);
351 /* Configure this visual as a CI, single-buffered overlay */
352 return save_glx_visual( dpy
, visinfo
,
354 GL_FALSE
, /* alpha */
355 GL_FALSE
, /* double */
356 GL_FALSE
, /* stereo */
358 0, /* stencil bits */
359 0,0,0,0, /* accum bits */
363 else if (is_usable_visual( visinfo
)) {
364 if (_mesa_getenv("MESA_GLX_FORCE_CI")) {
365 /* Configure this visual as a COLOR INDEX visual. */
366 return save_glx_visual( dpy
, visinfo
,
368 GL_FALSE
, /* alpha */
369 GL_TRUE
, /* double */
370 GL_FALSE
, /* stereo */
371 DEFAULT_SOFTWARE_DEPTH_BITS
,
372 8 * sizeof(GLstencil
),
373 0 * sizeof(GLaccum
), /* r */
374 0 * sizeof(GLaccum
), /* g */
375 0 * sizeof(GLaccum
), /* b */
376 0 * sizeof(GLaccum
), /* a */
381 /* Configure this visual as RGB, double-buffered, depth-buffered. */
382 /* This is surely wrong for some people's needs but what else */
383 /* can be done? They should use glXChooseVisual(). */
384 return save_glx_visual( dpy
, visinfo
,
386 GL_FALSE
, /* alpha */
387 GL_TRUE
, /* double */
388 GL_FALSE
, /* stereo */
389 DEFAULT_SOFTWARE_DEPTH_BITS
,
390 8 * sizeof(GLstencil
),
391 8 * sizeof(GLaccum
), /* r */
392 8 * sizeof(GLaccum
), /* g */
393 8 * sizeof(GLaccum
), /* b */
394 8 * sizeof(GLaccum
), /* a */
400 _mesa_warning(NULL
, "Mesa: error in glXCreateContext: bad visual\n");
408 * Find the GLX visual associated with an XVisualInfo.
411 find_glx_visual( Display
*dpy
, XVisualInfo
*vinfo
)
415 /* try to match visual id */
416 for (i
=0;i
<NumVisuals
;i
++) {
417 if (VisualTable
[i
]->display
==dpy
418 && VisualTable
[i
]->visinfo
->visualid
== vinfo
->visualid
) {
419 return VisualTable
[i
];
423 /* if that fails, try to match pointers */
424 for (i
=0;i
<NumVisuals
;i
++) {
425 if (VisualTable
[i
]->display
==dpy
&& VisualTable
[i
]->vishandle
==vinfo
) {
426 return VisualTable
[i
];
436 * Return the transparent pixel value for a GLX visual.
437 * Input: glxvis - the glx_visual
438 * Return: a pixel value or -1 if no transparent pixel
440 static int transparent_pixel( XMesaVisual glxvis
)
442 Display
*dpy
= glxvis
->display
;
443 XVisualInfo
*vinfo
= glxvis
->visinfo
;
444 Atom overlayVisualsAtom
;
445 OverlayInfo
*overlay_info
= NULL
;
446 int numOverlaysPerScreen
;
450 unsigned long sizeData
, bytesLeft
;
454 * The SERVER_OVERLAY_VISUALS property on the root window contains
455 * a list of overlay visuals. Get that list now.
457 overlayVisualsAtom
= XInternAtom(dpy
,"SERVER_OVERLAY_VISUALS", True
);
458 if (overlayVisualsAtom
== None
) {
462 status
= XGetWindowProperty(dpy
, RootWindow( dpy
, vinfo
->screen
),
463 overlayVisualsAtom
, 0L, (long) 10000, False
,
464 overlayVisualsAtom
, &actualType
, &actualFormat
,
465 &sizeData
, &bytesLeft
,
466 (unsigned char **) &overlay_info
);
468 if (status
!= Success
|| actualType
!= overlayVisualsAtom
||
469 actualFormat
!= 32 || sizeData
< 4) {
470 /* something went wrong */
471 XFree((void *) overlay_info
);
475 /* search the overlay visual list for the visual ID of interest */
476 numOverlaysPerScreen
= (int) (sizeData
/ 4);
477 for (i
=0;i
<numOverlaysPerScreen
;i
++) {
479 ov
= overlay_info
+ i
;
480 if (ov
->overlay_visual
==vinfo
->visualid
) {
482 if (ov
->transparent_type
==0) {
483 /* type 0 indicates no transparency */
484 XFree((void *) overlay_info
);
488 /* ov->value is the transparent pixel */
489 XFree((void *) overlay_info
);
495 /* The visual ID was not found in the overlay list. */
496 XFree((void *) overlay_info
);
503 * Try to get an X visual which matches the given arguments.
505 static XVisualInfo
*get_visual( Display
*dpy
, int scr
,
506 unsigned int depth
, int xclass
)
508 XVisualInfo temp
, *vis
;
511 unsigned int default_depth
;
514 mask
= VisualScreenMask
| VisualDepthMask
| VisualClassMask
;
519 default_depth
= DefaultDepth(dpy
,scr
);
520 default_class
= DefaultVisual(dpy
,scr
)->CLASS
;
522 if (depth
==default_depth
&& xclass
==default_class
) {
523 /* try to get root window's visual */
524 temp
.visualid
= DefaultVisual(dpy
,scr
)->visualid
;
525 mask
|= VisualIDMask
;
528 vis
= XGetVisualInfo( dpy
, mask
, &temp
, &n
);
530 /* In case bits/pixel > 24, make sure color channels are still <=8 bits.
531 * An SGI Infinite Reality system, for example, can have 30bpp pixels:
532 * 10 bits per color channel. Mesa's limited to a max of 8 bits/channel.
534 if (vis
&& depth
> 24 && (xclass
==TrueColor
|| xclass
==DirectColor
)) {
535 if (_mesa_bitcount((GLuint
) vis
->red_mask
) <= 8 &&
536 _mesa_bitcount((GLuint
) vis
->green_mask
) <= 8 &&
537 _mesa_bitcount((GLuint
) vis
->blue_mask
) <= 8) {
552 * Retrieve the value of the given environment variable and find
553 * the X visual which matches it.
554 * Input: dpy - the display
555 * screen - the screen number
556 * varname - the name of the environment variable
557 * Return: an XVisualInfo pointer to NULL if error.
559 static XVisualInfo
*get_env_visual(Display
*dpy
, int scr
, const char *varname
)
561 char value
[100], type
[100];
562 int depth
, xclass
= -1;
565 if (!_mesa_getenv( varname
)) {
569 _mesa_strncpy( value
, _mesa_getenv(varname
), 100 );
572 sscanf( value
, "%s %d", type
, &depth
);
574 if (_mesa_strcmp(type
,"TrueColor")==0) xclass
= TrueColor
;
575 else if (_mesa_strcmp(type
,"DirectColor")==0) xclass
= DirectColor
;
576 else if (_mesa_strcmp(type
,"PseudoColor")==0) xclass
= PseudoColor
;
577 else if (_mesa_strcmp(type
,"StaticColor")==0) xclass
= StaticColor
;
578 else if (_mesa_strcmp(type
,"GrayScale")==0) xclass
= GrayScale
;
579 else if (_mesa_strcmp(type
,"StaticGray")==0) xclass
= StaticGray
;
581 if (xclass
>-1 && depth
>0) {
582 vis
= get_visual( dpy
, scr
, depth
, xclass
);
588 _mesa_warning(NULL
, "GLX unable to find visual class=%s, depth=%d.",
597 * Select an X visual which satisfies the RGBA/CI flag and minimum depth.
598 * Input: dpy, screen - X display and screen number
599 * rgba - GL_TRUE = RGBA mode, GL_FALSE = CI mode
600 * min_depth - minimum visual depth
601 * preferred_class - preferred GLX visual class or DONT_CARE
602 * Return: pointer to an XVisualInfo or NULL.
604 static XVisualInfo
*choose_x_visual( Display
*dpy
, int screen
,
605 GLboolean rgba
, int min_depth
,
606 int preferred_class
)
609 int xclass
, visclass
= 0;
613 Atom hp_cr_maps
= XInternAtom(dpy
, "_HP_RGB_SMOOTH_MAP_LIST", True
);
614 /* First see if the MESA_RGB_VISUAL env var is defined */
615 vis
= get_env_visual( dpy
, screen
, "MESA_RGB_VISUAL" );
619 /* Otherwise, search for a suitable visual */
620 if (preferred_class
==DONT_CARE
) {
621 for (xclass
=0;xclass
<6;xclass
++) {
623 case 0: visclass
= TrueColor
; break;
624 case 1: visclass
= DirectColor
; break;
625 case 2: visclass
= PseudoColor
; break;
626 case 3: visclass
= StaticColor
; break;
627 case 4: visclass
= GrayScale
; break;
628 case 5: visclass
= StaticGray
; break;
631 /* start with shallowest */
632 for (depth
=0;depth
<=32;depth
++) {
633 if (visclass
==TrueColor
&& depth
==8 && !hp_cr_maps
) {
634 /* Special case: try to get 8-bit PseudoColor before */
635 /* 8-bit TrueColor */
636 vis
= get_visual( dpy
, screen
, 8, PseudoColor
);
641 vis
= get_visual( dpy
, screen
, depth
, visclass
);
648 /* start with deepest */
649 for (depth
=32;depth
>=min_depth
;depth
--) {
650 if (visclass
==TrueColor
&& depth
==8 && !hp_cr_maps
) {
651 /* Special case: try to get 8-bit PseudoColor before */
652 /* 8-bit TrueColor */
653 vis
= get_visual( dpy
, screen
, 8, PseudoColor
);
658 vis
= get_visual( dpy
, screen
, depth
, visclass
);
667 /* search for a specific visual class */
668 switch (preferred_class
) {
669 case GLX_TRUE_COLOR_EXT
: visclass
= TrueColor
; break;
670 case GLX_DIRECT_COLOR_EXT
: visclass
= DirectColor
; break;
671 case GLX_PSEUDO_COLOR_EXT
: visclass
= PseudoColor
; break;
672 case GLX_STATIC_COLOR_EXT
: visclass
= StaticColor
; break;
673 case GLX_GRAY_SCALE_EXT
: visclass
= GrayScale
; break;
674 case GLX_STATIC_GRAY_EXT
: visclass
= StaticGray
; break;
675 default: return NULL
;
678 /* start with shallowest */
679 for (depth
=0;depth
<=32;depth
++) {
680 vis
= get_visual( dpy
, screen
, depth
, visclass
);
687 /* start with deepest */
688 for (depth
=32;depth
>=min_depth
;depth
--) {
689 vis
= get_visual( dpy
, screen
, depth
, visclass
);
698 /* First see if the MESA_CI_VISUAL env var is defined */
699 vis
= get_env_visual( dpy
, screen
, "MESA_CI_VISUAL" );
703 /* Otherwise, search for a suitable visual, starting with shallowest */
704 if (preferred_class
==DONT_CARE
) {
705 for (xclass
=0;xclass
<4;xclass
++) {
707 case 0: visclass
= PseudoColor
; break;
708 case 1: visclass
= StaticColor
; break;
709 case 2: visclass
= GrayScale
; break;
710 case 3: visclass
= StaticGray
; break;
712 /* try 8-bit up through 16-bit */
713 for (depth
=8;depth
<=16;depth
++) {
714 vis
= get_visual( dpy
, screen
, depth
, visclass
);
719 /* try min_depth up to 8-bit */
720 for (depth
=min_depth
;depth
<8;depth
++) {
721 vis
= get_visual( dpy
, screen
, depth
, visclass
);
729 /* search for a specific visual class */
730 switch (preferred_class
) {
731 case GLX_TRUE_COLOR_EXT
: visclass
= TrueColor
; break;
732 case GLX_DIRECT_COLOR_EXT
: visclass
= DirectColor
; break;
733 case GLX_PSEUDO_COLOR_EXT
: visclass
= PseudoColor
; break;
734 case GLX_STATIC_COLOR_EXT
: visclass
= StaticColor
; break;
735 case GLX_GRAY_SCALE_EXT
: visclass
= GrayScale
; break;
736 case GLX_STATIC_GRAY_EXT
: visclass
= StaticGray
; break;
737 default: return NULL
;
739 /* try 8-bit up through 16-bit */
740 for (depth
=8;depth
<=16;depth
++) {
741 vis
= get_visual( dpy
, screen
, depth
, visclass
);
746 /* try min_depth up to 8-bit */
747 for (depth
=min_depth
;depth
<8;depth
++) {
748 vis
= get_visual( dpy
, screen
, depth
, visclass
);
756 /* didn't find a visual */
763 * Find the deepest X over/underlay visual of at least min_depth.
764 * Input: dpy, screen - X display and screen number
765 * level - the over/underlay level
766 * trans_type - transparent pixel type: GLX_NONE_EXT,
767 * GLX_TRANSPARENT_RGB_EXT, GLX_TRANSPARENT_INDEX_EXT,
769 * trans_value - transparent pixel value or DONT_CARE
770 * min_depth - minimum visual depth
771 * preferred_class - preferred GLX visual class or DONT_CARE
772 * Return: pointer to an XVisualInfo or NULL.
774 static XVisualInfo
*choose_x_overlay_visual( Display
*dpy
, int scr
,
776 int level
, int trans_type
,
779 int preferred_class
)
781 Atom overlayVisualsAtom
;
782 OverlayInfo
*overlay_info
;
783 int numOverlaysPerScreen
;
787 unsigned long sizeData
, bytesLeft
;
789 XVisualInfo
*deepvis
;
792 /*DEBUG int tt, tv; */
794 switch (preferred_class
) {
795 case GLX_TRUE_COLOR_EXT
: preferred_class
= TrueColor
; break;
796 case GLX_DIRECT_COLOR_EXT
: preferred_class
= DirectColor
; break;
797 case GLX_PSEUDO_COLOR_EXT
: preferred_class
= PseudoColor
; break;
798 case GLX_STATIC_COLOR_EXT
: preferred_class
= StaticColor
; break;
799 case GLX_GRAY_SCALE_EXT
: preferred_class
= GrayScale
; break;
800 case GLX_STATIC_GRAY_EXT
: preferred_class
= StaticGray
; break;
801 default: preferred_class
= DONT_CARE
;
805 * The SERVER_OVERLAY_VISUALS property on the root window contains
806 * a list of overlay visuals. Get that list now.
808 overlayVisualsAtom
= XInternAtom(dpy
,"SERVER_OVERLAY_VISUALS", True
);
809 if (overlayVisualsAtom
== (Atom
) None
) {
813 status
= XGetWindowProperty(dpy
, RootWindow( dpy
, scr
),
814 overlayVisualsAtom
, 0L, (long) 10000, False
,
815 overlayVisualsAtom
, &actualType
, &actualFormat
,
816 &sizeData
, &bytesLeft
,
817 (unsigned char **) &overlay_info
);
819 if (status
!= Success
|| actualType
!= overlayVisualsAtom
||
820 actualFormat
!= 32 || sizeData
< 4) {
821 /* something went wrong */
825 /* Search for the deepest overlay which satisifies all criteria. */
829 numOverlaysPerScreen
= (int) (sizeData
/ 4);
830 for (i
=0;i
<numOverlaysPerScreen
;i
++) {
831 XVisualInfo
*vislist
, vistemplate
;
834 ov
= overlay_info
+ i
;
836 if (ov
->layer
!=level
) {
837 /* failed overlay level criteria */
840 if (!(trans_type
==DONT_CARE
841 || (trans_type
==GLX_TRANSPARENT_INDEX_EXT
842 && ov
->transparent_type
>0)
843 || (trans_type
==GLX_NONE_EXT
&& ov
->transparent_type
==0))) {
844 /* failed transparent pixel type criteria */
847 if (trans_value
!=DONT_CARE
&& trans_value
!=ov
->value
) {
848 /* failed transparent pixel value criteria */
852 /* get XVisualInfo and check the depth */
853 vistemplate
.visualid
= ov
->overlay_visual
;
854 vistemplate
.screen
= scr
;
855 vislist
= XGetVisualInfo( dpy
, VisualIDMask
| VisualScreenMask
,
856 &vistemplate
, &count
);
859 /* something went wrong */
862 if (preferred_class
!=DONT_CARE
&& preferred_class
!=vislist
->CLASS
) {
863 /* wrong visual class */
867 /* if RGB was requested, make sure we have True/DirectColor */
868 if (rgbFlag
&& vislist
->CLASS
!= TrueColor
869 && vislist
->CLASS
!= DirectColor
)
872 /* if CI was requested, make sure we have a color indexed visual */
874 && (vislist
->CLASS
== TrueColor
|| vislist
->CLASS
== DirectColor
))
877 if (deepvis
==NULL
|| vislist
->depth
> deepest
) {
878 /* YES! found a satisfactory visual */
882 deepest
= vislist
->depth
;
884 /* DEBUG tt = ov->transparent_type;*/
885 /* DEBUG tv = ov->value; */
891 printf("chose 0x%x: layer=%d depth=%d trans_type=%d trans_value=%d\n",
892 deepvis->visualid, level, deepvis->depth, tt, tv );
899 /**********************************************************************/
900 /*** Begin Fake GLX API Functions ***/
901 /**********************************************************************/
904 static XMesaVisual
choose_visual( Display
*dpy
, int screen
, const int *list
,
905 GLboolean rgbModeDefault
)
907 const int *parselist
;
910 int min_red
=0, min_green
=0, min_blue
=0;
911 GLboolean rgb_flag
= rgbModeDefault
;
912 GLboolean alpha_flag
= GL_FALSE
;
913 GLboolean double_flag
= GL_FALSE
;
914 GLboolean stereo_flag
= GL_FALSE
;
915 GLint depth_size
= 0;
916 GLint stencil_size
= 0;
917 GLint accumRedSize
= 0;
918 GLint accumGreenSize
= 0;
919 GLint accumBlueSize
= 0;
920 GLint accumAlphaSize
= 0;
922 int visual_type
= DONT_CARE
;
923 int trans_type
= DONT_CARE
;
924 int trans_value
= DONT_CARE
;
925 GLint caveat
= DONT_CARE
;
926 XMesaVisual xmvis
= NULL
;
927 int desiredVisualID
= -1;
933 switch (*parselist
) {
938 case GLX_BUFFER_SIZE
:
940 min_ci
= *parselist
++;
944 level
= *parselist
++;
950 case GLX_DOUBLEBUFFER
:
951 double_flag
= GL_TRUE
;
955 stereo_flag
= GL_TRUE
;
957 case GLX_AUX_BUFFERS
:
964 min_red
= *parselist
++;
968 min_green
= *parselist
++;
972 min_blue
= *parselist
++;
977 GLint size
= *parselist
++;
978 alpha_flag
= size
>0 ? 1 : 0;
983 depth_size
= *parselist
++;
985 case GLX_STENCIL_SIZE
:
987 stencil_size
= *parselist
++;
989 case GLX_ACCUM_RED_SIZE
:
992 GLint size
= *parselist
++;
993 accumRedSize
= MAX2( accumRedSize
, size
);
996 case GLX_ACCUM_GREEN_SIZE
:
999 GLint size
= *parselist
++;
1000 accumGreenSize
= MAX2( accumGreenSize
, size
);
1003 case GLX_ACCUM_BLUE_SIZE
:
1006 GLint size
= *parselist
++;
1007 accumBlueSize
= MAX2( accumBlueSize
, size
);
1010 case GLX_ACCUM_ALPHA_SIZE
:
1013 GLint size
= *parselist
++;
1014 accumAlphaSize
= MAX2( accumAlphaSize
, size
);
1019 * GLX_EXT_visual_info extension
1021 case GLX_X_VISUAL_TYPE_EXT
:
1023 visual_type
= *parselist
++;
1025 case GLX_TRANSPARENT_TYPE_EXT
:
1027 trans_type
= *parselist
++;
1029 case GLX_TRANSPARENT_INDEX_VALUE_EXT
:
1031 trans_value
= *parselist
++;
1033 case GLX_TRANSPARENT_RED_VALUE_EXT
:
1034 case GLX_TRANSPARENT_GREEN_VALUE_EXT
:
1035 case GLX_TRANSPARENT_BLUE_VALUE_EXT
:
1036 case GLX_TRANSPARENT_ALPHA_VALUE_EXT
:
1043 * GLX_EXT_visual_info extension
1045 case GLX_VISUAL_CAVEAT_EXT
:
1047 caveat
= *parselist
++; /* ignored for now */
1051 * GLX_ARB_multisample
1053 case GLX_SAMPLE_BUFFERS_ARB
:
1054 /* ms not supported */
1056 case GLX_SAMPLES_ARB
:
1057 /* ms not supported */
1063 case GLX_RENDER_TYPE
:
1065 if (*parselist
== GLX_RGBA_BIT
) {
1068 else if (*parselist
== GLX_COLOR_INDEX_BIT
) {
1069 rgb_flag
= GL_FALSE
;
1071 else if (*parselist
== 0) {
1076 case GLX_DRAWABLE_TYPE
:
1078 if (*parselist
& ~(GLX_WINDOW_BIT
| GLX_PIXMAP_BIT
| GLX_PBUFFER_BIT
)) {
1079 return NULL
; /* bad bit */
1083 case GLX_FBCONFIG_ID
:
1085 desiredVisualID
= *parselist
;
1093 /* undefined attribute */
1094 _mesa_warning(NULL
, "unexpected attrib 0x%x in choose_visual()",
1103 * Since we're only simulating the GLX extension this function will never
1104 * find any real GL visuals. Instead, all we can do is try to find an RGB
1105 * or CI visual of appropriate depth. Other requested attributes such as
1106 * double buffering, depth buffer, etc. will be associated with the X
1107 * visual and stored in the VisualTable[].
1109 if (desiredVisualID
!= -1) {
1110 /* try to get a specific visual, by visualID */
1113 temp
.visualid
= desiredVisualID
;
1114 temp
.screen
= screen
;
1115 vis
= XGetVisualInfo(dpy
, VisualIDMask
| VisualScreenMask
, &temp
, &n
);
1117 /* give the visual some useful GLX attributes */
1118 double_flag
= GL_TRUE
;
1121 depth_size
= DEFAULT_SOFTWARE_DEPTH_BITS
;
1122 stencil_size
= STENCIL_BITS
;
1126 else if (level
==0) {
1127 /* normal color planes */
1129 /* Get an RGB visual */
1130 int min_rgb
= min_red
+ min_green
+ min_blue
;
1131 if (min_rgb
>1 && min_rgb
<8) {
1132 /* a special case to be sure we can get a monochrome visual */
1135 vis
= choose_x_visual( dpy
, screen
, rgb_flag
, min_rgb
, visual_type
);
1138 /* Get a color index visual */
1139 vis
= choose_x_visual( dpy
, screen
, rgb_flag
, min_ci
, visual_type
);
1140 accumRedSize
= accumGreenSize
= accumBlueSize
= accumAlphaSize
= 0;
1144 /* over/underlay planes */
1147 int min_rgb
= min_red
+ min_green
+ min_blue
;
1148 if (min_rgb
>1 && min_rgb
<8) {
1149 /* a special case to be sure we can get a monochrome visual */
1152 vis
= choose_x_overlay_visual( dpy
, screen
, rgb_flag
, level
,
1153 trans_type
, trans_value
, min_rgb
, visual_type
);
1156 /* color index overlay */
1157 vis
= choose_x_overlay_visual( dpy
, screen
, rgb_flag
, level
,
1158 trans_type
, trans_value
, min_ci
, visual_type
);
1163 /* Note: we're not exactly obeying the glXChooseVisual rules here.
1164 * When GLX_DEPTH_SIZE = 1 is specified we're supposed to choose the
1165 * largest depth buffer size, which is 32bits/value. Instead, we
1166 * return 16 to maintain performance with earlier versions of Mesa.
1168 if (depth_size
> 24)
1169 depth_size
= 31; /* 32 causes int overflow problems */
1170 else if (depth_size
> 16)
1172 else if (depth_size
> 0)
1173 depth_size
= DEFAULT_SOFTWARE_DEPTH_BITS
; /*16*/
1175 /* we only support one size of stencil and accum buffers. */
1176 if (stencil_size
> 0)
1177 stencil_size
= STENCIL_BITS
;
1178 if (accumRedSize
> 0 || accumGreenSize
> 0 || accumBlueSize
> 0 ||
1179 accumAlphaSize
> 0) {
1180 accumRedSize
= ACCUM_BITS
;
1181 accumGreenSize
= ACCUM_BITS
;
1182 accumBlueSize
= ACCUM_BITS
;
1183 accumAlphaSize
= alpha_flag
? ACCUM_BITS
: 0;
1186 xmvis
= save_glx_visual( dpy
, vis
, rgb_flag
, alpha_flag
, double_flag
,
1187 stereo_flag
, depth_size
, stencil_size
,
1188 accumRedSize
, accumGreenSize
,
1189 accumBlueSize
, accumAlphaSize
, level
);
1196 static XVisualInfo
*
1197 Fake_glXChooseVisual( Display
*dpy
, int screen
, int *list
)
1199 XMesaVisual xmvis
= choose_visual(dpy
, screen
, list
, GL_FALSE
);
1202 return xmvis
->vishandle
;
1204 /* create a new vishandle - the cached one may be stale */
1205 xmvis
->vishandle
= (XVisualInfo
*) _mesa_malloc(sizeof(XVisualInfo
));
1206 if (xmvis
->vishandle
) {
1207 _mesa_memcpy(xmvis
->vishandle
, xmvis
->visinfo
, sizeof(XVisualInfo
));
1209 return xmvis
->vishandle
;
1218 Fake_glXCreateContext( Display
*dpy
, XVisualInfo
*visinfo
,
1219 GLXContext share_list
, Bool direct
)
1222 struct fake_glx_context
*glxCtx
;
1223 struct fake_glx_context
*shareCtx
= (struct fake_glx_context
*) share_list
;
1225 if (!dpy
|| !visinfo
)
1228 glxCtx
= CALLOC_STRUCT(fake_glx_context
);
1232 /* deallocate unused windows/buffers */
1233 XMesaGarbageCollect();
1235 xmvis
= find_glx_visual( dpy
, visinfo
);
1237 /* This visual wasn't found with glXChooseVisual() */
1238 xmvis
= create_glx_visual( dpy
, visinfo
);
1240 /* unusable visual */
1246 glxCtx
->xmesaContext
= XMesaCreateContext(xmvis
,
1247 shareCtx
? shareCtx
->xmesaContext
: NULL
);
1248 if (!glxCtx
->xmesaContext
) {
1253 glxCtx
->xmesaContext
->direct
= GL_FALSE
;
1254 glxCtx
->glxContext
.isDirect
= GL_FALSE
;
1255 glxCtx
->glxContext
.currentDpy
= dpy
;
1256 glxCtx
->glxContext
.xid
= (XID
) glxCtx
; /* self pointer */
1258 assert((void *) glxCtx
== (void *) &(glxCtx
->glxContext
));
1260 return (GLXContext
) glxCtx
;
1264 /* XXX these may have to be removed due to thread-safety issues. */
1265 static GLXContext MakeCurrent_PrevContext
= 0;
1266 static GLXDrawable MakeCurrent_PrevDrawable
= 0;
1267 static GLXDrawable MakeCurrent_PrevReadable
= 0;
1268 static XMesaBuffer MakeCurrent_PrevDrawBuffer
= 0;
1269 static XMesaBuffer MakeCurrent_PrevReadBuffer
= 0;
1272 /* GLX 1.3 and later */
1274 Fake_glXMakeContextCurrent( Display
*dpy
, GLXDrawable draw
,
1275 GLXDrawable read
, GLXContext ctx
)
1277 struct fake_glx_context
*glxCtx
= (struct fake_glx_context
*) ctx
;
1279 if (ctx
&& draw
&& read
) {
1280 XMesaBuffer drawBuffer
, readBuffer
;
1281 XMesaContext xmctx
= glxCtx
->xmesaContext
;
1283 /* Find the XMesaBuffer which corresponds to the GLXDrawable 'draw' */
1284 if (ctx
== MakeCurrent_PrevContext
1285 && draw
== MakeCurrent_PrevDrawable
) {
1286 drawBuffer
= MakeCurrent_PrevDrawBuffer
;
1289 drawBuffer
= XMesaFindBuffer( dpy
, draw
);
1292 /* drawable must be a new window! */
1293 drawBuffer
= XMesaCreateWindowBuffer2( xmctx
->xm_visual
, draw
, xmctx
);
1295 /* Out of memory, or context/drawable depth mismatch */
1300 /* Find the XMesaBuffer which corresponds to the GLXDrawable 'read' */
1301 if (ctx
== MakeCurrent_PrevContext
1302 && read
== MakeCurrent_PrevReadable
) {
1303 readBuffer
= MakeCurrent_PrevReadBuffer
;
1306 readBuffer
= XMesaFindBuffer( dpy
, read
);
1309 /* drawable must be a new window! */
1310 readBuffer
= XMesaCreateWindowBuffer2(glxCtx
->xmesaContext
->xm_visual
,
1313 /* Out of memory, or context/drawable depth mismatch */
1318 MakeCurrent_PrevContext
= ctx
;
1319 MakeCurrent_PrevDrawable
= draw
;
1320 MakeCurrent_PrevReadable
= read
;
1321 MakeCurrent_PrevDrawBuffer
= drawBuffer
;
1322 MakeCurrent_PrevReadBuffer
= readBuffer
;
1324 /* Now make current! */
1325 if (XMesaMakeCurrent2(xmctx
, drawBuffer
, readBuffer
)) {
1326 ((__GLXcontext
*) ctx
)->currentDpy
= dpy
;
1327 ((__GLXcontext
*) ctx
)->currentDrawable
= draw
;
1328 #ifndef GLX_BUILT_IN_XMESA
1329 ((__GLXcontext
*) ctx
)->currentReadable
= read
;
1331 __glXSetCurrentContext(ctx
);
1339 else if (!ctx
&& !draw
&& !read
) {
1340 /* release current context w/out assigning new one. */
1341 XMesaMakeCurrent( NULL
, NULL
);
1342 MakeCurrent_PrevContext
= 0;
1343 MakeCurrent_PrevDrawable
= 0;
1344 MakeCurrent_PrevReadable
= 0;
1345 MakeCurrent_PrevDrawBuffer
= 0;
1346 MakeCurrent_PrevReadBuffer
= 0;
1347 #ifdef GLX_BUILT_IN_XMESA
1348 /* XXX bind dummy context with __glXSetCurrentContext(ctx); */
1353 /* The args must either all be non-zero or all zero.
1363 Fake_glXMakeCurrent( Display
*dpy
, GLXDrawable drawable
, GLXContext ctx
)
1365 return Fake_glXMakeContextCurrent( dpy
, drawable
, drawable
, ctx
);
1371 Fake_glXCreateGLXPixmap( Display
*dpy
, XVisualInfo
*visinfo
, Pixmap pixmap
)
1376 v
= find_glx_visual( dpy
, visinfo
);
1378 v
= create_glx_visual( dpy
, visinfo
);
1380 /* unusable visual */
1385 b
= XMesaCreatePixmapBuffer( v
, pixmap
, 0 );
1389 return b
->frontbuffer
;
1393 /*** GLX_MESA_pixmap_colormap ***/
1396 Fake_glXCreateGLXPixmapMESA( Display
*dpy
, XVisualInfo
*visinfo
,
1397 Pixmap pixmap
, Colormap cmap
)
1402 v
= find_glx_visual( dpy
, visinfo
);
1404 v
= create_glx_visual( dpy
, visinfo
);
1406 /* unusable visual */
1411 b
= XMesaCreatePixmapBuffer( v
, pixmap
, cmap
);
1415 return b
->frontbuffer
;
1420 Fake_glXDestroyGLXPixmap( Display
*dpy
, GLXPixmap pixmap
)
1422 XMesaBuffer b
= XMesaFindBuffer(dpy
, pixmap
);
1424 XMesaDestroyBuffer(b
);
1426 else if (_mesa_getenv("MESA_DEBUG")) {
1427 _mesa_warning(NULL
, "Mesa: glXDestroyGLXPixmap: invalid pixmap\n");
1434 Fake_glXCopyContext( Display
*dpy
, GLXContext src
, GLXContext dst
,
1435 unsigned long mask
)
1437 struct fake_glx_context
*fakeSrc
= (struct fake_glx_context
*) src
;
1438 struct fake_glx_context
*fakeDst
= (struct fake_glx_context
*) dst
;
1439 XMesaContext xm_src
= fakeSrc
->xmesaContext
;
1440 XMesaContext xm_dst
= fakeDst
->xmesaContext
;
1442 _mesa_copy_context( &(xm_src
->mesa
), &(xm_dst
->mesa
), (GLuint
) mask
);
1448 Fake_glXQueryExtension( Display
*dpy
, int *errorb
, int *event
)
1450 /* Mesa's GLX isn't really an X extension but we try to act like one. */
1458 extern void _kw_ungrab_all( Display
*dpy
);
1459 void _kw_ungrab_all( Display
*dpy
)
1461 XUngrabPointer( dpy
, CurrentTime
);
1462 XUngrabKeyboard( dpy
, CurrentTime
);
1467 Fake_glXDestroyContext( Display
*dpy
, GLXContext ctx
)
1469 struct fake_glx_context
*glxCtx
= (struct fake_glx_context
*) ctx
;
1471 MakeCurrent_PrevContext
= 0;
1472 MakeCurrent_PrevDrawable
= 0;
1473 MakeCurrent_PrevReadable
= 0;
1474 MakeCurrent_PrevDrawBuffer
= 0;
1475 MakeCurrent_PrevReadBuffer
= 0;
1476 XMesaDestroyContext( glxCtx
->xmesaContext
);
1477 XMesaGarbageCollect();
1483 Fake_glXIsDirect( Display
*dpy
, GLXContext ctx
)
1485 struct fake_glx_context
*glxCtx
= (struct fake_glx_context
*) ctx
;
1487 return glxCtx
->xmesaContext
->direct
;
1493 Fake_glXSwapBuffers( Display
*dpy
, GLXDrawable drawable
)
1495 XMesaBuffer buffer
= XMesaFindBuffer( dpy
, drawable
);
1498 XMesaSwapBuffers(buffer
);
1500 else if (_mesa_getenv("MESA_DEBUG")) {
1501 _mesa_warning(NULL
, "Mesa: glXSwapBuffers: invalid drawable\n");
1507 /*** GLX_MESA_copy_sub_buffer ***/
1510 Fake_glXCopySubBufferMESA( Display
*dpy
, GLXDrawable drawable
,
1511 int x
, int y
, int width
, int height
)
1513 XMesaBuffer buffer
= XMesaFindBuffer( dpy
, drawable
);
1515 XMesaCopySubBuffer(buffer
, x
, y
, width
, height
);
1517 else if (_mesa_getenv("MESA_DEBUG")) {
1518 _mesa_warning(NULL
, "Mesa: glXCopySubBufferMESA: invalid drawable\n");
1525 Fake_glXQueryVersion( Display
*dpy
, int *maj
, int *min
)
1528 /* Return GLX version, not Mesa version */
1529 assert(CLIENT_MAJOR_VERSION
== SERVER_MAJOR_VERSION
);
1530 *maj
= CLIENT_MAJOR_VERSION
;
1531 *min
= MIN2( CLIENT_MINOR_VERSION
, SERVER_MINOR_VERSION
);
1538 * Query the GLX attributes of the given XVisualInfo.
1541 get_config( XMesaVisual xmvis
, int attrib
, int *value
, GLboolean fbconfig
)
1546 *value
= (int) True
;
1548 case GLX_BUFFER_SIZE
:
1549 *value
= xmvis
->visinfo
->depth
;
1552 *value
= xmvis
->mesa_visual
.level
;
1555 if (xmvis
->mesa_visual
.rgbMode
) {
1562 case GLX_DOUBLEBUFFER
:
1563 *value
= (int) xmvis
->mesa_visual
.doubleBufferMode
;
1566 *value
= (int) xmvis
->mesa_visual
.stereoMode
;
1568 case GLX_AUX_BUFFERS
:
1569 *value
= (int) False
;
1572 *value
= xmvis
->mesa_visual
.redBits
;
1574 case GLX_GREEN_SIZE
:
1575 *value
= xmvis
->mesa_visual
.greenBits
;
1578 *value
= xmvis
->mesa_visual
.blueBits
;
1580 case GLX_ALPHA_SIZE
:
1581 *value
= xmvis
->mesa_visual
.alphaBits
;
1583 case GLX_DEPTH_SIZE
:
1584 *value
= xmvis
->mesa_visual
.depthBits
;
1586 case GLX_STENCIL_SIZE
:
1587 *value
= xmvis
->mesa_visual
.stencilBits
;
1589 case GLX_ACCUM_RED_SIZE
:
1590 *value
= xmvis
->mesa_visual
.accumRedBits
;
1592 case GLX_ACCUM_GREEN_SIZE
:
1593 *value
= xmvis
->mesa_visual
.accumGreenBits
;
1595 case GLX_ACCUM_BLUE_SIZE
:
1596 *value
= xmvis
->mesa_visual
.accumBlueBits
;
1598 case GLX_ACCUM_ALPHA_SIZE
:
1599 *value
= xmvis
->mesa_visual
.accumAlphaBits
;
1603 * GLX_EXT_visual_info extension
1605 case GLX_X_VISUAL_TYPE_EXT
:
1606 switch (xmvis
->visinfo
->CLASS
) {
1607 case StaticGray
: *value
= GLX_STATIC_GRAY_EXT
; return 0;
1608 case GrayScale
: *value
= GLX_GRAY_SCALE_EXT
; return 0;
1609 case StaticColor
: *value
= GLX_STATIC_GRAY_EXT
; return 0;
1610 case PseudoColor
: *value
= GLX_PSEUDO_COLOR_EXT
; return 0;
1611 case TrueColor
: *value
= GLX_TRUE_COLOR_EXT
; return 0;
1612 case DirectColor
: *value
= GLX_DIRECT_COLOR_EXT
; return 0;
1615 case GLX_TRANSPARENT_TYPE_EXT
:
1616 if (xmvis
->mesa_visual
.level
==0) {
1618 *value
= GLX_NONE_EXT
;
1620 else if (xmvis
->mesa_visual
.level
>0) {
1622 if (xmvis
->mesa_visual
.rgbMode
) {
1623 *value
= GLX_TRANSPARENT_RGB_EXT
;
1626 *value
= GLX_TRANSPARENT_INDEX_EXT
;
1629 else if (xmvis
->mesa_visual
.level
<0) {
1631 *value
= GLX_NONE_EXT
;
1634 case GLX_TRANSPARENT_INDEX_VALUE_EXT
:
1636 int pixel
= transparent_pixel( xmvis
);
1640 /* else undefined */
1643 case GLX_TRANSPARENT_RED_VALUE_EXT
:
1646 case GLX_TRANSPARENT_GREEN_VALUE_EXT
:
1649 case GLX_TRANSPARENT_BLUE_VALUE_EXT
:
1652 case GLX_TRANSPARENT_ALPHA_VALUE_EXT
:
1657 * GLX_EXT_visual_info extension
1659 case GLX_VISUAL_CAVEAT_EXT
:
1660 /* test for zero, just in case */
1661 if (xmvis
->mesa_visual
.visualRating
> 0)
1662 *value
= xmvis
->mesa_visual
.visualRating
;
1664 *value
= GLX_NONE_EXT
;
1668 * GLX_ARB_multisample
1670 case GLX_SAMPLE_BUFFERS_ARB
:
1673 case GLX_SAMPLES_ARB
:
1680 case GLX_SCREEN_EXT
:
1682 return GLX_BAD_ATTRIBUTE
;
1683 *value
= xmvis
->visinfo
->screen
;
1685 case GLX_DRAWABLE_TYPE
: /*SGIX too */
1687 return GLX_BAD_ATTRIBUTE
;
1688 *value
= GLX_WINDOW_BIT
| GLX_PIXMAP_BIT
| GLX_PBUFFER_BIT
;
1690 case GLX_RENDER_TYPE_SGIX
:
1692 return GLX_BAD_ATTRIBUTE
;
1693 if (xmvis
->mesa_visual
.rgbMode
)
1694 *value
= GLX_RGBA_BIT
;
1696 *value
= GLX_COLOR_INDEX_BIT
;
1698 case GLX_X_RENDERABLE_SGIX
:
1700 return GLX_BAD_ATTRIBUTE
;
1701 *value
= True
; /* XXX really? */
1703 case GLX_FBCONFIG_ID_SGIX
:
1705 return GLX_BAD_ATTRIBUTE
;
1706 *value
= xmvis
->visinfo
->visualid
;
1708 case GLX_MAX_PBUFFER_WIDTH
:
1710 return GLX_BAD_ATTRIBUTE
;
1711 /* XXX or MAX_WIDTH? */
1712 *value
= DisplayWidth(xmvis
->display
, xmvis
->visinfo
->screen
);
1714 case GLX_MAX_PBUFFER_HEIGHT
:
1716 return GLX_BAD_ATTRIBUTE
;
1717 *value
= DisplayHeight(xmvis
->display
, xmvis
->visinfo
->screen
);
1719 case GLX_MAX_PBUFFER_PIXELS
:
1721 return GLX_BAD_ATTRIBUTE
;
1722 *value
= DisplayWidth(xmvis
->display
, xmvis
->visinfo
->screen
) *
1723 DisplayHeight(xmvis
->display
, xmvis
->visinfo
->screen
);
1727 return GLX_BAD_ATTRIBUTE
;
1728 *value
= xmvis
->visinfo
->visualid
;
1732 return GLX_BAD_ATTRIBUTE
;
1739 Fake_glXGetConfig( Display
*dpy
, XVisualInfo
*visinfo
,
1740 int attrib
, int *value
)
1744 if (!dpy
|| !visinfo
)
1745 return GLX_BAD_ATTRIBUTE
;
1747 xmvis
= find_glx_visual( dpy
, visinfo
);
1749 /* this visual wasn't obtained with glXChooseVisual */
1750 xmvis
= create_glx_visual( dpy
, visinfo
);
1752 /* this visual can't be used for GL rendering */
1753 if (attrib
==GLX_USE_GL
) {
1754 *value
= (int) False
;
1758 return GLX_BAD_VISUAL
;
1763 return get_config(xmvis
, attrib
, value
, GL_FALSE
);
1768 Fake_glXWaitGL( void )
1770 XMesaContext xmesa
= XMesaGetCurrentContext();
1771 XMesaFlush( xmesa
);
1777 Fake_glXWaitX( void )
1779 XMesaContext xmesa
= XMesaGetCurrentContext();
1780 XMesaFlush( xmesa
);
1785 get_extensions( void )
1788 const char *fx
= _mesa_getenv("MESA_GLX_FX");
1789 if (fx
&& fx
[0] != 'd') {
1793 return EXTENSIONS
+ 23; /* skip "GLX_MESA_set_3dfx_mode" */
1798 /* GLX 1.1 and later */
1800 Fake_glXQueryExtensionsString( Display
*dpy
, int screen
)
1804 return get_extensions();
1809 /* GLX 1.1 and later */
1811 Fake_glXQueryServerString( Display
*dpy
, int screen
, int name
)
1813 static char version
[1000];
1814 _mesa_sprintf(version
, "%d.%d %s",
1815 SERVER_MAJOR_VERSION
, SERVER_MINOR_VERSION
, MESA_GLX_VERSION
);
1821 case GLX_EXTENSIONS
:
1822 return get_extensions();
1834 /* GLX 1.1 and later */
1836 Fake_glXGetClientString( Display
*dpy
, int name
)
1838 static char version
[1000];
1839 _mesa_sprintf(version
, "%d.%d %s", CLIENT_MAJOR_VERSION
,
1840 CLIENT_MINOR_VERSION
, MESA_GLX_VERSION
);
1845 case GLX_EXTENSIONS
:
1846 return get_extensions();
1863 static GLXFBConfig
*
1864 Fake_glXChooseFBConfig( Display
*dpy
, int screen
,
1865 const int *attribList
, int *nitems
)
1867 XMesaVisual xmvis
= choose_visual(dpy
, screen
, attribList
, GL_TRUE
);
1869 GLXFBConfig
*config
= (GLXFBConfig
*) _mesa_malloc(sizeof(XMesaVisual
));
1875 config
[0] = (GLXFBConfig
) xmvis
;
1876 return (GLXFBConfig
*) config
;
1886 Fake_glXGetFBConfigAttrib( Display
*dpy
, GLXFBConfig config
,
1887 int attribute
, int *value
)
1889 XMesaVisual v
= (XMesaVisual
) config
;
1893 if (!dpy
|| !config
|| !value
)
1896 return get_config(v
, attribute
, value
, GL_TRUE
);
1900 static GLXFBConfig
*
1901 Fake_glXGetFBConfigs( Display
*dpy
, int screen
, int *nelements
)
1903 XVisualInfo
*visuals
, visTemplate
;
1904 const long visMask
= VisualScreenMask
;
1907 /* Get list of all X visuals */
1908 visTemplate
.screen
= screen
;
1909 visuals
= XGetVisualInfo(dpy
, visMask
, &visTemplate
, nelements
);
1910 if (*nelements
> 0) {
1911 XMesaVisual
*results
;
1912 results
= (XMesaVisual
*) _mesa_malloc(*nelements
* sizeof(XMesaVisual
));
1917 for (i
= 0; i
< *nelements
; i
++) {
1918 results
[i
] = create_glx_visual(dpy
, visuals
+ i
);
1920 return (GLXFBConfig
*) results
;
1926 static XVisualInfo
*
1927 Fake_glXGetVisualFromFBConfig( Display
*dpy
, GLXFBConfig config
)
1929 if (dpy
&& config
) {
1930 XMesaVisual xmvis
= (XMesaVisual
) config
;
1932 return xmvis
->vishandle
;
1934 /* create a new vishandle - the cached one may be stale */
1935 xmvis
->vishandle
= (XVisualInfo
*) _mesa_malloc(sizeof(XVisualInfo
));
1936 if (xmvis
->vishandle
) {
1937 _mesa_memcpy(xmvis
->vishandle
, xmvis
->visinfo
, sizeof(XVisualInfo
));
1939 return xmvis
->vishandle
;
1949 Fake_glXCreateWindow( Display
*dpy
, GLXFBConfig config
, Window win
,
1950 const int *attribList
)
1952 XMesaVisual xmvis
= (XMesaVisual
) config
;
1957 xmbuf
= XMesaCreateWindowBuffer2(xmvis
, win
, NULL
);
1962 (void) attribList
; /* Ignored in GLX 1.3 */
1964 return win
; /* A hack for now */
1969 Fake_glXDestroyWindow( Display
*dpy
, GLXWindow window
)
1971 XMesaBuffer b
= XMesaFindBuffer(dpy
, (XMesaDrawable
) window
);
1973 XMesaDestroyBuffer(b
);
1974 /* don't destroy X window */
1980 Fake_glXCreatePixmap( Display
*dpy
, GLXFBConfig config
, Pixmap pixmap
,
1981 const int *attribList
)
1983 XMesaVisual v
= (XMesaVisual
) config
;
1989 (void) attribList
; /* Ignored in GLX 1.3 */
1991 if (!dpy
|| !config
|| !pixmap
)
1994 b
= XMesaCreatePixmapBuffer( v
, pixmap
, 0 );
2004 Fake_glXDestroyPixmap( Display
*dpy
, GLXPixmap pixmap
)
2006 XMesaBuffer b
= XMesaFindBuffer(dpy
, (XMesaDrawable
)pixmap
);
2008 XMesaDestroyBuffer(b
);
2009 /* don't destroy X pixmap */
2014 Fake_glXCreatePbuffer( Display
*dpy
, GLXFBConfig config
,
2015 const int *attribList
)
2017 XMesaVisual xmvis
= (XMesaVisual
) config
;
2020 int width
= 0, height
= 0;
2021 GLboolean useLargest
= GL_FALSE
, preserveContents
= GL_FALSE
;
2025 for (attrib
= attribList
; *attrib
; attrib
++) {
2027 case GLX_PBUFFER_WIDTH
:
2031 case GLX_PBUFFER_HEIGHT
:
2035 case GLX_PRESERVED_CONTENTS
:
2037 preserveContents
= *attrib
; /* ignored */
2039 case GLX_LARGEST_PBUFFER
:
2041 useLargest
= *attrib
; /* ignored */
2048 /* not used at this time */
2050 (void) preserveContents
;
2052 if (width
== 0 || height
== 0)
2055 xmbuf
= XMesaCreatePBuffer( xmvis
, 0, width
, height
);
2056 /* A GLXPbuffer handle must be an X Drawable because that's what
2057 * glXMakeCurrent takes.
2059 return (GLXPbuffer
) xmbuf
->frontbuffer
;
2064 Fake_glXDestroyPbuffer( Display
*dpy
, GLXPbuffer pbuf
)
2066 XMesaBuffer b
= XMesaFindBuffer(dpy
, pbuf
);
2068 XMesaDestroyBuffer(b
);
2074 Fake_glXQueryDrawable( Display
*dpy
, GLXDrawable draw
, int attribute
,
2075 unsigned int *value
)
2077 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, draw
);
2081 switch (attribute
) {
2083 *value
= xmbuf
->width
;
2086 *value
= xmbuf
->height
;
2088 case GLX_PRESERVED_CONTENTS
:
2091 case GLX_LARGEST_PBUFFER
:
2092 *value
= xmbuf
->width
* xmbuf
->height
;
2094 case GLX_FBCONFIG_ID
:
2095 *value
= xmbuf
->xm_visual
->visinfo
->visualid
;
2098 return; /* GLX_BAD_ATTRIBUTE? */
2104 Fake_glXCreateNewContext( Display
*dpy
, GLXFBConfig config
,
2105 int renderType
, GLXContext shareList
, Bool direct
)
2107 struct fake_glx_context
*glxCtx
;
2108 struct fake_glx_context
*shareCtx
= (struct fake_glx_context
*) shareList
;
2109 XMesaVisual xmvis
= (XMesaVisual
) config
;
2111 if (!dpy
|| !config
||
2112 (renderType
!= GLX_RGBA_TYPE
&& renderType
!= GLX_COLOR_INDEX_TYPE
))
2115 glxCtx
= CALLOC_STRUCT(fake_glx_context
);
2119 /* deallocate unused windows/buffers */
2120 XMesaGarbageCollect();
2122 glxCtx
->xmesaContext
= XMesaCreateContext(xmvis
,
2123 shareCtx
? shareCtx
->xmesaContext
: NULL
);
2124 if (!glxCtx
->xmesaContext
) {
2129 glxCtx
->xmesaContext
->direct
= GL_FALSE
;
2130 glxCtx
->glxContext
.isDirect
= GL_FALSE
;
2131 glxCtx
->glxContext
.currentDpy
= dpy
;
2132 glxCtx
->glxContext
.xid
= (XID
) glxCtx
; /* self pointer */
2134 assert((void *) glxCtx
== (void *) &(glxCtx
->glxContext
));
2136 return (GLXContext
) glxCtx
;
2141 Fake_glXQueryContext( Display
*dpy
, GLXContext ctx
, int attribute
, int *value
)
2143 struct fake_glx_context
*glxCtx
= (struct fake_glx_context
*) ctx
;
2144 XMesaContext xmctx
= glxCtx
->xmesaContext
;
2149 switch (attribute
) {
2150 case GLX_FBCONFIG_ID
:
2151 *value
= xmctx
->xm_visual
->visinfo
->visualid
;
2153 case GLX_RENDER_TYPE
:
2154 if (xmctx
->xm_visual
->mesa_visual
.rgbMode
)
2155 *value
= GLX_RGBA_BIT
;
2157 *value
= GLX_COLOR_INDEX_BIT
;
2163 return GLX_BAD_ATTRIBUTE
;
2170 Fake_glXSelectEvent( Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
2172 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, drawable
);
2174 xmbuf
->selectedEvents
= mask
;
2179 Fake_glXGetSelectedEvent( Display
*dpy
, GLXDrawable drawable
,
2180 unsigned long *mask
)
2182 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, drawable
);
2184 *mask
= xmbuf
->selectedEvents
;
2191 /*** GLX_SGI_swap_control ***/
2194 Fake_glXSwapIntervalSGI(int interval
)
2202 /*** GLX_SGI_video_sync ***/
2205 Fake_glXGetVideoSyncSGI(unsigned int *count
)
2212 Fake_glXWaitVideoSyncSGI(int divisor
, int remainder
, unsigned int *count
)
2222 /*** GLX_SGI_make_current_read ***/
2225 Fake_glXMakeCurrentReadSGI(Display
*dpy
, GLXDrawable draw
, GLXDrawable read
, GLXContext ctx
)
2227 return Fake_glXMakeContextCurrent( dpy
, draw
, read
, ctx
);
2232 Fake_glXGetCurrentReadDrawableSGI(void)
2239 /*** GLX_SGIX_video_source ***/
2242 static GLXVideoSourceSGIX
2243 Fake_glXCreateGLXVideoSourceSGIX(Display
*dpy
, int screen
, VLServer server
, VLPath path
, int nodeClass
, VLNode drainNode
)
2255 Fake_glXDestroyGLXVideoSourceSGIX(Display
*dpy
, GLXVideoSourceSGIX src
)
2264 /*** GLX_EXT_import_context ***/
2267 Fake_glXFreeContextEXT(Display
*dpy
, GLXContext context
)
2274 Fake_glXGetContextIDEXT(const GLXContext context
)
2281 Fake_glXImportContextEXT(Display
*dpy
, GLXContextID contextID
)
2289 Fake_glXQueryContextInfoEXT(Display
*dpy
, GLXContext context
, int attribute
, int *value
)
2300 /*** GLX_SGIX_fbconfig ***/
2303 Fake_glXGetFBConfigAttribSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int attribute
, int *value
)
2305 return Fake_glXGetFBConfigAttrib(dpy
, config
, attribute
, value
);
2308 static GLXFBConfigSGIX
*
2309 Fake_glXChooseFBConfigSGIX(Display
*dpy
, int screen
, int *attrib_list
, int *nelements
)
2311 return (GLXFBConfig
*) Fake_glXChooseFBConfig(dpy
, screen
, attrib_list
, nelements
);
2316 Fake_glXCreateGLXPixmapWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, Pixmap pixmap
)
2318 XMesaVisual xmvis
= (XMesaVisual
) config
;
2319 XMesaBuffer xmbuf
= XMesaCreatePixmapBuffer(xmvis
, pixmap
, 0);
2320 return xmbuf
->frontbuffer
; /* need to return an X ID */
2325 Fake_glXCreateContextWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int render_type
, GLXContext share_list
, Bool direct
)
2327 XMesaVisual xmvis
= (XMesaVisual
) config
;
2328 struct fake_glx_context
*glxCtx
;
2329 struct fake_glx_context
*shareCtx
= (struct fake_glx_context
*) share_list
;
2331 glxCtx
= CALLOC_STRUCT(fake_glx_context
);
2335 /* deallocate unused windows/buffers */
2336 XMesaGarbageCollect();
2338 glxCtx
->xmesaContext
= XMesaCreateContext(xmvis
,
2339 shareCtx
? shareCtx
->xmesaContext
: NULL
);
2340 if (!glxCtx
->xmesaContext
) {
2345 glxCtx
->xmesaContext
->direct
= GL_FALSE
;
2346 glxCtx
->glxContext
.isDirect
= GL_FALSE
;
2347 glxCtx
->glxContext
.currentDpy
= dpy
;
2348 glxCtx
->glxContext
.xid
= (XID
) glxCtx
; /* self pointer */
2350 assert((void *) glxCtx
== (void *) &(glxCtx
->glxContext
));
2352 return (GLXContext
) glxCtx
;
2356 static XVisualInfo
*
2357 Fake_glXGetVisualFromFBConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
)
2359 return Fake_glXGetVisualFromFBConfig(dpy
, config
);
2363 static GLXFBConfigSGIX
2364 Fake_glXGetFBConfigFromVisualSGIX(Display
*dpy
, XVisualInfo
*vis
)
2366 XMesaVisual xmvis
= find_glx_visual(dpy
, vis
);
2368 /* This visual wasn't found with glXChooseVisual() */
2369 xmvis
= create_glx_visual(dpy
, vis
);
2372 return (GLXFBConfigSGIX
) xmvis
;
2377 /*** GLX_SGIX_pbuffer ***/
2379 static GLXPbufferSGIX
2380 Fake_glXCreateGLXPbufferSGIX(Display
*dpy
, GLXFBConfigSGIX config
,
2381 unsigned int width
, unsigned int height
,
2384 XMesaVisual xmvis
= (XMesaVisual
) config
;
2387 GLboolean useLargest
= GL_FALSE
, preserveContents
= GL_FALSE
;
2391 for (attrib
= attribList
; *attrib
; attrib
++) {
2393 case GLX_PRESERVED_CONTENTS_SGIX
:
2395 preserveContents
= *attrib
; /* ignored */
2397 case GLX_LARGEST_PBUFFER_SGIX
:
2399 useLargest
= *attrib
; /* ignored */
2406 /* not used at this time */
2408 (void) preserveContents
;
2410 xmbuf
= XMesaCreatePBuffer( xmvis
, 0, width
, height
);
2411 /* A GLXPbuffer handle must be an X Drawable because that's what
2412 * glXMakeCurrent takes.
2414 return (GLXPbuffer
) xmbuf
->frontbuffer
;
2419 Fake_glXDestroyGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
)
2421 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, pbuf
);
2423 XMesaDestroyBuffer(xmbuf
);
2429 Fake_glXQueryGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
, int attribute
, unsigned int *value
)
2431 const XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, pbuf
);
2434 /* Generate GLXBadPbufferSGIX for bad pbuffer */
2438 switch (attribute
) {
2439 case GLX_PRESERVED_CONTENTS_SGIX
:
2442 case GLX_LARGEST_PBUFFER_SGIX
:
2443 *value
= xmbuf
->width
* xmbuf
->height
;
2445 case GLX_WIDTH_SGIX
:
2446 *value
= xmbuf
->width
;
2448 case GLX_HEIGHT_SGIX
:
2449 *value
= xmbuf
->height
;
2451 case GLX_EVENT_MASK_SGIX
:
2452 *value
= 0; /* XXX might be wrong */
2462 Fake_glXSelectEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
2464 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, drawable
);
2466 /* Note: we'll never generate clobber events */
2467 xmbuf
->selectedEvents
= mask
;
2473 Fake_glXGetSelectedEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long *mask
)
2475 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, drawable
);
2477 *mask
= xmbuf
->selectedEvents
;
2486 /*** GLX_SGI_cushion ***/
2489 Fake_glXCushionSGI(Display
*dpy
, Window win
, float cushion
)
2498 /*** GLX_SGIX_video_resize ***/
2501 Fake_glXBindChannelToWindowSGIX(Display
*dpy
, int screen
, int channel
, Window window
)
2511 Fake_glXChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int x
, int y
, int w
, int h
)
2524 Fake_glXQueryChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int *x
, int *y
, int *w
, int *h
)
2537 Fake_glXQueryChannelDeltasSGIX(Display
*dpy
, int screen
, int channel
, int *dx
, int *dy
, int *dw
, int *dh
)
2550 Fake_glXChannelRectSyncSGIX(Display
*dpy
, int screen
, int channel
, GLenum synctype
)
2561 /*** GLX_SGIX_dmbuffer **/
2563 #if defined(_DM_BUFFER_H_)
2565 Fake_glXAssociateDMPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuffer
, DMparams
*params
, DMbuffer dmbuffer
)
2576 /*** GLX_SGIX_swap_group ***/
2579 Fake_glXJoinSwapGroupSGIX(Display
*dpy
, GLXDrawable drawable
, GLXDrawable member
)
2588 /*** GLX_SGIX_swap_barrier ***/
2591 Fake_glXBindSwapBarrierSGIX(Display
*dpy
, GLXDrawable drawable
, int barrier
)
2599 Fake_glXQueryMaxSwapBarriersSGIX(Display
*dpy
, int screen
, int *max
)
2609 /*** GLX_SUN_get_transparent_index ***/
2612 Fake_glXGetTransparentIndexSUN(Display
*dpy
, Window overlay
, Window underlay
, long *pTransparent
)
2617 (void) pTransparent
;
2623 /*** GLX_MESA_release_buffers ***/
2626 * Release the depth, stencil, accum buffers attached to a GLXDrawable
2627 * (a window or pixmap) prior to destroying the GLXDrawable.
2630 Fake_glXReleaseBuffersMESA( Display
*dpy
, GLXDrawable d
)
2632 XMesaBuffer b
= XMesaFindBuffer(dpy
, d
);
2634 XMesaDestroyBuffer(b
);
2642 /*** GLX_MESA_set_3dfx_mode ***/
2645 Fake_glXSet3DfxModeMESA( int mode
)
2647 return XMesaSetFXmode( mode
);
2652 /*** GLX_NV_vertex_array range ***/
2654 Fake_glXAllocateMemoryNV( GLsizei size
,
2655 GLfloat readFrequency
,
2656 GLfloat writeFrequency
,
2660 (void) readFrequency
;
2661 (void) writeFrequency
;
2668 Fake_glXFreeMemoryNV( GLvoid
*pointer
)
2674 /*** GLX_MESA_agp_offset ***/
2677 Fake_glXGetAGPOffsetMESA( const GLvoid
*pointer
)
2684 /*** GLX_ARB_render_texture ***/
2687 Fake_glXBindTexImageARB( Display
*dpy
, GLXPbuffer pbuffer
, int buffer
)
2694 Fake_glXReleaseTexImageARB(Display
*dpy
, GLXPbuffer pbuffer
, int buffer
)
2701 Fake_glXDrawableAttribARB( Display
*dpy
, GLXDrawable draw
, const int *attribList
)
2708 extern struct _glxapi_table
*_mesa_GetGLXDispatchTable(void);
2709 struct _glxapi_table
*_mesa_GetGLXDispatchTable(void)
2711 static struct _glxapi_table glx
;
2713 /* be sure our dispatch table size <= libGL's table */
2715 GLuint size
= sizeof(struct _glxapi_table
) / sizeof(void *);
2717 assert(_glxapi_get_dispatch_table_size() >= size
);
2720 /* initialize the whole table to no-ops */
2721 _glxapi_set_no_op_table(&glx
);
2723 /* now initialize the table with the functions I implement */
2724 glx
.ChooseVisual
= Fake_glXChooseVisual
;
2725 glx
.CopyContext
= Fake_glXCopyContext
;
2726 glx
.CreateContext
= Fake_glXCreateContext
;
2727 glx
.CreateGLXPixmap
= Fake_glXCreateGLXPixmap
;
2728 glx
.DestroyContext
= Fake_glXDestroyContext
;
2729 glx
.DestroyGLXPixmap
= Fake_glXDestroyGLXPixmap
;
2730 glx
.GetConfig
= Fake_glXGetConfig
;
2731 /*glx.GetCurrentContext = Fake_glXGetCurrentContext;*/
2732 /*glx.GetCurrentDrawable = Fake_glXGetCurrentDrawable;*/
2733 glx
.IsDirect
= Fake_glXIsDirect
;
2734 glx
.MakeCurrent
= Fake_glXMakeCurrent
;
2735 glx
.QueryExtension
= Fake_glXQueryExtension
;
2736 glx
.QueryVersion
= Fake_glXQueryVersion
;
2737 glx
.SwapBuffers
= Fake_glXSwapBuffers
;
2738 glx
.UseXFont
= Fake_glXUseXFont
;
2739 glx
.WaitGL
= Fake_glXWaitGL
;
2740 glx
.WaitX
= Fake_glXWaitX
;
2742 /*** GLX_VERSION_1_1 ***/
2743 glx
.GetClientString
= Fake_glXGetClientString
;
2744 glx
.QueryExtensionsString
= Fake_glXQueryExtensionsString
;
2745 glx
.QueryServerString
= Fake_glXQueryServerString
;
2747 /*** GLX_VERSION_1_2 ***/
2748 /*glx.GetCurrentDisplay = Fake_glXGetCurrentDisplay;*/
2750 /*** GLX_VERSION_1_3 ***/
2751 glx
.ChooseFBConfig
= Fake_glXChooseFBConfig
;
2752 glx
.CreateNewContext
= Fake_glXCreateNewContext
;
2753 glx
.CreatePbuffer
= Fake_glXCreatePbuffer
;
2754 glx
.CreatePixmap
= Fake_glXCreatePixmap
;
2755 glx
.CreateWindow
= Fake_glXCreateWindow
;
2756 glx
.DestroyPbuffer
= Fake_glXDestroyPbuffer
;
2757 glx
.DestroyPixmap
= Fake_glXDestroyPixmap
;
2758 glx
.DestroyWindow
= Fake_glXDestroyWindow
;
2759 /*glx.GetCurrentReadDrawable = Fake_glXGetCurrentReadDrawable;*/
2760 glx
.GetFBConfigAttrib
= Fake_glXGetFBConfigAttrib
;
2761 glx
.GetFBConfigs
= Fake_glXGetFBConfigs
;
2762 glx
.GetSelectedEvent
= Fake_glXGetSelectedEvent
;
2763 glx
.GetVisualFromFBConfig
= Fake_glXGetVisualFromFBConfig
;
2764 glx
.MakeContextCurrent
= Fake_glXMakeContextCurrent
;
2765 glx
.QueryContext
= Fake_glXQueryContext
;
2766 glx
.QueryDrawable
= Fake_glXQueryDrawable
;
2767 glx
.SelectEvent
= Fake_glXSelectEvent
;
2769 /*** GLX_SGI_swap_control ***/
2770 glx
.SwapIntervalSGI
= Fake_glXSwapIntervalSGI
;
2772 /*** GLX_SGI_video_sync ***/
2773 glx
.GetVideoSyncSGI
= Fake_glXGetVideoSyncSGI
;
2774 glx
.WaitVideoSyncSGI
= Fake_glXWaitVideoSyncSGI
;
2776 /*** GLX_SGI_make_current_read ***/
2777 glx
.MakeCurrentReadSGI
= Fake_glXMakeCurrentReadSGI
;
2778 /*glx.GetCurrentReadDrawableSGI = Fake_glXGetCurrentReadDrawableSGI;*/
2780 /*** GLX_SGIX_video_source ***/
2782 glx
.CreateGLXVideoSourceSGIX
= Fake_glXCreateGLXVideoSourceSGIX
;
2783 glx
.DestroyGLXVideoSourceSGIX
= Fake_glXDestroyGLXVideoSourceSGIX
;
2786 /*** GLX_EXT_import_context ***/
2787 glx
.FreeContextEXT
= Fake_glXFreeContextEXT
;
2788 glx
.GetContextIDEXT
= Fake_glXGetContextIDEXT
;
2789 /*glx.GetCurrentDisplayEXT = Fake_glXGetCurrentDisplayEXT;*/
2790 glx
.ImportContextEXT
= Fake_glXImportContextEXT
;
2791 glx
.QueryContextInfoEXT
= Fake_glXQueryContextInfoEXT
;
2793 /*** GLX_SGIX_fbconfig ***/
2794 glx
.GetFBConfigAttribSGIX
= Fake_glXGetFBConfigAttribSGIX
;
2795 glx
.ChooseFBConfigSGIX
= Fake_glXChooseFBConfigSGIX
;
2796 glx
.CreateGLXPixmapWithConfigSGIX
= Fake_glXCreateGLXPixmapWithConfigSGIX
;
2797 glx
.CreateContextWithConfigSGIX
= Fake_glXCreateContextWithConfigSGIX
;
2798 glx
.GetVisualFromFBConfigSGIX
= Fake_glXGetVisualFromFBConfigSGIX
;
2799 glx
.GetFBConfigFromVisualSGIX
= Fake_glXGetFBConfigFromVisualSGIX
;
2801 /*** GLX_SGIX_pbuffer ***/
2802 glx
.CreateGLXPbufferSGIX
= Fake_glXCreateGLXPbufferSGIX
;
2803 glx
.DestroyGLXPbufferSGIX
= Fake_glXDestroyGLXPbufferSGIX
;
2804 glx
.QueryGLXPbufferSGIX
= Fake_glXQueryGLXPbufferSGIX
;
2805 glx
.SelectEventSGIX
= Fake_glXSelectEventSGIX
;
2806 glx
.GetSelectedEventSGIX
= Fake_glXGetSelectedEventSGIX
;
2808 /*** GLX_SGI_cushion ***/
2809 glx
.CushionSGI
= Fake_glXCushionSGI
;
2811 /*** GLX_SGIX_video_resize ***/
2812 glx
.BindChannelToWindowSGIX
= Fake_glXBindChannelToWindowSGIX
;
2813 glx
.ChannelRectSGIX
= Fake_glXChannelRectSGIX
;
2814 glx
.QueryChannelRectSGIX
= Fake_glXQueryChannelRectSGIX
;
2815 glx
.QueryChannelDeltasSGIX
= Fake_glXQueryChannelDeltasSGIX
;
2816 glx
.ChannelRectSyncSGIX
= Fake_glXChannelRectSyncSGIX
;
2818 /*** GLX_SGIX_dmbuffer **/
2819 #if defined(_DM_BUFFER_H_)
2820 glx
.AssociateDMPbufferSGIX
= NULL
;
2823 /*** GLX_SGIX_swap_group ***/
2824 glx
.JoinSwapGroupSGIX
= Fake_glXJoinSwapGroupSGIX
;
2826 /*** GLX_SGIX_swap_barrier ***/
2827 glx
.BindSwapBarrierSGIX
= Fake_glXBindSwapBarrierSGIX
;
2828 glx
.QueryMaxSwapBarriersSGIX
= Fake_glXQueryMaxSwapBarriersSGIX
;
2830 /*** GLX_SUN_get_transparent_index ***/
2831 glx
.GetTransparentIndexSUN
= Fake_glXGetTransparentIndexSUN
;
2833 /*** GLX_MESA_copy_sub_buffer ***/
2834 glx
.CopySubBufferMESA
= Fake_glXCopySubBufferMESA
;
2836 /*** GLX_MESA_release_buffers ***/
2837 glx
.ReleaseBuffersMESA
= Fake_glXReleaseBuffersMESA
;
2839 /*** GLX_MESA_pixmap_colormap ***/
2840 glx
.CreateGLXPixmapMESA
= Fake_glXCreateGLXPixmapMESA
;
2842 /*** GLX_MESA_set_3dfx_mode ***/
2843 glx
.Set3DfxModeMESA
= Fake_glXSet3DfxModeMESA
;
2845 /*** GLX_NV_vertex_array_range ***/
2846 glx
.AllocateMemoryNV
= Fake_glXAllocateMemoryNV
;
2847 glx
.FreeMemoryNV
= Fake_glXFreeMemoryNV
;
2849 /*** GLX_MESA_agp_offset ***/
2850 glx
.GetAGPOffsetMESA
= Fake_glXGetAGPOffsetMESA
;
2852 /*** GLX_ARB_render_texture ***/
2853 glx
.BindTexImageARB
= Fake_glXBindTexImageARB
;
2854 glx
.ReleaseTexImageARB
= Fake_glXReleaseTexImageARB
;
2855 glx
.DrawableAttribARB
= Fake_glXDrawableAttribARB
;