1 /* $Id: fakeglx.c,v 1.74 2002/11/05 21:11:18 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 5.0"
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
= _mesa_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 (_mesa_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 (_mesa_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 (!_mesa_getenv( varname
)) {
572 _mesa_strncpy( value
, _mesa_getenv(varname
), 100 );
575 sscanf( value
, "%s %d", type
, &depth
);
577 if (_mesa_strcmp(type
,"TrueColor")==0) xclass
= TrueColor
;
578 else if (_mesa_strcmp(type
,"DirectColor")==0) xclass
= DirectColor
;
579 else if (_mesa_strcmp(type
,"PseudoColor")==0) xclass
= PseudoColor
;
580 else if (_mesa_strcmp(type
,"StaticColor")==0) xclass
= StaticColor
;
581 else if (_mesa_strcmp(type
,"GrayScale")==0) xclass
= GrayScale
;
582 else if (_mesa_strcmp(type
,"StaticGray")==0) xclass
= StaticGray
;
584 if (xclass
>-1 && depth
>0) {
585 vis
= get_visual( dpy
, scr
, depth
, xclass
);
591 _mesa_warning(NULL
, "GLX unable to find visual class=%s, depth=%d.",
600 * Select an X visual which satisfies the RGBA/CI flag and minimum depth.
601 * Input: dpy, screen - X display and screen number
602 * rgba - GL_TRUE = RGBA mode, GL_FALSE = CI mode
603 * min_depth - minimum visual depth
604 * preferred_class - preferred GLX visual class or DONT_CARE
605 * Return: pointer to an XVisualInfo or NULL.
607 static XVisualInfo
*choose_x_visual( Display
*dpy
, int screen
,
608 GLboolean rgba
, int min_depth
,
609 int preferred_class
)
612 int xclass
, visclass
= 0;
616 Atom hp_cr_maps
= XInternAtom(dpy
, "_HP_RGB_SMOOTH_MAP_LIST", True
);
617 /* First see if the MESA_RGB_VISUAL env var is defined */
618 vis
= get_env_visual( dpy
, screen
, "MESA_RGB_VISUAL" );
622 /* Otherwise, search for a suitable visual */
623 if (preferred_class
==DONT_CARE
) {
624 for (xclass
=0;xclass
<6;xclass
++) {
626 case 0: visclass
= TrueColor
; break;
627 case 1: visclass
= DirectColor
; break;
628 case 2: visclass
= PseudoColor
; break;
629 case 3: visclass
= StaticColor
; break;
630 case 4: visclass
= GrayScale
; break;
631 case 5: visclass
= StaticGray
; break;
634 /* start with shallowest */
635 for (depth
=0;depth
<=32;depth
++) {
636 if (visclass
==TrueColor
&& depth
==8 && !hp_cr_maps
) {
637 /* Special case: try to get 8-bit PseudoColor before */
638 /* 8-bit TrueColor */
639 vis
= get_visual( dpy
, screen
, 8, PseudoColor
);
644 vis
= get_visual( dpy
, screen
, depth
, visclass
);
651 /* start with deepest */
652 for (depth
=32;depth
>=min_depth
;depth
--) {
653 if (visclass
==TrueColor
&& depth
==8 && !hp_cr_maps
) {
654 /* Special case: try to get 8-bit PseudoColor before */
655 /* 8-bit TrueColor */
656 vis
= get_visual( dpy
, screen
, 8, PseudoColor
);
661 vis
= get_visual( dpy
, screen
, depth
, visclass
);
670 /* search for a specific visual class */
671 switch (preferred_class
) {
672 case GLX_TRUE_COLOR_EXT
: visclass
= TrueColor
; break;
673 case GLX_DIRECT_COLOR_EXT
: visclass
= DirectColor
; break;
674 case GLX_PSEUDO_COLOR_EXT
: visclass
= PseudoColor
; break;
675 case GLX_STATIC_COLOR_EXT
: visclass
= StaticColor
; break;
676 case GLX_GRAY_SCALE_EXT
: visclass
= GrayScale
; break;
677 case GLX_STATIC_GRAY_EXT
: visclass
= StaticGray
; break;
678 default: return NULL
;
681 /* start with shallowest */
682 for (depth
=0;depth
<=32;depth
++) {
683 vis
= get_visual( dpy
, screen
, depth
, visclass
);
690 /* start with deepest */
691 for (depth
=32;depth
>=min_depth
;depth
--) {
692 vis
= get_visual( dpy
, screen
, depth
, visclass
);
701 /* First see if the MESA_CI_VISUAL env var is defined */
702 vis
= get_env_visual( dpy
, screen
, "MESA_CI_VISUAL" );
706 /* Otherwise, search for a suitable visual, starting with shallowest */
707 if (preferred_class
==DONT_CARE
) {
708 for (xclass
=0;xclass
<4;xclass
++) {
710 case 0: visclass
= PseudoColor
; break;
711 case 1: visclass
= StaticColor
; break;
712 case 2: visclass
= GrayScale
; break;
713 case 3: visclass
= StaticGray
; break;
715 /* try 8-bit up through 16-bit */
716 for (depth
=8;depth
<=16;depth
++) {
717 vis
= get_visual( dpy
, screen
, depth
, visclass
);
722 /* try min_depth up to 8-bit */
723 for (depth
=min_depth
;depth
<8;depth
++) {
724 vis
= get_visual( dpy
, screen
, depth
, visclass
);
732 /* search for a specific visual class */
733 switch (preferred_class
) {
734 case GLX_TRUE_COLOR_EXT
: visclass
= TrueColor
; break;
735 case GLX_DIRECT_COLOR_EXT
: visclass
= DirectColor
; break;
736 case GLX_PSEUDO_COLOR_EXT
: visclass
= PseudoColor
; break;
737 case GLX_STATIC_COLOR_EXT
: visclass
= StaticColor
; break;
738 case GLX_GRAY_SCALE_EXT
: visclass
= GrayScale
; break;
739 case GLX_STATIC_GRAY_EXT
: visclass
= StaticGray
; break;
740 default: return NULL
;
742 /* try 8-bit up through 16-bit */
743 for (depth
=8;depth
<=16;depth
++) {
744 vis
= get_visual( dpy
, screen
, depth
, visclass
);
749 /* try min_depth up to 8-bit */
750 for (depth
=min_depth
;depth
<8;depth
++) {
751 vis
= get_visual( dpy
, screen
, depth
, visclass
);
759 /* didn't find a visual */
766 * Find the deepest X over/underlay visual of at least min_depth.
767 * Input: dpy, screen - X display and screen number
768 * level - the over/underlay level
769 * trans_type - transparent pixel type: GLX_NONE_EXT,
770 * GLX_TRANSPARENT_RGB_EXT, GLX_TRANSPARENT_INDEX_EXT,
772 * trans_value - transparent pixel value or DONT_CARE
773 * min_depth - minimum visual depth
774 * preferred_class - preferred GLX visual class or DONT_CARE
775 * Return: pointer to an XVisualInfo or NULL.
777 static XVisualInfo
*choose_x_overlay_visual( Display
*dpy
, int scr
,
779 int level
, int trans_type
,
782 int preferred_class
)
784 Atom overlayVisualsAtom
;
785 OverlayInfo
*overlay_info
;
786 int numOverlaysPerScreen
;
790 unsigned long sizeData
, bytesLeft
;
792 XVisualInfo
*deepvis
;
795 /*DEBUG int tt, tv; */
797 switch (preferred_class
) {
798 case GLX_TRUE_COLOR_EXT
: preferred_class
= TrueColor
; break;
799 case GLX_DIRECT_COLOR_EXT
: preferred_class
= DirectColor
; break;
800 case GLX_PSEUDO_COLOR_EXT
: preferred_class
= PseudoColor
; break;
801 case GLX_STATIC_COLOR_EXT
: preferred_class
= StaticColor
; break;
802 case GLX_GRAY_SCALE_EXT
: preferred_class
= GrayScale
; break;
803 case GLX_STATIC_GRAY_EXT
: preferred_class
= StaticGray
; break;
804 default: preferred_class
= DONT_CARE
;
808 * The SERVER_OVERLAY_VISUALS property on the root window contains
809 * a list of overlay visuals. Get that list now.
811 overlayVisualsAtom
= XInternAtom(dpy
,"SERVER_OVERLAY_VISUALS", True
);
812 if (overlayVisualsAtom
== (Atom
) None
) {
816 status
= XGetWindowProperty(dpy
, RootWindow( dpy
, scr
),
817 overlayVisualsAtom
, 0L, (long) 10000, False
,
818 overlayVisualsAtom
, &actualType
, &actualFormat
,
819 &sizeData
, &bytesLeft
,
820 (unsigned char **) &overlay_info
);
822 if (status
!= Success
|| actualType
!= overlayVisualsAtom
||
823 actualFormat
!= 32 || sizeData
< 4) {
824 /* something went wrong */
828 /* Search for the deepest overlay which satisifies all criteria. */
832 numOverlaysPerScreen
= (int) (sizeData
/ 4);
833 for (i
=0;i
<numOverlaysPerScreen
;i
++) {
834 XVisualInfo
*vislist
, vistemplate
;
837 ov
= overlay_info
+ i
;
839 if (ov
->layer
!=level
) {
840 /* failed overlay level criteria */
843 if (!(trans_type
==DONT_CARE
844 || (trans_type
==GLX_TRANSPARENT_INDEX_EXT
845 && ov
->transparent_type
>0)
846 || (trans_type
==GLX_NONE_EXT
&& ov
->transparent_type
==0))) {
847 /* failed transparent pixel type criteria */
850 if (trans_value
!=DONT_CARE
&& trans_value
!=ov
->value
) {
851 /* failed transparent pixel value criteria */
855 /* get XVisualInfo and check the depth */
856 vistemplate
.visualid
= ov
->overlay_visual
;
857 vistemplate
.screen
= scr
;
858 vislist
= XGetVisualInfo( dpy
, VisualIDMask
| VisualScreenMask
,
859 &vistemplate
, &count
);
862 /* something went wrong */
865 if (preferred_class
!=DONT_CARE
&& preferred_class
!=vislist
->CLASS
) {
866 /* wrong visual class */
870 /* if RGB was requested, make sure we have True/DirectColor */
871 if (rgbFlag
&& vislist
->CLASS
!= TrueColor
872 && vislist
->CLASS
!= DirectColor
)
875 /* if CI was requested, make sure we have a color indexed visual */
877 && (vislist
->CLASS
== TrueColor
|| vislist
->CLASS
== DirectColor
))
880 if (deepvis
==NULL
|| vislist
->depth
> deepest
) {
881 /* YES! found a satisfactory visual */
885 deepest
= vislist
->depth
;
887 /* DEBUG tt = ov->transparent_type;*/
888 /* DEBUG tv = ov->value; */
894 printf("chose 0x%x: layer=%d depth=%d trans_type=%d trans_value=%d\n",
895 deepvis->visualid, level, deepvis->depth, tt, tv );
902 /**********************************************************************/
903 /*** Begin Fake GLX API Functions ***/
904 /**********************************************************************/
907 static XMesaVisual
choose_visual( Display
*dpy
, int screen
, const int *list
)
909 const int *parselist
;
912 int min_red
=0, min_green
=0, min_blue
=0;
913 GLboolean rgb_flag
= GL_FALSE
;
914 GLboolean alpha_flag
= GL_FALSE
;
915 GLboolean double_flag
= GL_FALSE
;
916 GLboolean stereo_flag
= GL_FALSE
;
917 GLint depth_size
= 0;
918 GLint stencil_size
= 0;
919 GLint accumRedSize
= 0;
920 GLint accumGreenSize
= 0;
921 GLint accumBlueSize
= 0;
922 GLint accumAlphaSize
= 0;
924 int visual_type
= DONT_CARE
;
925 int trans_type
= DONT_CARE
;
926 int trans_value
= DONT_CARE
;
927 GLint caveat
= DONT_CARE
;
928 XMesaVisual xmvis
= NULL
;
934 switch (*parselist
) {
939 case GLX_BUFFER_SIZE
:
941 min_ci
= *parselist
++;
945 level
= *parselist
++;
951 case GLX_DOUBLEBUFFER
:
952 double_flag
= GL_TRUE
;
956 stereo_flag
= GL_TRUE
;
958 case GLX_AUX_BUFFERS
:
965 min_red
= *parselist
++;
969 min_green
= *parselist
++;
973 min_blue
= *parselist
++;
978 GLint size
= *parselist
++;
979 alpha_flag
= size
>0 ? 1 : 0;
984 depth_size
= *parselist
++;
986 case GLX_STENCIL_SIZE
:
988 stencil_size
= *parselist
++;
990 case GLX_ACCUM_RED_SIZE
:
993 GLint size
= *parselist
++;
994 accumRedSize
= MAX2( accumRedSize
, size
);
997 case GLX_ACCUM_GREEN_SIZE
:
1000 GLint size
= *parselist
++;
1001 accumGreenSize
= MAX2( accumGreenSize
, size
);
1004 case GLX_ACCUM_BLUE_SIZE
:
1007 GLint size
= *parselist
++;
1008 accumBlueSize
= MAX2( accumBlueSize
, size
);
1011 case GLX_ACCUM_ALPHA_SIZE
:
1014 GLint size
= *parselist
++;
1015 accumAlphaSize
= MAX2( accumAlphaSize
, size
);
1020 * GLX_EXT_visual_info extension
1022 case GLX_X_VISUAL_TYPE_EXT
:
1024 visual_type
= *parselist
++;
1026 case GLX_TRANSPARENT_TYPE_EXT
:
1028 trans_type
= *parselist
++;
1030 case GLX_TRANSPARENT_INDEX_VALUE_EXT
:
1032 trans_value
= *parselist
++;
1034 case GLX_TRANSPARENT_RED_VALUE_EXT
:
1035 case GLX_TRANSPARENT_GREEN_VALUE_EXT
:
1036 case GLX_TRANSPARENT_BLUE_VALUE_EXT
:
1037 case GLX_TRANSPARENT_ALPHA_VALUE_EXT
:
1044 * GLX_EXT_visual_info extension
1046 case GLX_VISUAL_CAVEAT_EXT
:
1048 caveat
= *parselist
++; /* ignored for now */
1052 * GLX_ARB_multisample
1054 case GLX_SAMPLE_BUFFERS_ARB
:
1055 /* ms not supported */
1057 case GLX_SAMPLES_ARB
:
1058 /* ms not supported */
1064 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
== 0) {
1077 case GLX_DRAWABLE_TYPE
:
1079 if (*parselist
& ~(GLX_WINDOW_BIT
| GLX_PIXMAP_BIT
| GLX_PBUFFER_BIT
)) {
1080 return NULL
; /* bad bit */
1089 /* undefined attribute */
1090 _mesa_warning(NULL
, "unexpected attrib 0x%x in choose_visual()",
1097 * Since we're only simulating the GLX extension this function will never
1098 * find any real GL visuals. Instead, all we can do is try to find an RGB
1099 * or CI visual of appropriate depth. Other requested attributes such as
1100 * double buffering, depth buffer, etc. will be associated with the X
1101 * visual and stored in the VisualTable[].
1104 /* normal color planes */
1106 /* Get an RGB visual */
1107 int min_rgb
= min_red
+ min_green
+ min_blue
;
1108 if (min_rgb
>1 && min_rgb
<8) {
1109 /* a special case to be sure we can get a monochrome visual */
1112 vis
= choose_x_visual( dpy
, screen
, rgb_flag
, min_rgb
, visual_type
);
1115 /* Get a color index visual */
1116 vis
= choose_x_visual( dpy
, screen
, rgb_flag
, min_ci
, visual_type
);
1117 accumRedSize
= accumGreenSize
= accumBlueSize
= accumAlphaSize
= 0;
1121 /* over/underlay planes */
1124 int min_rgb
= min_red
+ min_green
+ min_blue
;
1125 if (min_rgb
>1 && min_rgb
<8) {
1126 /* a special case to be sure we can get a monochrome visual */
1129 vis
= choose_x_overlay_visual( dpy
, screen
, rgb_flag
, level
,
1130 trans_type
, trans_value
, min_rgb
, visual_type
);
1133 /* color index overlay */
1134 vis
= choose_x_overlay_visual( dpy
, screen
, rgb_flag
, level
,
1135 trans_type
, trans_value
, min_ci
, visual_type
);
1140 /* Note: we're not exactly obeying the glXChooseVisual rules here.
1141 * When GLX_DEPTH_SIZE = 1 is specified we're supposed to choose the
1142 * largest depth buffer size, which is 32bits/value. Instead, we
1143 * return 16 to maintain performance with earlier versions of Mesa.
1145 if (depth_size
> 24)
1146 depth_size
= 31; /* 32 causes int overflow problems */
1147 else if (depth_size
> 16)
1149 else if (depth_size
> 0)
1150 depth_size
= DEFAULT_SOFTWARE_DEPTH_BITS
; /*16*/
1152 /* we only support one size of stencil and accum buffers. */
1153 if (stencil_size
> 0)
1154 stencil_size
= STENCIL_BITS
;
1155 if (accumRedSize
> 0 || accumGreenSize
> 0 || accumBlueSize
> 0 ||
1156 accumAlphaSize
> 0) {
1157 accumRedSize
= ACCUM_BITS
;
1158 accumGreenSize
= ACCUM_BITS
;
1159 accumBlueSize
= ACCUM_BITS
;
1160 accumAlphaSize
= alpha_flag
? ACCUM_BITS
: 0;
1163 xmvis
= save_glx_visual( dpy
, vis
, rgb_flag
, alpha_flag
, double_flag
,
1164 stereo_flag
, depth_size
, stencil_size
,
1165 accumRedSize
, accumGreenSize
,
1166 accumBlueSize
, accumAlphaSize
, level
);
1173 static XVisualInfo
*
1174 Fake_glXChooseVisual( Display
*dpy
, int screen
, int *list
)
1176 XMesaVisual xmvis
= choose_visual(dpy
, screen
, list
);
1178 return xmvis
->vishandle
;
1185 Fake_glXCreateContext( Display
*dpy
, XVisualInfo
*visinfo
,
1186 GLXContext share_list
, Bool direct
)
1189 struct fake_glx_context
*glxCtx
;
1190 struct fake_glx_context
*shareCtx
= (struct fake_glx_context
*) share_list
;
1192 if (!dpy
|| !visinfo
)
1195 glxCtx
= CALLOC_STRUCT(fake_glx_context
);
1199 /* deallocate unused windows/buffers */
1200 XMesaGarbageCollect();
1202 xmvis
= find_glx_visual( dpy
, visinfo
);
1204 /* This visual wasn't found with glXChooseVisual() */
1205 xmvis
= create_glx_visual( dpy
, visinfo
);
1207 /* unusable visual */
1213 glxCtx
->xmesaContext
= XMesaCreateContext(xmvis
,
1214 shareCtx
? shareCtx
->xmesaContext
: NULL
);
1215 if (!glxCtx
->xmesaContext
) {
1220 glxCtx
->xmesaContext
->direct
= GL_FALSE
;
1221 glxCtx
->glxContext
.isDirect
= GL_FALSE
;
1222 glxCtx
->glxContext
.currentDpy
= dpy
;
1223 glxCtx
->glxContext
.xid
= (XID
) glxCtx
; /* self pointer */
1225 assert((void *) glxCtx
== (void *) &(glxCtx
->glxContext
));
1227 return (GLXContext
) glxCtx
;
1231 /* XXX these may have to be removed due to thread-safety issues. */
1232 static GLXContext MakeCurrent_PrevContext
= 0;
1233 static GLXDrawable MakeCurrent_PrevDrawable
= 0;
1234 static GLXDrawable MakeCurrent_PrevReadable
= 0;
1235 static XMesaBuffer MakeCurrent_PrevDrawBuffer
= 0;
1236 static XMesaBuffer MakeCurrent_PrevReadBuffer
= 0;
1239 /* GLX 1.3 and later */
1241 Fake_glXMakeContextCurrent( Display
*dpy
, GLXDrawable draw
,
1242 GLXDrawable read
, GLXContext ctx
)
1244 struct fake_glx_context
*glxCtx
= (struct fake_glx_context
*) ctx
;
1246 if (ctx
&& draw
&& read
) {
1247 XMesaBuffer drawBuffer
, readBuffer
;
1248 XMesaContext xmctx
= glxCtx
->xmesaContext
;
1250 /* Find the XMesaBuffer which corresponds to the GLXDrawable 'draw' */
1251 if (ctx
== MakeCurrent_PrevContext
1252 && draw
== MakeCurrent_PrevDrawable
) {
1253 drawBuffer
= MakeCurrent_PrevDrawBuffer
;
1256 drawBuffer
= XMesaFindBuffer( dpy
, draw
);
1259 /* drawable must be a new window! */
1260 drawBuffer
= XMesaCreateWindowBuffer2( xmctx
->xm_visual
, draw
, xmctx
);
1262 /* Out of memory, or context/drawable depth mismatch */
1267 /* Find the XMesaBuffer which corresponds to the GLXDrawable 'read' */
1268 if (ctx
== MakeCurrent_PrevContext
1269 && read
== MakeCurrent_PrevReadable
) {
1270 readBuffer
= MakeCurrent_PrevReadBuffer
;
1273 readBuffer
= XMesaFindBuffer( dpy
, read
);
1276 /* drawable must be a new window! */
1277 readBuffer
= XMesaCreateWindowBuffer2(glxCtx
->xmesaContext
->xm_visual
,
1280 /* Out of memory, or context/drawable depth mismatch */
1285 MakeCurrent_PrevContext
= ctx
;
1286 MakeCurrent_PrevDrawable
= draw
;
1287 MakeCurrent_PrevReadable
= read
;
1288 MakeCurrent_PrevDrawBuffer
= drawBuffer
;
1289 MakeCurrent_PrevReadBuffer
= readBuffer
;
1291 /* Now make current! */
1292 if (XMesaMakeCurrent2(xmctx
, drawBuffer
, readBuffer
)) {
1293 ((__GLXcontext
*) ctx
)->currentDpy
= dpy
;
1294 ((__GLXcontext
*) ctx
)->currentDrawable
= draw
;
1295 #ifndef GLX_BUILT_IN_XMESA
1296 ((__GLXcontext
*) ctx
)->currentReadable
= read
;
1298 __glXSetCurrentContext(ctx
);
1306 else if (!ctx
&& !draw
&& !read
) {
1307 /* release current context w/out assigning new one. */
1308 XMesaMakeCurrent( NULL
, NULL
);
1309 MakeCurrent_PrevContext
= 0;
1310 MakeCurrent_PrevDrawable
= 0;
1311 MakeCurrent_PrevReadable
= 0;
1312 MakeCurrent_PrevDrawBuffer
= 0;
1313 MakeCurrent_PrevReadBuffer
= 0;
1314 #ifdef GLX_BUILT_IN_XMESA
1315 /* XXX bind dummy context with __glXSetCurrentContext(ctx); */
1320 /* The args must either all be non-zero or all zero.
1330 Fake_glXMakeCurrent( Display
*dpy
, GLXDrawable drawable
, GLXContext ctx
)
1332 return Fake_glXMakeContextCurrent( dpy
, drawable
, drawable
, ctx
);
1338 Fake_glXCreateGLXPixmap( Display
*dpy
, XVisualInfo
*visinfo
, Pixmap pixmap
)
1343 v
= find_glx_visual( dpy
, visinfo
);
1345 v
= create_glx_visual( dpy
, visinfo
);
1347 /* unusable visual */
1352 b
= XMesaCreatePixmapBuffer( v
, pixmap
, 0 );
1356 return b
->frontbuffer
;
1360 /*** GLX_MESA_pixmap_colormap ***/
1363 Fake_glXCreateGLXPixmapMESA( Display
*dpy
, XVisualInfo
*visinfo
,
1364 Pixmap pixmap
, Colormap cmap
)
1369 v
= find_glx_visual( dpy
, visinfo
);
1371 v
= create_glx_visual( dpy
, visinfo
);
1373 /* unusable visual */
1378 b
= XMesaCreatePixmapBuffer( v
, pixmap
, cmap
);
1382 return b
->frontbuffer
;
1387 Fake_glXDestroyGLXPixmap( Display
*dpy
, GLXPixmap pixmap
)
1389 XMesaBuffer b
= XMesaFindBuffer(dpy
, pixmap
);
1391 XMesaDestroyBuffer(b
);
1393 else if (_mesa_getenv("MESA_DEBUG")) {
1394 _mesa_warning(NULL
, "Mesa: glXDestroyGLXPixmap: invalid pixmap\n");
1401 Fake_glXCopyContext( Display
*dpy
, GLXContext src
, GLXContext dst
,
1402 unsigned long mask
)
1404 struct fake_glx_context
*fakeSrc
= (struct fake_glx_context
*) src
;
1405 struct fake_glx_context
*fakeDst
= (struct fake_glx_context
*) dst
;
1406 XMesaContext xm_src
= fakeSrc
->xmesaContext
;
1407 XMesaContext xm_dst
= fakeDst
->xmesaContext
;
1409 _mesa_copy_context( xm_src
->gl_ctx
, xm_dst
->gl_ctx
, (GLuint
) mask
);
1415 Fake_glXQueryExtension( Display
*dpy
, int *errorb
, int *event
)
1417 /* Mesa's GLX isn't really an X extension but we try to act like one. */
1425 extern void _kw_ungrab_all( Display
*dpy
);
1426 void _kw_ungrab_all( Display
*dpy
)
1428 XUngrabPointer( dpy
, CurrentTime
);
1429 XUngrabKeyboard( dpy
, CurrentTime
);
1434 Fake_glXDestroyContext( Display
*dpy
, GLXContext ctx
)
1436 struct fake_glx_context
*glxCtx
= (struct fake_glx_context
*) ctx
;
1438 MakeCurrent_PrevContext
= 0;
1439 MakeCurrent_PrevDrawable
= 0;
1440 MakeCurrent_PrevReadable
= 0;
1441 MakeCurrent_PrevDrawBuffer
= 0;
1442 MakeCurrent_PrevReadBuffer
= 0;
1443 XMesaDestroyContext( glxCtx
->xmesaContext
);
1444 XMesaGarbageCollect();
1450 Fake_glXIsDirect( Display
*dpy
, GLXContext ctx
)
1452 struct fake_glx_context
*glxCtx
= (struct fake_glx_context
*) ctx
;
1454 return glxCtx
->xmesaContext
->direct
;
1460 Fake_glXSwapBuffers( Display
*dpy
, GLXDrawable drawable
)
1462 XMesaBuffer buffer
= XMesaFindBuffer( dpy
, drawable
);
1465 XMesaSwapBuffers(buffer
);
1467 else if (_mesa_getenv("MESA_DEBUG")) {
1468 _mesa_warning(NULL
, "Mesa: glXSwapBuffers: invalid drawable\n");
1474 /*** GLX_MESA_copy_sub_buffer ***/
1477 Fake_glXCopySubBufferMESA( Display
*dpy
, GLXDrawable drawable
,
1478 int x
, int y
, int width
, int height
)
1480 XMesaBuffer buffer
= XMesaFindBuffer( dpy
, drawable
);
1482 XMesaCopySubBuffer(buffer
, x
, y
, width
, height
);
1484 else if (_mesa_getenv("MESA_DEBUG")) {
1485 _mesa_warning(NULL
, "Mesa: glXCopySubBufferMESA: invalid drawable\n");
1492 Fake_glXQueryVersion( Display
*dpy
, int *maj
, int *min
)
1495 /* Return GLX version, not Mesa version */
1496 assert(CLIENT_MAJOR_VERSION
== SERVER_MAJOR_VERSION
);
1497 *maj
= CLIENT_MAJOR_VERSION
;
1498 *min
= MIN2( CLIENT_MINOR_VERSION
, SERVER_MINOR_VERSION
);
1505 * Query the GLX attributes of the given XVisualInfo.
1508 get_config( XMesaVisual xmvis
, int attrib
, int *value
, GLboolean fbconfig
)
1513 *value
= (int) True
;
1515 case GLX_BUFFER_SIZE
:
1516 *value
= xmvis
->visinfo
->depth
;
1519 *value
= xmvis
->level
;
1522 if (xmvis
->mesa_visual
.rgbMode
) {
1529 case GLX_DOUBLEBUFFER
:
1530 *value
= (int) xmvis
->mesa_visual
.doubleBufferMode
;
1533 *value
= (int) xmvis
->mesa_visual
.stereoMode
;
1535 case GLX_AUX_BUFFERS
:
1536 *value
= (int) False
;
1539 *value
= xmvis
->mesa_visual
.redBits
;
1541 case GLX_GREEN_SIZE
:
1542 *value
= xmvis
->mesa_visual
.greenBits
;
1545 *value
= xmvis
->mesa_visual
.blueBits
;
1547 case GLX_ALPHA_SIZE
:
1548 *value
= xmvis
->mesa_visual
.alphaBits
;
1550 case GLX_DEPTH_SIZE
:
1551 *value
= xmvis
->mesa_visual
.depthBits
;
1553 case GLX_STENCIL_SIZE
:
1554 *value
= xmvis
->mesa_visual
.stencilBits
;
1556 case GLX_ACCUM_RED_SIZE
:
1557 *value
= xmvis
->mesa_visual
.accumRedBits
;
1559 case GLX_ACCUM_GREEN_SIZE
:
1560 *value
= xmvis
->mesa_visual
.accumGreenBits
;
1562 case GLX_ACCUM_BLUE_SIZE
:
1563 *value
= xmvis
->mesa_visual
.accumBlueBits
;
1565 case GLX_ACCUM_ALPHA_SIZE
:
1566 *value
= xmvis
->mesa_visual
.accumAlphaBits
;
1570 * GLX_EXT_visual_info extension
1572 case GLX_X_VISUAL_TYPE_EXT
:
1573 switch (xmvis
->visinfo
->CLASS
) {
1574 case StaticGray
: *value
= GLX_STATIC_GRAY_EXT
; return 0;
1575 case GrayScale
: *value
= GLX_GRAY_SCALE_EXT
; return 0;
1576 case StaticColor
: *value
= GLX_STATIC_GRAY_EXT
; return 0;
1577 case PseudoColor
: *value
= GLX_PSEUDO_COLOR_EXT
; return 0;
1578 case TrueColor
: *value
= GLX_TRUE_COLOR_EXT
; return 0;
1579 case DirectColor
: *value
= GLX_DIRECT_COLOR_EXT
; return 0;
1582 case GLX_TRANSPARENT_TYPE_EXT
:
1583 if (xmvis
->level
==0) {
1585 *value
= GLX_NONE_EXT
;
1587 else if (xmvis
->level
>0) {
1589 if (xmvis
->mesa_visual
.rgbMode
) {
1590 *value
= GLX_TRANSPARENT_RGB_EXT
;
1593 *value
= GLX_TRANSPARENT_INDEX_EXT
;
1596 else if (xmvis
->level
<0) {
1598 *value
= GLX_NONE_EXT
;
1601 case GLX_TRANSPARENT_INDEX_VALUE_EXT
:
1603 int pixel
= transparent_pixel( xmvis
);
1607 /* else undefined */
1610 case GLX_TRANSPARENT_RED_VALUE_EXT
:
1613 case GLX_TRANSPARENT_GREEN_VALUE_EXT
:
1616 case GLX_TRANSPARENT_BLUE_VALUE_EXT
:
1619 case GLX_TRANSPARENT_ALPHA_VALUE_EXT
:
1624 * GLX_EXT_visual_info extension
1626 case GLX_VISUAL_CAVEAT_EXT
:
1627 /* test for zero, just in case */
1628 if (xmvis
->VisualCaveat
> 0)
1629 *value
= xmvis
->VisualCaveat
;
1631 *value
= GLX_NONE_EXT
;
1635 * GLX_ARB_multisample
1637 case GLX_SAMPLE_BUFFERS_ARB
:
1640 case GLX_SAMPLES_ARB
:
1647 case GLX_SCREEN_EXT
:
1649 return GLX_BAD_ATTRIBUTE
;
1650 *value
= xmvis
->visinfo
->screen
;
1652 case GLX_DRAWABLE_TYPE
: /*SGIX too */
1654 return GLX_BAD_ATTRIBUTE
;
1655 *value
= GLX_WINDOW_BIT
| GLX_PIXMAP_BIT
| GLX_PBUFFER_BIT
;
1657 case GLX_RENDER_TYPE_SGIX
:
1659 return GLX_BAD_ATTRIBUTE
;
1660 if (xmvis
->mesa_visual
.rgbMode
)
1661 *value
= GLX_RGBA_BIT
;
1663 *value
= GLX_COLOR_INDEX_BIT
;
1665 case GLX_X_RENDERABLE_SGIX
:
1667 return GLX_BAD_ATTRIBUTE
;
1668 *value
= True
; /* XXX really? */
1670 case GLX_FBCONFIG_ID_SGIX
:
1672 return GLX_BAD_ATTRIBUTE
;
1673 *value
= xmvis
->vishandle
->visualid
;
1675 case GLX_MAX_PBUFFER_WIDTH
:
1677 return GLX_BAD_ATTRIBUTE
;
1678 /* XXX or MAX_WIDTH? */
1679 *value
= DisplayWidth(xmvis
->display
, xmvis
->vishandle
->screen
);
1681 case GLX_MAX_PBUFFER_HEIGHT
:
1683 return GLX_BAD_ATTRIBUTE
;
1684 *value
= DisplayHeight(xmvis
->display
, xmvis
->vishandle
->screen
);
1686 case GLX_MAX_PBUFFER_PIXELS
:
1688 return GLX_BAD_ATTRIBUTE
;
1689 *value
= DisplayWidth(xmvis
->display
, xmvis
->vishandle
->screen
) *
1690 DisplayHeight(xmvis
->display
, xmvis
->vishandle
->screen
);
1694 return GLX_BAD_ATTRIBUTE
;
1695 *value
= xmvis
->vishandle
->visualid
;
1699 return GLX_BAD_ATTRIBUTE
;
1706 Fake_glXGetConfig( Display
*dpy
, XVisualInfo
*visinfo
,
1707 int attrib
, int *value
)
1711 xmvis
= find_glx_visual( dpy
, visinfo
);
1713 /* this visual wasn't obtained with glXChooseVisual */
1714 xmvis
= create_glx_visual( dpy
, visinfo
);
1716 /* this visual can't be used for GL rendering */
1717 if (attrib
==GLX_USE_GL
) {
1718 *value
= (int) False
;
1722 return GLX_BAD_VISUAL
;
1727 return get_config(xmvis
, attrib
, value
, GL_FALSE
);
1732 Fake_glXWaitGL( void )
1734 XMesaContext xmesa
= XMesaGetCurrentContext();
1735 XMesaFlush( xmesa
);
1741 Fake_glXWaitX( void )
1743 XMesaContext xmesa
= XMesaGetCurrentContext();
1744 XMesaFlush( xmesa
);
1749 get_extensions( void )
1752 const char *fx
= _mesa_getenv("MESA_GLX_FX");
1753 if (fx
&& fx
[0] != 'd') {
1757 return EXTENSIONS
+ 23; /* skip "GLX_MESA_set_3dfx_mode" */
1762 /* GLX 1.1 and later */
1764 Fake_glXQueryExtensionsString( Display
*dpy
, int screen
)
1768 return get_extensions();
1773 /* GLX 1.1 and later */
1775 Fake_glXQueryServerString( Display
*dpy
, int screen
, int name
)
1777 static char version
[1000];
1778 _mesa_sprintf(version
, "%d.%d %s",
1779 SERVER_MAJOR_VERSION
, SERVER_MINOR_VERSION
, MESA_GLX_VERSION
);
1785 case GLX_EXTENSIONS
:
1786 return get_extensions();
1798 /* GLX 1.1 and later */
1800 Fake_glXGetClientString( Display
*dpy
, int name
)
1802 static char version
[1000];
1803 _mesa_sprintf(version
, "%d.%d %s", CLIENT_MAJOR_VERSION
,
1804 CLIENT_MINOR_VERSION
, MESA_GLX_VERSION
);
1809 case GLX_EXTENSIONS
:
1810 return get_extensions();
1827 static GLXFBConfig
*
1828 Fake_glXChooseFBConfig( Display
*dpy
, int screen
,
1829 const int *attribList
, int *nitems
)
1831 XMesaVisual xmvis
= choose_visual(dpy
, screen
, attribList
);
1833 GLXFBConfig
*config
= _mesa_malloc(sizeof(XMesaVisual
));
1839 config
[0] = (GLXFBConfig
) xmvis
;
1840 return (GLXFBConfig
*) config
;
1850 Fake_glXGetFBConfigAttrib( Display
*dpy
, GLXFBConfig config
,
1851 int attribute
, int *value
)
1853 XMesaVisual v
= (XMesaVisual
) config
;
1857 if (!dpy
|| !config
|| !value
)
1860 return get_config(v
, attribute
, value
, GL_TRUE
);
1864 static GLXFBConfig
*
1865 Fake_glXGetFBConfigs( Display
*dpy
, int screen
, int *nelements
)
1867 XVisualInfo
*visuals
, visTemplate
;
1868 const long visMask
= VisualScreenMask
;
1871 /* Get list of all X visuals */
1872 visTemplate
.screen
= screen
;
1873 visuals
= XGetVisualInfo(dpy
, visMask
, &visTemplate
, nelements
);
1874 if (*nelements
> 0) {
1875 XMesaVisual
*results
;
1876 results
= _mesa_malloc(*nelements
* sizeof(XMesaVisual
));
1881 for (i
= 0; i
< *nelements
; i
++) {
1882 results
[i
] = create_glx_visual(dpy
, visuals
+ i
);
1884 return (GLXFBConfig
*) results
;
1890 static XVisualInfo
*
1891 Fake_glXGetVisualFromFBConfig( Display
*dpy
, GLXFBConfig config
)
1893 if (dpy
&& config
) {
1894 XMesaVisual v
= (XMesaVisual
) config
;
1895 return v
->vishandle
;
1904 Fake_glXCreateWindow( Display
*dpy
, GLXFBConfig config
, Window win
,
1905 const int *attribList
)
1910 (void) attribList
; /* Ignored in GLX 1.3 */
1912 return win
; /* A hack for now */
1917 Fake_glXDestroyWindow( Display
*dpy
, GLXWindow window
)
1919 XMesaBuffer b
= XMesaFindBuffer(dpy
, (XMesaDrawable
) window
);
1921 XMesaDestroyBuffer(b
);
1922 /* don't destroy X window */
1928 Fake_glXCreatePixmap( Display
*dpy
, GLXFBConfig config
, Pixmap pixmap
,
1929 const int *attribList
)
1931 XMesaVisual v
= (XMesaVisual
) config
;
1932 XVisualInfo
*visinfo
;
1938 (void) attribList
; /* Ignored in GLX 1.3 */
1940 if (!dpy
|| !config
|| !pixmap
)
1943 visinfo
= v
->vishandle
;
1945 v
= find_glx_visual( dpy
, visinfo
);
1947 v
= create_glx_visual( dpy
, visinfo
);
1949 /* unusable visual */
1954 b
= XMesaCreatePixmapBuffer( v
, pixmap
, 0 );
1964 Fake_glXDestroyPixmap( Display
*dpy
, GLXPixmap pixmap
)
1966 XMesaBuffer b
= XMesaFindBuffer(dpy
, (XMesaDrawable
)pixmap
);
1968 XMesaDestroyBuffer(b
);
1969 /* don't destroy X pixmap */
1974 Fake_glXCreatePbuffer( Display
*dpy
, GLXFBConfig config
,
1975 const int *attribList
)
1977 XMesaVisual xmvis
= (XMesaVisual
) config
;
1980 int width
= 0, height
= 0;
1981 GLboolean useLargest
= GL_FALSE
, preserveContents
= GL_FALSE
;
1985 for (attrib
= attribList
; *attrib
; attrib
++) {
1987 case GLX_PBUFFER_WIDTH
:
1991 case GLX_PBUFFER_HEIGHT
:
1995 case GLX_PRESERVED_CONTENTS
:
1997 preserveContents
= *attrib
; /* ignored */
1999 case GLX_LARGEST_PBUFFER
:
2001 useLargest
= *attrib
; /* ignored */
2008 if (width
== 0 || height
== 0)
2011 xmbuf
= XMesaCreatePBuffer( xmvis
, 0, width
, height
);
2012 /* A GLXPbuffer handle must be an X Drawable because that's what
2013 * glXMakeCurrent takes.
2015 return (GLXPbuffer
) xmbuf
->frontbuffer
;
2020 Fake_glXDestroyPbuffer( Display
*dpy
, GLXPbuffer pbuf
)
2022 XMesaBuffer b
= XMesaFindBuffer(dpy
, pbuf
);
2024 XMesaDestroyBuffer(b
);
2030 Fake_glXQueryDrawable( Display
*dpy
, GLXDrawable draw
, int attribute
,
2031 unsigned int *value
)
2033 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, draw
);
2037 switch (attribute
) {
2039 *value
= xmbuf
->width
;
2042 *value
= xmbuf
->height
;
2044 case GLX_PRESERVED_CONTENTS
:
2047 case GLX_LARGEST_PBUFFER
:
2048 *value
= xmbuf
->width
* xmbuf
->height
;
2050 case GLX_FBCONFIG_ID
:
2051 *value
= xmbuf
->xm_visual
->vishandle
->visualid
;
2054 return; /* GLX_BAD_ATTRIBUTE? */
2060 Fake_glXCreateNewContext( Display
*dpy
, GLXFBConfig config
,
2061 int renderType
, GLXContext shareList
, Bool direct
)
2063 XMesaVisual v
= (XMesaVisual
) config
;
2065 if (!dpy
|| !config
||
2066 (renderType
!= GLX_RGBA_TYPE
&& renderType
!= GLX_COLOR_INDEX_TYPE
))
2069 return Fake_glXCreateContext(dpy
, v
->vishandle
, shareList
, direct
);
2074 Fake_glXQueryContext( Display
*dpy
, GLXContext ctx
, int attribute
, int *value
)
2076 struct fake_glx_context
*glxCtx
= (struct fake_glx_context
*) ctx
;
2077 XMesaContext xmctx
= glxCtx
->xmesaContext
;
2082 switch (attribute
) {
2083 case GLX_FBCONFIG_ID
:
2084 *value
= xmctx
->xm_visual
->vishandle
->visualid
;
2086 case GLX_RENDER_TYPE
:
2087 if (xmctx
->xm_visual
->mesa_visual
.rgbMode
)
2088 *value
= GLX_RGBA_BIT
;
2090 *value
= GLX_COLOR_INDEX_BIT
;
2096 return GLX_BAD_ATTRIBUTE
;
2103 Fake_glXSelectEvent( Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
2105 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, drawable
);
2107 xmbuf
->selectedEvents
= mask
;
2112 Fake_glXGetSelectedEvent( Display
*dpy
, GLXDrawable drawable
,
2113 unsigned long *mask
)
2115 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, drawable
);
2117 *mask
= xmbuf
->selectedEvents
;
2124 /*** GLX_SGI_swap_control ***/
2127 Fake_glXSwapIntervalSGI(int interval
)
2135 /*** GLX_SGI_video_sync ***/
2138 Fake_glXGetVideoSyncSGI(unsigned int *count
)
2145 Fake_glXWaitVideoSyncSGI(int divisor
, int remainder
, unsigned int *count
)
2155 /*** GLX_SGI_make_current_read ***/
2158 Fake_glXMakeCurrentReadSGI(Display
*dpy
, GLXDrawable draw
, GLXDrawable read
, GLXContext ctx
)
2160 return Fake_glXMakeContextCurrent( dpy
, draw
, read
, ctx
);
2165 Fake_glXGetCurrentReadDrawableSGI(void)
2172 /*** GLX_SGIX_video_source ***/
2175 static GLXVideoSourceSGIX
2176 Fake_glXCreateGLXVideoSourceSGIX(Display
*dpy
, int screen
, VLServer server
, VLPath path
, int nodeClass
, VLNode drainNode
)
2188 Fake_glXDestroyGLXVideoSourceSGIX(Display
*dpy
, GLXVideoSourceSGIX src
)
2197 /*** GLX_EXT_import_context ***/
2200 Fake_glXFreeContextEXT(Display
*dpy
, GLXContext context
)
2207 Fake_glXGetContextIDEXT(const GLXContext context
)
2214 Fake_glXImportContextEXT(Display
*dpy
, GLXContextID contextID
)
2222 Fake_glXQueryContextInfoEXT(Display
*dpy
, GLXContext context
, int attribute
, int *value
)
2233 /*** GLX_SGIX_fbconfig ***/
2236 Fake_glXGetFBConfigAttribSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int attribute
, int *value
)
2238 return Fake_glXGetFBConfigAttrib(dpy
, config
, attribute
, value
);
2241 static GLXFBConfigSGIX
*
2242 Fake_glXChooseFBConfigSGIX(Display
*dpy
, int screen
, int *attrib_list
, int *nelements
)
2244 return (GLXFBConfig
*) Fake_glXChooseFBConfig(dpy
, screen
, attrib_list
, nelements
);
2249 Fake_glXCreateGLXPixmapWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, Pixmap pixmap
)
2251 XMesaVisual xmvis
= (XMesaVisual
) config
;
2252 XMesaBuffer xmbuf
= XMesaCreatePixmapBuffer(xmvis
, pixmap
, 0);
2253 return xmbuf
->frontbuffer
; /* need to return an X ID */
2258 Fake_glXCreateContextWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int render_type
, GLXContext share_list
, Bool direct
)
2260 XMesaVisual xmvis
= (XMesaVisual
) config
;
2261 struct fake_glx_context
*glxCtx
;
2262 struct fake_glx_context
*shareCtx
= (struct fake_glx_context
*) share_list
;
2264 glxCtx
= CALLOC_STRUCT(fake_glx_context
);
2268 /* deallocate unused windows/buffers */
2269 XMesaGarbageCollect();
2271 glxCtx
->xmesaContext
= XMesaCreateContext(xmvis
,
2272 shareCtx
? shareCtx
->xmesaContext
: NULL
);
2273 if (!glxCtx
->xmesaContext
) {
2278 glxCtx
->xmesaContext
->direct
= GL_FALSE
;
2279 glxCtx
->glxContext
.isDirect
= GL_FALSE
;
2280 glxCtx
->glxContext
.currentDpy
= dpy
;
2281 glxCtx
->glxContext
.xid
= (XID
) glxCtx
; /* self pointer */
2283 assert((void *) glxCtx
== (void *) &(glxCtx
->glxContext
));
2285 return (GLXContext
) glxCtx
;
2289 static XVisualInfo
*
2290 Fake_glXGetVisualFromFBConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
)
2292 return Fake_glXGetVisualFromFBConfig(dpy
, config
);
2296 static GLXFBConfigSGIX
2297 Fake_glXGetFBConfigFromVisualSGIX(Display
*dpy
, XVisualInfo
*vis
)
2299 XMesaVisual xmvis
= find_glx_visual(dpy
, vis
);
2301 /* This visual wasn't found with glXChooseVisual() */
2302 xmvis
= create_glx_visual(dpy
, vis
);
2305 return (GLXFBConfigSGIX
) xmvis
;
2310 /*** GLX_SGIX_pbuffer ***/
2312 static GLXPbufferSGIX
2313 Fake_glXCreateGLXPbufferSGIX(Display
*dpy
, GLXFBConfigSGIX config
,
2314 unsigned int width
, unsigned int height
,
2317 XMesaVisual xmvis
= (XMesaVisual
) config
;
2320 GLboolean useLargest
= GL_FALSE
, preserveContents
= GL_FALSE
;
2324 for (attrib
= attribList
; *attrib
; attrib
++) {
2326 case GLX_PRESERVED_CONTENTS_SGIX
:
2328 preserveContents
= *attrib
; /* ignored */
2330 case GLX_LARGEST_PBUFFER_SGIX
:
2332 useLargest
= *attrib
; /* ignored */
2339 xmbuf
= XMesaCreatePBuffer( xmvis
, 0, width
, height
);
2340 /* A GLXPbuffer handle must be an X Drawable because that's what
2341 * glXMakeCurrent takes.
2343 return (GLXPbuffer
) xmbuf
->frontbuffer
;
2348 Fake_glXDestroyGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
)
2350 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, pbuf
);
2352 XMesaDestroyBuffer(xmbuf
);
2358 Fake_glXQueryGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
, int attribute
, unsigned int *value
)
2360 const XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, pbuf
);
2363 /* Generate GLXBadPbufferSGIX for bad pbuffer */
2367 switch (attribute
) {
2368 case GLX_PRESERVED_CONTENTS_SGIX
:
2371 case GLX_LARGEST_PBUFFER_SGIX
:
2372 *value
= xmbuf
->width
* xmbuf
->height
;
2374 case GLX_WIDTH_SGIX
:
2375 *value
= xmbuf
->width
;
2377 case GLX_HEIGHT_SGIX
:
2378 *value
= xmbuf
->height
;
2380 case GLX_EVENT_MASK_SGIX
:
2381 *value
= 0; /* XXX might be wrong */
2391 Fake_glXSelectEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
2393 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, drawable
);
2395 /* Note: we'll never generate clobber events */
2396 xmbuf
->selectedEvents
= mask
;
2402 Fake_glXGetSelectedEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long *mask
)
2404 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, drawable
);
2406 *mask
= xmbuf
->selectedEvents
;
2415 /*** GLX_SGI_cushion ***/
2418 Fake_glXCushionSGI(Display
*dpy
, Window win
, float cushion
)
2427 /*** GLX_SGIX_video_resize ***/
2430 Fake_glXBindChannelToWindowSGIX(Display
*dpy
, int screen
, int channel
, Window window
)
2440 Fake_glXChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int x
, int y
, int w
, int h
)
2453 Fake_glXQueryChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int *x
, int *y
, int *w
, int *h
)
2466 Fake_glXQueryChannelDeltasSGIX(Display
*dpy
, int screen
, int channel
, int *dx
, int *dy
, int *dw
, int *dh
)
2479 Fake_glXChannelRectSyncSGIX(Display
*dpy
, int screen
, int channel
, GLenum synctype
)
2490 /*** GLX_SGIX_dmbuffer **/
2492 #if defined(_DM_BUFFER_H_)
2494 Fake_glXAssociateDMPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuffer
, DMparams
*params
, DMbuffer dmbuffer
)
2505 /*** GLX_SGIX_swap_group ***/
2508 Fake_glXJoinSwapGroupSGIX(Display
*dpy
, GLXDrawable drawable
, GLXDrawable member
)
2517 /*** GLX_SGIX_swap_barrier ***/
2520 Fake_glXBindSwapBarrierSGIX(Display
*dpy
, GLXDrawable drawable
, int barrier
)
2528 Fake_glXQueryMaxSwapBarriersSGIX(Display
*dpy
, int screen
, int *max
)
2538 /*** GLX_SUN_get_transparent_index ***/
2541 Fake_glXGetTransparentIndexSUN(Display
*dpy
, Window overlay
, Window underlay
, long *pTransparent
)
2546 (void) pTransparent
;
2552 /*** GLX_MESA_release_buffers ***/
2555 * Release the depth, stencil, accum buffers attached to a GLXDrawable
2556 * (a window or pixmap) prior to destroying the GLXDrawable.
2559 Fake_glXReleaseBuffersMESA( Display
*dpy
, GLXDrawable d
)
2561 XMesaBuffer b
= XMesaFindBuffer(dpy
, d
);
2563 XMesaDestroyBuffer(b
);
2571 /*** GLX_MESA_set_3dfx_mode ***/
2574 Fake_glXSet3DfxModeMESA( int mode
)
2576 return XMesaSetFXmode( mode
);
2581 /*** AGP memory allocation ***/
2583 Fake_glXAllocateMemoryNV( GLsizei size
,
2584 GLfloat readFrequency
,
2585 GLfloat writeFrequency
,
2589 (void) readFrequency
;
2590 (void) writeFrequency
;
2597 Fake_glXFreeMemoryNV( GLvoid
*pointer
)
2604 extern struct _glxapi_table
*_mesa_GetGLXDispatchTable(void);
2605 struct _glxapi_table
*_mesa_GetGLXDispatchTable(void)
2607 static struct _glxapi_table glx
;
2609 /* be sure our dispatch table size <= libGL's table */
2611 GLuint size
= sizeof(struct _glxapi_table
) / sizeof(void *);
2613 assert(_glxapi_get_dispatch_table_size() >= size
);
2616 /* initialize the whole table to no-ops */
2617 _glxapi_set_no_op_table(&glx
);
2619 /* now initialize the table with the functions I implement */
2620 glx
.ChooseVisual
= Fake_glXChooseVisual
;
2621 glx
.CopyContext
= Fake_glXCopyContext
;
2622 glx
.CreateContext
= Fake_glXCreateContext
;
2623 glx
.CreateGLXPixmap
= Fake_glXCreateGLXPixmap
;
2624 glx
.DestroyContext
= Fake_glXDestroyContext
;
2625 glx
.DestroyGLXPixmap
= Fake_glXDestroyGLXPixmap
;
2626 glx
.GetConfig
= Fake_glXGetConfig
;
2627 /*glx.GetCurrentContext = Fake_glXGetCurrentContext;*/
2628 /*glx.GetCurrentDrawable = Fake_glXGetCurrentDrawable;*/
2629 glx
.IsDirect
= Fake_glXIsDirect
;
2630 glx
.MakeCurrent
= Fake_glXMakeCurrent
;
2631 glx
.QueryExtension
= Fake_glXQueryExtension
;
2632 glx
.QueryVersion
= Fake_glXQueryVersion
;
2633 glx
.SwapBuffers
= Fake_glXSwapBuffers
;
2634 glx
.UseXFont
= Fake_glXUseXFont
;
2635 glx
.WaitGL
= Fake_glXWaitGL
;
2636 glx
.WaitX
= Fake_glXWaitX
;
2638 /*** GLX_VERSION_1_1 ***/
2639 glx
.GetClientString
= Fake_glXGetClientString
;
2640 glx
.QueryExtensionsString
= Fake_glXQueryExtensionsString
;
2641 glx
.QueryServerString
= Fake_glXQueryServerString
;
2643 /*** GLX_VERSION_1_2 ***/
2644 /*glx.GetCurrentDisplay = Fake_glXGetCurrentDisplay;*/
2646 /*** GLX_VERSION_1_3 ***/
2647 glx
.ChooseFBConfig
= Fake_glXChooseFBConfig
;
2648 glx
.CreateNewContext
= Fake_glXCreateNewContext
;
2649 glx
.CreatePbuffer
= Fake_glXCreatePbuffer
;
2650 glx
.CreatePixmap
= Fake_glXCreatePixmap
;
2651 glx
.CreateWindow
= Fake_glXCreateWindow
;
2652 glx
.DestroyPbuffer
= Fake_glXDestroyPbuffer
;
2653 glx
.DestroyPixmap
= Fake_glXDestroyPixmap
;
2654 glx
.DestroyWindow
= Fake_glXDestroyWindow
;
2655 /*glx.GetCurrentReadDrawable = Fake_glXGetCurrentReadDrawable;*/
2656 glx
.GetFBConfigAttrib
= Fake_glXGetFBConfigAttrib
;
2657 glx
.GetFBConfigs
= Fake_glXGetFBConfigs
;
2658 glx
.GetSelectedEvent
= Fake_glXGetSelectedEvent
;
2659 glx
.GetVisualFromFBConfig
= Fake_glXGetVisualFromFBConfig
;
2660 glx
.MakeContextCurrent
= Fake_glXMakeContextCurrent
;
2661 glx
.QueryContext
= Fake_glXQueryContext
;
2662 glx
.QueryDrawable
= Fake_glXQueryDrawable
;
2663 glx
.SelectEvent
= Fake_glXSelectEvent
;
2665 /*** GLX_SGI_swap_control ***/
2666 glx
.SwapIntervalSGI
= Fake_glXSwapIntervalSGI
;
2668 /*** GLX_SGI_video_sync ***/
2669 glx
.GetVideoSyncSGI
= Fake_glXGetVideoSyncSGI
;
2670 glx
.WaitVideoSyncSGI
= Fake_glXWaitVideoSyncSGI
;
2672 /*** GLX_SGI_make_current_read ***/
2673 glx
.MakeCurrentReadSGI
= Fake_glXMakeCurrentReadSGI
;
2674 /*glx.GetCurrentReadDrawableSGI = Fake_glXGetCurrentReadDrawableSGI;*/
2676 /*** GLX_SGIX_video_source ***/
2678 glx
.CreateGLXVideoSourceSGIX
= Fake_glXCreateGLXVideoSourceSGIX
;
2679 glx
.DestroyGLXVideoSourceSGIX
= Fake_glXDestroyGLXVideoSourceSGIX
;
2682 /*** GLX_EXT_import_context ***/
2683 glx
.FreeContextEXT
= Fake_glXFreeContextEXT
;
2684 glx
.GetContextIDEXT
= Fake_glXGetContextIDEXT
;
2685 /*glx.GetCurrentDisplayEXT = Fake_glXGetCurrentDisplayEXT;*/
2686 glx
.ImportContextEXT
= Fake_glXImportContextEXT
;
2687 glx
.QueryContextInfoEXT
= Fake_glXQueryContextInfoEXT
;
2689 /*** GLX_SGIX_fbconfig ***/
2690 glx
.GetFBConfigAttribSGIX
= Fake_glXGetFBConfigAttribSGIX
;
2691 glx
.ChooseFBConfigSGIX
= Fake_glXChooseFBConfigSGIX
;
2692 glx
.CreateGLXPixmapWithConfigSGIX
= Fake_glXCreateGLXPixmapWithConfigSGIX
;
2693 glx
.CreateContextWithConfigSGIX
= Fake_glXCreateContextWithConfigSGIX
;
2694 glx
.GetVisualFromFBConfigSGIX
= Fake_glXGetVisualFromFBConfigSGIX
;
2695 glx
.GetFBConfigFromVisualSGIX
= Fake_glXGetFBConfigFromVisualSGIX
;
2697 /*** GLX_SGIX_pbuffer ***/
2698 glx
.CreateGLXPbufferSGIX
= Fake_glXCreateGLXPbufferSGIX
;
2699 glx
.DestroyGLXPbufferSGIX
= Fake_glXDestroyGLXPbufferSGIX
;
2700 glx
.QueryGLXPbufferSGIX
= Fake_glXQueryGLXPbufferSGIX
;
2701 glx
.SelectEventSGIX
= Fake_glXSelectEventSGIX
;
2702 glx
.GetSelectedEventSGIX
= Fake_glXGetSelectedEventSGIX
;
2704 /*** GLX_SGI_cushion ***/
2705 glx
.CushionSGI
= Fake_glXCushionSGI
;
2707 /*** GLX_SGIX_video_resize ***/
2708 glx
.BindChannelToWindowSGIX
= Fake_glXBindChannelToWindowSGIX
;
2709 glx
.ChannelRectSGIX
= Fake_glXChannelRectSGIX
;
2710 glx
.QueryChannelRectSGIX
= Fake_glXQueryChannelRectSGIX
;
2711 glx
.QueryChannelDeltasSGIX
= Fake_glXQueryChannelDeltasSGIX
;
2712 glx
.ChannelRectSyncSGIX
= Fake_glXChannelRectSyncSGIX
;
2714 /*** GLX_SGIX_dmbuffer **/
2715 #if defined(_DM_BUFFER_H_)
2716 glx
.AssociateDMPbufferSGIX
= NULL
;
2719 /*** GLX_SGIX_swap_group ***/
2720 glx
.JoinSwapGroupSGIX
= Fake_glXJoinSwapGroupSGIX
;
2722 /*** GLX_SGIX_swap_barrier ***/
2723 glx
.BindSwapBarrierSGIX
= Fake_glXBindSwapBarrierSGIX
;
2724 glx
.QueryMaxSwapBarriersSGIX
= Fake_glXQueryMaxSwapBarriersSGIX
;
2726 /*** GLX_SUN_get_transparent_index ***/
2727 glx
.GetTransparentIndexSUN
= Fake_glXGetTransparentIndexSUN
;
2729 /*** GLX_MESA_copy_sub_buffer ***/
2730 glx
.CopySubBufferMESA
= Fake_glXCopySubBufferMESA
;
2732 /*** GLX_MESA_release_buffers ***/
2733 glx
.ReleaseBuffersMESA
= Fake_glXReleaseBuffersMESA
;
2735 /*** GLX_MESA_pixmap_colormap ***/
2736 glx
.CreateGLXPixmapMESA
= Fake_glXCreateGLXPixmapMESA
;
2738 /*** GLX_MESA_set_3dfx_mode ***/
2739 glx
.Set3DfxModeMESA
= Fake_glXSet3DfxModeMESA
;
2741 /*** GLX AGP memory allocation ***/
2742 glx
.AllocateMemoryNV
= Fake_glXAllocateMemoryNV
;
2743 glx
.FreeMemoryNV
= Fake_glXFreeMemoryNV
;