2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 * This is an emulation of the GLX API which allows Mesa/GLX-based programs
28 * to run on X servers which do not have the real GLX extension.
30 * Thanks to the contributors:
32 * Initial version: Philip Brown (phil@bolthole.com)
33 * Better glXGetConfig() support: Armin Liebchen (liebchen@asylum.cs.utah.edu)
34 * Further visual-handling refinements: Wolfram Gloger
35 * (wmglo@Dent.MED.Uni-Muenchen.DE).
38 * Don't be fooled, stereo isn't supported yet.
43 #include "glxheader.h"
56 #define _mesa_sprintf sprintf
59 /* This indicates the client-side GLX API and GLX encoder version. */
60 #define CLIENT_MAJOR_VERSION 1
61 #define CLIENT_MINOR_VERSION 4 /* but don't have 1.3's pbuffers, etc yet */
63 /* This indicates the server-side GLX decoder version.
64 * GLX 1.4 indicates OpenGL 1.3 support
66 #define SERVER_MAJOR_VERSION 1
67 #define SERVER_MINOR_VERSION 4
69 /* This is appended onto the glXGetClient/ServerString version strings. */
70 #define MESA_GLX_VERSION "Mesa " MESA_VERSION_STRING
72 /* Who implemented this GLX? */
73 #define VENDOR "Brian Paul"
76 "GLX_MESA_set_3dfx_mode " \
77 "GLX_MESA_copy_sub_buffer " \
78 "GLX_MESA_pixmap_colormap " \
79 "GLX_MESA_release_buffers " \
80 "GLX_ARB_get_proc_address " \
81 "GLX_EXT_visual_info " \
82 "GLX_EXT_visual_rating " \
83 /*"GLX_SGI_video_sync "*/ \
84 "GLX_SGIX_fbconfig " \
88 * Our fake GLX context will contain a "real" GLX context and an XMesa context.
90 * Note that a pointer to a __GLXcontext is a pointer to a fake_glx_context,
93 * We really just need this structure in order to make the libGL functions
94 * glXGetCurrentContext(), glXGetCurrentDrawable() and glXGetCurrentDisplay()
97 struct fake_glx_context
{
98 __GLXcontext glxContext
; /* this MUST be first! */
99 XMesaContext xmesaContext
;
104 /**********************************************************************/
105 /*** GLX Visual Code ***/
106 /**********************************************************************/
111 static XMesaVisual
*VisualTable
= NULL
;
112 static int NumVisuals
= 0;
116 * This struct and some code fragments borrowed
117 * from Mark Kilgard's GLUT library.
119 typedef struct _OverlayInfo
{
120 /* Avoid 64-bit portability problems by being careful to use
121 longs due to the way XGetWindowProperty is specified. Note
122 that these parameters are passed as CARD32s over X
124 unsigned long overlay_visual
;
125 long transparent_type
;
132 /* Macro to handle c_class vs class field name in XVisualInfo struct */
133 #if defined(__cplusplus) || defined(c_plusplus)
134 #define CLASS c_class
142 * Test if the given XVisualInfo is usable for Mesa rendering.
145 is_usable_visual( XVisualInfo
*vinfo
)
147 switch (vinfo
->CLASS
) {
150 /* Any StaticGray/GrayScale visual works in RGB or CI mode */
154 /* Any StaticColor/PseudoColor visual of at least 4 bits */
155 if (vinfo
->depth
>=4) {
163 /* Any depth of TrueColor or DirectColor works in RGB mode */
166 /* This should never happen */
174 * Get an array OverlayInfo records for specified screen.
175 * \param dpy the display
176 * \param screen screen number
177 * \param numOverlays returns numver of OverlayInfo records
178 * \return pointer to OverlayInfo array, free with XFree()
181 GetOverlayInfo(Display
*dpy
, int screen
, int *numOverlays
)
183 Atom overlayVisualsAtom
;
186 unsigned char *ovInfo
;
187 unsigned long sizeData
, bytesLeft
;
191 * The SERVER_OVERLAY_VISUALS property on the root window contains
192 * a list of overlay visuals. Get that list now.
194 overlayVisualsAtom
= XInternAtom(dpy
,"SERVER_OVERLAY_VISUALS", True
);
195 if (overlayVisualsAtom
== None
) {
199 status
= XGetWindowProperty(dpy
, RootWindow(dpy
, screen
),
200 overlayVisualsAtom
, 0L, (long) 10000, False
,
201 overlayVisualsAtom
, &actualType
, &actualFormat
,
202 &sizeData
, &bytesLeft
,
205 if (status
!= Success
|| actualType
!= overlayVisualsAtom
||
206 actualFormat
!= 32 || sizeData
< 4) {
207 /* something went wrong */
208 XFree((void *) ovInfo
);
213 *numOverlays
= sizeData
/ 4;
214 return (OverlayInfo
*) ovInfo
;
220 * Return the level (overlay, normal, underlay) of a given XVisualInfo.
221 * Input: dpy - the X display
222 * vinfo - the XVisualInfo to test
223 * Return: level of the visual:
225 * >0 = overlay planes
226 * <0 = underlay planes
229 level_of_visual( Display
*dpy
, XVisualInfo
*vinfo
)
231 OverlayInfo
*overlay_info
;
232 int numOverlaysPerScreen
, i
;
234 overlay_info
= GetOverlayInfo(dpy
, vinfo
->screen
, &numOverlaysPerScreen
);
239 /* search the overlay visual list for the visual ID of interest */
240 for (i
= 0; i
< numOverlaysPerScreen
; i
++) {
241 const OverlayInfo
*ov
= overlay_info
+ i
;
242 if (ov
->overlay_visual
== vinfo
->visualid
) {
243 /* found the visual */
244 if (/*ov->transparent_type==1 &&*/ ov
->layer
!=0) {
245 int level
= ov
->layer
;
246 XFree((void *) overlay_info
);
250 XFree((void *) overlay_info
);
256 /* The visual ID was not found in the overlay list. */
257 XFree((void *) overlay_info
);
265 * Given an XVisualInfo and RGB, Double, and Depth buffer flags, save the
266 * configuration in our list of GLX visuals.
269 save_glx_visual( Display
*dpy
, XVisualInfo
*vinfo
,
270 GLboolean rgbFlag
, GLboolean alphaFlag
, GLboolean dbFlag
,
271 GLboolean stereoFlag
,
272 GLint depth_size
, GLint stencil_size
,
273 GLint accumRedSize
, GLint accumGreenSize
,
274 GLint accumBlueSize
, GLint accumAlphaSize
,
275 GLint level
, GLint numAuxBuffers
)
277 GLboolean ximageFlag
= GL_TRUE
;
280 GLboolean comparePointers
;
283 /* Check if the MESA_BACK_BUFFER env var is set */
284 char *backbuffer
= _mesa_getenv("MESA_BACK_BUFFER");
286 if (backbuffer
[0]=='p' || backbuffer
[0]=='P') {
287 ximageFlag
= GL_FALSE
;
289 else if (backbuffer
[0]=='x' || backbuffer
[0]=='X') {
290 ximageFlag
= GL_TRUE
;
293 _mesa_warning(NULL
, "Mesa: invalid value for MESA_BACK_BUFFER environment variable, using an XImage.");
298 /* Comparing IDs uses less memory but sometimes fails. */
299 /* XXX revisit this after 3.0 is finished. */
300 if (_mesa_getenv("MESA_GLX_VISUAL_HACK"))
301 comparePointers
= GL_TRUE
;
303 comparePointers
= GL_FALSE
;
305 /* Force the visual to have an alpha channel */
306 if (rgbFlag
&& _mesa_getenv("MESA_GLX_FORCE_ALPHA"))
309 /* First check if a matching visual is already in the list */
310 for (i
=0; i
<NumVisuals
; i
++) {
311 XMesaVisual v
= VisualTable
[i
];
312 if (v
->display
== dpy
313 && v
->mesa_visual
.level
== level
314 && v
->mesa_visual
.numAuxBuffers
== numAuxBuffers
315 && v
->ximage_flag
== ximageFlag
316 && v
->mesa_visual
.rgbMode
== rgbFlag
317 && v
->mesa_visual
.doubleBufferMode
== dbFlag
318 && v
->mesa_visual
.stereoMode
== stereoFlag
319 && (v
->mesa_visual
.alphaBits
> 0) == alphaFlag
320 && (v
->mesa_visual
.depthBits
>= depth_size
|| depth_size
== 0)
321 && (v
->mesa_visual
.stencilBits
>= stencil_size
|| stencil_size
== 0)
322 && (v
->mesa_visual
.accumRedBits
>= accumRedSize
|| accumRedSize
== 0)
323 && (v
->mesa_visual
.accumGreenBits
>= accumGreenSize
|| accumGreenSize
== 0)
324 && (v
->mesa_visual
.accumBlueBits
>= accumBlueSize
|| accumBlueSize
== 0)
325 && (v
->mesa_visual
.accumAlphaBits
>= accumAlphaSize
|| accumAlphaSize
== 0)) {
326 /* now either compare XVisualInfo pointers or visual IDs */
327 if ((!comparePointers
&& v
->visinfo
->visualid
== vinfo
->visualid
)
328 || (comparePointers
&& v
->vishandle
== vinfo
)) {
334 /* Create a new visual and add it to the list. */
336 xmvis
= XMesaCreateVisual( dpy
, vinfo
, rgbFlag
, alphaFlag
, dbFlag
,
337 stereoFlag
, ximageFlag
,
338 depth_size
, stencil_size
,
339 accumRedSize
, accumBlueSize
,
340 accumBlueSize
, accumAlphaSize
, 0, level
,
343 /* Save a copy of the pointer now so we can find this visual again
344 * if we need to search for it in find_glx_visual().
346 xmvis
->vishandle
= vinfo
;
347 /* Allocate more space for additional visual */
348 VisualTable
= (XMesaVisual
*) _mesa_realloc( VisualTable
,
349 sizeof(XMesaVisual
) * NumVisuals
,
350 sizeof(XMesaVisual
) * (NumVisuals
+ 1));
351 /* add xmvis to the list */
352 VisualTable
[NumVisuals
] = xmvis
;
354 /* XXX minor hack, because XMesaCreateVisual doesn't support an
355 * aux buffers parameter.
357 xmvis
->mesa_visual
.numAuxBuffers
= numAuxBuffers
;
364 * Return the default number of bits for the Z buffer.
365 * If defined, use the MESA_GLX_DEPTH_BITS env var value.
366 * Otherwise, use the DEFAULT_SOFTWARE_DEPTH_BITS constant.
367 * XXX probably do the same thing for stencil, accum, etc.
370 default_depth_bits(void)
373 const char *zEnv
= _mesa_getenv("MESA_GLX_DEPTH_BITS");
375 zBits
= _mesa_atoi(zEnv
);
377 zBits
= DEFAULT_SOFTWARE_DEPTH_BITS
;
382 default_alpha_bits(void)
385 const char *aEnv
= _mesa_getenv("MESA_GLX_ALPHA_BITS");
387 aBits
= _mesa_atoi(aEnv
);
394 default_accum_bits(void)
402 * Create a GLX visual from a regular XVisualInfo.
403 * This is called when Fake GLX is given an XVisualInfo which wasn't
404 * returned by glXChooseVisual. Since this is the first time we're
405 * considering this visual we'll take a guess at reasonable values
406 * for depth buffer size, stencil size, accum size, etc.
407 * This is the best we can do with a client-side emulation of GLX.
410 create_glx_visual( Display
*dpy
, XVisualInfo
*visinfo
)
413 GLint zBits
= default_depth_bits();
414 GLint accBits
= default_accum_bits();
415 GLboolean alphaFlag
= default_alpha_bits() > 0;
417 vislevel
= level_of_visual( dpy
, visinfo
);
419 /* Configure this visual as a CI, single-buffered overlay */
420 return save_glx_visual( dpy
, visinfo
,
422 GL_FALSE
, /* alpha */
423 GL_FALSE
, /* double */
424 GL_FALSE
, /* stereo */
426 0, /* stencil bits */
427 0,0,0,0, /* accum bits */
428 vislevel
, /* level */
432 else if (is_usable_visual( visinfo
)) {
433 if (_mesa_getenv("MESA_GLX_FORCE_CI")) {
434 /* Configure this visual as a COLOR INDEX visual. */
435 return save_glx_visual( dpy
, visinfo
,
437 GL_FALSE
, /* alpha */
438 GL_TRUE
, /* double */
439 GL_FALSE
, /* stereo */
442 0, 0, 0, 0, /* accum bits */
448 /* Configure this visual as RGB, double-buffered, depth-buffered. */
449 /* This is surely wrong for some people's needs but what else */
450 /* can be done? They should use glXChooseVisual(). */
451 return save_glx_visual( dpy
, visinfo
,
453 alphaFlag
, /* alpha */
454 GL_TRUE
, /* double */
455 GL_FALSE
, /* stereo */
468 _mesa_warning(NULL
, "Mesa: error in glXCreateContext: bad visual\n");
476 * Find the GLX visual associated with an XVisualInfo.
479 find_glx_visual( Display
*dpy
, XVisualInfo
*vinfo
)
483 /* try to match visual id */
484 for (i
=0;i
<NumVisuals
;i
++) {
485 if (VisualTable
[i
]->display
==dpy
486 && VisualTable
[i
]->visinfo
->visualid
== vinfo
->visualid
) {
487 return VisualTable
[i
];
491 /* if that fails, try to match pointers */
492 for (i
=0;i
<NumVisuals
;i
++) {
493 if (VisualTable
[i
]->display
==dpy
&& VisualTable
[i
]->vishandle
==vinfo
) {
494 return VisualTable
[i
];
504 * Return the transparent pixel value for a GLX visual.
505 * Input: glxvis - the glx_visual
506 * Return: a pixel value or -1 if no transparent pixel
509 transparent_pixel( XMesaVisual glxvis
)
511 Display
*dpy
= glxvis
->display
;
512 XVisualInfo
*vinfo
= glxvis
->visinfo
;
513 OverlayInfo
*overlay_info
;
514 int numOverlaysPerScreen
, i
;
516 overlay_info
= GetOverlayInfo(dpy
, vinfo
->screen
, &numOverlaysPerScreen
);
521 for (i
= 0; i
< numOverlaysPerScreen
; i
++) {
522 const OverlayInfo
*ov
= overlay_info
+ i
;
523 if (ov
->overlay_visual
== vinfo
->visualid
) {
525 if (ov
->transparent_type
== 0) {
526 /* type 0 indicates no transparency */
527 XFree((void *) overlay_info
);
531 /* ov->value is the transparent pixel */
532 XFree((void *) overlay_info
);
538 /* The visual ID was not found in the overlay list. */
539 XFree((void *) overlay_info
);
546 * Try to get an X visual which matches the given arguments.
549 get_visual( Display
*dpy
, int scr
, unsigned int depth
, int xclass
)
551 XVisualInfo temp
, *vis
;
554 unsigned int default_depth
;
557 mask
= VisualScreenMask
| VisualDepthMask
| VisualClassMask
;
562 default_depth
= DefaultDepth(dpy
,scr
);
563 default_class
= DefaultVisual(dpy
,scr
)->CLASS
;
565 if (depth
==default_depth
&& xclass
==default_class
) {
566 /* try to get root window's visual */
567 temp
.visualid
= DefaultVisual(dpy
,scr
)->visualid
;
568 mask
|= VisualIDMask
;
571 vis
= XGetVisualInfo( dpy
, mask
, &temp
, &n
);
573 /* In case bits/pixel > 24, make sure color channels are still <=8 bits.
574 * An SGI Infinite Reality system, for example, can have 30bpp pixels:
575 * 10 bits per color channel. Mesa's limited to a max of 8 bits/channel.
577 if (vis
&& depth
> 24 && (xclass
==TrueColor
|| xclass
==DirectColor
)) {
578 if (_mesa_bitcount((GLuint
) vis
->red_mask
) <= 8 &&
579 _mesa_bitcount((GLuint
) vis
->green_mask
) <= 8 &&
580 _mesa_bitcount((GLuint
) vis
->blue_mask
) <= 8) {
595 * Retrieve the value of the given environment variable and find
596 * the X visual which matches it.
597 * Input: dpy - the display
598 * screen - the screen number
599 * varname - the name of the environment variable
600 * Return: an XVisualInfo pointer to NULL if error.
603 get_env_visual(Display
*dpy
, int scr
, const char *varname
)
605 char value
[100], type
[100];
606 int depth
, xclass
= -1;
609 if (!_mesa_getenv( varname
)) {
613 _mesa_strncpy( value
, _mesa_getenv(varname
), 100 );
616 sscanf( value
, "%s %d", type
, &depth
);
618 if (_mesa_strcmp(type
,"TrueColor")==0) xclass
= TrueColor
;
619 else if (_mesa_strcmp(type
,"DirectColor")==0) xclass
= DirectColor
;
620 else if (_mesa_strcmp(type
,"PseudoColor")==0) xclass
= PseudoColor
;
621 else if (_mesa_strcmp(type
,"StaticColor")==0) xclass
= StaticColor
;
622 else if (_mesa_strcmp(type
,"GrayScale")==0) xclass
= GrayScale
;
623 else if (_mesa_strcmp(type
,"StaticGray")==0) xclass
= StaticGray
;
625 if (xclass
>-1 && depth
>0) {
626 vis
= get_visual( dpy
, scr
, depth
, xclass
);
632 _mesa_warning(NULL
, "GLX unable to find visual class=%s, depth=%d.",
641 * Select an X visual which satisfies the RGBA/CI flag and minimum depth.
642 * Input: dpy, screen - X display and screen number
643 * rgba - GL_TRUE = RGBA mode, GL_FALSE = CI mode
644 * min_depth - minimum visual depth
645 * preferred_class - preferred GLX visual class or DONT_CARE
646 * Return: pointer to an XVisualInfo or NULL.
649 choose_x_visual( Display
*dpy
, int screen
, GLboolean rgba
, int min_depth
,
650 int preferred_class
)
653 int xclass
, visclass
= 0;
657 Atom hp_cr_maps
= XInternAtom(dpy
, "_HP_RGB_SMOOTH_MAP_LIST", True
);
658 /* First see if the MESA_RGB_VISUAL env var is defined */
659 vis
= get_env_visual( dpy
, screen
, "MESA_RGB_VISUAL" );
663 /* Otherwise, search for a suitable visual */
664 if (preferred_class
==DONT_CARE
) {
665 for (xclass
=0;xclass
<6;xclass
++) {
667 case 0: visclass
= TrueColor
; break;
668 case 1: visclass
= DirectColor
; break;
669 case 2: visclass
= PseudoColor
; break;
670 case 3: visclass
= StaticColor
; break;
671 case 4: visclass
= GrayScale
; break;
672 case 5: visclass
= StaticGray
; break;
675 /* start with shallowest */
676 for (depth
=0;depth
<=32;depth
++) {
677 if (visclass
==TrueColor
&& depth
==8 && !hp_cr_maps
) {
678 /* Special case: try to get 8-bit PseudoColor before */
679 /* 8-bit TrueColor */
680 vis
= get_visual( dpy
, screen
, 8, PseudoColor
);
685 vis
= get_visual( dpy
, screen
, depth
, visclass
);
692 /* start with deepest */
693 for (depth
=32;depth
>=min_depth
;depth
--) {
694 if (visclass
==TrueColor
&& depth
==8 && !hp_cr_maps
) {
695 /* Special case: try to get 8-bit PseudoColor before */
696 /* 8-bit TrueColor */
697 vis
= get_visual( dpy
, screen
, 8, PseudoColor
);
702 vis
= get_visual( dpy
, screen
, depth
, visclass
);
711 /* search for a specific visual class */
712 switch (preferred_class
) {
713 case GLX_TRUE_COLOR_EXT
: visclass
= TrueColor
; break;
714 case GLX_DIRECT_COLOR_EXT
: visclass
= DirectColor
; break;
715 case GLX_PSEUDO_COLOR_EXT
: visclass
= PseudoColor
; break;
716 case GLX_STATIC_COLOR_EXT
: visclass
= StaticColor
; break;
717 case GLX_GRAY_SCALE_EXT
: visclass
= GrayScale
; break;
718 case GLX_STATIC_GRAY_EXT
: visclass
= StaticGray
; break;
719 default: return NULL
;
722 /* start with shallowest */
723 for (depth
=0;depth
<=32;depth
++) {
724 vis
= get_visual( dpy
, screen
, depth
, visclass
);
731 /* start with deepest */
732 for (depth
=32;depth
>=min_depth
;depth
--) {
733 vis
= get_visual( dpy
, screen
, depth
, visclass
);
742 /* First see if the MESA_CI_VISUAL env var is defined */
743 vis
= get_env_visual( dpy
, screen
, "MESA_CI_VISUAL" );
747 /* Otherwise, search for a suitable visual, starting with shallowest */
748 if (preferred_class
==DONT_CARE
) {
749 for (xclass
=0;xclass
<4;xclass
++) {
751 case 0: visclass
= PseudoColor
; break;
752 case 1: visclass
= StaticColor
; break;
753 case 2: visclass
= GrayScale
; break;
754 case 3: visclass
= StaticGray
; break;
756 /* try 8-bit up through 16-bit */
757 for (depth
=8;depth
<=16;depth
++) {
758 vis
= get_visual( dpy
, screen
, depth
, visclass
);
763 /* try min_depth up to 8-bit */
764 for (depth
=min_depth
;depth
<8;depth
++) {
765 vis
= get_visual( dpy
, screen
, depth
, visclass
);
773 /* search for a specific visual class */
774 switch (preferred_class
) {
775 case GLX_TRUE_COLOR_EXT
: visclass
= TrueColor
; break;
776 case GLX_DIRECT_COLOR_EXT
: visclass
= DirectColor
; break;
777 case GLX_PSEUDO_COLOR_EXT
: visclass
= PseudoColor
; break;
778 case GLX_STATIC_COLOR_EXT
: visclass
= StaticColor
; break;
779 case GLX_GRAY_SCALE_EXT
: visclass
= GrayScale
; break;
780 case GLX_STATIC_GRAY_EXT
: visclass
= StaticGray
; break;
781 default: return NULL
;
783 /* try 8-bit up through 16-bit */
784 for (depth
=8;depth
<=16;depth
++) {
785 vis
= get_visual( dpy
, screen
, depth
, visclass
);
790 /* try min_depth up to 8-bit */
791 for (depth
=min_depth
;depth
<8;depth
++) {
792 vis
= get_visual( dpy
, screen
, depth
, visclass
);
800 /* didn't find a visual */
807 * Find the deepest X over/underlay visual of at least min_depth.
808 * Input: dpy, screen - X display and screen number
809 * level - the over/underlay level
810 * trans_type - transparent pixel type: GLX_NONE_EXT,
811 * GLX_TRANSPARENT_RGB_EXT, GLX_TRANSPARENT_INDEX_EXT,
813 * trans_value - transparent pixel value or DONT_CARE
814 * min_depth - minimum visual depth
815 * preferred_class - preferred GLX visual class or DONT_CARE
816 * Return: pointer to an XVisualInfo or NULL.
819 choose_x_overlay_visual( Display
*dpy
, int scr
, GLboolean rgbFlag
,
820 int level
, int trans_type
, int trans_value
,
821 int min_depth
, int preferred_class
)
823 OverlayInfo
*overlay_info
;
824 int numOverlaysPerScreen
;
826 XVisualInfo
*deepvis
;
829 /*DEBUG int tt, tv; */
831 switch (preferred_class
) {
832 case GLX_TRUE_COLOR_EXT
: preferred_class
= TrueColor
; break;
833 case GLX_DIRECT_COLOR_EXT
: preferred_class
= DirectColor
; break;
834 case GLX_PSEUDO_COLOR_EXT
: preferred_class
= PseudoColor
; break;
835 case GLX_STATIC_COLOR_EXT
: preferred_class
= StaticColor
; break;
836 case GLX_GRAY_SCALE_EXT
: preferred_class
= GrayScale
; break;
837 case GLX_STATIC_GRAY_EXT
: preferred_class
= StaticGray
; break;
838 default: preferred_class
= DONT_CARE
;
841 overlay_info
= GetOverlayInfo(dpy
, scr
, &numOverlaysPerScreen
);
846 /* Search for the deepest overlay which satisifies all criteria. */
850 for (i
= 0; i
< numOverlaysPerScreen
; i
++) {
851 const OverlayInfo
*ov
= overlay_info
+ i
;
852 XVisualInfo
*vislist
, vistemplate
;
855 if (ov
->layer
!=level
) {
856 /* failed overlay level criteria */
859 if (!(trans_type
==DONT_CARE
860 || (trans_type
==GLX_TRANSPARENT_INDEX_EXT
861 && ov
->transparent_type
>0)
862 || (trans_type
==GLX_NONE_EXT
&& ov
->transparent_type
==0))) {
863 /* failed transparent pixel type criteria */
866 if (trans_value
!=DONT_CARE
&& trans_value
!=ov
->value
) {
867 /* failed transparent pixel value criteria */
871 /* get XVisualInfo and check the depth */
872 vistemplate
.visualid
= ov
->overlay_visual
;
873 vistemplate
.screen
= scr
;
874 vislist
= XGetVisualInfo( dpy
, VisualIDMask
| VisualScreenMask
,
875 &vistemplate
, &count
);
878 /* something went wrong */
881 if (preferred_class
!=DONT_CARE
&& preferred_class
!=vislist
->CLASS
) {
882 /* wrong visual class */
886 /* if RGB was requested, make sure we have True/DirectColor */
887 if (rgbFlag
&& vislist
->CLASS
!= TrueColor
888 && vislist
->CLASS
!= DirectColor
)
891 /* if CI was requested, make sure we have a color indexed visual */
893 && (vislist
->CLASS
== TrueColor
|| vislist
->CLASS
== DirectColor
))
896 if (deepvis
==NULL
|| vislist
->depth
> deepest
) {
897 /* YES! found a satisfactory visual */
901 deepest
= vislist
->depth
;
903 /* DEBUG tt = ov->transparent_type;*/
904 /* DEBUG tv = ov->value; */
910 printf("chose 0x%x: layer=%d depth=%d trans_type=%d trans_value=%d\n",
911 deepvis->visualid, level, deepvis->depth, tt, tv );
918 /**********************************************************************/
919 /*** Display-related functions ***/
920 /**********************************************************************/
924 * Free all XMesaVisuals which are associated with the given display.
927 destroy_visuals_on_display(Display
*dpy
)
930 for (i
= 0; i
< NumVisuals
; i
++) {
931 if (VisualTable
[i
]->display
== dpy
) {
932 /* remove this visual */
934 free(VisualTable
[i
]);
935 for (j
= i
; j
< NumVisuals
- 1; j
++)
936 VisualTable
[j
] = VisualTable
[j
+ 1];
944 * Called from XCloseDisplay() to let us free our display-related data.
947 close_display_callback(Display
*dpy
, XExtCodes
*codes
)
949 destroy_visuals_on_display(dpy
);
950 xmesa_destroy_buffers_on_display(dpy
);
956 * Look for the named extension on given display and return a pointer
957 * to the _XExtension data, or NULL if extension not found.
960 lookup_extension(Display
*dpy
, const char *extName
)
963 for (ext
= dpy
->ext_procs
; ext
; ext
= ext
->next
) {
964 if (ext
->name
&& strcmp(ext
->name
, extName
) == 0) {
973 * Whenever we're given a new Display pointer, call this function to
974 * register our close_display_callback function.
977 register_with_display(Display
*dpy
)
979 const char *extName
= "MesaGLX";
982 ext
= lookup_extension(dpy
, extName
);
984 XExtCodes
*c
= XAddExtension(dpy
);
985 ext
= dpy
->ext_procs
; /* new extension is at head of list */
986 assert(c
->extension
== ext
->codes
.extension
);
987 ext
->name
= _mesa_strdup(extName
);
988 ext
->close_display
= close_display_callback
;
993 /**********************************************************************/
994 /*** Begin Fake GLX API Functions ***/
995 /**********************************************************************/
999 * Helper used by glXChooseVisual and glXChooseFBConfig.
1000 * The fbConfig parameter must be GL_FALSE for the former and GL_TRUE for
1002 * In either case, the attribute list is terminated with the value 'None'.
1005 choose_visual( Display
*dpy
, int screen
, const int *list
, GLboolean fbConfig
)
1007 const GLboolean rgbModeDefault
= fbConfig
;
1008 const int *parselist
;
1011 int min_red
=0, min_green
=0, min_blue
=0;
1012 GLboolean rgb_flag
= rgbModeDefault
;
1013 GLboolean alpha_flag
= GL_FALSE
;
1014 GLboolean double_flag
= GL_FALSE
;
1015 GLboolean stereo_flag
= GL_FALSE
;
1016 GLint depth_size
= 0;
1017 GLint stencil_size
= 0;
1018 GLint accumRedSize
= 0;
1019 GLint accumGreenSize
= 0;
1020 GLint accumBlueSize
= 0;
1021 GLint accumAlphaSize
= 0;
1023 int visual_type
= DONT_CARE
;
1024 int trans_type
= DONT_CARE
;
1025 int trans_value
= DONT_CARE
;
1026 GLint caveat
= DONT_CARE
;
1027 XMesaVisual xmvis
= NULL
;
1028 int desiredVisualID
= -1;
1033 while (*parselist
) {
1035 switch (*parselist
) {
1046 case GLX_BUFFER_SIZE
:
1048 min_ci
= *parselist
++;
1052 level
= *parselist
++;
1064 case GLX_DOUBLEBUFFER
:
1067 double_flag
= *parselist
++;
1070 double_flag
= GL_TRUE
;
1076 stereo_flag
= *parselist
++;
1079 stereo_flag
= GL_TRUE
;
1081 return NULL
; /* stereo not supported */
1082 case GLX_AUX_BUFFERS
:
1084 numAux
= *parselist
++;
1085 if (numAux
> MAX_AUX_BUFFERS
)
1090 min_red
= *parselist
++;
1092 case GLX_GREEN_SIZE
:
1094 min_green
= *parselist
++;
1098 min_blue
= *parselist
++;
1100 case GLX_ALPHA_SIZE
:
1103 GLint size
= *parselist
++;
1104 alpha_flag
= size
? GL_TRUE
: GL_FALSE
;
1107 case GLX_DEPTH_SIZE
:
1109 depth_size
= *parselist
++;
1111 case GLX_STENCIL_SIZE
:
1113 stencil_size
= *parselist
++;
1115 case GLX_ACCUM_RED_SIZE
:
1118 GLint size
= *parselist
++;
1119 accumRedSize
= MAX2( accumRedSize
, size
);
1122 case GLX_ACCUM_GREEN_SIZE
:
1125 GLint size
= *parselist
++;
1126 accumGreenSize
= MAX2( accumGreenSize
, size
);
1129 case GLX_ACCUM_BLUE_SIZE
:
1132 GLint size
= *parselist
++;
1133 accumBlueSize
= MAX2( accumBlueSize
, size
);
1136 case GLX_ACCUM_ALPHA_SIZE
:
1139 GLint size
= *parselist
++;
1140 accumAlphaSize
= MAX2( accumAlphaSize
, size
);
1145 * GLX_EXT_visual_info extension
1147 case GLX_X_VISUAL_TYPE_EXT
:
1149 visual_type
= *parselist
++;
1151 case GLX_TRANSPARENT_TYPE_EXT
:
1153 trans_type
= *parselist
++;
1155 case GLX_TRANSPARENT_INDEX_VALUE_EXT
:
1157 trans_value
= *parselist
++;
1159 case GLX_TRANSPARENT_RED_VALUE_EXT
:
1160 case GLX_TRANSPARENT_GREEN_VALUE_EXT
:
1161 case GLX_TRANSPARENT_BLUE_VALUE_EXT
:
1162 case GLX_TRANSPARENT_ALPHA_VALUE_EXT
:
1169 * GLX_EXT_visual_info extension
1171 case GLX_VISUAL_CAVEAT_EXT
:
1173 caveat
= *parselist
++; /* ignored for now */
1177 * GLX_ARB_multisample
1179 case GLX_SAMPLE_BUFFERS_ARB
:
1180 /* ms not supported */
1182 case GLX_SAMPLES_ARB
:
1183 /* ms not supported */
1189 case GLX_RENDER_TYPE
:
1193 if (*parselist
== GLX_RGBA_BIT
) {
1196 else if (*parselist
== GLX_COLOR_INDEX_BIT
) {
1197 rgb_flag
= GL_FALSE
;
1199 else if (*parselist
== 0) {
1204 case GLX_DRAWABLE_TYPE
:
1208 if (*parselist
& ~(GLX_WINDOW_BIT
| GLX_PIXMAP_BIT
| GLX_PBUFFER_BIT
)) {
1209 return NULL
; /* bad bit */
1213 case GLX_FBCONFIG_ID
:
1217 desiredVisualID
= *parselist
++;
1219 case GLX_X_RENDERABLE
:
1231 /* undefined attribute */
1232 _mesa_warning(NULL
, "unexpected attrib 0x%x in choose_visual()",
1241 * Since we're only simulating the GLX extension this function will never
1242 * find any real GL visuals. Instead, all we can do is try to find an RGB
1243 * or CI visual of appropriate depth. Other requested attributes such as
1244 * double buffering, depth buffer, etc. will be associated with the X
1245 * visual and stored in the VisualTable[].
1247 if (desiredVisualID
!= -1) {
1248 /* try to get a specific visual, by visualID */
1251 temp
.visualid
= desiredVisualID
;
1252 temp
.screen
= screen
;
1253 vis
= XGetVisualInfo(dpy
, VisualIDMask
| VisualScreenMask
, &temp
, &n
);
1255 /* give the visual some useful GLX attributes */
1256 double_flag
= GL_TRUE
;
1259 depth_size
= default_depth_bits();
1260 stencil_size
= STENCIL_BITS
;
1264 else if (level
==0) {
1265 /* normal color planes */
1267 /* Get an RGB visual */
1268 int min_rgb
= min_red
+ min_green
+ min_blue
;
1269 if (min_rgb
>1 && min_rgb
<8) {
1270 /* a special case to be sure we can get a monochrome visual */
1273 vis
= choose_x_visual( dpy
, screen
, rgb_flag
, min_rgb
, visual_type
);
1276 /* Get a color index visual */
1277 vis
= choose_x_visual( dpy
, screen
, rgb_flag
, min_ci
, visual_type
);
1278 accumRedSize
= accumGreenSize
= accumBlueSize
= accumAlphaSize
= 0;
1282 /* over/underlay planes */
1285 int min_rgb
= min_red
+ min_green
+ min_blue
;
1286 if (min_rgb
>1 && min_rgb
<8) {
1287 /* a special case to be sure we can get a monochrome visual */
1290 vis
= choose_x_overlay_visual( dpy
, screen
, rgb_flag
, level
,
1291 trans_type
, trans_value
, min_rgb
, visual_type
);
1294 /* color index overlay */
1295 vis
= choose_x_overlay_visual( dpy
, screen
, rgb_flag
, level
,
1296 trans_type
, trans_value
, min_ci
, visual_type
);
1301 /* Note: we're not exactly obeying the glXChooseVisual rules here.
1302 * When GLX_DEPTH_SIZE = 1 is specified we're supposed to choose the
1303 * largest depth buffer size, which is 32bits/value. Instead, we
1304 * return 16 to maintain performance with earlier versions of Mesa.
1306 if (depth_size
> 24)
1308 else if (depth_size
> 16)
1310 else if (depth_size
> 0) {
1311 depth_size
= default_depth_bits();
1315 alpha_flag
= default_alpha_bits() > 0;
1318 /* we only support one size of stencil and accum buffers. */
1319 if (stencil_size
> 0)
1320 stencil_size
= STENCIL_BITS
;
1321 if (accumRedSize
> 0 || accumGreenSize
> 0 || accumBlueSize
> 0 ||
1322 accumAlphaSize
> 0) {
1325 accumBlueSize
= default_accum_bits();
1326 accumAlphaSize
= alpha_flag
? accumRedSize
: 0;
1329 xmvis
= save_glx_visual( dpy
, vis
, rgb_flag
, alpha_flag
, double_flag
,
1330 stereo_flag
, depth_size
, stencil_size
,
1331 accumRedSize
, accumGreenSize
,
1332 accumBlueSize
, accumAlphaSize
, level
, numAux
);
1339 static XVisualInfo
*
1340 Fake_glXChooseVisual( Display
*dpy
, int screen
, int *list
)
1344 /* register ourselves as an extension on this display */
1345 register_with_display(dpy
);
1347 xmvis
= choose_visual(dpy
, screen
, list
, GL_FALSE
);
1350 return xmvis
->vishandle
;
1352 /* create a new vishandle - the cached one may be stale */
1353 xmvis
->vishandle
= (XVisualInfo
*) _mesa_malloc(sizeof(XVisualInfo
));
1354 if (xmvis
->vishandle
) {
1355 _mesa_memcpy(xmvis
->vishandle
, xmvis
->visinfo
, sizeof(XVisualInfo
));
1357 return xmvis
->vishandle
;
1366 Fake_glXCreateContext( Display
*dpy
, XVisualInfo
*visinfo
,
1367 GLXContext share_list
, Bool direct
)
1370 struct fake_glx_context
*glxCtx
;
1371 struct fake_glx_context
*shareCtx
= (struct fake_glx_context
*) share_list
;
1373 if (!dpy
|| !visinfo
)
1376 glxCtx
= CALLOC_STRUCT(fake_glx_context
);
1380 /* deallocate unused windows/buffers */
1382 XMesaGarbageCollect();
1385 xmvis
= find_glx_visual( dpy
, visinfo
);
1387 /* This visual wasn't found with glXChooseVisual() */
1388 xmvis
= create_glx_visual( dpy
, visinfo
);
1390 /* unusable visual */
1396 glxCtx
->xmesaContext
= XMesaCreateContext(xmvis
,
1397 shareCtx
? shareCtx
->xmesaContext
: NULL
);
1398 if (!glxCtx
->xmesaContext
) {
1403 glxCtx
->xmesaContext
->direct
= GL_FALSE
;
1404 glxCtx
->glxContext
.isDirect
= GL_FALSE
;
1405 glxCtx
->glxContext
.currentDpy
= dpy
;
1406 glxCtx
->glxContext
.xid
= (XID
) glxCtx
; /* self pointer */
1408 assert((void *) glxCtx
== (void *) &(glxCtx
->glxContext
));
1410 return (GLXContext
) glxCtx
;
1414 /* XXX these may have to be removed due to thread-safety issues. */
1415 static GLXContext MakeCurrent_PrevContext
= 0;
1416 static GLXDrawable MakeCurrent_PrevDrawable
= 0;
1417 static GLXDrawable MakeCurrent_PrevReadable
= 0;
1418 static XMesaBuffer MakeCurrent_PrevDrawBuffer
= 0;
1419 static XMesaBuffer MakeCurrent_PrevReadBuffer
= 0;
1422 /* GLX 1.3 and later */
1424 Fake_glXMakeContextCurrent( Display
*dpy
, GLXDrawable draw
,
1425 GLXDrawable read
, GLXContext ctx
)
1427 struct fake_glx_context
*glxCtx
= (struct fake_glx_context
*) ctx
;
1429 if (ctx
&& draw
&& read
) {
1430 XMesaBuffer drawBuffer
, readBuffer
;
1431 XMesaContext xmctx
= glxCtx
->xmesaContext
;
1433 /* Find the XMesaBuffer which corresponds to the GLXDrawable 'draw' */
1434 if (ctx
== MakeCurrent_PrevContext
1435 && draw
== MakeCurrent_PrevDrawable
) {
1436 drawBuffer
= MakeCurrent_PrevDrawBuffer
;
1439 drawBuffer
= XMesaFindBuffer( dpy
, draw
);
1442 /* drawable must be a new window! */
1443 drawBuffer
= XMesaCreateWindowBuffer2( xmctx
->xm_visual
, draw
, xmctx
);
1445 /* Out of memory, or context/drawable depth mismatch */
1450 /* Find the XMesaBuffer which corresponds to the GLXDrawable 'read' */
1451 if (ctx
== MakeCurrent_PrevContext
1452 && read
== MakeCurrent_PrevReadable
) {
1453 readBuffer
= MakeCurrent_PrevReadBuffer
;
1456 readBuffer
= XMesaFindBuffer( dpy
, read
);
1459 /* drawable must be a new window! */
1460 readBuffer
= XMesaCreateWindowBuffer2(glxCtx
->xmesaContext
->xm_visual
,
1463 /* Out of memory, or context/drawable depth mismatch */
1468 MakeCurrent_PrevContext
= ctx
;
1469 MakeCurrent_PrevDrawable
= draw
;
1470 MakeCurrent_PrevReadable
= read
;
1471 MakeCurrent_PrevDrawBuffer
= drawBuffer
;
1472 MakeCurrent_PrevReadBuffer
= readBuffer
;
1474 /* Now make current! */
1475 if (XMesaMakeCurrent2(xmctx
, drawBuffer
, readBuffer
)) {
1476 ((__GLXcontext
*) ctx
)->currentDpy
= dpy
;
1477 ((__GLXcontext
*) ctx
)->currentDrawable
= draw
;
1478 ((__GLXcontext
*) ctx
)->currentReadable
= read
;
1485 else if (!ctx
&& !draw
&& !read
) {
1486 /* release current context w/out assigning new one. */
1487 XMesaMakeCurrent( NULL
, NULL
);
1488 MakeCurrent_PrevContext
= 0;
1489 MakeCurrent_PrevDrawable
= 0;
1490 MakeCurrent_PrevReadable
= 0;
1491 MakeCurrent_PrevDrawBuffer
= 0;
1492 MakeCurrent_PrevReadBuffer
= 0;
1496 /* The args must either all be non-zero or all zero.
1505 Fake_glXMakeCurrent( Display
*dpy
, GLXDrawable drawable
, GLXContext ctx
)
1507 return Fake_glXMakeContextCurrent( dpy
, drawable
, drawable
, ctx
);
1512 Fake_glXCreateGLXPixmap( Display
*dpy
, XVisualInfo
*visinfo
, Pixmap pixmap
)
1517 v
= find_glx_visual( dpy
, visinfo
);
1519 v
= create_glx_visual( dpy
, visinfo
);
1521 /* unusable visual */
1526 b
= XMesaCreatePixmapBuffer( v
, pixmap
, 0 );
1530 return b
->frontxrb
->pixmap
;
1534 /*** GLX_MESA_pixmap_colormap ***/
1537 Fake_glXCreateGLXPixmapMESA( Display
*dpy
, XVisualInfo
*visinfo
,
1538 Pixmap pixmap
, Colormap cmap
)
1543 v
= find_glx_visual( dpy
, visinfo
);
1545 v
= create_glx_visual( dpy
, visinfo
);
1547 /* unusable visual */
1552 b
= XMesaCreatePixmapBuffer( v
, pixmap
, cmap
);
1556 return b
->frontxrb
->pixmap
;
1561 Fake_glXDestroyGLXPixmap( Display
*dpy
, GLXPixmap pixmap
)
1563 XMesaBuffer b
= XMesaFindBuffer(dpy
, pixmap
);
1565 XMesaDestroyBuffer(b
);
1567 else if (_mesa_getenv("MESA_DEBUG")) {
1568 _mesa_warning(NULL
, "Mesa: glXDestroyGLXPixmap: invalid pixmap\n");
1574 Fake_glXCopyContext( Display
*dpy
, GLXContext src
, GLXContext dst
,
1575 unsigned long mask
)
1577 struct fake_glx_context
*fakeSrc
= (struct fake_glx_context
*) src
;
1578 struct fake_glx_context
*fakeDst
= (struct fake_glx_context
*) dst
;
1579 XMesaContext xm_src
= fakeSrc
->xmesaContext
;
1580 XMesaContext xm_dst
= fakeDst
->xmesaContext
;
1582 if (MakeCurrent_PrevContext
== src
) {
1585 _mesa_copy_context( &(xm_src
->mesa
), &(xm_dst
->mesa
), (GLuint
) mask
);
1590 Fake_glXQueryExtension( Display
*dpy
, int *errorb
, int *event
)
1592 /* Mesa's GLX isn't really an X extension but we try to act like one. */
1600 extern void _kw_ungrab_all( Display
*dpy
);
1601 void _kw_ungrab_all( Display
*dpy
)
1603 XUngrabPointer( dpy
, CurrentTime
);
1604 XUngrabKeyboard( dpy
, CurrentTime
);
1609 Fake_glXDestroyContext( Display
*dpy
, GLXContext ctx
)
1611 struct fake_glx_context
*glxCtx
= (struct fake_glx_context
*) ctx
;
1613 MakeCurrent_PrevContext
= 0;
1614 MakeCurrent_PrevDrawable
= 0;
1615 MakeCurrent_PrevReadable
= 0;
1616 MakeCurrent_PrevDrawBuffer
= 0;
1617 MakeCurrent_PrevReadBuffer
= 0;
1618 XMesaDestroyContext( glxCtx
->xmesaContext
);
1619 XMesaGarbageCollect();
1625 Fake_glXIsDirect( Display
*dpy
, GLXContext ctx
)
1627 struct fake_glx_context
*glxCtx
= (struct fake_glx_context
*) ctx
;
1629 return glxCtx
->xmesaContext
->direct
;
1635 Fake_glXSwapBuffers( Display
*dpy
, GLXDrawable drawable
)
1637 XMesaBuffer buffer
= XMesaFindBuffer( dpy
, drawable
);
1640 XMesaSwapBuffers(buffer
);
1642 else if (_mesa_getenv("MESA_DEBUG")) {
1643 _mesa_warning(NULL
, "glXSwapBuffers: invalid drawable 0x%x\n",
1650 /*** GLX_MESA_copy_sub_buffer ***/
1653 Fake_glXCopySubBufferMESA( Display
*dpy
, GLXDrawable drawable
,
1654 int x
, int y
, int width
, int height
)
1656 XMesaBuffer buffer
= XMesaFindBuffer( dpy
, drawable
);
1658 XMesaCopySubBuffer(buffer
, x
, y
, width
, height
);
1660 else if (_mesa_getenv("MESA_DEBUG")) {
1661 _mesa_warning(NULL
, "Mesa: glXCopySubBufferMESA: invalid drawable\n");
1667 Fake_glXQueryVersion( Display
*dpy
, int *maj
, int *min
)
1670 /* Return GLX version, not Mesa version */
1671 assert(CLIENT_MAJOR_VERSION
== SERVER_MAJOR_VERSION
);
1672 *maj
= CLIENT_MAJOR_VERSION
;
1673 *min
= MIN2( CLIENT_MINOR_VERSION
, SERVER_MINOR_VERSION
);
1679 * Query the GLX attributes of the given XVisualInfo.
1682 get_config( XMesaVisual xmvis
, int attrib
, int *value
, GLboolean fbconfig
)
1688 return GLX_BAD_ATTRIBUTE
;
1689 *value
= (int) True
;
1691 case GLX_BUFFER_SIZE
:
1692 *value
= xmvis
->visinfo
->depth
;
1695 *value
= xmvis
->mesa_visual
.level
;
1699 return GLX_BAD_ATTRIBUTE
;
1700 if (xmvis
->mesa_visual
.rgbMode
) {
1707 case GLX_DOUBLEBUFFER
:
1708 *value
= (int) xmvis
->mesa_visual
.doubleBufferMode
;
1711 *value
= (int) xmvis
->mesa_visual
.stereoMode
;
1713 case GLX_AUX_BUFFERS
:
1714 *value
= xmvis
->mesa_visual
.numAuxBuffers
;
1717 *value
= xmvis
->mesa_visual
.redBits
;
1719 case GLX_GREEN_SIZE
:
1720 *value
= xmvis
->mesa_visual
.greenBits
;
1723 *value
= xmvis
->mesa_visual
.blueBits
;
1725 case GLX_ALPHA_SIZE
:
1726 *value
= xmvis
->mesa_visual
.alphaBits
;
1728 case GLX_DEPTH_SIZE
:
1729 *value
= xmvis
->mesa_visual
.depthBits
;
1731 case GLX_STENCIL_SIZE
:
1732 *value
= xmvis
->mesa_visual
.stencilBits
;
1734 case GLX_ACCUM_RED_SIZE
:
1735 *value
= xmvis
->mesa_visual
.accumRedBits
;
1737 case GLX_ACCUM_GREEN_SIZE
:
1738 *value
= xmvis
->mesa_visual
.accumGreenBits
;
1740 case GLX_ACCUM_BLUE_SIZE
:
1741 *value
= xmvis
->mesa_visual
.accumBlueBits
;
1743 case GLX_ACCUM_ALPHA_SIZE
:
1744 *value
= xmvis
->mesa_visual
.accumAlphaBits
;
1748 * GLX_EXT_visual_info extension
1750 case GLX_X_VISUAL_TYPE_EXT
:
1751 switch (xmvis
->visinfo
->CLASS
) {
1752 case StaticGray
: *value
= GLX_STATIC_GRAY_EXT
; return 0;
1753 case GrayScale
: *value
= GLX_GRAY_SCALE_EXT
; return 0;
1754 case StaticColor
: *value
= GLX_STATIC_GRAY_EXT
; return 0;
1755 case PseudoColor
: *value
= GLX_PSEUDO_COLOR_EXT
; return 0;
1756 case TrueColor
: *value
= GLX_TRUE_COLOR_EXT
; return 0;
1757 case DirectColor
: *value
= GLX_DIRECT_COLOR_EXT
; return 0;
1760 case GLX_TRANSPARENT_TYPE_EXT
:
1761 if (xmvis
->mesa_visual
.level
==0) {
1763 *value
= GLX_NONE_EXT
;
1765 else if (xmvis
->mesa_visual
.level
>0) {
1767 if (xmvis
->mesa_visual
.rgbMode
) {
1768 *value
= GLX_TRANSPARENT_RGB_EXT
;
1771 *value
= GLX_TRANSPARENT_INDEX_EXT
;
1774 else if (xmvis
->mesa_visual
.level
<0) {
1776 *value
= GLX_NONE_EXT
;
1779 case GLX_TRANSPARENT_INDEX_VALUE_EXT
:
1781 int pixel
= transparent_pixel( xmvis
);
1785 /* else undefined */
1788 case GLX_TRANSPARENT_RED_VALUE_EXT
:
1791 case GLX_TRANSPARENT_GREEN_VALUE_EXT
:
1794 case GLX_TRANSPARENT_BLUE_VALUE_EXT
:
1797 case GLX_TRANSPARENT_ALPHA_VALUE_EXT
:
1802 * GLX_EXT_visual_info extension
1804 case GLX_VISUAL_CAVEAT_EXT
:
1805 /* test for zero, just in case */
1806 if (xmvis
->mesa_visual
.visualRating
> 0)
1807 *value
= xmvis
->mesa_visual
.visualRating
;
1809 *value
= GLX_NONE_EXT
;
1813 * GLX_ARB_multisample
1815 case GLX_SAMPLE_BUFFERS_ARB
:
1818 case GLX_SAMPLES_ARB
:
1825 case GLX_SCREEN_EXT
:
1827 return GLX_BAD_ATTRIBUTE
;
1828 *value
= xmvis
->visinfo
->screen
;
1830 case GLX_DRAWABLE_TYPE
: /*SGIX too */
1832 return GLX_BAD_ATTRIBUTE
;
1833 *value
= GLX_WINDOW_BIT
| GLX_PIXMAP_BIT
| GLX_PBUFFER_BIT
;
1835 case GLX_RENDER_TYPE_SGIX
:
1837 return GLX_BAD_ATTRIBUTE
;
1838 if (xmvis
->mesa_visual
.rgbMode
)
1839 *value
= GLX_RGBA_BIT
;
1841 *value
= GLX_COLOR_INDEX_BIT
;
1843 case GLX_X_RENDERABLE_SGIX
:
1845 return GLX_BAD_ATTRIBUTE
;
1846 *value
= True
; /* XXX really? */
1848 case GLX_FBCONFIG_ID_SGIX
:
1850 return GLX_BAD_ATTRIBUTE
;
1851 *value
= xmvis
->visinfo
->visualid
;
1853 case GLX_MAX_PBUFFER_WIDTH
:
1855 return GLX_BAD_ATTRIBUTE
;
1856 /* XXX or MAX_WIDTH? */
1857 *value
= DisplayWidth(xmvis
->display
, xmvis
->visinfo
->screen
);
1859 case GLX_MAX_PBUFFER_HEIGHT
:
1861 return GLX_BAD_ATTRIBUTE
;
1862 *value
= DisplayHeight(xmvis
->display
, xmvis
->visinfo
->screen
);
1864 case GLX_MAX_PBUFFER_PIXELS
:
1866 return GLX_BAD_ATTRIBUTE
;
1867 *value
= DisplayWidth(xmvis
->display
, xmvis
->visinfo
->screen
) *
1868 DisplayHeight(xmvis
->display
, xmvis
->visinfo
->screen
);
1872 return GLX_BAD_ATTRIBUTE
;
1873 *value
= xmvis
->visinfo
->visualid
;
1877 return GLX_BAD_ATTRIBUTE
;
1884 Fake_glXGetConfig( Display
*dpy
, XVisualInfo
*visinfo
,
1885 int attrib
, int *value
)
1889 if (!dpy
|| !visinfo
)
1890 return GLX_BAD_ATTRIBUTE
;
1892 xmvis
= find_glx_visual( dpy
, visinfo
);
1894 /* this visual wasn't obtained with glXChooseVisual */
1895 xmvis
= create_glx_visual( dpy
, visinfo
);
1897 /* this visual can't be used for GL rendering */
1898 if (attrib
==GLX_USE_GL
) {
1899 *value
= (int) False
;
1903 return GLX_BAD_VISUAL
;
1908 k
= get_config(xmvis
, attrib
, value
, GL_FALSE
);
1914 Fake_glXWaitGL( void )
1916 XMesaContext xmesa
= XMesaGetCurrentContext();
1917 XMesaFlush( xmesa
);
1923 Fake_glXWaitX( void )
1925 XMesaContext xmesa
= XMesaGetCurrentContext();
1926 XMesaFlush( xmesa
);
1931 get_extensions( void )
1934 const char *fx
= _mesa_getenv("MESA_GLX_FX");
1935 if (fx
&& fx
[0] != 'd') {
1939 return EXTENSIONS
+ 23; /* skip "GLX_MESA_set_3dfx_mode" */
1944 /* GLX 1.1 and later */
1946 Fake_glXQueryExtensionsString( Display
*dpy
, int screen
)
1950 return get_extensions();
1955 /* GLX 1.1 and later */
1957 Fake_glXQueryServerString( Display
*dpy
, int screen
, int name
)
1959 static char version
[1000];
1960 _mesa_sprintf(version
, "%d.%d %s",
1961 SERVER_MAJOR_VERSION
, SERVER_MINOR_VERSION
, MESA_GLX_VERSION
);
1967 case GLX_EXTENSIONS
:
1968 return get_extensions();
1980 /* GLX 1.1 and later */
1982 Fake_glXGetClientString( Display
*dpy
, int name
)
1984 static char version
[1000];
1985 _mesa_sprintf(version
, "%d.%d %s", CLIENT_MAJOR_VERSION
,
1986 CLIENT_MINOR_VERSION
, MESA_GLX_VERSION
);
1991 case GLX_EXTENSIONS
:
1992 return get_extensions();
2010 Fake_glXGetFBConfigAttrib( Display
*dpy
, GLXFBConfig config
,
2011 int attribute
, int *value
)
2013 XMesaVisual v
= (XMesaVisual
) config
;
2017 if (!dpy
|| !config
|| !value
)
2020 return get_config(v
, attribute
, value
, GL_TRUE
);
2024 static GLXFBConfig
*
2025 Fake_glXGetFBConfigs( Display
*dpy
, int screen
, int *nelements
)
2027 XVisualInfo
*visuals
, visTemplate
;
2028 const long visMask
= VisualScreenMask
;
2031 /* Get list of all X visuals */
2032 visTemplate
.screen
= screen
;
2033 visuals
= XGetVisualInfo(dpy
, visMask
, &visTemplate
, nelements
);
2034 if (*nelements
> 0) {
2035 XMesaVisual
*results
;
2036 results
= (XMesaVisual
*) _mesa_malloc(*nelements
* sizeof(XMesaVisual
));
2041 for (i
= 0; i
< *nelements
; i
++) {
2042 results
[i
] = create_glx_visual(dpy
, visuals
+ i
);
2044 return (GLXFBConfig
*) results
;
2050 static GLXFBConfig
*
2051 Fake_glXChooseFBConfig( Display
*dpy
, int screen
,
2052 const int *attribList
, int *nitems
)
2056 if (!attribList
|| !attribList
[0]) {
2057 /* return list of all configs (per GLX_SGIX_fbconfig spec) */
2058 return Fake_glXGetFBConfigs(dpy
, screen
, nitems
);
2061 xmvis
= choose_visual(dpy
, screen
, attribList
, GL_TRUE
);
2063 GLXFBConfig
*config
= (GLXFBConfig
*) _mesa_malloc(sizeof(XMesaVisual
));
2069 config
[0] = (GLXFBConfig
) xmvis
;
2070 return (GLXFBConfig
*) config
;
2079 static XVisualInfo
*
2080 Fake_glXGetVisualFromFBConfig( Display
*dpy
, GLXFBConfig config
)
2082 if (dpy
&& config
) {
2083 XMesaVisual xmvis
= (XMesaVisual
) config
;
2085 return xmvis
->vishandle
;
2087 /* create a new vishandle - the cached one may be stale */
2088 xmvis
->vishandle
= (XVisualInfo
*) _mesa_malloc(sizeof(XVisualInfo
));
2089 if (xmvis
->vishandle
) {
2090 _mesa_memcpy(xmvis
->vishandle
, xmvis
->visinfo
, sizeof(XVisualInfo
));
2092 return xmvis
->vishandle
;
2102 Fake_glXCreateWindow( Display
*dpy
, GLXFBConfig config
, Window win
,
2103 const int *attribList
)
2105 XMesaVisual xmvis
= (XMesaVisual
) config
;
2110 xmbuf
= XMesaCreateWindowBuffer2(xmvis
, win
, NULL
);
2115 (void) attribList
; /* Ignored in GLX 1.3 */
2117 return win
; /* A hack for now */
2122 Fake_glXDestroyWindow( Display
*dpy
, GLXWindow window
)
2124 XMesaBuffer b
= XMesaFindBuffer(dpy
, (XMesaDrawable
) window
);
2126 XMesaDestroyBuffer(b
);
2127 /* don't destroy X window */
2133 Fake_glXCreatePixmap( Display
*dpy
, GLXFBConfig config
, Pixmap pixmap
,
2134 const int *attribList
)
2136 XMesaVisual v
= (XMesaVisual
) config
;
2142 (void) attribList
; /* Ignored in GLX 1.3 */
2144 if (!dpy
|| !config
|| !pixmap
)
2147 b
= XMesaCreatePixmapBuffer( v
, pixmap
, 0 );
2157 Fake_glXDestroyPixmap( Display
*dpy
, GLXPixmap pixmap
)
2159 XMesaBuffer b
= XMesaFindBuffer(dpy
, (XMesaDrawable
)pixmap
);
2161 XMesaDestroyBuffer(b
);
2162 /* don't destroy X pixmap */
2167 Fake_glXCreatePbuffer( Display
*dpy
, GLXFBConfig config
,
2168 const int *attribList
)
2170 XMesaVisual xmvis
= (XMesaVisual
) config
;
2173 int width
= 0, height
= 0;
2174 GLboolean useLargest
= GL_FALSE
, preserveContents
= GL_FALSE
;
2178 for (attrib
= attribList
; *attrib
; attrib
++) {
2180 case GLX_PBUFFER_WIDTH
:
2184 case GLX_PBUFFER_HEIGHT
:
2188 case GLX_PRESERVED_CONTENTS
:
2190 preserveContents
= *attrib
; /* ignored */
2192 case GLX_LARGEST_PBUFFER
:
2194 useLargest
= *attrib
; /* ignored */
2201 /* not used at this time */
2203 (void) preserveContents
;
2205 if (width
== 0 || height
== 0)
2208 xmbuf
= XMesaCreatePBuffer( xmvis
, 0, width
, height
);
2209 /* A GLXPbuffer handle must be an X Drawable because that's what
2210 * glXMakeCurrent takes.
2213 return (GLXPbuffer
) xmbuf
->frontxrb
->pixmap
;
2220 Fake_glXDestroyPbuffer( Display
*dpy
, GLXPbuffer pbuf
)
2222 XMesaBuffer b
= XMesaFindBuffer(dpy
, pbuf
);
2224 XMesaDestroyBuffer(b
);
2230 Fake_glXQueryDrawable( Display
*dpy
, GLXDrawable draw
, int attribute
,
2231 unsigned int *value
)
2233 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, draw
);
2237 switch (attribute
) {
2239 *value
= xmbuf
->mesa_buffer
.Width
;
2242 *value
= xmbuf
->mesa_buffer
.Height
;
2244 case GLX_PRESERVED_CONTENTS
:
2247 case GLX_LARGEST_PBUFFER
:
2248 *value
= xmbuf
->mesa_buffer
.Width
* xmbuf
->mesa_buffer
.Height
;
2250 case GLX_FBCONFIG_ID
:
2251 *value
= xmbuf
->xm_visual
->visinfo
->visualid
;
2254 return; /* GLX_BAD_ATTRIBUTE? */
2260 Fake_glXCreateNewContext( Display
*dpy
, GLXFBConfig config
,
2261 int renderType
, GLXContext shareList
, Bool direct
)
2263 struct fake_glx_context
*glxCtx
;
2264 struct fake_glx_context
*shareCtx
= (struct fake_glx_context
*) shareList
;
2265 XMesaVisual xmvis
= (XMesaVisual
) config
;
2267 if (!dpy
|| !config
||
2268 (renderType
!= GLX_RGBA_TYPE
&& renderType
!= GLX_COLOR_INDEX_TYPE
))
2271 glxCtx
= CALLOC_STRUCT(fake_glx_context
);
2275 /* deallocate unused windows/buffers */
2276 XMesaGarbageCollect();
2278 glxCtx
->xmesaContext
= XMesaCreateContext(xmvis
,
2279 shareCtx
? shareCtx
->xmesaContext
: NULL
);
2280 if (!glxCtx
->xmesaContext
) {
2285 glxCtx
->xmesaContext
->direct
= GL_FALSE
;
2286 glxCtx
->glxContext
.isDirect
= GL_FALSE
;
2287 glxCtx
->glxContext
.currentDpy
= dpy
;
2288 glxCtx
->glxContext
.xid
= (XID
) glxCtx
; /* self pointer */
2290 assert((void *) glxCtx
== (void *) &(glxCtx
->glxContext
));
2292 return (GLXContext
) glxCtx
;
2297 Fake_glXQueryContext( Display
*dpy
, GLXContext ctx
, int attribute
, int *value
)
2299 struct fake_glx_context
*glxCtx
= (struct fake_glx_context
*) ctx
;
2300 XMesaContext xmctx
= glxCtx
->xmesaContext
;
2305 switch (attribute
) {
2306 case GLX_FBCONFIG_ID
:
2307 *value
= xmctx
->xm_visual
->visinfo
->visualid
;
2309 case GLX_RENDER_TYPE
:
2310 if (xmctx
->xm_visual
->mesa_visual
.rgbMode
)
2311 *value
= GLX_RGBA_BIT
;
2313 *value
= GLX_COLOR_INDEX_BIT
;
2319 return GLX_BAD_ATTRIBUTE
;
2326 Fake_glXSelectEvent( Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
2328 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, drawable
);
2330 xmbuf
->selectedEvents
= mask
;
2335 Fake_glXGetSelectedEvent( Display
*dpy
, GLXDrawable drawable
,
2336 unsigned long *mask
)
2338 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, drawable
);
2340 *mask
= xmbuf
->selectedEvents
;
2347 /*** GLX_SGI_swap_control ***/
2350 Fake_glXSwapIntervalSGI(int interval
)
2358 /*** GLX_SGI_video_sync ***/
2360 static unsigned int FrameCounter
= 0;
2363 Fake_glXGetVideoSyncSGI(unsigned int *count
)
2365 /* this is a bogus implementation */
2366 *count
= FrameCounter
++;
2371 Fake_glXWaitVideoSyncSGI(int divisor
, int remainder
, unsigned int *count
)
2373 if (divisor
<= 0 || remainder
< 0)
2374 return GLX_BAD_VALUE
;
2375 /* this is a bogus implementation */
2377 while (FrameCounter
% divisor
!= remainder
)
2379 *count
= FrameCounter
;
2385 /*** GLX_SGI_make_current_read ***/
2388 Fake_glXMakeCurrentReadSGI(Display
*dpy
, GLXDrawable draw
, GLXDrawable read
, GLXContext ctx
)
2390 return Fake_glXMakeContextCurrent( dpy
, draw
, read
, ctx
);
2395 Fake_glXGetCurrentReadDrawableSGI(void)
2402 /*** GLX_SGIX_video_source ***/
2405 static GLXVideoSourceSGIX
2406 Fake_glXCreateGLXVideoSourceSGIX(Display
*dpy
, int screen
, VLServer server
, VLPath path
, int nodeClass
, VLNode drainNode
)
2418 Fake_glXDestroyGLXVideoSourceSGIX(Display
*dpy
, GLXVideoSourceSGIX src
)
2427 /*** GLX_EXT_import_context ***/
2430 Fake_glXFreeContextEXT(Display
*dpy
, GLXContext context
)
2437 Fake_glXGetContextIDEXT(const GLXContext context
)
2444 Fake_glXImportContextEXT(Display
*dpy
, GLXContextID contextID
)
2452 Fake_glXQueryContextInfoEXT(Display
*dpy
, GLXContext context
, int attribute
, int *value
)
2463 /*** GLX_SGIX_fbconfig ***/
2466 Fake_glXGetFBConfigAttribSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int attribute
, int *value
)
2468 return Fake_glXGetFBConfigAttrib(dpy
, config
, attribute
, value
);
2471 static GLXFBConfigSGIX
*
2472 Fake_glXChooseFBConfigSGIX(Display
*dpy
, int screen
, int *attrib_list
, int *nelements
)
2474 return (GLXFBConfig
*) Fake_glXChooseFBConfig(dpy
, screen
, attrib_list
, nelements
);
2479 Fake_glXCreateGLXPixmapWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, Pixmap pixmap
)
2481 XMesaVisual xmvis
= (XMesaVisual
) config
;
2482 XMesaBuffer xmbuf
= XMesaCreatePixmapBuffer(xmvis
, pixmap
, 0);
2483 return xmbuf
->frontxrb
->pixmap
; /* need to return an X ID */
2488 Fake_glXCreateContextWithConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
, int render_type
, GLXContext share_list
, Bool direct
)
2490 XMesaVisual xmvis
= (XMesaVisual
) config
;
2491 struct fake_glx_context
*glxCtx
;
2492 struct fake_glx_context
*shareCtx
= (struct fake_glx_context
*) share_list
;
2494 glxCtx
= CALLOC_STRUCT(fake_glx_context
);
2498 /* deallocate unused windows/buffers */
2499 XMesaGarbageCollect();
2501 glxCtx
->xmesaContext
= XMesaCreateContext(xmvis
,
2502 shareCtx
? shareCtx
->xmesaContext
: NULL
);
2503 if (!glxCtx
->xmesaContext
) {
2508 glxCtx
->xmesaContext
->direct
= GL_FALSE
;
2509 glxCtx
->glxContext
.isDirect
= GL_FALSE
;
2510 glxCtx
->glxContext
.currentDpy
= dpy
;
2511 glxCtx
->glxContext
.xid
= (XID
) glxCtx
; /* self pointer */
2513 assert((void *) glxCtx
== (void *) &(glxCtx
->glxContext
));
2515 return (GLXContext
) glxCtx
;
2519 static XVisualInfo
*
2520 Fake_glXGetVisualFromFBConfigSGIX(Display
*dpy
, GLXFBConfigSGIX config
)
2522 return Fake_glXGetVisualFromFBConfig(dpy
, config
);
2526 static GLXFBConfigSGIX
2527 Fake_glXGetFBConfigFromVisualSGIX(Display
*dpy
, XVisualInfo
*vis
)
2529 XMesaVisual xmvis
= find_glx_visual(dpy
, vis
);
2531 /* This visual wasn't found with glXChooseVisual() */
2532 xmvis
= create_glx_visual(dpy
, vis
);
2535 return (GLXFBConfigSGIX
) xmvis
;
2540 /*** GLX_SGIX_pbuffer ***/
2542 static GLXPbufferSGIX
2543 Fake_glXCreateGLXPbufferSGIX(Display
*dpy
, GLXFBConfigSGIX config
,
2544 unsigned int width
, unsigned int height
,
2547 XMesaVisual xmvis
= (XMesaVisual
) config
;
2550 GLboolean useLargest
= GL_FALSE
, preserveContents
= GL_FALSE
;
2554 for (attrib
= attribList
; attrib
&& *attrib
; attrib
++) {
2556 case GLX_PRESERVED_CONTENTS_SGIX
:
2558 preserveContents
= *attrib
; /* ignored */
2560 case GLX_LARGEST_PBUFFER_SGIX
:
2562 useLargest
= *attrib
; /* ignored */
2569 /* not used at this time */
2571 (void) preserveContents
;
2573 xmbuf
= XMesaCreatePBuffer( xmvis
, 0, width
, height
);
2574 /* A GLXPbuffer handle must be an X Drawable because that's what
2575 * glXMakeCurrent takes.
2577 return (GLXPbuffer
) xmbuf
->frontxrb
->pixmap
;
2582 Fake_glXDestroyGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
)
2584 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, pbuf
);
2586 XMesaDestroyBuffer(xmbuf
);
2592 Fake_glXQueryGLXPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuf
, int attribute
, unsigned int *value
)
2594 const XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, pbuf
);
2597 /* Generate GLXBadPbufferSGIX for bad pbuffer */
2601 switch (attribute
) {
2602 case GLX_PRESERVED_CONTENTS_SGIX
:
2605 case GLX_LARGEST_PBUFFER_SGIX
:
2606 *value
= xmbuf
->mesa_buffer
.Width
* xmbuf
->mesa_buffer
.Height
;
2608 case GLX_WIDTH_SGIX
:
2609 *value
= xmbuf
->mesa_buffer
.Width
;
2611 case GLX_HEIGHT_SGIX
:
2612 *value
= xmbuf
->mesa_buffer
.Height
;
2614 case GLX_EVENT_MASK_SGIX
:
2615 *value
= 0; /* XXX might be wrong */
2625 Fake_glXSelectEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long mask
)
2627 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, drawable
);
2629 /* Note: we'll never generate clobber events */
2630 xmbuf
->selectedEvents
= mask
;
2636 Fake_glXGetSelectedEventSGIX(Display
*dpy
, GLXDrawable drawable
, unsigned long *mask
)
2638 XMesaBuffer xmbuf
= XMesaFindBuffer(dpy
, drawable
);
2640 *mask
= xmbuf
->selectedEvents
;
2649 /*** GLX_SGI_cushion ***/
2652 Fake_glXCushionSGI(Display
*dpy
, Window win
, float cushion
)
2661 /*** GLX_SGIX_video_resize ***/
2664 Fake_glXBindChannelToWindowSGIX(Display
*dpy
, int screen
, int channel
, Window window
)
2674 Fake_glXChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int x
, int y
, int w
, int h
)
2687 Fake_glXQueryChannelRectSGIX(Display
*dpy
, int screen
, int channel
, int *x
, int *y
, int *w
, int *h
)
2700 Fake_glXQueryChannelDeltasSGIX(Display
*dpy
, int screen
, int channel
, int *dx
, int *dy
, int *dw
, int *dh
)
2713 Fake_glXChannelRectSyncSGIX(Display
*dpy
, int screen
, int channel
, GLenum synctype
)
2724 /*** GLX_SGIX_dmbuffer **/
2726 #if defined(_DM_BUFFER_H_)
2728 Fake_glXAssociateDMPbufferSGIX(Display
*dpy
, GLXPbufferSGIX pbuffer
, DMparams
*params
, DMbuffer dmbuffer
)
2739 /*** GLX_SGIX_swap_group ***/
2742 Fake_glXJoinSwapGroupSGIX(Display
*dpy
, GLXDrawable drawable
, GLXDrawable member
)
2751 /*** GLX_SGIX_swap_barrier ***/
2754 Fake_glXBindSwapBarrierSGIX(Display
*dpy
, GLXDrawable drawable
, int barrier
)
2762 Fake_glXQueryMaxSwapBarriersSGIX(Display
*dpy
, int screen
, int *max
)
2772 /*** GLX_SUN_get_transparent_index ***/
2775 Fake_glXGetTransparentIndexSUN(Display
*dpy
, Window overlay
, Window underlay
, long *pTransparent
)
2780 (void) pTransparent
;
2786 /*** GLX_MESA_release_buffers ***/
2789 * Release the depth, stencil, accum buffers attached to a GLXDrawable
2790 * (a window or pixmap) prior to destroying the GLXDrawable.
2793 Fake_glXReleaseBuffersMESA( Display
*dpy
, GLXDrawable d
)
2795 XMesaBuffer b
= XMesaFindBuffer(dpy
, d
);
2797 XMesaDestroyBuffer(b
);
2805 /*** GLX_MESA_set_3dfx_mode ***/
2808 Fake_glXSet3DfxModeMESA( int mode
)
2810 return XMesaSetFXmode( mode
);
2815 /*** GLX_NV_vertex_array range ***/
2817 Fake_glXAllocateMemoryNV( GLsizei size
,
2818 GLfloat readFrequency
,
2819 GLfloat writeFrequency
,
2823 (void) readFrequency
;
2824 (void) writeFrequency
;
2831 Fake_glXFreeMemoryNV( GLvoid
*pointer
)
2837 /*** GLX_MESA_agp_offset ***/
2840 Fake_glXGetAGPOffsetMESA( const GLvoid
*pointer
)
2847 /* silence warning */
2848 extern struct _glxapi_table
*_mesa_GetGLXDispatchTable(void);
2852 * Create a new GLX API dispatch table with its function pointers
2853 * initialized to point to Mesa's "fake" GLX API functions.
2854 * Note: there's a similar function (_real_GetGLXDispatchTable) that
2855 * returns a new dispatch table with all pointers initalized to point
2856 * to "real" GLX functions (which understand GLX wire protocol, etc).
2858 struct _glxapi_table
*
2859 _mesa_GetGLXDispatchTable(void)
2861 static struct _glxapi_table glx
;
2863 /* be sure our dispatch table size <= libGL's table */
2865 GLuint size
= sizeof(struct _glxapi_table
) / sizeof(void *);
2867 assert(_glxapi_get_dispatch_table_size() >= size
);
2870 /* initialize the whole table to no-ops */
2871 _glxapi_set_no_op_table(&glx
);
2873 /* now initialize the table with the functions I implement */
2874 glx
.ChooseVisual
= Fake_glXChooseVisual
;
2875 glx
.CopyContext
= Fake_glXCopyContext
;
2876 glx
.CreateContext
= Fake_glXCreateContext
;
2877 glx
.CreateGLXPixmap
= Fake_glXCreateGLXPixmap
;
2878 glx
.DestroyContext
= Fake_glXDestroyContext
;
2879 glx
.DestroyGLXPixmap
= Fake_glXDestroyGLXPixmap
;
2880 glx
.GetConfig
= Fake_glXGetConfig
;
2881 /*glx.GetCurrentContext = Fake_glXGetCurrentContext;*/
2882 /*glx.GetCurrentDrawable = Fake_glXGetCurrentDrawable;*/
2883 glx
.IsDirect
= Fake_glXIsDirect
;
2884 glx
.MakeCurrent
= Fake_glXMakeCurrent
;
2885 glx
.QueryExtension
= Fake_glXQueryExtension
;
2886 glx
.QueryVersion
= Fake_glXQueryVersion
;
2887 glx
.SwapBuffers
= Fake_glXSwapBuffers
;
2888 glx
.UseXFont
= Fake_glXUseXFont
;
2889 glx
.WaitGL
= Fake_glXWaitGL
;
2890 glx
.WaitX
= Fake_glXWaitX
;
2892 /*** GLX_VERSION_1_1 ***/
2893 glx
.GetClientString
= Fake_glXGetClientString
;
2894 glx
.QueryExtensionsString
= Fake_glXQueryExtensionsString
;
2895 glx
.QueryServerString
= Fake_glXQueryServerString
;
2897 /*** GLX_VERSION_1_2 ***/
2898 /*glx.GetCurrentDisplay = Fake_glXGetCurrentDisplay;*/
2900 /*** GLX_VERSION_1_3 ***/
2901 glx
.ChooseFBConfig
= Fake_glXChooseFBConfig
;
2902 glx
.CreateNewContext
= Fake_glXCreateNewContext
;
2903 glx
.CreatePbuffer
= Fake_glXCreatePbuffer
;
2904 glx
.CreatePixmap
= Fake_glXCreatePixmap
;
2905 glx
.CreateWindow
= Fake_glXCreateWindow
;
2906 glx
.DestroyPbuffer
= Fake_glXDestroyPbuffer
;
2907 glx
.DestroyPixmap
= Fake_glXDestroyPixmap
;
2908 glx
.DestroyWindow
= Fake_glXDestroyWindow
;
2909 /*glx.GetCurrentReadDrawable = Fake_glXGetCurrentReadDrawable;*/
2910 glx
.GetFBConfigAttrib
= Fake_glXGetFBConfigAttrib
;
2911 glx
.GetFBConfigs
= Fake_glXGetFBConfigs
;
2912 glx
.GetSelectedEvent
= Fake_glXGetSelectedEvent
;
2913 glx
.GetVisualFromFBConfig
= Fake_glXGetVisualFromFBConfig
;
2914 glx
.MakeContextCurrent
= Fake_glXMakeContextCurrent
;
2915 glx
.QueryContext
= Fake_glXQueryContext
;
2916 glx
.QueryDrawable
= Fake_glXQueryDrawable
;
2917 glx
.SelectEvent
= Fake_glXSelectEvent
;
2919 /*** GLX_SGI_swap_control ***/
2920 glx
.SwapIntervalSGI
= Fake_glXSwapIntervalSGI
;
2922 /*** GLX_SGI_video_sync ***/
2923 glx
.GetVideoSyncSGI
= Fake_glXGetVideoSyncSGI
;
2924 glx
.WaitVideoSyncSGI
= Fake_glXWaitVideoSyncSGI
;
2926 /*** GLX_SGI_make_current_read ***/
2927 glx
.MakeCurrentReadSGI
= Fake_glXMakeCurrentReadSGI
;
2928 /*glx.GetCurrentReadDrawableSGI = Fake_glXGetCurrentReadDrawableSGI;*/
2930 /*** GLX_SGIX_video_source ***/
2932 glx
.CreateGLXVideoSourceSGIX
= Fake_glXCreateGLXVideoSourceSGIX
;
2933 glx
.DestroyGLXVideoSourceSGIX
= Fake_glXDestroyGLXVideoSourceSGIX
;
2936 /*** GLX_EXT_import_context ***/
2937 glx
.FreeContextEXT
= Fake_glXFreeContextEXT
;
2938 glx
.GetContextIDEXT
= Fake_glXGetContextIDEXT
;
2939 /*glx.GetCurrentDisplayEXT = Fake_glXGetCurrentDisplayEXT;*/
2940 glx
.ImportContextEXT
= Fake_glXImportContextEXT
;
2941 glx
.QueryContextInfoEXT
= Fake_glXQueryContextInfoEXT
;
2943 /*** GLX_SGIX_fbconfig ***/
2944 glx
.GetFBConfigAttribSGIX
= Fake_glXGetFBConfigAttribSGIX
;
2945 glx
.ChooseFBConfigSGIX
= Fake_glXChooseFBConfigSGIX
;
2946 glx
.CreateGLXPixmapWithConfigSGIX
= Fake_glXCreateGLXPixmapWithConfigSGIX
;
2947 glx
.CreateContextWithConfigSGIX
= Fake_glXCreateContextWithConfigSGIX
;
2948 glx
.GetVisualFromFBConfigSGIX
= Fake_glXGetVisualFromFBConfigSGIX
;
2949 glx
.GetFBConfigFromVisualSGIX
= Fake_glXGetFBConfigFromVisualSGIX
;
2951 /*** GLX_SGIX_pbuffer ***/
2952 glx
.CreateGLXPbufferSGIX
= Fake_glXCreateGLXPbufferSGIX
;
2953 glx
.DestroyGLXPbufferSGIX
= Fake_glXDestroyGLXPbufferSGIX
;
2954 glx
.QueryGLXPbufferSGIX
= Fake_glXQueryGLXPbufferSGIX
;
2955 glx
.SelectEventSGIX
= Fake_glXSelectEventSGIX
;
2956 glx
.GetSelectedEventSGIX
= Fake_glXGetSelectedEventSGIX
;
2958 /*** GLX_SGI_cushion ***/
2959 glx
.CushionSGI
= Fake_glXCushionSGI
;
2961 /*** GLX_SGIX_video_resize ***/
2962 glx
.BindChannelToWindowSGIX
= Fake_glXBindChannelToWindowSGIX
;
2963 glx
.ChannelRectSGIX
= Fake_glXChannelRectSGIX
;
2964 glx
.QueryChannelRectSGIX
= Fake_glXQueryChannelRectSGIX
;
2965 glx
.QueryChannelDeltasSGIX
= Fake_glXQueryChannelDeltasSGIX
;
2966 glx
.ChannelRectSyncSGIX
= Fake_glXChannelRectSyncSGIX
;
2968 /*** GLX_SGIX_dmbuffer **/
2969 #if defined(_DM_BUFFER_H_)
2970 glx
.AssociateDMPbufferSGIX
= NULL
;
2973 /*** GLX_SGIX_swap_group ***/
2974 glx
.JoinSwapGroupSGIX
= Fake_glXJoinSwapGroupSGIX
;
2976 /*** GLX_SGIX_swap_barrier ***/
2977 glx
.BindSwapBarrierSGIX
= Fake_glXBindSwapBarrierSGIX
;
2978 glx
.QueryMaxSwapBarriersSGIX
= Fake_glXQueryMaxSwapBarriersSGIX
;
2980 /*** GLX_SUN_get_transparent_index ***/
2981 glx
.GetTransparentIndexSUN
= Fake_glXGetTransparentIndexSUN
;
2983 /*** GLX_MESA_copy_sub_buffer ***/
2984 glx
.CopySubBufferMESA
= Fake_glXCopySubBufferMESA
;
2986 /*** GLX_MESA_release_buffers ***/
2987 glx
.ReleaseBuffersMESA
= Fake_glXReleaseBuffersMESA
;
2989 /*** GLX_MESA_pixmap_colormap ***/
2990 glx
.CreateGLXPixmapMESA
= Fake_glXCreateGLXPixmapMESA
;
2992 /*** GLX_MESA_set_3dfx_mode ***/
2993 glx
.Set3DfxModeMESA
= Fake_glXSet3DfxModeMESA
;
2995 /*** GLX_NV_vertex_array_range ***/
2996 glx
.AllocateMemoryNV
= Fake_glXAllocateMemoryNV
;
2997 glx
.FreeMemoryNV
= Fake_glXFreeMemoryNV
;
2999 /*** GLX_MESA_agp_offset ***/
3000 glx
.GetAGPOffsetMESA
= Fake_glXGetAGPOffsetMESA
;