1 /* $Id: fakeglx.c,v 1.82 2003/04/01 17:28:10 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 * This is an emulation of the GLX API which allows Mesa/GLX-based programs
30 * to run on X servers which do not have the real GLX extension.
32 * Thanks to the contributors:
34 * Initial version: Philip Brown (phil@bolthole.com)
35 * Better glXGetConfig() support: Armin Liebchen (liebchen@asylum.cs.utah.edu)
36 * Further visual-handling refinements: Wolfram Gloger
37 * (wmglo@Dent.MED.Uni-Muenchen.DE).
40 * Don't be fooled, stereo isn't supported yet.
45 #include "glxheader.h"
57 /* This indicates the client-side GLX API and GLX encoder version. */
58 #define CLIENT_MAJOR_VERSION 1
59 #define CLIENT_MINOR_VERSION 4 /* but don't have 1.3's pbuffers, etc yet */
61 /* This indicates the server-side GLX decoder version.
62 * GLX 1.4 indicates OpenGL 1.3 support
64 #define SERVER_MAJOR_VERSION 1
65 #define SERVER_MINOR_VERSION 4
67 /* This is appended onto the glXGetClient/ServerString version strings. */
68 #define MESA_GLX_VERSION "Mesa 5.1"
70 /* Who implemented this GLX? */
71 #define VENDOR "Brian Paul"
74 "GLX_MESA_set_3dfx_mode " \
75 "GLX_MESA_copy_sub_buffer " \
76 "GLX_MESA_pixmap_colormap " \
77 "GLX_MESA_release_buffers " \
78 "GLX_ARB_get_proc_address " \
79 "GLX_EXT_visual_info " \
80 "GLX_EXT_visual_rating " \
81 "GLX_SGI_video_sync " \
82 "GLX_SGIX_fbconfig " \
85 "GLX_ARB_render_texture"
88 /* Silence compiler warnings */
89 extern void Fake_glXDummyFunc( void );
90 void Fake_glXDummyFunc( void )
100 * Our fake GLX context will contain a "real" GLX context and an XMesa context.
102 * Note that a pointer to a __GLXcontext is a pointer to a fake_glx_context,
105 * We really just need this structure in order to make the libGL functions
106 * glXGetCurrentContext(), glXGetCurrentDrawable() and glXGetCurrentDisplay()
109 struct fake_glx_context
{
110 __GLXcontext glxContext
; /* this MUST be first! */
111 XMesaContext xmesaContext
;
116 /**********************************************************************/
117 /*** GLX Visual Code ***/
118 /**********************************************************************/
123 #define MAX_VISUALS 100
124 static XMesaVisual VisualTable
[MAX_VISUALS
];
125 static int NumVisuals
= 0;
129 * This struct and some code fragments borrowed
130 * from Mark Kilgard's GLUT library.
132 typedef struct _OverlayInfo
{
133 /* Avoid 64-bit portability problems by being careful to use
134 longs due to the way XGetWindowProperty is specified. Note
135 that these parameters are passed as CARD32s over X
137 unsigned long overlay_visual
;
138 long transparent_type
;
145 /* Macro to handle c_class vs class field name in XVisualInfo struct */
146 #if defined(__cplusplus) || defined(c_plusplus)
147 #define CLASS c_class
156 * Test if the given XVisualInfo is usable for Mesa rendering.
158 static GLboolean
is_usable_visual( XVisualInfo
*vinfo
)
160 switch (vinfo
->CLASS
) {
163 /* Any StaticGray/GrayScale visual works in RGB or CI mode */
167 /* Any StaticColor/PseudoColor visual of at least 4 bits */
168 if (vinfo
->depth
>=4) {
176 /* Any depth of TrueColor or DirectColor works in RGB mode */
179 /* This should never happen */
187 * Return the level (overlay, normal, underlay) of a given XVisualInfo.
188 * Input: dpy - the X display
189 * vinfo - the XVisualInfo to test
190 * Return: level of the visual:
192 * >0 = overlay planes
193 * <0 = underlay planes
195 static int level_of_visual( Display
*dpy
, XVisualInfo
*vinfo
)
197 Atom overlayVisualsAtom
;
198 OverlayInfo
*overlay_info
= NULL
;
199 int numOverlaysPerScreen
;
203 unsigned long sizeData
, bytesLeft
;
207 * The SERVER_OVERLAY_VISUALS property on the root window contains
208 * a list of overlay visuals. Get that list now.
210 overlayVisualsAtom
= XInternAtom(dpy
,"SERVER_OVERLAY_VISUALS", True
);
211 if (overlayVisualsAtom
== None
) {
215 status
= XGetWindowProperty(dpy
, RootWindow( dpy
, vinfo
->screen
),
216 overlayVisualsAtom
, 0L, (long) 10000, False
,
217 overlayVisualsAtom
, &actualType
, &actualFormat
,
218 &sizeData
, &bytesLeft
,
219 (unsigned char **) &overlay_info
);
221 if (status
!= Success
|| actualType
!= overlayVisualsAtom
||
222 actualFormat
!= 32 || sizeData
< 4) {
223 /* something went wrong */
224 XFree((void *) overlay_info
);
228 /* search the overlay visual list for the visual ID of interest */
229 numOverlaysPerScreen
= (int) (sizeData
/ 4);
230 for (i
=0;i
<numOverlaysPerScreen
;i
++) {
232 ov
= overlay_info
+ i
;
233 if (ov
->overlay_visual
==vinfo
->visualid
) {
234 /* found the visual */
235 if (/*ov->transparent_type==1 &&*/ ov
->layer
!=0) {
236 int level
= ov
->layer
;
237 XFree((void *) overlay_info
);
241 XFree((void *) overlay_info
);
247 /* The visual ID was not found in the overlay list. */
248 XFree((void *) overlay_info
);
256 * Given an XVisualInfo and RGB, Double, and Depth buffer flags, save the
257 * configuration in our list of GLX visuals.
260 save_glx_visual( Display
*dpy
, XVisualInfo
*vinfo
,
261 GLboolean rgbFlag
, GLboolean alphaFlag
, GLboolean dbFlag
,
262 GLboolean stereoFlag
,
263 GLint depth_size
, GLint stencil_size
,
264 GLint accumRedSize
, GLint accumGreenSize
,
265 GLint accumBlueSize
, GLint accumAlphaSize
,
268 GLboolean ximageFlag
= GL_TRUE
;
271 GLboolean comparePointers
;
274 /* Check if the MESA_BACK_BUFFER env var is set */
275 char *backbuffer
= _mesa_getenv("MESA_BACK_BUFFER");
277 if (backbuffer
[0]=='p' || backbuffer
[0]=='P') {
278 ximageFlag
= GL_FALSE
;
280 else if (backbuffer
[0]=='x' || backbuffer
[0]=='X') {
281 ximageFlag
= GL_TRUE
;
284 _mesa_warning(NULL
, "Mesa: invalid value for MESA_BACK_BUFFER environment variable, using an XImage.");
289 /* Comparing IDs uses less memory but sometimes fails. */
290 /* XXX revisit this after 3.0 is finished. */
291 if (_mesa_getenv("MESA_GLX_VISUAL_HACK"))
292 comparePointers
= GL_TRUE
;
294 comparePointers
= GL_FALSE
;
296 /* First check if a matching visual is already in the list */
297 for (i
=0; i
<NumVisuals
; i
++) {
298 XMesaVisual v
= VisualTable
[i
];
299 if (v
->display
== dpy
301 && v
->ximage_flag
== ximageFlag
302 && v
->mesa_visual
.rgbMode
== rgbFlag
303 && v
->mesa_visual
.doubleBufferMode
== dbFlag
304 && v
->mesa_visual
.stereoMode
== stereoFlag
305 && (v
->mesa_visual
.alphaBits
> 0) == alphaFlag
306 && (v
->mesa_visual
.depthBits
>= depth_size
|| depth_size
== 0)
307 && (v
->mesa_visual
.stencilBits
>= stencil_size
|| stencil_size
== 0)
308 && (v
->mesa_visual
.accumRedBits
>= accumRedSize
|| accumRedSize
== 0)
309 && (v
->mesa_visual
.accumGreenBits
>= accumGreenSize
|| accumGreenSize
== 0)
310 && (v
->mesa_visual
.accumBlueBits
>= accumBlueSize
|| accumBlueSize
== 0)
311 && (v
->mesa_visual
.accumAlphaBits
>= accumAlphaSize
|| accumAlphaSize
== 0)) {
312 /* now either compare XVisualInfo pointers or visual IDs */
313 if ((!comparePointers
&& v
->visinfo
->visualid
== vinfo
->visualid
)
314 || (comparePointers
&& v
->vishandle
== vinfo
)) {
320 /* Create a new visual and add it to the list. */
322 if (NumVisuals
>= MAX_VISUALS
) {
323 _mesa_problem(NULL
, "GLX Error: maximum number of visuals exceeded");
327 xmvis
= XMesaCreateVisual( dpy
, vinfo
, rgbFlag
, alphaFlag
, dbFlag
,
328 stereoFlag
, ximageFlag
,
329 depth_size
, stencil_size
,
330 accumRedSize
, accumBlueSize
,
331 accumBlueSize
, accumAlphaSize
, 0, level
,
334 /* Save a copy of the pointer now so we can find this visual again
335 * if we need to search for it in find_glx_visual().
337 xmvis
->vishandle
= vinfo
;
338 /* add xmvis to the list */
339 VisualTable
[NumVisuals
] = xmvis
;
348 * Create a GLX visual from a regular XVisualInfo.
349 * This is called when Fake GLX is given an XVisualInfo which wasn't
350 * returned by glXChooseVisual. Since this is the first time we're
351 * considering this visual we'll take a guess at reasonable values
352 * for depth buffer size, stencil size, accum size, etc.
353 * This is the best we can do with a client-side emulation of GLX.
356 create_glx_visual( Display
*dpy
, XVisualInfo
*visinfo
)
360 vislevel
= level_of_visual( dpy
, visinfo
);
362 /* Configure this visual as a CI, single-buffered overlay */
363 return save_glx_visual( dpy
, visinfo
,
365 GL_FALSE
, /* alpha */
366 GL_FALSE
, /* double */
367 GL_FALSE
, /* stereo */
369 0, /* stencil bits */
370 0,0,0,0, /* accum bits */
374 else if (is_usable_visual( visinfo
)) {
375 if (_mesa_getenv("MESA_GLX_FORCE_CI")) {
376 /* Configure this visual as a COLOR INDEX visual. */
377 return save_glx_visual( dpy
, visinfo
,
379 GL_FALSE
, /* alpha */
380 GL_TRUE
, /* double */
381 GL_FALSE
, /* stereo */
382 DEFAULT_SOFTWARE_DEPTH_BITS
,
383 8 * sizeof(GLstencil
),
384 0 * sizeof(GLaccum
), /* r */
385 0 * sizeof(GLaccum
), /* g */
386 0 * sizeof(GLaccum
), /* b */
387 0 * sizeof(GLaccum
), /* a */
392 /* Configure this visual as RGB, double-buffered, depth-buffered. */
393 /* This is surely wrong for some people's needs but what else */
394 /* can be done? They should use glXChooseVisual(). */
395 return save_glx_visual( dpy
, visinfo
,
397 GL_FALSE
, /* alpha */
398 GL_TRUE
, /* double */
399 GL_FALSE
, /* stereo */
400 DEFAULT_SOFTWARE_DEPTH_BITS
,
401 8 * sizeof(GLstencil
),
402 8 * sizeof(GLaccum
), /* r */
403 8 * sizeof(GLaccum
), /* g */
404 8 * sizeof(GLaccum
), /* b */
405 8 * sizeof(GLaccum
), /* a */
411 _mesa_warning(NULL
, "Mesa: error in glXCreateContext: bad visual\n");
419 * Find the GLX visual associated with an XVisualInfo.
422 find_glx_visual( Display
*dpy
, XVisualInfo
*vinfo
)
426 /* try to match visual id */
427 for (i
=0;i
<NumVisuals
;i
++) {
428 if (VisualTable
[i
]->display
==dpy
429 && VisualTable
[i
]->visinfo
->visualid
== vinfo
->visualid
) {
430 return VisualTable
[i
];
434 /* if that fails, try to match pointers */
435 for (i
=0;i
<NumVisuals
;i
++) {
436 if (VisualTable
[i
]->display
==dpy
&& VisualTable
[i
]->vishandle
==vinfo
) {
437 return VisualTable
[i
];
447 * Return the transparent pixel value for a GLX visual.
448 * Input: glxvis - the glx_visual
449 * Return: a pixel value or -1 if no transparent pixel
451 static int transparent_pixel( XMesaVisual glxvis
)
453 Display
*dpy
= glxvis
->display
;
454 XVisualInfo
*vinfo
= glxvis
->visinfo
;
455 Atom overlayVisualsAtom
;
456 OverlayInfo
*overlay_info
= NULL
;
457 int numOverlaysPerScreen
;
461 unsigned long sizeData
, bytesLeft
;
465 * The SERVER_OVERLAY_VISUALS property on the root window contains
466 * a list of overlay visuals. Get that list now.
468 overlayVisualsAtom
= XInternAtom(dpy
,"SERVER_OVERLAY_VISUALS", True
);
469 if (overlayVisualsAtom
== None
) {
473 status
= XGetWindowProperty(dpy
, RootWindow( dpy
, vinfo
->screen
),
474 overlayVisualsAtom
, 0L, (long) 10000, False
,
475 overlayVisualsAtom
, &actualType
, &actualFormat
,
476 &sizeData
, &bytesLeft
,
477 (unsigned char **) &overlay_info
);
479 if (status
!= Success
|| actualType
!= overlayVisualsAtom
||
480 actualFormat
!= 32 || sizeData
< 4) {
481 /* something went wrong */
482 XFree((void *) overlay_info
);
486 /* search the overlay visual list for the visual ID of interest */
487 numOverlaysPerScreen
= (int) (sizeData
/ 4);
488 for (i
=0;i
<numOverlaysPerScreen
;i
++) {
490 ov
= overlay_info
+ i
;
491 if (ov
->overlay_visual
==vinfo
->visualid
) {
493 if (ov
->transparent_type
==0) {
494 /* type 0 indicates no transparency */
495 XFree((void *) overlay_info
);
499 /* ov->value is the transparent pixel */
500 XFree((void *) overlay_info
);
506 /* The visual ID was not found in the overlay list. */
507 XFree((void *) overlay_info
);
514 * Try to get an X visual which matches the given arguments.
516 static XVisualInfo
*get_visual( Display
*dpy
, int scr
,
517 unsigned int depth
, int xclass
)
519 XVisualInfo temp
, *vis
;
522 unsigned int default_depth
;
525 mask
= VisualScreenMask
| VisualDepthMask
| VisualClassMask
;
530 default_depth
= DefaultDepth(dpy
,scr
);
531 default_class
= DefaultVisual(dpy
,scr
)->CLASS
;
533 if (depth
==default_depth
&& xclass
==default_class
) {
534 /* try to get root window's visual */
535 temp
.visualid
= DefaultVisual(dpy
,scr
)->visualid
;
536 mask
|= VisualIDMask
;
539 vis
= XGetVisualInfo( dpy
, mask
, &temp
, &n
);
541 /* In case bits/pixel > 24, make sure color channels are still <=8 bits.
542 * An SGI Infinite Reality system, for example, can have 30bpp pixels:
543 * 10 bits per color channel. Mesa's limited to a max of 8 bits/channel.
545 if (vis
&& depth
> 24 && (xclass
==TrueColor
|| xclass
==DirectColor
)) {
546 if (_mesa_bitcount((GLuint
) vis
->red_mask
) <= 8 &&
547 _mesa_bitcount((GLuint
) vis
->green_mask
) <= 8 &&
548 _mesa_bitcount((GLuint
) vis
->blue_mask
) <= 8) {
563 * Retrieve the value of the given environment variable and find
564 * the X visual which matches it.
565 * Input: dpy - the display
566 * screen - the screen number
567 * varname - the name of the environment variable
568 * Return: an XVisualInfo pointer to NULL if error.
570 static XVisualInfo
*get_env_visual(Display
*dpy
, int scr
, const char *varname
)
572 char value
[100], type
[100];
573 int depth
, xclass
= -1;
576 if (!_mesa_getenv( varname
)) {
580 _mesa_strncpy( value
, _mesa_getenv(varname
), 100 );
583 sscanf( value
, "%s %d", type
, &depth
);
585 if (_mesa_strcmp(type
,"TrueColor")==0) xclass
= TrueColor
;
586 else if (_mesa_strcmp(type
,"DirectColor")==0) xclass
= DirectColor
;
587 else if (_mesa_strcmp(type
,"PseudoColor")==0) xclass
= PseudoColor
;
588 else if (_mesa_strcmp(type
,"StaticColor")==0) xclass
= StaticColor
;
589 else if (_mesa_strcmp(type
,"GrayScale")==0) xclass
= GrayScale
;
590 else if (_mesa_strcmp(type
,"StaticGray")==0) xclass
= StaticGray
;
592 if (xclass
>-1 && depth
>0) {
593 vis
= get_visual( dpy
, scr
, depth
, xclass
);
599 _mesa_warning(NULL
, "GLX unable to find visual class=%s, depth=%d.",
608 * Select an X visual which satisfies the RGBA/CI flag and minimum depth.
609 * Input: dpy, screen - X display and screen number
610 * rgba - GL_TRUE = RGBA mode, GL_FALSE = CI mode
611 * min_depth - minimum visual depth
612 * preferred_class - preferred GLX visual class or DONT_CARE
613 * Return: pointer to an XVisualInfo or NULL.
615 static XVisualInfo
*choose_x_visual( Display
*dpy
, int screen
,
616 GLboolean rgba
, int min_depth
,
617 int preferred_class
)
620 int xclass
, visclass
= 0;
624 Atom hp_cr_maps
= XInternAtom(dpy
, "_HP_RGB_SMOOTH_MAP_LIST", True
);
625 /* First see if the MESA_RGB_VISUAL env var is defined */
626 vis
= get_env_visual( dpy
, screen
, "MESA_RGB_VISUAL" );
630 /* Otherwise, search for a suitable visual */
631 if (preferred_class
==DONT_CARE
) {
632 for (xclass
=0;xclass
<6;xclass
++) {
634 case 0: visclass
= TrueColor
; break;
635 case 1: visclass
= DirectColor
; break;
636 case 2: visclass
= PseudoColor
; break;
637 case 3: visclass
= StaticColor
; break;
638 case 4: visclass
= GrayScale
; break;
639 case 5: visclass
= StaticGray
; break;
642 /* start with shallowest */
643 for (depth
=0;depth
<=32;depth
++) {
644 if (visclass
==TrueColor
&& depth
==8 && !hp_cr_maps
) {
645 /* Special case: try to get 8-bit PseudoColor before */
646 /* 8-bit TrueColor */
647 vis
= get_visual( dpy
, screen
, 8, PseudoColor
);
652 vis
= get_visual( dpy
, screen
, depth
, visclass
);
659 /* start with deepest */
660 for (depth
=32;depth
>=min_depth
;depth
--) {
661 if (visclass
==TrueColor
&& depth
==8 && !hp_cr_maps
) {
662 /* Special case: try to get 8-bit PseudoColor before */
663 /* 8-bit TrueColor */
664 vis
= get_visual( dpy
, screen
, 8, PseudoColor
);
669 vis
= get_visual( dpy
, screen
, depth
, visclass
);
678 /* search for a specific visual class */
679 switch (preferred_class
) {
680 case GLX_TRUE_COLOR_EXT
: visclass
= TrueColor
; break;
681 case GLX_DIRECT_COLOR_EXT
: visclass
= DirectColor
; break;
682 case GLX_PSEUDO_COLOR_EXT
: visclass
= PseudoColor
; break;
683 case GLX_STATIC_COLOR_EXT
: visclass
= StaticColor
; break;
684 case GLX_GRAY_SCALE_EXT
: visclass
= GrayScale
; break;
685 case GLX_STATIC_GRAY_EXT
: visclass
= StaticGray
; break;
686 default: return NULL
;
689 /* start with shallowest */
690 for (depth
=0;depth
<=32;depth
++) {
691 vis
= get_visual( dpy
, screen
, depth
, visclass
);
698 /* start with deepest */
699 for (depth
=32;depth
>=min_depth
;depth
--) {
700 vis
= get_visual( dpy
, screen
, depth
, visclass
);
709 /* First see if the MESA_CI_VISUAL env var is defined */
710 vis
= get_env_visual( dpy
, screen
, "MESA_CI_VISUAL" );
714 /* Otherwise, search for a suitable visual, starting with shallowest */
715 if (preferred_class
==DONT_CARE
) {
716 for (xclass
=0;xclass
<4;xclass
++) {
718 case 0: visclass
= PseudoColor
; break;
719 case 1: visclass
= StaticColor
; break;
720 case 2: visclass
= GrayScale
; break;
721 case 3: visclass
= StaticGray
; break;
723 /* try 8-bit up through 16-bit */
724 for (depth
=8;depth
<=16;depth
++) {
725 vis
= get_visual( dpy
, screen
, depth
, visclass
);
730 /* try min_depth up to 8-bit */
731 for (depth
=min_depth
;depth
<8;depth
++) {
732 vis
= get_visual( dpy
, screen
, depth
, visclass
);
740 /* search for a specific visual class */
741 switch (preferred_class
) {
742 case GLX_TRUE_COLOR_EXT
: visclass
= TrueColor
; break;
743 case GLX_DIRECT_COLOR_EXT
: visclass
= DirectColor
; break;
744 case GLX_PSEUDO_COLOR_EXT
: visclass
= PseudoColor
; break;
745 case GLX_STATIC_COLOR_EXT
: visclass
= StaticColor
; break;
746 case GLX_GRAY_SCALE_EXT
: visclass
= GrayScale
; break;
747 case GLX_STATIC_GRAY_EXT
: visclass
= StaticGray
; break;
748 default: return NULL
;
750 /* try 8-bit up through 16-bit */
751 for (depth
=8;depth
<=16;depth
++) {
752 vis
= get_visual( dpy
, screen
, depth
, visclass
);
757 /* try min_depth up to 8-bit */
758 for (depth
=min_depth
;depth
<8;depth
++) {
759 vis
= get_visual( dpy
, screen
, depth
, visclass
);
767 /* didn't find a visual */
774 * Find the deepest X over/underlay visual of at least min_depth.
775 * Input: dpy, screen - X display and screen number
776 * level - the over/underlay level
777 * trans_type - transparent pixel type: GLX_NONE_EXT,
778 * GLX_TRANSPARENT_RGB_EXT, GLX_TRANSPARENT_INDEX_EXT,
780 * trans_value - transparent pixel value or DONT_CARE
781 * min_depth - minimum visual depth
782 * preferred_class - preferred GLX visual class or DONT_CARE
783 * Return: pointer to an XVisualInfo or NULL.
785 static XVisualInfo
*choose_x_overlay_visual( Display
*dpy
, int scr
,
787 int level
, int trans_type
,
790 int preferred_class
)
792 Atom overlayVisualsAtom
;
793 OverlayInfo
*overlay_info
;
794 int numOverlaysPerScreen
;
798 unsigned long sizeData
, bytesLeft
;
800 XVisualInfo
*deepvis
;
803 /*DEBUG int tt, tv; */
805 switch (preferred_class
) {
806 case GLX_TRUE_COLOR_EXT
: preferred_class
= TrueColor
; break;
807 case GLX_DIRECT_COLOR_EXT
: preferred_class
= DirectColor
; break;
808 case GLX_PSEUDO_COLOR_EXT
: preferred_class
= PseudoColor
; break;
809 case GLX_STATIC_COLOR_EXT
: preferred_class
= StaticColor
; break;
810 case GLX_GRAY_SCALE_EXT
: preferred_class
= GrayScale
; break;
811 case GLX_STATIC_GRAY_EXT
: preferred_class
= StaticGray
; break;
812 default: preferred_class
= DONT_CARE
;
816 * The SERVER_OVERLAY_VISUALS property on the root window contains
817 * a list of overlay visuals. Get that list now.
819 overlayVisualsAtom
= XInternAtom(dpy
,"SERVER_OVERLAY_VISUALS", True
);
820 if (overlayVisualsAtom
== (Atom
) None
) {
824 status
= XGetWindowProperty(dpy
, RootWindow( dpy
, scr
),
825 overlayVisualsAtom
, 0L, (long) 10000, False
,
826 overlayVisualsAtom
, &actualType
, &actualFormat
,
827 &sizeData
, &bytesLeft
,
828 (unsigned char **) &overlay_info
);
830 if (status
!= Success
|| actualType
!= overlayVisualsAtom
||
831 actualFormat
!= 32 || sizeData
< 4) {
832 /* something went wrong */
836 /* Search for the deepest overlay which satisifies all criteria. */
840 numOverlaysPerScreen
= (int) (sizeData
/ 4);
841 for (i
=0;i
<numOverlaysPerScreen
;i
++) {
842 XVisualInfo
*vislist
, vistemplate
;
845 ov
= overlay_info
+ i
;
847 if (ov
->layer
!=level
) {
848 /* failed overlay level criteria */
851 if (!(trans_type
==DONT_CARE
852 || (trans_type
==GLX_TRANSPARENT_INDEX_EXT
853 && ov
->transparent_type
>0)
854 || (trans_type
==GLX_NONE_EXT
&& ov
->transparent_type
==0))) {
855 /* failed transparent pixel type criteria */
858 if (trans_value
!=DONT_CARE
&& trans_value
!=ov
->value
) {
859 /* failed transparent pixel value criteria */
863 /* get XVisualInfo and check the depth */
864 vistemplate
.visualid
= ov
->overlay_visual
;
865 vistemplate
.screen
= scr
;
866 vislist
= XGetVisualInfo( dpy
, VisualIDMask
| VisualScreenMask
,
867 &vistemplate
, &count
);
870 /* something went wrong */
873 if (preferred_class
!=DONT_CARE
&& preferred_class
!=vislist
->CLASS
) {
874 /* wrong visual class */
878 /* if RGB was requested, make sure we have True/DirectColor */
879 if (rgbFlag
&& vislist
->CLASS
!= TrueColor
880 && vislist
->CLASS
!= DirectColor
)
883 /* if CI was requested, make sure we have a color indexed visual */
885 && (vislist
->CLASS
== TrueColor
|| vislist
->CLASS
== DirectColor
))
888 if (deepvis
==NULL
|| vislist
->depth
> deepest
) {
889 /* YES! found a satisfactory visual */
893 deepest
= vislist
->depth
;
895 /* DEBUG tt = ov->transparent_type;*/
896 /* DEBUG tv = ov->value; */
902 printf("chose 0x%x: layer=%d depth=%d trans_type=%d trans_value=%d\n",
903 deepvis->visualid, level, deepvis->depth, tt, tv );
910 /**********************************************************************/
911 /*** Begin Fake GLX API Functions ***/
912 /**********************************************************************/
915 static XMesaVisual
choose_visual( Display
*dpy
, int screen
, const int *list
)
917 const int *parselist
;
920 int min_red
=0, min_green
=0, min_blue
=0;
921 GLboolean rgb_flag
= GL_FALSE
;
922 GLboolean alpha_flag
= GL_FALSE
;
923 GLboolean double_flag
= GL_FALSE
;
924 GLboolean stereo_flag
= GL_FALSE
;
925 GLint depth_size
= 0;
926 GLint stencil_size
= 0;
927 GLint accumRedSize
= 0;
928 GLint accumGreenSize
= 0;
929 GLint accumBlueSize
= 0;
930 GLint accumAlphaSize
= 0;
932 int visual_type
= DONT_CARE
;
933 int trans_type
= DONT_CARE
;
934 int trans_value
= DONT_CARE
;
935 GLint caveat
= DONT_CARE
;
936 XMesaVisual xmvis
= NULL
;
942 switch (*parselist
) {
947 case GLX_BUFFER_SIZE
:
949 min_ci
= *parselist
++;
953 level
= *parselist
++;
959 case GLX_DOUBLEBUFFER
:
960 double_flag
= GL_TRUE
;
964 stereo_flag
= GL_TRUE
;
966 case GLX_AUX_BUFFERS
:
973 min_red
= *parselist
++;
977 min_green
= *parselist
++;
981 min_blue
= *parselist
++;
986 GLint size
= *parselist
++;
987 alpha_flag
= size
>0 ? 1 : 0;
992 depth_size
= *parselist
++;
994 case GLX_STENCIL_SIZE
:
996 stencil_size
= *parselist
++;
998 case GLX_ACCUM_RED_SIZE
:
1001 GLint size
= *parselist
++;
1002 accumRedSize
= MAX2( accumRedSize
, size
);
1005 case GLX_ACCUM_GREEN_SIZE
:
1008 GLint size
= *parselist
++;
1009 accumGreenSize
= MAX2( accumGreenSize
, size
);
1012 case GLX_ACCUM_BLUE_SIZE
:
1015 GLint size
= *parselist
++;
1016 accumBlueSize
= MAX2( accumBlueSize
, size
);
1019 case GLX_ACCUM_ALPHA_SIZE
:
1022 GLint size
= *parselist
++;
1023 accumAlphaSize
= MAX2( accumAlphaSize
, size
);
1028 * GLX_EXT_visual_info extension
1030 case GLX_X_VISUAL_TYPE_EXT
:
1032 visual_type
= *parselist
++;
1034 case GLX_TRANSPARENT_TYPE_EXT
:
1036 trans_type
= *parselist
++;
1038 case GLX_TRANSPARENT_INDEX_VALUE_EXT
:
1040 trans_value
= *parselist
++;
1042 case GLX_TRANSPARENT_RED_VALUE_EXT
:
1043 case GLX_TRANSPARENT_GREEN_VALUE_EXT
:
1044 case GLX_TRANSPARENT_BLUE_VALUE_EXT
:
1045 case GLX_TRANSPARENT_ALPHA_VALUE_EXT
:
1052 * GLX_EXT_visual_info extension
1054 case GLX_VISUAL_CAVEAT_EXT
:
1056 caveat
= *parselist
++; /* ignored for now */
1060 * GLX_ARB_multisample
1062 case GLX_SAMPLE_BUFFERS_ARB
:
1063 /* ms not supported */
1065 case GLX_SAMPLES_ARB
:
1066 /* ms not supported */
1072 case GLX_RENDER_TYPE
:
1074 if (*parselist
== GLX_RGBA_BIT
) {
1077 else if (*parselist
== GLX_COLOR_INDEX_BIT
) {
1078 rgb_flag
= GL_FALSE
;
1080 else if (*parselist
== 0) {
1085 case GLX_DRAWABLE_TYPE
:
1087 if (*parselist
& ~(GLX_WINDOW_BIT
| GLX_PIXMAP_BIT
| GLX_PBUFFER_BIT
)) {
1088 return NULL
; /* bad bit */
1097 /* undefined attribute */
1098 _mesa_warning(NULL
, "unexpected attrib 0x%x in choose_visual()",
1105 * Since we're only simulating the GLX extension this function will never
1106 * find any real GL visuals. Instead, all we can do is try to find an RGB
1107 * or CI visual of appropriate depth. Other requested attributes such as
1108 * double buffering, depth buffer, etc. will be associated with the X
1109 * visual and stored in the VisualTable[].
1112 /* normal color planes */
1114 /* Get an RGB visual */
1115 int min_rgb
= min_red
+ min_green
+ min_blue
;
1116 if (min_rgb
>1 && min_rgb
<8) {
1117 /* a special case to be sure we can get a monochrome visual */
1120 vis
= choose_x_visual( dpy
, screen
, rgb_flag
, min_rgb
, visual_type
);
1123 /* Get a color index visual */
1124 vis
= choose_x_visual( dpy
, screen
, rgb_flag
, min_ci
, visual_type
);
1125 accumRedSize
= accumGreenSize
= accumBlueSize
= accumAlphaSize
= 0;
1129 /* over/underlay planes */
1132 int min_rgb
= min_red
+ min_green
+ min_blue
;
1133 if (min_rgb
>1 && min_rgb
<8) {
1134 /* a special case to be sure we can get a monochrome visual */
1137 vis
= choose_x_overlay_visual( dpy
, screen
, rgb_flag
, level
,
1138 trans_type
, trans_value
, min_rgb
, visual_type
);
1141 /* color index overlay */
1142 vis
= choose_x_overlay_visual( dpy
, screen
, rgb_flag
, level
,
1143 trans_type
, trans_value
, min_ci
, visual_type
);
1148 /* Note: we're not exactly obeying the glXChooseVisual rules here.
1149 * When GLX_DEPTH_SIZE = 1 is specified we're supposed to choose the
1150 * largest depth buffer size, which is 32bits/value. Instead, we
1151 * return 16 to maintain performance with earlier versions of Mesa.
1153 if (depth_size
> 24)
1154 depth_size
= 31; /* 32 causes int overflow problems */
1155 else if (depth_size
> 16)
1157 else if (depth_size
> 0)
1158 depth_size
= DEFAULT_SOFTWARE_DEPTH_BITS
; /*16*/
1160 /* we only support one size of stencil and accum buffers. */
1161 if (stencil_size
> 0)
1162 stencil_size
= STENCIL_BITS
;
1163 if (accumRedSize
> 0 || accumGreenSize
> 0 || accumBlueSize
> 0 ||
1164 accumAlphaSize
> 0) {
1165 accumRedSize
= ACCUM_BITS
;
1166 accumGreenSize
= ACCUM_BITS
;
1167 accumBlueSize
= ACCUM_BITS
;
1168 accumAlphaSize
= alpha_flag
? ACCUM_BITS
: 0;
1171 xmvis
= save_glx_visual( dpy
, vis
, rgb_flag
, alpha_flag
, double_flag
,
1172 stereo_flag
, depth_size
, stencil_size
,
1173 accumRedSize
, accumGreenSize
,
1174 accumBlueSize
, accumAlphaSize
, level
);
1181 static XVisualInfo
*
1182 Fake_glXChooseVisual( Display
*dpy
, int screen
, int *list
)
1184 XMesaVisual xmvis
= choose_visual(dpy
, screen
, list
);
1187 return xmvis
->vishandle
;
1189 /* create a new vishandle - the cached one may be stale */
1190 xmvis
->vishandle
= (XVisualInfo
*) _mesa_malloc(sizeof(XVisualInfo
));
1191 if (xmvis
->vishandle
) {
1192 _mesa_memcpy(xmvis
->vishandle
, xmvis
->visinfo
, sizeof(XVisualInfo
));
1194 return xmvis
->vishandle
;
1203 Fake_glXCreateContext( Display
*dpy
, XVisualInfo
*visinfo
,
1204 GLXContext share_list
, Bool direct
)
1207 struct fake_glx_context
*glxCtx
;
1208 struct fake_glx_context
*shareCtx
= (struct fake_glx_context
*) share_list
;
1210 if (!dpy
|| !visinfo
)
1213 glxCtx
= CALLOC_STRUCT(fake_glx_context
);
1217 /* deallocate unused windows/buffers */
1218 XMesaGarbageCollect();
1220 xmvis
= find_glx_visual( dpy
, visinfo
);
1222 /* This visual wasn't found with glXChooseVisual() */
1223 xmvis
= create_glx_visual( dpy
, visinfo
);
1225 /* unusable visual */
1231 glxCtx
->xmesaContext
= XMesaCreateContext(xmvis
,
1232 shareCtx
? shareCtx
->xmesaContext
: NULL
);
1233 if (!glxCtx
->xmesaContext
) {
1238 glxCtx
->xmesaContext
->direct
= GL_FALSE
;
1239 glxCtx
->glxContext
.isDirect
= GL_FALSE
;
1240 glxCtx
->glxContext
.currentDpy
= dpy
;
1241 glxCtx
->glxContext
.xid
= (XID
) glxCtx
; /* self pointer */
1243 assert((void *) glxCtx
== (void *) &(glxCtx
->glxContext
));
1245 return (GLXContext
) glxCtx
;
1249 /* XXX these may have to be removed due to thread-safety issues. */
1250 static GLXContext MakeCurrent_PrevContext
= 0;
1251 static GLXDrawable MakeCurrent_PrevDrawable
= 0;
1252 static GLXDrawable MakeCurrent_PrevReadable
= 0;
1253 static XMesaBuffer MakeCurrent_PrevDrawBuffer
= 0;
1254 static XMesaBuffer MakeCurrent_PrevReadBuffer
= 0;
1257 /* GLX 1.3 and later */
1259 Fake_glXMakeContextCurrent( Display
*dpy
, GLXDrawable draw
,
1260 GLXDrawable read
, GLXContext ctx
)
1262 struct fake_glx_context
*glxCtx
= (struct fake_glx_context
*) ctx
;
1264 if (ctx
&& draw
&& read
) {
1265 XMesaBuffer drawBuffer
, readBuffer
;
1266 XMesaContext xmctx
= glxCtx
->xmesaContext
;
1268 /* Find the XMesaBuffer which corresponds to the GLXDrawable 'draw' */
1269 if (ctx
== MakeCurrent_PrevContext
1270 && draw
== MakeCurrent_PrevDrawable
) {
1271 drawBuffer
= MakeCurrent_PrevDrawBuffer
;
1274 drawBuffer
= XMesaFindBuffer( dpy
, draw
);
1277 /* drawable must be a new window! */
1278 drawBuffer
= XMesaCreateWindowBuffer2( xmctx
->xm_visual
, draw
, xmctx
);
1280 /* Out of memory, or context/drawable depth mismatch */
1285 /* Find the XMesaBuffer which corresponds to the GLXDrawable 'read' */
1286 if (ctx
== MakeCurrent_PrevContext
1287 && read
== MakeCurrent_PrevReadable
) {
1288 readBuffer
= MakeCurrent_PrevReadBuffer
;
1291 readBuffer
= XMesaFindBuffer( dpy
, read
);
1294 /* drawable must be a new window! */
1295 readBuffer
= XMesaCreateWindowBuffer2(glxCtx
->xmesaContext
->xm_visual
,
1298 /* Out of memory, or context/drawable depth mismatch */
1303 MakeCurrent_PrevContext
= ctx
;
1304 MakeCurrent_PrevDrawable
= draw
;
1305 MakeCurrent_PrevReadable
= read
;
1306 MakeCurrent_PrevDrawBuffer
= drawBuffer
;
1307 MakeCurrent_PrevReadBuffer
= readBuffer
;
1309 /* Now make current! */
1310 if (XMesaMakeCurrent2(xmctx
, drawBuffer
, readBuffer
)) {
1311 ((__GLXcontext
*) ctx
)->currentDpy
= dpy
;
1312 ((__GLXcontext
*) ctx
)->currentDrawable
= draw
;
1313 #ifndef GLX_BUILT_IN_XMESA
1314 ((__GLXcontext
*) ctx
)->currentReadable
= read
;
1316 __glXSetCurrentContext(ctx
);
1324 else if (!ctx
&& !draw
&& !read
) {
1325 /* release current context w/out assigning new one. */
1326 XMesaMakeCurrent( NULL
, NULL
);
1327 MakeCurrent_PrevContext
= 0;
1328 MakeCurrent_PrevDrawable
= 0;
1329 MakeCurrent_PrevReadable
= 0;
1330 MakeCurrent_PrevDrawBuffer
= 0;
1331 MakeCurrent_PrevReadBuffer
= 0;
1332 #ifdef GLX_BUILT_IN_XMESA
1333 /* XXX bind dummy context with __glXSetCurrentContext(ctx); */
1338 /* The args must either all be non-zero or all zero.
1348 Fake_glXMakeCurrent( Display
*dpy
, GLXDrawable drawable
, GLXContext ctx
)
1350 return Fake_glXMakeContextCurrent( dpy
, drawable
, drawable
, ctx
);
1356 Fake_glXCreateGLXPixmap( Display
*dpy
, XVisualInfo
*visinfo
, Pixmap pixmap
)
1361 v
= find_glx_visual( dpy
, visinfo
);
1363 v
= create_glx_visual( dpy
, visinfo
);
1365 /* unusable visual */
1370 b
= XMesaCreatePixmapBuffer( v
, pixmap
, 0 );
1374 return b
->frontbuffer
;
1378 /*** GLX_MESA_pixmap_colormap ***/
1381 Fake_glXCreateGLXPixmapMESA( Display
*dpy
, XVisualInfo
*visinfo
,
1382 Pixmap pixmap
, Colormap cmap
)
1387 v
= find_glx_visual( dpy
, visinfo
);
1389 v
= create_glx_visual( dpy
, visinfo
);
1391 /* unusable visual */
1396 b
= XMesaCreatePixmapBuffer( v
, pixmap
, cmap
);
1400 return b
->frontbuffer
;
1405 Fake_glXDestroyGLXPixmap( Display
*dpy
, GLXPixmap pixmap
)
1407 XMesaBuffer b
= XMesaFindBuffer(dpy
, pixmap
);
1409 XMesaDestroyBuffer(b
);
1411 else if (_mesa_getenv("MESA_DEBUG")) {
1412 _mesa_warning(NULL
, "Mesa: glXDestroyGLXPixmap: invalid pixmap\n");
1419 Fake_glXCopyContext( Display
*dpy
, GLXContext src
, GLXContext dst
,
1420 unsigned long mask
)
1422 struct fake_glx_context
*fakeSrc
= (struct fake_glx_context
*) src
;
1423 struct fake_glx_context
*fakeDst
= (struct fake_glx_context
*) dst
;
1424 XMesaContext xm_src
= fakeSrc
->xmesaContext
;
1425 XMesaContext xm_dst
= fakeDst
->xmesaContext
;
1427 _mesa_copy_context( &(xm_src
->mesa
), &(xm_dst
->mesa
), (GLuint
) mask
);
1433 Fake_glXQueryExtension( Display
*dpy
, int *errorb
, int *event
)
1435 /* Mesa's GLX isn't really an X extension but we try to act like one. */
1443 extern void _kw_ungrab_all( Display
*dpy
);
1444 void _kw_ungrab_all( Display
*dpy
)
1446 XUngrabPointer( dpy
, CurrentTime
);
1447 XUngrabKeyboard( dpy
, CurrentTime
);
1452 Fake_glXDestroyContext( Display
*dpy
, GLXContext ctx
)
1454 struct fake_glx_context
*glxCtx
= (struct fake_glx_context
*) ctx
;
1456 MakeCurrent_PrevContext
= 0;
1457 MakeCurrent_PrevDrawable
= 0;
1458 MakeCurrent_PrevReadable
= 0;
1459 MakeCurrent_PrevDrawBuffer
= 0;
1460 MakeCurrent_PrevReadBuffer
= 0;
1461 XMesaDestroyContext( glxCtx
->xmesaContext
);
1462 XMesaGarbageCollect();
1468 Fake_glXIsDirect( Display
*dpy
, GLXContext ctx
)
1470 struct fake_glx_context
*glxCtx
= (struct fake_glx_context
*) ctx
;
1472 return glxCtx
->xmesaContext
->direct
;
1478 Fake_glXSwapBuffers( Display
*dpy
, GLXDrawable drawable
)
1480 XMesaBuffer buffer
= XMesaFindBuffer( dpy
, drawable
);
1483 XMesaSwapBuffers(buffer
);
1485 else if (_mesa_getenv("MESA_DEBUG")) {
1486 _mesa_warning(NULL
, "Mesa: glXSwapBuffers: invalid drawable\n");
1492 /*** GLX_MESA_copy_sub_buffer ***/
1495 Fake_glXCopySubBufferMESA( Display
*dpy
, GLXDrawable drawable
,
1496 int x
, int y
, int width
, int height
)
1498 XMesaBuffer buffer
= XMesaFindBuffer( dpy
, drawable
);
1500 XMesaCopySubBuffer(buffer
, x
, y
, width
, height
);
1502 else if (_mesa_getenv("MESA_DEBUG")) {
1503 _mesa_warning(NULL
, "Mesa: glXCopySubBufferMESA: invalid drawable\n");
1510 Fake_glXQueryVersion( Display
*dpy
, int *maj
, int *min
)
1513 /* Return GLX version, not Mesa version */
1514 assert(CLIENT_MAJOR_VERSION
== SERVER_MAJOR_VERSION
);
1515 *maj
= CLIENT_MAJOR_VERSION
;
1516 *min
= MIN2( CLIENT_MINOR_VERSION
, SERVER_MINOR_VERSION
);
1523 * Query the GLX attributes of the given XVisualInfo.
1526 get_config( XMesaVisual xmvis
, int attrib
, int *value
, GLboolean fbconfig
)
1531 *value
= (int) True
;
1533 case GLX_BUFFER_SIZE
:
1534 *value
= xmvis
->visinfo
->depth
;
1537 *value
= xmvis
->level
;
1540 if (xmvis
->mesa_visual
.rgbMode
) {
1547 case GLX_DOUBLEBUFFER
:
1548 *value
= (int) xmvis
->mesa_visual
.doubleBufferMode
;
1551 *value
= (int) xmvis
->mesa_visual
.stereoMode
;
1553 case GLX_AUX_BUFFERS
:
1554 *value
= (int) False
;
1557 *value
= xmvis
->mesa_visual
.redBits
;
1559 case GLX_GREEN_SIZE
:
1560 *value
= xmvis
->mesa_visual
.greenBits
;
1563 *value
= xmvis
->mesa_visual
.blueBits
;
1565 case GLX_ALPHA_SIZE
:
1566 *value
= xmvis
->mesa_visual
.alphaBits
;
1568 case GLX_DEPTH_SIZE
:
1569 *value
= xmvis
->mesa_visual
.depthBits
;
1571 case GLX_STENCIL_SIZE
:
1572 *value
= xmvis
->mesa_visual
.stencilBits
;
1574 case GLX_ACCUM_RED_SIZE
:
1575 *value
= xmvis
->mesa_visual
.accumRedBits
;
1577 case GLX_ACCUM_GREEN_SIZE
:
1578 *value
= xmvis
->mesa_visual
.accumGreenBits
;
1580 case GLX_ACCUM_BLUE_SIZE
:
1581 *value
= xmvis
->mesa_visual
.accumBlueBits
;
1583 case GLX_ACCUM_ALPHA_SIZE
:
1584 *value
= xmvis
->mesa_visual
.accumAlphaBits
;
1588 * GLX_EXT_visual_info extension
1590 case GLX_X_VISUAL_TYPE_EXT
:
1591 switch (xmvis
->visinfo
->CLASS
) {
1592 case StaticGray
: *value
= GLX_STATIC_GRAY_EXT
; return 0;
1593 case GrayScale
: *value
= GLX_GRAY_SCALE_EXT
; return 0;
1594 case StaticColor
: *value
= GLX_STATIC_GRAY_EXT
; return 0;
1595 case PseudoColor
: *value
= GLX_PSEUDO_COLOR_EXT
; return 0;
1596 case TrueColor
: *value
= GLX_TRUE_COLOR_EXT
; return 0;
1597 case DirectColor
: *value
= GLX_DIRECT_COLOR_EXT
; return 0;
1600 case GLX_TRANSPARENT_TYPE_EXT
:
1601 if (xmvis
->level
==0) {
1603 *value
= GLX_NONE_EXT
;
1605 else if (xmvis
->level
>0) {
1607 if (xmvis
->mesa_visual
.rgbMode
) {
1608 *value
= GLX_TRANSPARENT_RGB_EXT
;
1611 *value
= GLX_TRANSPARENT_INDEX_EXT
;
1614 else if (xmvis
->level
<0) {
1616 *value
= GLX_NONE_EXT
;
1619 case GLX_TRANSPARENT_INDEX_VALUE_EXT
:
1621 int pixel
= transparent_pixel( xmvis
);
1625 /* else undefined */
1628 case GLX_TRANSPARENT_RED_VALUE_EXT
:
1631 case GLX_TRANSPARENT_GREEN_VALUE_EXT
:
1634 case GLX_TRANSPARENT_BLUE_VALUE_EXT
:
1637 case GLX_TRANSPARENT_ALPHA_VALUE_EXT
:
1642 * GLX_EXT_visual_info extension
1644 case GLX_VISUAL_CAVEAT_EXT
:
1645 /* test for zero, just in case */
1646 if (xmvis
->VisualCaveat
> 0)
1647 *value
= xmvis
->VisualCaveat
;
1649 *value
= GLX_NONE_EXT
;
1653 * GLX_ARB_multisample
1655 case GLX_SAMPLE_BUFFERS_ARB
:
1658 case GLX_SAMPLES_ARB
:
1665 case GLX_SCREEN_EXT
:
1667 return GLX_BAD_ATTRIBUTE
;
1668 *value
= xmvis
->visinfo
->screen
;
1670 case GLX_DRAWABLE_TYPE
: /*SGIX too */
1672 return GLX_BAD_ATTRIBUTE
;
1673 *value
= GLX_WINDOW_BIT
| GLX_PIXMAP_BIT
| GLX_PBUFFER_BIT
;
1675 case GLX_RENDER_TYPE_SGIX
:
1677 return GLX_BAD_ATTRIBUTE
;
1678 if (xmvis
->mesa_visual
.rgbMode
)
1679 *value
= GLX_RGBA_BIT
;
1681 *value
= GLX_COLOR_INDEX_BIT
;
1683 case GLX_X_RENDERABLE_SGIX
:
1685 return GLX_BAD_ATTRIBUTE
;
1686 *value
= True
; /* XXX really? */
1688 case GLX_FBCONFIG_ID_SGIX
:
1690 return GLX_BAD_ATTRIBUTE
;
1691 *value
= xmvis
->visinfo
->visualid
;
1693 case GLX_MAX_PBUFFER_WIDTH
:
1695 return GLX_BAD_ATTRIBUTE
;
1696 /* XXX or MAX_WIDTH? */
1697 *value
= DisplayWidth(xmvis
->display
, xmvis
->visinfo
->screen
);
1699 case GLX_MAX_PBUFFER_HEIGHT
:
1701 return GLX_BAD_ATTRIBUTE
;
1702 *value
= DisplayHeight(xmvis
->display
, xmvis
->visinfo
->screen
);
1704 case GLX_MAX_PBUFFER_PIXELS
:
1706 return GLX_BAD_ATTRIBUTE
;
1707 *value
= DisplayWidth(xmvis
->display
, xmvis
->visinfo
->screen
) *
1708 DisplayHeight(xmvis
->display
, xmvis
->visinfo
->screen
);
1712 return GLX_BAD_ATTRIBUTE
;
1713 *value
= xmvis
->visinfo
->visualid
;
1717 return GLX_BAD_ATTRIBUTE
;
1724 Fake_glXGetConfig( Display
*dpy
, XVisualInfo
*visinfo
,
1725 int attrib
, int *value
)
1729 xmvis
= find_glx_visual( dpy
, visinfo
);
1731 /* this visual wasn't obtained with glXChooseVisual */
1732 xmvis
= create_glx_visual( dpy
, visinfo
);
1734 /* this visual can't be used for GL rendering */
1735 if (attrib
==GLX_USE_GL
) {
1736 *value
= (int) False
;
1740 return GLX_BAD_VISUAL
;
1745 return get_config(xmvis
, attrib
, value
, GL_FALSE
);
1750 Fake_glXWaitGL( void )
1752 XMesaContext xmesa
= XMesaGetCurrentContext();
1753 XMesaFlush( xmesa
);
1759 Fake_glXWaitX( void )
1761 XMesaContext xmesa
= XMesaGetCurrentContext();
1762 XMesaFlush( xmesa
);
1767 get_extensions( void )
1770 const char *fx
= _mesa_getenv("MESA_GLX_FX");
1771 if (fx
&& fx
[0] != 'd') {
1775 return EXTENSIONS
+ 23; /* skip "GLX_MESA_set_3dfx_mode" */
1780 /* GLX 1.1 and later */
1782 Fake_glXQueryExtensionsString( Display
*dpy
, int screen
)
1786 return get_extensions();
1791 /* GLX 1.1 and later */
1793 Fake_glXQueryServerString( Display
*dpy
, int screen
, int name
)
1795 static char version
[1000];
1796 _mesa_sprintf(version
, "%d.%d %s",
1797 SERVER_MAJOR_VERSION
, SERVER_MINOR_VERSION
, MESA_GLX_VERSION
);
1803 case GLX_EXTENSIONS
:
1804 return get_extensions();
1816 /* GLX 1.1 and later */
1818 Fake_glXGetClientString( Display
*dpy
, int name
)
1820 static char version
[1000];
1821 _mesa_sprintf(version
, "%d.%d %s", CLIENT_MAJOR_VERSION
,
1822 CLIENT_MINOR_VERSION
, MESA_GLX_VERSION
);
1827 case GLX_EXTENSIONS
:
1828 return get_extensions();
1845 static GLXFBConfig
*
1846 Fake_glXChooseFBConfig( Display
*dpy
, int screen
,
1847 const int *attribList
, int *nitems
)
1849 XMesaVisual xmvis
= choose_visual(dpy
, screen
, attribList
);
1851 GLXFBConfig
*config
= (GLXFBConfig
*) _mesa_malloc(sizeof(XMesaVisual
));
1857 config
[0] = (GLXFBConfig
) xmvis
;
1858 return (GLXFBConfig
*) config
;
1868 Fake_glXGetFBConfigAttrib( Display
*dpy
, GLXFBConfig config
,
1869 int attribute
, int *value
)
1871 XMesaVisual v
= (XMesaVisual
) config
;
1875 if (!dpy
|| !config
|| !value
)
1878 return get_config(v
, attribute
, value
, GL_TRUE
);
1882 static GLXFBConfig
*
1883 Fake_glXGetFBConfigs( Display
*dpy
, int screen
, int *nelements
)
1885 XVisualInfo
*visuals
, visTemplate
;
1886 const long visMask
= VisualScreenMask
;
1889 /* Get list of all X visuals */
1890 visTemplate
.screen
= screen
;
1891 visuals
= XGetVisualInfo(dpy
, visMask
, &visTemplate
, nelements
);
1892 if (*nelements
> 0) {
1893 XMesaVisual
*results
;
1894 results
= (XMesaVisual
*) _mesa_malloc(*nelements
* sizeof(XMesaVisual
));
1899 for (i
= 0; i
< *nelements
; i
++) {
1900 results
[i
] = create_glx_visual(dpy
, visuals
+ i
);
1902 return (GLXFBConfig
*) results
;
1908 static XVisualInfo
*
1909 Fake_glXGetVisualFromFBConfig( Display
*dpy
, GLXFBConfig config
)
1911 if (dpy
&& config
) {
1912 XMesaVisual xmvis
= (XMesaVisual
) config
;
1914 return xmvis
->vishandle
;
1916 /* create a new vishandle - the cached one may be stale */
1917 xmvis
->vishandle
= (XVisualInfo
*) _mesa_malloc(sizeof(XVisualInfo
));
1918 if (xmvis
->vishandle
) {
1919 _mesa_memcpy(xmvis
->vishandle
, xmvis
->visinfo
, sizeof(XVisualInfo
));
1921 return xmvis
->vishandle
;
1931 Fake_glXCreateWindow( Display
*dpy
, GLXFBConfig config
, Window win
,
1932 const int *attribList
)
1937 (void) attribList
; /* Ignored in GLX 1.3 */
1939 return win
; /* A hack for now */
1944 Fake_glXDestroyWindow( Display
*dpy
, GLXWindow window
)
1946 XMesaBuffer b
= XMesaFindBuffer(dpy
, (XMesaDrawable
) window
);
1948 XMesaDestroyBuffer(b
);
1949 /* don't destroy X window */
1955 Fake_glXCreatePixmap( Display
*dpy
, GLXFBConfig config
, Pixmap pixmap
,
1956 const int *attribList
)
1958 XMesaVisual v
= (XMesaVisual
) config
;
1964 (void) attribList
; /* Ignored in GLX 1.3 */
1966 if (!dpy
|| !config
|| !pixmap
)
1969 b
= XMesaCreatePixmapBuffer( v
, pixmap
, 0 );
1979 Fake_glXDestroyPixmap( Display
*dpy
, GLXPixmap pixmap
)
1981 XMesaBuffer b
= XMesaFindBuffer(dpy
, (XMesaDrawable
)pixmap
);
1983 XMesaDestroyBuffer(b
);
1984 /* don't destroy X pixmap */
1989 Fake_glXCreatePbuffer( Display
*dpy
, GLXFBConfig config
,
1990 const int *attribList
)
1992 XMesaVisual xmvis
= (XMesaVisual
) config
;
1995 int width
= 0, height
= 0;
1996 GLboolean useLargest
= GL_FALSE
, preserveContents
= GL_FALSE
;
2000 for (attrib
= attribList
; *attrib
; attrib
++) {
2002 case GLX_PBUFFER_WIDTH
:
2006 case GLX_PBUFFER_HEIGHT
:
2010 case GLX_PRESERVED_CONTENTS
:
2012 preserveContents
= *attrib
; /* ignored */
2014 case GLX_LARGEST_PBUFFER
:
2016 useLargest
= *attrib
; /* ignored */
2023 if (width
== 0 || height
== 0)
2026 xmbuf
= XMesaCreatePBuffer( xmvis
, 0, width
, height
);
2027 /* A GLXPbuffer handle must be an X Drawable because that's what
2028 * glXMakeCurrent takes.
2030 return (GLXPbuffer
) xmbuf
->frontbuffer
;
2035 Fake_glXDestroyPbuffer( Display
*dpy
, GLXPbuffer pbuf
)
2037 XMesaBuffer b
= XMesaFindBuffer(dpy
, pbuf
);
2039 XMesaDestroyBuffer(b
);
2045 Fake_glXQueryDrawable( Display
*dpy
, GLXDrawable draw
, int attribute
,
2046 unsigned int *value
)
2048 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, draw
);
2052 switch (attribute
) {
2054 *value
= xmbuf
->width
;
2057 *value
= xmbuf
->height
;
2059 case GLX_PRESERVED_CONTENTS
:
2062 case GLX_LARGEST_PBUFFER
:
2063 *value
= xmbuf
->width
* xmbuf
->height
;
2065 case GLX_FBCONFIG_ID
:
2066 *value
= xmbuf
->xm_visual
->visinfo
->visualid
;
2069 return; /* GLX_BAD_ATTRIBUTE? */
2075 Fake_glXCreateNewContext( Display
*dpy
, GLXFBConfig config
,
2076 int renderType
, GLXContext shareList
, Bool direct
)
2078 struct fake_glx_context
*glxCtx
;
2079 struct fake_glx_context
*shareCtx
= (struct fake_glx_context
*) shareList
;
2080 XMesaVisual xmvis
= (XMesaVisual
) config
;
2082 if (!dpy
|| !config
||
2083 (renderType
!= GLX_RGBA_TYPE
&& renderType
!= GLX_COLOR_INDEX_TYPE
))
2086 glxCtx
= CALLOC_STRUCT(fake_glx_context
);
2090 /* deallocate unused windows/buffers */
2091 XMesaGarbageCollect();
2093 glxCtx
->xmesaContext
= XMesaCreateContext(xmvis
,
2094 shareCtx
? shareCtx
->xmesaContext
: NULL
);
2095 if (!glxCtx
->xmesaContext
) {
2100 glxCtx
->xmesaContext
->direct
= GL_FALSE
;
2101 glxCtx
->glxContext
.isDirect
= GL_FALSE
;
2102 glxCtx
->glxContext
.currentDpy
= dpy
;
2103 glxCtx
->glxContext
.xid
= (XID
) glxCtx
; /* self pointer */
2105 assert((void *) glxCtx
== (void *) &(glxCtx
->glxContext
));
2107 return (GLXContext
) glxCtx
;
2112 Fake_glXQueryContext( Display
*dpy
, GLXContext ctx
, int attribute
, int *value
)
2114 struct fake_glx_context
*glxCtx
= (struct fake_glx_context
*) ctx
;
2115 XMesaContext xmctx
= glxCtx
->xmesaContext
;
2120 switch (attribute
) {
2121 case GLX_FBCONFIG_ID
:
2122 *value
= xmctx
->xm_visual
->visinfo
->visualid
;
2124 case GLX_RENDER_TYPE
:
2125 if (xmctx
->xm_visual
->mesa_visual
.rgbMode
)
2126 *value
= GLX_RGBA_BIT
;
2128 *value
= GLX_COLOR_INDEX_BIT
;
2134 return GLX_BAD_ATTRIBUTE
;
2141 Fake_glXSelectEvent( Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
2143 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, drawable
);
2145 xmbuf
->selectedEvents
= mask
;
2150 Fake_glXGetSelectedEvent( Display
*dpy
, GLXDrawable drawable
,
2151 unsigned long *mask
)
2153 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, drawable
);
2155 *mask
= xmbuf
->selectedEvents
;
2162 /*** GLX_SGI_swap_control ***/
2165 Fake_glXSwapIntervalSGI(int interval
)
2173 /*** GLX_SGI_video_sync ***/
2176 Fake_glXGetVideoSyncSGI(unsigned int *count
)
2183 Fake_glXWaitVideoSyncSGI(int divisor
, int remainder
, unsigned int *count
)
2193 /*** GLX_SGI_make_current_read ***/
2196 Fake_glXMakeCurrentReadSGI(Display
*dpy
, GLXDrawable draw
, GLXDrawable read
, GLXContext ctx
)
2198 return Fake_glXMakeContextCurrent( dpy
, draw
, read
, ctx
);
2203 Fake_glXGetCurrentReadDrawableSGI(void)
2210 /*** GLX_SGIX_video_source ***/
2213 static GLXVideoSourceSGIX
2214 Fake_glXCreateGLXVideoSourceSGIX(Display
*dpy
, int screen
, VLServer server
, VLPath path
, int nodeClass
, VLNode drainNode
)
2226 Fake_glXDestroyGLXVideoSourceSGIX(Display
*dpy
, GLXVideoSourceSGIX src
)
2235 /*** GLX_EXT_import_context ***/
2238 Fake_glXFreeContextEXT(Display
*dpy
, GLXContext context
)
2245 Fake_glXGetContextIDEXT(const GLXContext context
)
2252 Fake_glXImportContextEXT(Display
*dpy
, GLXContextID contextID
)
2260 Fake_glXQueryContextInfoEXT(Display
*dpy
, GLXContext context
, int attribute
, int *value
)
2271 /*** GLX_SGIX_fbconfig ***/
2274 Fake_glXGetFBConfigAttribSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int attribute
, int *value
)
2276 return Fake_glXGetFBConfigAttrib(dpy
, config
, attribute
, value
);
2279 static GLXFBConfigSGIX
*
2280 Fake_glXChooseFBConfigSGIX(Display
*dpy
, int screen
, int *attrib_list
, int *nelements
)
2282 return (GLXFBConfig
*) Fake_glXChooseFBConfig(dpy
, screen
, attrib_list
, nelements
);
2287 Fake_glXCreateGLXPixmapWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, Pixmap pixmap
)
2289 XMesaVisual xmvis
= (XMesaVisual
) config
;
2290 XMesaBuffer xmbuf
= XMesaCreatePixmapBuffer(xmvis
, pixmap
, 0);
2291 return xmbuf
->frontbuffer
; /* need to return an X ID */
2296 Fake_glXCreateContextWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int render_type
, GLXContext share_list
, Bool direct
)
2298 XMesaVisual xmvis
= (XMesaVisual
) config
;
2299 struct fake_glx_context
*glxCtx
;
2300 struct fake_glx_context
*shareCtx
= (struct fake_glx_context
*) share_list
;
2302 glxCtx
= CALLOC_STRUCT(fake_glx_context
);
2306 /* deallocate unused windows/buffers */
2307 XMesaGarbageCollect();
2309 glxCtx
->xmesaContext
= XMesaCreateContext(xmvis
,
2310 shareCtx
? shareCtx
->xmesaContext
: NULL
);
2311 if (!glxCtx
->xmesaContext
) {
2316 glxCtx
->xmesaContext
->direct
= GL_FALSE
;
2317 glxCtx
->glxContext
.isDirect
= GL_FALSE
;
2318 glxCtx
->glxContext
.currentDpy
= dpy
;
2319 glxCtx
->glxContext
.xid
= (XID
) glxCtx
; /* self pointer */
2321 assert((void *) glxCtx
== (void *) &(glxCtx
->glxContext
));
2323 return (GLXContext
) glxCtx
;
2327 static XVisualInfo
*
2328 Fake_glXGetVisualFromFBConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
)
2330 return Fake_glXGetVisualFromFBConfig(dpy
, config
);
2334 static GLXFBConfigSGIX
2335 Fake_glXGetFBConfigFromVisualSGIX(Display
*dpy
, XVisualInfo
*vis
)
2337 XMesaVisual xmvis
= find_glx_visual(dpy
, vis
);
2339 /* This visual wasn't found with glXChooseVisual() */
2340 xmvis
= create_glx_visual(dpy
, vis
);
2343 return (GLXFBConfigSGIX
) xmvis
;
2348 /*** GLX_SGIX_pbuffer ***/
2350 static GLXPbufferSGIX
2351 Fake_glXCreateGLXPbufferSGIX(Display
*dpy
, GLXFBConfigSGIX config
,
2352 unsigned int width
, unsigned int height
,
2355 XMesaVisual xmvis
= (XMesaVisual
) config
;
2358 GLboolean useLargest
= GL_FALSE
, preserveContents
= GL_FALSE
;
2362 for (attrib
= attribList
; *attrib
; attrib
++) {
2364 case GLX_PRESERVED_CONTENTS_SGIX
:
2366 preserveContents
= *attrib
; /* ignored */
2368 case GLX_LARGEST_PBUFFER_SGIX
:
2370 useLargest
= *attrib
; /* ignored */
2377 xmbuf
= XMesaCreatePBuffer( xmvis
, 0, width
, height
);
2378 /* A GLXPbuffer handle must be an X Drawable because that's what
2379 * glXMakeCurrent takes.
2381 return (GLXPbuffer
) xmbuf
->frontbuffer
;
2386 Fake_glXDestroyGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
)
2388 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, pbuf
);
2390 XMesaDestroyBuffer(xmbuf
);
2396 Fake_glXQueryGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
, int attribute
, unsigned int *value
)
2398 const XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, pbuf
);
2401 /* Generate GLXBadPbufferSGIX for bad pbuffer */
2405 switch (attribute
) {
2406 case GLX_PRESERVED_CONTENTS_SGIX
:
2409 case GLX_LARGEST_PBUFFER_SGIX
:
2410 *value
= xmbuf
->width
* xmbuf
->height
;
2412 case GLX_WIDTH_SGIX
:
2413 *value
= xmbuf
->width
;
2415 case GLX_HEIGHT_SGIX
:
2416 *value
= xmbuf
->height
;
2418 case GLX_EVENT_MASK_SGIX
:
2419 *value
= 0; /* XXX might be wrong */
2429 Fake_glXSelectEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
2431 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, drawable
);
2433 /* Note: we'll never generate clobber events */
2434 xmbuf
->selectedEvents
= mask
;
2440 Fake_glXGetSelectedEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long *mask
)
2442 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, drawable
);
2444 *mask
= xmbuf
->selectedEvents
;
2453 /*** GLX_SGI_cushion ***/
2456 Fake_glXCushionSGI(Display
*dpy
, Window win
, float cushion
)
2465 /*** GLX_SGIX_video_resize ***/
2468 Fake_glXBindChannelToWindowSGIX(Display
*dpy
, int screen
, int channel
, Window window
)
2478 Fake_glXChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int x
, int y
, int w
, int h
)
2491 Fake_glXQueryChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int *x
, int *y
, int *w
, int *h
)
2504 Fake_glXQueryChannelDeltasSGIX(Display
*dpy
, int screen
, int channel
, int *dx
, int *dy
, int *dw
, int *dh
)
2517 Fake_glXChannelRectSyncSGIX(Display
*dpy
, int screen
, int channel
, GLenum synctype
)
2528 /*** GLX_SGIX_dmbuffer **/
2530 #if defined(_DM_BUFFER_H_)
2532 Fake_glXAssociateDMPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuffer
, DMparams
*params
, DMbuffer dmbuffer
)
2543 /*** GLX_SGIX_swap_group ***/
2546 Fake_glXJoinSwapGroupSGIX(Display
*dpy
, GLXDrawable drawable
, GLXDrawable member
)
2555 /*** GLX_SGIX_swap_barrier ***/
2558 Fake_glXBindSwapBarrierSGIX(Display
*dpy
, GLXDrawable drawable
, int barrier
)
2566 Fake_glXQueryMaxSwapBarriersSGIX(Display
*dpy
, int screen
, int *max
)
2576 /*** GLX_SUN_get_transparent_index ***/
2579 Fake_glXGetTransparentIndexSUN(Display
*dpy
, Window overlay
, Window underlay
, long *pTransparent
)
2584 (void) pTransparent
;
2590 /*** GLX_MESA_release_buffers ***/
2593 * Release the depth, stencil, accum buffers attached to a GLXDrawable
2594 * (a window or pixmap) prior to destroying the GLXDrawable.
2597 Fake_glXReleaseBuffersMESA( Display
*dpy
, GLXDrawable d
)
2599 XMesaBuffer b
= XMesaFindBuffer(dpy
, d
);
2601 XMesaDestroyBuffer(b
);
2609 /*** GLX_MESA_set_3dfx_mode ***/
2612 Fake_glXSet3DfxModeMESA( int mode
)
2614 return XMesaSetFXmode( mode
);
2619 /*** GLX_NV_vertex_array range ***/
2621 Fake_glXAllocateMemoryNV( GLsizei size
,
2622 GLfloat readFrequency
,
2623 GLfloat writeFrequency
,
2627 (void) readFrequency
;
2628 (void) writeFrequency
;
2635 Fake_glXFreeMemoryNV( GLvoid
*pointer
)
2641 /*** GLX_MESA_agp_offset ***/
2644 Fake_glXGetAGPOffsetMESA( const GLvoid
*pointer
)
2651 /*** GLX_ARB_render_texture ***/
2654 Fake_glXBindTexImageARB( Display
*dpy
, GLXPbuffer pbuffer
, int buffer
)
2661 Fake_glXReleaseTexImageARB(Display
*dpy
, GLXPbuffer pbuffer
, int buffer
)
2668 Fake_glXDrawableAttribARB( Display
*dpy
, GLXDrawable draw
, const int *attribList
)
2675 extern struct _glxapi_table
*_mesa_GetGLXDispatchTable(void);
2676 struct _glxapi_table
*_mesa_GetGLXDispatchTable(void)
2678 static struct _glxapi_table glx
;
2680 /* be sure our dispatch table size <= libGL's table */
2682 GLuint size
= sizeof(struct _glxapi_table
) / sizeof(void *);
2684 assert(_glxapi_get_dispatch_table_size() >= size
);
2687 /* initialize the whole table to no-ops */
2688 _glxapi_set_no_op_table(&glx
);
2690 /* now initialize the table with the functions I implement */
2691 glx
.ChooseVisual
= Fake_glXChooseVisual
;
2692 glx
.CopyContext
= Fake_glXCopyContext
;
2693 glx
.CreateContext
= Fake_glXCreateContext
;
2694 glx
.CreateGLXPixmap
= Fake_glXCreateGLXPixmap
;
2695 glx
.DestroyContext
= Fake_glXDestroyContext
;
2696 glx
.DestroyGLXPixmap
= Fake_glXDestroyGLXPixmap
;
2697 glx
.GetConfig
= Fake_glXGetConfig
;
2698 /*glx.GetCurrentContext = Fake_glXGetCurrentContext;*/
2699 /*glx.GetCurrentDrawable = Fake_glXGetCurrentDrawable;*/
2700 glx
.IsDirect
= Fake_glXIsDirect
;
2701 glx
.MakeCurrent
= Fake_glXMakeCurrent
;
2702 glx
.QueryExtension
= Fake_glXQueryExtension
;
2703 glx
.QueryVersion
= Fake_glXQueryVersion
;
2704 glx
.SwapBuffers
= Fake_glXSwapBuffers
;
2705 glx
.UseXFont
= Fake_glXUseXFont
;
2706 glx
.WaitGL
= Fake_glXWaitGL
;
2707 glx
.WaitX
= Fake_glXWaitX
;
2709 /*** GLX_VERSION_1_1 ***/
2710 glx
.GetClientString
= Fake_glXGetClientString
;
2711 glx
.QueryExtensionsString
= Fake_glXQueryExtensionsString
;
2712 glx
.QueryServerString
= Fake_glXQueryServerString
;
2714 /*** GLX_VERSION_1_2 ***/
2715 /*glx.GetCurrentDisplay = Fake_glXGetCurrentDisplay;*/
2717 /*** GLX_VERSION_1_3 ***/
2718 glx
.ChooseFBConfig
= Fake_glXChooseFBConfig
;
2719 glx
.CreateNewContext
= Fake_glXCreateNewContext
;
2720 glx
.CreatePbuffer
= Fake_glXCreatePbuffer
;
2721 glx
.CreatePixmap
= Fake_glXCreatePixmap
;
2722 glx
.CreateWindow
= Fake_glXCreateWindow
;
2723 glx
.DestroyPbuffer
= Fake_glXDestroyPbuffer
;
2724 glx
.DestroyPixmap
= Fake_glXDestroyPixmap
;
2725 glx
.DestroyWindow
= Fake_glXDestroyWindow
;
2726 /*glx.GetCurrentReadDrawable = Fake_glXGetCurrentReadDrawable;*/
2727 glx
.GetFBConfigAttrib
= Fake_glXGetFBConfigAttrib
;
2728 glx
.GetFBConfigs
= Fake_glXGetFBConfigs
;
2729 glx
.GetSelectedEvent
= Fake_glXGetSelectedEvent
;
2730 glx
.GetVisualFromFBConfig
= Fake_glXGetVisualFromFBConfig
;
2731 glx
.MakeContextCurrent
= Fake_glXMakeContextCurrent
;
2732 glx
.QueryContext
= Fake_glXQueryContext
;
2733 glx
.QueryDrawable
= Fake_glXQueryDrawable
;
2734 glx
.SelectEvent
= Fake_glXSelectEvent
;
2736 /*** GLX_SGI_swap_control ***/
2737 glx
.SwapIntervalSGI
= Fake_glXSwapIntervalSGI
;
2739 /*** GLX_SGI_video_sync ***/
2740 glx
.GetVideoSyncSGI
= Fake_glXGetVideoSyncSGI
;
2741 glx
.WaitVideoSyncSGI
= Fake_glXWaitVideoSyncSGI
;
2743 /*** GLX_SGI_make_current_read ***/
2744 glx
.MakeCurrentReadSGI
= Fake_glXMakeCurrentReadSGI
;
2745 /*glx.GetCurrentReadDrawableSGI = Fake_glXGetCurrentReadDrawableSGI;*/
2747 /*** GLX_SGIX_video_source ***/
2749 glx
.CreateGLXVideoSourceSGIX
= Fake_glXCreateGLXVideoSourceSGIX
;
2750 glx
.DestroyGLXVideoSourceSGIX
= Fake_glXDestroyGLXVideoSourceSGIX
;
2753 /*** GLX_EXT_import_context ***/
2754 glx
.FreeContextEXT
= Fake_glXFreeContextEXT
;
2755 glx
.GetContextIDEXT
= Fake_glXGetContextIDEXT
;
2756 /*glx.GetCurrentDisplayEXT = Fake_glXGetCurrentDisplayEXT;*/
2757 glx
.ImportContextEXT
= Fake_glXImportContextEXT
;
2758 glx
.QueryContextInfoEXT
= Fake_glXQueryContextInfoEXT
;
2760 /*** GLX_SGIX_fbconfig ***/
2761 glx
.GetFBConfigAttribSGIX
= Fake_glXGetFBConfigAttribSGIX
;
2762 glx
.ChooseFBConfigSGIX
= Fake_glXChooseFBConfigSGIX
;
2763 glx
.CreateGLXPixmapWithConfigSGIX
= Fake_glXCreateGLXPixmapWithConfigSGIX
;
2764 glx
.CreateContextWithConfigSGIX
= Fake_glXCreateContextWithConfigSGIX
;
2765 glx
.GetVisualFromFBConfigSGIX
= Fake_glXGetVisualFromFBConfigSGIX
;
2766 glx
.GetFBConfigFromVisualSGIX
= Fake_glXGetFBConfigFromVisualSGIX
;
2768 /*** GLX_SGIX_pbuffer ***/
2769 glx
.CreateGLXPbufferSGIX
= Fake_glXCreateGLXPbufferSGIX
;
2770 glx
.DestroyGLXPbufferSGIX
= Fake_glXDestroyGLXPbufferSGIX
;
2771 glx
.QueryGLXPbufferSGIX
= Fake_glXQueryGLXPbufferSGIX
;
2772 glx
.SelectEventSGIX
= Fake_glXSelectEventSGIX
;
2773 glx
.GetSelectedEventSGIX
= Fake_glXGetSelectedEventSGIX
;
2775 /*** GLX_SGI_cushion ***/
2776 glx
.CushionSGI
= Fake_glXCushionSGI
;
2778 /*** GLX_SGIX_video_resize ***/
2779 glx
.BindChannelToWindowSGIX
= Fake_glXBindChannelToWindowSGIX
;
2780 glx
.ChannelRectSGIX
= Fake_glXChannelRectSGIX
;
2781 glx
.QueryChannelRectSGIX
= Fake_glXQueryChannelRectSGIX
;
2782 glx
.QueryChannelDeltasSGIX
= Fake_glXQueryChannelDeltasSGIX
;
2783 glx
.ChannelRectSyncSGIX
= Fake_glXChannelRectSyncSGIX
;
2785 /*** GLX_SGIX_dmbuffer **/
2786 #if defined(_DM_BUFFER_H_)
2787 glx
.AssociateDMPbufferSGIX
= NULL
;
2790 /*** GLX_SGIX_swap_group ***/
2791 glx
.JoinSwapGroupSGIX
= Fake_glXJoinSwapGroupSGIX
;
2793 /*** GLX_SGIX_swap_barrier ***/
2794 glx
.BindSwapBarrierSGIX
= Fake_glXBindSwapBarrierSGIX
;
2795 glx
.QueryMaxSwapBarriersSGIX
= Fake_glXQueryMaxSwapBarriersSGIX
;
2797 /*** GLX_SUN_get_transparent_index ***/
2798 glx
.GetTransparentIndexSUN
= Fake_glXGetTransparentIndexSUN
;
2800 /*** GLX_MESA_copy_sub_buffer ***/
2801 glx
.CopySubBufferMESA
= Fake_glXCopySubBufferMESA
;
2803 /*** GLX_MESA_release_buffers ***/
2804 glx
.ReleaseBuffersMESA
= Fake_glXReleaseBuffersMESA
;
2806 /*** GLX_MESA_pixmap_colormap ***/
2807 glx
.CreateGLXPixmapMESA
= Fake_glXCreateGLXPixmapMESA
;
2809 /*** GLX_MESA_set_3dfx_mode ***/
2810 glx
.Set3DfxModeMESA
= Fake_glXSet3DfxModeMESA
;
2812 /*** GLX_NV_vertex_array_range ***/
2813 glx
.AllocateMemoryNV
= Fake_glXAllocateMemoryNV
;
2814 glx
.FreeMemoryNV
= Fake_glXFreeMemoryNV
;
2816 /*** GLX_MESA_agp_offset ***/
2817 glx
.GetAGPOffsetMESA
= Fake_glXGetAGPOffsetMESA
;
2819 /*** GLX_ARB_render_texture ***/
2820 glx
.BindTexImageARB
= Fake_glXBindTexImageARB
;
2821 glx
.ReleaseTexImageARB
= Fake_glXReleaseTexImageARB
;
2822 glx
.DrawableAttribARB
= Fake_glXDrawableAttribARB
;