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/imports.h"
51 #include "main/mtypes.h"
52 #include "main/version.h"
55 #include "util/u_math.h"
57 /* This indicates the client-side GLX API and GLX encoder version. */
58 #define CLIENT_MAJOR_VERSION 1
59 #define CLIENT_MINOR_VERSION 4 /* but don't have 1.3's pbuffers, etc yet */
61 /* This indicates the server-side GLX decoder version.
62 * GLX 1.4 indicates OpenGL 1.3 support
64 #define SERVER_MAJOR_VERSION 1
65 #define SERVER_MINOR_VERSION 4
67 /* This is appended onto the glXGetClient/ServerString version strings. */
68 #define MESA_GLX_VERSION "Mesa " PACKAGE_VERSION
70 /* Who implemented this GLX? */
71 #define VENDOR "Brian Paul"
74 "GLX_MESA_set_3dfx_mode " \
75 "GLX_MESA_copy_sub_buffer " \
76 "GLX_MESA_pixmap_colormap " \
77 "GLX_MESA_release_buffers " \
78 "GLX_ARB_create_context " \
79 "GLX_ARB_get_proc_address " \
80 "GLX_EXT_texture_from_pixmap " \
81 "GLX_EXT_visual_info " \
82 "GLX_EXT_visual_rating " \
83 /*"GLX_SGI_video_sync "*/ \
84 "GLX_SGIX_fbconfig " \
89 /**********************************************************************/
90 /*** GLX Visual Code ***/
91 /**********************************************************************/
96 static XMesaVisual
*VisualTable
= NULL
;
97 static int NumVisuals
= 0;
101 * This struct and some code fragments borrowed
102 * from Mark Kilgard's GLUT library.
104 typedef struct _OverlayInfo
{
105 /* Avoid 64-bit portability problems by being careful to use
106 longs due to the way XGetWindowProperty is specified. Note
107 that these parameters are passed as CARD32s over X
109 unsigned long overlay_visual
;
110 long transparent_type
;
117 /* Macro to handle c_class vs class field name in XVisualInfo struct */
118 #if defined(__cplusplus) || defined(c_plusplus)
119 #define CLASS c_class
127 * Test if the given XVisualInfo is usable for Mesa rendering.
130 is_usable_visual( XVisualInfo
*vinfo
)
132 switch (vinfo
->CLASS
) {
135 /* Any StaticGray/GrayScale visual works in RGB or CI mode */
139 /* Color-index rendering is not supported. */
143 /* Any depth of TrueColor or DirectColor works in RGB mode */
146 /* This should never happen */
154 * Get an array OverlayInfo records for specified screen.
155 * \param dpy the display
156 * \param screen screen number
157 * \param numOverlays returns numver of OverlayInfo records
158 * \return pointer to OverlayInfo array, free with XFree()
161 GetOverlayInfo(Display
*dpy
, int screen
, int *numOverlays
)
163 Atom overlayVisualsAtom
;
166 unsigned char *ovInfo
;
167 unsigned long sizeData
, bytesLeft
;
171 * The SERVER_OVERLAY_VISUALS property on the root window contains
172 * a list of overlay visuals. Get that list now.
174 overlayVisualsAtom
= XInternAtom(dpy
,"SERVER_OVERLAY_VISUALS", True
);
175 if (overlayVisualsAtom
== None
) {
179 status
= XGetWindowProperty(dpy
, RootWindow(dpy
, screen
),
180 overlayVisualsAtom
, 0L, (long) 10000, False
,
181 overlayVisualsAtom
, &actualType
, &actualFormat
,
182 &sizeData
, &bytesLeft
,
185 if (status
!= Success
|| actualType
!= overlayVisualsAtom
||
186 actualFormat
!= 32 || sizeData
< 4) {
187 /* something went wrong */
188 free((void *) ovInfo
);
193 *numOverlays
= sizeData
/ 4;
194 return (OverlayInfo
*) ovInfo
;
200 * Return the level (overlay, normal, underlay) of a given XVisualInfo.
201 * Input: dpy - the X display
202 * vinfo - the XVisualInfo to test
203 * Return: level of the visual:
205 * >0 = overlay planes
206 * <0 = underlay planes
209 level_of_visual( Display
*dpy
, XVisualInfo
*vinfo
)
211 OverlayInfo
*overlay_info
;
212 int numOverlaysPerScreen
, i
;
214 overlay_info
= GetOverlayInfo(dpy
, vinfo
->screen
, &numOverlaysPerScreen
);
219 /* search the overlay visual list for the visual ID of interest */
220 for (i
= 0; i
< numOverlaysPerScreen
; i
++) {
221 const OverlayInfo
*ov
= overlay_info
+ i
;
222 if (ov
->overlay_visual
== vinfo
->visualid
) {
223 /* found the visual */
224 if (/*ov->transparent_type==1 &&*/ ov
->layer
!=0) {
225 int level
= ov
->layer
;
226 free((void *) overlay_info
);
230 free((void *) overlay_info
);
236 /* The visual ID was not found in the overlay list. */
237 free((void *) overlay_info
);
245 * Given an XVisualInfo and RGB, Double, and Depth buffer flags, save the
246 * configuration in our list of GLX visuals.
249 save_glx_visual( Display
*dpy
, XVisualInfo
*vinfo
,
250 GLboolean alphaFlag
, GLboolean dbFlag
,
251 GLboolean stereoFlag
,
252 GLint depth_size
, GLint stencil_size
,
253 GLint accumRedSize
, GLint accumGreenSize
,
254 GLint accumBlueSize
, GLint accumAlphaSize
,
255 GLint level
, GLint numAuxBuffers
)
257 GLboolean ximageFlag
= GL_TRUE
;
262 /* Check if the MESA_BACK_BUFFER env var is set */
263 char *backbuffer
= getenv("MESA_BACK_BUFFER");
265 if (backbuffer
[0]=='p' || backbuffer
[0]=='P') {
266 ximageFlag
= GL_FALSE
;
268 else if (backbuffer
[0]=='x' || backbuffer
[0]=='X') {
269 ximageFlag
= GL_TRUE
;
272 _mesa_warning(NULL
, "Mesa: invalid value for MESA_BACK_BUFFER environment variable, using an XImage.");
278 /* stereo not supported */
283 /* Force the visual to have an alpha channel */
284 if (getenv("MESA_GLX_FORCE_ALPHA"))
287 /* First check if a matching visual is already in the list */
288 for (i
=0; i
<NumVisuals
; i
++) {
289 XMesaVisual v
= VisualTable
[i
];
290 if (v
->display
== dpy
291 && v
->mesa_visual
.level
== level
292 && v
->mesa_visual
.numAuxBuffers
== numAuxBuffers
293 && v
->ximage_flag
== ximageFlag
294 && v
->mesa_visual
.doubleBufferMode
== dbFlag
295 && v
->mesa_visual
.stereoMode
== stereoFlag
296 && (v
->mesa_visual
.alphaBits
> 0) == alphaFlag
297 && (v
->mesa_visual
.depthBits
>= depth_size
|| depth_size
== 0)
298 && (v
->mesa_visual
.stencilBits
>= stencil_size
|| stencil_size
== 0)
299 && (v
->mesa_visual
.accumRedBits
>= accumRedSize
|| accumRedSize
== 0)
300 && (v
->mesa_visual
.accumGreenBits
>= accumGreenSize
|| accumGreenSize
== 0)
301 && (v
->mesa_visual
.accumBlueBits
>= accumBlueSize
|| accumBlueSize
== 0)
302 && (v
->mesa_visual
.accumAlphaBits
>= accumAlphaSize
|| accumAlphaSize
== 0)) {
303 /* now compare visual IDs */
304 if (v
->visinfo
->visualid
== vinfo
->visualid
) {
310 /* Create a new visual and add it to the list. */
312 xmvis
= XMesaCreateVisual( dpy
, vinfo
, GL_TRUE
, alphaFlag
, dbFlag
,
313 stereoFlag
, ximageFlag
,
314 depth_size
, stencil_size
,
315 accumRedSize
, accumBlueSize
,
316 accumBlueSize
, accumAlphaSize
, 0, level
,
319 /* Allocate more space for additional visual */
320 VisualTable
= realloc(VisualTable
, sizeof(XMesaVisual
) * (NumVisuals
+ 1));
321 /* add xmvis to the list */
322 VisualTable
[NumVisuals
] = xmvis
;
324 /* XXX minor hack, because XMesaCreateVisual doesn't support an
325 * aux buffers parameter.
327 xmvis
->mesa_visual
.numAuxBuffers
= numAuxBuffers
;
334 * Return the default number of bits for the Z buffer.
335 * If defined, use the MESA_GLX_DEPTH_BITS env var value.
336 * Otherwise, use the DEFAULT_SOFTWARE_DEPTH_BITS constant.
337 * XXX probably do the same thing for stencil, accum, etc.
340 default_depth_bits(void)
343 const char *zEnv
= getenv("MESA_GLX_DEPTH_BITS");
347 zBits
= DEFAULT_SOFTWARE_DEPTH_BITS
;
352 default_alpha_bits(void)
355 const char *aEnv
= getenv("MESA_GLX_ALPHA_BITS");
364 default_accum_bits(void)
372 * Create a GLX visual from a regular XVisualInfo.
373 * This is called when Fake GLX is given an XVisualInfo which wasn't
374 * returned by glXChooseVisual. Since this is the first time we're
375 * considering this visual we'll take a guess at reasonable values
376 * for depth buffer size, stencil size, accum size, etc.
377 * This is the best we can do with a client-side emulation of GLX.
380 create_glx_visual( Display
*dpy
, XVisualInfo
*visinfo
)
383 GLint zBits
= default_depth_bits();
384 GLint accBits
= default_accum_bits();
385 GLboolean alphaFlag
= default_alpha_bits() > 0;
387 vislevel
= level_of_visual( dpy
, visinfo
);
389 /* Color-index rendering to overlays is not supported. */
392 else if (is_usable_visual( visinfo
)) {
393 /* Configure this visual as RGB, double-buffered, depth-buffered. */
394 /* This is surely wrong for some people's needs but what else */
395 /* can be done? They should use glXChooseVisual(). */
396 return save_glx_visual( dpy
, visinfo
,
397 alphaFlag
, /* alpha */
398 GL_TRUE
, /* double */
399 GL_FALSE
, /* stereo */
401 8, /* stencil bits */
411 _mesa_warning(NULL
, "Mesa: error in glXCreateContext: bad visual\n");
419 * Find the GLX visual associated with an XVisualInfo.
422 find_glx_visual( Display
*dpy
, XVisualInfo
*vinfo
)
426 /* try to match visual id */
427 for (i
=0;i
<NumVisuals
;i
++) {
428 if (VisualTable
[i
]->display
==dpy
429 && VisualTable
[i
]->visinfo
->visualid
== vinfo
->visualid
) {
430 return VisualTable
[i
];
440 * Return the transparent pixel value for a GLX visual.
441 * Input: glxvis - the glx_visual
442 * Return: a pixel value or -1 if no transparent pixel
445 transparent_pixel( XMesaVisual glxvis
)
447 Display
*dpy
= glxvis
->display
;
448 XVisualInfo
*vinfo
= glxvis
->visinfo
;
449 OverlayInfo
*overlay_info
;
450 int numOverlaysPerScreen
, i
;
452 overlay_info
= GetOverlayInfo(dpy
, vinfo
->screen
, &numOverlaysPerScreen
);
457 for (i
= 0; i
< numOverlaysPerScreen
; i
++) {
458 const OverlayInfo
*ov
= overlay_info
+ i
;
459 if (ov
->overlay_visual
== vinfo
->visualid
) {
461 if (ov
->transparent_type
== 0) {
462 /* type 0 indicates no transparency */
463 free((void *) overlay_info
);
467 /* ov->value is the transparent pixel */
468 free((void *) overlay_info
);
474 /* The visual ID was not found in the overlay list. */
475 free((void *) overlay_info
);
482 * Try to get an X visual which matches the given arguments.
485 get_visual( Display
*dpy
, int scr
, unsigned int depth
, int xclass
)
487 XVisualInfo temp
, *vis
;
490 unsigned int default_depth
;
493 mask
= VisualScreenMask
| VisualDepthMask
| VisualClassMask
;
498 default_depth
= DefaultDepth(dpy
,scr
);
499 default_class
= DefaultVisual(dpy
,scr
)->CLASS
;
501 if (depth
==default_depth
&& xclass
==default_class
) {
502 /* try to get root window's visual */
503 temp
.visualid
= DefaultVisual(dpy
,scr
)->visualid
;
504 mask
|= VisualIDMask
;
507 vis
= XGetVisualInfo( dpy
, mask
, &temp
, &n
);
509 /* In case bits/pixel > 24, make sure color channels are still <=8 bits.
510 * An SGI Infinite Reality system, for example, can have 30bpp pixels:
511 * 10 bits per color channel. Mesa's limited to a max of 8 bits/channel.
513 if (vis
&& depth
> 24 && (xclass
==TrueColor
|| xclass
==DirectColor
)) {
514 if (util_bitcount((GLuint
) vis
->red_mask
) <= 8 &&
515 util_bitcount((GLuint
) vis
->green_mask
) <= 8 &&
516 util_bitcount((GLuint
) vis
->blue_mask
) <= 8) {
531 * Retrieve the value of the given environment variable and find
532 * the X visual which matches it.
533 * Input: dpy - the display
534 * screen - the screen number
535 * varname - the name of the environment variable
536 * Return: an XVisualInfo pointer to NULL if error.
539 get_env_visual(Display
*dpy
, int scr
, const char *varname
)
541 char value
[100], type
[100];
542 int depth
, xclass
= -1;
545 if (!getenv( varname
)) {
549 strncpy( value
, getenv(varname
), 100 );
552 sscanf( value
, "%s %d", type
, &depth
);
554 if (strcmp(type
,"TrueColor")==0) xclass
= TrueColor
;
555 else if (strcmp(type
,"DirectColor")==0) xclass
= DirectColor
;
556 else if (strcmp(type
,"GrayScale")==0) xclass
= GrayScale
;
557 else if (strcmp(type
,"StaticGray")==0) xclass
= StaticGray
;
559 if (xclass
>-1 && depth
>0) {
560 vis
= get_visual( dpy
, scr
, depth
, xclass
);
566 _mesa_warning(NULL
, "GLX unable to find visual class=%s, depth=%d.",
575 * Select an X visual which satisfies the RGBA/CI flag and minimum depth.
576 * Input: dpy, screen - X display and screen number
577 * min_depth - minimum visual depth
578 * preferred_class - preferred GLX visual class or DONT_CARE
579 * Return: pointer to an XVisualInfo or NULL.
582 choose_x_visual(Display
*dpy
, int screen
, int min_depth
, int preferred_class
)
585 int xclass
, visclass
= 0;
588 /* First see if the MESA_RGB_VISUAL env var is defined */
589 vis
= get_env_visual( dpy
, screen
, "MESA_RGB_VISUAL" );
593 /* Otherwise, search for a suitable visual */
594 if (preferred_class
==DONT_CARE
) {
595 for (xclass
=0;xclass
<4;xclass
++) {
597 case 0: visclass
= TrueColor
; break;
598 case 1: visclass
= DirectColor
; break;
599 case 2: visclass
= GrayScale
; break;
600 case 3: visclass
= StaticGray
; break;
603 /* start with shallowest */
604 for (depth
=0;depth
<=32;depth
++) {
605 vis
= get_visual( dpy
, screen
, depth
, visclass
);
612 /* start with deepest */
613 for (depth
=32;depth
>=min_depth
;depth
--) {
614 vis
= get_visual( dpy
, screen
, depth
, visclass
);
623 /* search for a specific visual class */
624 switch (preferred_class
) {
625 case GLX_TRUE_COLOR_EXT
: visclass
= TrueColor
; break;
626 case GLX_DIRECT_COLOR_EXT
: visclass
= DirectColor
; break;
627 case GLX_GRAY_SCALE_EXT
: visclass
= GrayScale
; break;
628 case GLX_STATIC_GRAY_EXT
: visclass
= StaticGray
; break;
629 case GLX_PSEUDO_COLOR_EXT
:
630 case GLX_STATIC_COLOR_EXT
:
631 default: return NULL
;
634 /* start with shallowest */
635 for (depth
=0;depth
<=32;depth
++) {
636 vis
= get_visual( dpy
, screen
, depth
, visclass
);
643 /* start with deepest */
644 for (depth
=32;depth
>=min_depth
;depth
--) {
645 vis
= get_visual( dpy
, screen
, depth
, visclass
);
653 /* didn't find a visual */
660 * Find the deepest X over/underlay visual of at least min_depth.
661 * Input: dpy, screen - X display and screen number
662 * level - the over/underlay level
663 * trans_type - transparent pixel type: GLX_NONE_EXT,
664 * GLX_TRANSPARENT_RGB_EXT, GLX_TRANSPARENT_INDEX_EXT,
666 * trans_value - transparent pixel value or DONT_CARE
667 * min_depth - minimum visual depth
668 * preferred_class - preferred GLX visual class or DONT_CARE
669 * Return: pointer to an XVisualInfo or NULL.
672 choose_x_overlay_visual( Display
*dpy
, int scr
,
673 int level
, int trans_type
, int trans_value
,
674 int min_depth
, int preferred_class
)
676 OverlayInfo
*overlay_info
;
677 int numOverlaysPerScreen
;
679 XVisualInfo
*deepvis
;
682 /*DEBUG int tt, tv; */
684 switch (preferred_class
) {
685 case GLX_TRUE_COLOR_EXT
: preferred_class
= TrueColor
; break;
686 case GLX_DIRECT_COLOR_EXT
: preferred_class
= DirectColor
; break;
687 case GLX_PSEUDO_COLOR_EXT
: preferred_class
= PseudoColor
; break;
688 case GLX_STATIC_COLOR_EXT
: preferred_class
= StaticColor
; break;
689 case GLX_GRAY_SCALE_EXT
: preferred_class
= GrayScale
; break;
690 case GLX_STATIC_GRAY_EXT
: preferred_class
= StaticGray
; break;
691 default: preferred_class
= DONT_CARE
;
694 overlay_info
= GetOverlayInfo(dpy
, scr
, &numOverlaysPerScreen
);
699 /* Search for the deepest overlay which satisifies all criteria. */
703 for (i
= 0; i
< numOverlaysPerScreen
; i
++) {
704 const OverlayInfo
*ov
= overlay_info
+ i
;
705 XVisualInfo
*vislist
, vistemplate
;
708 if (ov
->layer
!=level
) {
709 /* failed overlay level criteria */
712 if (!(trans_type
==DONT_CARE
713 || (trans_type
==GLX_TRANSPARENT_INDEX_EXT
714 && ov
->transparent_type
>0)
715 || (trans_type
==GLX_NONE_EXT
&& ov
->transparent_type
==0))) {
716 /* failed transparent pixel type criteria */
719 if (trans_value
!=DONT_CARE
&& trans_value
!=ov
->value
) {
720 /* failed transparent pixel value criteria */
724 /* get XVisualInfo and check the depth */
725 vistemplate
.visualid
= ov
->overlay_visual
;
726 vistemplate
.screen
= scr
;
727 vislist
= XGetVisualInfo( dpy
, VisualIDMask
| VisualScreenMask
,
728 &vistemplate
, &count
);
736 /* something went wrong */
740 if (preferred_class
!=DONT_CARE
&& preferred_class
!=vislist
->CLASS
) {
741 /* wrong visual class */
746 /* Color-index rendering is not supported. Make sure we have True/DirectColor */
747 if (vislist
->CLASS
!= TrueColor
&& vislist
->CLASS
!= DirectColor
) {
752 if (deepvis
!=NULL
&& vislist
->depth
<= deepest
) {
757 /* YES! found a satisfactory visual */
759 deepest
= vislist
->depth
;
761 /* DEBUG tt = ov->transparent_type;*/
762 /* DEBUG tv = ov->value; */
767 printf("chose 0x%x: layer=%d depth=%d trans_type=%d trans_value=%d\n",
768 deepvis->visualid, level, deepvis->depth, tt, tv );
775 /**********************************************************************/
776 /*** Display-related functions ***/
777 /**********************************************************************/
781 * Free all XMesaVisuals which are associated with the given display.
784 destroy_visuals_on_display(Display
*dpy
)
787 for (i
= 0; i
< NumVisuals
; i
++) {
788 if (VisualTable
[i
]->display
== dpy
) {
789 /* remove this visual */
791 XMesaDestroyVisual(VisualTable
[i
]);
792 for (j
= i
; j
< NumVisuals
- 1; j
++)
793 VisualTable
[j
] = VisualTable
[j
+ 1];
801 * Called from XCloseDisplay() to let us free our display-related data.
804 close_display_callback(Display
*dpy
, XExtCodes
*codes
)
806 destroy_visuals_on_display(dpy
);
807 xmesa_destroy_buffers_on_display(dpy
);
813 * Look for the named extension on given display and return a pointer
814 * to the _XExtension data, or NULL if extension not found.
817 lookup_extension(Display
*dpy
, const char *extName
)
820 for (ext
= dpy
->ext_procs
; ext
; ext
= ext
->next
) {
821 if (ext
->name
&& strcmp(ext
->name
, extName
) == 0) {
830 * Whenever we're given a new Display pointer, call this function to
831 * register our close_display_callback function.
834 register_with_display(Display
*dpy
)
836 const char *extName
= "MesaGLX";
839 ext
= lookup_extension(dpy
, extName
);
841 XExtCodes
*c
= XAddExtension(dpy
);
842 ext
= dpy
->ext_procs
; /* new extension is at head of list */
843 assert(c
->extension
== ext
->codes
.extension
);
844 (void) c
; /* silence warning */
845 ext
->name
= strdup(extName
);
846 ext
->close_display
= close_display_callback
;
851 /**********************************************************************/
852 /*** Begin Fake GLX API Functions ***/
853 /**********************************************************************/
857 * Helper used by glXChooseVisual and glXChooseFBConfig.
858 * The fbConfig parameter must be GL_FALSE for the former and GL_TRUE for
860 * In either case, the attribute list is terminated with the value 'None'.
863 choose_visual( Display
*dpy
, int screen
, const int *list
, GLboolean fbConfig
)
865 const GLboolean rgbModeDefault
= fbConfig
;
866 const int *parselist
;
869 int min_red
=0, min_green
=0, min_blue
=0;
870 GLboolean rgb_flag
= rgbModeDefault
;
871 GLboolean alpha_flag
= GL_FALSE
;
872 GLboolean double_flag
= GL_FALSE
;
873 GLboolean stereo_flag
= GL_FALSE
;
874 GLint depth_size
= 0;
875 GLint stencil_size
= 0;
876 GLint accumRedSize
= 0;
877 GLint accumGreenSize
= 0;
878 GLint accumBlueSize
= 0;
879 GLint accumAlphaSize
= 0;
881 int visual_type
= DONT_CARE
;
882 int trans_type
= DONT_CARE
;
883 int trans_value
= DONT_CARE
;
884 GLint caveat
= DONT_CARE
;
885 XMesaVisual xmvis
= NULL
;
886 int desiredVisualID
= -1;
894 parselist
[1] == GLX_DONT_CARE
&&
895 parselist
[0] != GLX_LEVEL
) {
896 /* For glXChooseFBConfig(), skip attributes whose value is
897 * GLX_DONT_CARE (-1), unless it's GLX_LEVEL (which can legitimately be
900 * From page 17 (23 of the pdf) of the GLX 1.4 spec:
901 * GLX DONT CARE may be specified for all attributes except GLX LEVEL.
907 switch (*parselist
) {
918 case GLX_BUFFER_SIZE
:
920 min_ci
= *parselist
++;
924 level
= *parselist
++;
936 case GLX_DOUBLEBUFFER
:
939 double_flag
= *parselist
++;
942 double_flag
= GL_TRUE
;
948 stereo_flag
= *parselist
++;
951 stereo_flag
= GL_TRUE
;
954 case GLX_AUX_BUFFERS
:
956 numAux
= *parselist
++;
957 if (numAux
> MAX_AUX_BUFFERS
)
962 min_red
= *parselist
++;
966 min_green
= *parselist
++;
970 min_blue
= *parselist
++;
975 GLint size
= *parselist
++;
976 alpha_flag
= size
? GL_TRUE
: GL_FALSE
;
981 depth_size
= *parselist
++;
983 case GLX_STENCIL_SIZE
:
985 stencil_size
= *parselist
++;
987 case GLX_ACCUM_RED_SIZE
:
990 GLint size
= *parselist
++;
991 accumRedSize
= MAX2( accumRedSize
, size
);
994 case GLX_ACCUM_GREEN_SIZE
:
997 GLint size
= *parselist
++;
998 accumGreenSize
= MAX2( accumGreenSize
, size
);
1001 case GLX_ACCUM_BLUE_SIZE
:
1004 GLint size
= *parselist
++;
1005 accumBlueSize
= MAX2( accumBlueSize
, size
);
1008 case GLX_ACCUM_ALPHA_SIZE
:
1011 GLint size
= *parselist
++;
1012 accumAlphaSize
= MAX2( accumAlphaSize
, size
);
1017 * GLX_EXT_visual_info extension
1019 case GLX_X_VISUAL_TYPE_EXT
:
1021 visual_type
= *parselist
++;
1023 case GLX_TRANSPARENT_TYPE_EXT
:
1025 trans_type
= *parselist
++;
1027 case GLX_TRANSPARENT_INDEX_VALUE_EXT
:
1029 trans_value
= *parselist
++;
1031 case GLX_TRANSPARENT_RED_VALUE_EXT
:
1032 case GLX_TRANSPARENT_GREEN_VALUE_EXT
:
1033 case GLX_TRANSPARENT_BLUE_VALUE_EXT
:
1034 case GLX_TRANSPARENT_ALPHA_VALUE_EXT
:
1041 * GLX_EXT_visual_info extension
1043 case GLX_VISUAL_CAVEAT_EXT
:
1045 caveat
= *parselist
++; /* ignored for now */
1049 * GLX_ARB_multisample
1051 case GLX_SAMPLE_BUFFERS_ARB
:
1052 case GLX_SAMPLES_ARB
:
1054 if (*parselist
++ != 0)
1055 /* ms not supported */
1062 case GLX_RENDER_TYPE
:
1066 if (*parselist
& GLX_RGBA_BIT
) {
1069 else if (*parselist
& GLX_COLOR_INDEX_BIT
) {
1070 rgb_flag
= GL_FALSE
;
1072 else if (*parselist
& (GLX_RGBA_FLOAT_BIT_ARB
|GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT
)) {
1075 else if (*parselist
== 0) {
1080 case GLX_DRAWABLE_TYPE
:
1084 if (*parselist
& ~(GLX_WINDOW_BIT
| GLX_PIXMAP_BIT
| GLX_PBUFFER_BIT
)) {
1085 return NULL
; /* bad bit */
1089 case GLX_FBCONFIG_ID
:
1094 desiredVisualID
= *parselist
++;
1096 case GLX_X_RENDERABLE
:
1097 case GLX_MAX_PBUFFER_WIDTH
:
1098 case GLX_MAX_PBUFFER_HEIGHT
:
1099 case GLX_MAX_PBUFFER_PIXELS
:
1106 case GLX_BIND_TO_TEXTURE_RGB_EXT
:
1107 parselist
++; /*skip*/
1109 case GLX_BIND_TO_TEXTURE_RGBA_EXT
:
1110 parselist
++; /*skip*/
1112 case GLX_BIND_TO_MIPMAP_TEXTURE_EXT
:
1113 parselist
++; /*skip*/
1115 case GLX_BIND_TO_TEXTURE_TARGETS_EXT
:
1117 if (*parselist
& ~(GLX_TEXTURE_1D_BIT_EXT
|
1118 GLX_TEXTURE_2D_BIT_EXT
|
1119 GLX_TEXTURE_RECTANGLE_BIT_EXT
)) {
1124 case GLX_Y_INVERTED_EXT
:
1125 parselist
++; /*skip*/
1133 /* undefined attribute */
1134 _mesa_warning(NULL
, "unexpected attrib 0x%x in choose_visual()",
1147 * Since we're only simulating the GLX extension this function will never
1148 * find any real GL visuals. Instead, all we can do is try to find an RGB
1149 * or CI visual of appropriate depth. Other requested attributes such as
1150 * double buffering, depth buffer, etc. will be associated with the X
1151 * visual and stored in the VisualTable[].
1153 if (desiredVisualID
!= -1) {
1154 /* try to get a specific visual, by visualID */
1157 temp
.visualid
= desiredVisualID
;
1158 temp
.screen
= screen
;
1159 vis
= XGetVisualInfo(dpy
, VisualIDMask
| VisualScreenMask
, &temp
, &n
);
1161 /* give the visual some useful GLX attributes */
1162 double_flag
= GL_TRUE
;
1163 if (vis
->depth
<= 8)
1165 depth_size
= default_depth_bits();
1172 int min_rgb
= min_red
+ min_green
+ min_blue
;
1173 if (min_rgb
>1 && min_rgb
<8) {
1174 /* a special case to be sure we can get a monochrome visual */
1179 vis
= choose_x_visual(dpy
, screen
, min_rgb
, visual_type
);
1182 vis
= choose_x_overlay_visual(dpy
, screen
, level
,
1183 trans_type
, trans_value
, min_rgb
, visual_type
);
1188 /* Note: we're not exactly obeying the glXChooseVisual rules here.
1189 * When GLX_DEPTH_SIZE = 1 is specified we're supposed to choose the
1190 * largest depth buffer size, which is 32bits/value. Instead, we
1191 * return 16 to maintain performance with earlier versions of Mesa.
1193 if (depth_size
> 24)
1195 else if (depth_size
> 16)
1197 else if (depth_size
> 0) {
1198 depth_size
= default_depth_bits();
1202 alpha_flag
= default_alpha_bits() > 0;
1205 /* we only support one size of stencil and accum buffers. */
1206 if (stencil_size
> 0)
1208 if (accumRedSize
> 0 || accumGreenSize
> 0 || accumBlueSize
> 0 ||
1209 accumAlphaSize
> 0) {
1212 accumBlueSize
= default_accum_bits();
1213 accumAlphaSize
= alpha_flag
? accumRedSize
: 0;
1216 xmvis
= save_glx_visual( dpy
, vis
, alpha_flag
, double_flag
,
1217 stereo_flag
, depth_size
, stencil_size
,
1218 accumRedSize
, accumGreenSize
,
1219 accumBlueSize
, accumAlphaSize
, level
, numAux
);
1227 static XVisualInfo
*
1228 Fake_glXChooseVisual( Display
*dpy
, int screen
, int *list
)
1232 /* register ourselves as an extension on this display */
1233 register_with_display(dpy
);
1235 xmvis
= choose_visual(dpy
, screen
, list
, GL_FALSE
);
1237 XVisualInfo
* visinfo
= malloc(sizeof(XVisualInfo
));
1239 memcpy(visinfo
, xmvis
->visinfo
, sizeof(XVisualInfo
));
1249 Fake_glXCreateContext( Display
*dpy
, XVisualInfo
*visinfo
,
1250 GLXContext share_list
, Bool direct
)
1253 XMesaContext xmesaCtx
;
1255 if (!dpy
|| !visinfo
)
1258 /* deallocate unused windows/buffers */
1260 XMesaGarbageCollect(dpy
);
1263 xmvis
= find_glx_visual( dpy
, visinfo
);
1265 /* This visual wasn't found with glXChooseVisual() */
1266 xmvis
= create_glx_visual( dpy
, visinfo
);
1272 xmesaCtx
= XMesaCreateContext(xmvis
, (XMesaContext
) share_list
);
1274 return (GLXContext
) xmesaCtx
;
1278 /* XXX these may have to be removed due to thread-safety issues. */
1279 static GLXContext MakeCurrent_PrevContext
= 0;
1280 static GLXDrawable MakeCurrent_PrevDrawable
= 0;
1281 static GLXDrawable MakeCurrent_PrevReadable
= 0;
1282 static XMesaBuffer MakeCurrent_PrevDrawBuffer
= 0;
1283 static XMesaBuffer MakeCurrent_PrevReadBuffer
= 0;
1286 /* GLX 1.3 and later */
1288 Fake_glXMakeContextCurrent( Display
*dpy
, GLXDrawable draw
,
1289 GLXDrawable read
, GLXContext ctx
)
1291 if (ctx
&& draw
&& read
) {
1292 XMesaBuffer drawBuffer
, readBuffer
;
1293 XMesaContext xmctx
= (XMesaContext
) ctx
;
1295 /* Find the XMesaBuffer which corresponds to the GLXDrawable 'draw' */
1296 if (ctx
== MakeCurrent_PrevContext
1297 && draw
== MakeCurrent_PrevDrawable
) {
1298 drawBuffer
= MakeCurrent_PrevDrawBuffer
;
1301 drawBuffer
= XMesaFindBuffer( dpy
, draw
);
1304 /* drawable must be a new window! */
1305 drawBuffer
= XMesaCreateWindowBuffer( xmctx
->xm_visual
, draw
);
1307 /* Out of memory, or context/drawable depth mismatch */
1312 /* Find the XMesaBuffer which corresponds to the GLXDrawable 'read' */
1313 if (ctx
== MakeCurrent_PrevContext
1314 && read
== MakeCurrent_PrevReadable
) {
1315 readBuffer
= MakeCurrent_PrevReadBuffer
;
1318 readBuffer
= XMesaFindBuffer( dpy
, read
);
1321 /* drawable must be a new window! */
1322 readBuffer
= XMesaCreateWindowBuffer( xmctx
->xm_visual
, read
);
1324 /* Out of memory, or context/drawable depth mismatch */
1329 MakeCurrent_PrevContext
= ctx
;
1330 MakeCurrent_PrevDrawable
= draw
;
1331 MakeCurrent_PrevReadable
= read
;
1332 MakeCurrent_PrevDrawBuffer
= drawBuffer
;
1333 MakeCurrent_PrevReadBuffer
= readBuffer
;
1335 /* Now make current! */
1336 return XMesaMakeCurrent2(xmctx
, drawBuffer
, readBuffer
);
1338 else if (!ctx
&& !draw
&& !read
) {
1339 /* release current context w/out assigning new one. */
1340 XMesaMakeCurrent( NULL
, NULL
);
1341 MakeCurrent_PrevContext
= 0;
1342 MakeCurrent_PrevDrawable
= 0;
1343 MakeCurrent_PrevReadable
= 0;
1344 MakeCurrent_PrevDrawBuffer
= 0;
1345 MakeCurrent_PrevReadBuffer
= 0;
1349 /* The args must either all be non-zero or all zero.
1358 Fake_glXMakeCurrent( Display
*dpy
, GLXDrawable drawable
, GLXContext ctx
)
1360 return Fake_glXMakeContextCurrent( dpy
, drawable
, drawable
, ctx
);
1365 Fake_glXCreateGLXPixmap( Display
*dpy
, XVisualInfo
*visinfo
, Pixmap pixmap
)
1370 v
= find_glx_visual( dpy
, visinfo
);
1372 v
= create_glx_visual( dpy
, visinfo
);
1374 /* unusable visual */
1379 b
= XMesaCreatePixmapBuffer( v
, pixmap
, 0 );
1383 return b
->frontxrb
->pixmap
;
1387 /*** GLX_MESA_pixmap_colormap ***/
1390 Fake_glXCreateGLXPixmapMESA( Display
*dpy
, XVisualInfo
*visinfo
,
1391 Pixmap pixmap
, Colormap cmap
)
1396 v
= find_glx_visual( dpy
, visinfo
);
1398 v
= create_glx_visual( dpy
, visinfo
);
1400 /* unusable visual */
1405 b
= XMesaCreatePixmapBuffer( v
, pixmap
, cmap
);
1409 return b
->frontxrb
->pixmap
;
1414 Fake_glXDestroyGLXPixmap( Display
*dpy
, GLXPixmap pixmap
)
1416 XMesaBuffer b
= XMesaFindBuffer(dpy
, pixmap
);
1418 XMesaDestroyBuffer(b
);
1420 else if (getenv("MESA_DEBUG")) {
1421 _mesa_warning(NULL
, "Mesa: glXDestroyGLXPixmap: invalid pixmap\n");
1427 Fake_glXCopyContext( Display
*dpy
, GLXContext src
, GLXContext dst
,
1428 unsigned long mask
)
1430 XMesaContext xmSrc
= (XMesaContext
) src
;
1431 XMesaContext xmDst
= (XMesaContext
) dst
;
1433 if (MakeCurrent_PrevContext
== src
) {
1436 _mesa_copy_context( &xmSrc
->mesa
, &xmDst
->mesa
, (GLuint
) mask
);
1441 Fake_glXQueryExtension( Display
*dpy
, int *errorBase
, int *eventBase
)
1444 /* Mesa's GLX isn't really an X extension but we try to act like one. */
1445 if (!XQueryExtension(dpy
, GLX_EXTENSION_NAME
, &op
, &ev
, &err
))
1451 return True
; /* we're faking GLX so always return success */
1455 extern void _kw_ungrab_all( Display
*dpy
);
1456 void _kw_ungrab_all( Display
*dpy
)
1458 XUngrabPointer( dpy
, CurrentTime
);
1459 XUngrabKeyboard( dpy
, CurrentTime
);
1464 Fake_glXDestroyContext( Display
*dpy
, GLXContext ctx
)
1468 MakeCurrent_PrevContext
= 0;
1469 MakeCurrent_PrevDrawable
= 0;
1470 MakeCurrent_PrevReadable
= 0;
1471 MakeCurrent_PrevDrawBuffer
= 0;
1472 MakeCurrent_PrevReadBuffer
= 0;
1473 XMesaDestroyContext((XMesaContext
) ctx
);
1474 XMesaGarbageCollect(dpy
);
1480 Fake_glXIsDirect( Display
*dpy
, GLXContext ctx
)
1482 XMesaContext xmCtx
= (XMesaContext
) ctx
;
1483 return xmCtx
? xmCtx
->direct
: False
;
1489 Fake_glXSwapBuffers( Display
*dpy
, GLXDrawable drawable
)
1491 XMesaBuffer buffer
= XMesaFindBuffer( dpy
, drawable
);
1494 XMesaSwapBuffers(buffer
);
1496 else if (getenv("MESA_DEBUG")) {
1497 _mesa_warning(NULL
, "glXSwapBuffers: invalid drawable 0x%x\n",
1504 /*** GLX_MESA_copy_sub_buffer ***/
1507 Fake_glXCopySubBufferMESA( Display
*dpy
, GLXDrawable drawable
,
1508 int x
, int y
, int width
, int height
)
1510 XMesaBuffer buffer
= XMesaFindBuffer( dpy
, drawable
);
1512 XMesaCopySubBuffer(buffer
, x
, y
, width
, height
);
1514 else if (getenv("MESA_DEBUG")) {
1515 _mesa_warning(NULL
, "Mesa: glXCopySubBufferMESA: invalid drawable\n");
1521 Fake_glXQueryVersion( Display
*dpy
, int *maj
, int *min
)
1524 /* Return GLX version, not Mesa version */
1525 assert(CLIENT_MAJOR_VERSION
== SERVER_MAJOR_VERSION
);
1526 *maj
= CLIENT_MAJOR_VERSION
;
1527 *min
= MIN2( CLIENT_MINOR_VERSION
, SERVER_MINOR_VERSION
);
1533 * Query the GLX attributes of the given XVisualInfo.
1536 get_config( XMesaVisual xmvis
, int attrib
, int *value
, GLboolean fbconfig
)
1542 return GLX_BAD_ATTRIBUTE
;
1543 *value
= (int) True
;
1545 case GLX_BUFFER_SIZE
:
1546 *value
= xmvis
->visinfo
->depth
;
1549 *value
= xmvis
->mesa_visual
.level
;
1553 return GLX_BAD_ATTRIBUTE
;
1556 case GLX_DOUBLEBUFFER
:
1557 *value
= (int) xmvis
->mesa_visual
.doubleBufferMode
;
1560 *value
= (int) xmvis
->mesa_visual
.stereoMode
;
1562 case GLX_AUX_BUFFERS
:
1563 *value
= xmvis
->mesa_visual
.numAuxBuffers
;
1566 *value
= xmvis
->mesa_visual
.redBits
;
1568 case GLX_GREEN_SIZE
:
1569 *value
= xmvis
->mesa_visual
.greenBits
;
1572 *value
= xmvis
->mesa_visual
.blueBits
;
1574 case GLX_ALPHA_SIZE
:
1575 *value
= xmvis
->mesa_visual
.alphaBits
;
1577 case GLX_DEPTH_SIZE
:
1578 *value
= xmvis
->mesa_visual
.depthBits
;
1580 case GLX_STENCIL_SIZE
:
1581 *value
= xmvis
->mesa_visual
.stencilBits
;
1583 case GLX_ACCUM_RED_SIZE
:
1584 *value
= xmvis
->mesa_visual
.accumRedBits
;
1586 case GLX_ACCUM_GREEN_SIZE
:
1587 *value
= xmvis
->mesa_visual
.accumGreenBits
;
1589 case GLX_ACCUM_BLUE_SIZE
:
1590 *value
= xmvis
->mesa_visual
.accumBlueBits
;
1592 case GLX_ACCUM_ALPHA_SIZE
:
1593 *value
= xmvis
->mesa_visual
.accumAlphaBits
;
1597 * GLX_EXT_visual_info extension
1599 case GLX_X_VISUAL_TYPE_EXT
:
1600 switch (xmvis
->visinfo
->CLASS
) {
1601 case StaticGray
: *value
= GLX_STATIC_GRAY_EXT
; return 0;
1602 case GrayScale
: *value
= GLX_GRAY_SCALE_EXT
; return 0;
1603 case StaticColor
: *value
= GLX_STATIC_GRAY_EXT
; return 0;
1604 case PseudoColor
: *value
= GLX_PSEUDO_COLOR_EXT
; return 0;
1605 case TrueColor
: *value
= GLX_TRUE_COLOR_EXT
; return 0;
1606 case DirectColor
: *value
= GLX_DIRECT_COLOR_EXT
; return 0;
1609 case GLX_TRANSPARENT_TYPE_EXT
:
1610 if (xmvis
->mesa_visual
.level
==0) {
1612 *value
= GLX_NONE_EXT
;
1614 else if (xmvis
->mesa_visual
.level
>0) {
1616 *value
= GLX_TRANSPARENT_RGB_EXT
;
1618 else if (xmvis
->mesa_visual
.level
<0) {
1620 *value
= GLX_NONE_EXT
;
1623 case GLX_TRANSPARENT_INDEX_VALUE_EXT
:
1625 int pixel
= transparent_pixel( xmvis
);
1629 /* else undefined */
1632 case GLX_TRANSPARENT_RED_VALUE_EXT
:
1635 case GLX_TRANSPARENT_GREEN_VALUE_EXT
:
1638 case GLX_TRANSPARENT_BLUE_VALUE_EXT
:
1641 case GLX_TRANSPARENT_ALPHA_VALUE_EXT
:
1646 * GLX_EXT_visual_info extension
1648 case GLX_VISUAL_CAVEAT_EXT
:
1649 /* test for zero, just in case */
1650 if (xmvis
->mesa_visual
.visualRating
> 0)
1651 *value
= xmvis
->mesa_visual
.visualRating
;
1653 *value
= GLX_NONE_EXT
;
1657 * GLX_ARB_multisample
1659 case GLX_SAMPLE_BUFFERS_ARB
:
1662 case GLX_SAMPLES_ARB
:
1669 case GLX_SCREEN_EXT
:
1671 return GLX_BAD_ATTRIBUTE
;
1672 *value
= xmvis
->visinfo
->screen
;
1674 case GLX_DRAWABLE_TYPE
: /*SGIX too */
1676 return GLX_BAD_ATTRIBUTE
;
1677 *value
= GLX_WINDOW_BIT
| GLX_PIXMAP_BIT
| GLX_PBUFFER_BIT
;
1679 case GLX_RENDER_TYPE_SGIX
:
1681 return GLX_BAD_ATTRIBUTE
;
1682 if (xmvis
->mesa_visual
.floatMode
)
1683 *value
= GLX_RGBA_FLOAT_BIT_ARB
;
1685 *value
= GLX_RGBA_BIT
;
1687 case GLX_X_RENDERABLE_SGIX
:
1689 return GLX_BAD_ATTRIBUTE
;
1690 *value
= True
; /* XXX really? */
1692 case GLX_FBCONFIG_ID_SGIX
:
1694 return GLX_BAD_ATTRIBUTE
;
1695 *value
= xmvis
->visinfo
->visualid
;
1697 case GLX_MAX_PBUFFER_WIDTH
:
1699 return GLX_BAD_ATTRIBUTE
;
1700 /* XXX should be same as ctx->Const.MaxRenderbufferSize */
1701 *value
= DisplayWidth(xmvis
->display
, xmvis
->visinfo
->screen
);
1703 case GLX_MAX_PBUFFER_HEIGHT
:
1705 return GLX_BAD_ATTRIBUTE
;
1706 *value
= DisplayHeight(xmvis
->display
, xmvis
->visinfo
->screen
);
1708 case GLX_MAX_PBUFFER_PIXELS
:
1710 return GLX_BAD_ATTRIBUTE
;
1711 *value
= DisplayWidth(xmvis
->display
, xmvis
->visinfo
->screen
) *
1712 DisplayHeight(xmvis
->display
, xmvis
->visinfo
->screen
);
1716 return GLX_BAD_ATTRIBUTE
;
1717 *value
= xmvis
->visinfo
->visualid
;
1720 case GLX_BIND_TO_TEXTURE_RGB_EXT
:
1721 *value
= True
; /*XXX*/
1723 case GLX_BIND_TO_TEXTURE_RGBA_EXT
:
1725 *value
= xmvis
->mesa_visual
.alphaBits
> 0 ? True
: False
;
1727 case GLX_BIND_TO_MIPMAP_TEXTURE_EXT
:
1728 *value
= True
; /*XXX*/
1730 case GLX_BIND_TO_TEXTURE_TARGETS_EXT
:
1731 *value
= (GLX_TEXTURE_1D_BIT_EXT
|
1732 GLX_TEXTURE_2D_BIT_EXT
|
1733 GLX_TEXTURE_RECTANGLE_BIT_EXT
); /*XXX*/
1735 case GLX_Y_INVERTED_EXT
:
1736 *value
= True
; /*XXX*/
1740 return GLX_BAD_ATTRIBUTE
;
1747 Fake_glXGetConfig( Display
*dpy
, XVisualInfo
*visinfo
,
1748 int attrib
, int *value
)
1752 if (!dpy
|| !visinfo
)
1753 return GLX_BAD_ATTRIBUTE
;
1755 xmvis
= find_glx_visual( dpy
, visinfo
);
1757 /* this visual wasn't obtained with glXChooseVisual */
1758 xmvis
= create_glx_visual( dpy
, visinfo
);
1760 /* this visual can't be used for GL rendering */
1761 if (attrib
==GLX_USE_GL
) {
1762 *value
= (int) False
;
1766 return GLX_BAD_VISUAL
;
1771 k
= get_config(xmvis
, attrib
, value
, GL_FALSE
);
1777 Fake_glXGetCurrentContext(void)
1779 XMesaContext xmesa
= XMesaGetCurrentContext();
1780 return (GLXContext
) xmesa
;
1784 Fake_glXWaitGL( void )
1786 XMesaContext xmesa
= XMesaGetCurrentContext();
1787 XMesaFlush( xmesa
);
1793 Fake_glXWaitX( void )
1795 XMesaContext xmesa
= XMesaGetCurrentContext();
1796 XMesaFlush( xmesa
);
1801 get_extensions( void )
1803 return EXTENSIONS
+ 23; /* skip "GLX_MESA_set_3dfx_mode" */
1808 /* GLX 1.1 and later */
1810 Fake_glXQueryExtensionsString( Display
*dpy
, int screen
)
1814 return get_extensions();
1819 /* GLX 1.1 and later */
1821 Fake_glXQueryServerString( Display
*dpy
, int screen
, int name
)
1823 static char version
[1000];
1824 sprintf(version
, "%d.%d %s",
1825 SERVER_MAJOR_VERSION
, SERVER_MINOR_VERSION
, MESA_GLX_VERSION
);
1831 case GLX_EXTENSIONS
:
1832 return get_extensions();
1844 /* GLX 1.1 and later */
1846 Fake_glXGetClientString( Display
*dpy
, int name
)
1848 static char version
[1000];
1849 sprintf(version
, "%d.%d %s", CLIENT_MAJOR_VERSION
,
1850 CLIENT_MINOR_VERSION
, MESA_GLX_VERSION
);
1855 case GLX_EXTENSIONS
:
1856 return get_extensions();
1874 Fake_glXGetFBConfigAttrib( Display
*dpy
, GLXFBConfig config
,
1875 int attribute
, int *value
)
1877 XMesaVisual v
= (XMesaVisual
) config
;
1881 if (!dpy
|| !config
|| !value
)
1884 return get_config(v
, attribute
, value
, GL_TRUE
);
1888 static GLXFBConfig
*
1889 Fake_glXGetFBConfigs( Display
*dpy
, int screen
, int *nelements
)
1891 XVisualInfo
*visuals
, visTemplate
;
1892 const long visMask
= VisualScreenMask
;
1895 /* Get list of all X visuals */
1896 visTemplate
.screen
= screen
;
1897 visuals
= XGetVisualInfo(dpy
, visMask
, &visTemplate
, nelements
);
1898 if (*nelements
> 0) {
1899 XMesaVisual
*results
;
1900 results
= malloc(*nelements
* sizeof(XMesaVisual
));
1905 for (i
= 0; i
< *nelements
; i
++) {
1906 results
[i
] = create_glx_visual(dpy
, visuals
+ i
);
1909 return (GLXFBConfig
*) results
;
1915 static GLXFBConfig
*
1916 Fake_glXChooseFBConfig( Display
*dpy
, int screen
,
1917 const int *attribList
, int *nitems
)
1921 /* register ourselves as an extension on this display */
1922 register_with_display(dpy
);
1924 if (!attribList
|| !attribList
[0]) {
1925 /* return list of all configs (per GLX_SGIX_fbconfig spec) */
1926 return Fake_glXGetFBConfigs(dpy
, screen
, nitems
);
1929 xmvis
= choose_visual(dpy
, screen
, attribList
, GL_TRUE
);
1931 GLXFBConfig
*config
= malloc(sizeof(XMesaVisual
));
1937 config
[0] = (GLXFBConfig
) xmvis
;
1938 return (GLXFBConfig
*) config
;
1947 static XVisualInfo
*
1948 Fake_glXGetVisualFromFBConfig( Display
*dpy
, GLXFBConfig config
)
1950 if (dpy
&& config
) {
1951 XMesaVisual xmvis
= (XMesaVisual
) config
;
1952 XVisualInfo
* visinfo
= malloc(sizeof(XVisualInfo
));
1954 memcpy(visinfo
, xmvis
->visinfo
, sizeof(XVisualInfo
));
1965 Fake_glXCreateWindow( Display
*dpy
, GLXFBConfig config
, Window win
,
1966 const int *attribList
)
1968 XMesaVisual xmvis
= (XMesaVisual
) config
;
1973 xmbuf
= XMesaCreateWindowBuffer(xmvis
, win
);
1978 (void) attribList
; /* Ignored in GLX 1.3 */
1980 return win
; /* A hack for now */
1985 Fake_glXDestroyWindow( Display
*dpy
, GLXWindow window
)
1987 XMesaBuffer b
= XMesaFindBuffer(dpy
, (XMesaDrawable
) window
);
1989 XMesaDestroyBuffer(b
);
1990 /* don't destroy X window */
1996 Fake_glXCreatePixmap( Display
*dpy
, GLXFBConfig config
, Pixmap pixmap
,
1997 const int *attribList
)
1999 XMesaVisual v
= (XMesaVisual
) config
;
2002 int target
= 0, format
= 0, mipmap
= 0;
2005 if (!dpy
|| !config
|| !pixmap
)
2008 for (attr
= attribList
; attr
&& *attr
; attr
++) {
2010 case GLX_TEXTURE_FORMAT_EXT
:
2013 case GLX_TEXTURE_FORMAT_NONE_EXT
:
2014 case GLX_TEXTURE_FORMAT_RGB_EXT
:
2015 case GLX_TEXTURE_FORMAT_RGBA_EXT
:
2023 case GLX_TEXTURE_TARGET_EXT
:
2026 case GLX_TEXTURE_1D_EXT
:
2027 case GLX_TEXTURE_2D_EXT
:
2028 case GLX_TEXTURE_RECTANGLE_EXT
:
2036 case GLX_MIPMAP_TEXTURE_EXT
:
2047 if (format
== GLX_TEXTURE_FORMAT_RGB_EXT
) {
2048 if (get_config(v
, GLX_BIND_TO_TEXTURE_RGB_EXT
,
2049 &value
, GL_TRUE
) != Success
2051 return 0; /* error! */
2054 else if (format
== GLX_TEXTURE_FORMAT_RGBA_EXT
) {
2055 if (get_config(v
, GLX_BIND_TO_TEXTURE_RGBA_EXT
,
2056 &value
, GL_TRUE
) != Success
2058 return 0; /* error! */
2062 if (get_config(v
, GLX_BIND_TO_MIPMAP_TEXTURE_EXT
,
2063 &value
, GL_TRUE
) != Success
2065 return 0; /* error! */
2068 if (target
== GLX_TEXTURE_1D_EXT
) {
2069 if (get_config(v
, GLX_BIND_TO_TEXTURE_TARGETS_EXT
,
2070 &value
, GL_TRUE
) != Success
2071 || (value
& GLX_TEXTURE_1D_BIT_EXT
) == 0) {
2072 return 0; /* error! */
2075 else if (target
== GLX_TEXTURE_2D_EXT
) {
2076 if (get_config(v
, GLX_BIND_TO_TEXTURE_TARGETS_EXT
,
2077 &value
, GL_TRUE
) != Success
2078 || (value
& GLX_TEXTURE_2D_BIT_EXT
) == 0) {
2079 return 0; /* error! */
2082 if (target
== GLX_TEXTURE_RECTANGLE_EXT
) {
2083 if (get_config(v
, GLX_BIND_TO_TEXTURE_TARGETS_EXT
,
2084 &value
, GL_TRUE
) != Success
2085 || (value
& GLX_TEXTURE_RECTANGLE_BIT_EXT
) == 0) {
2086 return 0; /* error! */
2090 if (format
|| target
|| mipmap
) {
2091 /* texture from pixmap */
2092 b
= XMesaCreatePixmapTextureBuffer(v
, pixmap
, 0, format
, target
, mipmap
);
2095 b
= XMesaCreatePixmapBuffer( v
, pixmap
, 0 );
2106 Fake_glXDestroyPixmap( Display
*dpy
, GLXPixmap pixmap
)
2108 XMesaBuffer b
= XMesaFindBuffer(dpy
, (XMesaDrawable
)pixmap
);
2110 XMesaDestroyBuffer(b
);
2111 /* don't destroy X pixmap */
2116 Fake_glXCreatePbuffer( Display
*dpy
, GLXFBConfig config
,
2117 const int *attribList
)
2119 XMesaVisual xmvis
= (XMesaVisual
) config
;
2122 int width
= 0, height
= 0;
2123 GLboolean useLargest
= GL_FALSE
, preserveContents
= GL_FALSE
;
2127 for (attrib
= attribList
; *attrib
; attrib
++) {
2129 case GLX_PBUFFER_WIDTH
:
2133 case GLX_PBUFFER_HEIGHT
:
2137 case GLX_PRESERVED_CONTENTS
:
2139 preserveContents
= *attrib
;
2141 case GLX_LARGEST_PBUFFER
:
2143 useLargest
= *attrib
;
2150 if (width
== 0 || height
== 0)
2153 if (width
> SWRAST_MAX_WIDTH
|| height
> SWRAST_MAX_HEIGHT
) {
2154 /* If allocation would have failed and GLX_LARGEST_PBUFFER is set,
2155 * allocate the largest possible buffer.
2158 width
= SWRAST_MAX_WIDTH
;
2159 height
= SWRAST_MAX_HEIGHT
;
2163 xmbuf
= XMesaCreatePBuffer( xmvis
, 0, width
, height
);
2164 /* A GLXPbuffer handle must be an X Drawable because that's what
2165 * glXMakeCurrent takes.
2168 xmbuf
->largestPbuffer
= useLargest
;
2169 xmbuf
->preservedContents
= preserveContents
;
2170 return (GLXPbuffer
) xmbuf
->frontxrb
->pixmap
;
2179 Fake_glXDestroyPbuffer( Display
*dpy
, GLXPbuffer pbuf
)
2181 XMesaBuffer b
= XMesaFindBuffer(dpy
, pbuf
);
2183 XMesaDestroyBuffer(b
);
2189 Fake_glXQueryDrawable( Display
*dpy
, GLXDrawable draw
, int attribute
,
2190 unsigned int *value
)
2192 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, draw
);
2196 /* make sure buffer's dimensions are up to date */
2197 xmesa_check_and_update_buffer_size(NULL
, xmbuf
);
2199 switch (attribute
) {
2201 *value
= xmbuf
->mesa_buffer
.Width
;
2204 *value
= xmbuf
->mesa_buffer
.Height
;
2206 case GLX_PRESERVED_CONTENTS
:
2207 *value
= xmbuf
->preservedContents
;
2209 case GLX_LARGEST_PBUFFER
:
2210 *value
= xmbuf
->largestPbuffer
;
2212 case GLX_FBCONFIG_ID
:
2213 *value
= xmbuf
->xm_visual
->visinfo
->visualid
;
2215 case GLX_TEXTURE_FORMAT_EXT
:
2216 *value
= xmbuf
->TextureFormat
;
2218 case GLX_TEXTURE_TARGET_EXT
:
2219 *value
= xmbuf
->TextureTarget
;
2221 case GLX_MIPMAP_TEXTURE_EXT
:
2222 *value
= xmbuf
->TextureMipmap
;
2226 return; /* raise BadValue error */
2232 Fake_glXCreateNewContext( Display
*dpy
, GLXFBConfig config
,
2233 int renderType
, GLXContext shareList
, Bool direct
)
2236 XMesaVisual xmvis
= (XMesaVisual
) config
;
2238 if (!dpy
|| !config
||
2239 (renderType
!= GLX_RGBA_TYPE
&&
2240 renderType
!= GLX_COLOR_INDEX_TYPE
&&
2241 renderType
!= GLX_RGBA_FLOAT_TYPE_ARB
&&
2242 renderType
!= GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT
))
2245 /* deallocate unused windows/buffers */
2246 XMesaGarbageCollect(dpy
);
2248 xmCtx
= XMesaCreateContext(xmvis
, (XMesaContext
) shareList
);
2250 return (GLXContext
) xmCtx
;
2255 Fake_glXQueryContext( Display
*dpy
, GLXContext ctx
, int attribute
, int *value
)
2257 XMesaContext xmctx
= (XMesaContext
) ctx
;
2261 switch (attribute
) {
2262 case GLX_FBCONFIG_ID
:
2263 *value
= xmctx
->xm_visual
->visinfo
->visualid
;
2265 case GLX_RENDER_TYPE
:
2266 *value
= GLX_RGBA_TYPE
;
2272 return GLX_BAD_ATTRIBUTE
;
2279 Fake_glXSelectEvent( Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
2281 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, drawable
);
2283 xmbuf
->selectedEvents
= mask
;
2288 Fake_glXGetSelectedEvent( Display
*dpy
, GLXDrawable drawable
,
2289 unsigned long *mask
)
2291 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, drawable
);
2293 *mask
= xmbuf
->selectedEvents
;
2300 /*** GLX_SGI_swap_control ***/
2303 Fake_glXSwapIntervalSGI(int interval
)
2311 /*** GLX_SGI_video_sync ***/
2313 static unsigned int FrameCounter
= 0;
2316 Fake_glXGetVideoSyncSGI(unsigned int *count
)
2318 /* this is a bogus implementation */
2319 *count
= FrameCounter
++;
2324 Fake_glXWaitVideoSyncSGI(int divisor
, int remainder
, unsigned int *count
)
2326 if (divisor
<= 0 || remainder
< 0)
2327 return GLX_BAD_VALUE
;
2328 /* this is a bogus implementation */
2330 while (FrameCounter
% divisor
!= remainder
)
2332 *count
= FrameCounter
;
2338 /*** GLX_SGI_make_current_read ***/
2341 Fake_glXMakeCurrentReadSGI(Display
*dpy
, GLXDrawable draw
, GLXDrawable read
, GLXContext ctx
)
2343 return Fake_glXMakeContextCurrent( dpy
, draw
, read
, ctx
);
2348 Fake_glXGetCurrentReadDrawableSGI(void)
2355 /*** GLX_SGIX_video_source ***/
2358 static GLXVideoSourceSGIX
2359 Fake_glXCreateGLXVideoSourceSGIX(Display
*dpy
, int screen
, VLServer server
, VLPath path
, int nodeClass
, VLNode drainNode
)
2371 Fake_glXDestroyGLXVideoSourceSGIX(Display
*dpy
, GLXVideoSourceSGIX src
)
2380 /*** GLX_EXT_import_context ***/
2383 Fake_glXFreeContextEXT(Display
*dpy
, GLXContext context
)
2390 Fake_glXGetContextIDEXT(const GLXContext context
)
2397 Fake_glXImportContextEXT(Display
*dpy
, GLXContextID contextID
)
2405 Fake_glXQueryContextInfoEXT(Display
*dpy
, GLXContext context
, int attribute
, int *value
)
2416 /*** GLX_SGIX_fbconfig ***/
2419 Fake_glXGetFBConfigAttribSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int attribute
, int *value
)
2421 return Fake_glXGetFBConfigAttrib(dpy
, config
, attribute
, value
);
2424 static GLXFBConfigSGIX
*
2425 Fake_glXChooseFBConfigSGIX(Display
*dpy
, int screen
, int *attrib_list
, int *nelements
)
2427 return (GLXFBConfig
*) Fake_glXChooseFBConfig(dpy
, screen
, attrib_list
, nelements
);
2432 Fake_glXCreateGLXPixmapWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, Pixmap pixmap
)
2434 XMesaVisual xmvis
= (XMesaVisual
) config
;
2435 XMesaBuffer xmbuf
= XMesaCreatePixmapBuffer(xmvis
, pixmap
, 0);
2436 return xmbuf
->frontxrb
->pixmap
; /* need to return an X ID */
2441 Fake_glXCreateContextWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int render_type
, GLXContext share_list
, Bool direct
)
2444 XMesaVisual xmvis
= (XMesaVisual
) config
;
2446 /* deallocate unused windows/buffers */
2447 XMesaGarbageCollect(dpy
);
2449 xmCtx
= XMesaCreateContext(xmvis
, (XMesaContext
) share_list
);
2451 return (GLXContext
) xmCtx
;
2455 static XVisualInfo
*
2456 Fake_glXGetVisualFromFBConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
)
2458 return Fake_glXGetVisualFromFBConfig(dpy
, config
);
2462 static GLXFBConfigSGIX
2463 Fake_glXGetFBConfigFromVisualSGIX(Display
*dpy
, XVisualInfo
*vis
)
2465 XMesaVisual xmvis
= find_glx_visual(dpy
, vis
);
2467 /* This visual wasn't found with glXChooseVisual() */
2468 xmvis
= create_glx_visual(dpy
, vis
);
2471 return (GLXFBConfigSGIX
) xmvis
;
2476 /*** GLX_SGIX_pbuffer ***/
2478 static GLXPbufferSGIX
2479 Fake_glXCreateGLXPbufferSGIX(Display
*dpy
, GLXFBConfigSGIX config
,
2480 unsigned int width
, unsigned int height
,
2483 XMesaVisual xmvis
= (XMesaVisual
) config
;
2486 GLboolean useLargest
= GL_FALSE
, preserveContents
= GL_FALSE
;
2490 for (attrib
= attribList
; attrib
&& *attrib
; attrib
++) {
2492 case GLX_PRESERVED_CONTENTS_SGIX
:
2494 preserveContents
= *attrib
; /* ignored */
2496 case GLX_LARGEST_PBUFFER_SGIX
:
2498 useLargest
= *attrib
; /* ignored */
2505 /* not used at this time */
2507 (void) preserveContents
;
2509 xmbuf
= XMesaCreatePBuffer( xmvis
, 0, width
, height
);
2510 /* A GLXPbuffer handle must be an X Drawable because that's what
2511 * glXMakeCurrent takes.
2513 return (GLXPbuffer
) xmbuf
->frontxrb
->pixmap
;
2518 Fake_glXDestroyGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
)
2520 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, pbuf
);
2522 XMesaDestroyBuffer(xmbuf
);
2528 Fake_glXQueryGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
, int attribute
, unsigned int *value
)
2530 const XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, pbuf
);
2533 /* Generate GLXBadPbufferSGIX for bad pbuffer */
2537 switch (attribute
) {
2538 case GLX_PRESERVED_CONTENTS_SGIX
:
2539 *value
= xmbuf
->preservedContents
;
2541 case GLX_LARGEST_PBUFFER_SGIX
:
2542 *value
= xmbuf
->largestPbuffer
;
2544 case GLX_WIDTH_SGIX
:
2545 *value
= xmbuf
->mesa_buffer
.Width
;
2547 case GLX_HEIGHT_SGIX
:
2548 *value
= xmbuf
->mesa_buffer
.Height
;
2550 case GLX_EVENT_MASK_SGIX
:
2551 *value
= 0; /* XXX might be wrong */
2560 Fake_glXSelectEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
2562 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, drawable
);
2564 /* Note: we'll never generate clobber events */
2565 xmbuf
->selectedEvents
= mask
;
2571 Fake_glXGetSelectedEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long *mask
)
2573 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, drawable
);
2575 *mask
= xmbuf
->selectedEvents
;
2584 /*** GLX_SGI_cushion ***/
2587 Fake_glXCushionSGI(Display
*dpy
, Window win
, float cushion
)
2596 /*** GLX_SGIX_video_resize ***/
2599 Fake_glXBindChannelToWindowSGIX(Display
*dpy
, int screen
, int channel
, Window window
)
2609 Fake_glXChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int x
, int y
, int w
, int h
)
2622 Fake_glXQueryChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int *x
, int *y
, int *w
, int *h
)
2635 Fake_glXQueryChannelDeltasSGIX(Display
*dpy
, int screen
, int channel
, int *dx
, int *dy
, int *dw
, int *dh
)
2648 Fake_glXChannelRectSyncSGIX(Display
*dpy
, int screen
, int channel
, GLenum synctype
)
2659 /*** GLX_SGIX_dmbuffer **/
2661 #if defined(_DM_BUFFER_H_)
2663 Fake_glXAssociateDMPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuffer
, DMparams
*params
, DMbuffer dmbuffer
)
2674 /*** GLX_SUN_get_transparent_index ***/
2677 Fake_glXGetTransparentIndexSUN(Display
*dpy
, Window overlay
, Window underlay
, unsigned long *pTransparent
)
2682 (void) pTransparent
;
2688 /*** GLX_MESA_release_buffers ***/
2691 * Release the depth, stencil, accum buffers attached to a GLXDrawable
2692 * (a window or pixmap) prior to destroying the GLXDrawable.
2695 Fake_glXReleaseBuffersMESA( Display
*dpy
, GLXDrawable d
)
2697 XMesaBuffer b
= XMesaFindBuffer(dpy
, d
);
2699 XMesaDestroyBuffer(b
);
2707 /*** GLX_EXT_texture_from_pixmap ***/
2710 Fake_glXBindTexImageEXT(Display
*dpy
, GLXDrawable drawable
, int buffer
,
2711 const int *attrib_list
)
2713 XMesaBuffer b
= XMesaFindBuffer(dpy
, drawable
);
2715 XMesaBindTexImage(dpy
, b
, buffer
, attrib_list
);
2719 Fake_glXReleaseTexImageEXT(Display
*dpy
, GLXDrawable drawable
, int buffer
)
2721 XMesaBuffer b
= XMesaFindBuffer(dpy
, drawable
);
2723 XMesaReleaseTexImage(dpy
, b
, buffer
);
2728 Fake_glXCreateContextAttribs(Display
*dpy
, GLXFBConfig config
,
2729 GLXContext share_context
, Bool direct
,
2730 const int *attrib_list
)
2733 XMesaVisual xmvis
= (XMesaVisual
) config
;
2735 int major
= 0, minor
= 0, ctxFlags
= 0, profileFlags
= 0;
2737 for (i
= 0; attrib_list
[i
]; i
+= 2) {
2738 switch (attrib_list
[i
]) {
2739 case GLX_CONTEXT_MAJOR_VERSION_ARB
:
2740 major
= attrib_list
[i
+ 1];
2742 case GLX_CONTEXT_MINOR_VERSION_ARB
:
2743 minor
= attrib_list
[i
+ 1];
2745 case GLX_CONTEXT_FLAGS_ARB
:
2746 ctxFlags
= attrib_list
[i
+ 1];
2748 case GLX_CONTEXT_PROFILE_MASK_ARB
:
2749 profileFlags
= attrib_list
[i
+ 1];
2752 _mesa_warning(NULL
, "Unexpected attribute 0x%x in "
2753 "glXCreateContextAttribs()\n", attrib_list
[i
]);
2758 if (major
* 10 + minor
> 21) {
2759 /* swrast only supports GL 2.1 and earlier */
2763 /* These are ignored for now. We'd have to enhance XMesaCreateContext
2764 * to take these flags and the version, at least.
2767 (void) profileFlags
;
2769 /* deallocate unused windows/buffers */
2770 XMesaGarbageCollect(dpy
);
2772 xmCtx
= XMesaCreateContext(xmvis
, (XMesaContext
) share_context
);
2774 return (GLXContext
) xmCtx
;
2778 /* silence warning */
2779 extern struct _glxapi_table
*_mesa_GetGLXDispatchTable(void);
2783 * Create a new GLX API dispatch table with its function pointers
2784 * initialized to point to Mesa's "fake" GLX API functions.
2785 * Note: there's a similar function (_real_GetGLXDispatchTable) that
2786 * returns a new dispatch table with all pointers initalized to point
2787 * to "real" GLX functions (which understand GLX wire protocol, etc).
2789 struct _glxapi_table
*
2790 _mesa_GetGLXDispatchTable(void)
2792 static struct _glxapi_table glx
;
2794 /* be sure our dispatch table size <= libGL's table */
2796 GLuint size
= sizeof(struct _glxapi_table
) / sizeof(void *);
2798 assert(_glxapi_get_dispatch_table_size() >= size
);
2801 /* initialize the whole table to no-ops */
2802 _glxapi_set_no_op_table(&glx
);
2804 /* now initialize the table with the functions I implement */
2805 glx
.ChooseVisual
= Fake_glXChooseVisual
;
2806 glx
.CopyContext
= Fake_glXCopyContext
;
2807 glx
.CreateContext
= Fake_glXCreateContext
;
2808 glx
.CreateGLXPixmap
= Fake_glXCreateGLXPixmap
;
2809 glx
.DestroyContext
= Fake_glXDestroyContext
;
2810 glx
.DestroyGLXPixmap
= Fake_glXDestroyGLXPixmap
;
2811 glx
.GetConfig
= Fake_glXGetConfig
;
2812 glx
.GetCurrentContext
= Fake_glXGetCurrentContext
;
2813 /*glx.GetCurrentDrawable = Fake_glXGetCurrentDrawable;*/
2814 glx
.IsDirect
= Fake_glXIsDirect
;
2815 glx
.MakeCurrent
= Fake_glXMakeCurrent
;
2816 glx
.QueryExtension
= Fake_glXQueryExtension
;
2817 glx
.QueryVersion
= Fake_glXQueryVersion
;
2818 glx
.SwapBuffers
= Fake_glXSwapBuffers
;
2819 glx
.UseXFont
= Fake_glXUseXFont
;
2820 glx
.WaitGL
= Fake_glXWaitGL
;
2821 glx
.WaitX
= Fake_glXWaitX
;
2823 /*** GLX_VERSION_1_1 ***/
2824 glx
.GetClientString
= Fake_glXGetClientString
;
2825 glx
.QueryExtensionsString
= Fake_glXQueryExtensionsString
;
2826 glx
.QueryServerString
= Fake_glXQueryServerString
;
2828 /*** GLX_VERSION_1_2 ***/
2829 /*glx.GetCurrentDisplay = Fake_glXGetCurrentDisplay;*/
2831 /*** GLX_VERSION_1_3 ***/
2832 glx
.ChooseFBConfig
= Fake_glXChooseFBConfig
;
2833 glx
.CreateNewContext
= Fake_glXCreateNewContext
;
2834 glx
.CreatePbuffer
= Fake_glXCreatePbuffer
;
2835 glx
.CreatePixmap
= Fake_glXCreatePixmap
;
2836 glx
.CreateWindow
= Fake_glXCreateWindow
;
2837 glx
.DestroyPbuffer
= Fake_glXDestroyPbuffer
;
2838 glx
.DestroyPixmap
= Fake_glXDestroyPixmap
;
2839 glx
.DestroyWindow
= Fake_glXDestroyWindow
;
2840 /*glx.GetCurrentReadDrawable = Fake_glXGetCurrentReadDrawable;*/
2841 glx
.GetFBConfigAttrib
= Fake_glXGetFBConfigAttrib
;
2842 glx
.GetFBConfigs
= Fake_glXGetFBConfigs
;
2843 glx
.GetSelectedEvent
= Fake_glXGetSelectedEvent
;
2844 glx
.GetVisualFromFBConfig
= Fake_glXGetVisualFromFBConfig
;
2845 glx
.MakeContextCurrent
= Fake_glXMakeContextCurrent
;
2846 glx
.QueryContext
= Fake_glXQueryContext
;
2847 glx
.QueryDrawable
= Fake_glXQueryDrawable
;
2848 glx
.SelectEvent
= Fake_glXSelectEvent
;
2850 /*** GLX_SGI_swap_control ***/
2851 glx
.SwapIntervalSGI
= Fake_glXSwapIntervalSGI
;
2853 /*** GLX_SGI_video_sync ***/
2854 glx
.GetVideoSyncSGI
= Fake_glXGetVideoSyncSGI
;
2855 glx
.WaitVideoSyncSGI
= Fake_glXWaitVideoSyncSGI
;
2857 /*** GLX_SGI_make_current_read ***/
2858 glx
.MakeCurrentReadSGI
= Fake_glXMakeCurrentReadSGI
;
2859 /*glx.GetCurrentReadDrawableSGI = Fake_glXGetCurrentReadDrawableSGI;*/
2861 /*** GLX_SGIX_video_source ***/
2863 glx
.CreateGLXVideoSourceSGIX
= Fake_glXCreateGLXVideoSourceSGIX
;
2864 glx
.DestroyGLXVideoSourceSGIX
= Fake_glXDestroyGLXVideoSourceSGIX
;
2867 /*** GLX_EXT_import_context ***/
2868 glx
.FreeContextEXT
= Fake_glXFreeContextEXT
;
2869 glx
.GetContextIDEXT
= Fake_glXGetContextIDEXT
;
2870 /*glx.GetCurrentDisplayEXT = Fake_glXGetCurrentDisplayEXT;*/
2871 glx
.ImportContextEXT
= Fake_glXImportContextEXT
;
2872 glx
.QueryContextInfoEXT
= Fake_glXQueryContextInfoEXT
;
2874 /*** GLX_SGIX_fbconfig ***/
2875 glx
.GetFBConfigAttribSGIX
= Fake_glXGetFBConfigAttribSGIX
;
2876 glx
.ChooseFBConfigSGIX
= Fake_glXChooseFBConfigSGIX
;
2877 glx
.CreateGLXPixmapWithConfigSGIX
= Fake_glXCreateGLXPixmapWithConfigSGIX
;
2878 glx
.CreateContextWithConfigSGIX
= Fake_glXCreateContextWithConfigSGIX
;
2879 glx
.GetVisualFromFBConfigSGIX
= Fake_glXGetVisualFromFBConfigSGIX
;
2880 glx
.GetFBConfigFromVisualSGIX
= Fake_glXGetFBConfigFromVisualSGIX
;
2882 /*** GLX_SGIX_pbuffer ***/
2883 glx
.CreateGLXPbufferSGIX
= Fake_glXCreateGLXPbufferSGIX
;
2884 glx
.DestroyGLXPbufferSGIX
= Fake_glXDestroyGLXPbufferSGIX
;
2885 glx
.QueryGLXPbufferSGIX
= Fake_glXQueryGLXPbufferSGIX
;
2886 glx
.SelectEventSGIX
= Fake_glXSelectEventSGIX
;
2887 glx
.GetSelectedEventSGIX
= Fake_glXGetSelectedEventSGIX
;
2889 /*** GLX_SGI_cushion ***/
2890 glx
.CushionSGI
= Fake_glXCushionSGI
;
2892 /*** GLX_SGIX_video_resize ***/
2893 glx
.BindChannelToWindowSGIX
= Fake_glXBindChannelToWindowSGIX
;
2894 glx
.ChannelRectSGIX
= Fake_glXChannelRectSGIX
;
2895 glx
.QueryChannelRectSGIX
= Fake_glXQueryChannelRectSGIX
;
2896 glx
.QueryChannelDeltasSGIX
= Fake_glXQueryChannelDeltasSGIX
;
2897 glx
.ChannelRectSyncSGIX
= Fake_glXChannelRectSyncSGIX
;
2899 /*** GLX_SGIX_dmbuffer **/
2900 #if defined(_DM_BUFFER_H_)
2901 glx
.AssociateDMPbufferSGIX
= NULL
;
2904 /*** GLX_SUN_get_transparent_index ***/
2905 glx
.GetTransparentIndexSUN
= Fake_glXGetTransparentIndexSUN
;
2907 /*** GLX_MESA_copy_sub_buffer ***/
2908 glx
.CopySubBufferMESA
= Fake_glXCopySubBufferMESA
;
2910 /*** GLX_MESA_release_buffers ***/
2911 glx
.ReleaseBuffersMESA
= Fake_glXReleaseBuffersMESA
;
2913 /*** GLX_MESA_pixmap_colormap ***/
2914 glx
.CreateGLXPixmapMESA
= Fake_glXCreateGLXPixmapMESA
;
2916 /*** GLX_EXT_texture_from_pixmap ***/
2917 glx
.BindTexImageEXT
= Fake_glXBindTexImageEXT
;
2918 glx
.ReleaseTexImageEXT
= Fake_glXReleaseTexImageEXT
;
2920 glx
.CreateContextAttribs
= Fake_glXCreateContextAttribs
;