1 /* $Id: fakeglx.c,v 1.32 2000/04/10 21:13:19 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 * This is an emulation of the GLX API which allows Mesa/GLX-based programs
30 * to run on X servers which do not have the real GLX extension.
32 * Thanks to the contributors:
34 * Initial version: Philip Brown (philb@CSUA.Berkeley.EDU)
35 * Better glXGetConfig() support: Armin Liebchen (liebchen@asylum.cs.utah.edu)
36 * Further visual-handling refinements: Wolfram Gloger
37 * (wmglo@Dent.MED.Uni-Muenchen.DE).
40 * Don't be fooled, stereo isn't supported yet.
45 #include "glxheader.h"
55 /* This indicates the client-side GLX API and GLX encoder version. */
56 #define CLIENT_MAJOR_VERSION 1
57 #define CLIENT_MINOR_VERSION 2
59 /* This indicates the server-side GLX decoder version.
60 * GLX 1.3 indicates OpenGL 1.2 support
62 #define SERVER_MAJOR_VERSION 1
63 #define SERVER_MINOR_VERSION 3
65 /* This is appended onto the glXGetClient/ServerString version strings. */
66 #define MESA_GLX_VERSION "Mesa 3.3"
68 /* Who implemented this GLX? */
69 #define VENDOR "Brian Paul"
73 /* Silence compiler warnings */
74 extern void Fake_glXDummyFunc( void );
75 void Fake_glXDummyFunc( void )
89 #define MAX_VISUALS 100
90 static XMesaVisual VisualTable
[MAX_VISUALS
];
91 static int NumVisuals
= 0;
96 * This struct and some code fragments borrowed
97 * from Mark Kilgard's GLUT library.
99 typedef struct _OverlayInfo
{
100 /* Avoid 64-bit portability problems by being careful to use
101 longs due to the way XGetWindowProperty is specified. Note
102 that these parameters are passed as CARD32s over X
104 unsigned long overlay_visual
;
105 long transparent_type
;
112 /* Macro to handle c_class vs class field name in XVisualInfo struct */
113 #if defined(__cplusplus) || defined(c_plusplus)
114 #define CLASS c_class
123 * Test if the given XVisualInfo is usable for Mesa rendering.
125 static GLboolean
is_usable_visual( XVisualInfo
*vinfo
)
127 switch (vinfo
->CLASS
) {
130 /* Any StaticGray/GrayScale visual works in RGB or CI mode */
134 /* Any StaticColor/PseudoColor visual of at least 4 bits */
135 if (vinfo
->depth
>=4) {
143 /* Any depth of TrueColor or DirectColor works in RGB mode */
146 /* This should never happen */
154 * Return the level (overlay, normal, underlay) of a given XVisualInfo.
155 * Input: dpy - the X display
156 * vinfo - the XVisualInfo to test
157 * Return: level of the visual:
159 * >0 = overlay planes
160 * <0 = underlay planes
162 static int level_of_visual( Display
*dpy
, XVisualInfo
*vinfo
)
164 Atom overlayVisualsAtom
;
165 OverlayInfo
*overlay_info
= NULL
;
166 int numOverlaysPerScreen
;
170 unsigned long sizeData
, bytesLeft
;
174 * The SERVER_OVERLAY_VISUALS property on the root window contains
175 * a list of overlay visuals. Get that list now.
177 overlayVisualsAtom
= XInternAtom(dpy
,"SERVER_OVERLAY_VISUALS", True
);
178 if (overlayVisualsAtom
== None
) {
182 status
= XGetWindowProperty(dpy
, RootWindow( dpy
, vinfo
->screen
),
183 overlayVisualsAtom
, 0L, (long) 10000, False
,
184 overlayVisualsAtom
, &actualType
, &actualFormat
,
185 &sizeData
, &bytesLeft
,
186 (unsigned char **) &overlay_info
);
188 if (status
!= Success
|| actualType
!= overlayVisualsAtom
||
189 actualFormat
!= 32 || sizeData
< 4) {
190 /* something went wrong */
191 XFree((void *) overlay_info
);
195 /* search the overlay visual list for the visual ID of interest */
196 numOverlaysPerScreen
= (int) (sizeData
/ 4);
197 for (i
=0;i
<numOverlaysPerScreen
;i
++) {
199 ov
= overlay_info
+ i
;
200 if (ov
->overlay_visual
==vinfo
->visualid
) {
201 /* found the visual */
202 if (/*ov->transparent_type==1 &&*/ ov
->layer
!=0) {
203 int level
= ov
->layer
;
204 XFree((void *) overlay_info
);
208 XFree((void *) overlay_info
);
214 /* The visual ID was not found in the overlay list. */
215 XFree((void *) overlay_info
);
223 * Given an XVisualInfo and RGB, Double, and Depth buffer flags, save the
224 * configuration in our list of GLX visuals.
227 save_glx_visual( Display
*dpy
, XVisualInfo
*vinfo
,
228 GLboolean rgbFlag
, GLboolean alphaFlag
, GLboolean dbFlag
,
229 GLboolean stereoFlag
,
230 GLint depth_size
, GLint stencil_size
,
231 GLint accumRedSize
, GLint accumGreenSize
,
232 GLint accumBlueSize
, GLint accumAlphaSize
,
235 GLboolean ximageFlag
= GL_TRUE
;
238 GLboolean comparePointers
;
241 /* Check if the MESA_BACK_BUFFER env var is set */
242 char *backbuffer
= getenv("MESA_BACK_BUFFER");
244 if (backbuffer
[0]=='p' || backbuffer
[0]=='P') {
245 ximageFlag
= GL_FALSE
;
247 else if (backbuffer
[0]=='x' || backbuffer
[0]=='X') {
248 ximageFlag
= GL_TRUE
;
251 fprintf(stderr
, "Mesa: invalid value for MESA_BACK_BUFFER ");
252 fprintf(stderr
, "environment variable, using an XImage.\n");
257 /* Comparing IDs uses less memory but sometimes fails. */
258 /* XXX revisit this after 3.0 is finished. */
259 if (getenv("MESA_GLX_VISUAL_HACK"))
260 comparePointers
= GL_TRUE
;
262 comparePointers
= GL_FALSE
;
264 /* First check if a matching visual is already in the list */
265 for (i
=0; i
<NumVisuals
; i
++) {
266 XMesaVisual v
= VisualTable
[i
];
267 if (v
->display
== dpy
269 && v
->ximage_flag
== ximageFlag
270 && v
->gl_visual
->RGBAflag
== rgbFlag
271 && v
->gl_visual
->DBflag
== dbFlag
272 && v
->gl_visual
->StereoFlag
== stereoFlag
273 && (v
->gl_visual
->AlphaBits
> 0) == alphaFlag
274 && (v
->gl_visual
->DepthBits
>= depth_size
|| depth_size
== 0)
275 && (v
->gl_visual
->StencilBits
>= stencil_size
|| stencil_size
== 0)
276 && (v
->gl_visual
->AccumRedBits
>= accumRedSize
|| accumRedSize
== 0)
277 && (v
->gl_visual
->AccumGreenBits
>= accumGreenSize
|| accumGreenSize
== 0)
278 && (v
->gl_visual
->AccumBlueBits
>= accumBlueSize
|| accumBlueSize
== 0)
279 && (v
->gl_visual
->AccumAlphaBits
>= accumAlphaSize
|| accumAlphaSize
== 0)) {
280 /* now either compare XVisualInfo pointers or visual IDs */
281 if ((!comparePointers
&& v
->visinfo
->visualid
== vinfo
->visualid
)
282 || (comparePointers
&& v
->vishandle
== vinfo
)) {
288 /* Create a new visual and add it to the list. */
290 if (NumVisuals
>=MAX_VISUALS
) {
291 fprintf( stderr
, "GLX Error: maximum number of visuals exceeded\n");
295 xmvis
= XMesaCreateVisual( dpy
, vinfo
, rgbFlag
, alphaFlag
, dbFlag
,
296 stereoFlag
, ximageFlag
,
297 depth_size
, stencil_size
,
298 accumRedSize
, accumBlueSize
,
299 accumBlueSize
, accumAlphaSize
, 0, level
,
302 VisualTable
[NumVisuals
] = xmvis
;
311 * Create a GLX visual from a regular XVisualInfo.
312 * This is called when Fake GLX is given an XVisualInfo which wasn't
313 * returned by glXChooseVisual. Since this is the first time we're
314 * considering this visual we'll take a guess at reasonable values
315 * for depth buffer size, stencil size, accum size, etc.
316 * This is the best we can do with a client-side emulation of GLX.
319 create_glx_visual( Display
*dpy
, XVisualInfo
*visinfo
)
323 vislevel
= level_of_visual( dpy
, visinfo
);
325 /* Configure this visual as a CI, single-buffered overlay */
326 return save_glx_visual( dpy
, visinfo
,
328 GL_FALSE
, /* alpha */
329 GL_FALSE
, /* double */
330 GL_FALSE
, /* stereo */
332 0, /* stencil bits */
333 0,0,0,0, /* accum bits */
337 else if (is_usable_visual( visinfo
)) {
338 /* Configure this visual as RGB, double-buffered, depth-buffered. */
339 /* This is surely wrong for some people's needs but what else */
340 /* can be done? They should use glXChooseVisual(). */
341 return save_glx_visual( dpy
, visinfo
,
343 GL_FALSE
, /* alpha */
344 GL_TRUE
, /* double */
345 GL_FALSE
, /* stereo */
346 DEFAULT_SOFTWARE_DEPTH_BITS
,
347 8 * sizeof(GLstencil
),
348 8 * sizeof(GLaccum
), /* r */
349 8 * sizeof(GLaccum
), /* g */
350 8 * sizeof(GLaccum
), /* b */
351 8 * sizeof(GLaccum
), /* a */
356 fprintf(stderr
,"Mesa: error in glXCreateContext: bad visual\n");
364 * Find the GLX visual associated with an XVisualInfo.
367 find_glx_visual( Display
*dpy
, XVisualInfo
*vinfo
)
371 /* First try to match pointers */
372 for (i
=0;i
<NumVisuals
;i
++) {
373 if (VisualTable
[i
]->display
==dpy
&& VisualTable
[i
]->vishandle
==vinfo
) {
374 return VisualTable
[i
];
377 /* try to match visual id */
378 for (i
=0;i
<NumVisuals
;i
++) {
379 if (VisualTable
[i
]->display
==dpy
380 && VisualTable
[i
]->visinfo
->visualid
== vinfo
->visualid
) {
381 return VisualTable
[i
];
390 * Return the transparent pixel value for a GLX visual.
391 * Input: glxvis - the glx_visual
392 * Return: a pixel value or -1 if no transparent pixel
394 static int transparent_pixel( XMesaVisual glxvis
)
396 Display
*dpy
= glxvis
->display
;
397 XVisualInfo
*vinfo
= glxvis
->visinfo
;
398 Atom overlayVisualsAtom
;
399 OverlayInfo
*overlay_info
= NULL
;
400 int numOverlaysPerScreen
;
404 unsigned long sizeData
, bytesLeft
;
408 * The SERVER_OVERLAY_VISUALS property on the root window contains
409 * a list of overlay visuals. Get that list now.
411 overlayVisualsAtom
= XInternAtom(dpy
,"SERVER_OVERLAY_VISUALS", True
);
412 if (overlayVisualsAtom
== None
) {
416 status
= XGetWindowProperty(dpy
, RootWindow( dpy
, vinfo
->screen
),
417 overlayVisualsAtom
, 0L, (long) 10000, False
,
418 overlayVisualsAtom
, &actualType
, &actualFormat
,
419 &sizeData
, &bytesLeft
,
420 (unsigned char **) &overlay_info
);
422 if (status
!= Success
|| actualType
!= overlayVisualsAtom
||
423 actualFormat
!= 32 || sizeData
< 4) {
424 /* something went wrong */
425 XFree((void *) overlay_info
);
429 /* search the overlay visual list for the visual ID of interest */
430 numOverlaysPerScreen
= (int) (sizeData
/ 4);
431 for (i
=0;i
<numOverlaysPerScreen
;i
++) {
433 ov
= overlay_info
+ i
;
434 if (ov
->overlay_visual
==vinfo
->visualid
) {
436 if (ov
->transparent_type
==0) {
437 /* type 0 indicates no transparency */
438 XFree((void *) overlay_info
);
442 /* ov->value is the transparent pixel */
443 XFree((void *) overlay_info
);
449 /* The visual ID was not found in the overlay list. */
450 XFree((void *) overlay_info
);
457 * Return number of bits set in n.
459 static int bitcount( unsigned long n
)
462 for (bits
=0; n
>0; n
=n
>>1) {
472 * Try to get an X visual which matches the given arguments.
474 static XVisualInfo
*get_visual( Display
*dpy
, int scr
,
475 unsigned int depth
, int xclass
)
477 XVisualInfo temp
, *vis
;
480 unsigned int default_depth
;
483 mask
= VisualScreenMask
| VisualDepthMask
| VisualClassMask
;
488 default_depth
= DefaultDepth(dpy
,scr
);
489 default_class
= DefaultVisual(dpy
,scr
)->CLASS
;
491 if (depth
==default_depth
&& xclass
==default_class
) {
492 /* try to get root window's visual */
493 temp
.visualid
= DefaultVisual(dpy
,scr
)->visualid
;
494 mask
|= VisualIDMask
;
497 vis
= XGetVisualInfo( dpy
, mask
, &temp
, &n
);
499 /* In case bits/pixel > 24, make sure color channels are still <=8 bits.
500 * An SGI Infinite Reality system, for example, can have 30bpp pixels:
501 * 10 bits per color channel. Mesa's limited to a max of 8 bits/channel.
503 if (vis
&& depth
> 24 && (xclass
==TrueColor
|| xclass
==DirectColor
)) {
504 if (bitcount(vis
->red_mask
) <= 8
505 && bitcount(vis
->green_mask
) <= 8
506 && bitcount(vis
->blue_mask
) <= 8) {
521 * Retrieve the value of the given environment variable and find
522 * the X visual which matches it.
523 * Input: dpy - the display
524 * screen - the screen number
525 * varname - the name of the environment variable
526 * Return: an XVisualInfo pointer to NULL if error.
528 static XVisualInfo
*get_env_visual(Display
*dpy
, int scr
, const char *varname
)
530 char value
[100], type
[100];
531 int depth
, xclass
= -1;
534 if (!getenv( varname
)) {
538 strncpy( value
, getenv(varname
), 100 );
541 sscanf( value
, "%s %d", type
, &depth
);
543 if (strcmp(type
,"TrueColor")==0) xclass
= TrueColor
;
544 else if (strcmp(type
,"DirectColor")==0) xclass
= DirectColor
;
545 else if (strcmp(type
,"PseudoColor")==0) xclass
= PseudoColor
;
546 else if (strcmp(type
,"StaticColor")==0) xclass
= StaticColor
;
547 else if (strcmp(type
,"GrayScale")==0) xclass
= GrayScale
;
548 else if (strcmp(type
,"StaticGray")==0) xclass
= StaticGray
;
550 if (xclass
>-1 && depth
>0) {
551 vis
= get_visual( dpy
, scr
, depth
, xclass
);
557 fprintf( stderr
, "Mesa: GLX unable to find visual class=%s, depth=%d.\n",
565 * Select an X visual which satisfies the RGBA/CI flag and minimum depth.
566 * Input: dpy, screen - X display and screen number
567 * rgba - GL_TRUE = RGBA mode, GL_FALSE = CI mode
568 * min_depth - minimum visual depth
569 * preferred_class - preferred GLX visual class or DONT_CARE
570 * Return: pointer to an XVisualInfo or NULL.
572 static XVisualInfo
*choose_x_visual( Display
*dpy
, int screen
,
573 GLboolean rgba
, int min_depth
,
574 int preferred_class
)
577 int xclass
, visclass
;
581 Atom hp_cr_maps
= XInternAtom(dpy
, "_HP_RGB_SMOOTH_MAP_LIST", True
);
582 /* First see if the MESA_RGB_VISUAL env var is defined */
583 vis
= get_env_visual( dpy
, screen
, "MESA_RGB_VISUAL" );
587 /* Otherwise, search for a suitable visual */
588 if (preferred_class
==DONT_CARE
) {
589 for (xclass
=0;xclass
<6;xclass
++) {
591 case 0: visclass
= TrueColor
; break;
592 case 1: visclass
= DirectColor
; break;
593 case 2: visclass
= PseudoColor
; break;
594 case 3: visclass
= StaticColor
; break;
595 case 4: visclass
= GrayScale
; break;
596 case 5: visclass
= StaticGray
; break;
599 /* start with shallowest */
600 for (depth
=0;depth
<=32;depth
++) {
601 if (visclass
==TrueColor
&& depth
==8 && !hp_cr_maps
) {
602 /* Special case: try to get 8-bit PseudoColor before */
603 /* 8-bit TrueColor */
604 vis
= get_visual( dpy
, screen
, 8, PseudoColor
);
609 vis
= get_visual( dpy
, screen
, depth
, visclass
);
616 /* start with deepest */
617 for (depth
=32;depth
>=min_depth
;depth
--) {
618 if (visclass
==TrueColor
&& depth
==8 && !hp_cr_maps
) {
619 /* Special case: try to get 8-bit PseudoColor before */
620 /* 8-bit TrueColor */
621 vis
= get_visual( dpy
, screen
, 8, PseudoColor
);
626 vis
= get_visual( dpy
, screen
, depth
, visclass
);
635 /* search for a specific visual class */
636 switch (preferred_class
) {
637 case GLX_TRUE_COLOR_EXT
: visclass
= TrueColor
; break;
638 case GLX_DIRECT_COLOR_EXT
: visclass
= DirectColor
; break;
639 case GLX_PSEUDO_COLOR_EXT
: visclass
= PseudoColor
; break;
640 case GLX_STATIC_COLOR_EXT
: visclass
= StaticColor
; break;
641 case GLX_GRAY_SCALE_EXT
: visclass
= GrayScale
; break;
642 case GLX_STATIC_GRAY_EXT
: visclass
= StaticGray
; break;
643 default: return NULL
;
646 /* start with shallowest */
647 for (depth
=0;depth
<=32;depth
++) {
648 vis
= get_visual( dpy
, screen
, depth
, visclass
);
655 /* start with deepest */
656 for (depth
=32;depth
>=min_depth
;depth
--) {
657 vis
= get_visual( dpy
, screen
, depth
, visclass
);
666 /* First see if the MESA_CI_VISUAL env var is defined */
667 vis
= get_env_visual( dpy
, screen
, "MESA_CI_VISUAL" );
671 /* Otherwise, search for a suitable visual, starting with shallowest */
672 if (preferred_class
==DONT_CARE
) {
673 for (xclass
=0;xclass
<4;xclass
++) {
675 case 0: visclass
= PseudoColor
; break;
676 case 1: visclass
= StaticColor
; break;
677 case 2: visclass
= GrayScale
; break;
678 case 3: visclass
= StaticGray
; break;
680 /* try 8-bit up through 16-bit */
681 for (depth
=8;depth
<=16;depth
++) {
682 vis
= get_visual( dpy
, screen
, depth
, visclass
);
687 /* try min_depth up to 8-bit */
688 for (depth
=min_depth
;depth
<8;depth
++) {
689 vis
= get_visual( dpy
, screen
, depth
, visclass
);
697 /* search for a specific visual class */
698 switch (preferred_class
) {
699 case GLX_TRUE_COLOR_EXT
: visclass
= TrueColor
; break;
700 case GLX_DIRECT_COLOR_EXT
: visclass
= DirectColor
; break;
701 case GLX_PSEUDO_COLOR_EXT
: visclass
= PseudoColor
; break;
702 case GLX_STATIC_COLOR_EXT
: visclass
= StaticColor
; break;
703 case GLX_GRAY_SCALE_EXT
: visclass
= GrayScale
; break;
704 case GLX_STATIC_GRAY_EXT
: visclass
= StaticGray
; break;
705 default: return NULL
;
707 /* try 8-bit up through 16-bit */
708 for (depth
=8;depth
<=16;depth
++) {
709 vis
= get_visual( dpy
, screen
, depth
, visclass
);
714 /* try min_depth up to 8-bit */
715 for (depth
=min_depth
;depth
<8;depth
++) {
716 vis
= get_visual( dpy
, screen
, depth
, visclass
);
724 /* didn't find a visual */
731 * Find the deepest X over/underlay visual of at least min_depth.
732 * Input: dpy, screen - X display and screen number
733 * level - the over/underlay level
734 * trans_type - transparent pixel type: GLX_NONE_EXT,
735 * GLX_TRANSPARENT_RGB_EXT, GLX_TRANSPARENT_INDEX_EXT,
737 * trans_value - transparent pixel value or DONT_CARE
738 * min_depth - minimum visual depth
739 * preferred_class - preferred GLX visual class or DONT_CARE
740 * Return: pointer to an XVisualInfo or NULL.
742 static XVisualInfo
*choose_x_overlay_visual( Display
*dpy
, int scr
,
744 int level
, int trans_type
,
747 int preferred_class
)
749 Atom overlayVisualsAtom
;
750 OverlayInfo
*overlay_info
;
751 int numOverlaysPerScreen
;
755 unsigned long sizeData
, bytesLeft
;
757 XVisualInfo
*deepvis
;
760 /*DEBUG int tt, tv; */
762 switch (preferred_class
) {
763 case GLX_TRUE_COLOR_EXT
: preferred_class
= TrueColor
; break;
764 case GLX_DIRECT_COLOR_EXT
: preferred_class
= DirectColor
; break;
765 case GLX_PSEUDO_COLOR_EXT
: preferred_class
= PseudoColor
; break;
766 case GLX_STATIC_COLOR_EXT
: preferred_class
= StaticColor
; break;
767 case GLX_GRAY_SCALE_EXT
: preferred_class
= GrayScale
; break;
768 case GLX_STATIC_GRAY_EXT
: preferred_class
= StaticGray
; break;
769 default: preferred_class
= DONT_CARE
;
773 * The SERVER_OVERLAY_VISUALS property on the root window contains
774 * a list of overlay visuals. Get that list now.
776 overlayVisualsAtom
= XInternAtom(dpy
,"SERVER_OVERLAY_VISUALS", True
);
777 if (overlayVisualsAtom
== (Atom
) None
) {
781 status
= XGetWindowProperty(dpy
, RootWindow( dpy
, scr
),
782 overlayVisualsAtom
, 0L, (long) 10000, False
,
783 overlayVisualsAtom
, &actualType
, &actualFormat
,
784 &sizeData
, &bytesLeft
,
785 (unsigned char **) &overlay_info
);
787 if (status
!= Success
|| actualType
!= overlayVisualsAtom
||
788 actualFormat
!= 32 || sizeData
< 4) {
789 /* something went wrong */
793 /* Search for the deepest overlay which satisifies all criteria. */
797 numOverlaysPerScreen
= (int) (sizeData
/ 4);
798 for (i
=0;i
<numOverlaysPerScreen
;i
++) {
799 XVisualInfo
*vislist
, vistemplate
;
802 ov
= overlay_info
+ i
;
804 if (ov
->layer
!=level
) {
805 /* failed overlay level criteria */
808 if (!(trans_type
==DONT_CARE
809 || (trans_type
==GLX_TRANSPARENT_INDEX_EXT
810 && ov
->transparent_type
>0)
811 || (trans_type
==GLX_NONE_EXT
&& ov
->transparent_type
==0))) {
812 /* failed transparent pixel type criteria */
815 if (trans_value
!=DONT_CARE
&& trans_value
!=ov
->value
) {
816 /* failed transparent pixel value criteria */
820 /* get XVisualInfo and check the depth */
821 vistemplate
.visualid
= ov
->overlay_visual
;
822 vistemplate
.screen
= scr
;
823 vislist
= XGetVisualInfo( dpy
, VisualIDMask
| VisualScreenMask
,
824 &vistemplate
, &count
);
827 /* something went wrong */
830 if (preferred_class
!=DONT_CARE
&& preferred_class
!=vislist
->CLASS
) {
831 /* wrong visual class */
835 /* if RGB was requested, make sure we have True/DirectColor */
836 if (rgbFlag
&& vislist
->CLASS
!= TrueColor
837 && vislist
->CLASS
!= DirectColor
)
840 /* if CI was requested, make sure we have a color indexed visual */
842 && (vislist
->CLASS
== TrueColor
|| vislist
->CLASS
== DirectColor
))
845 if (deepvis
==NULL
|| vislist
->depth
> deepest
) {
846 /* YES! found a satisfactory visual */
850 deepest
= vislist
->depth
;
852 /* DEBUG tt = ov->transparent_type;*/
853 /* DEBUG tv = ov->value; */
859 printf("chose 0x%x: layer=%d depth=%d trans_type=%d trans_value=%d\n",
860 deepvis->visualid, level, deepvis->depth, tt, tv );
869 Fake_glXChooseVisual( Display
*dpy
, int screen
, int *list
)
874 int min_red
=0, min_green
=0, min_blue
=0;
875 GLboolean rgb_flag
= GL_FALSE
;
876 GLboolean alpha_flag
= GL_FALSE
;
877 GLboolean double_flag
= GL_FALSE
;
878 GLboolean stereo_flag
= GL_FALSE
;
879 GLint depth_size
= 0;
880 GLint stencil_size
= 0;
881 GLint accumRedSize
= 0;
882 GLint accumGreenSize
= 0;
883 GLint accumBlueSize
= 0;
884 GLint accumAlphaSize
= 0;
886 int visual_type
= DONT_CARE
;
887 int trans_type
= DONT_CARE
;
888 int trans_value
= DONT_CARE
;
889 GLint caveat
= DONT_CARE
;
895 switch (*parselist
) {
900 case GLX_BUFFER_SIZE
:
902 min_ci
= *parselist
++;
906 level
= *parselist
++;
912 case GLX_DOUBLEBUFFER
:
913 double_flag
= GL_TRUE
;
917 stereo_flag
= GL_TRUE
;
919 case GLX_AUX_BUFFERS
:
926 min_red
= *parselist
++;
930 min_green
= *parselist
++;
934 min_blue
= *parselist
++;
939 GLint size
= *parselist
++;
940 alpha_flag
= size
>0 ? 1 : 0;
945 depth_size
= *parselist
++;
947 case GLX_STENCIL_SIZE
:
949 stencil_size
= *parselist
++;
951 case GLX_ACCUM_RED_SIZE
:
954 GLint size
= *parselist
++;
955 accumRedSize
= MAX2( accumRedSize
, size
);
958 case GLX_ACCUM_GREEN_SIZE
:
961 GLint size
= *parselist
++;
962 accumGreenSize
= MAX2( accumGreenSize
, size
);
965 case GLX_ACCUM_BLUE_SIZE
:
968 GLint size
= *parselist
++;
969 accumBlueSize
= MAX2( accumBlueSize
, size
);
972 case GLX_ACCUM_ALPHA_SIZE
:
975 GLint size
= *parselist
++;
976 accumAlphaSize
= MAX2( accumAlphaSize
, size
);
981 * GLX_EXT_visual_info extension
983 case GLX_X_VISUAL_TYPE_EXT
:
985 visual_type
= *parselist
++;
987 case GLX_TRANSPARENT_TYPE_EXT
:
989 trans_type
= *parselist
++;
991 case GLX_TRANSPARENT_INDEX_VALUE_EXT
:
993 trans_value
= *parselist
++;
995 case GLX_TRANSPARENT_RED_VALUE_EXT
:
996 case GLX_TRANSPARENT_GREEN_VALUE_EXT
:
997 case GLX_TRANSPARENT_BLUE_VALUE_EXT
:
998 case GLX_TRANSPARENT_ALPHA_VALUE_EXT
:
1005 * GLX_EXT_visual_info extension
1007 case GLX_VISUAL_CAVEAT_EXT
:
1009 caveat
= *parselist
++; /* ignored for now */
1015 /* undefined attribute */
1021 * Since we're only simulating the GLX extension this function will never
1022 * find any real GL visuals. Instead, all we can do is try to find an RGB
1023 * or CI visual of appropriate depth. Other requested attributes such as
1024 * double buffering, depth buffer, etc. will be associated with the X
1025 * visual and stored in the VisualTable[].
1028 /* normal color planes */
1030 /* Get an RGB visual */
1031 int min_rgb
= min_red
+ min_green
+ min_blue
;
1032 if (min_rgb
>1 && min_rgb
<8) {
1033 /* a special case to be sure we can get a monochrome visual */
1036 vis
= choose_x_visual( dpy
, screen
, rgb_flag
, min_rgb
, visual_type
);
1039 /* Get a color index visual */
1040 vis
= choose_x_visual( dpy
, screen
, rgb_flag
, min_ci
, visual_type
);
1041 accumRedSize
= accumGreenSize
= accumBlueSize
= accumAlphaSize
= 0;
1045 /* over/underlay planes */
1048 int min_rgb
= min_red
+ min_green
+ min_blue
;
1049 if (min_rgb
>1 && min_rgb
<8) {
1050 /* a special case to be sure we can get a monochrome visual */
1053 vis
= choose_x_overlay_visual( dpy
, screen
, rgb_flag
, level
,
1054 trans_type
, trans_value
, min_rgb
, visual_type
);
1057 /* color index overlay */
1058 vis
= choose_x_overlay_visual( dpy
, screen
, rgb_flag
, level
,
1059 trans_type
, trans_value
, min_ci
, visual_type
);
1064 /* Note: we're not exactly obeying the glXChooseVisual rules here.
1065 * When GLX_DEPTH_SIZE = 1 is specified we're supposed to choose the
1066 * largest depth buffer size, which is 32bits/value. However, we
1067 * return 16 to maintain performance with earlier versions of Mesa.
1069 if (depth_size
== 1)
1070 depth_size
= DEFAULT_SOFTWARE_DEPTH_BITS
;
1071 else if (depth_size
> 24)
1073 else if (depth_size
> 16)
1075 /* we only support one size of stencil and accum buffers. */
1076 if (stencil_size
> 0)
1077 stencil_size
= STENCIL_BITS
;
1078 if (accumRedSize
> 0)
1079 accumRedSize
= ACCUM_BITS
;
1080 if (accumGreenSize
> 0)
1081 accumGreenSize
= ACCUM_BITS
;
1082 if (accumBlueSize
> 0)
1083 accumBlueSize
= ACCUM_BITS
;
1084 if (accumAlphaSize
> 0)
1085 accumAlphaSize
= ACCUM_BITS
;
1086 if (!save_glx_visual( dpy
, vis
, rgb_flag
, alpha_flag
, double_flag
,
1087 stereo_flag
, depth_size
, stencil_size
,
1088 accumRedSize
, accumGreenSize
,
1089 accumBlueSize
, accumAlphaSize
,
1101 Fake_glXCreateContext( Display
*dpy
, XVisualInfo
*visinfo
,
1102 GLXContext share_list
, Bool direct
)
1107 /* deallocate unused windows/buffers */
1108 XMesaGarbageCollect();
1110 glxvis
= find_glx_visual( dpy
, visinfo
);
1112 /* This visual wasn't found with glXChooseVisual() */
1113 glxvis
= create_glx_visual( dpy
, visinfo
);
1115 /* unusable visual */
1120 xmctx
= XMesaCreateContext( glxvis
, (XMesaContext
) share_list
);
1122 /* set the direct/indirect flag */
1123 xmctx
->direct
= direct
;
1125 return (GLXContext
) xmctx
;
1129 static GLXContext MakeCurrent_PrevContext
= 0;
1130 static GLXDrawable MakeCurrent_PrevDrawable
= 0;
1131 static GLXDrawable MakeCurrent_PrevReadable
= 0;
1132 static XMesaBuffer MakeCurrent_PrevDrawBuffer
= 0;
1133 static XMesaBuffer MakeCurrent_PrevReadBuffer
= 0;
1135 /* GLX 1.3 and later */
1137 Fake_glXMakeContextCurrent( Display
*dpy
, GLXDrawable draw
,
1138 GLXDrawable read
, GLXContext ctx
)
1140 if (ctx
&& draw
&& read
) {
1141 XMesaBuffer drawBuffer
, readBuffer
;
1142 XMesaContext xmctx
= (XMesaContext
) ctx
;
1144 /* Find the XMesaBuffer which corresponds to the GLXDrawable 'draw' */
1145 if (ctx
== MakeCurrent_PrevContext
1146 && draw
== MakeCurrent_PrevDrawable
) {
1147 drawBuffer
= MakeCurrent_PrevDrawBuffer
;
1150 drawBuffer
= XMesaFindBuffer( dpy
, draw
);
1153 /* drawable must be a new window! */
1154 drawBuffer
= XMesaCreateWindowBuffer2( xmctx
->xm_visual
, draw
, ctx
);
1156 /* Out of memory, or context/drawable depth mismatch */
1161 /* Find the XMesaBuffer which corresponds to the GLXDrawable 'read' */
1162 if (ctx
== MakeCurrent_PrevContext
1163 && read
== MakeCurrent_PrevReadable
) {
1164 readBuffer
= MakeCurrent_PrevReadBuffer
;
1167 readBuffer
= XMesaFindBuffer( dpy
, read
);
1170 /* drawable must be a new window! */
1171 readBuffer
= XMesaCreateWindowBuffer2( xmctx
->xm_visual
, read
, ctx
);
1173 /* Out of memory, or context/drawable depth mismatch */
1178 MakeCurrent_PrevContext
= ctx
;
1179 MakeCurrent_PrevDrawable
= draw
;
1180 MakeCurrent_PrevReadable
= read
;
1181 MakeCurrent_PrevDrawBuffer
= drawBuffer
;
1182 MakeCurrent_PrevReadBuffer
= readBuffer
;
1184 /* Now make current! */
1185 return (Bool
) XMesaMakeCurrent2((XMesaContext
) ctx
, drawBuffer
, readBuffer
);
1187 else if (!ctx
&& !draw
&& !read
) {
1188 /* release current context w/out assigning new one. */
1189 XMesaMakeCurrent( NULL
, NULL
);
1190 MakeCurrent_PrevContext
= 0;
1191 MakeCurrent_PrevDrawable
= 0;
1192 MakeCurrent_PrevReadable
= 0;
1193 MakeCurrent_PrevDrawBuffer
= 0;
1194 MakeCurrent_PrevReadBuffer
= 0;
1198 /* The args must either all be non-zero or all zero.
1208 Fake_glXMakeCurrent( Display
*dpy
, GLXDrawable drawable
, GLXContext ctx
)
1210 return Fake_glXMakeContextCurrent( dpy
, drawable
, drawable
, ctx
);
1216 Fake_glXCreateGLXPixmap( Display
*dpy
, XVisualInfo
*visinfo
, Pixmap pixmap
)
1221 v
= find_glx_visual( dpy
, visinfo
);
1223 v
= create_glx_visual( dpy
, visinfo
);
1225 /* unusable visual */
1230 b
= XMesaCreatePixmapBuffer( v
, pixmap
, 0 );
1234 return b
->frontbuffer
;
1238 #ifdef GLX_MESA_pixmap_colormap
1241 Fake_glXCreateGLXPixmapMESA( Display
*dpy
, XVisualInfo
*visinfo
,
1242 Pixmap pixmap
, Colormap cmap
)
1247 v
= find_glx_visual( dpy
, visinfo
);
1249 v
= create_glx_visual( dpy
, visinfo
);
1251 /* unusable visual */
1256 b
= XMesaCreatePixmapBuffer( v
, pixmap
, cmap
);
1260 return b
->frontbuffer
;
1267 Fake_glXDestroyGLXPixmap( Display
*dpy
, GLXPixmap pixmap
)
1269 XMesaBuffer b
= XMesaFindBuffer(dpy
, pixmap
);
1271 XMesaDestroyBuffer(b
);
1273 else if (getenv("MESA_DEBUG")) {
1274 fprintf( stderr
, "Mesa: glXDestroyGLXPixmap: invalid pixmap\n");
1280 Fake_glXCopyContext( Display
*dpy
, GLXContext src
, GLXContext dst
,
1281 unsigned long mask
)
1283 XMesaContext xm_src
= (XMesaContext
) src
;
1284 XMesaContext xm_dst
= (XMesaContext
) dst
;
1286 gl_copy_context( xm_src
->gl_ctx
, xm_dst
->gl_ctx
, (GLuint
) mask
);
1292 Fake_glXQueryExtension( Display
*dpy
, int *errorb
, int *event
)
1294 /* Mesa's GLX isn't really an X extension but we try to act like one. */
1302 extern void _kw_ungrab_all( Display
*dpy
);
1303 void _kw_ungrab_all( Display
*dpy
)
1305 XUngrabPointer( dpy
, CurrentTime
);
1306 XUngrabKeyboard( dpy
, CurrentTime
);
1311 Fake_glXDestroyContext( Display
*dpy
, GLXContext ctx
)
1314 MakeCurrent_PrevContext
= 0;
1315 MakeCurrent_PrevDrawable
= 0;
1316 MakeCurrent_PrevReadable
= 0;
1317 MakeCurrent_PrevDrawBuffer
= 0;
1318 MakeCurrent_PrevReadBuffer
= 0;
1319 XMesaDestroyContext( (XMesaContext
) ctx
);
1320 XMesaGarbageCollect();
1326 Fake_glXIsDirect( Display
*dpy
, GLXContext ctx
)
1329 return ((XMesaContext
) ctx
)->direct
;
1335 Fake_glXSwapBuffers( Display
*dpy
, GLXDrawable drawable
)
1337 XMesaBuffer buffer
= XMesaFindBuffer( dpy
, drawable
);
1340 XMesaSwapBuffers(buffer
);
1342 else if (getenv("MESA_DEBUG")) {
1343 fprintf(stderr
, "Mesa Warning: glXSwapBuffers: invalid drawable\n");
1349 Fake_glXCopySubBufferMESA( Display
*dpy
, GLXDrawable drawable
,
1350 int x
, int y
, int width
, int height
)
1352 XMesaBuffer buffer
= XMesaFindBuffer( dpy
, drawable
);
1354 XMesaCopySubBuffer(buffer
, x
, y
, width
, height
);
1356 else if (getenv("MESA_DEBUG")) {
1357 fprintf(stderr
, "Mesa Warning: glXCopySubBufferMESA: invalid drawable\n");
1364 Fake_glXQueryVersion( Display
*dpy
, int *maj
, int *min
)
1367 /* Return GLX version, not Mesa version */
1368 assert(CLIENT_MAJOR_VERSION
== SERVER_MAJOR_VERSION
);
1369 *maj
= CLIENT_MAJOR_VERSION
;
1370 *min
= MIN2( CLIENT_MINOR_VERSION
, SERVER_MINOR_VERSION
);
1377 * Query the GLX attributes of the given XVisualInfo.
1380 Fake_glXGetConfig( Display
*dpy
, XVisualInfo
*visinfo
,
1381 int attrib
, int *value
)
1385 glxvis
= find_glx_visual( dpy
, visinfo
);
1387 /* this visual wasn't obtained with glXChooseVisual */
1388 glxvis
= create_glx_visual( dpy
, visinfo
);
1390 /* this visual can't be used for GL rendering */
1391 if (attrib
==GLX_USE_GL
) {
1392 *value
= (int) False
;
1396 /*fprintf( stderr, "Mesa: Error in glXGetConfig: bad visual\n");*/
1397 return GLX_BAD_VISUAL
;
1404 *value
= (int) True
;
1406 case GLX_BUFFER_SIZE
:
1407 *value
= visinfo
->depth
;
1410 *value
= glxvis
->level
;
1413 if (glxvis
->gl_visual
->RGBAflag
) {
1420 case GLX_DOUBLEBUFFER
:
1421 *value
= (int) glxvis
->gl_visual
->DBflag
;
1424 *value
= (int) glxvis
->gl_visual
->StereoFlag
;
1426 case GLX_AUX_BUFFERS
:
1427 *value
= (int) False
;
1430 *value
= glxvis
->gl_visual
->RedBits
;
1432 case GLX_GREEN_SIZE
:
1433 *value
= glxvis
->gl_visual
->GreenBits
;
1436 *value
= glxvis
->gl_visual
->BlueBits
;
1438 case GLX_ALPHA_SIZE
:
1439 *value
= glxvis
->gl_visual
->AlphaBits
;
1441 case GLX_DEPTH_SIZE
:
1442 *value
= glxvis
->gl_visual
->DepthBits
;
1444 case GLX_STENCIL_SIZE
:
1445 *value
= glxvis
->gl_visual
->StencilBits
;
1447 case GLX_ACCUM_RED_SIZE
:
1448 *value
= glxvis
->gl_visual
->AccumRedBits
;
1450 case GLX_ACCUM_GREEN_SIZE
:
1451 *value
= glxvis
->gl_visual
->AccumGreenBits
;
1453 case GLX_ACCUM_BLUE_SIZE
:
1454 *value
= glxvis
->gl_visual
->AccumBlueBits
;
1456 case GLX_ACCUM_ALPHA_SIZE
:
1457 *value
= glxvis
->gl_visual
->AccumAlphaBits
;
1461 * GLX_EXT_visual_info extension
1463 case GLX_X_VISUAL_TYPE_EXT
:
1464 switch (glxvis
->visinfo
->CLASS
) {
1465 case StaticGray
: *value
= GLX_STATIC_GRAY_EXT
; return 0;
1466 case GrayScale
: *value
= GLX_GRAY_SCALE_EXT
; return 0;
1467 case StaticColor
: *value
= GLX_STATIC_GRAY_EXT
; return 0;
1468 case PseudoColor
: *value
= GLX_PSEUDO_COLOR_EXT
; return 0;
1469 case TrueColor
: *value
= GLX_TRUE_COLOR_EXT
; return 0;
1470 case DirectColor
: *value
= GLX_DIRECT_COLOR_EXT
; return 0;
1473 case GLX_TRANSPARENT_TYPE_EXT
:
1474 if (glxvis
->level
==0) {
1476 *value
= GLX_NONE_EXT
;
1478 else if (glxvis
->level
>0) {
1480 if (glxvis
->gl_visual
->RGBAflag
) {
1481 *value
= GLX_TRANSPARENT_RGB_EXT
;
1484 *value
= GLX_TRANSPARENT_INDEX_EXT
;
1487 else if (glxvis
->level
<0) {
1489 *value
= GLX_NONE_EXT
;
1492 case GLX_TRANSPARENT_INDEX_VALUE_EXT
:
1494 int pixel
= transparent_pixel( glxvis
);
1498 /* else undefined */
1501 case GLX_TRANSPARENT_RED_VALUE_EXT
:
1504 case GLX_TRANSPARENT_GREEN_VALUE_EXT
:
1507 case GLX_TRANSPARENT_BLUE_VALUE_EXT
:
1510 case GLX_TRANSPARENT_ALPHA_VALUE_EXT
:
1515 * GLX_EXT_visual_info extension
1517 case GLX_VISUAL_CAVEAT_EXT
:
1518 /* test for zero, just in case */
1519 if (glxvis
->VisualCaveat
> 0)
1520 *value
= glxvis
->VisualCaveat
;
1522 *value
= GLX_NONE_EXT
;
1529 return GLX_BAD_ATTRIBUTE
;
1536 Fake_glXWaitGL( void )
1538 XMesaContext xmesa
= XMesaGetCurrentContext();
1539 XMesaFlush( xmesa
);
1545 Fake_glXWaitX( void )
1547 XMesaContext xmesa
= XMesaGetCurrentContext();
1548 XMesaFlush( xmesa
);
1553 * Return the extensions string, which is 3Dfx-dependant.
1555 static const char *get_extensions( void )
1558 const char *fx
= getenv("MESA_GLX_FX");
1559 if (fx
&& fx
[0] != 'd') {
1560 return "GLX_MESA_pixmap_colormap GLX_EXT_visual_info GLX_EXT_visual_rating GLX_MESA_release_buffers GLX_MESA_copy_sub_buffer GLX_SGI_video_sync GLX_MESA_set_3dfx_mode GLX_ARB_get_proc_address";
1563 return "GLX_MESA_pixmap_colormap GLX_EXT_visual_info GLX_EXT_visual_rating GLX_MESA_release_buffers GLX_MESA_copy_sub_buffer GLX_SGI_video_sync GLX_ARB_get_proc_address";
1568 /* GLX 1.1 and later */
1570 Fake_glXQueryExtensionsString( Display
*dpy
, int screen
)
1574 return get_extensions();
1579 /* GLX 1.1 and later */
1581 Fake_glXQueryServerString( Display
*dpy
, int screen
, int name
)
1583 static char version
[1000];
1584 sprintf(version
, "%d.%d %s", SERVER_MAJOR_VERSION
, SERVER_MINOR_VERSION
,
1591 case GLX_EXTENSIONS
:
1592 return get_extensions();
1604 /* GLX 1.1 and later */
1606 Fake_glXGetClientString( Display
*dpy
, int name
)
1608 static char version
[1000];
1609 sprintf(version
, "%d.%d %s", CLIENT_MAJOR_VERSION
, CLIENT_MINOR_VERSION
,
1615 case GLX_EXTENSIONS
:
1616 return get_extensions();
1632 static GLXFBConfig
*
1633 Fake_glXChooseFBConfig( Display
*dpy
, int screen
,
1634 const int *attribList
, int *nitems
)
1645 Fake_glXGetFBConfigAttrib( Display
*dpy
, GLXFBConfig config
,
1646 int attribute
, int *value
)
1656 static GLXFBConfig
*
1657 Fake_glXGetFBConfigs( Display
*dpy
, int screen
, int *nelements
)
1666 static XVisualInfo
*
1667 Fake_glXGetVisualFromFBConfig( Display
*dpy
, GLXFBConfig config
)
1676 Fake_glXCreateWindow( Display
*dpy
, GLXFBConfig config
, Window win
,
1677 const int *attribList
)
1688 Fake_glXDestroyWindow( Display
*dpy
, GLXWindow window
)
1697 Fake_glXCreatePixmap( Display
*dpy
, GLXFBConfig config
, Pixmap pixmap
,
1698 const int *attribList
)
1709 Fake_glXDestroyPixmap( Display
*dpy
, GLXPixmap pixmap
)
1718 Fake_glXCreatePbuffer( Display
*dpy
, GLXFBConfig config
,
1719 const int *attribList
)
1729 Fake_glXDestroyPbuffer( Display
*dpy
, GLXPbuffer pbuf
)
1737 Fake_glXQueryDrawable( Display
*dpy
, GLXDrawable draw
, int attribute
,
1738 unsigned int *value
)
1748 Fake_glXCreateNewContext( Display
*dpy
, GLXFBConfig config
,
1749 int renderType
, GLXContext shareList
, Bool direct
)
1761 Fake_glXQueryContext( Display
*dpy
, GLXContext ctx
, int attribute
, int *value
)
1772 Fake_glXSelectEvent( Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
1781 Fake_glXGetSelectedEvent( Display
*dpy
, GLXDrawable drawable
,
1782 unsigned long *mask
)
1792 * Release the depth, stencil, accum buffers attached to a GLXDrawable
1793 * (a window or pixmap) prior to destroying the GLXDrawable.
1796 Fake_glXReleaseBuffersMESA( Display
*dpy
, GLXDrawable d
)
1798 XMesaBuffer b
= XMesaFindBuffer(dpy
, d
);
1800 XMesaDestroyBuffer(b
);
1808 * GLX_MESA_set_3dfx_mode
1811 Fake_glXSet3DfxModeMESA( GLint mode
)
1813 return XMesaSetFXmode( mode
);
1818 * GLX_SGI_video_sync
1821 #ifdef GLX_SGI_video_sync
1824 Fake_glXGetVideoSyncSGI(unsigned int *count
)
1831 Fake_glXWaitVideoSyncSGI(int divisor
, int remainder
, unsigned int *count
)
1840 extern void Fake_glXUseXFont( Font font
, int first
, int count
, int listbase
);
1843 extern struct _glxapi_table
*_mesa_GetGLXDispatchTable(void);
1844 struct _glxapi_table
*_mesa_GetGLXDispatchTable(void)
1846 static struct _glxapi_table glx
;
1848 /* be sure our dispatch table size <= libGL's table */
1850 int size
= sizeof(struct _glxapi_table
) / sizeof(void *);
1852 assert(_glxapi_get_dispatch_table_size() >= size
);
1855 /* initialize the whole table to no-ops */
1856 _glxapi_set_no_op_table(&glx
);
1858 /* now initialize the table with the functions I implement */
1859 glx
.ChooseVisual
= Fake_glXChooseVisual
;
1860 glx
.CopyContext
= Fake_glXCopyContext
;
1861 glx
.CreateContext
= Fake_glXCreateContext
;
1862 glx
.CreateGLXPixmap
= Fake_glXCreateGLXPixmap
;
1863 glx
.DestroyContext
= Fake_glXDestroyContext
;
1864 glx
.DestroyGLXPixmap
= Fake_glXDestroyGLXPixmap
;
1865 glx
.GetConfig
= Fake_glXGetConfig
;
1866 /*glx.GetCurrentContext = Fake_glXGetCurrentContext;*/
1867 /*glx.GetCurrentDrawable = Fake_glXGetCurrentDrawable;*/
1868 glx
.IsDirect
= Fake_glXIsDirect
;
1869 glx
.MakeCurrent
= Fake_glXMakeCurrent
;
1870 glx
.QueryExtension
= Fake_glXQueryExtension
;
1871 glx
.QueryVersion
= Fake_glXQueryVersion
;
1872 glx
.SwapBuffers
= Fake_glXSwapBuffers
;
1873 glx
.UseXFont
= Fake_glXUseXFont
;
1874 glx
.WaitGL
= Fake_glXWaitGL
;
1875 glx
.WaitX
= Fake_glXWaitX
;
1877 #ifdef _GLXAPI_VERSION_1_1
1878 glx
.GetClientString
= Fake_glXGetClientString
;
1879 glx
.QueryExtensionsString
= Fake_glXQueryExtensionsString
;
1880 glx
.QueryServerString
= Fake_glXQueryServerString
;
1883 #ifdef _GLXAPI_VERSION_1_2
1884 /*glx.GetCurrentDisplay = Fake_glXGetCurrentDisplay;*/
1887 #ifdef _GLXAPI_VERSION_1_3
1888 glx
.ChooseFBConfig
= Fake_glXChooseFBConfig
;
1889 glx
.CreateNewContext
= Fake_glXCreateNewContext
;
1890 glx
.CreatePbuffer
= Fake_glXCreatePbuffer
;
1891 glx
.CreatePixmap
= Fake_glXCreatePixmap
;
1892 glx
.CreateWindow
= Fake_glXCreateWindow
;
1893 glx
.DestroyPbuffer
= Fake_glXDestroyPbuffer
;
1894 glx
.DestroyPixmap
= Fake_glXDestroyPixmap
;
1895 glx
.DestroyWindow
= Fake_glXDestroyWindow
;
1896 /*glx.GetCurrentReadDrawable = Fake_glXGetCurrentReadDrawable;*/
1897 glx
.GetFBConfigAttrib
= Fake_glXGetFBConfigAttrib
;
1898 glx
.GetSelectedEvent
= Fake_glXGetSelectedEvent
;
1899 glx
.GetVisualFromFBConfig
= Fake_glXGetVisualFromFBConfig
;
1900 glx
.MakeContextCurrent
= Fake_glXMakeContextCurrent
;
1901 glx
.QueryContext
= Fake_glXQueryContext
;
1902 glx
.QueryDrawable
= Fake_glXQueryDrawable
;
1903 glx
.SelectEvent
= Fake_glXSelectEvent
;
1906 #ifdef _GLXAPI_SGI_video_sync
1907 glx
.GetVideoSyncSGI
= Fake_glXGetVideoSyncSGI
;
1908 glx
.WaitVideoSyncSGI
= Fake_glXWaitVideoSyncSGI
;
1911 #ifdef _GLXAPI_MESA_copy_sub_buffer
1912 glx
.CopySubBufferMESA
= Fake_glXCopySubBufferMESA
;
1915 #ifdef _GLXAPI_MESA_release_buffers
1916 glx
.ReleaseBuffersMESA
= Fake_glXReleaseBuffersMESA
;
1919 #ifdef _GLXAPI_MESA_pixmap_colormap
1920 glx
.CreateGLXPixmapMESA
= Fake_glXCreateGLXPixmapMESA
;
1923 #ifdef _GLXAPI_MESA_set_3dfx_mode
1924 glx
.Set3DfxModeMESA
= Fake_glXSet3DfxModeMESA
;