1 /* $Id: fakeglx.c,v 1.39 2000/11/10 17:23:03 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 (phil@bolthole.com)
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"
57 /* This indicates the client-side GLX API and GLX encoder version. */
58 #define CLIENT_MAJOR_VERSION 1
59 #define CLIENT_MINOR_VERSION 2
61 /* This indicates the server-side GLX decoder version.
62 * GLX 1.3 indicates OpenGL 1.2 support
64 #define SERVER_MAJOR_VERSION 1
65 #define SERVER_MINOR_VERSION 3
67 /* This is appended onto the glXGetClient/ServerString version strings. */
68 #define MESA_GLX_VERSION "Mesa 3.5"
70 /* Who implemented this GLX? */
71 #define VENDOR "Brian Paul"
75 /* Silence compiler warnings */
76 extern void Fake_glXDummyFunc( void );
77 void Fake_glXDummyFunc( void )
91 #define MAX_VISUALS 100
92 static XMesaVisual VisualTable
[MAX_VISUALS
];
93 static int NumVisuals
= 0;
98 * This struct and some code fragments borrowed
99 * from Mark Kilgard's GLUT library.
101 typedef struct _OverlayInfo
{
102 /* Avoid 64-bit portability problems by being careful to use
103 longs due to the way XGetWindowProperty is specified. Note
104 that these parameters are passed as CARD32s over X
106 unsigned long overlay_visual
;
107 long transparent_type
;
114 /* Macro to handle c_class vs class field name in XVisualInfo struct */
115 #if defined(__cplusplus) || defined(c_plusplus)
116 #define CLASS c_class
125 * Test if the given XVisualInfo is usable for Mesa rendering.
127 static GLboolean
is_usable_visual( XVisualInfo
*vinfo
)
129 switch (vinfo
->CLASS
) {
132 /* Any StaticGray/GrayScale visual works in RGB or CI mode */
136 /* Any StaticColor/PseudoColor visual of at least 4 bits */
137 if (vinfo
->depth
>=4) {
145 /* Any depth of TrueColor or DirectColor works in RGB mode */
148 /* This should never happen */
156 * Return the level (overlay, normal, underlay) of a given XVisualInfo.
157 * Input: dpy - the X display
158 * vinfo - the XVisualInfo to test
159 * Return: level of the visual:
161 * >0 = overlay planes
162 * <0 = underlay planes
164 static int level_of_visual( Display
*dpy
, XVisualInfo
*vinfo
)
166 Atom overlayVisualsAtom
;
167 OverlayInfo
*overlay_info
= NULL
;
168 int numOverlaysPerScreen
;
172 unsigned long sizeData
, bytesLeft
;
176 * The SERVER_OVERLAY_VISUALS property on the root window contains
177 * a list of overlay visuals. Get that list now.
179 overlayVisualsAtom
= XInternAtom(dpy
,"SERVER_OVERLAY_VISUALS", True
);
180 if (overlayVisualsAtom
== None
) {
184 status
= XGetWindowProperty(dpy
, RootWindow( dpy
, vinfo
->screen
),
185 overlayVisualsAtom
, 0L, (long) 10000, False
,
186 overlayVisualsAtom
, &actualType
, &actualFormat
,
187 &sizeData
, &bytesLeft
,
188 (unsigned char **) &overlay_info
);
190 if (status
!= Success
|| actualType
!= overlayVisualsAtom
||
191 actualFormat
!= 32 || sizeData
< 4) {
192 /* something went wrong */
193 XFree((void *) overlay_info
);
197 /* search the overlay visual list for the visual ID of interest */
198 numOverlaysPerScreen
= (int) (sizeData
/ 4);
199 for (i
=0;i
<numOverlaysPerScreen
;i
++) {
201 ov
= overlay_info
+ i
;
202 if (ov
->overlay_visual
==vinfo
->visualid
) {
203 /* found the visual */
204 if (/*ov->transparent_type==1 &&*/ ov
->layer
!=0) {
205 int level
= ov
->layer
;
206 XFree((void *) overlay_info
);
210 XFree((void *) overlay_info
);
216 /* The visual ID was not found in the overlay list. */
217 XFree((void *) overlay_info
);
225 * Given an XVisualInfo and RGB, Double, and Depth buffer flags, save the
226 * configuration in our list of GLX visuals.
229 save_glx_visual( Display
*dpy
, XVisualInfo
*vinfo
,
230 GLboolean rgbFlag
, GLboolean alphaFlag
, GLboolean dbFlag
,
231 GLboolean stereoFlag
,
232 GLint depth_size
, GLint stencil_size
,
233 GLint accumRedSize
, GLint accumGreenSize
,
234 GLint accumBlueSize
, GLint accumAlphaSize
,
237 GLboolean ximageFlag
= GL_TRUE
;
240 GLboolean comparePointers
;
243 /* Check if the MESA_BACK_BUFFER env var is set */
244 char *backbuffer
= getenv("MESA_BACK_BUFFER");
246 if (backbuffer
[0]=='p' || backbuffer
[0]=='P') {
247 ximageFlag
= GL_FALSE
;
249 else if (backbuffer
[0]=='x' || backbuffer
[0]=='X') {
250 ximageFlag
= GL_TRUE
;
253 fprintf(stderr
, "Mesa: invalid value for MESA_BACK_BUFFER ");
254 fprintf(stderr
, "environment variable, using an XImage.\n");
259 /* Comparing IDs uses less memory but sometimes fails. */
260 /* XXX revisit this after 3.0 is finished. */
261 if (getenv("MESA_GLX_VISUAL_HACK"))
262 comparePointers
= GL_TRUE
;
264 comparePointers
= GL_FALSE
;
266 /* First check if a matching visual is already in the list */
267 for (i
=0; i
<NumVisuals
; i
++) {
268 XMesaVisual v
= VisualTable
[i
];
269 if (v
->display
== dpy
271 && v
->ximage_flag
== ximageFlag
272 && v
->gl_visual
->RGBAflag
== rgbFlag
273 && v
->gl_visual
->DBflag
== dbFlag
274 && v
->gl_visual
->StereoFlag
== stereoFlag
275 && (v
->gl_visual
->AlphaBits
> 0) == alphaFlag
276 && (v
->gl_visual
->DepthBits
>= depth_size
|| depth_size
== 0)
277 && (v
->gl_visual
->StencilBits
>= stencil_size
|| stencil_size
== 0)
278 && (v
->gl_visual
->AccumRedBits
>= accumRedSize
|| accumRedSize
== 0)
279 && (v
->gl_visual
->AccumGreenBits
>= accumGreenSize
|| accumGreenSize
== 0)
280 && (v
->gl_visual
->AccumBlueBits
>= accumBlueSize
|| accumBlueSize
== 0)
281 && (v
->gl_visual
->AccumAlphaBits
>= accumAlphaSize
|| accumAlphaSize
== 0)) {
282 /* now either compare XVisualInfo pointers or visual IDs */
283 if ((!comparePointers
&& v
->visinfo
->visualid
== vinfo
->visualid
)
284 || (comparePointers
&& v
->vishandle
== vinfo
)) {
290 /* Create a new visual and add it to the list. */
292 if (NumVisuals
>=MAX_VISUALS
) {
293 fprintf( stderr
, "GLX Error: maximum number of visuals exceeded\n");
297 xmvis
= XMesaCreateVisual( dpy
, vinfo
, rgbFlag
, alphaFlag
, dbFlag
,
298 stereoFlag
, ximageFlag
,
299 depth_size
, stencil_size
,
300 accumRedSize
, accumBlueSize
,
301 accumBlueSize
, accumAlphaSize
, 0, level
,
304 VisualTable
[NumVisuals
] = xmvis
;
313 * Create a GLX visual from a regular XVisualInfo.
314 * This is called when Fake GLX is given an XVisualInfo which wasn't
315 * returned by glXChooseVisual. Since this is the first time we're
316 * considering this visual we'll take a guess at reasonable values
317 * for depth buffer size, stencil size, accum size, etc.
318 * This is the best we can do with a client-side emulation of GLX.
321 create_glx_visual( Display
*dpy
, XVisualInfo
*visinfo
)
325 vislevel
= level_of_visual( dpy
, visinfo
);
327 /* Configure this visual as a CI, single-buffered overlay */
328 return save_glx_visual( dpy
, visinfo
,
330 GL_FALSE
, /* alpha */
331 GL_FALSE
, /* double */
332 GL_FALSE
, /* stereo */
334 0, /* stencil bits */
335 0,0,0,0, /* accum bits */
339 else if (is_usable_visual( visinfo
)) {
340 /* Configure this visual as RGB, double-buffered, depth-buffered. */
341 /* This is surely wrong for some people's needs but what else */
342 /* can be done? They should use glXChooseVisual(). */
343 return save_glx_visual( dpy
, visinfo
,
345 GL_FALSE
, /* alpha */
346 GL_TRUE
, /* double */
347 GL_FALSE
, /* stereo */
348 DEFAULT_SOFTWARE_DEPTH_BITS
,
349 8 * sizeof(GLstencil
),
350 8 * sizeof(GLaccum
), /* r */
351 8 * sizeof(GLaccum
), /* g */
352 8 * sizeof(GLaccum
), /* b */
353 8 * sizeof(GLaccum
), /* a */
358 fprintf(stderr
,"Mesa: error in glXCreateContext: bad visual\n");
366 * Find the GLX visual associated with an XVisualInfo.
369 find_glx_visual( Display
*dpy
, XVisualInfo
*vinfo
)
373 /* First try to match pointers */
374 for (i
=0;i
<NumVisuals
;i
++) {
375 if (VisualTable
[i
]->display
==dpy
&& VisualTable
[i
]->vishandle
==vinfo
) {
376 return VisualTable
[i
];
379 /* try to match visual id */
380 for (i
=0;i
<NumVisuals
;i
++) {
381 if (VisualTable
[i
]->display
==dpy
382 && VisualTable
[i
]->visinfo
->visualid
== vinfo
->visualid
) {
383 return VisualTable
[i
];
392 * Return the transparent pixel value for a GLX visual.
393 * Input: glxvis - the glx_visual
394 * Return: a pixel value or -1 if no transparent pixel
396 static int transparent_pixel( XMesaVisual glxvis
)
398 Display
*dpy
= glxvis
->display
;
399 XVisualInfo
*vinfo
= glxvis
->visinfo
;
400 Atom overlayVisualsAtom
;
401 OverlayInfo
*overlay_info
= NULL
;
402 int numOverlaysPerScreen
;
406 unsigned long sizeData
, bytesLeft
;
410 * The SERVER_OVERLAY_VISUALS property on the root window contains
411 * a list of overlay visuals. Get that list now.
413 overlayVisualsAtom
= XInternAtom(dpy
,"SERVER_OVERLAY_VISUALS", True
);
414 if (overlayVisualsAtom
== None
) {
418 status
= XGetWindowProperty(dpy
, RootWindow( dpy
, vinfo
->screen
),
419 overlayVisualsAtom
, 0L, (long) 10000, False
,
420 overlayVisualsAtom
, &actualType
, &actualFormat
,
421 &sizeData
, &bytesLeft
,
422 (unsigned char **) &overlay_info
);
424 if (status
!= Success
|| actualType
!= overlayVisualsAtom
||
425 actualFormat
!= 32 || sizeData
< 4) {
426 /* something went wrong */
427 XFree((void *) overlay_info
);
431 /* search the overlay visual list for the visual ID of interest */
432 numOverlaysPerScreen
= (int) (sizeData
/ 4);
433 for (i
=0;i
<numOverlaysPerScreen
;i
++) {
435 ov
= overlay_info
+ i
;
436 if (ov
->overlay_visual
==vinfo
->visualid
) {
438 if (ov
->transparent_type
==0) {
439 /* type 0 indicates no transparency */
440 XFree((void *) overlay_info
);
444 /* ov->value is the transparent pixel */
445 XFree((void *) overlay_info
);
451 /* The visual ID was not found in the overlay list. */
452 XFree((void *) overlay_info
);
459 * Try to get an X visual which matches the given arguments.
461 static XVisualInfo
*get_visual( Display
*dpy
, int scr
,
462 unsigned int depth
, int xclass
)
464 XVisualInfo temp
, *vis
;
467 unsigned int default_depth
;
470 mask
= VisualScreenMask
| VisualDepthMask
| VisualClassMask
;
475 default_depth
= DefaultDepth(dpy
,scr
);
476 default_class
= DefaultVisual(dpy
,scr
)->CLASS
;
478 if (depth
==default_depth
&& xclass
==default_class
) {
479 /* try to get root window's visual */
480 temp
.visualid
= DefaultVisual(dpy
,scr
)->visualid
;
481 mask
|= VisualIDMask
;
484 vis
= XGetVisualInfo( dpy
, mask
, &temp
, &n
);
486 /* In case bits/pixel > 24, make sure color channels are still <=8 bits.
487 * An SGI Infinite Reality system, for example, can have 30bpp pixels:
488 * 10 bits per color channel. Mesa's limited to a max of 8 bits/channel.
490 if (vis
&& depth
> 24 && (xclass
==TrueColor
|| xclass
==DirectColor
)) {
491 if (_mesa_bitcount((GLuint
) vis
->red_mask
) <= 8 &&
492 _mesa_bitcount((GLuint
) vis
->green_mask
) <= 8 &&
493 _mesa_bitcount((GLuint
) vis
->blue_mask
) <= 8) {
508 * Retrieve the value of the given environment variable and find
509 * the X visual which matches it.
510 * Input: dpy - the display
511 * screen - the screen number
512 * varname - the name of the environment variable
513 * Return: an XVisualInfo pointer to NULL if error.
515 static XVisualInfo
*get_env_visual(Display
*dpy
, int scr
, const char *varname
)
517 char value
[100], type
[100];
518 int depth
, xclass
= -1;
521 if (!getenv( varname
)) {
525 strncpy( value
, getenv(varname
), 100 );
528 sscanf( value
, "%s %d", type
, &depth
);
530 if (strcmp(type
,"TrueColor")==0) xclass
= TrueColor
;
531 else if (strcmp(type
,"DirectColor")==0) xclass
= DirectColor
;
532 else if (strcmp(type
,"PseudoColor")==0) xclass
= PseudoColor
;
533 else if (strcmp(type
,"StaticColor")==0) xclass
= StaticColor
;
534 else if (strcmp(type
,"GrayScale")==0) xclass
= GrayScale
;
535 else if (strcmp(type
,"StaticGray")==0) xclass
= StaticGray
;
537 if (xclass
>-1 && depth
>0) {
538 vis
= get_visual( dpy
, scr
, depth
, xclass
);
544 fprintf( stderr
, "Mesa: GLX unable to find visual class=%s, depth=%d.\n",
552 * Select an X visual which satisfies the RGBA/CI flag and minimum depth.
553 * Input: dpy, screen - X display and screen number
554 * rgba - GL_TRUE = RGBA mode, GL_FALSE = CI mode
555 * min_depth - minimum visual depth
556 * preferred_class - preferred GLX visual class or DONT_CARE
557 * Return: pointer to an XVisualInfo or NULL.
559 static XVisualInfo
*choose_x_visual( Display
*dpy
, int screen
,
560 GLboolean rgba
, int min_depth
,
561 int preferred_class
)
564 int xclass
, visclass
= 0;
568 Atom hp_cr_maps
= XInternAtom(dpy
, "_HP_RGB_SMOOTH_MAP_LIST", True
);
569 /* First see if the MESA_RGB_VISUAL env var is defined */
570 vis
= get_env_visual( dpy
, screen
, "MESA_RGB_VISUAL" );
574 /* Otherwise, search for a suitable visual */
575 if (preferred_class
==DONT_CARE
) {
576 for (xclass
=0;xclass
<6;xclass
++) {
578 case 0: visclass
= TrueColor
; break;
579 case 1: visclass
= DirectColor
; break;
580 case 2: visclass
= PseudoColor
; break;
581 case 3: visclass
= StaticColor
; break;
582 case 4: visclass
= GrayScale
; break;
583 case 5: visclass
= StaticGray
; break;
586 /* start with shallowest */
587 for (depth
=0;depth
<=32;depth
++) {
588 if (visclass
==TrueColor
&& depth
==8 && !hp_cr_maps
) {
589 /* Special case: try to get 8-bit PseudoColor before */
590 /* 8-bit TrueColor */
591 vis
= get_visual( dpy
, screen
, 8, PseudoColor
);
596 vis
= get_visual( dpy
, screen
, depth
, visclass
);
603 /* start with deepest */
604 for (depth
=32;depth
>=min_depth
;depth
--) {
605 if (visclass
==TrueColor
&& depth
==8 && !hp_cr_maps
) {
606 /* Special case: try to get 8-bit PseudoColor before */
607 /* 8-bit TrueColor */
608 vis
= get_visual( dpy
, screen
, 8, PseudoColor
);
613 vis
= get_visual( dpy
, screen
, depth
, visclass
);
622 /* search for a specific visual class */
623 switch (preferred_class
) {
624 case GLX_TRUE_COLOR_EXT
: visclass
= TrueColor
; break;
625 case GLX_DIRECT_COLOR_EXT
: visclass
= DirectColor
; break;
626 case GLX_PSEUDO_COLOR_EXT
: visclass
= PseudoColor
; break;
627 case GLX_STATIC_COLOR_EXT
: visclass
= StaticColor
; break;
628 case GLX_GRAY_SCALE_EXT
: visclass
= GrayScale
; break;
629 case GLX_STATIC_GRAY_EXT
: visclass
= StaticGray
; break;
630 default: return NULL
;
633 /* start with shallowest */
634 for (depth
=0;depth
<=32;depth
++) {
635 vis
= get_visual( dpy
, screen
, depth
, visclass
);
642 /* start with deepest */
643 for (depth
=32;depth
>=min_depth
;depth
--) {
644 vis
= get_visual( dpy
, screen
, depth
, visclass
);
653 /* First see if the MESA_CI_VISUAL env var is defined */
654 vis
= get_env_visual( dpy
, screen
, "MESA_CI_VISUAL" );
658 /* Otherwise, search for a suitable visual, starting with shallowest */
659 if (preferred_class
==DONT_CARE
) {
660 for (xclass
=0;xclass
<4;xclass
++) {
662 case 0: visclass
= PseudoColor
; break;
663 case 1: visclass
= StaticColor
; break;
664 case 2: visclass
= GrayScale
; break;
665 case 3: visclass
= StaticGray
; break;
667 /* try 8-bit up through 16-bit */
668 for (depth
=8;depth
<=16;depth
++) {
669 vis
= get_visual( dpy
, screen
, depth
, visclass
);
674 /* try min_depth up to 8-bit */
675 for (depth
=min_depth
;depth
<8;depth
++) {
676 vis
= get_visual( dpy
, screen
, depth
, visclass
);
684 /* search for a specific visual class */
685 switch (preferred_class
) {
686 case GLX_TRUE_COLOR_EXT
: visclass
= TrueColor
; break;
687 case GLX_DIRECT_COLOR_EXT
: visclass
= DirectColor
; break;
688 case GLX_PSEUDO_COLOR_EXT
: visclass
= PseudoColor
; break;
689 case GLX_STATIC_COLOR_EXT
: visclass
= StaticColor
; break;
690 case GLX_GRAY_SCALE_EXT
: visclass
= GrayScale
; break;
691 case GLX_STATIC_GRAY_EXT
: visclass
= StaticGray
; break;
692 default: return NULL
;
694 /* try 8-bit up through 16-bit */
695 for (depth
=8;depth
<=16;depth
++) {
696 vis
= get_visual( dpy
, screen
, depth
, visclass
);
701 /* try min_depth up to 8-bit */
702 for (depth
=min_depth
;depth
<8;depth
++) {
703 vis
= get_visual( dpy
, screen
, depth
, visclass
);
711 /* didn't find a visual */
718 * Find the deepest X over/underlay visual of at least min_depth.
719 * Input: dpy, screen - X display and screen number
720 * level - the over/underlay level
721 * trans_type - transparent pixel type: GLX_NONE_EXT,
722 * GLX_TRANSPARENT_RGB_EXT, GLX_TRANSPARENT_INDEX_EXT,
724 * trans_value - transparent pixel value or DONT_CARE
725 * min_depth - minimum visual depth
726 * preferred_class - preferred GLX visual class or DONT_CARE
727 * Return: pointer to an XVisualInfo or NULL.
729 static XVisualInfo
*choose_x_overlay_visual( Display
*dpy
, int scr
,
731 int level
, int trans_type
,
734 int preferred_class
)
736 Atom overlayVisualsAtom
;
737 OverlayInfo
*overlay_info
;
738 int numOverlaysPerScreen
;
742 unsigned long sizeData
, bytesLeft
;
744 XVisualInfo
*deepvis
;
747 /*DEBUG int tt, tv; */
749 switch (preferred_class
) {
750 case GLX_TRUE_COLOR_EXT
: preferred_class
= TrueColor
; break;
751 case GLX_DIRECT_COLOR_EXT
: preferred_class
= DirectColor
; break;
752 case GLX_PSEUDO_COLOR_EXT
: preferred_class
= PseudoColor
; break;
753 case GLX_STATIC_COLOR_EXT
: preferred_class
= StaticColor
; break;
754 case GLX_GRAY_SCALE_EXT
: preferred_class
= GrayScale
; break;
755 case GLX_STATIC_GRAY_EXT
: preferred_class
= StaticGray
; break;
756 default: preferred_class
= DONT_CARE
;
760 * The SERVER_OVERLAY_VISUALS property on the root window contains
761 * a list of overlay visuals. Get that list now.
763 overlayVisualsAtom
= XInternAtom(dpy
,"SERVER_OVERLAY_VISUALS", True
);
764 if (overlayVisualsAtom
== (Atom
) None
) {
768 status
= XGetWindowProperty(dpy
, RootWindow( dpy
, scr
),
769 overlayVisualsAtom
, 0L, (long) 10000, False
,
770 overlayVisualsAtom
, &actualType
, &actualFormat
,
771 &sizeData
, &bytesLeft
,
772 (unsigned char **) &overlay_info
);
774 if (status
!= Success
|| actualType
!= overlayVisualsAtom
||
775 actualFormat
!= 32 || sizeData
< 4) {
776 /* something went wrong */
780 /* Search for the deepest overlay which satisifies all criteria. */
784 numOverlaysPerScreen
= (int) (sizeData
/ 4);
785 for (i
=0;i
<numOverlaysPerScreen
;i
++) {
786 XVisualInfo
*vislist
, vistemplate
;
789 ov
= overlay_info
+ i
;
791 if (ov
->layer
!=level
) {
792 /* failed overlay level criteria */
795 if (!(trans_type
==DONT_CARE
796 || (trans_type
==GLX_TRANSPARENT_INDEX_EXT
797 && ov
->transparent_type
>0)
798 || (trans_type
==GLX_NONE_EXT
&& ov
->transparent_type
==0))) {
799 /* failed transparent pixel type criteria */
802 if (trans_value
!=DONT_CARE
&& trans_value
!=ov
->value
) {
803 /* failed transparent pixel value criteria */
807 /* get XVisualInfo and check the depth */
808 vistemplate
.visualid
= ov
->overlay_visual
;
809 vistemplate
.screen
= scr
;
810 vislist
= XGetVisualInfo( dpy
, VisualIDMask
| VisualScreenMask
,
811 &vistemplate
, &count
);
814 /* something went wrong */
817 if (preferred_class
!=DONT_CARE
&& preferred_class
!=vislist
->CLASS
) {
818 /* wrong visual class */
822 /* if RGB was requested, make sure we have True/DirectColor */
823 if (rgbFlag
&& vislist
->CLASS
!= TrueColor
824 && vislist
->CLASS
!= DirectColor
)
827 /* if CI was requested, make sure we have a color indexed visual */
829 && (vislist
->CLASS
== TrueColor
|| vislist
->CLASS
== DirectColor
))
832 if (deepvis
==NULL
|| vislist
->depth
> deepest
) {
833 /* YES! found a satisfactory visual */
837 deepest
= vislist
->depth
;
839 /* DEBUG tt = ov->transparent_type;*/
840 /* DEBUG tv = ov->value; */
846 printf("chose 0x%x: layer=%d depth=%d trans_type=%d trans_value=%d\n",
847 deepvis->visualid, level, deepvis->depth, tt, tv );
856 Fake_glXChooseVisual( Display
*dpy
, int screen
, int *list
)
861 int min_red
=0, min_green
=0, min_blue
=0;
862 GLboolean rgb_flag
= GL_FALSE
;
863 GLboolean alpha_flag
= GL_FALSE
;
864 GLboolean double_flag
= GL_FALSE
;
865 GLboolean stereo_flag
= GL_FALSE
;
866 GLint depth_size
= 0;
867 GLint stencil_size
= 0;
868 GLint accumRedSize
= 0;
869 GLint accumGreenSize
= 0;
870 GLint accumBlueSize
= 0;
871 GLint accumAlphaSize
= 0;
873 int visual_type
= DONT_CARE
;
874 int trans_type
= DONT_CARE
;
875 int trans_value
= DONT_CARE
;
876 GLint caveat
= DONT_CARE
;
882 switch (*parselist
) {
887 case GLX_BUFFER_SIZE
:
889 min_ci
= *parselist
++;
893 level
= *parselist
++;
899 case GLX_DOUBLEBUFFER
:
900 double_flag
= GL_TRUE
;
904 stereo_flag
= GL_TRUE
;
906 case GLX_AUX_BUFFERS
:
913 min_red
= *parselist
++;
917 min_green
= *parselist
++;
921 min_blue
= *parselist
++;
926 GLint size
= *parselist
++;
927 alpha_flag
= size
>0 ? 1 : 0;
932 depth_size
= *parselist
++;
934 case GLX_STENCIL_SIZE
:
936 stencil_size
= *parselist
++;
938 case GLX_ACCUM_RED_SIZE
:
941 GLint size
= *parselist
++;
942 accumRedSize
= MAX2( accumRedSize
, size
);
945 case GLX_ACCUM_GREEN_SIZE
:
948 GLint size
= *parselist
++;
949 accumGreenSize
= MAX2( accumGreenSize
, size
);
952 case GLX_ACCUM_BLUE_SIZE
:
955 GLint size
= *parselist
++;
956 accumBlueSize
= MAX2( accumBlueSize
, size
);
959 case GLX_ACCUM_ALPHA_SIZE
:
962 GLint size
= *parselist
++;
963 accumAlphaSize
= MAX2( accumAlphaSize
, size
);
968 * GLX_EXT_visual_info extension
970 case GLX_X_VISUAL_TYPE_EXT
:
972 visual_type
= *parselist
++;
974 case GLX_TRANSPARENT_TYPE_EXT
:
976 trans_type
= *parselist
++;
978 case GLX_TRANSPARENT_INDEX_VALUE_EXT
:
980 trans_value
= *parselist
++;
982 case GLX_TRANSPARENT_RED_VALUE_EXT
:
983 case GLX_TRANSPARENT_GREEN_VALUE_EXT
:
984 case GLX_TRANSPARENT_BLUE_VALUE_EXT
:
985 case GLX_TRANSPARENT_ALPHA_VALUE_EXT
:
992 * GLX_EXT_visual_info extension
994 case GLX_VISUAL_CAVEAT_EXT
:
996 caveat
= *parselist
++; /* ignored for now */
1002 /* undefined attribute */
1008 * Since we're only simulating the GLX extension this function will never
1009 * find any real GL visuals. Instead, all we can do is try to find an RGB
1010 * or CI visual of appropriate depth. Other requested attributes such as
1011 * double buffering, depth buffer, etc. will be associated with the X
1012 * visual and stored in the VisualTable[].
1015 /* normal color planes */
1017 /* Get an RGB visual */
1018 int min_rgb
= min_red
+ min_green
+ min_blue
;
1019 if (min_rgb
>1 && min_rgb
<8) {
1020 /* a special case to be sure we can get a monochrome visual */
1023 vis
= choose_x_visual( dpy
, screen
, rgb_flag
, min_rgb
, visual_type
);
1026 /* Get a color index visual */
1027 vis
= choose_x_visual( dpy
, screen
, rgb_flag
, min_ci
, visual_type
);
1028 accumRedSize
= accumGreenSize
= accumBlueSize
= accumAlphaSize
= 0;
1032 /* over/underlay planes */
1035 int min_rgb
= min_red
+ min_green
+ min_blue
;
1036 if (min_rgb
>1 && min_rgb
<8) {
1037 /* a special case to be sure we can get a monochrome visual */
1040 vis
= choose_x_overlay_visual( dpy
, screen
, rgb_flag
, level
,
1041 trans_type
, trans_value
, min_rgb
, visual_type
);
1044 /* color index overlay */
1045 vis
= choose_x_overlay_visual( dpy
, screen
, rgb_flag
, level
,
1046 trans_type
, trans_value
, min_ci
, visual_type
);
1051 /* Note: we're not exactly obeying the glXChooseVisual rules here.
1052 * When GLX_DEPTH_SIZE = 1 is specified we're supposed to choose the
1053 * largest depth buffer size, which is 32bits/value. Instead, we
1054 * return 16 to maintain performance with earlier versions of Mesa.
1056 if (depth_size
> 24)
1057 depth_size
= 31; /* 32 causes int overflow problems */
1058 else if (depth_size
> 16)
1060 else if (depth_size
> 0)
1061 depth_size
= DEFAULT_SOFTWARE_DEPTH_BITS
; /*16*/
1063 /* we only support one size of stencil and accum buffers. */
1064 if (stencil_size
> 0)
1065 stencil_size
= STENCIL_BITS
;
1066 if (accumRedSize
> 0)
1067 accumRedSize
= ACCUM_BITS
;
1068 if (accumGreenSize
> 0)
1069 accumGreenSize
= ACCUM_BITS
;
1070 if (accumBlueSize
> 0)
1071 accumBlueSize
= ACCUM_BITS
;
1072 if (accumAlphaSize
> 0)
1073 accumAlphaSize
= ACCUM_BITS
;
1074 if (!save_glx_visual( dpy
, vis
, rgb_flag
, alpha_flag
, double_flag
,
1075 stereo_flag
, depth_size
, stencil_size
,
1076 accumRedSize
, accumGreenSize
,
1077 accumBlueSize
, accumAlphaSize
,
1089 Fake_glXCreateContext( Display
*dpy
, XVisualInfo
*visinfo
,
1090 GLXContext share_list
, Bool direct
)
1095 /* deallocate unused windows/buffers */
1096 XMesaGarbageCollect();
1098 glxvis
= find_glx_visual( dpy
, visinfo
);
1100 /* This visual wasn't found with glXChooseVisual() */
1101 glxvis
= create_glx_visual( dpy
, visinfo
);
1103 /* unusable visual */
1108 xmctx
= XMesaCreateContext( glxvis
, (XMesaContext
) share_list
);
1110 /* set the direct/indirect flag */
1111 xmctx
->direct
= direct
;
1113 return (GLXContext
) xmctx
;
1117 static GLXContext MakeCurrent_PrevContext
= 0;
1118 static GLXDrawable MakeCurrent_PrevDrawable
= 0;
1119 static GLXDrawable MakeCurrent_PrevReadable
= 0;
1120 static XMesaBuffer MakeCurrent_PrevDrawBuffer
= 0;
1121 static XMesaBuffer MakeCurrent_PrevReadBuffer
= 0;
1123 /* GLX 1.3 and later */
1125 Fake_glXMakeContextCurrent( Display
*dpy
, GLXDrawable draw
,
1126 GLXDrawable read
, GLXContext ctx
)
1128 if (ctx
&& draw
&& read
) {
1129 XMesaBuffer drawBuffer
, readBuffer
;
1130 XMesaContext xmctx
= (XMesaContext
) ctx
;
1132 /* Find the XMesaBuffer which corresponds to the GLXDrawable 'draw' */
1133 if (ctx
== MakeCurrent_PrevContext
1134 && draw
== MakeCurrent_PrevDrawable
) {
1135 drawBuffer
= MakeCurrent_PrevDrawBuffer
;
1138 drawBuffer
= XMesaFindBuffer( dpy
, draw
);
1141 /* drawable must be a new window! */
1142 drawBuffer
= XMesaCreateWindowBuffer2( xmctx
->xm_visual
, draw
, (XMesaContext
) ctx
);
1144 /* Out of memory, or context/drawable depth mismatch */
1149 /* Find the XMesaBuffer which corresponds to the GLXDrawable 'read' */
1150 if (ctx
== MakeCurrent_PrevContext
1151 && read
== MakeCurrent_PrevReadable
) {
1152 readBuffer
= MakeCurrent_PrevReadBuffer
;
1155 readBuffer
= XMesaFindBuffer( dpy
, read
);
1158 /* drawable must be a new window! */
1159 readBuffer
= XMesaCreateWindowBuffer2( xmctx
->xm_visual
, read
, (XMesaContext
) ctx
);
1161 /* Out of memory, or context/drawable depth mismatch */
1166 MakeCurrent_PrevContext
= ctx
;
1167 MakeCurrent_PrevDrawable
= draw
;
1168 MakeCurrent_PrevReadable
= read
;
1169 MakeCurrent_PrevDrawBuffer
= drawBuffer
;
1170 MakeCurrent_PrevReadBuffer
= readBuffer
;
1172 /* Now make current! */
1173 return (Bool
) XMesaMakeCurrent2((XMesaContext
) ctx
, drawBuffer
, readBuffer
);
1175 else if (!ctx
&& !draw
&& !read
) {
1176 /* release current context w/out assigning new one. */
1177 XMesaMakeCurrent( NULL
, NULL
);
1178 MakeCurrent_PrevContext
= 0;
1179 MakeCurrent_PrevDrawable
= 0;
1180 MakeCurrent_PrevReadable
= 0;
1181 MakeCurrent_PrevDrawBuffer
= 0;
1182 MakeCurrent_PrevReadBuffer
= 0;
1186 /* The args must either all be non-zero or all zero.
1196 Fake_glXMakeCurrent( Display
*dpy
, GLXDrawable drawable
, GLXContext ctx
)
1198 return Fake_glXMakeContextCurrent( dpy
, drawable
, drawable
, ctx
);
1204 Fake_glXCreateGLXPixmap( Display
*dpy
, XVisualInfo
*visinfo
, Pixmap pixmap
)
1209 v
= find_glx_visual( dpy
, visinfo
);
1211 v
= create_glx_visual( dpy
, visinfo
);
1213 /* unusable visual */
1218 b
= XMesaCreatePixmapBuffer( v
, pixmap
, 0 );
1222 return b
->frontbuffer
;
1226 #ifdef GLX_MESA_pixmap_colormap
1228 Fake_glXCreateGLXPixmapMESA( Display
*dpy
, XVisualInfo
*visinfo
,
1229 Pixmap pixmap
, Colormap cmap
)
1234 v
= find_glx_visual( dpy
, visinfo
);
1236 v
= create_glx_visual( dpy
, visinfo
);
1238 /* unusable visual */
1243 b
= XMesaCreatePixmapBuffer( v
, pixmap
, cmap
);
1247 return b
->frontbuffer
;
1253 Fake_glXDestroyGLXPixmap( Display
*dpy
, GLXPixmap pixmap
)
1255 XMesaBuffer b
= XMesaFindBuffer(dpy
, pixmap
);
1257 XMesaDestroyBuffer(b
);
1259 else if (getenv("MESA_DEBUG")) {
1260 fprintf( stderr
, "Mesa: glXDestroyGLXPixmap: invalid pixmap\n");
1267 Fake_glXCopyContext( Display
*dpy
, GLXContext src
, GLXContext dst
,
1268 unsigned long mask
)
1270 XMesaContext xm_src
= (XMesaContext
) src
;
1271 XMesaContext xm_dst
= (XMesaContext
) dst
;
1273 _mesa_copy_context( xm_src
->gl_ctx
, xm_dst
->gl_ctx
, (GLuint
) mask
);
1279 Fake_glXQueryExtension( Display
*dpy
, int *errorb
, int *event
)
1281 /* Mesa's GLX isn't really an X extension but we try to act like one. */
1289 extern void _kw_ungrab_all( Display
*dpy
);
1290 void _kw_ungrab_all( Display
*dpy
)
1292 XUngrabPointer( dpy
, CurrentTime
);
1293 XUngrabKeyboard( dpy
, CurrentTime
);
1298 Fake_glXDestroyContext( Display
*dpy
, GLXContext ctx
)
1301 MakeCurrent_PrevContext
= 0;
1302 MakeCurrent_PrevDrawable
= 0;
1303 MakeCurrent_PrevReadable
= 0;
1304 MakeCurrent_PrevDrawBuffer
= 0;
1305 MakeCurrent_PrevReadBuffer
= 0;
1306 XMesaDestroyContext( (XMesaContext
) ctx
);
1307 XMesaGarbageCollect();
1313 Fake_glXIsDirect( Display
*dpy
, GLXContext ctx
)
1316 return ((XMesaContext
) ctx
)->direct
;
1322 Fake_glXSwapBuffers( Display
*dpy
, GLXDrawable drawable
)
1324 XMesaBuffer buffer
= XMesaFindBuffer( dpy
, drawable
);
1327 XMesaSwapBuffers(buffer
);
1329 else if (getenv("MESA_DEBUG")) {
1330 fprintf(stderr
, "Mesa Warning: glXSwapBuffers: invalid drawable\n");
1336 #ifdef GLX_MESA_copy_sub_buffer
1338 Fake_glXCopySubBufferMESA( Display
*dpy
, GLXDrawable drawable
,
1339 int x
, int y
, int width
, int height
)
1341 XMesaBuffer buffer
= XMesaFindBuffer( dpy
, drawable
);
1343 XMesaCopySubBuffer(buffer
, x
, y
, width
, height
);
1345 else if (getenv("MESA_DEBUG")) {
1346 fprintf(stderr
, "Mesa Warning: glXCopySubBufferMESA: invalid drawable\n");
1354 Fake_glXQueryVersion( Display
*dpy
, int *maj
, int *min
)
1357 /* Return GLX version, not Mesa version */
1358 assert(CLIENT_MAJOR_VERSION
== SERVER_MAJOR_VERSION
);
1359 *maj
= CLIENT_MAJOR_VERSION
;
1360 *min
= MIN2( CLIENT_MINOR_VERSION
, SERVER_MINOR_VERSION
);
1367 * Query the GLX attributes of the given XVisualInfo.
1370 Fake_glXGetConfig( Display
*dpy
, XVisualInfo
*visinfo
,
1371 int attrib
, int *value
)
1375 glxvis
= find_glx_visual( dpy
, visinfo
);
1377 /* this visual wasn't obtained with glXChooseVisual */
1378 glxvis
= create_glx_visual( dpy
, visinfo
);
1380 /* this visual can't be used for GL rendering */
1381 if (attrib
==GLX_USE_GL
) {
1382 *value
= (int) False
;
1386 /*fprintf( stderr, "Mesa: Error in glXGetConfig: bad visual\n");*/
1387 return GLX_BAD_VISUAL
;
1394 *value
= (int) True
;
1396 case GLX_BUFFER_SIZE
:
1397 *value
= visinfo
->depth
;
1400 *value
= glxvis
->level
;
1403 if (glxvis
->gl_visual
->RGBAflag
) {
1410 case GLX_DOUBLEBUFFER
:
1411 *value
= (int) glxvis
->gl_visual
->DBflag
;
1414 *value
= (int) glxvis
->gl_visual
->StereoFlag
;
1416 case GLX_AUX_BUFFERS
:
1417 *value
= (int) False
;
1420 *value
= glxvis
->gl_visual
->RedBits
;
1422 case GLX_GREEN_SIZE
:
1423 *value
= glxvis
->gl_visual
->GreenBits
;
1426 *value
= glxvis
->gl_visual
->BlueBits
;
1428 case GLX_ALPHA_SIZE
:
1429 *value
= glxvis
->gl_visual
->AlphaBits
;
1431 case GLX_DEPTH_SIZE
:
1432 *value
= glxvis
->gl_visual
->DepthBits
;
1434 case GLX_STENCIL_SIZE
:
1435 *value
= glxvis
->gl_visual
->StencilBits
;
1437 case GLX_ACCUM_RED_SIZE
:
1438 *value
= glxvis
->gl_visual
->AccumRedBits
;
1440 case GLX_ACCUM_GREEN_SIZE
:
1441 *value
= glxvis
->gl_visual
->AccumGreenBits
;
1443 case GLX_ACCUM_BLUE_SIZE
:
1444 *value
= glxvis
->gl_visual
->AccumBlueBits
;
1446 case GLX_ACCUM_ALPHA_SIZE
:
1447 *value
= glxvis
->gl_visual
->AccumAlphaBits
;
1451 * GLX_EXT_visual_info extension
1453 case GLX_X_VISUAL_TYPE_EXT
:
1454 switch (glxvis
->visinfo
->CLASS
) {
1455 case StaticGray
: *value
= GLX_STATIC_GRAY_EXT
; return 0;
1456 case GrayScale
: *value
= GLX_GRAY_SCALE_EXT
; return 0;
1457 case StaticColor
: *value
= GLX_STATIC_GRAY_EXT
; return 0;
1458 case PseudoColor
: *value
= GLX_PSEUDO_COLOR_EXT
; return 0;
1459 case TrueColor
: *value
= GLX_TRUE_COLOR_EXT
; return 0;
1460 case DirectColor
: *value
= GLX_DIRECT_COLOR_EXT
; return 0;
1463 case GLX_TRANSPARENT_TYPE_EXT
:
1464 if (glxvis
->level
==0) {
1466 *value
= GLX_NONE_EXT
;
1468 else if (glxvis
->level
>0) {
1470 if (glxvis
->gl_visual
->RGBAflag
) {
1471 *value
= GLX_TRANSPARENT_RGB_EXT
;
1474 *value
= GLX_TRANSPARENT_INDEX_EXT
;
1477 else if (glxvis
->level
<0) {
1479 *value
= GLX_NONE_EXT
;
1482 case GLX_TRANSPARENT_INDEX_VALUE_EXT
:
1484 int pixel
= transparent_pixel( glxvis
);
1488 /* else undefined */
1491 case GLX_TRANSPARENT_RED_VALUE_EXT
:
1494 case GLX_TRANSPARENT_GREEN_VALUE_EXT
:
1497 case GLX_TRANSPARENT_BLUE_VALUE_EXT
:
1500 case GLX_TRANSPARENT_ALPHA_VALUE_EXT
:
1505 * GLX_EXT_visual_info extension
1507 case GLX_VISUAL_CAVEAT_EXT
:
1508 /* test for zero, just in case */
1509 if (glxvis
->VisualCaveat
> 0)
1510 *value
= glxvis
->VisualCaveat
;
1512 *value
= GLX_NONE_EXT
;
1519 return GLX_BAD_ATTRIBUTE
;
1526 Fake_glXWaitGL( void )
1528 XMesaContext xmesa
= XMesaGetCurrentContext();
1529 XMesaFlush( xmesa
);
1535 Fake_glXWaitX( void )
1537 XMesaContext xmesa
= XMesaGetCurrentContext();
1538 XMesaFlush( xmesa
);
1543 * Return the extensions string, which is 3Dfx-dependant.
1545 static const char *get_extensions( void )
1548 const char *fx
= getenv("MESA_GLX_FX");
1549 if (fx
&& fx
[0] != 'd') {
1550 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";
1553 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";
1558 /* GLX 1.1 and later */
1560 Fake_glXQueryExtensionsString( Display
*dpy
, int screen
)
1564 return get_extensions();
1569 /* GLX 1.1 and later */
1571 Fake_glXQueryServerString( Display
*dpy
, int screen
, int name
)
1573 static char version
[1000];
1574 sprintf(version
, "%d.%d %s", SERVER_MAJOR_VERSION
, SERVER_MINOR_VERSION
,
1581 case GLX_EXTENSIONS
:
1582 return get_extensions();
1594 /* GLX 1.1 and later */
1596 Fake_glXGetClientString( Display
*dpy
, int name
)
1598 static char version
[1000];
1599 sprintf(version
, "%d.%d %s", CLIENT_MAJOR_VERSION
, CLIENT_MINOR_VERSION
,
1605 case GLX_EXTENSIONS
:
1606 return get_extensions();
1622 static GLXFBConfig
*
1623 Fake_glXChooseFBConfig( Display
*dpy
, int screen
,
1624 const int *attribList
, int *nitems
)
1635 Fake_glXGetFBConfigAttrib( Display
*dpy
, GLXFBConfig config
,
1636 int attribute
, int *value
)
1646 static GLXFBConfig
*
1647 Fake_glXGetFBConfigs( Display
*dpy
, int screen
, int *nelements
)
1656 static XVisualInfo
*
1657 Fake_glXGetVisualFromFBConfig( Display
*dpy
, GLXFBConfig config
)
1666 Fake_glXCreateWindow( Display
*dpy
, GLXFBConfig config
, Window win
,
1667 const int *attribList
)
1678 Fake_glXDestroyWindow( Display
*dpy
, GLXWindow window
)
1687 Fake_glXCreatePixmap( Display
*dpy
, GLXFBConfig config
, Pixmap pixmap
,
1688 const int *attribList
)
1699 Fake_glXDestroyPixmap( Display
*dpy
, GLXPixmap pixmap
)
1708 Fake_glXCreatePbuffer( Display
*dpy
, GLXFBConfig config
,
1709 const int *attribList
)
1719 Fake_glXDestroyPbuffer( Display
*dpy
, GLXPbuffer pbuf
)
1727 Fake_glXQueryDrawable( Display
*dpy
, GLXDrawable draw
, int attribute
,
1728 unsigned int *value
)
1738 Fake_glXCreateNewContext( Display
*dpy
, GLXFBConfig config
,
1739 int renderType
, GLXContext shareList
, Bool direct
)
1751 Fake_glXQueryContext( Display
*dpy
, GLXContext ctx
, int attribute
, int *value
)
1762 Fake_glXSelectEvent( Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
1771 Fake_glXGetSelectedEvent( Display
*dpy
, GLXDrawable drawable
,
1772 unsigned long *mask
)
1781 #ifdef GLX_MESA_release_buffers
1783 * Release the depth, stencil, accum buffers attached to a GLXDrawable
1784 * (a window or pixmap) prior to destroying the GLXDrawable.
1787 Fake_glXReleaseBuffersMESA( Display
*dpy
, GLXDrawable d
)
1789 XMesaBuffer b
= XMesaFindBuffer(dpy
, d
);
1791 XMesaDestroyBuffer(b
);
1800 #ifdef GLX_MESA_set_3dfx_mode
1802 Fake_glXSet3DfxModeMESA( GLint mode
)
1804 return XMesaSetFXmode( mode
);
1811 * GLX_SGI_video_sync
1814 #ifdef GLX_SGI_video_sync
1817 Fake_glXGetVideoSyncSGI(unsigned int *count
)
1824 Fake_glXWaitVideoSyncSGI(int divisor
, int remainder
, unsigned int *count
)
1833 extern struct _glxapi_table
*_mesa_GetGLXDispatchTable(void);
1834 struct _glxapi_table
*_mesa_GetGLXDispatchTable(void)
1836 static struct _glxapi_table glx
;
1838 /* be sure our dispatch table size <= libGL's table */
1840 int size
= sizeof(struct _glxapi_table
) / sizeof(void *);
1842 assert(_glxapi_get_dispatch_table_size() >= size
);
1845 /* initialize the whole table to no-ops */
1846 _glxapi_set_no_op_table(&glx
);
1848 /* now initialize the table with the functions I implement */
1849 glx
.ChooseVisual
= Fake_glXChooseVisual
;
1850 glx
.CopyContext
= Fake_glXCopyContext
;
1851 glx
.CreateContext
= Fake_glXCreateContext
;
1852 glx
.CreateGLXPixmap
= Fake_glXCreateGLXPixmap
;
1853 glx
.DestroyContext
= Fake_glXDestroyContext
;
1854 glx
.DestroyGLXPixmap
= Fake_glXDestroyGLXPixmap
;
1855 glx
.GetConfig
= Fake_glXGetConfig
;
1856 /*glx.GetCurrentContext = Fake_glXGetCurrentContext;*/
1857 /*glx.GetCurrentDrawable = Fake_glXGetCurrentDrawable;*/
1858 glx
.IsDirect
= Fake_glXIsDirect
;
1859 glx
.MakeCurrent
= Fake_glXMakeCurrent
;
1860 glx
.QueryExtension
= Fake_glXQueryExtension
;
1861 glx
.QueryVersion
= Fake_glXQueryVersion
;
1862 glx
.SwapBuffers
= Fake_glXSwapBuffers
;
1863 glx
.UseXFont
= Fake_glXUseXFont
;
1864 glx
.WaitGL
= Fake_glXWaitGL
;
1865 glx
.WaitX
= Fake_glXWaitX
;
1867 #ifdef GLX_VERSION_1_1
1868 glx
.GetClientString
= Fake_glXGetClientString
;
1869 glx
.QueryExtensionsString
= Fake_glXQueryExtensionsString
;
1870 glx
.QueryServerString
= Fake_glXQueryServerString
;
1873 #ifdef GLX_VERSION_1_2
1874 /*glx.GetCurrentDisplay = Fake_glXGetCurrentDisplay;*/
1877 #ifdef GLX_VERSION_1_3
1878 glx
.ChooseFBConfig
= Fake_glXChooseFBConfig
;
1879 glx
.CreateNewContext
= Fake_glXCreateNewContext
;
1880 glx
.CreatePbuffer
= Fake_glXCreatePbuffer
;
1881 glx
.CreatePixmap
= Fake_glXCreatePixmap
;
1882 glx
.CreateWindow
= Fake_glXCreateWindow
;
1883 glx
.DestroyPbuffer
= Fake_glXDestroyPbuffer
;
1884 glx
.DestroyPixmap
= Fake_glXDestroyPixmap
;
1885 glx
.DestroyWindow
= Fake_glXDestroyWindow
;
1886 /*glx.GetCurrentReadDrawable = Fake_glXGetCurrentReadDrawable;*/
1887 glx
.GetFBConfigAttrib
= Fake_glXGetFBConfigAttrib
;
1888 glx
.GetFBConfigs
= Fake_glXGetFBConfigs
;
1889 glx
.GetSelectedEvent
= Fake_glXGetSelectedEvent
;
1890 glx
.GetVisualFromFBConfig
= Fake_glXGetVisualFromFBConfig
;
1891 glx
.MakeContextCurrent
= Fake_glXMakeContextCurrent
;
1892 glx
.QueryContext
= Fake_glXQueryContext
;
1893 glx
.QueryDrawable
= Fake_glXQueryDrawable
;
1894 glx
.SelectEvent
= Fake_glXSelectEvent
;
1897 #ifdef GLX_SGI_video_sync
1898 glx
.GetVideoSyncSGI
= Fake_glXGetVideoSyncSGI
;
1899 glx
.WaitVideoSyncSGI
= Fake_glXWaitVideoSyncSGI
;
1902 #ifdef GLX_MESA_copy_sub_buffer
1903 glx
.CopySubBufferMESA
= Fake_glXCopySubBufferMESA
;
1906 #ifdef GLX_MESA_release_buffers
1907 glx
.ReleaseBuffersMESA
= Fake_glXReleaseBuffersMESA
;
1910 #ifdef GLX_MESA_pixmap_colormap
1911 glx
.CreateGLXPixmapMESA
= Fake_glXCreateGLXPixmapMESA
;
1914 #ifdef GLX_MESA_set_3dfx_mode
1915 glx
.Set3DfxModeMESA
= Fake_glXSet3DfxModeMESA
;