2 * Mesa 3-D graphics library
4 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
5 * Copyright (C) 2009 VMware, Inc. 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 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
28 * This is an emulation of the GLX API which allows Mesa/GLX-based programs
29 * to run on X servers which do not have the real GLX extension.
31 * Thanks to the contributors:
33 * Initial version: Philip Brown (phil@bolthole.com)
34 * Better glXGetConfig() support: Armin Liebchen (liebchen@asylum.cs.utah.edu)
35 * Further visual-handling refinements: Wolfram Gloger
36 * (wmglo@Dent.MED.Uni-Muenchen.DE).
39 * Don't be fooled, stereo isn't supported yet.
45 #include "glxheader.h"
47 #include "main/context.h"
48 #include "main/config.h"
49 #include "main/macros.h"
50 #include "main/mtypes.h"
51 #include "main/version.h"
54 #include "util/u_math.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 " PACKAGE_VERSION
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_create_context " \
78 "GLX_ARB_get_proc_address " \
79 "GLX_EXT_texture_from_pixmap " \
80 "GLX_EXT_visual_info " \
81 "GLX_EXT_visual_rating " \
82 /*"GLX_SGI_video_sync "*/ \
83 "GLX_SGIX_fbconfig " \
88 /**********************************************************************/
89 /*** GLX Visual Code ***/
90 /**********************************************************************/
95 static XMesaVisual
*VisualTable
= NULL
;
96 static int NumVisuals
= 0;
100 * This struct and some code fragments borrowed
101 * from Mark Kilgard's GLUT library.
103 typedef struct _OverlayInfo
{
104 /* Avoid 64-bit portability problems by being careful to use
105 longs due to the way XGetWindowProperty is specified. Note
106 that these parameters are passed as CARD32s over X
108 unsigned long overlay_visual
;
109 long transparent_type
;
116 /* Macro to handle c_class vs class field name in XVisualInfo struct */
117 #if defined(__cplusplus) || defined(c_plusplus)
118 #define CLASS c_class
126 * Test if the given XVisualInfo is usable for Mesa rendering.
129 is_usable_visual( XVisualInfo
*vinfo
)
131 switch (vinfo
->CLASS
) {
134 /* Any StaticGray/GrayScale visual works in RGB or CI mode */
138 /* Color-index rendering is not supported. */
142 /* Any depth of TrueColor or DirectColor works in RGB mode */
145 /* This should never happen */
153 * Get an array OverlayInfo records for specified screen.
154 * \param dpy the display
155 * \param screen screen number
156 * \param numOverlays returns numver of OverlayInfo records
157 * \return pointer to OverlayInfo array, free with XFree()
160 GetOverlayInfo(Display
*dpy
, int screen
, int *numOverlays
)
162 Atom overlayVisualsAtom
;
165 unsigned char *ovInfo
;
166 unsigned long sizeData
, bytesLeft
;
170 * The SERVER_OVERLAY_VISUALS property on the root window contains
171 * a list of overlay visuals. Get that list now.
173 overlayVisualsAtom
= XInternAtom(dpy
,"SERVER_OVERLAY_VISUALS", True
);
174 if (overlayVisualsAtom
== None
) {
178 status
= XGetWindowProperty(dpy
, RootWindow(dpy
, screen
),
179 overlayVisualsAtom
, 0L, (long) 10000, False
,
180 overlayVisualsAtom
, &actualType
, &actualFormat
,
181 &sizeData
, &bytesLeft
,
184 if (status
!= Success
|| actualType
!= overlayVisualsAtom
||
185 actualFormat
!= 32 || sizeData
< 4) {
186 /* something went wrong */
187 free((void *) ovInfo
);
192 *numOverlays
= sizeData
/ 4;
193 return (OverlayInfo
*) ovInfo
;
199 * Return the level (overlay, normal, underlay) of a given XVisualInfo.
200 * Input: dpy - the X display
201 * vinfo - the XVisualInfo to test
202 * Return: level of the visual:
204 * >0 = overlay planes
205 * <0 = underlay planes
208 level_of_visual( Display
*dpy
, XVisualInfo
*vinfo
)
210 OverlayInfo
*overlay_info
;
211 int numOverlaysPerScreen
, i
;
213 overlay_info
= GetOverlayInfo(dpy
, vinfo
->screen
, &numOverlaysPerScreen
);
218 /* search the overlay visual list for the visual ID of interest */
219 for (i
= 0; i
< numOverlaysPerScreen
; i
++) {
220 const OverlayInfo
*ov
= overlay_info
+ i
;
221 if (ov
->overlay_visual
== vinfo
->visualid
) {
222 /* found the visual */
223 if (/*ov->transparent_type==1 &&*/ ov
->layer
!=0) {
224 int level
= ov
->layer
;
225 free((void *) overlay_info
);
229 free((void *) overlay_info
);
235 /* The visual ID was not found in the overlay list. */
236 free((void *) overlay_info
);
244 * Given an XVisualInfo and RGB, Double, and Depth buffer flags, save the
245 * configuration in our list of GLX visuals.
248 save_glx_visual( Display
*dpy
, XVisualInfo
*vinfo
,
249 GLboolean alphaFlag
, GLboolean dbFlag
,
250 GLboolean stereoFlag
,
251 GLint depth_size
, GLint stencil_size
,
252 GLint accumRedSize
, GLint accumGreenSize
,
253 GLint accumBlueSize
, GLint accumAlphaSize
,
254 GLint level
, GLint numAuxBuffers
)
256 GLboolean ximageFlag
= GL_TRUE
;
261 /* Check if the MESA_BACK_BUFFER env var is set */
262 char *backbuffer
= getenv("MESA_BACK_BUFFER");
264 if (backbuffer
[0]=='p' || backbuffer
[0]=='P') {
265 ximageFlag
= GL_FALSE
;
267 else if (backbuffer
[0]=='x' || backbuffer
[0]=='X') {
268 ximageFlag
= GL_TRUE
;
271 _mesa_warning(NULL
, "Mesa: invalid value for MESA_BACK_BUFFER environment variable, using an XImage.");
277 /* stereo not supported */
282 /* Force the visual to have an alpha channel */
283 if (getenv("MESA_GLX_FORCE_ALPHA"))
286 /* First check if a matching visual is already in the list */
287 for (i
=0; i
<NumVisuals
; i
++) {
288 XMesaVisual v
= VisualTable
[i
];
289 if (v
->display
== dpy
290 && v
->mesa_visual
.level
== level
291 && v
->mesa_visual
.numAuxBuffers
== numAuxBuffers
292 && v
->ximage_flag
== ximageFlag
293 && v
->mesa_visual
.doubleBufferMode
== dbFlag
294 && v
->mesa_visual
.stereoMode
== stereoFlag
295 && (v
->mesa_visual
.alphaBits
> 0) == alphaFlag
296 && (v
->mesa_visual
.depthBits
>= depth_size
|| depth_size
== 0)
297 && (v
->mesa_visual
.stencilBits
>= stencil_size
|| stencil_size
== 0)
298 && (v
->mesa_visual
.accumRedBits
>= accumRedSize
|| accumRedSize
== 0)
299 && (v
->mesa_visual
.accumGreenBits
>= accumGreenSize
|| accumGreenSize
== 0)
300 && (v
->mesa_visual
.accumBlueBits
>= accumBlueSize
|| accumBlueSize
== 0)
301 && (v
->mesa_visual
.accumAlphaBits
>= accumAlphaSize
|| accumAlphaSize
== 0)) {
302 /* now compare visual IDs */
303 if (v
->visinfo
->visualid
== vinfo
->visualid
) {
309 /* Create a new visual and add it to the list. */
311 xmvis
= XMesaCreateVisual( dpy
, vinfo
, GL_TRUE
, alphaFlag
, dbFlag
,
312 stereoFlag
, ximageFlag
,
313 depth_size
, stencil_size
,
314 accumRedSize
, accumBlueSize
,
315 accumBlueSize
, accumAlphaSize
, 0, level
,
318 /* Allocate more space for additional visual */
319 VisualTable
= realloc(VisualTable
, sizeof(XMesaVisual
) * (NumVisuals
+ 1));
320 /* add xmvis to the list */
321 VisualTable
[NumVisuals
] = xmvis
;
323 /* XXX minor hack, because XMesaCreateVisual doesn't support an
324 * aux buffers parameter.
326 xmvis
->mesa_visual
.numAuxBuffers
= numAuxBuffers
;
333 * Return the default number of bits for the Z buffer.
334 * If defined, use the MESA_GLX_DEPTH_BITS env var value.
335 * Otherwise, use the DEFAULT_SOFTWARE_DEPTH_BITS constant.
336 * XXX probably do the same thing for stencil, accum, etc.
339 default_depth_bits(void)
342 const char *zEnv
= getenv("MESA_GLX_DEPTH_BITS");
346 zBits
= DEFAULT_SOFTWARE_DEPTH_BITS
;
351 default_alpha_bits(void)
354 const char *aEnv
= getenv("MESA_GLX_ALPHA_BITS");
363 default_accum_bits(void)
371 * Create a GLX visual from a regular XVisualInfo.
372 * This is called when Fake GLX is given an XVisualInfo which wasn't
373 * returned by glXChooseVisual. Since this is the first time we're
374 * considering this visual we'll take a guess at reasonable values
375 * for depth buffer size, stencil size, accum size, etc.
376 * This is the best we can do with a client-side emulation of GLX.
379 create_glx_visual( Display
*dpy
, XVisualInfo
*visinfo
)
382 GLint zBits
= default_depth_bits();
383 GLint accBits
= default_accum_bits();
384 GLboolean alphaFlag
= default_alpha_bits() > 0;
386 vislevel
= level_of_visual( dpy
, visinfo
);
388 /* Color-index rendering to overlays is not supported. */
391 else if (is_usable_visual( visinfo
)) {
392 /* Configure this visual as RGB, double-buffered, depth-buffered. */
393 /* This is surely wrong for some people's needs but what else */
394 /* can be done? They should use glXChooseVisual(). */
395 return save_glx_visual( dpy
, visinfo
,
396 alphaFlag
, /* alpha */
397 GL_TRUE
, /* double */
398 GL_FALSE
, /* stereo */
400 8, /* stencil bits */
410 _mesa_warning(NULL
, "Mesa: error in glXCreateContext: bad visual\n");
418 * Find the GLX visual associated with an XVisualInfo.
421 find_glx_visual( Display
*dpy
, XVisualInfo
*vinfo
)
425 /* try to match visual id */
426 for (i
=0;i
<NumVisuals
;i
++) {
427 if (VisualTable
[i
]->display
==dpy
428 && VisualTable
[i
]->visinfo
->visualid
== vinfo
->visualid
) {
429 return VisualTable
[i
];
439 * Return the transparent pixel value for a GLX visual.
440 * Input: glxvis - the glx_visual
441 * Return: a pixel value or -1 if no transparent pixel
444 transparent_pixel( XMesaVisual glxvis
)
446 Display
*dpy
= glxvis
->display
;
447 XVisualInfo
*vinfo
= glxvis
->visinfo
;
448 OverlayInfo
*overlay_info
;
449 int numOverlaysPerScreen
, i
;
451 overlay_info
= GetOverlayInfo(dpy
, vinfo
->screen
, &numOverlaysPerScreen
);
456 for (i
= 0; i
< numOverlaysPerScreen
; i
++) {
457 const OverlayInfo
*ov
= overlay_info
+ i
;
458 if (ov
->overlay_visual
== vinfo
->visualid
) {
460 if (ov
->transparent_type
== 0) {
461 /* type 0 indicates no transparency */
462 free((void *) overlay_info
);
466 /* ov->value is the transparent pixel */
467 free((void *) overlay_info
);
473 /* The visual ID was not found in the overlay list. */
474 free((void *) overlay_info
);
481 * Try to get an X visual which matches the given arguments.
484 get_visual( Display
*dpy
, int scr
, unsigned int depth
, int xclass
)
486 XVisualInfo temp
, *vis
;
489 unsigned int default_depth
;
492 mask
= VisualScreenMask
| VisualDepthMask
| VisualClassMask
;
497 default_depth
= DefaultDepth(dpy
,scr
);
498 default_class
= DefaultVisual(dpy
,scr
)->CLASS
;
500 if (depth
==default_depth
&& xclass
==default_class
) {
501 /* try to get root window's visual */
502 temp
.visualid
= DefaultVisual(dpy
,scr
)->visualid
;
503 mask
|= VisualIDMask
;
506 vis
= XGetVisualInfo( dpy
, mask
, &temp
, &n
);
508 /* In case bits/pixel > 24, make sure color channels are still <=8 bits.
509 * An SGI Infinite Reality system, for example, can have 30bpp pixels:
510 * 10 bits per color channel. Mesa's limited to a max of 8 bits/channel.
512 if (vis
&& depth
> 24 && (xclass
==TrueColor
|| xclass
==DirectColor
)) {
513 if (util_bitcount((GLuint
) vis
->red_mask
) <= 8 &&
514 util_bitcount((GLuint
) vis
->green_mask
) <= 8 &&
515 util_bitcount((GLuint
) vis
->blue_mask
) <= 8) {
530 * Retrieve the value of the given environment variable and find
531 * the X visual which matches it.
532 * Input: dpy - the display
533 * screen - the screen number
534 * varname - the name of the environment variable
535 * Return: an XVisualInfo pointer to NULL if error.
538 get_env_visual(Display
*dpy
, int scr
, const char *varname
)
540 char value
[100], type
[100];
541 int depth
, xclass
= -1;
544 if (!getenv( varname
)) {
548 strncpy( value
, getenv(varname
), 100 );
551 sscanf( value
, "%s %d", type
, &depth
);
553 if (strcmp(type
,"TrueColor")==0) xclass
= TrueColor
;
554 else if (strcmp(type
,"DirectColor")==0) xclass
= DirectColor
;
555 else if (strcmp(type
,"GrayScale")==0) xclass
= GrayScale
;
556 else if (strcmp(type
,"StaticGray")==0) xclass
= StaticGray
;
558 if (xclass
>-1 && depth
>0) {
559 vis
= get_visual( dpy
, scr
, depth
, xclass
);
565 _mesa_warning(NULL
, "GLX unable to find visual class=%s, depth=%d.",
574 * Select an X visual which satisfies the RGBA/CI flag and minimum depth.
575 * Input: dpy, screen - X display and screen number
576 * min_depth - minimum visual depth
577 * preferred_class - preferred GLX visual class or DONT_CARE
578 * Return: pointer to an XVisualInfo or NULL.
581 choose_x_visual(Display
*dpy
, int screen
, int min_depth
, int preferred_class
)
584 int xclass
, visclass
= 0;
587 /* First see if the MESA_RGB_VISUAL env var is defined */
588 vis
= get_env_visual( dpy
, screen
, "MESA_RGB_VISUAL" );
592 /* Otherwise, search for a suitable visual */
593 if (preferred_class
==DONT_CARE
) {
594 for (xclass
=0;xclass
<4;xclass
++) {
596 case 0: visclass
= TrueColor
; break;
597 case 1: visclass
= DirectColor
; break;
598 case 2: visclass
= GrayScale
; break;
599 case 3: visclass
= StaticGray
; break;
602 /* start with shallowest */
603 for (depth
=0;depth
<=32;depth
++) {
604 vis
= get_visual( dpy
, screen
, depth
, visclass
);
611 /* start with deepest */
612 for (depth
=32;depth
>=min_depth
;depth
--) {
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_GRAY_SCALE_EXT
: visclass
= GrayScale
; break;
627 case GLX_STATIC_GRAY_EXT
: visclass
= StaticGray
; break;
628 case GLX_PSEUDO_COLOR_EXT
:
629 case GLX_STATIC_COLOR_EXT
:
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
);
652 /* didn't find a visual */
659 * Find the deepest X over/underlay visual of at least min_depth.
660 * Input: dpy, screen - X display and screen number
661 * level - the over/underlay level
662 * trans_type - transparent pixel type: GLX_NONE_EXT,
663 * GLX_TRANSPARENT_RGB_EXT, GLX_TRANSPARENT_INDEX_EXT,
665 * trans_value - transparent pixel value or DONT_CARE
666 * min_depth - minimum visual depth
667 * preferred_class - preferred GLX visual class or DONT_CARE
668 * Return: pointer to an XVisualInfo or NULL.
671 choose_x_overlay_visual( Display
*dpy
, int scr
,
672 int level
, int trans_type
, int trans_value
,
673 int min_depth
, int preferred_class
)
675 OverlayInfo
*overlay_info
;
676 int numOverlaysPerScreen
;
678 XVisualInfo
*deepvis
;
681 /*DEBUG int tt, tv; */
683 switch (preferred_class
) {
684 case GLX_TRUE_COLOR_EXT
: preferred_class
= TrueColor
; break;
685 case GLX_DIRECT_COLOR_EXT
: preferred_class
= DirectColor
; break;
686 case GLX_PSEUDO_COLOR_EXT
: preferred_class
= PseudoColor
; break;
687 case GLX_STATIC_COLOR_EXT
: preferred_class
= StaticColor
; break;
688 case GLX_GRAY_SCALE_EXT
: preferred_class
= GrayScale
; break;
689 case GLX_STATIC_GRAY_EXT
: preferred_class
= StaticGray
; break;
690 default: preferred_class
= DONT_CARE
;
693 overlay_info
= GetOverlayInfo(dpy
, scr
, &numOverlaysPerScreen
);
698 /* Search for the deepest overlay which satisifies all criteria. */
702 for (i
= 0; i
< numOverlaysPerScreen
; i
++) {
703 const OverlayInfo
*ov
= overlay_info
+ i
;
704 XVisualInfo
*vislist
, vistemplate
;
707 if (ov
->layer
!=level
) {
708 /* failed overlay level criteria */
711 if (!(trans_type
==DONT_CARE
712 || (trans_type
==GLX_TRANSPARENT_INDEX_EXT
713 && ov
->transparent_type
>0)
714 || (trans_type
==GLX_NONE_EXT
&& ov
->transparent_type
==0))) {
715 /* failed transparent pixel type criteria */
718 if (trans_value
!=DONT_CARE
&& trans_value
!=ov
->value
) {
719 /* failed transparent pixel value criteria */
723 /* get XVisualInfo and check the depth */
724 vistemplate
.visualid
= ov
->overlay_visual
;
725 vistemplate
.screen
= scr
;
726 vislist
= XGetVisualInfo( dpy
, VisualIDMask
| VisualScreenMask
,
727 &vistemplate
, &count
);
735 /* something went wrong */
739 if (preferred_class
!=DONT_CARE
&& preferred_class
!=vislist
->CLASS
) {
740 /* wrong visual class */
745 /* Color-index rendering is not supported. Make sure we have True/DirectColor */
746 if (vislist
->CLASS
!= TrueColor
&& vislist
->CLASS
!= DirectColor
) {
751 if (deepvis
!=NULL
&& vislist
->depth
<= deepest
) {
756 /* YES! found a satisfactory visual */
758 deepest
= vislist
->depth
;
760 /* DEBUG tt = ov->transparent_type;*/
761 /* DEBUG tv = ov->value; */
766 printf("chose 0x%x: layer=%d depth=%d trans_type=%d trans_value=%d\n",
767 deepvis->visualid, level, deepvis->depth, tt, tv );
774 /**********************************************************************/
775 /*** Display-related functions ***/
776 /**********************************************************************/
780 * Free all XMesaVisuals which are associated with the given display.
783 destroy_visuals_on_display(Display
*dpy
)
786 for (i
= 0; i
< NumVisuals
; i
++) {
787 if (VisualTable
[i
]->display
== dpy
) {
788 /* remove this visual */
790 XMesaDestroyVisual(VisualTable
[i
]);
791 for (j
= i
; j
< NumVisuals
- 1; j
++)
792 VisualTable
[j
] = VisualTable
[j
+ 1];
800 * Called from XCloseDisplay() to let us free our display-related data.
803 close_display_callback(Display
*dpy
, XExtCodes
*codes
)
805 destroy_visuals_on_display(dpy
);
806 xmesa_destroy_buffers_on_display(dpy
);
812 * Look for the named extension on given display and return a pointer
813 * to the _XExtension data, or NULL if extension not found.
816 lookup_extension(Display
*dpy
, const char *extName
)
819 for (ext
= dpy
->ext_procs
; ext
; ext
= ext
->next
) {
820 if (ext
->name
&& strcmp(ext
->name
, extName
) == 0) {
829 * Whenever we're given a new Display pointer, call this function to
830 * register our close_display_callback function.
833 register_with_display(Display
*dpy
)
835 const char *extName
= "MesaGLX";
838 ext
= lookup_extension(dpy
, extName
);
840 XExtCodes
*c
= XAddExtension(dpy
);
841 ext
= dpy
->ext_procs
; /* new extension is at head of list */
842 assert(c
->extension
== ext
->codes
.extension
);
843 (void) c
; /* silence warning */
844 ext
->name
= strdup(extName
);
845 ext
->close_display
= close_display_callback
;
850 /**********************************************************************/
851 /*** Begin Fake GLX API Functions ***/
852 /**********************************************************************/
856 * Helper used by glXChooseVisual and glXChooseFBConfig.
857 * The fbConfig parameter must be GL_FALSE for the former and GL_TRUE for
859 * In either case, the attribute list is terminated with the value 'None'.
862 choose_visual( Display
*dpy
, int screen
, const int *list
, GLboolean fbConfig
)
864 const GLboolean rgbModeDefault
= fbConfig
;
865 const int *parselist
;
868 int min_red
=0, min_green
=0, min_blue
=0;
869 GLboolean rgb_flag
= rgbModeDefault
;
870 GLboolean alpha_flag
= GL_FALSE
;
871 GLboolean double_flag
= GL_FALSE
;
872 GLboolean stereo_flag
= GL_FALSE
;
873 GLint depth_size
= 0;
874 GLint stencil_size
= 0;
875 GLint accumRedSize
= 0;
876 GLint accumGreenSize
= 0;
877 GLint accumBlueSize
= 0;
878 GLint accumAlphaSize
= 0;
880 int visual_type
= DONT_CARE
;
881 int trans_type
= DONT_CARE
;
882 int trans_value
= DONT_CARE
;
883 GLint caveat
= DONT_CARE
;
884 XMesaVisual xmvis
= NULL
;
885 int desiredVisualID
= -1;
893 parselist
[1] == GLX_DONT_CARE
&&
894 parselist
[0] != GLX_LEVEL
) {
895 /* For glXChooseFBConfig(), skip attributes whose value is
896 * GLX_DONT_CARE (-1), unless it's GLX_LEVEL (which can legitimately be
899 * From page 17 (23 of the pdf) of the GLX 1.4 spec:
900 * GLX DONT CARE may be specified for all attributes except GLX LEVEL.
906 switch (*parselist
) {
917 case GLX_BUFFER_SIZE
:
919 min_ci
= *parselist
++;
923 level
= *parselist
++;
935 case GLX_DOUBLEBUFFER
:
938 double_flag
= *parselist
++;
941 double_flag
= GL_TRUE
;
947 stereo_flag
= *parselist
++;
950 stereo_flag
= GL_TRUE
;
953 case GLX_AUX_BUFFERS
:
955 numAux
= *parselist
++;
956 if (numAux
> MAX_AUX_BUFFERS
)
961 min_red
= *parselist
++;
965 min_green
= *parselist
++;
969 min_blue
= *parselist
++;
974 GLint size
= *parselist
++;
975 alpha_flag
= size
? GL_TRUE
: GL_FALSE
;
980 depth_size
= *parselist
++;
982 case GLX_STENCIL_SIZE
:
984 stencil_size
= *parselist
++;
986 case GLX_ACCUM_RED_SIZE
:
989 GLint size
= *parselist
++;
990 accumRedSize
= MAX2( accumRedSize
, size
);
993 case GLX_ACCUM_GREEN_SIZE
:
996 GLint size
= *parselist
++;
997 accumGreenSize
= MAX2( accumGreenSize
, size
);
1000 case GLX_ACCUM_BLUE_SIZE
:
1003 GLint size
= *parselist
++;
1004 accumBlueSize
= MAX2( accumBlueSize
, size
);
1007 case GLX_ACCUM_ALPHA_SIZE
:
1010 GLint size
= *parselist
++;
1011 accumAlphaSize
= MAX2( accumAlphaSize
, size
);
1016 * GLX_EXT_visual_info extension
1018 case GLX_X_VISUAL_TYPE_EXT
:
1020 visual_type
= *parselist
++;
1022 case GLX_TRANSPARENT_TYPE_EXT
:
1024 trans_type
= *parselist
++;
1026 case GLX_TRANSPARENT_INDEX_VALUE_EXT
:
1028 trans_value
= *parselist
++;
1030 case GLX_TRANSPARENT_RED_VALUE_EXT
:
1031 case GLX_TRANSPARENT_GREEN_VALUE_EXT
:
1032 case GLX_TRANSPARENT_BLUE_VALUE_EXT
:
1033 case GLX_TRANSPARENT_ALPHA_VALUE_EXT
:
1040 * GLX_EXT_visual_info extension
1042 case GLX_VISUAL_CAVEAT_EXT
:
1044 caveat
= *parselist
++; /* ignored for now */
1048 * GLX_ARB_multisample
1050 case GLX_SAMPLE_BUFFERS_ARB
:
1051 case GLX_SAMPLES_ARB
:
1053 if (*parselist
++ != 0)
1054 /* ms not supported */
1061 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
& (GLX_RGBA_FLOAT_BIT_ARB
|GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT
)) {
1074 else if (*parselist
== 0) {
1079 case GLX_DRAWABLE_TYPE
:
1083 if (*parselist
& ~(GLX_WINDOW_BIT
| GLX_PIXMAP_BIT
| GLX_PBUFFER_BIT
)) {
1084 return NULL
; /* bad bit */
1088 case GLX_FBCONFIG_ID
:
1093 desiredVisualID
= *parselist
++;
1095 case GLX_X_RENDERABLE
:
1096 case GLX_MAX_PBUFFER_WIDTH
:
1097 case GLX_MAX_PBUFFER_HEIGHT
:
1098 case GLX_MAX_PBUFFER_PIXELS
:
1105 case GLX_BIND_TO_TEXTURE_RGB_EXT
:
1106 parselist
++; /*skip*/
1108 case GLX_BIND_TO_TEXTURE_RGBA_EXT
:
1109 parselist
++; /*skip*/
1111 case GLX_BIND_TO_MIPMAP_TEXTURE_EXT
:
1112 parselist
++; /*skip*/
1114 case GLX_BIND_TO_TEXTURE_TARGETS_EXT
:
1116 if (*parselist
& ~(GLX_TEXTURE_1D_BIT_EXT
|
1117 GLX_TEXTURE_2D_BIT_EXT
|
1118 GLX_TEXTURE_RECTANGLE_BIT_EXT
)) {
1123 case GLX_Y_INVERTED_EXT
:
1124 parselist
++; /*skip*/
1132 /* undefined attribute */
1133 _mesa_warning(NULL
, "unexpected attrib 0x%x in choose_visual()",
1146 * Since we're only simulating the GLX extension this function will never
1147 * find any real GL visuals. Instead, all we can do is try to find an RGB
1148 * or CI visual of appropriate depth. Other requested attributes such as
1149 * double buffering, depth buffer, etc. will be associated with the X
1150 * visual and stored in the VisualTable[].
1152 if (desiredVisualID
!= -1) {
1153 /* try to get a specific visual, by visualID */
1156 temp
.visualid
= desiredVisualID
;
1157 temp
.screen
= screen
;
1158 vis
= XGetVisualInfo(dpy
, VisualIDMask
| VisualScreenMask
, &temp
, &n
);
1160 /* give the visual some useful GLX attributes */
1161 double_flag
= GL_TRUE
;
1162 if (vis
->depth
<= 8)
1164 depth_size
= default_depth_bits();
1171 int min_rgb
= min_red
+ min_green
+ min_blue
;
1172 if (min_rgb
>1 && min_rgb
<8) {
1173 /* a special case to be sure we can get a monochrome visual */
1178 vis
= choose_x_visual(dpy
, screen
, min_rgb
, visual_type
);
1181 vis
= choose_x_overlay_visual(dpy
, screen
, level
,
1182 trans_type
, trans_value
, min_rgb
, visual_type
);
1187 /* Note: we're not exactly obeying the glXChooseVisual rules here.
1188 * When GLX_DEPTH_SIZE = 1 is specified we're supposed to choose the
1189 * largest depth buffer size, which is 32bits/value. Instead, we
1190 * return 16 to maintain performance with earlier versions of Mesa.
1192 if (depth_size
> 24)
1194 else if (depth_size
> 16)
1196 else if (depth_size
> 0) {
1197 depth_size
= default_depth_bits();
1201 alpha_flag
= default_alpha_bits() > 0;
1204 /* we only support one size of stencil and accum buffers. */
1205 if (stencil_size
> 0)
1207 if (accumRedSize
> 0 || accumGreenSize
> 0 || accumBlueSize
> 0 ||
1208 accumAlphaSize
> 0) {
1211 accumBlueSize
= default_accum_bits();
1212 accumAlphaSize
= alpha_flag
? accumRedSize
: 0;
1215 xmvis
= save_glx_visual( dpy
, vis
, alpha_flag
, double_flag
,
1216 stereo_flag
, depth_size
, stencil_size
,
1217 accumRedSize
, accumGreenSize
,
1218 accumBlueSize
, accumAlphaSize
, level
, numAux
);
1226 static XVisualInfo
*
1227 Fake_glXChooseVisual( Display
*dpy
, int screen
, int *list
)
1231 /* register ourselves as an extension on this display */
1232 register_with_display(dpy
);
1234 xmvis
= choose_visual(dpy
, screen
, list
, GL_FALSE
);
1236 XVisualInfo
* visinfo
= malloc(sizeof(XVisualInfo
));
1238 memcpy(visinfo
, xmvis
->visinfo
, sizeof(XVisualInfo
));
1248 Fake_glXCreateContext( Display
*dpy
, XVisualInfo
*visinfo
,
1249 GLXContext share_list
, Bool direct
)
1252 XMesaContext xmesaCtx
;
1254 if (!dpy
|| !visinfo
)
1257 /* deallocate unused windows/buffers */
1259 XMesaGarbageCollect(dpy
);
1262 xmvis
= find_glx_visual( dpy
, visinfo
);
1264 /* This visual wasn't found with glXChooseVisual() */
1265 xmvis
= create_glx_visual( dpy
, visinfo
);
1271 xmesaCtx
= XMesaCreateContext(xmvis
, (XMesaContext
) share_list
);
1273 return (GLXContext
) xmesaCtx
;
1277 /* XXX these may have to be removed due to thread-safety issues. */
1278 static GLXContext MakeCurrent_PrevContext
= 0;
1279 static GLXDrawable MakeCurrent_PrevDrawable
= 0;
1280 static GLXDrawable MakeCurrent_PrevReadable
= 0;
1281 static XMesaBuffer MakeCurrent_PrevDrawBuffer
= 0;
1282 static XMesaBuffer MakeCurrent_PrevReadBuffer
= 0;
1285 /* GLX 1.3 and later */
1287 Fake_glXMakeContextCurrent( Display
*dpy
, GLXDrawable draw
,
1288 GLXDrawable read
, GLXContext ctx
)
1290 if (ctx
&& draw
&& read
) {
1291 XMesaBuffer drawBuffer
, readBuffer
;
1292 XMesaContext xmctx
= (XMesaContext
) ctx
;
1294 /* Find the XMesaBuffer which corresponds to the GLXDrawable 'draw' */
1295 if (ctx
== MakeCurrent_PrevContext
1296 && draw
== MakeCurrent_PrevDrawable
) {
1297 drawBuffer
= MakeCurrent_PrevDrawBuffer
;
1300 drawBuffer
= XMesaFindBuffer( dpy
, draw
);
1303 /* drawable must be a new window! */
1304 drawBuffer
= XMesaCreateWindowBuffer( xmctx
->xm_visual
, draw
);
1306 /* Out of memory, or context/drawable depth mismatch */
1311 /* Find the XMesaBuffer which corresponds to the GLXDrawable 'read' */
1312 if (ctx
== MakeCurrent_PrevContext
1313 && read
== MakeCurrent_PrevReadable
) {
1314 readBuffer
= MakeCurrent_PrevReadBuffer
;
1317 readBuffer
= XMesaFindBuffer( dpy
, read
);
1320 /* drawable must be a new window! */
1321 readBuffer
= XMesaCreateWindowBuffer( xmctx
->xm_visual
, read
);
1323 /* Out of memory, or context/drawable depth mismatch */
1328 MakeCurrent_PrevContext
= ctx
;
1329 MakeCurrent_PrevDrawable
= draw
;
1330 MakeCurrent_PrevReadable
= read
;
1331 MakeCurrent_PrevDrawBuffer
= drawBuffer
;
1332 MakeCurrent_PrevReadBuffer
= readBuffer
;
1334 /* Now make current! */
1335 return XMesaMakeCurrent2(xmctx
, drawBuffer
, readBuffer
);
1337 else if (!ctx
&& !draw
&& !read
) {
1338 /* release current context w/out assigning new one. */
1339 XMesaMakeCurrent( NULL
, NULL
);
1340 MakeCurrent_PrevContext
= 0;
1341 MakeCurrent_PrevDrawable
= 0;
1342 MakeCurrent_PrevReadable
= 0;
1343 MakeCurrent_PrevDrawBuffer
= 0;
1344 MakeCurrent_PrevReadBuffer
= 0;
1348 /* The args must either all be non-zero or all zero.
1357 Fake_glXMakeCurrent( Display
*dpy
, GLXDrawable drawable
, GLXContext ctx
)
1359 return Fake_glXMakeContextCurrent( dpy
, drawable
, drawable
, ctx
);
1364 Fake_glXCreateGLXPixmap( Display
*dpy
, XVisualInfo
*visinfo
, Pixmap pixmap
)
1369 v
= find_glx_visual( dpy
, visinfo
);
1371 v
= create_glx_visual( dpy
, visinfo
);
1373 /* unusable visual */
1378 b
= XMesaCreatePixmapBuffer( v
, pixmap
, 0 );
1382 return b
->frontxrb
->pixmap
;
1386 /*** GLX_MESA_pixmap_colormap ***/
1389 Fake_glXCreateGLXPixmapMESA( Display
*dpy
, XVisualInfo
*visinfo
,
1390 Pixmap pixmap
, Colormap cmap
)
1395 v
= find_glx_visual( dpy
, visinfo
);
1397 v
= create_glx_visual( dpy
, visinfo
);
1399 /* unusable visual */
1404 b
= XMesaCreatePixmapBuffer( v
, pixmap
, cmap
);
1408 return b
->frontxrb
->pixmap
;
1413 Fake_glXDestroyGLXPixmap( Display
*dpy
, GLXPixmap pixmap
)
1415 XMesaBuffer b
= XMesaFindBuffer(dpy
, pixmap
);
1417 XMesaDestroyBuffer(b
);
1419 else if (getenv("MESA_DEBUG")) {
1420 _mesa_warning(NULL
, "Mesa: glXDestroyGLXPixmap: invalid pixmap\n");
1426 Fake_glXCopyContext( Display
*dpy
, GLXContext src
, GLXContext dst
,
1427 unsigned long mask
)
1429 XMesaContext xmSrc
= (XMesaContext
) src
;
1430 XMesaContext xmDst
= (XMesaContext
) dst
;
1432 if (MakeCurrent_PrevContext
== src
) {
1435 _mesa_copy_context( &xmSrc
->mesa
, &xmDst
->mesa
, (GLuint
) mask
);
1440 Fake_glXQueryExtension( Display
*dpy
, int *errorBase
, int *eventBase
)
1443 /* Mesa's GLX isn't really an X extension but we try to act like one. */
1444 if (!XQueryExtension(dpy
, GLX_EXTENSION_NAME
, &op
, &ev
, &err
))
1450 return True
; /* we're faking GLX so always return success */
1454 extern void _kw_ungrab_all( Display
*dpy
);
1455 void _kw_ungrab_all( Display
*dpy
)
1457 XUngrabPointer( dpy
, CurrentTime
);
1458 XUngrabKeyboard( dpy
, CurrentTime
);
1463 Fake_glXDestroyContext( Display
*dpy
, GLXContext ctx
)
1467 MakeCurrent_PrevContext
= 0;
1468 MakeCurrent_PrevDrawable
= 0;
1469 MakeCurrent_PrevReadable
= 0;
1470 MakeCurrent_PrevDrawBuffer
= 0;
1471 MakeCurrent_PrevReadBuffer
= 0;
1472 XMesaDestroyContext((XMesaContext
) ctx
);
1473 XMesaGarbageCollect(dpy
);
1479 Fake_glXIsDirect( Display
*dpy
, GLXContext ctx
)
1481 XMesaContext xmCtx
= (XMesaContext
) ctx
;
1482 return xmCtx
? xmCtx
->direct
: False
;
1488 Fake_glXSwapBuffers( Display
*dpy
, GLXDrawable drawable
)
1490 XMesaBuffer buffer
= XMesaFindBuffer( dpy
, drawable
);
1493 XMesaSwapBuffers(buffer
);
1495 else if (getenv("MESA_DEBUG")) {
1496 _mesa_warning(NULL
, "glXSwapBuffers: invalid drawable 0x%x\n",
1503 /*** GLX_MESA_copy_sub_buffer ***/
1506 Fake_glXCopySubBufferMESA( Display
*dpy
, GLXDrawable drawable
,
1507 int x
, int y
, int width
, int height
)
1509 XMesaBuffer buffer
= XMesaFindBuffer( dpy
, drawable
);
1511 XMesaCopySubBuffer(buffer
, x
, y
, width
, height
);
1513 else if (getenv("MESA_DEBUG")) {
1514 _mesa_warning(NULL
, "Mesa: glXCopySubBufferMESA: invalid drawable\n");
1520 Fake_glXQueryVersion( Display
*dpy
, int *maj
, int *min
)
1523 /* Return GLX version, not Mesa version */
1524 assert(CLIENT_MAJOR_VERSION
== SERVER_MAJOR_VERSION
);
1525 *maj
= CLIENT_MAJOR_VERSION
;
1526 *min
= MIN2( CLIENT_MINOR_VERSION
, SERVER_MINOR_VERSION
);
1532 * Query the GLX attributes of the given XVisualInfo.
1535 get_config( XMesaVisual xmvis
, int attrib
, int *value
, GLboolean fbconfig
)
1541 return GLX_BAD_ATTRIBUTE
;
1542 *value
= (int) True
;
1544 case GLX_BUFFER_SIZE
:
1545 *value
= xmvis
->visinfo
->depth
;
1548 *value
= xmvis
->mesa_visual
.level
;
1552 return GLX_BAD_ATTRIBUTE
;
1555 case GLX_DOUBLEBUFFER
:
1556 *value
= (int) xmvis
->mesa_visual
.doubleBufferMode
;
1559 *value
= (int) xmvis
->mesa_visual
.stereoMode
;
1561 case GLX_AUX_BUFFERS
:
1562 *value
= xmvis
->mesa_visual
.numAuxBuffers
;
1565 *value
= xmvis
->mesa_visual
.redBits
;
1567 case GLX_GREEN_SIZE
:
1568 *value
= xmvis
->mesa_visual
.greenBits
;
1571 *value
= xmvis
->mesa_visual
.blueBits
;
1573 case GLX_ALPHA_SIZE
:
1574 *value
= xmvis
->mesa_visual
.alphaBits
;
1576 case GLX_DEPTH_SIZE
:
1577 *value
= xmvis
->mesa_visual
.depthBits
;
1579 case GLX_STENCIL_SIZE
:
1580 *value
= xmvis
->mesa_visual
.stencilBits
;
1582 case GLX_ACCUM_RED_SIZE
:
1583 *value
= xmvis
->mesa_visual
.accumRedBits
;
1585 case GLX_ACCUM_GREEN_SIZE
:
1586 *value
= xmvis
->mesa_visual
.accumGreenBits
;
1588 case GLX_ACCUM_BLUE_SIZE
:
1589 *value
= xmvis
->mesa_visual
.accumBlueBits
;
1591 case GLX_ACCUM_ALPHA_SIZE
:
1592 *value
= xmvis
->mesa_visual
.accumAlphaBits
;
1596 * GLX_EXT_visual_info extension
1598 case GLX_X_VISUAL_TYPE_EXT
:
1599 switch (xmvis
->visinfo
->CLASS
) {
1600 case StaticGray
: *value
= GLX_STATIC_GRAY_EXT
; return 0;
1601 case GrayScale
: *value
= GLX_GRAY_SCALE_EXT
; return 0;
1602 case StaticColor
: *value
= GLX_STATIC_GRAY_EXT
; return 0;
1603 case PseudoColor
: *value
= GLX_PSEUDO_COLOR_EXT
; return 0;
1604 case TrueColor
: *value
= GLX_TRUE_COLOR_EXT
; return 0;
1605 case DirectColor
: *value
= GLX_DIRECT_COLOR_EXT
; return 0;
1608 case GLX_TRANSPARENT_TYPE_EXT
:
1609 if (xmvis
->mesa_visual
.level
==0) {
1611 *value
= GLX_NONE_EXT
;
1613 else if (xmvis
->mesa_visual
.level
>0) {
1615 *value
= GLX_TRANSPARENT_RGB_EXT
;
1617 else if (xmvis
->mesa_visual
.level
<0) {
1619 *value
= GLX_NONE_EXT
;
1622 case GLX_TRANSPARENT_INDEX_VALUE_EXT
:
1624 int pixel
= transparent_pixel( xmvis
);
1628 /* else undefined */
1631 case GLX_TRANSPARENT_RED_VALUE_EXT
:
1634 case GLX_TRANSPARENT_GREEN_VALUE_EXT
:
1637 case GLX_TRANSPARENT_BLUE_VALUE_EXT
:
1640 case GLX_TRANSPARENT_ALPHA_VALUE_EXT
:
1645 * GLX_EXT_visual_info extension
1647 case GLX_VISUAL_CAVEAT_EXT
:
1648 /* test for zero, just in case */
1649 if (xmvis
->mesa_visual
.visualRating
> 0)
1650 *value
= xmvis
->mesa_visual
.visualRating
;
1652 *value
= GLX_NONE_EXT
;
1656 * GLX_ARB_multisample
1658 case GLX_SAMPLE_BUFFERS_ARB
:
1661 case GLX_SAMPLES_ARB
:
1668 case GLX_SCREEN_EXT
:
1670 return GLX_BAD_ATTRIBUTE
;
1671 *value
= xmvis
->visinfo
->screen
;
1673 case GLX_DRAWABLE_TYPE
: /*SGIX too */
1675 return GLX_BAD_ATTRIBUTE
;
1676 *value
= GLX_WINDOW_BIT
| GLX_PIXMAP_BIT
| GLX_PBUFFER_BIT
;
1678 case GLX_RENDER_TYPE_SGIX
:
1680 return GLX_BAD_ATTRIBUTE
;
1681 if (xmvis
->mesa_visual
.floatMode
)
1682 *value
= GLX_RGBA_FLOAT_BIT_ARB
;
1684 *value
= GLX_RGBA_BIT
;
1686 case GLX_X_RENDERABLE_SGIX
:
1688 return GLX_BAD_ATTRIBUTE
;
1689 *value
= True
; /* XXX really? */
1691 case GLX_FBCONFIG_ID_SGIX
:
1693 return GLX_BAD_ATTRIBUTE
;
1694 *value
= xmvis
->visinfo
->visualid
;
1696 case GLX_MAX_PBUFFER_WIDTH
:
1698 return GLX_BAD_ATTRIBUTE
;
1699 /* XXX should be same as ctx->Const.MaxRenderbufferSize */
1700 *value
= DisplayWidth(xmvis
->display
, xmvis
->visinfo
->screen
);
1702 case GLX_MAX_PBUFFER_HEIGHT
:
1704 return GLX_BAD_ATTRIBUTE
;
1705 *value
= DisplayHeight(xmvis
->display
, xmvis
->visinfo
->screen
);
1707 case GLX_MAX_PBUFFER_PIXELS
:
1709 return GLX_BAD_ATTRIBUTE
;
1710 *value
= DisplayWidth(xmvis
->display
, xmvis
->visinfo
->screen
) *
1711 DisplayHeight(xmvis
->display
, xmvis
->visinfo
->screen
);
1715 return GLX_BAD_ATTRIBUTE
;
1716 *value
= xmvis
->visinfo
->visualid
;
1719 case GLX_BIND_TO_TEXTURE_RGB_EXT
:
1720 *value
= True
; /*XXX*/
1722 case GLX_BIND_TO_TEXTURE_RGBA_EXT
:
1724 *value
= xmvis
->mesa_visual
.alphaBits
> 0 ? True
: False
;
1726 case GLX_BIND_TO_MIPMAP_TEXTURE_EXT
:
1727 *value
= True
; /*XXX*/
1729 case GLX_BIND_TO_TEXTURE_TARGETS_EXT
:
1730 *value
= (GLX_TEXTURE_1D_BIT_EXT
|
1731 GLX_TEXTURE_2D_BIT_EXT
|
1732 GLX_TEXTURE_RECTANGLE_BIT_EXT
); /*XXX*/
1734 case GLX_Y_INVERTED_EXT
:
1735 *value
= True
; /*XXX*/
1739 return GLX_BAD_ATTRIBUTE
;
1746 Fake_glXGetConfig( Display
*dpy
, XVisualInfo
*visinfo
,
1747 int attrib
, int *value
)
1751 if (!dpy
|| !visinfo
)
1752 return GLX_BAD_ATTRIBUTE
;
1754 xmvis
= find_glx_visual( dpy
, visinfo
);
1756 /* this visual wasn't obtained with glXChooseVisual */
1757 xmvis
= create_glx_visual( dpy
, visinfo
);
1759 /* this visual can't be used for GL rendering */
1760 if (attrib
==GLX_USE_GL
) {
1761 *value
= (int) False
;
1765 return GLX_BAD_VISUAL
;
1770 k
= get_config(xmvis
, attrib
, value
, GL_FALSE
);
1776 Fake_glXGetCurrentContext(void)
1778 XMesaContext xmesa
= XMesaGetCurrentContext();
1779 return (GLXContext
) xmesa
;
1783 Fake_glXWaitGL( void )
1785 XMesaContext xmesa
= XMesaGetCurrentContext();
1786 XMesaFlush( xmesa
);
1792 Fake_glXWaitX( void )
1794 XMesaContext xmesa
= XMesaGetCurrentContext();
1795 XMesaFlush( xmesa
);
1800 get_extensions( void )
1802 return EXTENSIONS
+ 23; /* skip "GLX_MESA_set_3dfx_mode" */
1807 /* GLX 1.1 and later */
1809 Fake_glXQueryExtensionsString( Display
*dpy
, int screen
)
1813 return get_extensions();
1818 /* GLX 1.1 and later */
1820 Fake_glXQueryServerString( Display
*dpy
, int screen
, int name
)
1822 static char version
[1000];
1823 sprintf(version
, "%d.%d %s",
1824 SERVER_MAJOR_VERSION
, SERVER_MINOR_VERSION
, MESA_GLX_VERSION
);
1830 case GLX_EXTENSIONS
:
1831 return get_extensions();
1843 /* GLX 1.1 and later */
1845 Fake_glXGetClientString( Display
*dpy
, int name
)
1847 static char version
[1000];
1848 sprintf(version
, "%d.%d %s", CLIENT_MAJOR_VERSION
,
1849 CLIENT_MINOR_VERSION
, MESA_GLX_VERSION
);
1854 case GLX_EXTENSIONS
:
1855 return get_extensions();
1873 Fake_glXGetFBConfigAttrib( Display
*dpy
, GLXFBConfig config
,
1874 int attribute
, int *value
)
1876 XMesaVisual v
= (XMesaVisual
) config
;
1880 if (!dpy
|| !config
|| !value
)
1883 return get_config(v
, attribute
, value
, GL_TRUE
);
1887 static GLXFBConfig
*
1888 Fake_glXGetFBConfigs( Display
*dpy
, int screen
, int *nelements
)
1890 XVisualInfo
*visuals
, visTemplate
;
1891 const long visMask
= VisualScreenMask
;
1894 /* Get list of all X visuals */
1895 visTemplate
.screen
= screen
;
1896 visuals
= XGetVisualInfo(dpy
, visMask
, &visTemplate
, nelements
);
1897 if (*nelements
> 0) {
1898 XMesaVisual
*results
;
1899 results
= malloc(*nelements
* sizeof(XMesaVisual
));
1904 for (i
= 0; i
< *nelements
; i
++) {
1905 results
[i
] = create_glx_visual(dpy
, visuals
+ i
);
1908 return (GLXFBConfig
*) results
;
1914 static GLXFBConfig
*
1915 Fake_glXChooseFBConfig( Display
*dpy
, int screen
,
1916 const int *attribList
, int *nitems
)
1920 /* register ourselves as an extension on this display */
1921 register_with_display(dpy
);
1923 if (!attribList
|| !attribList
[0]) {
1924 /* return list of all configs (per GLX_SGIX_fbconfig spec) */
1925 return Fake_glXGetFBConfigs(dpy
, screen
, nitems
);
1928 xmvis
= choose_visual(dpy
, screen
, attribList
, GL_TRUE
);
1930 GLXFBConfig
*config
= malloc(sizeof(XMesaVisual
));
1936 config
[0] = (GLXFBConfig
) xmvis
;
1937 return (GLXFBConfig
*) config
;
1946 static XVisualInfo
*
1947 Fake_glXGetVisualFromFBConfig( Display
*dpy
, GLXFBConfig config
)
1949 if (dpy
&& config
) {
1950 XMesaVisual xmvis
= (XMesaVisual
) config
;
1951 XVisualInfo
* visinfo
= malloc(sizeof(XVisualInfo
));
1953 memcpy(visinfo
, xmvis
->visinfo
, sizeof(XVisualInfo
));
1964 Fake_glXCreateWindow( Display
*dpy
, GLXFBConfig config
, Window win
,
1965 const int *attribList
)
1967 XMesaVisual xmvis
= (XMesaVisual
) config
;
1972 xmbuf
= XMesaCreateWindowBuffer(xmvis
, win
);
1977 (void) attribList
; /* Ignored in GLX 1.3 */
1979 return win
; /* A hack for now */
1984 Fake_glXDestroyWindow( Display
*dpy
, GLXWindow window
)
1986 XMesaBuffer b
= XMesaFindBuffer(dpy
, (XMesaDrawable
) window
);
1988 XMesaDestroyBuffer(b
);
1989 /* don't destroy X window */
1995 Fake_glXCreatePixmap( Display
*dpy
, GLXFBConfig config
, Pixmap pixmap
,
1996 const int *attribList
)
1998 XMesaVisual v
= (XMesaVisual
) config
;
2001 int target
= 0, format
= 0, mipmap
= 0;
2004 if (!dpy
|| !config
|| !pixmap
)
2007 for (attr
= attribList
; attr
&& *attr
; attr
++) {
2009 case GLX_TEXTURE_FORMAT_EXT
:
2012 case GLX_TEXTURE_FORMAT_NONE_EXT
:
2013 case GLX_TEXTURE_FORMAT_RGB_EXT
:
2014 case GLX_TEXTURE_FORMAT_RGBA_EXT
:
2022 case GLX_TEXTURE_TARGET_EXT
:
2025 case GLX_TEXTURE_1D_EXT
:
2026 case GLX_TEXTURE_2D_EXT
:
2027 case GLX_TEXTURE_RECTANGLE_EXT
:
2035 case GLX_MIPMAP_TEXTURE_EXT
:
2046 if (format
== GLX_TEXTURE_FORMAT_RGB_EXT
) {
2047 if (get_config(v
, GLX_BIND_TO_TEXTURE_RGB_EXT
,
2048 &value
, GL_TRUE
) != Success
2050 return 0; /* error! */
2053 else if (format
== GLX_TEXTURE_FORMAT_RGBA_EXT
) {
2054 if (get_config(v
, GLX_BIND_TO_TEXTURE_RGBA_EXT
,
2055 &value
, GL_TRUE
) != Success
2057 return 0; /* error! */
2061 if (get_config(v
, GLX_BIND_TO_MIPMAP_TEXTURE_EXT
,
2062 &value
, GL_TRUE
) != Success
2064 return 0; /* error! */
2067 if (target
== GLX_TEXTURE_1D_EXT
) {
2068 if (get_config(v
, GLX_BIND_TO_TEXTURE_TARGETS_EXT
,
2069 &value
, GL_TRUE
) != Success
2070 || (value
& GLX_TEXTURE_1D_BIT_EXT
) == 0) {
2071 return 0; /* error! */
2074 else if (target
== GLX_TEXTURE_2D_EXT
) {
2075 if (get_config(v
, GLX_BIND_TO_TEXTURE_TARGETS_EXT
,
2076 &value
, GL_TRUE
) != Success
2077 || (value
& GLX_TEXTURE_2D_BIT_EXT
) == 0) {
2078 return 0; /* error! */
2081 if (target
== GLX_TEXTURE_RECTANGLE_EXT
) {
2082 if (get_config(v
, GLX_BIND_TO_TEXTURE_TARGETS_EXT
,
2083 &value
, GL_TRUE
) != Success
2084 || (value
& GLX_TEXTURE_RECTANGLE_BIT_EXT
) == 0) {
2085 return 0; /* error! */
2089 if (format
|| target
|| mipmap
) {
2090 /* texture from pixmap */
2091 b
= XMesaCreatePixmapTextureBuffer(v
, pixmap
, 0, format
, target
, mipmap
);
2094 b
= XMesaCreatePixmapBuffer( v
, pixmap
, 0 );
2105 Fake_glXDestroyPixmap( Display
*dpy
, GLXPixmap pixmap
)
2107 XMesaBuffer b
= XMesaFindBuffer(dpy
, (XMesaDrawable
)pixmap
);
2109 XMesaDestroyBuffer(b
);
2110 /* don't destroy X pixmap */
2115 Fake_glXCreatePbuffer( Display
*dpy
, GLXFBConfig config
,
2116 const int *attribList
)
2118 XMesaVisual xmvis
= (XMesaVisual
) config
;
2121 int width
= 0, height
= 0;
2122 GLboolean useLargest
= GL_FALSE
, preserveContents
= GL_FALSE
;
2126 for (attrib
= attribList
; *attrib
; attrib
++) {
2128 case GLX_PBUFFER_WIDTH
:
2132 case GLX_PBUFFER_HEIGHT
:
2136 case GLX_PRESERVED_CONTENTS
:
2138 preserveContents
= *attrib
;
2140 case GLX_LARGEST_PBUFFER
:
2142 useLargest
= *attrib
;
2149 if (width
== 0 || height
== 0)
2152 if (width
> SWRAST_MAX_WIDTH
|| height
> SWRAST_MAX_HEIGHT
) {
2153 /* If allocation would have failed and GLX_LARGEST_PBUFFER is set,
2154 * allocate the largest possible buffer.
2157 width
= SWRAST_MAX_WIDTH
;
2158 height
= SWRAST_MAX_HEIGHT
;
2162 xmbuf
= XMesaCreatePBuffer( xmvis
, 0, width
, height
);
2163 /* A GLXPbuffer handle must be an X Drawable because that's what
2164 * glXMakeCurrent takes.
2167 xmbuf
->largestPbuffer
= useLargest
;
2168 xmbuf
->preservedContents
= preserveContents
;
2169 return (GLXPbuffer
) xmbuf
->frontxrb
->pixmap
;
2178 Fake_glXDestroyPbuffer( Display
*dpy
, GLXPbuffer pbuf
)
2180 XMesaBuffer b
= XMesaFindBuffer(dpy
, pbuf
);
2182 XMesaDestroyBuffer(b
);
2188 Fake_glXQueryDrawable( Display
*dpy
, GLXDrawable draw
, int attribute
,
2189 unsigned int *value
)
2191 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, draw
);
2195 /* make sure buffer's dimensions are up to date */
2196 xmesa_check_and_update_buffer_size(NULL
, xmbuf
);
2198 switch (attribute
) {
2200 *value
= xmbuf
->mesa_buffer
.Width
;
2203 *value
= xmbuf
->mesa_buffer
.Height
;
2205 case GLX_PRESERVED_CONTENTS
:
2206 *value
= xmbuf
->preservedContents
;
2208 case GLX_LARGEST_PBUFFER
:
2209 *value
= xmbuf
->largestPbuffer
;
2211 case GLX_FBCONFIG_ID
:
2212 *value
= xmbuf
->xm_visual
->visinfo
->visualid
;
2214 case GLX_TEXTURE_FORMAT_EXT
:
2215 *value
= xmbuf
->TextureFormat
;
2217 case GLX_TEXTURE_TARGET_EXT
:
2218 *value
= xmbuf
->TextureTarget
;
2220 case GLX_MIPMAP_TEXTURE_EXT
:
2221 *value
= xmbuf
->TextureMipmap
;
2225 return; /* raise BadValue error */
2231 Fake_glXCreateNewContext( Display
*dpy
, GLXFBConfig config
,
2232 int renderType
, GLXContext shareList
, Bool direct
)
2235 XMesaVisual xmvis
= (XMesaVisual
) config
;
2237 if (!dpy
|| !config
||
2238 (renderType
!= GLX_RGBA_TYPE
&&
2239 renderType
!= GLX_COLOR_INDEX_TYPE
&&
2240 renderType
!= GLX_RGBA_FLOAT_TYPE_ARB
&&
2241 renderType
!= GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT
))
2244 /* deallocate unused windows/buffers */
2245 XMesaGarbageCollect(dpy
);
2247 xmCtx
= XMesaCreateContext(xmvis
, (XMesaContext
) shareList
);
2249 return (GLXContext
) xmCtx
;
2254 Fake_glXQueryContext( Display
*dpy
, GLXContext ctx
, int attribute
, int *value
)
2256 XMesaContext xmctx
= (XMesaContext
) ctx
;
2260 switch (attribute
) {
2261 case GLX_FBCONFIG_ID
:
2262 *value
= xmctx
->xm_visual
->visinfo
->visualid
;
2264 case GLX_RENDER_TYPE
:
2265 *value
= GLX_RGBA_TYPE
;
2271 return GLX_BAD_ATTRIBUTE
;
2278 Fake_glXSelectEvent( Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
2280 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, drawable
);
2282 xmbuf
->selectedEvents
= mask
;
2287 Fake_glXGetSelectedEvent( Display
*dpy
, GLXDrawable drawable
,
2288 unsigned long *mask
)
2290 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, drawable
);
2292 *mask
= xmbuf
->selectedEvents
;
2299 /*** GLX_SGI_swap_control ***/
2302 Fake_glXSwapIntervalSGI(int interval
)
2310 /*** GLX_SGI_video_sync ***/
2312 static unsigned int FrameCounter
= 0;
2315 Fake_glXGetVideoSyncSGI(unsigned int *count
)
2317 /* this is a bogus implementation */
2318 *count
= FrameCounter
++;
2323 Fake_glXWaitVideoSyncSGI(int divisor
, int remainder
, unsigned int *count
)
2325 if (divisor
<= 0 || remainder
< 0)
2326 return GLX_BAD_VALUE
;
2327 /* this is a bogus implementation */
2329 while (FrameCounter
% divisor
!= remainder
)
2331 *count
= FrameCounter
;
2337 /*** GLX_SGI_make_current_read ***/
2340 Fake_glXMakeCurrentReadSGI(Display
*dpy
, GLXDrawable draw
, GLXDrawable read
, GLXContext ctx
)
2342 return Fake_glXMakeContextCurrent( dpy
, draw
, read
, ctx
);
2347 Fake_glXGetCurrentReadDrawableSGI(void)
2354 /*** GLX_SGIX_video_source ***/
2357 static GLXVideoSourceSGIX
2358 Fake_glXCreateGLXVideoSourceSGIX(Display
*dpy
, int screen
, VLServer server
, VLPath path
, int nodeClass
, VLNode drainNode
)
2370 Fake_glXDestroyGLXVideoSourceSGIX(Display
*dpy
, GLXVideoSourceSGIX src
)
2379 /*** GLX_EXT_import_context ***/
2382 Fake_glXFreeContextEXT(Display
*dpy
, GLXContext context
)
2389 Fake_glXGetContextIDEXT(const GLXContext context
)
2396 Fake_glXImportContextEXT(Display
*dpy
, GLXContextID contextID
)
2404 Fake_glXQueryContextInfoEXT(Display
*dpy
, GLXContext context
, int attribute
, int *value
)
2415 /*** GLX_SGIX_fbconfig ***/
2418 Fake_glXGetFBConfigAttribSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int attribute
, int *value
)
2420 return Fake_glXGetFBConfigAttrib(dpy
, config
, attribute
, value
);
2423 static GLXFBConfigSGIX
*
2424 Fake_glXChooseFBConfigSGIX(Display
*dpy
, int screen
, int *attrib_list
, int *nelements
)
2426 return (GLXFBConfig
*) Fake_glXChooseFBConfig(dpy
, screen
, attrib_list
, nelements
);
2431 Fake_glXCreateGLXPixmapWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, Pixmap pixmap
)
2433 XMesaVisual xmvis
= (XMesaVisual
) config
;
2434 XMesaBuffer xmbuf
= XMesaCreatePixmapBuffer(xmvis
, pixmap
, 0);
2435 return xmbuf
->frontxrb
->pixmap
; /* need to return an X ID */
2440 Fake_glXCreateContextWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int render_type
, GLXContext share_list
, Bool direct
)
2443 XMesaVisual xmvis
= (XMesaVisual
) config
;
2445 /* deallocate unused windows/buffers */
2446 XMesaGarbageCollect(dpy
);
2448 xmCtx
= XMesaCreateContext(xmvis
, (XMesaContext
) share_list
);
2450 return (GLXContext
) xmCtx
;
2454 static XVisualInfo
*
2455 Fake_glXGetVisualFromFBConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
)
2457 return Fake_glXGetVisualFromFBConfig(dpy
, config
);
2461 static GLXFBConfigSGIX
2462 Fake_glXGetFBConfigFromVisualSGIX(Display
*dpy
, XVisualInfo
*vis
)
2464 XMesaVisual xmvis
= find_glx_visual(dpy
, vis
);
2466 /* This visual wasn't found with glXChooseVisual() */
2467 xmvis
= create_glx_visual(dpy
, vis
);
2470 return (GLXFBConfigSGIX
) xmvis
;
2475 /*** GLX_SGIX_pbuffer ***/
2477 static GLXPbufferSGIX
2478 Fake_glXCreateGLXPbufferSGIX(Display
*dpy
, GLXFBConfigSGIX config
,
2479 unsigned int width
, unsigned int height
,
2482 XMesaVisual xmvis
= (XMesaVisual
) config
;
2485 GLboolean useLargest
= GL_FALSE
, preserveContents
= GL_FALSE
;
2489 for (attrib
= attribList
; attrib
&& *attrib
; attrib
++) {
2491 case GLX_PRESERVED_CONTENTS_SGIX
:
2493 preserveContents
= *attrib
; /* ignored */
2495 case GLX_LARGEST_PBUFFER_SGIX
:
2497 useLargest
= *attrib
; /* ignored */
2504 /* not used at this time */
2506 (void) preserveContents
;
2508 xmbuf
= XMesaCreatePBuffer( xmvis
, 0, width
, height
);
2509 /* A GLXPbuffer handle must be an X Drawable because that's what
2510 * glXMakeCurrent takes.
2512 return (GLXPbuffer
) xmbuf
->frontxrb
->pixmap
;
2517 Fake_glXDestroyGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
)
2519 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, pbuf
);
2521 XMesaDestroyBuffer(xmbuf
);
2527 Fake_glXQueryGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
, int attribute
, unsigned int *value
)
2529 const XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, pbuf
);
2532 /* Generate GLXBadPbufferSGIX for bad pbuffer */
2536 switch (attribute
) {
2537 case GLX_PRESERVED_CONTENTS_SGIX
:
2538 *value
= xmbuf
->preservedContents
;
2540 case GLX_LARGEST_PBUFFER_SGIX
:
2541 *value
= xmbuf
->largestPbuffer
;
2543 case GLX_WIDTH_SGIX
:
2544 *value
= xmbuf
->mesa_buffer
.Width
;
2546 case GLX_HEIGHT_SGIX
:
2547 *value
= xmbuf
->mesa_buffer
.Height
;
2549 case GLX_EVENT_MASK_SGIX
:
2550 *value
= 0; /* XXX might be wrong */
2559 Fake_glXSelectEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
2561 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, drawable
);
2563 /* Note: we'll never generate clobber events */
2564 xmbuf
->selectedEvents
= mask
;
2570 Fake_glXGetSelectedEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long *mask
)
2572 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, drawable
);
2574 *mask
= xmbuf
->selectedEvents
;
2583 /*** GLX_SGI_cushion ***/
2586 Fake_glXCushionSGI(Display
*dpy
, Window win
, float cushion
)
2595 /*** GLX_SGIX_video_resize ***/
2598 Fake_glXBindChannelToWindowSGIX(Display
*dpy
, int screen
, int channel
, Window window
)
2608 Fake_glXChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int x
, int y
, int w
, int h
)
2621 Fake_glXQueryChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int *x
, int *y
, int *w
, int *h
)
2634 Fake_glXQueryChannelDeltasSGIX(Display
*dpy
, int screen
, int channel
, int *dx
, int *dy
, int *dw
, int *dh
)
2647 Fake_glXChannelRectSyncSGIX(Display
*dpy
, int screen
, int channel
, GLenum synctype
)
2658 /*** GLX_SGIX_dmbuffer **/
2660 #if defined(_DM_BUFFER_H_)
2662 Fake_glXAssociateDMPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuffer
, DMparams
*params
, DMbuffer dmbuffer
)
2673 /*** GLX_SUN_get_transparent_index ***/
2676 Fake_glXGetTransparentIndexSUN(Display
*dpy
, Window overlay
, Window underlay
, unsigned long *pTransparent
)
2681 (void) pTransparent
;
2687 /*** GLX_MESA_release_buffers ***/
2690 * Release the depth, stencil, accum buffers attached to a GLXDrawable
2691 * (a window or pixmap) prior to destroying the GLXDrawable.
2694 Fake_glXReleaseBuffersMESA( Display
*dpy
, GLXDrawable d
)
2696 XMesaBuffer b
= XMesaFindBuffer(dpy
, d
);
2698 XMesaDestroyBuffer(b
);
2706 /*** GLX_EXT_texture_from_pixmap ***/
2709 Fake_glXBindTexImageEXT(Display
*dpy
, GLXDrawable drawable
, int buffer
,
2710 const int *attrib_list
)
2712 XMesaBuffer b
= XMesaFindBuffer(dpy
, drawable
);
2714 XMesaBindTexImage(dpy
, b
, buffer
, attrib_list
);
2718 Fake_glXReleaseTexImageEXT(Display
*dpy
, GLXDrawable drawable
, int buffer
)
2720 XMesaBuffer b
= XMesaFindBuffer(dpy
, drawable
);
2722 XMesaReleaseTexImage(dpy
, b
, buffer
);
2727 Fake_glXCreateContextAttribs(Display
*dpy
, GLXFBConfig config
,
2728 GLXContext share_context
, Bool direct
,
2729 const int *attrib_list
)
2732 XMesaVisual xmvis
= (XMesaVisual
) config
;
2734 int major
= 0, minor
= 0, ctxFlags
= 0, profileFlags
= 0;
2736 for (i
= 0; attrib_list
[i
]; i
+= 2) {
2737 switch (attrib_list
[i
]) {
2738 case GLX_CONTEXT_MAJOR_VERSION_ARB
:
2739 major
= attrib_list
[i
+ 1];
2741 case GLX_CONTEXT_MINOR_VERSION_ARB
:
2742 minor
= attrib_list
[i
+ 1];
2744 case GLX_CONTEXT_FLAGS_ARB
:
2745 ctxFlags
= attrib_list
[i
+ 1];
2747 case GLX_CONTEXT_PROFILE_MASK_ARB
:
2748 profileFlags
= attrib_list
[i
+ 1];
2751 _mesa_warning(NULL
, "Unexpected attribute 0x%x in "
2752 "glXCreateContextAttribs()\n", attrib_list
[i
]);
2757 if (major
* 10 + minor
> 21) {
2758 /* swrast only supports GL 2.1 and earlier */
2762 /* These are ignored for now. We'd have to enhance XMesaCreateContext
2763 * to take these flags and the version, at least.
2766 (void) profileFlags
;
2768 /* deallocate unused windows/buffers */
2769 XMesaGarbageCollect(dpy
);
2771 xmCtx
= XMesaCreateContext(xmvis
, (XMesaContext
) share_context
);
2773 return (GLXContext
) xmCtx
;
2777 /* silence warning */
2778 extern struct _glxapi_table
*_mesa_GetGLXDispatchTable(void);
2782 * Create a new GLX API dispatch table with its function pointers
2783 * initialized to point to Mesa's "fake" GLX API functions.
2784 * Note: there's a similar function (_real_GetGLXDispatchTable) that
2785 * returns a new dispatch table with all pointers initalized to point
2786 * to "real" GLX functions (which understand GLX wire protocol, etc).
2788 struct _glxapi_table
*
2789 _mesa_GetGLXDispatchTable(void)
2791 static struct _glxapi_table glx
;
2793 /* be sure our dispatch table size <= libGL's table */
2795 GLuint size
= sizeof(struct _glxapi_table
) / sizeof(void *);
2797 assert(_glxapi_get_dispatch_table_size() >= size
);
2800 /* initialize the whole table to no-ops */
2801 _glxapi_set_no_op_table(&glx
);
2803 /* now initialize the table with the functions I implement */
2804 glx
.ChooseVisual
= Fake_glXChooseVisual
;
2805 glx
.CopyContext
= Fake_glXCopyContext
;
2806 glx
.CreateContext
= Fake_glXCreateContext
;
2807 glx
.CreateGLXPixmap
= Fake_glXCreateGLXPixmap
;
2808 glx
.DestroyContext
= Fake_glXDestroyContext
;
2809 glx
.DestroyGLXPixmap
= Fake_glXDestroyGLXPixmap
;
2810 glx
.GetConfig
= Fake_glXGetConfig
;
2811 glx
.GetCurrentContext
= Fake_glXGetCurrentContext
;
2812 /*glx.GetCurrentDrawable = Fake_glXGetCurrentDrawable;*/
2813 glx
.IsDirect
= Fake_glXIsDirect
;
2814 glx
.MakeCurrent
= Fake_glXMakeCurrent
;
2815 glx
.QueryExtension
= Fake_glXQueryExtension
;
2816 glx
.QueryVersion
= Fake_glXQueryVersion
;
2817 glx
.SwapBuffers
= Fake_glXSwapBuffers
;
2818 glx
.UseXFont
= Fake_glXUseXFont
;
2819 glx
.WaitGL
= Fake_glXWaitGL
;
2820 glx
.WaitX
= Fake_glXWaitX
;
2822 /*** GLX_VERSION_1_1 ***/
2823 glx
.GetClientString
= Fake_glXGetClientString
;
2824 glx
.QueryExtensionsString
= Fake_glXQueryExtensionsString
;
2825 glx
.QueryServerString
= Fake_glXQueryServerString
;
2827 /*** GLX_VERSION_1_2 ***/
2828 /*glx.GetCurrentDisplay = Fake_glXGetCurrentDisplay;*/
2830 /*** GLX_VERSION_1_3 ***/
2831 glx
.ChooseFBConfig
= Fake_glXChooseFBConfig
;
2832 glx
.CreateNewContext
= Fake_glXCreateNewContext
;
2833 glx
.CreatePbuffer
= Fake_glXCreatePbuffer
;
2834 glx
.CreatePixmap
= Fake_glXCreatePixmap
;
2835 glx
.CreateWindow
= Fake_glXCreateWindow
;
2836 glx
.DestroyPbuffer
= Fake_glXDestroyPbuffer
;
2837 glx
.DestroyPixmap
= Fake_glXDestroyPixmap
;
2838 glx
.DestroyWindow
= Fake_glXDestroyWindow
;
2839 /*glx.GetCurrentReadDrawable = Fake_glXGetCurrentReadDrawable;*/
2840 glx
.GetFBConfigAttrib
= Fake_glXGetFBConfigAttrib
;
2841 glx
.GetFBConfigs
= Fake_glXGetFBConfigs
;
2842 glx
.GetSelectedEvent
= Fake_glXGetSelectedEvent
;
2843 glx
.GetVisualFromFBConfig
= Fake_glXGetVisualFromFBConfig
;
2844 glx
.MakeContextCurrent
= Fake_glXMakeContextCurrent
;
2845 glx
.QueryContext
= Fake_glXQueryContext
;
2846 glx
.QueryDrawable
= Fake_glXQueryDrawable
;
2847 glx
.SelectEvent
= Fake_glXSelectEvent
;
2849 /*** GLX_SGI_swap_control ***/
2850 glx
.SwapIntervalSGI
= Fake_glXSwapIntervalSGI
;
2852 /*** GLX_SGI_video_sync ***/
2853 glx
.GetVideoSyncSGI
= Fake_glXGetVideoSyncSGI
;
2854 glx
.WaitVideoSyncSGI
= Fake_glXWaitVideoSyncSGI
;
2856 /*** GLX_SGI_make_current_read ***/
2857 glx
.MakeCurrentReadSGI
= Fake_glXMakeCurrentReadSGI
;
2858 /*glx.GetCurrentReadDrawableSGI = Fake_glXGetCurrentReadDrawableSGI;*/
2860 /*** GLX_SGIX_video_source ***/
2862 glx
.CreateGLXVideoSourceSGIX
= Fake_glXCreateGLXVideoSourceSGIX
;
2863 glx
.DestroyGLXVideoSourceSGIX
= Fake_glXDestroyGLXVideoSourceSGIX
;
2866 /*** GLX_EXT_import_context ***/
2867 glx
.FreeContextEXT
= Fake_glXFreeContextEXT
;
2868 glx
.GetContextIDEXT
= Fake_glXGetContextIDEXT
;
2869 /*glx.GetCurrentDisplayEXT = Fake_glXGetCurrentDisplayEXT;*/
2870 glx
.ImportContextEXT
= Fake_glXImportContextEXT
;
2871 glx
.QueryContextInfoEXT
= Fake_glXQueryContextInfoEXT
;
2873 /*** GLX_SGIX_fbconfig ***/
2874 glx
.GetFBConfigAttribSGIX
= Fake_glXGetFBConfigAttribSGIX
;
2875 glx
.ChooseFBConfigSGIX
= Fake_glXChooseFBConfigSGIX
;
2876 glx
.CreateGLXPixmapWithConfigSGIX
= Fake_glXCreateGLXPixmapWithConfigSGIX
;
2877 glx
.CreateContextWithConfigSGIX
= Fake_glXCreateContextWithConfigSGIX
;
2878 glx
.GetVisualFromFBConfigSGIX
= Fake_glXGetVisualFromFBConfigSGIX
;
2879 glx
.GetFBConfigFromVisualSGIX
= Fake_glXGetFBConfigFromVisualSGIX
;
2881 /*** GLX_SGIX_pbuffer ***/
2882 glx
.CreateGLXPbufferSGIX
= Fake_glXCreateGLXPbufferSGIX
;
2883 glx
.DestroyGLXPbufferSGIX
= Fake_glXDestroyGLXPbufferSGIX
;
2884 glx
.QueryGLXPbufferSGIX
= Fake_glXQueryGLXPbufferSGIX
;
2885 glx
.SelectEventSGIX
= Fake_glXSelectEventSGIX
;
2886 glx
.GetSelectedEventSGIX
= Fake_glXGetSelectedEventSGIX
;
2888 /*** GLX_SGI_cushion ***/
2889 glx
.CushionSGI
= Fake_glXCushionSGI
;
2891 /*** GLX_SGIX_video_resize ***/
2892 glx
.BindChannelToWindowSGIX
= Fake_glXBindChannelToWindowSGIX
;
2893 glx
.ChannelRectSGIX
= Fake_glXChannelRectSGIX
;
2894 glx
.QueryChannelRectSGIX
= Fake_glXQueryChannelRectSGIX
;
2895 glx
.QueryChannelDeltasSGIX
= Fake_glXQueryChannelDeltasSGIX
;
2896 glx
.ChannelRectSyncSGIX
= Fake_glXChannelRectSyncSGIX
;
2898 /*** GLX_SGIX_dmbuffer **/
2899 #if defined(_DM_BUFFER_H_)
2900 glx
.AssociateDMPbufferSGIX
= NULL
;
2903 /*** GLX_SUN_get_transparent_index ***/
2904 glx
.GetTransparentIndexSUN
= Fake_glXGetTransparentIndexSUN
;
2906 /*** GLX_MESA_copy_sub_buffer ***/
2907 glx
.CopySubBufferMESA
= Fake_glXCopySubBufferMESA
;
2909 /*** GLX_MESA_release_buffers ***/
2910 glx
.ReleaseBuffersMESA
= Fake_glXReleaseBuffersMESA
;
2912 /*** GLX_MESA_pixmap_colormap ***/
2913 glx
.CreateGLXPixmapMESA
= Fake_glXCreateGLXPixmapMESA
;
2915 /*** GLX_EXT_texture_from_pixmap ***/
2916 glx
.BindTexImageEXT
= Fake_glXBindTexImageEXT
;
2917 glx
.ReleaseTexImageEXT
= Fake_glXReleaseTexImageEXT
;
2919 glx
.CreateContextAttribs
= Fake_glXCreateContextAttribs
;