1 /* $Id: fakeglx.c,v 1.69 2002/10/05 18:27:41 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 * This is an emulation of the GLX API which allows Mesa/GLX-based programs
30 * to run on X servers which do not have the real GLX extension.
32 * Thanks to the contributors:
34 * Initial version: Philip Brown (phil@bolthole.com)
35 * Better glXGetConfig() support: Armin Liebchen (liebchen@asylum.cs.utah.edu)
36 * Further visual-handling refinements: Wolfram Gloger
37 * (wmglo@Dent.MED.Uni-Muenchen.DE).
40 * Don't be fooled, stereo isn't supported yet.
45 #include "glxheader.h"
58 /* This indicates the client-side GLX API and GLX encoder version. */
59 #define CLIENT_MAJOR_VERSION 1
60 #define CLIENT_MINOR_VERSION 4 /* but don't have 1.3's pbuffers, etc yet */
62 /* This indicates the server-side GLX decoder version.
63 * GLX 1.4 indicates OpenGL 1.3 support
65 #define SERVER_MAJOR_VERSION 1
66 #define SERVER_MINOR_VERSION 4
68 /* This is appended onto the glXGetClient/ServerString version strings. */
69 #define MESA_GLX_VERSION "Mesa 4.1"
71 /* Who implemented this GLX? */
72 #define VENDOR "Brian Paul"
75 "GLX_MESA_set_3dfx_mode " \
76 "GLX_MESA_copy_sub_buffer " \
77 "GLX_MESA_pixmap_colormap " \
78 "GLX_MESA_release_buffers " \
79 "GLX_ARB_get_proc_address " \
80 "GLX_EXT_visual_info " \
81 "GLX_EXT_visual_rating " \
82 "GLX_SGI_video_sync " \
83 "GLX_SGIX_fbconfig " \
87 /* Silence compiler warnings */
88 extern void Fake_glXDummyFunc( void );
89 void Fake_glXDummyFunc( void )
99 * Our fake GLX context will contain a "real" GLX context and an XMesa context.
101 * Note that a pointer to a __GLXcontext is a pointer to a fake_glx_context,
104 * We really just need this structure in order to make the libGL functions
105 * glXGetCurrentContext(), glXGetCurrentDrawable() and glXGetCurrentDisplay()
108 struct fake_glx_context
{
109 __GLXcontext glxContext
; /* this MUST be first! */
110 XMesaContext xmesaContext
;
115 /**********************************************************************/
116 /*** GLX Visual Code ***/
117 /**********************************************************************/
122 #define MAX_VISUALS 100
123 static XMesaVisual VisualTable
[MAX_VISUALS
];
124 static int NumVisuals
= 0;
128 * This struct and some code fragments borrowed
129 * from Mark Kilgard's GLUT library.
131 typedef struct _OverlayInfo
{
132 /* Avoid 64-bit portability problems by being careful to use
133 longs due to the way XGetWindowProperty is specified. Note
134 that these parameters are passed as CARD32s over X
136 unsigned long overlay_visual
;
137 long transparent_type
;
144 /* Macro to handle c_class vs class field name in XVisualInfo struct */
145 #if defined(__cplusplus) || defined(c_plusplus)
146 #define CLASS c_class
155 * Test if the given XVisualInfo is usable for Mesa rendering.
157 static GLboolean
is_usable_visual( XVisualInfo
*vinfo
)
159 switch (vinfo
->CLASS
) {
162 /* Any StaticGray/GrayScale visual works in RGB or CI mode */
166 /* Any StaticColor/PseudoColor visual of at least 4 bits */
167 if (vinfo
->depth
>=4) {
175 /* Any depth of TrueColor or DirectColor works in RGB mode */
178 /* This should never happen */
186 * Return the level (overlay, normal, underlay) of a given XVisualInfo.
187 * Input: dpy - the X display
188 * vinfo - the XVisualInfo to test
189 * Return: level of the visual:
191 * >0 = overlay planes
192 * <0 = underlay planes
194 static int level_of_visual( Display
*dpy
, XVisualInfo
*vinfo
)
196 Atom overlayVisualsAtom
;
197 OverlayInfo
*overlay_info
= NULL
;
198 int numOverlaysPerScreen
;
202 unsigned long sizeData
, bytesLeft
;
206 * The SERVER_OVERLAY_VISUALS property on the root window contains
207 * a list of overlay visuals. Get that list now.
209 overlayVisualsAtom
= XInternAtom(dpy
,"SERVER_OVERLAY_VISUALS", True
);
210 if (overlayVisualsAtom
== None
) {
214 status
= XGetWindowProperty(dpy
, RootWindow( dpy
, vinfo
->screen
),
215 overlayVisualsAtom
, 0L, (long) 10000, False
,
216 overlayVisualsAtom
, &actualType
, &actualFormat
,
217 &sizeData
, &bytesLeft
,
218 (unsigned char **) &overlay_info
);
220 if (status
!= Success
|| actualType
!= overlayVisualsAtom
||
221 actualFormat
!= 32 || sizeData
< 4) {
222 /* something went wrong */
223 XFree((void *) overlay_info
);
227 /* search the overlay visual list for the visual ID of interest */
228 numOverlaysPerScreen
= (int) (sizeData
/ 4);
229 for (i
=0;i
<numOverlaysPerScreen
;i
++) {
231 ov
= overlay_info
+ i
;
232 if (ov
->overlay_visual
==vinfo
->visualid
) {
233 /* found the visual */
234 if (/*ov->transparent_type==1 &&*/ ov
->layer
!=0) {
235 int level
= ov
->layer
;
236 XFree((void *) overlay_info
);
240 XFree((void *) overlay_info
);
246 /* The visual ID was not found in the overlay list. */
247 XFree((void *) overlay_info
);
255 * Given an XVisualInfo and RGB, Double, and Depth buffer flags, save the
256 * configuration in our list of GLX visuals.
259 save_glx_visual( Display
*dpy
, XVisualInfo
*vinfo
,
260 GLboolean rgbFlag
, GLboolean alphaFlag
, GLboolean dbFlag
,
261 GLboolean stereoFlag
,
262 GLint depth_size
, GLint stencil_size
,
263 GLint accumRedSize
, GLint accumGreenSize
,
264 GLint accumBlueSize
, GLint accumAlphaSize
,
267 GLboolean ximageFlag
= GL_TRUE
;
270 GLboolean comparePointers
;
273 /* Check if the MESA_BACK_BUFFER env var is set */
274 char *backbuffer
= getenv("MESA_BACK_BUFFER");
276 if (backbuffer
[0]=='p' || backbuffer
[0]=='P') {
277 ximageFlag
= GL_FALSE
;
279 else if (backbuffer
[0]=='x' || backbuffer
[0]=='X') {
280 ximageFlag
= GL_TRUE
;
283 _mesa_warning(NULL
, "Mesa: invalid value for MESA_BACK_BUFFER environment variable, using an XImage.");
288 /* Comparing IDs uses less memory but sometimes fails. */
289 /* XXX revisit this after 3.0 is finished. */
290 if (getenv("MESA_GLX_VISUAL_HACK"))
291 comparePointers
= GL_TRUE
;
293 comparePointers
= GL_FALSE
;
295 /* First check if a matching visual is already in the list */
296 for (i
=0; i
<NumVisuals
; i
++) {
297 XMesaVisual v
= VisualTable
[i
];
298 if (v
->display
== dpy
300 && v
->ximage_flag
== ximageFlag
301 && v
->mesa_visual
.rgbMode
== rgbFlag
302 && v
->mesa_visual
.doubleBufferMode
== dbFlag
303 && v
->mesa_visual
.stereoMode
== stereoFlag
304 && (v
->mesa_visual
.alphaBits
> 0) == alphaFlag
305 && (v
->mesa_visual
.depthBits
>= depth_size
|| depth_size
== 0)
306 && (v
->mesa_visual
.stencilBits
>= stencil_size
|| stencil_size
== 0)
307 && (v
->mesa_visual
.accumRedBits
>= accumRedSize
|| accumRedSize
== 0)
308 && (v
->mesa_visual
.accumGreenBits
>= accumGreenSize
|| accumGreenSize
== 0)
309 && (v
->mesa_visual
.accumBlueBits
>= accumBlueSize
|| accumBlueSize
== 0)
310 && (v
->mesa_visual
.accumAlphaBits
>= accumAlphaSize
|| accumAlphaSize
== 0)) {
311 /* now either compare XVisualInfo pointers or visual IDs */
312 if ((!comparePointers
&& v
->visinfo
->visualid
== vinfo
->visualid
)
313 || (comparePointers
&& v
->vishandle
== vinfo
)) {
319 /* Create a new visual and add it to the list. */
321 if (NumVisuals
>= MAX_VISUALS
) {
322 _mesa_problem(NULL
, "GLX Error: maximum number of visuals exceeded");
326 xmvis
= XMesaCreateVisual( dpy
, vinfo
, rgbFlag
, alphaFlag
, dbFlag
,
327 stereoFlag
, ximageFlag
,
328 depth_size
, stencil_size
,
329 accumRedSize
, accumBlueSize
,
330 accumBlueSize
, accumAlphaSize
, 0, level
,
333 VisualTable
[NumVisuals
] = xmvis
;
342 * Create a GLX visual from a regular XVisualInfo.
343 * This is called when Fake GLX is given an XVisualInfo which wasn't
344 * returned by glXChooseVisual. Since this is the first time we're
345 * considering this visual we'll take a guess at reasonable values
346 * for depth buffer size, stencil size, accum size, etc.
347 * This is the best we can do with a client-side emulation of GLX.
350 create_glx_visual( Display
*dpy
, XVisualInfo
*visinfo
)
354 vislevel
= level_of_visual( dpy
, visinfo
);
356 /* Configure this visual as a CI, single-buffered overlay */
357 return save_glx_visual( dpy
, visinfo
,
359 GL_FALSE
, /* alpha */
360 GL_FALSE
, /* double */
361 GL_FALSE
, /* stereo */
363 0, /* stencil bits */
364 0,0,0,0, /* accum bits */
368 else if (is_usable_visual( visinfo
)) {
369 if (getenv("MESA_GLX_FORCE_CI")) {
370 /* Configure this visual as a COLOR INDEX visual. */
371 return save_glx_visual( dpy
, visinfo
,
373 GL_FALSE
, /* alpha */
374 GL_TRUE
, /* double */
375 GL_FALSE
, /* stereo */
376 DEFAULT_SOFTWARE_DEPTH_BITS
,
377 8 * sizeof(GLstencil
),
378 0 * sizeof(GLaccum
), /* r */
379 0 * sizeof(GLaccum
), /* g */
380 0 * sizeof(GLaccum
), /* b */
381 0 * sizeof(GLaccum
), /* a */
386 /* Configure this visual as RGB, double-buffered, depth-buffered. */
387 /* This is surely wrong for some people's needs but what else */
388 /* can be done? They should use glXChooseVisual(). */
389 return save_glx_visual( dpy
, visinfo
,
391 GL_FALSE
, /* alpha */
392 GL_TRUE
, /* double */
393 GL_FALSE
, /* stereo */
394 DEFAULT_SOFTWARE_DEPTH_BITS
,
395 8 * sizeof(GLstencil
),
396 8 * sizeof(GLaccum
), /* r */
397 8 * sizeof(GLaccum
), /* g */
398 8 * sizeof(GLaccum
), /* b */
399 8 * sizeof(GLaccum
), /* a */
405 _mesa_warning(NULL
, "Mesa: error in glXCreateContext: bad visual\n");
413 * Find the GLX visual associated with an XVisualInfo.
416 find_glx_visual( Display
*dpy
, XVisualInfo
*vinfo
)
420 /* First try to match pointers */
421 for (i
=0;i
<NumVisuals
;i
++) {
422 if (VisualTable
[i
]->display
==dpy
&& VisualTable
[i
]->vishandle
==vinfo
) {
423 return VisualTable
[i
];
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
];
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
443 static int transparent_pixel( XMesaVisual glxvis
)
445 Display
*dpy
= glxvis
->display
;
446 XVisualInfo
*vinfo
= glxvis
->visinfo
;
447 Atom overlayVisualsAtom
;
448 OverlayInfo
*overlay_info
= NULL
;
449 int numOverlaysPerScreen
;
453 unsigned long sizeData
, bytesLeft
;
457 * The SERVER_OVERLAY_VISUALS property on the root window contains
458 * a list of overlay visuals. Get that list now.
460 overlayVisualsAtom
= XInternAtom(dpy
,"SERVER_OVERLAY_VISUALS", True
);
461 if (overlayVisualsAtom
== None
) {
465 status
= XGetWindowProperty(dpy
, RootWindow( dpy
, vinfo
->screen
),
466 overlayVisualsAtom
, 0L, (long) 10000, False
,
467 overlayVisualsAtom
, &actualType
, &actualFormat
,
468 &sizeData
, &bytesLeft
,
469 (unsigned char **) &overlay_info
);
471 if (status
!= Success
|| actualType
!= overlayVisualsAtom
||
472 actualFormat
!= 32 || sizeData
< 4) {
473 /* something went wrong */
474 XFree((void *) overlay_info
);
478 /* search the overlay visual list for the visual ID of interest */
479 numOverlaysPerScreen
= (int) (sizeData
/ 4);
480 for (i
=0;i
<numOverlaysPerScreen
;i
++) {
482 ov
= overlay_info
+ i
;
483 if (ov
->overlay_visual
==vinfo
->visualid
) {
485 if (ov
->transparent_type
==0) {
486 /* type 0 indicates no transparency */
487 XFree((void *) overlay_info
);
491 /* ov->value is the transparent pixel */
492 XFree((void *) overlay_info
);
498 /* The visual ID was not found in the overlay list. */
499 XFree((void *) overlay_info
);
506 * Try to get an X visual which matches the given arguments.
508 static XVisualInfo
*get_visual( Display
*dpy
, int scr
,
509 unsigned int depth
, int xclass
)
511 XVisualInfo temp
, *vis
;
514 unsigned int default_depth
;
517 mask
= VisualScreenMask
| VisualDepthMask
| VisualClassMask
;
522 default_depth
= DefaultDepth(dpy
,scr
);
523 default_class
= DefaultVisual(dpy
,scr
)->CLASS
;
525 if (depth
==default_depth
&& xclass
==default_class
) {
526 /* try to get root window's visual */
527 temp
.visualid
= DefaultVisual(dpy
,scr
)->visualid
;
528 mask
|= VisualIDMask
;
531 vis
= XGetVisualInfo( dpy
, mask
, &temp
, &n
);
533 /* In case bits/pixel > 24, make sure color channels are still <=8 bits.
534 * An SGI Infinite Reality system, for example, can have 30bpp pixels:
535 * 10 bits per color channel. Mesa's limited to a max of 8 bits/channel.
537 if (vis
&& depth
> 24 && (xclass
==TrueColor
|| xclass
==DirectColor
)) {
538 if (_mesa_bitcount((GLuint
) vis
->red_mask
) <= 8 &&
539 _mesa_bitcount((GLuint
) vis
->green_mask
) <= 8 &&
540 _mesa_bitcount((GLuint
) vis
->blue_mask
) <= 8) {
555 * Retrieve the value of the given environment variable and find
556 * the X visual which matches it.
557 * Input: dpy - the display
558 * screen - the screen number
559 * varname - the name of the environment variable
560 * Return: an XVisualInfo pointer to NULL if error.
562 static XVisualInfo
*get_env_visual(Display
*dpy
, int scr
, const char *varname
)
564 char value
[100], type
[100];
565 int depth
, xclass
= -1;
568 if (!getenv( varname
)) {
572 strncpy( value
, getenv(varname
), 100 );
575 sscanf( value
, "%s %d", type
, &depth
);
577 if (strcmp(type
,"TrueColor")==0) xclass
= TrueColor
;
578 else if (strcmp(type
,"DirectColor")==0) xclass
= DirectColor
;
579 else if (strcmp(type
,"PseudoColor")==0) xclass
= PseudoColor
;
580 else if (strcmp(type
,"StaticColor")==0) xclass
= StaticColor
;
581 else if (strcmp(type
,"GrayScale")==0) xclass
= GrayScale
;
582 else if (strcmp(type
,"StaticGray")==0) xclass
= StaticGray
;
584 if (xclass
>-1 && depth
>0) {
585 vis
= get_visual( dpy
, scr
, depth
, xclass
);
593 sprintf(s
, "Mesa: GLX unable to find visual class=%s, depth=%d.\n",
595 _mesa_warning(NULL
, s
);
604 * Select an X visual which satisfies the RGBA/CI flag and minimum depth.
605 * Input: dpy, screen - X display and screen number
606 * rgba - GL_TRUE = RGBA mode, GL_FALSE = CI mode
607 * min_depth - minimum visual depth
608 * preferred_class - preferred GLX visual class or DONT_CARE
609 * Return: pointer to an XVisualInfo or NULL.
611 static XVisualInfo
*choose_x_visual( Display
*dpy
, int screen
,
612 GLboolean rgba
, int min_depth
,
613 int preferred_class
)
616 int xclass
, visclass
= 0;
620 Atom hp_cr_maps
= XInternAtom(dpy
, "_HP_RGB_SMOOTH_MAP_LIST", True
);
621 /* First see if the MESA_RGB_VISUAL env var is defined */
622 vis
= get_env_visual( dpy
, screen
, "MESA_RGB_VISUAL" );
626 /* Otherwise, search for a suitable visual */
627 if (preferred_class
==DONT_CARE
) {
628 for (xclass
=0;xclass
<6;xclass
++) {
630 case 0: visclass
= TrueColor
; break;
631 case 1: visclass
= DirectColor
; break;
632 case 2: visclass
= PseudoColor
; break;
633 case 3: visclass
= StaticColor
; break;
634 case 4: visclass
= GrayScale
; break;
635 case 5: visclass
= StaticGray
; break;
638 /* start with shallowest */
639 for (depth
=0;depth
<=32;depth
++) {
640 if (visclass
==TrueColor
&& depth
==8 && !hp_cr_maps
) {
641 /* Special case: try to get 8-bit PseudoColor before */
642 /* 8-bit TrueColor */
643 vis
= get_visual( dpy
, screen
, 8, PseudoColor
);
648 vis
= get_visual( dpy
, screen
, depth
, visclass
);
655 /* start with deepest */
656 for (depth
=32;depth
>=min_depth
;depth
--) {
657 if (visclass
==TrueColor
&& depth
==8 && !hp_cr_maps
) {
658 /* Special case: try to get 8-bit PseudoColor before */
659 /* 8-bit TrueColor */
660 vis
= get_visual( dpy
, screen
, 8, PseudoColor
);
665 vis
= get_visual( dpy
, screen
, depth
, visclass
);
674 /* search for a specific visual class */
675 switch (preferred_class
) {
676 case GLX_TRUE_COLOR_EXT
: visclass
= TrueColor
; break;
677 case GLX_DIRECT_COLOR_EXT
: visclass
= DirectColor
; break;
678 case GLX_PSEUDO_COLOR_EXT
: visclass
= PseudoColor
; break;
679 case GLX_STATIC_COLOR_EXT
: visclass
= StaticColor
; break;
680 case GLX_GRAY_SCALE_EXT
: visclass
= GrayScale
; break;
681 case GLX_STATIC_GRAY_EXT
: visclass
= StaticGray
; break;
682 default: return NULL
;
685 /* start with shallowest */
686 for (depth
=0;depth
<=32;depth
++) {
687 vis
= get_visual( dpy
, screen
, depth
, visclass
);
694 /* start with deepest */
695 for (depth
=32;depth
>=min_depth
;depth
--) {
696 vis
= get_visual( dpy
, screen
, depth
, visclass
);
705 /* First see if the MESA_CI_VISUAL env var is defined */
706 vis
= get_env_visual( dpy
, screen
, "MESA_CI_VISUAL" );
710 /* Otherwise, search for a suitable visual, starting with shallowest */
711 if (preferred_class
==DONT_CARE
) {
712 for (xclass
=0;xclass
<4;xclass
++) {
714 case 0: visclass
= PseudoColor
; break;
715 case 1: visclass
= StaticColor
; break;
716 case 2: visclass
= GrayScale
; break;
717 case 3: visclass
= StaticGray
; break;
719 /* try 8-bit up through 16-bit */
720 for (depth
=8;depth
<=16;depth
++) {
721 vis
= get_visual( dpy
, screen
, depth
, visclass
);
726 /* try min_depth up to 8-bit */
727 for (depth
=min_depth
;depth
<8;depth
++) {
728 vis
= get_visual( dpy
, screen
, depth
, visclass
);
736 /* search for a specific visual class */
737 switch (preferred_class
) {
738 case GLX_TRUE_COLOR_EXT
: visclass
= TrueColor
; break;
739 case GLX_DIRECT_COLOR_EXT
: visclass
= DirectColor
; break;
740 case GLX_PSEUDO_COLOR_EXT
: visclass
= PseudoColor
; break;
741 case GLX_STATIC_COLOR_EXT
: visclass
= StaticColor
; break;
742 case GLX_GRAY_SCALE_EXT
: visclass
= GrayScale
; break;
743 case GLX_STATIC_GRAY_EXT
: visclass
= StaticGray
; break;
744 default: return NULL
;
746 /* try 8-bit up through 16-bit */
747 for (depth
=8;depth
<=16;depth
++) {
748 vis
= get_visual( dpy
, screen
, depth
, visclass
);
753 /* try min_depth up to 8-bit */
754 for (depth
=min_depth
;depth
<8;depth
++) {
755 vis
= get_visual( dpy
, screen
, depth
, visclass
);
763 /* didn't find a visual */
770 * Find the deepest X over/underlay visual of at least min_depth.
771 * Input: dpy, screen - X display and screen number
772 * level - the over/underlay level
773 * trans_type - transparent pixel type: GLX_NONE_EXT,
774 * GLX_TRANSPARENT_RGB_EXT, GLX_TRANSPARENT_INDEX_EXT,
776 * trans_value - transparent pixel value or DONT_CARE
777 * min_depth - minimum visual depth
778 * preferred_class - preferred GLX visual class or DONT_CARE
779 * Return: pointer to an XVisualInfo or NULL.
781 static XVisualInfo
*choose_x_overlay_visual( Display
*dpy
, int scr
,
783 int level
, int trans_type
,
786 int preferred_class
)
788 Atom overlayVisualsAtom
;
789 OverlayInfo
*overlay_info
;
790 int numOverlaysPerScreen
;
794 unsigned long sizeData
, bytesLeft
;
796 XVisualInfo
*deepvis
;
799 /*DEBUG int tt, tv; */
801 switch (preferred_class
) {
802 case GLX_TRUE_COLOR_EXT
: preferred_class
= TrueColor
; break;
803 case GLX_DIRECT_COLOR_EXT
: preferred_class
= DirectColor
; break;
804 case GLX_PSEUDO_COLOR_EXT
: preferred_class
= PseudoColor
; break;
805 case GLX_STATIC_COLOR_EXT
: preferred_class
= StaticColor
; break;
806 case GLX_GRAY_SCALE_EXT
: preferred_class
= GrayScale
; break;
807 case GLX_STATIC_GRAY_EXT
: preferred_class
= StaticGray
; break;
808 default: preferred_class
= DONT_CARE
;
812 * The SERVER_OVERLAY_VISUALS property on the root window contains
813 * a list of overlay visuals. Get that list now.
815 overlayVisualsAtom
= XInternAtom(dpy
,"SERVER_OVERLAY_VISUALS", True
);
816 if (overlayVisualsAtom
== (Atom
) None
) {
820 status
= XGetWindowProperty(dpy
, RootWindow( dpy
, scr
),
821 overlayVisualsAtom
, 0L, (long) 10000, False
,
822 overlayVisualsAtom
, &actualType
, &actualFormat
,
823 &sizeData
, &bytesLeft
,
824 (unsigned char **) &overlay_info
);
826 if (status
!= Success
|| actualType
!= overlayVisualsAtom
||
827 actualFormat
!= 32 || sizeData
< 4) {
828 /* something went wrong */
832 /* Search for the deepest overlay which satisifies all criteria. */
836 numOverlaysPerScreen
= (int) (sizeData
/ 4);
837 for (i
=0;i
<numOverlaysPerScreen
;i
++) {
838 XVisualInfo
*vislist
, vistemplate
;
841 ov
= overlay_info
+ i
;
843 if (ov
->layer
!=level
) {
844 /* failed overlay level criteria */
847 if (!(trans_type
==DONT_CARE
848 || (trans_type
==GLX_TRANSPARENT_INDEX_EXT
849 && ov
->transparent_type
>0)
850 || (trans_type
==GLX_NONE_EXT
&& ov
->transparent_type
==0))) {
851 /* failed transparent pixel type criteria */
854 if (trans_value
!=DONT_CARE
&& trans_value
!=ov
->value
) {
855 /* failed transparent pixel value criteria */
859 /* get XVisualInfo and check the depth */
860 vistemplate
.visualid
= ov
->overlay_visual
;
861 vistemplate
.screen
= scr
;
862 vislist
= XGetVisualInfo( dpy
, VisualIDMask
| VisualScreenMask
,
863 &vistemplate
, &count
);
866 /* something went wrong */
869 if (preferred_class
!=DONT_CARE
&& preferred_class
!=vislist
->CLASS
) {
870 /* wrong visual class */
874 /* if RGB was requested, make sure we have True/DirectColor */
875 if (rgbFlag
&& vislist
->CLASS
!= TrueColor
876 && vislist
->CLASS
!= DirectColor
)
879 /* if CI was requested, make sure we have a color indexed visual */
881 && (vislist
->CLASS
== TrueColor
|| vislist
->CLASS
== DirectColor
))
884 if (deepvis
==NULL
|| vislist
->depth
> deepest
) {
885 /* YES! found a satisfactory visual */
889 deepest
= vislist
->depth
;
891 /* DEBUG tt = ov->transparent_type;*/
892 /* DEBUG tv = ov->value; */
898 printf("chose 0x%x: layer=%d depth=%d trans_type=%d trans_value=%d\n",
899 deepvis->visualid, level, deepvis->depth, tt, tv );
906 /**********************************************************************/
907 /*** Begin Fake GLX API Functions ***/
908 /**********************************************************************/
911 static XMesaVisual
choose_visual( Display
*dpy
, int screen
, const int *list
)
913 const int *parselist
;
916 int min_red
=0, min_green
=0, min_blue
=0;
917 GLboolean rgb_flag
= GL_FALSE
;
918 GLboolean alpha_flag
= GL_FALSE
;
919 GLboolean double_flag
= GL_FALSE
;
920 GLboolean stereo_flag
= GL_FALSE
;
921 GLint depth_size
= 0;
922 GLint stencil_size
= 0;
923 GLint accumRedSize
= 0;
924 GLint accumGreenSize
= 0;
925 GLint accumBlueSize
= 0;
926 GLint accumAlphaSize
= 0;
928 int visual_type
= DONT_CARE
;
929 int trans_type
= DONT_CARE
;
930 int trans_value
= DONT_CARE
;
931 GLint caveat
= DONT_CARE
;
932 XMesaVisual xmvis
= NULL
;
938 switch (*parselist
) {
943 case GLX_BUFFER_SIZE
:
945 min_ci
= *parselist
++;
949 level
= *parselist
++;
955 case GLX_DOUBLEBUFFER
:
956 double_flag
= GL_TRUE
;
960 stereo_flag
= GL_TRUE
;
962 case GLX_AUX_BUFFERS
:
969 min_red
= *parselist
++;
973 min_green
= *parselist
++;
977 min_blue
= *parselist
++;
982 GLint size
= *parselist
++;
983 alpha_flag
= size
>0 ? 1 : 0;
988 depth_size
= *parselist
++;
990 case GLX_STENCIL_SIZE
:
992 stencil_size
= *parselist
++;
994 case GLX_ACCUM_RED_SIZE
:
997 GLint size
= *parselist
++;
998 accumRedSize
= MAX2( accumRedSize
, size
);
1001 case GLX_ACCUM_GREEN_SIZE
:
1004 GLint size
= *parselist
++;
1005 accumGreenSize
= MAX2( accumGreenSize
, size
);
1008 case GLX_ACCUM_BLUE_SIZE
:
1011 GLint size
= *parselist
++;
1012 accumBlueSize
= MAX2( accumBlueSize
, size
);
1015 case GLX_ACCUM_ALPHA_SIZE
:
1018 GLint size
= *parselist
++;
1019 accumAlphaSize
= MAX2( accumAlphaSize
, size
);
1024 * GLX_EXT_visual_info extension
1026 case GLX_X_VISUAL_TYPE_EXT
:
1028 visual_type
= *parselist
++;
1030 case GLX_TRANSPARENT_TYPE_EXT
:
1032 trans_type
= *parselist
++;
1034 case GLX_TRANSPARENT_INDEX_VALUE_EXT
:
1036 trans_value
= *parselist
++;
1038 case GLX_TRANSPARENT_RED_VALUE_EXT
:
1039 case GLX_TRANSPARENT_GREEN_VALUE_EXT
:
1040 case GLX_TRANSPARENT_BLUE_VALUE_EXT
:
1041 case GLX_TRANSPARENT_ALPHA_VALUE_EXT
:
1048 * GLX_EXT_visual_info extension
1050 case GLX_VISUAL_CAVEAT_EXT
:
1052 caveat
= *parselist
++; /* ignored for now */
1058 case GLX_RENDER_TYPE
:
1060 if (*parselist
== GLX_RGBA_BIT
) {
1063 else if (*parselist
== GLX_COLOR_INDEX_BIT
) {
1064 rgb_flag
= GL_FALSE
;
1066 else if (*parselist
== 0) {
1071 case GLX_DRAWABLE_TYPE
:
1073 if (*parselist
& ~(GLX_WINDOW_BIT
| GLX_PIXMAP_BIT
| GLX_PBUFFER_BIT
)) {
1074 return NULL
; /* bad bit */
1083 /* undefined attribute */
1084 printf("unexpected attrib 0x%x\n", *parselist
);
1090 * Since we're only simulating the GLX extension this function will never
1091 * find any real GL visuals. Instead, all we can do is try to find an RGB
1092 * or CI visual of appropriate depth. Other requested attributes such as
1093 * double buffering, depth buffer, etc. will be associated with the X
1094 * visual and stored in the VisualTable[].
1097 /* normal color planes */
1099 /* Get an RGB visual */
1100 int min_rgb
= min_red
+ min_green
+ min_blue
;
1101 if (min_rgb
>1 && min_rgb
<8) {
1102 /* a special case to be sure we can get a monochrome visual */
1105 vis
= choose_x_visual( dpy
, screen
, rgb_flag
, min_rgb
, visual_type
);
1108 /* Get a color index visual */
1109 vis
= choose_x_visual( dpy
, screen
, rgb_flag
, min_ci
, visual_type
);
1110 accumRedSize
= accumGreenSize
= accumBlueSize
= accumAlphaSize
= 0;
1114 /* over/underlay planes */
1117 int min_rgb
= min_red
+ min_green
+ min_blue
;
1118 if (min_rgb
>1 && min_rgb
<8) {
1119 /* a special case to be sure we can get a monochrome visual */
1122 vis
= choose_x_overlay_visual( dpy
, screen
, rgb_flag
, level
,
1123 trans_type
, trans_value
, min_rgb
, visual_type
);
1126 /* color index overlay */
1127 vis
= choose_x_overlay_visual( dpy
, screen
, rgb_flag
, level
,
1128 trans_type
, trans_value
, min_ci
, visual_type
);
1133 /* Note: we're not exactly obeying the glXChooseVisual rules here.
1134 * When GLX_DEPTH_SIZE = 1 is specified we're supposed to choose the
1135 * largest depth buffer size, which is 32bits/value. Instead, we
1136 * return 16 to maintain performance with earlier versions of Mesa.
1138 if (depth_size
> 24)
1139 depth_size
= 31; /* 32 causes int overflow problems */
1140 else if (depth_size
> 16)
1142 else if (depth_size
> 0)
1143 depth_size
= DEFAULT_SOFTWARE_DEPTH_BITS
; /*16*/
1145 /* we only support one size of stencil and accum buffers. */
1146 if (stencil_size
> 0)
1147 stencil_size
= STENCIL_BITS
;
1148 if (accumRedSize
> 0 || accumGreenSize
> 0 || accumBlueSize
> 0 ||
1149 accumAlphaSize
> 0) {
1150 accumRedSize
= ACCUM_BITS
;
1151 accumGreenSize
= ACCUM_BITS
;
1152 accumBlueSize
= ACCUM_BITS
;
1153 accumAlphaSize
= alpha_flag
? ACCUM_BITS
: 0;
1156 xmvis
= save_glx_visual( dpy
, vis
, rgb_flag
, alpha_flag
, double_flag
,
1157 stereo_flag
, depth_size
, stencil_size
,
1158 accumRedSize
, accumGreenSize
,
1159 accumBlueSize
, accumAlphaSize
, level
);
1166 static XVisualInfo
*
1167 Fake_glXChooseVisual( Display
*dpy
, int screen
, int *list
)
1169 XMesaVisual xmvis
= choose_visual(dpy
, screen
, list
);
1171 return xmvis
->vishandle
;
1178 Fake_glXCreateContext( Display
*dpy
, XVisualInfo
*visinfo
,
1179 GLXContext share_list
, Bool direct
)
1182 struct fake_glx_context
*glxCtx
;
1183 struct fake_glx_context
*shareCtx
= (struct fake_glx_context
*) share_list
;
1185 if (!dpy
|| !visinfo
)
1188 glxCtx
= CALLOC_STRUCT(fake_glx_context
);
1192 /* deallocate unused windows/buffers */
1193 XMesaGarbageCollect();
1195 xmvis
= find_glx_visual( dpy
, visinfo
);
1197 /* This visual wasn't found with glXChooseVisual() */
1198 xmvis
= create_glx_visual( dpy
, visinfo
);
1200 /* unusable visual */
1206 glxCtx
->xmesaContext
= XMesaCreateContext(xmvis
,
1207 shareCtx
? shareCtx
->xmesaContext
: NULL
);
1208 if (!glxCtx
->xmesaContext
) {
1213 glxCtx
->xmesaContext
->direct
= GL_FALSE
;
1214 glxCtx
->glxContext
.isDirect
= GL_FALSE
;
1215 glxCtx
->glxContext
.currentDpy
= dpy
;
1216 glxCtx
->glxContext
.xid
= (XID
) glxCtx
; /* self pointer */
1218 assert((void *) glxCtx
== (void *) &(glxCtx
->glxContext
));
1220 return (GLXContext
) glxCtx
;
1224 /* XXX these may have to be removed due to thread-safety issues. */
1225 static GLXContext MakeCurrent_PrevContext
= 0;
1226 static GLXDrawable MakeCurrent_PrevDrawable
= 0;
1227 static GLXDrawable MakeCurrent_PrevReadable
= 0;
1228 static XMesaBuffer MakeCurrent_PrevDrawBuffer
= 0;
1229 static XMesaBuffer MakeCurrent_PrevReadBuffer
= 0;
1232 /* GLX 1.3 and later */
1234 Fake_glXMakeContextCurrent( Display
*dpy
, GLXDrawable draw
,
1235 GLXDrawable read
, GLXContext ctx
)
1237 struct fake_glx_context
*glxCtx
= (struct fake_glx_context
*) ctx
;
1239 if (ctx
&& draw
&& read
) {
1240 XMesaBuffer drawBuffer
, readBuffer
;
1241 XMesaContext xmctx
= glxCtx
->xmesaContext
;
1243 /* Find the XMesaBuffer which corresponds to the GLXDrawable 'draw' */
1244 if (ctx
== MakeCurrent_PrevContext
1245 && draw
== MakeCurrent_PrevDrawable
) {
1246 drawBuffer
= MakeCurrent_PrevDrawBuffer
;
1249 drawBuffer
= XMesaFindBuffer( dpy
, draw
);
1252 /* drawable must be a new window! */
1253 drawBuffer
= XMesaCreateWindowBuffer2( xmctx
->xm_visual
, draw
, xmctx
);
1255 /* Out of memory, or context/drawable depth mismatch */
1260 /* Find the XMesaBuffer which corresponds to the GLXDrawable 'read' */
1261 if (ctx
== MakeCurrent_PrevContext
1262 && read
== MakeCurrent_PrevReadable
) {
1263 readBuffer
= MakeCurrent_PrevReadBuffer
;
1266 readBuffer
= XMesaFindBuffer( dpy
, read
);
1269 /* drawable must be a new window! */
1270 readBuffer
= XMesaCreateWindowBuffer2(glxCtx
->xmesaContext
->xm_visual
,
1273 /* Out of memory, or context/drawable depth mismatch */
1278 MakeCurrent_PrevContext
= ctx
;
1279 MakeCurrent_PrevDrawable
= draw
;
1280 MakeCurrent_PrevReadable
= read
;
1281 MakeCurrent_PrevDrawBuffer
= drawBuffer
;
1282 MakeCurrent_PrevReadBuffer
= readBuffer
;
1284 /* Now make current! */
1285 if (XMesaMakeCurrent2(xmctx
, drawBuffer
, readBuffer
)) {
1286 ((__GLXcontext
*) ctx
)->currentDpy
= dpy
;
1287 ((__GLXcontext
*) ctx
)->currentDrawable
= draw
;
1288 #ifndef GLX_BUILT_IN_XMESA
1289 ((__GLXcontext
*) ctx
)->currentReadable
= read
;
1291 __glXSetCurrentContext(ctx
);
1299 else if (!ctx
&& !draw
&& !read
) {
1300 /* release current context w/out assigning new one. */
1301 XMesaMakeCurrent( NULL
, NULL
);
1302 MakeCurrent_PrevContext
= 0;
1303 MakeCurrent_PrevDrawable
= 0;
1304 MakeCurrent_PrevReadable
= 0;
1305 MakeCurrent_PrevDrawBuffer
= 0;
1306 MakeCurrent_PrevReadBuffer
= 0;
1307 #ifdef GLX_BUILT_IN_XMESA
1308 /* XXX bind dummy context with __glXSetCurrentContext(ctx); */
1313 /* The args must either all be non-zero or all zero.
1323 Fake_glXMakeCurrent( Display
*dpy
, GLXDrawable drawable
, GLXContext ctx
)
1325 return Fake_glXMakeContextCurrent( dpy
, drawable
, drawable
, ctx
);
1331 Fake_glXCreateGLXPixmap( Display
*dpy
, XVisualInfo
*visinfo
, Pixmap pixmap
)
1336 v
= find_glx_visual( dpy
, visinfo
);
1338 v
= create_glx_visual( dpy
, visinfo
);
1340 /* unusable visual */
1345 b
= XMesaCreatePixmapBuffer( v
, pixmap
, 0 );
1349 return b
->frontbuffer
;
1353 /*** GLX_MESA_pixmap_colormap ***/
1356 Fake_glXCreateGLXPixmapMESA( Display
*dpy
, XVisualInfo
*visinfo
,
1357 Pixmap pixmap
, Colormap cmap
)
1362 v
= find_glx_visual( dpy
, visinfo
);
1364 v
= create_glx_visual( dpy
, visinfo
);
1366 /* unusable visual */
1371 b
= XMesaCreatePixmapBuffer( v
, pixmap
, cmap
);
1375 return b
->frontbuffer
;
1380 Fake_glXDestroyGLXPixmap( Display
*dpy
, GLXPixmap pixmap
)
1382 XMesaBuffer b
= XMesaFindBuffer(dpy
, pixmap
);
1384 XMesaDestroyBuffer(b
);
1386 else if (getenv("MESA_DEBUG")) {
1387 _mesa_warning(NULL
, "Mesa: glXDestroyGLXPixmap: invalid pixmap\n");
1394 Fake_glXCopyContext( Display
*dpy
, GLXContext src
, GLXContext dst
,
1395 unsigned long mask
)
1397 struct fake_glx_context
*fakeSrc
= (struct fake_glx_context
*) src
;
1398 struct fake_glx_context
*fakeDst
= (struct fake_glx_context
*) dst
;
1399 XMesaContext xm_src
= fakeSrc
->xmesaContext
;
1400 XMesaContext xm_dst
= fakeDst
->xmesaContext
;
1402 _mesa_copy_context( xm_src
->gl_ctx
, xm_dst
->gl_ctx
, (GLuint
) mask
);
1408 Fake_glXQueryExtension( Display
*dpy
, int *errorb
, int *event
)
1410 /* Mesa's GLX isn't really an X extension but we try to act like one. */
1418 extern void _kw_ungrab_all( Display
*dpy
);
1419 void _kw_ungrab_all( Display
*dpy
)
1421 XUngrabPointer( dpy
, CurrentTime
);
1422 XUngrabKeyboard( dpy
, CurrentTime
);
1427 Fake_glXDestroyContext( Display
*dpy
, GLXContext ctx
)
1429 struct fake_glx_context
*glxCtx
= (struct fake_glx_context
*) ctx
;
1431 MakeCurrent_PrevContext
= 0;
1432 MakeCurrent_PrevDrawable
= 0;
1433 MakeCurrent_PrevReadable
= 0;
1434 MakeCurrent_PrevDrawBuffer
= 0;
1435 MakeCurrent_PrevReadBuffer
= 0;
1436 XMesaDestroyContext( glxCtx
->xmesaContext
);
1437 XMesaGarbageCollect();
1443 Fake_glXIsDirect( Display
*dpy
, GLXContext ctx
)
1445 struct fake_glx_context
*glxCtx
= (struct fake_glx_context
*) ctx
;
1447 return glxCtx
->xmesaContext
->direct
;
1453 Fake_glXSwapBuffers( Display
*dpy
, GLXDrawable drawable
)
1455 XMesaBuffer buffer
= XMesaFindBuffer( dpy
, drawable
);
1458 XMesaSwapBuffers(buffer
);
1460 else if (getenv("MESA_DEBUG")) {
1461 _mesa_warning(NULL
, "Mesa: glXSwapBuffers: invalid drawable\n");
1467 /*** GLX_MESA_copy_sub_buffer ***/
1470 Fake_glXCopySubBufferMESA( Display
*dpy
, GLXDrawable drawable
,
1471 int x
, int y
, int width
, int height
)
1473 XMesaBuffer buffer
= XMesaFindBuffer( dpy
, drawable
);
1475 XMesaCopySubBuffer(buffer
, x
, y
, width
, height
);
1477 else if (getenv("MESA_DEBUG")) {
1478 _mesa_warning(NULL
, "Mesa: glXCopySubBufferMESA: invalid drawable\n");
1485 Fake_glXQueryVersion( Display
*dpy
, int *maj
, int *min
)
1488 /* Return GLX version, not Mesa version */
1489 assert(CLIENT_MAJOR_VERSION
== SERVER_MAJOR_VERSION
);
1490 *maj
= CLIENT_MAJOR_VERSION
;
1491 *min
= MIN2( CLIENT_MINOR_VERSION
, SERVER_MINOR_VERSION
);
1498 * Query the GLX attributes of the given XVisualInfo.
1501 get_config( XMesaVisual xmvis
, int attrib
, int *value
, GLboolean fbconfig
)
1506 *value
= (int) True
;
1508 case GLX_BUFFER_SIZE
:
1509 *value
= xmvis
->visinfo
->depth
;
1512 *value
= xmvis
->level
;
1515 if (xmvis
->mesa_visual
.rgbMode
) {
1522 case GLX_DOUBLEBUFFER
:
1523 *value
= (int) xmvis
->mesa_visual
.doubleBufferMode
;
1526 *value
= (int) xmvis
->mesa_visual
.stereoMode
;
1528 case GLX_AUX_BUFFERS
:
1529 *value
= (int) False
;
1532 *value
= xmvis
->mesa_visual
.redBits
;
1534 case GLX_GREEN_SIZE
:
1535 *value
= xmvis
->mesa_visual
.greenBits
;
1538 *value
= xmvis
->mesa_visual
.blueBits
;
1540 case GLX_ALPHA_SIZE
:
1541 *value
= xmvis
->mesa_visual
.alphaBits
;
1543 case GLX_DEPTH_SIZE
:
1544 *value
= xmvis
->mesa_visual
.depthBits
;
1546 case GLX_STENCIL_SIZE
:
1547 *value
= xmvis
->mesa_visual
.stencilBits
;
1549 case GLX_ACCUM_RED_SIZE
:
1550 *value
= xmvis
->mesa_visual
.accumRedBits
;
1552 case GLX_ACCUM_GREEN_SIZE
:
1553 *value
= xmvis
->mesa_visual
.accumGreenBits
;
1555 case GLX_ACCUM_BLUE_SIZE
:
1556 *value
= xmvis
->mesa_visual
.accumBlueBits
;
1558 case GLX_ACCUM_ALPHA_SIZE
:
1559 *value
= xmvis
->mesa_visual
.accumAlphaBits
;
1563 * GLX_EXT_visual_info extension
1565 case GLX_X_VISUAL_TYPE_EXT
:
1566 switch (xmvis
->visinfo
->CLASS
) {
1567 case StaticGray
: *value
= GLX_STATIC_GRAY_EXT
; return 0;
1568 case GrayScale
: *value
= GLX_GRAY_SCALE_EXT
; return 0;
1569 case StaticColor
: *value
= GLX_STATIC_GRAY_EXT
; return 0;
1570 case PseudoColor
: *value
= GLX_PSEUDO_COLOR_EXT
; return 0;
1571 case TrueColor
: *value
= GLX_TRUE_COLOR_EXT
; return 0;
1572 case DirectColor
: *value
= GLX_DIRECT_COLOR_EXT
; return 0;
1575 case GLX_TRANSPARENT_TYPE_EXT
:
1576 if (xmvis
->level
==0) {
1578 *value
= GLX_NONE_EXT
;
1580 else if (xmvis
->level
>0) {
1582 if (xmvis
->mesa_visual
.rgbMode
) {
1583 *value
= GLX_TRANSPARENT_RGB_EXT
;
1586 *value
= GLX_TRANSPARENT_INDEX_EXT
;
1589 else if (xmvis
->level
<0) {
1591 *value
= GLX_NONE_EXT
;
1594 case GLX_TRANSPARENT_INDEX_VALUE_EXT
:
1596 int pixel
= transparent_pixel( xmvis
);
1600 /* else undefined */
1603 case GLX_TRANSPARENT_RED_VALUE_EXT
:
1606 case GLX_TRANSPARENT_GREEN_VALUE_EXT
:
1609 case GLX_TRANSPARENT_BLUE_VALUE_EXT
:
1612 case GLX_TRANSPARENT_ALPHA_VALUE_EXT
:
1617 * GLX_EXT_visual_info extension
1619 case GLX_VISUAL_CAVEAT_EXT
:
1620 /* test for zero, just in case */
1621 if (xmvis
->VisualCaveat
> 0)
1622 *value
= xmvis
->VisualCaveat
;
1624 *value
= GLX_NONE_EXT
;
1628 * GLX_EXT_multisample
1630 case GLX_SAMPLE_BUFFERS_SGIS
:
1633 case GLX_SAMPLES_SGIS
:
1640 case GLX_SCREEN_EXT
:
1642 return GLX_BAD_ATTRIBUTE
;
1643 *value
= xmvis
->visinfo
->screen
;
1645 case GLX_DRAWABLE_TYPE
: /*SGIX too */
1647 return GLX_BAD_ATTRIBUTE
;
1648 *value
= GLX_WINDOW_BIT
| GLX_PIXMAP_BIT
| GLX_PBUFFER_BIT
;
1650 case GLX_RENDER_TYPE_SGIX
:
1652 return GLX_BAD_ATTRIBUTE
;
1653 if (xmvis
->mesa_visual
.rgbMode
)
1654 *value
= GLX_RGBA_BIT
;
1656 *value
= GLX_COLOR_INDEX_BIT
;
1658 case GLX_X_RENDERABLE_SGIX
:
1660 return GLX_BAD_ATTRIBUTE
;
1661 *value
= True
; /* XXX really? */
1663 case GLX_FBCONFIG_ID_SGIX
:
1665 return GLX_BAD_ATTRIBUTE
;
1666 *value
= xmvis
->vishandle
->visualid
;
1668 case GLX_MAX_PBUFFER_WIDTH
:
1670 return GLX_BAD_ATTRIBUTE
;
1671 /* XXX or MAX_WIDTH? */
1672 *value
= DisplayWidth(xmvis
->display
, xmvis
->vishandle
->screen
);
1674 case GLX_MAX_PBUFFER_HEIGHT
:
1676 return GLX_BAD_ATTRIBUTE
;
1677 *value
= DisplayHeight(xmvis
->display
, xmvis
->vishandle
->screen
);
1679 case GLX_MAX_PBUFFER_PIXELS
:
1681 return GLX_BAD_ATTRIBUTE
;
1682 *value
= DisplayWidth(xmvis
->display
, xmvis
->vishandle
->screen
) *
1683 DisplayHeight(xmvis
->display
, xmvis
->vishandle
->screen
);
1687 return GLX_BAD_ATTRIBUTE
;
1688 *value
= xmvis
->vishandle
->visualid
;
1692 return GLX_BAD_ATTRIBUTE
;
1699 Fake_glXGetConfig( Display
*dpy
, XVisualInfo
*visinfo
,
1700 int attrib
, int *value
)
1704 xmvis
= find_glx_visual( dpy
, visinfo
);
1706 /* this visual wasn't obtained with glXChooseVisual */
1707 xmvis
= create_glx_visual( dpy
, visinfo
);
1709 /* this visual can't be used for GL rendering */
1710 if (attrib
==GLX_USE_GL
) {
1711 *value
= (int) False
;
1715 return GLX_BAD_VISUAL
;
1720 return get_config(xmvis
, attrib
, value
, GL_FALSE
);
1725 Fake_glXWaitGL( void )
1727 XMesaContext xmesa
= XMesaGetCurrentContext();
1728 XMesaFlush( xmesa
);
1734 Fake_glXWaitX( void )
1736 XMesaContext xmesa
= XMesaGetCurrentContext();
1737 XMesaFlush( xmesa
);
1742 get_extensions( void )
1745 const char *fx
= getenv("MESA_GLX_FX");
1746 if (fx
&& fx
[0] != 'd') {
1750 return EXTENSIONS
+ 23; /* skip "GLX_MESA_set_3dfx_mode" */
1755 /* GLX 1.1 and later */
1757 Fake_glXQueryExtensionsString( Display
*dpy
, int screen
)
1761 return get_extensions();
1766 /* GLX 1.1 and later */
1768 Fake_glXQueryServerString( Display
*dpy
, int screen
, int name
)
1770 static char version
[1000];
1771 sprintf(version
, "%d.%d %s", SERVER_MAJOR_VERSION
, SERVER_MINOR_VERSION
,
1778 case GLX_EXTENSIONS
:
1779 return get_extensions();
1791 /* GLX 1.1 and later */
1793 Fake_glXGetClientString( Display
*dpy
, int name
)
1795 static char version
[1000];
1796 sprintf(version
, "%d.%d %s", CLIENT_MAJOR_VERSION
, CLIENT_MINOR_VERSION
,
1802 case GLX_EXTENSIONS
:
1803 return get_extensions();
1820 static GLXFBConfig
*
1821 Fake_glXChooseFBConfig( Display
*dpy
, int screen
,
1822 const int *attribList
, int *nitems
)
1824 XMesaVisual xmvis
= choose_visual(dpy
, screen
, attribList
);
1826 GLXFBConfig
*config
= malloc(sizeof(XMesaVisual
));
1832 config
[0] = (GLXFBConfig
) xmvis
;
1833 return (GLXFBConfig
*) config
;
1843 Fake_glXGetFBConfigAttrib( Display
*dpy
, GLXFBConfig config
,
1844 int attribute
, int *value
)
1846 XMesaVisual v
= (XMesaVisual
) config
;
1850 if (!dpy
|| !config
|| !value
)
1853 return get_config(v
, attribute
, value
, GL_TRUE
);
1857 static GLXFBConfig
*
1858 Fake_glXGetFBConfigs( Display
*dpy
, int screen
, int *nelements
)
1860 XVisualInfo
*visuals
, visTemplate
;
1861 const long visMask
= VisualScreenMask
;
1864 /* Get list of all X visuals */
1865 visTemplate
.screen
= screen
;
1866 visuals
= XGetVisualInfo(dpy
, visMask
, &visTemplate
, nelements
);
1867 if (*nelements
> 0) {
1868 XMesaVisual
*results
;
1869 results
= malloc(*nelements
* sizeof(XMesaVisual
));
1874 for (i
= 0; i
< *nelements
; i
++) {
1875 results
[i
] = create_glx_visual(dpy
, visuals
+ i
);
1877 return (GLXFBConfig
*) results
;
1883 static XVisualInfo
*
1884 Fake_glXGetVisualFromFBConfig( Display
*dpy
, GLXFBConfig config
)
1886 if (dpy
&& config
) {
1887 XMesaVisual v
= (XMesaVisual
) config
;
1888 return v
->vishandle
;
1897 Fake_glXCreateWindow( Display
*dpy
, GLXFBConfig config
, Window win
,
1898 const int *attribList
)
1903 (void) attribList
; /* Ignored in GLX 1.3 */
1905 return win
; /* A hack for now */
1910 Fake_glXDestroyWindow( Display
*dpy
, GLXWindow window
)
1912 XMesaBuffer b
= XMesaFindBuffer(dpy
, (XMesaDrawable
) window
);
1914 XMesaDestroyBuffer(b
);
1915 /* don't destroy X window */
1921 Fake_glXCreatePixmap( Display
*dpy
, GLXFBConfig config
, Pixmap pixmap
,
1922 const int *attribList
)
1924 XMesaVisual v
= (XMesaVisual
) config
;
1925 XVisualInfo
*visinfo
;
1931 (void) attribList
; /* Ignored in GLX 1.3 */
1933 if (!dpy
|| !config
|| !pixmap
)
1936 visinfo
= v
->vishandle
;
1938 v
= find_glx_visual( dpy
, visinfo
);
1940 v
= create_glx_visual( dpy
, visinfo
);
1942 /* unusable visual */
1947 b
= XMesaCreatePixmapBuffer( v
, pixmap
, 0 );
1957 Fake_glXDestroyPixmap( Display
*dpy
, GLXPixmap pixmap
)
1959 XMesaBuffer b
= XMesaFindBuffer(dpy
, (XMesaDrawable
)pixmap
);
1961 XMesaDestroyBuffer(b
);
1962 /* don't destroy X pixmap */
1967 Fake_glXCreatePbuffer( Display
*dpy
, GLXFBConfig config
,
1968 const int *attribList
)
1970 XMesaVisual xmvis
= (XMesaVisual
) config
;
1973 int width
= 0, height
= 0;
1974 GLboolean useLargest
= GL_FALSE
, preserveContents
= GL_FALSE
;
1978 for (attrib
= attribList
; *attrib
; attrib
++) {
1980 case GLX_PBUFFER_WIDTH
:
1984 case GLX_PBUFFER_HEIGHT
:
1988 case GLX_PRESERVED_CONTENTS
:
1990 preserveContents
= *attrib
; /* ignored */
1992 case GLX_LARGEST_PBUFFER
:
1994 useLargest
= *attrib
; /* ignored */
2001 if (width
== 0 || height
== 0)
2004 xmbuf
= XMesaCreatePBuffer( xmvis
, 0, width
, height
);
2005 /* A GLXPbuffer handle must be an X Drawable because that's what
2006 * glXMakeCurrent takes.
2008 return (GLXPbuffer
) xmbuf
->frontbuffer
;
2013 Fake_glXDestroyPbuffer( Display
*dpy
, GLXPbuffer pbuf
)
2015 XMesaBuffer b
= XMesaFindBuffer(dpy
, pbuf
);
2017 XMesaDestroyBuffer(b
);
2023 Fake_glXQueryDrawable( Display
*dpy
, GLXDrawable draw
, int attribute
,
2024 unsigned int *value
)
2026 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, draw
);
2030 switch (attribute
) {
2032 *value
= xmbuf
->width
;
2035 *value
= xmbuf
->height
;
2037 case GLX_PRESERVED_CONTENTS
:
2040 case GLX_LARGEST_PBUFFER
:
2041 *value
= xmbuf
->width
* xmbuf
->height
;
2043 case GLX_FBCONFIG_ID
:
2044 *value
= xmbuf
->xm_visual
->vishandle
->visualid
;
2047 return; /* GLX_BAD_ATTRIBUTE? */
2053 Fake_glXCreateNewContext( Display
*dpy
, GLXFBConfig config
,
2054 int renderType
, GLXContext shareList
, Bool direct
)
2056 XMesaVisual v
= (XMesaVisual
) config
;
2058 if (!dpy
|| !config
||
2059 (renderType
!= GLX_RGBA_TYPE
&& renderType
!= GLX_COLOR_INDEX_TYPE
))
2062 return Fake_glXCreateContext(dpy
, v
->vishandle
, shareList
, direct
);
2067 Fake_glXQueryContext( Display
*dpy
, GLXContext ctx
, int attribute
, int *value
)
2069 struct fake_glx_context
*glxCtx
= (struct fake_glx_context
*) ctx
;
2070 XMesaContext xmctx
= glxCtx
->xmesaContext
;
2075 switch (attribute
) {
2076 case GLX_FBCONFIG_ID
:
2077 *value
= xmctx
->xm_visual
->vishandle
->visualid
;
2079 case GLX_RENDER_TYPE
:
2080 if (xmctx
->xm_visual
->mesa_visual
.rgbMode
)
2081 *value
= GLX_RGBA_BIT
;
2083 *value
= GLX_COLOR_INDEX_BIT
;
2089 return GLX_BAD_ATTRIBUTE
;
2096 Fake_glXSelectEvent( Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
2098 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, drawable
);
2100 xmbuf
->selectedEvents
= mask
;
2105 Fake_glXGetSelectedEvent( Display
*dpy
, GLXDrawable drawable
,
2106 unsigned long *mask
)
2108 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, drawable
);
2110 *mask
= xmbuf
->selectedEvents
;
2117 /*** GLX_SGI_swap_control ***/
2120 Fake_glXSwapIntervalSGI(int interval
)
2128 /*** GLX_SGI_video_sync ***/
2131 Fake_glXGetVideoSyncSGI(unsigned int *count
)
2138 Fake_glXWaitVideoSyncSGI(int divisor
, int remainder
, unsigned int *count
)
2148 /*** GLX_SGI_make_current_read ***/
2151 Fake_glXMakeCurrentReadSGI(Display
*dpy
, GLXDrawable draw
, GLXDrawable read
, GLXContext ctx
)
2153 return Fake_glXMakeContextCurrent( dpy
, draw
, read
, ctx
);
2158 Fake_glXGetCurrentReadDrawableSGI(void)
2165 /*** GLX_SGIX_video_source ***/
2168 static GLXVideoSourceSGIX
2169 Fake_glXCreateGLXVideoSourceSGIX(Display
*dpy
, int screen
, VLServer server
, VLPath path
, int nodeClass
, VLNode drainNode
)
2181 Fake_glXDestroyGLXVideoSourceSGIX(Display
*dpy
, GLXVideoSourceSGIX src
)
2190 /*** GLX_EXT_import_context ***/
2193 Fake_glXFreeContextEXT(Display
*dpy
, GLXContext context
)
2200 Fake_glXGetContextIDEXT(const GLXContext context
)
2207 Fake_glXImportContextEXT(Display
*dpy
, GLXContextID contextID
)
2215 Fake_glXQueryContextInfoEXT(Display
*dpy
, GLXContext context
, int attribute
, int *value
)
2226 /*** GLX_SGIX_fbconfig ***/
2229 Fake_glXGetFBConfigAttribSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int attribute
, int *value
)
2231 return Fake_glXGetFBConfigAttrib(dpy
, config
, attribute
, value
);
2234 static GLXFBConfigSGIX
*
2235 Fake_glXChooseFBConfigSGIX(Display
*dpy
, int screen
, int *attrib_list
, int *nelements
)
2237 return (GLXFBConfig
*) Fake_glXChooseFBConfig(dpy
, screen
, attrib_list
, nelements
);
2242 Fake_glXCreateGLXPixmapWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, Pixmap pixmap
)
2244 XMesaVisual xmvis
= (XMesaVisual
) config
;
2245 XMesaBuffer xmbuf
= XMesaCreatePixmapBuffer(xmvis
, pixmap
, 0);
2246 return xmbuf
->frontbuffer
; /* need to return an X ID */
2251 Fake_glXCreateContextWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int render_type
, GLXContext share_list
, Bool direct
)
2253 XMesaVisual xmvis
= (XMesaVisual
) config
;
2254 struct fake_glx_context
*glxCtx
;
2255 struct fake_glx_context
*shareCtx
= (struct fake_glx_context
*) share_list
;
2257 glxCtx
= CALLOC_STRUCT(fake_glx_context
);
2261 /* deallocate unused windows/buffers */
2262 XMesaGarbageCollect();
2264 glxCtx
->xmesaContext
= XMesaCreateContext(xmvis
,
2265 shareCtx
? shareCtx
->xmesaContext
: NULL
);
2266 if (!glxCtx
->xmesaContext
) {
2271 glxCtx
->xmesaContext
->direct
= GL_FALSE
;
2272 glxCtx
->glxContext
.isDirect
= GL_FALSE
;
2273 glxCtx
->glxContext
.currentDpy
= dpy
;
2274 glxCtx
->glxContext
.xid
= (XID
) glxCtx
; /* self pointer */
2276 assert((void *) glxCtx
== (void *) &(glxCtx
->glxContext
));
2278 return (GLXContext
) glxCtx
;
2282 static XVisualInfo
*
2283 Fake_glXGetVisualFromFBConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
)
2285 return Fake_glXGetVisualFromFBConfig(dpy
, config
);
2289 static GLXFBConfigSGIX
2290 Fake_glXGetFBConfigFromVisualSGIX(Display
*dpy
, XVisualInfo
*vis
)
2292 XMesaVisual xmvis
= find_glx_visual(dpy
, vis
);
2294 /* This visual wasn't found with glXChooseVisual() */
2295 xmvis
= create_glx_visual(dpy
, vis
);
2298 return (GLXFBConfigSGIX
) xmvis
;
2303 /*** GLX_SGIX_pbuffer ***/
2305 static GLXPbufferSGIX
2306 Fake_glXCreateGLXPbufferSGIX(Display
*dpy
, GLXFBConfigSGIX config
,
2307 unsigned int width
, unsigned int height
,
2310 XMesaVisual xmvis
= (XMesaVisual
) config
;
2313 GLboolean useLargest
= GL_FALSE
, preserveContents
= GL_FALSE
;
2317 for (attrib
= attribList
; *attrib
; attrib
++) {
2319 case GLX_PRESERVED_CONTENTS_SGIX
:
2321 preserveContents
= *attrib
; /* ignored */
2323 case GLX_LARGEST_PBUFFER_SGIX
:
2325 useLargest
= *attrib
; /* ignored */
2332 xmbuf
= XMesaCreatePBuffer( xmvis
, 0, width
, height
);
2333 /* A GLXPbuffer handle must be an X Drawable because that's what
2334 * glXMakeCurrent takes.
2336 return (GLXPbuffer
) xmbuf
->frontbuffer
;
2341 Fake_glXDestroyGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
)
2343 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, pbuf
);
2345 XMesaDestroyBuffer(xmbuf
);
2351 Fake_glXQueryGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
, int attribute
, unsigned int *value
)
2353 const XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, pbuf
);
2356 /* Generate GLXBadPbufferSGIX for bad pbuffer */
2360 switch (attribute
) {
2361 case GLX_PRESERVED_CONTENTS_SGIX
:
2364 case GLX_LARGEST_PBUFFER_SGIX
:
2365 *value
= xmbuf
->width
* xmbuf
->height
;
2367 case GLX_WIDTH_SGIX
:
2368 *value
= xmbuf
->width
;
2370 case GLX_HEIGHT_SGIX
:
2371 *value
= xmbuf
->height
;
2373 case GLX_EVENT_MASK_SGIX
:
2374 *value
= 0; /* XXX might be wrong */
2384 Fake_glXSelectEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
2386 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, drawable
);
2388 /* Note: we'll never generate clobber events */
2389 xmbuf
->selectedEvents
= mask
;
2395 Fake_glXGetSelectedEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long *mask
)
2397 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, drawable
);
2399 *mask
= xmbuf
->selectedEvents
;
2408 /*** GLX_SGI_cushion ***/
2411 Fake_glXCushionSGI(Display
*dpy
, Window win
, float cushion
)
2420 /*** GLX_SGIX_video_resize ***/
2423 Fake_glXBindChannelToWindowSGIX(Display
*dpy
, int screen
, int channel
, Window window
)
2433 Fake_glXChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int x
, int y
, int w
, int h
)
2446 Fake_glXQueryChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int *x
, int *y
, int *w
, int *h
)
2459 Fake_glXQueryChannelDeltasSGIX(Display
*dpy
, int screen
, int channel
, int *dx
, int *dy
, int *dw
, int *dh
)
2472 Fake_glXChannelRectSyncSGIX(Display
*dpy
, int screen
, int channel
, GLenum synctype
)
2483 /*** GLX_SGIX_dmbuffer **/
2485 #if defined(_DM_BUFFER_H_)
2487 Fake_glXAssociateDMPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuffer
, DMparams
*params
, DMbuffer dmbuffer
)
2498 /*** GLX_SGIX_swap_group ***/
2501 Fake_glXJoinSwapGroupSGIX(Display
*dpy
, GLXDrawable drawable
, GLXDrawable member
)
2510 /*** GLX_SGIX_swap_barrier ***/
2513 Fake_glXBindSwapBarrierSGIX(Display
*dpy
, GLXDrawable drawable
, int barrier
)
2521 Fake_glXQueryMaxSwapBarriersSGIX(Display
*dpy
, int screen
, int *max
)
2531 /*** GLX_SUN_get_transparent_index ***/
2534 Fake_glXGetTransparentIndexSUN(Display
*dpy
, Window overlay
, Window underlay
, long *pTransparent
)
2539 (void) pTransparent
;
2545 /*** GLX_MESA_release_buffers ***/
2548 * Release the depth, stencil, accum buffers attached to a GLXDrawable
2549 * (a window or pixmap) prior to destroying the GLXDrawable.
2552 Fake_glXReleaseBuffersMESA( Display
*dpy
, GLXDrawable d
)
2554 XMesaBuffer b
= XMesaFindBuffer(dpy
, d
);
2556 XMesaDestroyBuffer(b
);
2564 /*** GLX_MESA_set_3dfx_mode ***/
2567 Fake_glXSet3DfxModeMESA( int mode
)
2569 return XMesaSetFXmode( mode
);
2574 /*** AGP memory allocation ***/
2576 Fake_glXAllocateMemoryNV( GLsizei size
,
2577 GLfloat readFrequency
,
2578 GLfloat writeFrequency
,
2582 (void) readFrequency
;
2583 (void) writeFrequency
;
2590 Fake_glXFreeMemoryNV( GLvoid
*pointer
)
2597 extern struct _glxapi_table
*_mesa_GetGLXDispatchTable(void);
2598 struct _glxapi_table
*_mesa_GetGLXDispatchTable(void)
2600 static struct _glxapi_table glx
;
2602 /* be sure our dispatch table size <= libGL's table */
2604 GLuint size
= sizeof(struct _glxapi_table
) / sizeof(void *);
2606 assert(_glxapi_get_dispatch_table_size() >= size
);
2609 /* initialize the whole table to no-ops */
2610 _glxapi_set_no_op_table(&glx
);
2612 /* now initialize the table with the functions I implement */
2613 glx
.ChooseVisual
= Fake_glXChooseVisual
;
2614 glx
.CopyContext
= Fake_glXCopyContext
;
2615 glx
.CreateContext
= Fake_glXCreateContext
;
2616 glx
.CreateGLXPixmap
= Fake_glXCreateGLXPixmap
;
2617 glx
.DestroyContext
= Fake_glXDestroyContext
;
2618 glx
.DestroyGLXPixmap
= Fake_glXDestroyGLXPixmap
;
2619 glx
.GetConfig
= Fake_glXGetConfig
;
2620 /*glx.GetCurrentContext = Fake_glXGetCurrentContext;*/
2621 /*glx.GetCurrentDrawable = Fake_glXGetCurrentDrawable;*/
2622 glx
.IsDirect
= Fake_glXIsDirect
;
2623 glx
.MakeCurrent
= Fake_glXMakeCurrent
;
2624 glx
.QueryExtension
= Fake_glXQueryExtension
;
2625 glx
.QueryVersion
= Fake_glXQueryVersion
;
2626 glx
.SwapBuffers
= Fake_glXSwapBuffers
;
2627 glx
.UseXFont
= Fake_glXUseXFont
;
2628 glx
.WaitGL
= Fake_glXWaitGL
;
2629 glx
.WaitX
= Fake_glXWaitX
;
2631 /*** GLX_VERSION_1_1 ***/
2632 glx
.GetClientString
= Fake_glXGetClientString
;
2633 glx
.QueryExtensionsString
= Fake_glXQueryExtensionsString
;
2634 glx
.QueryServerString
= Fake_glXQueryServerString
;
2636 /*** GLX_VERSION_1_2 ***/
2637 /*glx.GetCurrentDisplay = Fake_glXGetCurrentDisplay;*/
2639 /*** GLX_VERSION_1_3 ***/
2640 glx
.ChooseFBConfig
= Fake_glXChooseFBConfig
;
2641 glx
.CreateNewContext
= Fake_glXCreateNewContext
;
2642 glx
.CreatePbuffer
= Fake_glXCreatePbuffer
;
2643 glx
.CreatePixmap
= Fake_glXCreatePixmap
;
2644 glx
.CreateWindow
= Fake_glXCreateWindow
;
2645 glx
.DestroyPbuffer
= Fake_glXDestroyPbuffer
;
2646 glx
.DestroyPixmap
= Fake_glXDestroyPixmap
;
2647 glx
.DestroyWindow
= Fake_glXDestroyWindow
;
2648 /*glx.GetCurrentReadDrawable = Fake_glXGetCurrentReadDrawable;*/
2649 glx
.GetFBConfigAttrib
= Fake_glXGetFBConfigAttrib
;
2650 glx
.GetFBConfigs
= Fake_glXGetFBConfigs
;
2651 glx
.GetSelectedEvent
= Fake_glXGetSelectedEvent
;
2652 glx
.GetVisualFromFBConfig
= Fake_glXGetVisualFromFBConfig
;
2653 glx
.MakeContextCurrent
= Fake_glXMakeContextCurrent
;
2654 glx
.QueryContext
= Fake_glXQueryContext
;
2655 glx
.QueryDrawable
= Fake_glXQueryDrawable
;
2656 glx
.SelectEvent
= Fake_glXSelectEvent
;
2658 /*** GLX_SGI_swap_control ***/
2659 glx
.SwapIntervalSGI
= Fake_glXSwapIntervalSGI
;
2661 /*** GLX_SGI_video_sync ***/
2662 glx
.GetVideoSyncSGI
= Fake_glXGetVideoSyncSGI
;
2663 glx
.WaitVideoSyncSGI
= Fake_glXWaitVideoSyncSGI
;
2665 /*** GLX_SGI_make_current_read ***/
2666 glx
.MakeCurrentReadSGI
= Fake_glXMakeCurrentReadSGI
;
2667 /*glx.GetCurrentReadDrawableSGI = Fake_glXGetCurrentReadDrawableSGI;*/
2669 /*** GLX_SGIX_video_source ***/
2671 glx
.CreateGLXVideoSourceSGIX
= Fake_glXCreateGLXVideoSourceSGIX
;
2672 glx
.DestroyGLXVideoSourceSGIX
= Fake_glXDestroyGLXVideoSourceSGIX
;
2675 /*** GLX_EXT_import_context ***/
2676 glx
.FreeContextEXT
= Fake_glXFreeContextEXT
;
2677 glx
.GetContextIDEXT
= Fake_glXGetContextIDEXT
;
2678 /*glx.GetCurrentDisplayEXT = Fake_glXGetCurrentDisplayEXT;*/
2679 glx
.ImportContextEXT
= Fake_glXImportContextEXT
;
2680 glx
.QueryContextInfoEXT
= Fake_glXQueryContextInfoEXT
;
2682 /*** GLX_SGIX_fbconfig ***/
2683 glx
.GetFBConfigAttribSGIX
= Fake_glXGetFBConfigAttribSGIX
;
2684 glx
.ChooseFBConfigSGIX
= Fake_glXChooseFBConfigSGIX
;
2685 glx
.CreateGLXPixmapWithConfigSGIX
= Fake_glXCreateGLXPixmapWithConfigSGIX
;
2686 glx
.CreateContextWithConfigSGIX
= Fake_glXCreateContextWithConfigSGIX
;
2687 glx
.GetVisualFromFBConfigSGIX
= Fake_glXGetVisualFromFBConfigSGIX
;
2688 glx
.GetFBConfigFromVisualSGIX
= Fake_glXGetFBConfigFromVisualSGIX
;
2690 /*** GLX_SGIX_pbuffer ***/
2691 glx
.CreateGLXPbufferSGIX
= Fake_glXCreateGLXPbufferSGIX
;
2692 glx
.DestroyGLXPbufferSGIX
= Fake_glXDestroyGLXPbufferSGIX
;
2693 glx
.QueryGLXPbufferSGIX
= Fake_glXQueryGLXPbufferSGIX
;
2694 glx
.SelectEventSGIX
= Fake_glXSelectEventSGIX
;
2695 glx
.GetSelectedEventSGIX
= Fake_glXGetSelectedEventSGIX
;
2697 /*** GLX_SGI_cushion ***/
2698 glx
.CushionSGI
= Fake_glXCushionSGI
;
2700 /*** GLX_SGIX_video_resize ***/
2701 glx
.BindChannelToWindowSGIX
= Fake_glXBindChannelToWindowSGIX
;
2702 glx
.ChannelRectSGIX
= Fake_glXChannelRectSGIX
;
2703 glx
.QueryChannelRectSGIX
= Fake_glXQueryChannelRectSGIX
;
2704 glx
.QueryChannelDeltasSGIX
= Fake_glXQueryChannelDeltasSGIX
;
2705 glx
.ChannelRectSyncSGIX
= Fake_glXChannelRectSyncSGIX
;
2707 /*** GLX_SGIX_dmbuffer **/
2708 #if defined(_DM_BUFFER_H_)
2709 glx
.AssociateDMPbufferSGIX
= NULL
;
2712 /*** GLX_SGIX_swap_group ***/
2713 glx
.JoinSwapGroupSGIX
= Fake_glXJoinSwapGroupSGIX
;
2715 /*** GLX_SGIX_swap_barrier ***/
2716 glx
.BindSwapBarrierSGIX
= Fake_glXBindSwapBarrierSGIX
;
2717 glx
.QueryMaxSwapBarriersSGIX
= Fake_glXQueryMaxSwapBarriersSGIX
;
2719 /*** GLX_SUN_get_transparent_index ***/
2720 glx
.GetTransparentIndexSUN
= Fake_glXGetTransparentIndexSUN
;
2722 /*** GLX_MESA_copy_sub_buffer ***/
2723 glx
.CopySubBufferMESA
= Fake_glXCopySubBufferMESA
;
2725 /*** GLX_MESA_release_buffers ***/
2726 glx
.ReleaseBuffersMESA
= Fake_glXReleaseBuffersMESA
;
2728 /*** GLX_MESA_pixmap_colormap ***/
2729 glx
.CreateGLXPixmapMESA
= Fake_glXCreateGLXPixmapMESA
;
2731 /*** GLX_MESA_set_3dfx_mode ***/
2732 glx
.Set3DfxModeMESA
= Fake_glXSet3DfxModeMESA
;
2734 /*** GLX AGP memory allocation ***/
2735 glx
.AllocateMemoryNV
= Fake_glXAllocateMemoryNV
;
2736 glx
.FreeMemoryNV
= Fake_glXFreeMemoryNV
;