jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Mesa 3-D graphics library |
Brian Paul | be2de8b | 2004-11-25 23:25:33 +0000 | [diff] [blame] | 3 | * Version: 6.3 |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 4 | * |
Brian Paul | 3a99674 | 2004-02-02 15:40:21 +0000 | [diff] [blame] | 5 | * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 6 | * |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 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: |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 13 | * |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 14 | * The above copyright notice and this permission notice shall be included |
| 15 | * in all copies or substantial portions of the Software. |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 16 | * |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 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. |
| 23 | */ |
| 24 | |
| 25 | |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 26 | /* |
Brian Paul | 36cfa38 | 1999-11-28 20:15:04 +0000 | [diff] [blame] | 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. |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 29 | * |
| 30 | * Thanks to the contributors: |
| 31 | * |
Brian Paul | ddf69f2 | 2000-08-02 20:35:09 +0000 | [diff] [blame] | 32 | * Initial version: Philip Brown (phil@bolthole.com) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 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). |
| 36 | * |
| 37 | * Notes: |
| 38 | * Don't be fooled, stereo isn't supported yet. |
| 39 | */ |
| 40 | |
| 41 | |
| 42 | |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 43 | #include "glxheader.h" |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 44 | #include "glxapi.h" |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 45 | #include "GL/xmesa.h" |
| 46 | #include "context.h" |
| 47 | #include "config.h" |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 48 | #include "macros.h" |
Brian Paul | 3c63452 | 2002-10-24 23:57:19 +0000 | [diff] [blame] | 49 | #include "imports.h" |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 50 | #include "mtypes.h" |
Brian Paul | 2c5f937 | 2003-05-27 21:24:40 +0000 | [diff] [blame] | 51 | #include "version.h" |
Brian Paul | 71dea34 | 2000-04-19 01:44:01 +0000 | [diff] [blame] | 52 | #include "xfonts.h" |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 53 | #include "xmesaP.h" |
| 54 | |
| 55 | |
Brian Paul | 78fc78e | 1999-11-22 22:17:06 +0000 | [diff] [blame] | 56 | /* This indicates the client-side GLX API and GLX encoder version. */ |
| 57 | #define CLIENT_MAJOR_VERSION 1 |
Brian Paul | a573803 | 2001-09-23 16:10:02 +0000 | [diff] [blame] | 58 | #define CLIENT_MINOR_VERSION 4 /* but don't have 1.3's pbuffers, etc yet */ |
Brian Paul | 78fc78e | 1999-11-22 22:17:06 +0000 | [diff] [blame] | 59 | |
| 60 | /* This indicates the server-side GLX decoder version. |
Brian Paul | ba57e52 | 2001-09-14 02:43:03 +0000 | [diff] [blame] | 61 | * GLX 1.4 indicates OpenGL 1.3 support |
Brian Paul | 78fc78e | 1999-11-22 22:17:06 +0000 | [diff] [blame] | 62 | */ |
| 63 | #define SERVER_MAJOR_VERSION 1 |
Brian Paul | ba57e52 | 2001-09-14 02:43:03 +0000 | [diff] [blame] | 64 | #define SERVER_MINOR_VERSION 4 |
Brian Paul | 78fc78e | 1999-11-22 22:17:06 +0000 | [diff] [blame] | 65 | |
| 66 | /* This is appended onto the glXGetClient/ServerString version strings. */ |
Brian Paul | 2c5f937 | 2003-05-27 21:24:40 +0000 | [diff] [blame] | 67 | #define MESA_GLX_VERSION "Mesa " MESA_VERSION_STRING |
Brian Paul | 78fc78e | 1999-11-22 22:17:06 +0000 | [diff] [blame] | 68 | |
| 69 | /* Who implemented this GLX? */ |
| 70 | #define VENDOR "Brian Paul" |
| 71 | |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 72 | #define EXTENSIONS \ |
| 73 | "GLX_MESA_set_3dfx_mode " \ |
| 74 | "GLX_MESA_copy_sub_buffer " \ |
| 75 | "GLX_MESA_pixmap_colormap " \ |
| 76 | "GLX_MESA_release_buffers " \ |
| 77 | "GLX_ARB_get_proc_address " \ |
| 78 | "GLX_EXT_visual_info " \ |
| 79 | "GLX_EXT_visual_rating " \ |
| 80 | "GLX_SGI_video_sync " \ |
| 81 | "GLX_SGIX_fbconfig " \ |
Brian Paul | 6d6efd6 | 2003-03-24 23:41:10 +0000 | [diff] [blame] | 82 | "GLX_SGIX_pbuffer " |
Brian Paul | 43c9c2c | 1999-09-16 15:52:51 +0000 | [diff] [blame] | 83 | |
Brian Paul | 7cf50e1 | 2001-05-24 19:06:21 +0000 | [diff] [blame] | 84 | /* |
| 85 | * Our fake GLX context will contain a "real" GLX context and an XMesa context. |
| 86 | * |
| 87 | * Note that a pointer to a __GLXcontext is a pointer to a fake_glx_context, |
| 88 | * and vice versa. |
| 89 | * |
| 90 | * We really just need this structure in order to make the libGL functions |
| 91 | * glXGetCurrentContext(), glXGetCurrentDrawable() and glXGetCurrentDisplay() |
| 92 | * work correctly. |
| 93 | */ |
| 94 | struct fake_glx_context { |
| 95 | __GLXcontext glxContext; /* this MUST be first! */ |
| 96 | XMesaContext xmesaContext; |
| 97 | }; |
| 98 | |
| 99 | |
| 100 | |
| 101 | /**********************************************************************/ |
| 102 | /*** GLX Visual Code ***/ |
| 103 | /**********************************************************************/ |
Brian Paul | 43c9c2c | 1999-09-16 15:52:51 +0000 | [diff] [blame] | 104 | |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 105 | #define DONT_CARE -1 |
| 106 | |
| 107 | |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 108 | #define MAX_VISUALS 100 |
| 109 | static XMesaVisual VisualTable[MAX_VISUALS]; |
| 110 | static int NumVisuals = 0; |
| 111 | |
| 112 | |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 113 | /* |
| 114 | * This struct and some code fragments borrowed |
| 115 | * from Mark Kilgard's GLUT library. |
| 116 | */ |
| 117 | typedef struct _OverlayInfo { |
| 118 | /* Avoid 64-bit portability problems by being careful to use |
| 119 | longs due to the way XGetWindowProperty is specified. Note |
| 120 | that these parameters are passed as CARD32s over X |
| 121 | protocol. */ |
| 122 | unsigned long overlay_visual; |
| 123 | long transparent_type; |
| 124 | long value; |
| 125 | long layer; |
| 126 | } OverlayInfo; |
| 127 | |
| 128 | |
| 129 | |
| 130 | /* Macro to handle c_class vs class field name in XVisualInfo struct */ |
| 131 | #if defined(__cplusplus) || defined(c_plusplus) |
| 132 | #define CLASS c_class |
| 133 | #else |
| 134 | #define CLASS class |
| 135 | #endif |
| 136 | |
| 137 | |
| 138 | |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 139 | /* |
| 140 | * Test if the given XVisualInfo is usable for Mesa rendering. |
| 141 | */ |
Brian Paul | 7287bbf | 2004-09-23 17:30:54 +0000 | [diff] [blame] | 142 | static GLboolean |
| 143 | is_usable_visual( XVisualInfo *vinfo ) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 144 | { |
| 145 | switch (vinfo->CLASS) { |
| 146 | case StaticGray: |
| 147 | case GrayScale: |
| 148 | /* Any StaticGray/GrayScale visual works in RGB or CI mode */ |
| 149 | return GL_TRUE; |
| 150 | case StaticColor: |
| 151 | case PseudoColor: |
| 152 | /* Any StaticColor/PseudoColor visual of at least 4 bits */ |
| 153 | if (vinfo->depth>=4) { |
| 154 | return GL_TRUE; |
| 155 | } |
| 156 | else { |
| 157 | return GL_FALSE; |
| 158 | } |
| 159 | case TrueColor: |
| 160 | case DirectColor: |
| 161 | /* Any depth of TrueColor or DirectColor works in RGB mode */ |
| 162 | return GL_TRUE; |
| 163 | default: |
| 164 | /* This should never happen */ |
| 165 | return GL_FALSE; |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | |
| 170 | |
Brian Paul | 1d97c27 | 2004-11-27 16:49:52 +0000 | [diff] [blame^] | 171 | /** |
| 172 | * Get an array OverlayInfo records for specified screen. |
| 173 | * \param dpy the display |
| 174 | * \param screen screen number |
| 175 | * \param numOverlays returns numver of OverlayInfo records |
| 176 | * \return pointer to OverlayInfo array, free with XFree() |
| 177 | */ |
| 178 | static OverlayInfo * |
| 179 | GetOverlayInfo(Display *dpy, int screen, int *numOverlays) |
| 180 | { |
| 181 | Atom overlayVisualsAtom; |
| 182 | Atom actualType; |
| 183 | Status status; |
| 184 | unsigned char *ovInfo; |
| 185 | unsigned long sizeData, bytesLeft; |
| 186 | int actualFormat; |
| 187 | |
| 188 | /* |
| 189 | * The SERVER_OVERLAY_VISUALS property on the root window contains |
| 190 | * a list of overlay visuals. Get that list now. |
| 191 | */ |
| 192 | overlayVisualsAtom = XInternAtom(dpy,"SERVER_OVERLAY_VISUALS", True); |
| 193 | if (overlayVisualsAtom == None) { |
| 194 | return 0; |
| 195 | } |
| 196 | |
| 197 | status = XGetWindowProperty(dpy, RootWindow(dpy, screen), |
| 198 | overlayVisualsAtom, 0L, (long) 10000, False, |
| 199 | overlayVisualsAtom, &actualType, &actualFormat, |
| 200 | &sizeData, &bytesLeft, |
| 201 | &ovInfo); |
| 202 | |
| 203 | if (status != Success || actualType != overlayVisualsAtom || |
| 204 | actualFormat != 32 || sizeData < 4) { |
| 205 | /* something went wrong */ |
| 206 | XFree((void *) ovInfo); |
| 207 | *numOverlays = 0; |
| 208 | return NULL; |
| 209 | } |
| 210 | |
| 211 | *numOverlays = sizeData / 4; |
| 212 | return (OverlayInfo *) ovInfo; |
| 213 | } |
| 214 | |
| 215 | |
| 216 | |
| 217 | /** |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 218 | * Return the level (overlay, normal, underlay) of a given XVisualInfo. |
| 219 | * Input: dpy - the X display |
| 220 | * vinfo - the XVisualInfo to test |
| 221 | * Return: level of the visual: |
| 222 | * 0 = normal planes |
| 223 | * >0 = overlay planes |
| 224 | * <0 = underlay planes |
| 225 | */ |
Brian Paul | 7287bbf | 2004-09-23 17:30:54 +0000 | [diff] [blame] | 226 | static int |
| 227 | level_of_visual( Display *dpy, XVisualInfo *vinfo ) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 228 | { |
Brian Paul | 1d97c27 | 2004-11-27 16:49:52 +0000 | [diff] [blame^] | 229 | OverlayInfo *overlay_info; |
| 230 | int numOverlaysPerScreen, i; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 231 | |
Brian Paul | 1d97c27 | 2004-11-27 16:49:52 +0000 | [diff] [blame^] | 232 | overlay_info = GetOverlayInfo(dpy, vinfo->screen, &numOverlaysPerScreen); |
| 233 | if (!overlay_info) { |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 234 | return 0; |
| 235 | } |
| 236 | |
| 237 | /* search the overlay visual list for the visual ID of interest */ |
Brian Paul | 1d97c27 | 2004-11-27 16:49:52 +0000 | [diff] [blame^] | 238 | for (i = 0; i < numOverlaysPerScreen; i++) { |
| 239 | const OverlayInfo *ov = overlay_info + i; |
| 240 | if (ov->overlay_visual == vinfo->visualid) { |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 241 | /* found the visual */ |
| 242 | if (/*ov->transparent_type==1 &&*/ ov->layer!=0) { |
| 243 | int level = ov->layer; |
| 244 | XFree((void *) overlay_info); |
| 245 | return level; |
| 246 | } |
| 247 | else { |
| 248 | XFree((void *) overlay_info); |
| 249 | return 0; |
| 250 | } |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | /* The visual ID was not found in the overlay list. */ |
| 255 | XFree((void *) overlay_info); |
| 256 | return 0; |
| 257 | } |
| 258 | |
| 259 | |
| 260 | |
| 261 | |
| 262 | /* |
| 263 | * Given an XVisualInfo and RGB, Double, and Depth buffer flags, save the |
| 264 | * configuration in our list of GLX visuals. |
| 265 | */ |
| 266 | static XMesaVisual |
| 267 | save_glx_visual( Display *dpy, XVisualInfo *vinfo, |
| 268 | GLboolean rgbFlag, GLboolean alphaFlag, GLboolean dbFlag, |
| 269 | GLboolean stereoFlag, |
| 270 | GLint depth_size, GLint stencil_size, |
Brian Paul | b2e4600 | 2000-03-31 01:07:13 +0000 | [diff] [blame] | 271 | GLint accumRedSize, GLint accumGreenSize, |
| 272 | GLint accumBlueSize, GLint accumAlphaSize, |
Brian Paul | 894844a | 2004-03-21 17:05:03 +0000 | [diff] [blame] | 273 | GLint level, GLint numAuxBuffers ) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 274 | { |
| 275 | GLboolean ximageFlag = GL_TRUE; |
| 276 | XMesaVisual xmvis; |
| 277 | GLint i; |
| 278 | GLboolean comparePointers; |
| 279 | |
| 280 | if (dbFlag) { |
| 281 | /* Check if the MESA_BACK_BUFFER env var is set */ |
Brian Paul | 367d308 | 2002-10-25 21:06:26 +0000 | [diff] [blame] | 282 | char *backbuffer = _mesa_getenv("MESA_BACK_BUFFER"); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 283 | if (backbuffer) { |
| 284 | if (backbuffer[0]=='p' || backbuffer[0]=='P') { |
| 285 | ximageFlag = GL_FALSE; |
| 286 | } |
| 287 | else if (backbuffer[0]=='x' || backbuffer[0]=='X') { |
| 288 | ximageFlag = GL_TRUE; |
| 289 | } |
| 290 | else { |
Brian Paul | d09a1d8 | 2002-06-13 04:49:17 +0000 | [diff] [blame] | 291 | _mesa_warning(NULL, "Mesa: invalid value for MESA_BACK_BUFFER environment variable, using an XImage."); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 292 | } |
| 293 | } |
| 294 | } |
| 295 | |
| 296 | /* Comparing IDs uses less memory but sometimes fails. */ |
| 297 | /* XXX revisit this after 3.0 is finished. */ |
Brian Paul | 367d308 | 2002-10-25 21:06:26 +0000 | [diff] [blame] | 298 | if (_mesa_getenv("MESA_GLX_VISUAL_HACK")) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 299 | comparePointers = GL_TRUE; |
| 300 | else |
| 301 | comparePointers = GL_FALSE; |
| 302 | |
Brian Paul | a13331d | 2004-07-23 15:47:04 +0000 | [diff] [blame] | 303 | /* Force the visual to have an alpha channel */ |
| 304 | if (rgbFlag && _mesa_getenv("MESA_GLX_FORCE_ALPHA")) |
| 305 | alphaFlag = GL_TRUE; |
| 306 | |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 307 | /* First check if a matching visual is already in the list */ |
| 308 | for (i=0; i<NumVisuals; i++) { |
| 309 | XMesaVisual v = VisualTable[i]; |
| 310 | if (v->display == dpy |
Ian Romanick | 304d3aa | 2004-02-19 00:57:04 +0000 | [diff] [blame] | 311 | && v->mesa_visual.level == level |
Brian Paul | 894844a | 2004-03-21 17:05:03 +0000 | [diff] [blame] | 312 | && v->mesa_visual.numAuxBuffers == numAuxBuffers |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 313 | && v->ximage_flag == ximageFlag |
Brian Paul | 1832f1c | 2001-04-27 21:18:25 +0000 | [diff] [blame] | 314 | && v->mesa_visual.rgbMode == rgbFlag |
| 315 | && v->mesa_visual.doubleBufferMode == dbFlag |
| 316 | && v->mesa_visual.stereoMode == stereoFlag |
| 317 | && (v->mesa_visual.alphaBits > 0) == alphaFlag |
| 318 | && (v->mesa_visual.depthBits >= depth_size || depth_size == 0) |
| 319 | && (v->mesa_visual.stencilBits >= stencil_size || stencil_size == 0) |
| 320 | && (v->mesa_visual.accumRedBits >= accumRedSize || accumRedSize == 0) |
| 321 | && (v->mesa_visual.accumGreenBits >= accumGreenSize || accumGreenSize == 0) |
| 322 | && (v->mesa_visual.accumBlueBits >= accumBlueSize || accumBlueSize == 0) |
| 323 | && (v->mesa_visual.accumAlphaBits >= accumAlphaSize || accumAlphaSize == 0)) { |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 324 | /* now either compare XVisualInfo pointers or visual IDs */ |
Brian Paul | d0247f5 | 1999-11-18 15:17:01 +0000 | [diff] [blame] | 325 | if ((!comparePointers && v->visinfo->visualid == vinfo->visualid) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 326 | || (comparePointers && v->vishandle == vinfo)) { |
| 327 | return v; |
| 328 | } |
| 329 | } |
| 330 | } |
| 331 | |
| 332 | /* Create a new visual and add it to the list. */ |
| 333 | |
Brian Paul | d09a1d8 | 2002-06-13 04:49:17 +0000 | [diff] [blame] | 334 | if (NumVisuals >= MAX_VISUALS) { |
| 335 | _mesa_problem(NULL, "GLX Error: maximum number of visuals exceeded"); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 336 | return NULL; |
| 337 | } |
| 338 | |
Brian Paul | c8735e8 | 2000-04-05 22:09:58 +0000 | [diff] [blame] | 339 | xmvis = XMesaCreateVisual( dpy, vinfo, rgbFlag, alphaFlag, dbFlag, |
| 340 | stereoFlag, ximageFlag, |
| 341 | depth_size, stencil_size, |
| 342 | accumRedSize, accumBlueSize, |
| 343 | accumBlueSize, accumAlphaSize, 0, level, |
| 344 | GLX_NONE_EXT ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 345 | if (xmvis) { |
Brian Paul | f104619 | 2002-11-10 17:07:06 +0000 | [diff] [blame] | 346 | /* Save a copy of the pointer now so we can find this visual again |
| 347 | * if we need to search for it in find_glx_visual(). |
| 348 | */ |
| 349 | xmvis->vishandle = vinfo; |
| 350 | /* add xmvis to the list */ |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 351 | VisualTable[NumVisuals] = xmvis; |
| 352 | NumVisuals++; |
Brian Paul | 7287bbf | 2004-09-23 17:30:54 +0000 | [diff] [blame] | 353 | /* XXX minor hack, because XMesaCreateVisual doesn't support an |
| 354 | * aux buffers parameter. |
| 355 | */ |
Brian Paul | 894844a | 2004-03-21 17:05:03 +0000 | [diff] [blame] | 356 | xmvis->mesa_visual.numAuxBuffers = numAuxBuffers; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 357 | } |
| 358 | return xmvis; |
| 359 | } |
| 360 | |
| 361 | |
Brian Paul | dfa5c2b | 2004-07-23 23:32:15 +0000 | [diff] [blame] | 362 | /** |
| 363 | * Return the default number of bits for the Z buffer. |
| 364 | * If defined, use the MESA_GLX_DEPTH_BITS env var value. |
| 365 | * Otherwise, use the DEFAULT_SOFTWARE_DEPTH_BITS constant. |
| 366 | * XXX probably do the same thing for stencil, accum, etc. |
| 367 | */ |
| 368 | static GLint |
| 369 | default_depth_bits(void) |
| 370 | { |
| 371 | int zBits; |
| 372 | const char *zEnv = _mesa_getenv("MESA_GLX_DEPTH_BITS"); |
| 373 | if (zEnv) |
| 374 | zBits = _mesa_atoi(zEnv); |
| 375 | else |
| 376 | zBits = DEFAULT_SOFTWARE_DEPTH_BITS; |
| 377 | return zBits; |
| 378 | } |
| 379 | |
| 380 | |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 381 | |
| 382 | /* |
| 383 | * Create a GLX visual from a regular XVisualInfo. |
Brian Paul | ed30dfa | 2000-03-03 17:47:39 +0000 | [diff] [blame] | 384 | * This is called when Fake GLX is given an XVisualInfo which wasn't |
| 385 | * returned by glXChooseVisual. Since this is the first time we're |
| 386 | * considering this visual we'll take a guess at reasonable values |
| 387 | * for depth buffer size, stencil size, accum size, etc. |
| 388 | * This is the best we can do with a client-side emulation of GLX. |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 389 | */ |
| 390 | static XMesaVisual |
| 391 | create_glx_visual( Display *dpy, XVisualInfo *visinfo ) |
| 392 | { |
| 393 | int vislevel; |
Brian Paul | dfa5c2b | 2004-07-23 23:32:15 +0000 | [diff] [blame] | 394 | GLint zBits = default_depth_bits(); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 395 | |
| 396 | vislevel = level_of_visual( dpy, visinfo ); |
| 397 | if (vislevel) { |
| 398 | /* Configure this visual as a CI, single-buffered overlay */ |
| 399 | return save_glx_visual( dpy, visinfo, |
| 400 | GL_FALSE, /* rgb */ |
| 401 | GL_FALSE, /* alpha */ |
| 402 | GL_FALSE, /* double */ |
| 403 | GL_FALSE, /* stereo */ |
| 404 | 0, /* depth bits */ |
| 405 | 0, /* stencil bits */ |
Brian Paul | b2e4600 | 2000-03-31 01:07:13 +0000 | [diff] [blame] | 406 | 0,0,0,0, /* accum bits */ |
Brian Paul | 894844a | 2004-03-21 17:05:03 +0000 | [diff] [blame] | 407 | vislevel, /* level */ |
| 408 | 0 /* numAux */ |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 409 | ); |
| 410 | } |
| 411 | else if (is_usable_visual( visinfo )) { |
Brian Paul | 367d308 | 2002-10-25 21:06:26 +0000 | [diff] [blame] | 412 | if (_mesa_getenv("MESA_GLX_FORCE_CI")) { |
Brian Paul | 8f9a594 | 2001-02-17 00:17:31 +0000 | [diff] [blame] | 413 | /* Configure this visual as a COLOR INDEX visual. */ |
| 414 | return save_glx_visual( dpy, visinfo, |
| 415 | GL_FALSE, /* rgb */ |
| 416 | GL_FALSE, /* alpha */ |
| 417 | GL_TRUE, /* double */ |
| 418 | GL_FALSE, /* stereo */ |
Brian Paul | dfa5c2b | 2004-07-23 23:32:15 +0000 | [diff] [blame] | 419 | zBits, |
Brian Paul | 8f9a594 | 2001-02-17 00:17:31 +0000 | [diff] [blame] | 420 | 8 * sizeof(GLstencil), |
| 421 | 0 * sizeof(GLaccum), /* r */ |
| 422 | 0 * sizeof(GLaccum), /* g */ |
| 423 | 0 * sizeof(GLaccum), /* b */ |
| 424 | 0 * sizeof(GLaccum), /* a */ |
Brian Paul | 894844a | 2004-03-21 17:05:03 +0000 | [diff] [blame] | 425 | 0, /* level */ |
| 426 | 0 /* numAux */ |
Brian Paul | 8f9a594 | 2001-02-17 00:17:31 +0000 | [diff] [blame] | 427 | ); |
| 428 | } |
| 429 | else { |
| 430 | /* Configure this visual as RGB, double-buffered, depth-buffered. */ |
| 431 | /* This is surely wrong for some people's needs but what else */ |
| 432 | /* can be done? They should use glXChooseVisual(). */ |
| 433 | return save_glx_visual( dpy, visinfo, |
| 434 | GL_TRUE, /* rgb */ |
| 435 | GL_FALSE, /* alpha */ |
| 436 | GL_TRUE, /* double */ |
| 437 | GL_FALSE, /* stereo */ |
Brian Paul | dfa5c2b | 2004-07-23 23:32:15 +0000 | [diff] [blame] | 438 | zBits, |
Brian Paul | 8f9a594 | 2001-02-17 00:17:31 +0000 | [diff] [blame] | 439 | 8 * sizeof(GLstencil), |
| 440 | 8 * sizeof(GLaccum), /* r */ |
| 441 | 8 * sizeof(GLaccum), /* g */ |
| 442 | 8 * sizeof(GLaccum), /* b */ |
| 443 | 8 * sizeof(GLaccum), /* a */ |
Brian Paul | 894844a | 2004-03-21 17:05:03 +0000 | [diff] [blame] | 444 | 0, /* level */ |
| 445 | 0 /* numAux */ |
Brian Paul | 8f9a594 | 2001-02-17 00:17:31 +0000 | [diff] [blame] | 446 | ); |
| 447 | } |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 448 | } |
| 449 | else { |
Brian Paul | d09a1d8 | 2002-06-13 04:49:17 +0000 | [diff] [blame] | 450 | _mesa_warning(NULL, "Mesa: error in glXCreateContext: bad visual\n"); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 451 | return NULL; |
| 452 | } |
| 453 | } |
| 454 | |
| 455 | |
| 456 | |
| 457 | /* |
| 458 | * Find the GLX visual associated with an XVisualInfo. |
| 459 | */ |
| 460 | static XMesaVisual |
| 461 | find_glx_visual( Display *dpy, XVisualInfo *vinfo ) |
| 462 | { |
| 463 | int i; |
| 464 | |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 465 | /* try to match visual id */ |
| 466 | for (i=0;i<NumVisuals;i++) { |
| 467 | if (VisualTable[i]->display==dpy |
| 468 | && VisualTable[i]->visinfo->visualid == vinfo->visualid) { |
| 469 | return VisualTable[i]; |
| 470 | } |
| 471 | } |
Brian Paul | f104619 | 2002-11-10 17:07:06 +0000 | [diff] [blame] | 472 | |
| 473 | /* if that fails, try to match pointers */ |
| 474 | for (i=0;i<NumVisuals;i++) { |
| 475 | if (VisualTable[i]->display==dpy && VisualTable[i]->vishandle==vinfo) { |
| 476 | return VisualTable[i]; |
| 477 | } |
| 478 | } |
| 479 | |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 480 | return NULL; |
| 481 | } |
| 482 | |
| 483 | |
| 484 | |
Brian Paul | 1d97c27 | 2004-11-27 16:49:52 +0000 | [diff] [blame^] | 485 | /** |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 486 | * Return the transparent pixel value for a GLX visual. |
| 487 | * Input: glxvis - the glx_visual |
| 488 | * Return: a pixel value or -1 if no transparent pixel |
| 489 | */ |
Brian Paul | 7287bbf | 2004-09-23 17:30:54 +0000 | [diff] [blame] | 490 | static int |
| 491 | transparent_pixel( XMesaVisual glxvis ) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 492 | { |
| 493 | Display *dpy = glxvis->display; |
| 494 | XVisualInfo *vinfo = glxvis->visinfo; |
Brian Paul | 1d97c27 | 2004-11-27 16:49:52 +0000 | [diff] [blame^] | 495 | OverlayInfo *overlay_info; |
| 496 | int numOverlaysPerScreen, i; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 497 | |
Brian Paul | 1d97c27 | 2004-11-27 16:49:52 +0000 | [diff] [blame^] | 498 | overlay_info = GetOverlayInfo(dpy, vinfo->screen, &numOverlaysPerScreen); |
| 499 | if (!overlay_info) { |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 500 | return -1; |
| 501 | } |
| 502 | |
Brian Paul | 1d97c27 | 2004-11-27 16:49:52 +0000 | [diff] [blame^] | 503 | for (i = 0; i < numOverlaysPerScreen; i++) { |
| 504 | const OverlayInfo *ov = overlay_info + i; |
| 505 | if (ov->overlay_visual == vinfo->visualid) { |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 506 | /* found it! */ |
Brian Paul | 1d97c27 | 2004-11-27 16:49:52 +0000 | [diff] [blame^] | 507 | if (ov->transparent_type == 0) { |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 508 | /* type 0 indicates no transparency */ |
| 509 | XFree((void *) overlay_info); |
| 510 | return -1; |
| 511 | } |
| 512 | else { |
| 513 | /* ov->value is the transparent pixel */ |
| 514 | XFree((void *) overlay_info); |
| 515 | return ov->value; |
| 516 | } |
| 517 | } |
| 518 | } |
| 519 | |
| 520 | /* The visual ID was not found in the overlay list. */ |
| 521 | XFree((void *) overlay_info); |
| 522 | return -1; |
| 523 | } |
| 524 | |
| 525 | |
| 526 | |
Brian Paul | 1d97c27 | 2004-11-27 16:49:52 +0000 | [diff] [blame^] | 527 | /** |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 528 | * Try to get an X visual which matches the given arguments. |
| 529 | */ |
Brian Paul | 7287bbf | 2004-09-23 17:30:54 +0000 | [diff] [blame] | 530 | static XVisualInfo * |
| 531 | get_visual( Display *dpy, int scr, unsigned int depth, int xclass ) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 532 | { |
| 533 | XVisualInfo temp, *vis; |
| 534 | long mask; |
| 535 | int n; |
| 536 | unsigned int default_depth; |
| 537 | int default_class; |
| 538 | |
| 539 | mask = VisualScreenMask | VisualDepthMask | VisualClassMask; |
| 540 | temp.screen = scr; |
| 541 | temp.depth = depth; |
| 542 | temp.CLASS = xclass; |
| 543 | |
| 544 | default_depth = DefaultDepth(dpy,scr); |
| 545 | default_class = DefaultVisual(dpy,scr)->CLASS; |
| 546 | |
| 547 | if (depth==default_depth && xclass==default_class) { |
| 548 | /* try to get root window's visual */ |
| 549 | temp.visualid = DefaultVisual(dpy,scr)->visualid; |
| 550 | mask |= VisualIDMask; |
| 551 | } |
| 552 | |
| 553 | vis = XGetVisualInfo( dpy, mask, &temp, &n ); |
| 554 | |
| 555 | /* In case bits/pixel > 24, make sure color channels are still <=8 bits. |
| 556 | * An SGI Infinite Reality system, for example, can have 30bpp pixels: |
| 557 | * 10 bits per color channel. Mesa's limited to a max of 8 bits/channel. |
| 558 | */ |
| 559 | if (vis && depth > 24 && (xclass==TrueColor || xclass==DirectColor)) { |
Brian Paul | 71dea34 | 2000-04-19 01:44:01 +0000 | [diff] [blame] | 560 | if (_mesa_bitcount((GLuint) vis->red_mask ) <= 8 && |
| 561 | _mesa_bitcount((GLuint) vis->green_mask) <= 8 && |
| 562 | _mesa_bitcount((GLuint) vis->blue_mask ) <= 8) { |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 563 | return vis; |
| 564 | } |
| 565 | else { |
| 566 | XFree((void *) vis); |
| 567 | return NULL; |
| 568 | } |
| 569 | } |
| 570 | |
| 571 | return vis; |
| 572 | } |
| 573 | |
| 574 | |
| 575 | |
| 576 | /* |
| 577 | * Retrieve the value of the given environment variable and find |
| 578 | * the X visual which matches it. |
| 579 | * Input: dpy - the display |
| 580 | * screen - the screen number |
| 581 | * varname - the name of the environment variable |
| 582 | * Return: an XVisualInfo pointer to NULL if error. |
| 583 | */ |
Brian Paul | 7287bbf | 2004-09-23 17:30:54 +0000 | [diff] [blame] | 584 | static XVisualInfo * |
| 585 | get_env_visual(Display *dpy, int scr, const char *varname) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 586 | { |
| 587 | char value[100], type[100]; |
| 588 | int depth, xclass = -1; |
| 589 | XVisualInfo *vis; |
| 590 | |
Brian Paul | 367d308 | 2002-10-25 21:06:26 +0000 | [diff] [blame] | 591 | if (!_mesa_getenv( varname )) { |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 592 | return NULL; |
| 593 | } |
| 594 | |
Brian Paul | 367d308 | 2002-10-25 21:06:26 +0000 | [diff] [blame] | 595 | _mesa_strncpy( value, _mesa_getenv(varname), 100 ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 596 | value[99] = 0; |
| 597 | |
| 598 | sscanf( value, "%s %d", type, &depth ); |
| 599 | |
Brian Paul | 367d308 | 2002-10-25 21:06:26 +0000 | [diff] [blame] | 600 | if (_mesa_strcmp(type,"TrueColor")==0) xclass = TrueColor; |
| 601 | else if (_mesa_strcmp(type,"DirectColor")==0) xclass = DirectColor; |
| 602 | else if (_mesa_strcmp(type,"PseudoColor")==0) xclass = PseudoColor; |
| 603 | else if (_mesa_strcmp(type,"StaticColor")==0) xclass = StaticColor; |
| 604 | else if (_mesa_strcmp(type,"GrayScale")==0) xclass = GrayScale; |
| 605 | else if (_mesa_strcmp(type,"StaticGray")==0) xclass = StaticGray; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 606 | |
| 607 | if (xclass>-1 && depth>0) { |
| 608 | vis = get_visual( dpy, scr, depth, xclass ); |
| 609 | if (vis) { |
| 610 | return vis; |
| 611 | } |
| 612 | } |
| 613 | |
Brian Paul | 2ad5921 | 2002-10-30 20:24:45 +0000 | [diff] [blame] | 614 | _mesa_warning(NULL, "GLX unable to find visual class=%s, depth=%d.", |
| 615 | type, depth); |
Brian Paul | d09a1d8 | 2002-06-13 04:49:17 +0000 | [diff] [blame] | 616 | |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 617 | return NULL; |
| 618 | } |
| 619 | |
| 620 | |
| 621 | |
| 622 | /* |
| 623 | * Select an X visual which satisfies the RGBA/CI flag and minimum depth. |
| 624 | * Input: dpy, screen - X display and screen number |
| 625 | * rgba - GL_TRUE = RGBA mode, GL_FALSE = CI mode |
| 626 | * min_depth - minimum visual depth |
| 627 | * preferred_class - preferred GLX visual class or DONT_CARE |
| 628 | * Return: pointer to an XVisualInfo or NULL. |
| 629 | */ |
Brian Paul | 7287bbf | 2004-09-23 17:30:54 +0000 | [diff] [blame] | 630 | static XVisualInfo * |
| 631 | choose_x_visual( Display *dpy, int screen, GLboolean rgba, int min_depth, |
| 632 | int preferred_class ) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 633 | { |
| 634 | XVisualInfo *vis; |
Brian Paul | db6aa58 | 2000-11-10 17:23:02 +0000 | [diff] [blame] | 635 | int xclass, visclass = 0; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 636 | int depth; |
| 637 | |
| 638 | if (rgba) { |
| 639 | Atom hp_cr_maps = XInternAtom(dpy, "_HP_RGB_SMOOTH_MAP_LIST", True); |
| 640 | /* First see if the MESA_RGB_VISUAL env var is defined */ |
| 641 | vis = get_env_visual( dpy, screen, "MESA_RGB_VISUAL" ); |
| 642 | if (vis) { |
| 643 | return vis; |
| 644 | } |
| 645 | /* Otherwise, search for a suitable visual */ |
| 646 | if (preferred_class==DONT_CARE) { |
| 647 | for (xclass=0;xclass<6;xclass++) { |
| 648 | switch (xclass) { |
| 649 | case 0: visclass = TrueColor; break; |
| 650 | case 1: visclass = DirectColor; break; |
| 651 | case 2: visclass = PseudoColor; break; |
| 652 | case 3: visclass = StaticColor; break; |
| 653 | case 4: visclass = GrayScale; break; |
| 654 | case 5: visclass = StaticGray; break; |
| 655 | } |
| 656 | if (min_depth==0) { |
| 657 | /* start with shallowest */ |
| 658 | for (depth=0;depth<=32;depth++) { |
| 659 | if (visclass==TrueColor && depth==8 && !hp_cr_maps) { |
| 660 | /* Special case: try to get 8-bit PseudoColor before */ |
| 661 | /* 8-bit TrueColor */ |
| 662 | vis = get_visual( dpy, screen, 8, PseudoColor ); |
| 663 | if (vis) { |
| 664 | return vis; |
| 665 | } |
| 666 | } |
| 667 | vis = get_visual( dpy, screen, depth, visclass ); |
| 668 | if (vis) { |
| 669 | return vis; |
| 670 | } |
| 671 | } |
| 672 | } |
| 673 | else { |
| 674 | /* start with deepest */ |
| 675 | for (depth=32;depth>=min_depth;depth--) { |
| 676 | if (visclass==TrueColor && depth==8 && !hp_cr_maps) { |
| 677 | /* Special case: try to get 8-bit PseudoColor before */ |
| 678 | /* 8-bit TrueColor */ |
| 679 | vis = get_visual( dpy, screen, 8, PseudoColor ); |
| 680 | if (vis) { |
| 681 | return vis; |
| 682 | } |
| 683 | } |
| 684 | vis = get_visual( dpy, screen, depth, visclass ); |
| 685 | if (vis) { |
| 686 | return vis; |
| 687 | } |
| 688 | } |
| 689 | } |
| 690 | } |
| 691 | } |
| 692 | else { |
| 693 | /* search for a specific visual class */ |
| 694 | switch (preferred_class) { |
| 695 | case GLX_TRUE_COLOR_EXT: visclass = TrueColor; break; |
| 696 | case GLX_DIRECT_COLOR_EXT: visclass = DirectColor; break; |
| 697 | case GLX_PSEUDO_COLOR_EXT: visclass = PseudoColor; break; |
| 698 | case GLX_STATIC_COLOR_EXT: visclass = StaticColor; break; |
| 699 | case GLX_GRAY_SCALE_EXT: visclass = GrayScale; break; |
| 700 | case GLX_STATIC_GRAY_EXT: visclass = StaticGray; break; |
| 701 | default: return NULL; |
| 702 | } |
| 703 | if (min_depth==0) { |
| 704 | /* start with shallowest */ |
| 705 | for (depth=0;depth<=32;depth++) { |
| 706 | vis = get_visual( dpy, screen, depth, visclass ); |
| 707 | if (vis) { |
| 708 | return vis; |
| 709 | } |
| 710 | } |
| 711 | } |
| 712 | else { |
| 713 | /* start with deepest */ |
| 714 | for (depth=32;depth>=min_depth;depth--) { |
| 715 | vis = get_visual( dpy, screen, depth, visclass ); |
| 716 | if (vis) { |
| 717 | return vis; |
| 718 | } |
| 719 | } |
| 720 | } |
| 721 | } |
| 722 | } |
| 723 | else { |
| 724 | /* First see if the MESA_CI_VISUAL env var is defined */ |
| 725 | vis = get_env_visual( dpy, screen, "MESA_CI_VISUAL" ); |
| 726 | if (vis) { |
| 727 | return vis; |
| 728 | } |
| 729 | /* Otherwise, search for a suitable visual, starting with shallowest */ |
| 730 | if (preferred_class==DONT_CARE) { |
| 731 | for (xclass=0;xclass<4;xclass++) { |
| 732 | switch (xclass) { |
| 733 | case 0: visclass = PseudoColor; break; |
| 734 | case 1: visclass = StaticColor; break; |
| 735 | case 2: visclass = GrayScale; break; |
| 736 | case 3: visclass = StaticGray; break; |
| 737 | } |
| 738 | /* try 8-bit up through 16-bit */ |
| 739 | for (depth=8;depth<=16;depth++) { |
| 740 | vis = get_visual( dpy, screen, depth, visclass ); |
| 741 | if (vis) { |
| 742 | return vis; |
| 743 | } |
| 744 | } |
| 745 | /* try min_depth up to 8-bit */ |
| 746 | for (depth=min_depth;depth<8;depth++) { |
| 747 | vis = get_visual( dpy, screen, depth, visclass ); |
| 748 | if (vis) { |
| 749 | return vis; |
| 750 | } |
| 751 | } |
| 752 | } |
| 753 | } |
| 754 | else { |
| 755 | /* search for a specific visual class */ |
| 756 | switch (preferred_class) { |
| 757 | case GLX_TRUE_COLOR_EXT: visclass = TrueColor; break; |
| 758 | case GLX_DIRECT_COLOR_EXT: visclass = DirectColor; break; |
| 759 | case GLX_PSEUDO_COLOR_EXT: visclass = PseudoColor; break; |
| 760 | case GLX_STATIC_COLOR_EXT: visclass = StaticColor; break; |
| 761 | case GLX_GRAY_SCALE_EXT: visclass = GrayScale; break; |
| 762 | case GLX_STATIC_GRAY_EXT: visclass = StaticGray; break; |
| 763 | default: return NULL; |
| 764 | } |
| 765 | /* try 8-bit up through 16-bit */ |
| 766 | for (depth=8;depth<=16;depth++) { |
| 767 | vis = get_visual( dpy, screen, depth, visclass ); |
| 768 | if (vis) { |
| 769 | return vis; |
| 770 | } |
| 771 | } |
| 772 | /* try min_depth up to 8-bit */ |
| 773 | for (depth=min_depth;depth<8;depth++) { |
| 774 | vis = get_visual( dpy, screen, depth, visclass ); |
| 775 | if (vis) { |
| 776 | return vis; |
| 777 | } |
| 778 | } |
| 779 | } |
| 780 | } |
| 781 | |
| 782 | /* didn't find a visual */ |
| 783 | return NULL; |
| 784 | } |
| 785 | |
| 786 | |
| 787 | |
| 788 | /* |
| 789 | * Find the deepest X over/underlay visual of at least min_depth. |
| 790 | * Input: dpy, screen - X display and screen number |
| 791 | * level - the over/underlay level |
| 792 | * trans_type - transparent pixel type: GLX_NONE_EXT, |
| 793 | * GLX_TRANSPARENT_RGB_EXT, GLX_TRANSPARENT_INDEX_EXT, |
| 794 | * or DONT_CARE |
| 795 | * trans_value - transparent pixel value or DONT_CARE |
| 796 | * min_depth - minimum visual depth |
| 797 | * preferred_class - preferred GLX visual class or DONT_CARE |
| 798 | * Return: pointer to an XVisualInfo or NULL. |
| 799 | */ |
Brian Paul | 7287bbf | 2004-09-23 17:30:54 +0000 | [diff] [blame] | 800 | static XVisualInfo * |
| 801 | choose_x_overlay_visual( Display *dpy, int scr, GLboolean rgbFlag, |
| 802 | int level, int trans_type, int trans_value, |
| 803 | int min_depth, int preferred_class ) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 804 | { |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 805 | OverlayInfo *overlay_info; |
| 806 | int numOverlaysPerScreen; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 807 | int i; |
| 808 | XVisualInfo *deepvis; |
| 809 | int deepest; |
| 810 | |
| 811 | /*DEBUG int tt, tv; */ |
| 812 | |
| 813 | switch (preferred_class) { |
| 814 | case GLX_TRUE_COLOR_EXT: preferred_class = TrueColor; break; |
| 815 | case GLX_DIRECT_COLOR_EXT: preferred_class = DirectColor; break; |
| 816 | case GLX_PSEUDO_COLOR_EXT: preferred_class = PseudoColor; break; |
| 817 | case GLX_STATIC_COLOR_EXT: preferred_class = StaticColor; break; |
| 818 | case GLX_GRAY_SCALE_EXT: preferred_class = GrayScale; break; |
| 819 | case GLX_STATIC_GRAY_EXT: preferred_class = StaticGray; break; |
| 820 | default: preferred_class = DONT_CARE; |
| 821 | } |
| 822 | |
Brian Paul | 1d97c27 | 2004-11-27 16:49:52 +0000 | [diff] [blame^] | 823 | overlay_info = GetOverlayInfo(dpy, scr, &numOverlaysPerScreen); |
| 824 | if (!overlay_info) { |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 825 | return NULL; |
| 826 | } |
| 827 | |
| 828 | /* Search for the deepest overlay which satisifies all criteria. */ |
| 829 | deepest = min_depth; |
| 830 | deepvis = NULL; |
| 831 | |
Brian Paul | 1d97c27 | 2004-11-27 16:49:52 +0000 | [diff] [blame^] | 832 | for (i = 0; i < numOverlaysPerScreen; i++) { |
| 833 | const OverlayInfo *ov = overlay_info + i; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 834 | XVisualInfo *vislist, vistemplate; |
| 835 | int count; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 836 | |
| 837 | if (ov->layer!=level) { |
| 838 | /* failed overlay level criteria */ |
| 839 | continue; |
| 840 | } |
| 841 | if (!(trans_type==DONT_CARE |
| 842 | || (trans_type==GLX_TRANSPARENT_INDEX_EXT |
| 843 | && ov->transparent_type>0) |
| 844 | || (trans_type==GLX_NONE_EXT && ov->transparent_type==0))) { |
| 845 | /* failed transparent pixel type criteria */ |
| 846 | continue; |
| 847 | } |
| 848 | if (trans_value!=DONT_CARE && trans_value!=ov->value) { |
| 849 | /* failed transparent pixel value criteria */ |
| 850 | continue; |
| 851 | } |
| 852 | |
| 853 | /* get XVisualInfo and check the depth */ |
| 854 | vistemplate.visualid = ov->overlay_visual; |
| 855 | vistemplate.screen = scr; |
| 856 | vislist = XGetVisualInfo( dpy, VisualIDMask | VisualScreenMask, |
| 857 | &vistemplate, &count ); |
| 858 | |
| 859 | if (count!=1) { |
| 860 | /* something went wrong */ |
| 861 | continue; |
| 862 | } |
| 863 | if (preferred_class!=DONT_CARE && preferred_class!=vislist->CLASS) { |
| 864 | /* wrong visual class */ |
| 865 | continue; |
| 866 | } |
| 867 | |
Brian Paul | 42f252f | 1999-10-14 18:47:37 +0000 | [diff] [blame] | 868 | /* if RGB was requested, make sure we have True/DirectColor */ |
| 869 | if (rgbFlag && vislist->CLASS != TrueColor |
| 870 | && vislist->CLASS != DirectColor) |
| 871 | continue; |
| 872 | |
| 873 | /* if CI was requested, make sure we have a color indexed visual */ |
| 874 | if (!rgbFlag |
| 875 | && (vislist->CLASS == TrueColor || vislist->CLASS == DirectColor)) |
| 876 | continue; |
| 877 | |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 878 | if (deepvis==NULL || vislist->depth > deepest) { |
| 879 | /* YES! found a satisfactory visual */ |
| 880 | if (deepvis) { |
Brian Paul | 80af361 | 1999-10-13 18:49:47 +0000 | [diff] [blame] | 881 | XFree( deepvis ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 882 | } |
| 883 | deepest = vislist->depth; |
| 884 | deepvis = vislist; |
| 885 | /* DEBUG tt = ov->transparent_type;*/ |
| 886 | /* DEBUG tv = ov->value; */ |
| 887 | } |
| 888 | } |
| 889 | |
| 890 | /*DEBUG |
| 891 | if (deepvis) { |
| 892 | printf("chose 0x%x: layer=%d depth=%d trans_type=%d trans_value=%d\n", |
| 893 | deepvis->visualid, level, deepvis->depth, tt, tv ); |
| 894 | } |
| 895 | */ |
| 896 | return deepvis; |
| 897 | } |
| 898 | |
| 899 | |
Brian Paul | 7cf50e1 | 2001-05-24 19:06:21 +0000 | [diff] [blame] | 900 | /**********************************************************************/ |
| 901 | /*** Begin Fake GLX API Functions ***/ |
| 902 | /**********************************************************************/ |
| 903 | |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 904 | |
Brian Paul | 7287bbf | 2004-09-23 17:30:54 +0000 | [diff] [blame] | 905 | static XMesaVisual |
| 906 | choose_visual( Display *dpy, int screen, const int *list, |
| 907 | GLboolean rgbModeDefault ) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 908 | { |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 909 | const int *parselist; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 910 | XVisualInfo *vis; |
| 911 | int min_ci = 0; |
| 912 | int min_red=0, min_green=0, min_blue=0; |
Brian Paul | b3063ac | 2004-02-04 23:39:19 +0000 | [diff] [blame] | 913 | GLboolean rgb_flag = rgbModeDefault; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 914 | GLboolean alpha_flag = GL_FALSE; |
| 915 | GLboolean double_flag = GL_FALSE; |
| 916 | GLboolean stereo_flag = GL_FALSE; |
| 917 | GLint depth_size = 0; |
| 918 | GLint stencil_size = 0; |
Brian Paul | b2e4600 | 2000-03-31 01:07:13 +0000 | [diff] [blame] | 919 | GLint accumRedSize = 0; |
| 920 | GLint accumGreenSize = 0; |
| 921 | GLint accumBlueSize = 0; |
| 922 | GLint accumAlphaSize = 0; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 923 | int level = 0; |
| 924 | int visual_type = DONT_CARE; |
| 925 | int trans_type = DONT_CARE; |
| 926 | int trans_value = DONT_CARE; |
Brian Paul | e1210b1 | 2000-03-31 01:17:52 +0000 | [diff] [blame] | 927 | GLint caveat = DONT_CARE; |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 928 | XMesaVisual xmvis = NULL; |
Brian Paul | 3a99674 | 2004-02-02 15:40:21 +0000 | [diff] [blame] | 929 | int desiredVisualID = -1; |
Brian Paul | 894844a | 2004-03-21 17:05:03 +0000 | [diff] [blame] | 930 | int numAux = 0; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 931 | |
| 932 | parselist = list; |
| 933 | |
| 934 | while (*parselist) { |
| 935 | |
| 936 | switch (*parselist) { |
| 937 | case GLX_USE_GL: |
| 938 | /* ignore */ |
| 939 | parselist++; |
| 940 | break; |
| 941 | case GLX_BUFFER_SIZE: |
| 942 | parselist++; |
| 943 | min_ci = *parselist++; |
| 944 | break; |
| 945 | case GLX_LEVEL: |
| 946 | parselist++; |
| 947 | level = *parselist++; |
| 948 | break; |
| 949 | case GLX_RGBA: |
| 950 | rgb_flag = GL_TRUE; |
| 951 | parselist++; |
| 952 | break; |
| 953 | case GLX_DOUBLEBUFFER: |
| 954 | double_flag = GL_TRUE; |
| 955 | parselist++; |
| 956 | break; |
| 957 | case GLX_STEREO: |
| 958 | stereo_flag = GL_TRUE; |
| 959 | return NULL; |
| 960 | case GLX_AUX_BUFFERS: |
| 961 | /* ignore */ |
| 962 | parselist++; |
Brian Paul | 894844a | 2004-03-21 17:05:03 +0000 | [diff] [blame] | 963 | numAux = *parselist++; |
| 964 | if (numAux > MAX_AUX_BUFFERS) |
| 965 | return NULL; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 966 | break; |
| 967 | case GLX_RED_SIZE: |
| 968 | parselist++; |
| 969 | min_red = *parselist++; |
| 970 | break; |
| 971 | case GLX_GREEN_SIZE: |
| 972 | parselist++; |
| 973 | min_green = *parselist++; |
| 974 | break; |
| 975 | case GLX_BLUE_SIZE: |
| 976 | parselist++; |
| 977 | min_blue = *parselist++; |
| 978 | break; |
| 979 | case GLX_ALPHA_SIZE: |
| 980 | parselist++; |
| 981 | { |
| 982 | GLint size = *parselist++; |
| 983 | alpha_flag = size>0 ? 1 : 0; |
| 984 | } |
| 985 | break; |
| 986 | case GLX_DEPTH_SIZE: |
| 987 | parselist++; |
| 988 | depth_size = *parselist++; |
| 989 | break; |
| 990 | case GLX_STENCIL_SIZE: |
| 991 | parselist++; |
| 992 | stencil_size = *parselist++; |
| 993 | break; |
| 994 | case GLX_ACCUM_RED_SIZE: |
Brian Paul | b2e4600 | 2000-03-31 01:07:13 +0000 | [diff] [blame] | 995 | parselist++; |
| 996 | { |
| 997 | GLint size = *parselist++; |
| 998 | accumRedSize = MAX2( accumRedSize, size ); |
| 999 | } |
| 1000 | break; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1001 | case GLX_ACCUM_GREEN_SIZE: |
Brian Paul | b2e4600 | 2000-03-31 01:07:13 +0000 | [diff] [blame] | 1002 | parselist++; |
| 1003 | { |
| 1004 | GLint size = *parselist++; |
| 1005 | accumGreenSize = MAX2( accumGreenSize, size ); |
| 1006 | } |
| 1007 | break; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1008 | case GLX_ACCUM_BLUE_SIZE: |
Brian Paul | b2e4600 | 2000-03-31 01:07:13 +0000 | [diff] [blame] | 1009 | parselist++; |
| 1010 | { |
| 1011 | GLint size = *parselist++; |
| 1012 | accumBlueSize = MAX2( accumBlueSize, size ); |
| 1013 | } |
| 1014 | break; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1015 | case GLX_ACCUM_ALPHA_SIZE: |
| 1016 | parselist++; |
| 1017 | { |
| 1018 | GLint size = *parselist++; |
Brian Paul | b2e4600 | 2000-03-31 01:07:13 +0000 | [diff] [blame] | 1019 | accumAlphaSize = MAX2( accumAlphaSize, size ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1020 | } |
| 1021 | break; |
| 1022 | |
| 1023 | /* |
| 1024 | * GLX_EXT_visual_info extension |
| 1025 | */ |
| 1026 | case GLX_X_VISUAL_TYPE_EXT: |
| 1027 | parselist++; |
| 1028 | visual_type = *parselist++; |
| 1029 | break; |
| 1030 | case GLX_TRANSPARENT_TYPE_EXT: |
| 1031 | parselist++; |
| 1032 | trans_type = *parselist++; |
| 1033 | break; |
| 1034 | case GLX_TRANSPARENT_INDEX_VALUE_EXT: |
| 1035 | parselist++; |
| 1036 | trans_value = *parselist++; |
| 1037 | break; |
| 1038 | case GLX_TRANSPARENT_RED_VALUE_EXT: |
| 1039 | case GLX_TRANSPARENT_GREEN_VALUE_EXT: |
| 1040 | case GLX_TRANSPARENT_BLUE_VALUE_EXT: |
| 1041 | case GLX_TRANSPARENT_ALPHA_VALUE_EXT: |
| 1042 | /* ignore */ |
| 1043 | parselist++; |
| 1044 | parselist++; |
| 1045 | break; |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 1046 | |
Brian Paul | e1210b1 | 2000-03-31 01:17:52 +0000 | [diff] [blame] | 1047 | /* |
| 1048 | * GLX_EXT_visual_info extension |
| 1049 | */ |
| 1050 | case GLX_VISUAL_CAVEAT_EXT: |
| 1051 | parselist++; |
| 1052 | caveat = *parselist++; /* ignored for now */ |
| 1053 | break; |
| 1054 | |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 1055 | /* |
Brian Paul | 66ab727 | 2002-11-05 21:11:18 +0000 | [diff] [blame] | 1056 | * GLX_ARB_multisample |
| 1057 | */ |
| 1058 | case GLX_SAMPLE_BUFFERS_ARB: |
| 1059 | /* ms not supported */ |
| 1060 | return NULL; |
| 1061 | case GLX_SAMPLES_ARB: |
| 1062 | /* ms not supported */ |
| 1063 | return NULL; |
| 1064 | |
| 1065 | /* |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 1066 | * FBConfig attribs. |
| 1067 | */ |
| 1068 | case GLX_RENDER_TYPE: |
| 1069 | parselist++; |
| 1070 | if (*parselist == GLX_RGBA_BIT) { |
| 1071 | rgb_flag = GL_TRUE; |
| 1072 | } |
| 1073 | else if (*parselist == GLX_COLOR_INDEX_BIT) { |
| 1074 | rgb_flag = GL_FALSE; |
| 1075 | } |
| 1076 | else if (*parselist == 0) { |
| 1077 | rgb_flag = GL_TRUE; |
| 1078 | } |
| 1079 | parselist++; |
| 1080 | break; |
| 1081 | case GLX_DRAWABLE_TYPE: |
| 1082 | parselist++; |
| 1083 | if (*parselist & ~(GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT)) { |
| 1084 | return NULL; /* bad bit */ |
| 1085 | } |
| 1086 | parselist++; |
| 1087 | break; |
Brian Paul | 3a99674 | 2004-02-02 15:40:21 +0000 | [diff] [blame] | 1088 | case GLX_FBCONFIG_ID: |
| 1089 | parselist++; |
| 1090 | desiredVisualID = *parselist; |
| 1091 | break; |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 1092 | |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1093 | case None: |
Brian Paul | 3a99674 | 2004-02-02 15:40:21 +0000 | [diff] [blame] | 1094 | /* end of list */ |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1095 | break; |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 1096 | |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1097 | default: |
| 1098 | /* undefined attribute */ |
Brian Paul | 2ad5921 | 2002-10-30 20:24:45 +0000 | [diff] [blame] | 1099 | _mesa_warning(NULL, "unexpected attrib 0x%x in choose_visual()", |
| 1100 | *parselist); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1101 | return NULL; |
| 1102 | } |
| 1103 | } |
| 1104 | |
Brian Paul | b305028 | 2003-12-04 03:19:46 +0000 | [diff] [blame] | 1105 | (void) caveat; |
| 1106 | |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1107 | /* |
| 1108 | * Since we're only simulating the GLX extension this function will never |
| 1109 | * find any real GL visuals. Instead, all we can do is try to find an RGB |
| 1110 | * or CI visual of appropriate depth. Other requested attributes such as |
| 1111 | * double buffering, depth buffer, etc. will be associated with the X |
| 1112 | * visual and stored in the VisualTable[]. |
| 1113 | */ |
Brian Paul | 3a99674 | 2004-02-02 15:40:21 +0000 | [diff] [blame] | 1114 | if (desiredVisualID != -1) { |
| 1115 | /* try to get a specific visual, by visualID */ |
| 1116 | XVisualInfo temp; |
| 1117 | int n; |
| 1118 | temp.visualid = desiredVisualID; |
| 1119 | temp.screen = screen; |
| 1120 | vis = XGetVisualInfo(dpy, VisualIDMask | VisualScreenMask, &temp, &n); |
| 1121 | if (vis) { |
| 1122 | /* give the visual some useful GLX attributes */ |
| 1123 | double_flag = GL_TRUE; |
| 1124 | if (vis->depth > 8) |
| 1125 | rgb_flag = GL_TRUE; |
Brian Paul | dfa5c2b | 2004-07-23 23:32:15 +0000 | [diff] [blame] | 1126 | depth_size = default_depth_bits(); |
Brian Paul | 3a99674 | 2004-02-02 15:40:21 +0000 | [diff] [blame] | 1127 | stencil_size = STENCIL_BITS; |
| 1128 | /* XXX accum??? */ |
| 1129 | } |
| 1130 | } |
| 1131 | else if (level==0) { |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1132 | /* normal color planes */ |
| 1133 | if (rgb_flag) { |
| 1134 | /* Get an RGB visual */ |
| 1135 | int min_rgb = min_red + min_green + min_blue; |
| 1136 | if (min_rgb>1 && min_rgb<8) { |
| 1137 | /* a special case to be sure we can get a monochrome visual */ |
| 1138 | min_rgb = 1; |
| 1139 | } |
| 1140 | vis = choose_x_visual( dpy, screen, rgb_flag, min_rgb, visual_type ); |
| 1141 | } |
| 1142 | else { |
| 1143 | /* Get a color index visual */ |
| 1144 | vis = choose_x_visual( dpy, screen, rgb_flag, min_ci, visual_type ); |
Brian Paul | b2e4600 | 2000-03-31 01:07:13 +0000 | [diff] [blame] | 1145 | accumRedSize = accumGreenSize = accumBlueSize = accumAlphaSize = 0; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1146 | } |
| 1147 | } |
| 1148 | else { |
| 1149 | /* over/underlay planes */ |
Brian Paul | 42f252f | 1999-10-14 18:47:37 +0000 | [diff] [blame] | 1150 | if (rgb_flag) { |
| 1151 | /* rgba overlay */ |
| 1152 | int min_rgb = min_red + min_green + min_blue; |
| 1153 | if (min_rgb>1 && min_rgb<8) { |
| 1154 | /* a special case to be sure we can get a monochrome visual */ |
| 1155 | min_rgb = 1; |
| 1156 | } |
| 1157 | vis = choose_x_overlay_visual( dpy, screen, rgb_flag, level, |
| 1158 | trans_type, trans_value, min_rgb, visual_type ); |
| 1159 | } |
| 1160 | else { |
| 1161 | /* color index overlay */ |
| 1162 | vis = choose_x_overlay_visual( dpy, screen, rgb_flag, level, |
| 1163 | trans_type, trans_value, min_ci, visual_type ); |
| 1164 | } |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1165 | } |
| 1166 | |
| 1167 | if (vis) { |
Brian Paul | ed30dfa | 2000-03-03 17:47:39 +0000 | [diff] [blame] | 1168 | /* Note: we're not exactly obeying the glXChooseVisual rules here. |
| 1169 | * When GLX_DEPTH_SIZE = 1 is specified we're supposed to choose the |
Brian Paul | 2c7e633 | 2000-10-05 17:38:21 +0000 | [diff] [blame] | 1170 | * largest depth buffer size, which is 32bits/value. Instead, we |
Brian Paul | ed30dfa | 2000-03-03 17:47:39 +0000 | [diff] [blame] | 1171 | * return 16 to maintain performance with earlier versions of Mesa. |
| 1172 | */ |
Brian Paul | 2c7e633 | 2000-10-05 17:38:21 +0000 | [diff] [blame] | 1173 | if (depth_size > 24) |
| 1174 | depth_size = 31; /* 32 causes int overflow problems */ |
Brian Paul | ed30dfa | 2000-03-03 17:47:39 +0000 | [diff] [blame] | 1175 | else if (depth_size > 16) |
| 1176 | depth_size = 24; |
Brian Paul | dfa5c2b | 2004-07-23 23:32:15 +0000 | [diff] [blame] | 1177 | else if (depth_size > 0) { |
| 1178 | depth_size = default_depth_bits(); |
| 1179 | } |
Brian Paul | 2c7e633 | 2000-10-05 17:38:21 +0000 | [diff] [blame] | 1180 | |
Brian Paul | ed30dfa | 2000-03-03 17:47:39 +0000 | [diff] [blame] | 1181 | /* we only support one size of stencil and accum buffers. */ |
| 1182 | if (stencil_size > 0) |
| 1183 | stencil_size = STENCIL_BITS; |
Brian Paul | 6d62d7f | 2001-03-23 21:37:05 +0000 | [diff] [blame] | 1184 | if (accumRedSize > 0 || accumGreenSize > 0 || accumBlueSize > 0 || |
| 1185 | accumAlphaSize > 0) { |
Brian Paul | b2e4600 | 2000-03-31 01:07:13 +0000 | [diff] [blame] | 1186 | accumRedSize = ACCUM_BITS; |
Brian Paul | b2e4600 | 2000-03-31 01:07:13 +0000 | [diff] [blame] | 1187 | accumGreenSize = ACCUM_BITS; |
Brian Paul | b2e4600 | 2000-03-31 01:07:13 +0000 | [diff] [blame] | 1188 | accumBlueSize = ACCUM_BITS; |
Brian Paul | 6d62d7f | 2001-03-23 21:37:05 +0000 | [diff] [blame] | 1189 | accumAlphaSize = alpha_flag ? ACCUM_BITS : 0; |
| 1190 | } |
| 1191 | |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 1192 | xmvis = save_glx_visual( dpy, vis, rgb_flag, alpha_flag, double_flag, |
| 1193 | stereo_flag, depth_size, stencil_size, |
| 1194 | accumRedSize, accumGreenSize, |
Brian Paul | 894844a | 2004-03-21 17:05:03 +0000 | [diff] [blame] | 1195 | accumBlueSize, accumAlphaSize, level, numAux ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1196 | } |
| 1197 | |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 1198 | return xmvis; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1199 | } |
| 1200 | |
| 1201 | |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 1202 | static XVisualInfo * |
| 1203 | Fake_glXChooseVisual( Display *dpy, int screen, int *list ) |
| 1204 | { |
Brian Paul | b3063ac | 2004-02-04 23:39:19 +0000 | [diff] [blame] | 1205 | XMesaVisual xmvis = choose_visual(dpy, screen, list, GL_FALSE); |
Brian Paul | f104619 | 2002-11-10 17:07:06 +0000 | [diff] [blame] | 1206 | if (xmvis) { |
| 1207 | #if 0 |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 1208 | return xmvis->vishandle; |
Brian Paul | f104619 | 2002-11-10 17:07:06 +0000 | [diff] [blame] | 1209 | #else |
| 1210 | /* create a new vishandle - the cached one may be stale */ |
Brian Paul | 4039cb8 | 2003-02-25 19:25:52 +0000 | [diff] [blame] | 1211 | xmvis->vishandle = (XVisualInfo *) _mesa_malloc(sizeof(XVisualInfo)); |
Brian Paul | f104619 | 2002-11-10 17:07:06 +0000 | [diff] [blame] | 1212 | if (xmvis->vishandle) { |
| 1213 | _mesa_memcpy(xmvis->vishandle, xmvis->visinfo, sizeof(XVisualInfo)); |
| 1214 | } |
| 1215 | return xmvis->vishandle; |
| 1216 | #endif |
| 1217 | } |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 1218 | else |
| 1219 | return NULL; |
| 1220 | } |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1221 | |
| 1222 | |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 1223 | static GLXContext |
| 1224 | Fake_glXCreateContext( Display *dpy, XVisualInfo *visinfo, |
| 1225 | GLXContext share_list, Bool direct ) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1226 | { |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 1227 | XMesaVisual xmvis; |
Brian Paul | 7cf50e1 | 2001-05-24 19:06:21 +0000 | [diff] [blame] | 1228 | struct fake_glx_context *glxCtx; |
Brian Paul | 5e1680c | 2001-08-07 16:01:34 +0000 | [diff] [blame] | 1229 | struct fake_glx_context *shareCtx = (struct fake_glx_context *) share_list; |
Brian Paul | 99aab34 | 2002-04-02 23:52:53 +0000 | [diff] [blame] | 1230 | |
| 1231 | if (!dpy || !visinfo) |
| 1232 | return 0; |
| 1233 | |
Brian Paul | 7cf50e1 | 2001-05-24 19:06:21 +0000 | [diff] [blame] | 1234 | glxCtx = CALLOC_STRUCT(fake_glx_context); |
| 1235 | if (!glxCtx) |
| 1236 | return 0; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1237 | |
| 1238 | /* deallocate unused windows/buffers */ |
| 1239 | XMesaGarbageCollect(); |
| 1240 | |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 1241 | xmvis = find_glx_visual( dpy, visinfo ); |
| 1242 | if (!xmvis) { |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1243 | /* This visual wasn't found with glXChooseVisual() */ |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 1244 | xmvis = create_glx_visual( dpy, visinfo ); |
| 1245 | if (!xmvis) { |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1246 | /* unusable visual */ |
Brian Paul | 7cf50e1 | 2001-05-24 19:06:21 +0000 | [diff] [blame] | 1247 | FREE(glxCtx); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1248 | return NULL; |
| 1249 | } |
| 1250 | } |
| 1251 | |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 1252 | glxCtx->xmesaContext = XMesaCreateContext(xmvis, |
Brian Paul | 5e1680c | 2001-08-07 16:01:34 +0000 | [diff] [blame] | 1253 | shareCtx ? shareCtx->xmesaContext : NULL); |
Brian Paul | 7cf50e1 | 2001-05-24 19:06:21 +0000 | [diff] [blame] | 1254 | if (!glxCtx->xmesaContext) { |
| 1255 | FREE(glxCtx); |
| 1256 | return NULL; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1257 | } |
Brian Paul | 7cf50e1 | 2001-05-24 19:06:21 +0000 | [diff] [blame] | 1258 | |
| 1259 | glxCtx->xmesaContext->direct = GL_FALSE; |
| 1260 | glxCtx->glxContext.isDirect = GL_FALSE; |
| 1261 | glxCtx->glxContext.currentDpy = dpy; |
| 1262 | glxCtx->glxContext.xid = (XID) glxCtx; /* self pointer */ |
| 1263 | |
| 1264 | assert((void *) glxCtx == (void *) &(glxCtx->glxContext)); |
| 1265 | |
| 1266 | return (GLXContext) glxCtx; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1267 | } |
| 1268 | |
| 1269 | |
Brian Paul | 7cf50e1 | 2001-05-24 19:06:21 +0000 | [diff] [blame] | 1270 | /* XXX these may have to be removed due to thread-safety issues. */ |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1271 | static GLXContext MakeCurrent_PrevContext = 0; |
Brian Paul | 086a151 | 1999-11-25 17:37:49 +0000 | [diff] [blame] | 1272 | static GLXDrawable MakeCurrent_PrevDrawable = 0; |
| 1273 | static GLXDrawable MakeCurrent_PrevReadable = 0; |
| 1274 | static XMesaBuffer MakeCurrent_PrevDrawBuffer = 0; |
| 1275 | static XMesaBuffer MakeCurrent_PrevReadBuffer = 0; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1276 | |
Brian Paul | 7cf50e1 | 2001-05-24 19:06:21 +0000 | [diff] [blame] | 1277 | |
Brian Paul | 086a151 | 1999-11-25 17:37:49 +0000 | [diff] [blame] | 1278 | /* GLX 1.3 and later */ |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 1279 | static Bool |
| 1280 | Fake_glXMakeContextCurrent( Display *dpy, GLXDrawable draw, |
Keith Whitwell | 7a1f3a3 | 2001-01-08 04:55:22 +0000 | [diff] [blame] | 1281 | GLXDrawable read, GLXContext ctx ) |
Brian Paul | 086a151 | 1999-11-25 17:37:49 +0000 | [diff] [blame] | 1282 | { |
Brian Paul | 7cf50e1 | 2001-05-24 19:06:21 +0000 | [diff] [blame] | 1283 | struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx; |
| 1284 | |
Keith Whitwell | 7a1f3a3 | 2001-01-08 04:55:22 +0000 | [diff] [blame] | 1285 | if (ctx && draw && read) { |
Brian Paul | 086a151 | 1999-11-25 17:37:49 +0000 | [diff] [blame] | 1286 | XMesaBuffer drawBuffer, readBuffer; |
Brian Paul | 7cf50e1 | 2001-05-24 19:06:21 +0000 | [diff] [blame] | 1287 | XMesaContext xmctx = glxCtx->xmesaContext; |
Brian Paul | 086a151 | 1999-11-25 17:37:49 +0000 | [diff] [blame] | 1288 | |
| 1289 | /* Find the XMesaBuffer which corresponds to the GLXDrawable 'draw' */ |
Keith Whitwell | 7a1f3a3 | 2001-01-08 04:55:22 +0000 | [diff] [blame] | 1290 | if (ctx == MakeCurrent_PrevContext |
| 1291 | && draw == MakeCurrent_PrevDrawable) { |
Brian Paul | 086a151 | 1999-11-25 17:37:49 +0000 | [diff] [blame] | 1292 | drawBuffer = MakeCurrent_PrevDrawBuffer; |
| 1293 | } |
| 1294 | else { |
| 1295 | drawBuffer = XMesaFindBuffer( dpy, draw ); |
| 1296 | } |
| 1297 | if (!drawBuffer) { |
| 1298 | /* drawable must be a new window! */ |
Brian Paul | 7cf50e1 | 2001-05-24 19:06:21 +0000 | [diff] [blame] | 1299 | drawBuffer = XMesaCreateWindowBuffer2( xmctx->xm_visual, draw, xmctx); |
Brian Paul | 086a151 | 1999-11-25 17:37:49 +0000 | [diff] [blame] | 1300 | if (!drawBuffer) { |
| 1301 | /* Out of memory, or context/drawable depth mismatch */ |
| 1302 | return False; |
| 1303 | } |
| 1304 | } |
| 1305 | |
| 1306 | /* Find the XMesaBuffer which corresponds to the GLXDrawable 'read' */ |
Keith Whitwell | 7a1f3a3 | 2001-01-08 04:55:22 +0000 | [diff] [blame] | 1307 | if (ctx == MakeCurrent_PrevContext |
Brian Paul | 086a151 | 1999-11-25 17:37:49 +0000 | [diff] [blame] | 1308 | && read == MakeCurrent_PrevReadable) { |
| 1309 | readBuffer = MakeCurrent_PrevReadBuffer; |
| 1310 | } |
| 1311 | else { |
| 1312 | readBuffer = XMesaFindBuffer( dpy, read ); |
| 1313 | } |
| 1314 | if (!readBuffer) { |
| 1315 | /* drawable must be a new window! */ |
Brian Paul | 7cf50e1 | 2001-05-24 19:06:21 +0000 | [diff] [blame] | 1316 | readBuffer = XMesaCreateWindowBuffer2(glxCtx->xmesaContext->xm_visual, |
| 1317 | read, xmctx); |
Brian Paul | 086a151 | 1999-11-25 17:37:49 +0000 | [diff] [blame] | 1318 | if (!readBuffer) { |
| 1319 | /* Out of memory, or context/drawable depth mismatch */ |
| 1320 | return False; |
| 1321 | } |
| 1322 | } |
| 1323 | |
Keith Whitwell | 7a1f3a3 | 2001-01-08 04:55:22 +0000 | [diff] [blame] | 1324 | MakeCurrent_PrevContext = ctx; |
Brian Paul | 086a151 | 1999-11-25 17:37:49 +0000 | [diff] [blame] | 1325 | MakeCurrent_PrevDrawable = draw; |
| 1326 | MakeCurrent_PrevReadable = read; |
| 1327 | MakeCurrent_PrevDrawBuffer = drawBuffer; |
| 1328 | MakeCurrent_PrevReadBuffer = readBuffer; |
| 1329 | |
| 1330 | /* Now make current! */ |
Brian Paul | 7cf50e1 | 2001-05-24 19:06:21 +0000 | [diff] [blame] | 1331 | if (XMesaMakeCurrent2(xmctx, drawBuffer, readBuffer)) { |
Brian Paul | 12c1bee | 2001-05-24 20:05:32 +0000 | [diff] [blame] | 1332 | ((__GLXcontext *) ctx)->currentDpy = dpy; |
| 1333 | ((__GLXcontext *) ctx)->currentDrawable = draw; |
Brian Paul | 8d687e7 | 2002-03-15 18:43:25 +0000 | [diff] [blame] | 1334 | #ifndef GLX_BUILT_IN_XMESA |
Brian Paul | 12c1bee | 2001-05-24 20:05:32 +0000 | [diff] [blame] | 1335 | ((__GLXcontext *) ctx)->currentReadable = read; |
Brian Paul | 8d687e7 | 2002-03-15 18:43:25 +0000 | [diff] [blame] | 1336 | #else |
Brian Paul | 7cf50e1 | 2001-05-24 19:06:21 +0000 | [diff] [blame] | 1337 | __glXSetCurrentContext(ctx); |
| 1338 | #endif |
| 1339 | return True; |
| 1340 | } |
| 1341 | else { |
| 1342 | return False; |
| 1343 | } |
Brian Paul | 086a151 | 1999-11-25 17:37:49 +0000 | [diff] [blame] | 1344 | } |
Keith Whitwell | 7a1f3a3 | 2001-01-08 04:55:22 +0000 | [diff] [blame] | 1345 | else if (!ctx && !draw && !read) { |
Brian Paul | 086a151 | 1999-11-25 17:37:49 +0000 | [diff] [blame] | 1346 | /* release current context w/out assigning new one. */ |
| 1347 | XMesaMakeCurrent( NULL, NULL ); |
| 1348 | MakeCurrent_PrevContext = 0; |
| 1349 | MakeCurrent_PrevDrawable = 0; |
| 1350 | MakeCurrent_PrevReadable = 0; |
| 1351 | MakeCurrent_PrevDrawBuffer = 0; |
| 1352 | MakeCurrent_PrevReadBuffer = 0; |
Brian Paul | 84cac84 | 2001-05-29 23:15:07 +0000 | [diff] [blame] | 1353 | #ifdef GLX_BUILT_IN_XMESA |
Brian Paul | b0bb4f6 | 2001-05-25 21:51:02 +0000 | [diff] [blame] | 1354 | /* XXX bind dummy context with __glXSetCurrentContext(ctx); */ |
| 1355 | #endif |
Brian Paul | 086a151 | 1999-11-25 17:37:49 +0000 | [diff] [blame] | 1356 | return True; |
| 1357 | } |
| 1358 | else { |
| 1359 | /* The args must either all be non-zero or all zero. |
| 1360 | * This is an error. |
| 1361 | */ |
| 1362 | return False; |
| 1363 | } |
| 1364 | } |
| 1365 | |
| 1366 | |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 1367 | static Bool |
| 1368 | Fake_glXMakeCurrent( Display *dpy, GLXDrawable drawable, GLXContext ctx ) |
| 1369 | { |
| 1370 | return Fake_glXMakeContextCurrent( dpy, drawable, drawable, ctx ); |
| 1371 | } |
| 1372 | |
| 1373 | |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 1374 | static GLXPixmap |
| 1375 | Fake_glXCreateGLXPixmap( Display *dpy, XVisualInfo *visinfo, Pixmap pixmap ) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1376 | { |
| 1377 | XMesaVisual v; |
| 1378 | XMesaBuffer b; |
| 1379 | |
| 1380 | v = find_glx_visual( dpy, visinfo ); |
| 1381 | if (!v) { |
| 1382 | v = create_glx_visual( dpy, visinfo ); |
| 1383 | if (!v) { |
| 1384 | /* unusable visual */ |
| 1385 | return 0; |
| 1386 | } |
| 1387 | } |
| 1388 | |
| 1389 | b = XMesaCreatePixmapBuffer( v, pixmap, 0 ); |
| 1390 | if (!b) { |
| 1391 | return 0; |
| 1392 | } |
| 1393 | return b->frontbuffer; |
| 1394 | } |
| 1395 | |
| 1396 | |
Brian Paul | b0bb4f6 | 2001-05-25 21:51:02 +0000 | [diff] [blame] | 1397 | /*** GLX_MESA_pixmap_colormap ***/ |
| 1398 | |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 1399 | static GLXPixmap |
| 1400 | Fake_glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visinfo, |
| 1401 | Pixmap pixmap, Colormap cmap ) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1402 | { |
| 1403 | XMesaVisual v; |
| 1404 | XMesaBuffer b; |
| 1405 | |
| 1406 | v = find_glx_visual( dpy, visinfo ); |
| 1407 | if (!v) { |
| 1408 | v = create_glx_visual( dpy, visinfo ); |
| 1409 | if (!v) { |
| 1410 | /* unusable visual */ |
| 1411 | return 0; |
| 1412 | } |
| 1413 | } |
| 1414 | |
| 1415 | b = XMesaCreatePixmapBuffer( v, pixmap, cmap ); |
| 1416 | if (!b) { |
| 1417 | return 0; |
| 1418 | } |
| 1419 | return b->frontbuffer; |
| 1420 | } |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1421 | |
| 1422 | |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 1423 | static void |
| 1424 | Fake_glXDestroyGLXPixmap( Display *dpy, GLXPixmap pixmap ) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1425 | { |
| 1426 | XMesaBuffer b = XMesaFindBuffer(dpy, pixmap); |
| 1427 | if (b) { |
| 1428 | XMesaDestroyBuffer(b); |
| 1429 | } |
Brian Paul | 367d308 | 2002-10-25 21:06:26 +0000 | [diff] [blame] | 1430 | else if (_mesa_getenv("MESA_DEBUG")) { |
Brian Paul | d09a1d8 | 2002-06-13 04:49:17 +0000 | [diff] [blame] | 1431 | _mesa_warning(NULL, "Mesa: glXDestroyGLXPixmap: invalid pixmap\n"); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1432 | } |
| 1433 | } |
| 1434 | |
| 1435 | |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 1436 | static void |
| 1437 | Fake_glXCopyContext( Display *dpy, GLXContext src, GLXContext dst, |
Brian Paul | 3994b77 | 2000-02-27 18:26:54 +0000 | [diff] [blame] | 1438 | unsigned long mask ) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1439 | { |
Brian Paul | 83b820a | 2002-06-16 03:56:11 +0000 | [diff] [blame] | 1440 | struct fake_glx_context *fakeSrc = (struct fake_glx_context *) src; |
| 1441 | struct fake_glx_context *fakeDst = (struct fake_glx_context *) dst; |
| 1442 | XMesaContext xm_src = fakeSrc->xmesaContext; |
| 1443 | XMesaContext xm_dst = fakeDst->xmesaContext; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1444 | (void) dpy; |
Brian Paul | 1e24d33 | 2003-04-01 17:28:10 +0000 | [diff] [blame] | 1445 | _mesa_copy_context( &(xm_src->mesa), &(xm_dst->mesa), (GLuint) mask ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1446 | } |
| 1447 | |
| 1448 | |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 1449 | static Bool |
| 1450 | Fake_glXQueryExtension( Display *dpy, int *errorb, int *event ) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1451 | { |
| 1452 | /* Mesa's GLX isn't really an X extension but we try to act like one. */ |
| 1453 | (void) dpy; |
| 1454 | (void) errorb; |
| 1455 | (void) event; |
| 1456 | return True; |
| 1457 | } |
| 1458 | |
| 1459 | |
Brian Paul | e7b16b7 | 2000-03-17 15:33:09 +0000 | [diff] [blame] | 1460 | extern void _kw_ungrab_all( Display *dpy ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1461 | void _kw_ungrab_all( Display *dpy ) |
| 1462 | { |
| 1463 | XUngrabPointer( dpy, CurrentTime ); |
| 1464 | XUngrabKeyboard( dpy, CurrentTime ); |
| 1465 | } |
| 1466 | |
| 1467 | |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 1468 | static void |
| 1469 | Fake_glXDestroyContext( Display *dpy, GLXContext ctx ) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1470 | { |
Brian Paul | 7cf50e1 | 2001-05-24 19:06:21 +0000 | [diff] [blame] | 1471 | struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1472 | (void) dpy; |
| 1473 | MakeCurrent_PrevContext = 0; |
| 1474 | MakeCurrent_PrevDrawable = 0; |
Brian Paul | 086a151 | 1999-11-25 17:37:49 +0000 | [diff] [blame] | 1475 | MakeCurrent_PrevReadable = 0; |
| 1476 | MakeCurrent_PrevDrawBuffer = 0; |
| 1477 | MakeCurrent_PrevReadBuffer = 0; |
Brian Paul | 7cf50e1 | 2001-05-24 19:06:21 +0000 | [diff] [blame] | 1478 | XMesaDestroyContext( glxCtx->xmesaContext ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1479 | XMesaGarbageCollect(); |
| 1480 | } |
| 1481 | |
| 1482 | |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 1483 | static Bool |
| 1484 | Fake_glXIsDirect( Display *dpy, GLXContext ctx ) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1485 | { |
Brian Paul | 7cf50e1 | 2001-05-24 19:06:21 +0000 | [diff] [blame] | 1486 | struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1487 | (void) dpy; |
Brian Paul | 7cf50e1 | 2001-05-24 19:06:21 +0000 | [diff] [blame] | 1488 | return glxCtx->xmesaContext->direct; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1489 | } |
| 1490 | |
| 1491 | |
| 1492 | |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 1493 | static void |
| 1494 | Fake_glXSwapBuffers( Display *dpy, GLXDrawable drawable ) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1495 | { |
| 1496 | XMesaBuffer buffer = XMesaFindBuffer( dpy, drawable ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1497 | |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1498 | if (buffer) { |
| 1499 | XMesaSwapBuffers(buffer); |
| 1500 | } |
Brian Paul | 367d308 | 2002-10-25 21:06:26 +0000 | [diff] [blame] | 1501 | else if (_mesa_getenv("MESA_DEBUG")) { |
Brian Paul | d09a1d8 | 2002-06-13 04:49:17 +0000 | [diff] [blame] | 1502 | _mesa_warning(NULL, "Mesa: glXSwapBuffers: invalid drawable\n"); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1503 | } |
| 1504 | } |
| 1505 | |
| 1506 | |
Brian Paul | 4c07bd5 | 2000-06-08 22:50:28 +0000 | [diff] [blame] | 1507 | |
Brian Paul | b0bb4f6 | 2001-05-25 21:51:02 +0000 | [diff] [blame] | 1508 | /*** GLX_MESA_copy_sub_buffer ***/ |
| 1509 | |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 1510 | static void |
| 1511 | Fake_glXCopySubBufferMESA( Display *dpy, GLXDrawable drawable, |
| 1512 | int x, int y, int width, int height ) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1513 | { |
| 1514 | XMesaBuffer buffer = XMesaFindBuffer( dpy, drawable ); |
| 1515 | if (buffer) { |
| 1516 | XMesaCopySubBuffer(buffer, x, y, width, height); |
| 1517 | } |
Brian Paul | 367d308 | 2002-10-25 21:06:26 +0000 | [diff] [blame] | 1518 | else if (_mesa_getenv("MESA_DEBUG")) { |
Brian Paul | d09a1d8 | 2002-06-13 04:49:17 +0000 | [diff] [blame] | 1519 | _mesa_warning(NULL, "Mesa: glXCopySubBufferMESA: invalid drawable\n"); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1520 | } |
| 1521 | } |
| 1522 | |
| 1523 | |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 1524 | static Bool |
| 1525 | Fake_glXQueryVersion( Display *dpy, int *maj, int *min ) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1526 | { |
| 1527 | (void) dpy; |
| 1528 | /* Return GLX version, not Mesa version */ |
Brian Paul | 78fc78e | 1999-11-22 22:17:06 +0000 | [diff] [blame] | 1529 | assert(CLIENT_MAJOR_VERSION == SERVER_MAJOR_VERSION); |
| 1530 | *maj = CLIENT_MAJOR_VERSION; |
| 1531 | *min = MIN2( CLIENT_MINOR_VERSION, SERVER_MINOR_VERSION ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1532 | return True; |
| 1533 | } |
| 1534 | |
| 1535 | |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1536 | /* |
| 1537 | * Query the GLX attributes of the given XVisualInfo. |
| 1538 | */ |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 1539 | static int |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 1540 | get_config( XMesaVisual xmvis, int attrib, int *value, GLboolean fbconfig ) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1541 | { |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 1542 | ASSERT(xmvis); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1543 | switch(attrib) { |
| 1544 | case GLX_USE_GL: |
| 1545 | *value = (int) True; |
| 1546 | return 0; |
| 1547 | case GLX_BUFFER_SIZE: |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 1548 | *value = xmvis->visinfo->depth; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1549 | return 0; |
| 1550 | case GLX_LEVEL: |
Ian Romanick | 304d3aa | 2004-02-19 00:57:04 +0000 | [diff] [blame] | 1551 | *value = xmvis->mesa_visual.level; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1552 | return 0; |
| 1553 | case GLX_RGBA: |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 1554 | if (xmvis->mesa_visual.rgbMode) { |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1555 | *value = True; |
| 1556 | } |
| 1557 | else { |
| 1558 | *value = False; |
| 1559 | } |
| 1560 | return 0; |
| 1561 | case GLX_DOUBLEBUFFER: |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 1562 | *value = (int) xmvis->mesa_visual.doubleBufferMode; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1563 | return 0; |
| 1564 | case GLX_STEREO: |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 1565 | *value = (int) xmvis->mesa_visual.stereoMode; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1566 | return 0; |
| 1567 | case GLX_AUX_BUFFERS: |
Brian Paul | 894844a | 2004-03-21 17:05:03 +0000 | [diff] [blame] | 1568 | *value = xmvis->mesa_visual.numAuxBuffers; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1569 | return 0; |
| 1570 | case GLX_RED_SIZE: |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 1571 | *value = xmvis->mesa_visual.redBits; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1572 | return 0; |
| 1573 | case GLX_GREEN_SIZE: |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 1574 | *value = xmvis->mesa_visual.greenBits; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1575 | return 0; |
| 1576 | case GLX_BLUE_SIZE: |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 1577 | *value = xmvis->mesa_visual.blueBits; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1578 | return 0; |
| 1579 | case GLX_ALPHA_SIZE: |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 1580 | *value = xmvis->mesa_visual.alphaBits; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1581 | return 0; |
| 1582 | case GLX_DEPTH_SIZE: |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 1583 | *value = xmvis->mesa_visual.depthBits; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1584 | return 0; |
| 1585 | case GLX_STENCIL_SIZE: |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 1586 | *value = xmvis->mesa_visual.stencilBits; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1587 | return 0; |
| 1588 | case GLX_ACCUM_RED_SIZE: |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 1589 | *value = xmvis->mesa_visual.accumRedBits; |
Brian Paul | b2e4600 | 2000-03-31 01:07:13 +0000 | [diff] [blame] | 1590 | return 0; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1591 | case GLX_ACCUM_GREEN_SIZE: |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 1592 | *value = xmvis->mesa_visual.accumGreenBits; |
Brian Paul | b2e4600 | 2000-03-31 01:07:13 +0000 | [diff] [blame] | 1593 | return 0; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1594 | case GLX_ACCUM_BLUE_SIZE: |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 1595 | *value = xmvis->mesa_visual.accumBlueBits; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1596 | return 0; |
| 1597 | case GLX_ACCUM_ALPHA_SIZE: |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 1598 | *value = xmvis->mesa_visual.accumAlphaBits; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1599 | return 0; |
| 1600 | |
| 1601 | /* |
| 1602 | * GLX_EXT_visual_info extension |
| 1603 | */ |
| 1604 | case GLX_X_VISUAL_TYPE_EXT: |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 1605 | switch (xmvis->visinfo->CLASS) { |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1606 | case StaticGray: *value = GLX_STATIC_GRAY_EXT; return 0; |
| 1607 | case GrayScale: *value = GLX_GRAY_SCALE_EXT; return 0; |
| 1608 | case StaticColor: *value = GLX_STATIC_GRAY_EXT; return 0; |
| 1609 | case PseudoColor: *value = GLX_PSEUDO_COLOR_EXT; return 0; |
| 1610 | case TrueColor: *value = GLX_TRUE_COLOR_EXT; return 0; |
| 1611 | case DirectColor: *value = GLX_DIRECT_COLOR_EXT; return 0; |
| 1612 | } |
| 1613 | return 0; |
| 1614 | case GLX_TRANSPARENT_TYPE_EXT: |
Ian Romanick | 304d3aa | 2004-02-19 00:57:04 +0000 | [diff] [blame] | 1615 | if (xmvis->mesa_visual.level==0) { |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1616 | /* normal planes */ |
| 1617 | *value = GLX_NONE_EXT; |
| 1618 | } |
Ian Romanick | 304d3aa | 2004-02-19 00:57:04 +0000 | [diff] [blame] | 1619 | else if (xmvis->mesa_visual.level>0) { |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1620 | /* overlay */ |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 1621 | if (xmvis->mesa_visual.rgbMode) { |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1622 | *value = GLX_TRANSPARENT_RGB_EXT; |
| 1623 | } |
| 1624 | else { |
| 1625 | *value = GLX_TRANSPARENT_INDEX_EXT; |
| 1626 | } |
| 1627 | } |
Ian Romanick | 304d3aa | 2004-02-19 00:57:04 +0000 | [diff] [blame] | 1628 | else if (xmvis->mesa_visual.level<0) { |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1629 | /* underlay */ |
| 1630 | *value = GLX_NONE_EXT; |
| 1631 | } |
| 1632 | return 0; |
| 1633 | case GLX_TRANSPARENT_INDEX_VALUE_EXT: |
| 1634 | { |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 1635 | int pixel = transparent_pixel( xmvis ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1636 | if (pixel>=0) { |
| 1637 | *value = pixel; |
| 1638 | } |
| 1639 | /* else undefined */ |
| 1640 | } |
| 1641 | return 0; |
| 1642 | case GLX_TRANSPARENT_RED_VALUE_EXT: |
| 1643 | /* undefined */ |
| 1644 | return 0; |
| 1645 | case GLX_TRANSPARENT_GREEN_VALUE_EXT: |
| 1646 | /* undefined */ |
| 1647 | return 0; |
| 1648 | case GLX_TRANSPARENT_BLUE_VALUE_EXT: |
| 1649 | /* undefined */ |
| 1650 | return 0; |
| 1651 | case GLX_TRANSPARENT_ALPHA_VALUE_EXT: |
| 1652 | /* undefined */ |
| 1653 | return 0; |
| 1654 | |
| 1655 | /* |
Brian Paul | b2e4600 | 2000-03-31 01:07:13 +0000 | [diff] [blame] | 1656 | * GLX_EXT_visual_info extension |
| 1657 | */ |
| 1658 | case GLX_VISUAL_CAVEAT_EXT: |
Brian Paul | fc68be6 | 2000-03-31 01:12:40 +0000 | [diff] [blame] | 1659 | /* test for zero, just in case */ |
Ian Romanick | 304d3aa | 2004-02-19 00:57:04 +0000 | [diff] [blame] | 1660 | if (xmvis->mesa_visual.visualRating > 0) |
| 1661 | *value = xmvis->mesa_visual.visualRating; |
Brian Paul | 962f426 | 2000-03-31 18:17:01 +0000 | [diff] [blame] | 1662 | else |
| 1663 | *value = GLX_NONE_EXT; |
| 1664 | return 0; |
Brian Paul | b2e4600 | 2000-03-31 01:07:13 +0000 | [diff] [blame] | 1665 | |
| 1666 | /* |
Brian Paul | 66ab727 | 2002-11-05 21:11:18 +0000 | [diff] [blame] | 1667 | * GLX_ARB_multisample |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1668 | */ |
Brian Paul | 66ab727 | 2002-11-05 21:11:18 +0000 | [diff] [blame] | 1669 | case GLX_SAMPLE_BUFFERS_ARB: |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 1670 | *value = 0; |
| 1671 | return 0; |
Brian Paul | 66ab727 | 2002-11-05 21:11:18 +0000 | [diff] [blame] | 1672 | case GLX_SAMPLES_ARB: |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 1673 | *value = 0; |
| 1674 | return 0; |
| 1675 | |
| 1676 | /* |
| 1677 | * For FBConfigs: |
| 1678 | */ |
| 1679 | case GLX_SCREEN_EXT: |
| 1680 | if (!fbconfig) |
| 1681 | return GLX_BAD_ATTRIBUTE; |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 1682 | *value = xmvis->visinfo->screen; |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 1683 | break; |
| 1684 | case GLX_DRAWABLE_TYPE: /*SGIX too */ |
| 1685 | if (!fbconfig) |
| 1686 | return GLX_BAD_ATTRIBUTE; |
| 1687 | *value = GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT; |
| 1688 | break; |
| 1689 | case GLX_RENDER_TYPE_SGIX: |
| 1690 | if (!fbconfig) |
| 1691 | return GLX_BAD_ATTRIBUTE; |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 1692 | if (xmvis->mesa_visual.rgbMode) |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 1693 | *value = GLX_RGBA_BIT; |
| 1694 | else |
| 1695 | *value = GLX_COLOR_INDEX_BIT; |
| 1696 | break; |
| 1697 | case GLX_X_RENDERABLE_SGIX: |
| 1698 | if (!fbconfig) |
| 1699 | return GLX_BAD_ATTRIBUTE; |
| 1700 | *value = True; /* XXX really? */ |
| 1701 | break; |
| 1702 | case GLX_FBCONFIG_ID_SGIX: |
| 1703 | if (!fbconfig) |
| 1704 | return GLX_BAD_ATTRIBUTE; |
Brian Paul | f104619 | 2002-11-10 17:07:06 +0000 | [diff] [blame] | 1705 | *value = xmvis->visinfo->visualid; |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 1706 | break; |
| 1707 | case GLX_MAX_PBUFFER_WIDTH: |
| 1708 | if (!fbconfig) |
| 1709 | return GLX_BAD_ATTRIBUTE; |
| 1710 | /* XXX or MAX_WIDTH? */ |
Brian Paul | f104619 | 2002-11-10 17:07:06 +0000 | [diff] [blame] | 1711 | *value = DisplayWidth(xmvis->display, xmvis->visinfo->screen); |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 1712 | break; |
| 1713 | case GLX_MAX_PBUFFER_HEIGHT: |
| 1714 | if (!fbconfig) |
| 1715 | return GLX_BAD_ATTRIBUTE; |
Brian Paul | f104619 | 2002-11-10 17:07:06 +0000 | [diff] [blame] | 1716 | *value = DisplayHeight(xmvis->display, xmvis->visinfo->screen); |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 1717 | break; |
| 1718 | case GLX_MAX_PBUFFER_PIXELS: |
| 1719 | if (!fbconfig) |
| 1720 | return GLX_BAD_ATTRIBUTE; |
Brian Paul | f104619 | 2002-11-10 17:07:06 +0000 | [diff] [blame] | 1721 | *value = DisplayWidth(xmvis->display, xmvis->visinfo->screen) * |
| 1722 | DisplayHeight(xmvis->display, xmvis->visinfo->screen); |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 1723 | break; |
| 1724 | case GLX_VISUAL_ID: |
| 1725 | if (!fbconfig) |
| 1726 | return GLX_BAD_ATTRIBUTE; |
Brian Paul | f104619 | 2002-11-10 17:07:06 +0000 | [diff] [blame] | 1727 | *value = xmvis->visinfo->visualid; |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 1728 | break; |
| 1729 | |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1730 | default: |
| 1731 | return GLX_BAD_ATTRIBUTE; |
| 1732 | } |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 1733 | return Success; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1734 | } |
| 1735 | |
| 1736 | |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 1737 | static int |
| 1738 | Fake_glXGetConfig( Display *dpy, XVisualInfo *visinfo, |
| 1739 | int attrib, int *value ) |
| 1740 | { |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 1741 | XMesaVisual xmvis; |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 1742 | |
Brian Paul | 3796419 | 2003-12-12 00:08:01 +0000 | [diff] [blame] | 1743 | if (!dpy || !visinfo) |
Brian Paul | a9a1c3f | 2003-12-12 00:01:17 +0000 | [diff] [blame] | 1744 | return GLX_BAD_ATTRIBUTE; |
| 1745 | |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 1746 | xmvis = find_glx_visual( dpy, visinfo ); |
| 1747 | if (!xmvis) { |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 1748 | /* this visual wasn't obtained with glXChooseVisual */ |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 1749 | xmvis = create_glx_visual( dpy, visinfo ); |
| 1750 | if (!xmvis) { |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 1751 | /* this visual can't be used for GL rendering */ |
| 1752 | if (attrib==GLX_USE_GL) { |
| 1753 | *value = (int) False; |
| 1754 | return 0; |
| 1755 | } |
| 1756 | else { |
| 1757 | return GLX_BAD_VISUAL; |
| 1758 | } |
| 1759 | } |
| 1760 | } |
| 1761 | |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 1762 | return get_config(xmvis, attrib, value, GL_FALSE); |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 1763 | } |
| 1764 | |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1765 | |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 1766 | static void |
| 1767 | Fake_glXWaitGL( void ) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1768 | { |
| 1769 | XMesaContext xmesa = XMesaGetCurrentContext(); |
| 1770 | XMesaFlush( xmesa ); |
| 1771 | } |
| 1772 | |
| 1773 | |
| 1774 | |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 1775 | static void |
| 1776 | Fake_glXWaitX( void ) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1777 | { |
| 1778 | XMesaContext xmesa = XMesaGetCurrentContext(); |
| 1779 | XMesaFlush( xmesa ); |
| 1780 | } |
| 1781 | |
| 1782 | |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 1783 | static const char * |
| 1784 | get_extensions( void ) |
Brian Paul | 43c9c2c | 1999-09-16 15:52:51 +0000 | [diff] [blame] | 1785 | { |
| 1786 | #ifdef FX |
Brian Paul | 367d308 | 2002-10-25 21:06:26 +0000 | [diff] [blame] | 1787 | const char *fx = _mesa_getenv("MESA_GLX_FX"); |
Brian Paul | 43c9c2c | 1999-09-16 15:52:51 +0000 | [diff] [blame] | 1788 | if (fx && fx[0] != 'd') { |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 1789 | return EXTENSIONS; |
Brian Paul | 43c9c2c | 1999-09-16 15:52:51 +0000 | [diff] [blame] | 1790 | } |
| 1791 | #endif |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 1792 | return EXTENSIONS + 23; /* skip "GLX_MESA_set_3dfx_mode" */ |
Brian Paul | 43c9c2c | 1999-09-16 15:52:51 +0000 | [diff] [blame] | 1793 | } |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1794 | |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1795 | |
| 1796 | |
| 1797 | /* GLX 1.1 and later */ |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 1798 | static const char * |
| 1799 | Fake_glXQueryExtensionsString( Display *dpy, int screen ) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1800 | { |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1801 | (void) dpy; |
| 1802 | (void) screen; |
Brian Paul | 43c9c2c | 1999-09-16 15:52:51 +0000 | [diff] [blame] | 1803 | return get_extensions(); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1804 | } |
| 1805 | |
| 1806 | |
| 1807 | |
| 1808 | /* GLX 1.1 and later */ |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 1809 | static const char * |
| 1810 | Fake_glXQueryServerString( Display *dpy, int screen, int name ) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1811 | { |
Brian Paul | 78fc78e | 1999-11-22 22:17:06 +0000 | [diff] [blame] | 1812 | static char version[1000]; |
Brian Paul | 2ad5921 | 2002-10-30 20:24:45 +0000 | [diff] [blame] | 1813 | _mesa_sprintf(version, "%d.%d %s", |
| 1814 | SERVER_MAJOR_VERSION, SERVER_MINOR_VERSION, MESA_GLX_VERSION); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1815 | |
| 1816 | (void) dpy; |
| 1817 | (void) screen; |
| 1818 | |
| 1819 | switch (name) { |
| 1820 | case GLX_EXTENSIONS: |
Brian Paul | 43c9c2c | 1999-09-16 15:52:51 +0000 | [diff] [blame] | 1821 | return get_extensions(); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1822 | case GLX_VENDOR: |
Brian Paul | 78fc78e | 1999-11-22 22:17:06 +0000 | [diff] [blame] | 1823 | return VENDOR; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1824 | case GLX_VERSION: |
| 1825 | return version; |
| 1826 | default: |
| 1827 | return NULL; |
| 1828 | } |
| 1829 | } |
| 1830 | |
| 1831 | |
| 1832 | |
| 1833 | /* GLX 1.1 and later */ |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 1834 | static const char * |
| 1835 | Fake_glXGetClientString( Display *dpy, int name ) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1836 | { |
Brian Paul | 78fc78e | 1999-11-22 22:17:06 +0000 | [diff] [blame] | 1837 | static char version[1000]; |
Brian Paul | 2ad5921 | 2002-10-30 20:24:45 +0000 | [diff] [blame] | 1838 | _mesa_sprintf(version, "%d.%d %s", CLIENT_MAJOR_VERSION, |
| 1839 | CLIENT_MINOR_VERSION, MESA_GLX_VERSION); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1840 | |
| 1841 | (void) dpy; |
| 1842 | |
| 1843 | switch (name) { |
| 1844 | case GLX_EXTENSIONS: |
Brian Paul | 43c9c2c | 1999-09-16 15:52:51 +0000 | [diff] [blame] | 1845 | return get_extensions(); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1846 | case GLX_VENDOR: |
Brian Paul | 78fc78e | 1999-11-22 22:17:06 +0000 | [diff] [blame] | 1847 | return VENDOR; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1848 | case GLX_VERSION: |
| 1849 | return version; |
| 1850 | default: |
| 1851 | return NULL; |
| 1852 | } |
| 1853 | } |
| 1854 | |
| 1855 | |
| 1856 | |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 1857 | /* |
| 1858 | * GLX 1.3 and later |
| 1859 | */ |
| 1860 | |
Brian Paul | 7d5656b | 2001-09-01 20:23:25 +0000 | [diff] [blame] | 1861 | |
Brian Paul | 5605798 | 2000-04-10 21:13:19 +0000 | [diff] [blame] | 1862 | static GLXFBConfig * |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 1863 | Fake_glXChooseFBConfig( Display *dpy, int screen, |
| 1864 | const int *attribList, int *nitems ) |
| 1865 | { |
Brian Paul | b3063ac | 2004-02-04 23:39:19 +0000 | [diff] [blame] | 1866 | XMesaVisual xmvis = choose_visual(dpy, screen, attribList, GL_TRUE); |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 1867 | if (xmvis) { |
Brian Paul | 4039cb8 | 2003-02-25 19:25:52 +0000 | [diff] [blame] | 1868 | GLXFBConfig *config = (GLXFBConfig *) _mesa_malloc(sizeof(XMesaVisual)); |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 1869 | if (!config) { |
| 1870 | *nitems = 0; |
| 1871 | return NULL; |
| 1872 | } |
| 1873 | *nitems = 1; |
| 1874 | config[0] = (GLXFBConfig) xmvis; |
| 1875 | return (GLXFBConfig *) config; |
| 1876 | } |
| 1877 | else { |
| 1878 | *nitems = 0; |
| 1879 | return NULL; |
| 1880 | } |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 1881 | } |
| 1882 | |
| 1883 | |
| 1884 | static int |
| 1885 | Fake_glXGetFBConfigAttrib( Display *dpy, GLXFBConfig config, |
| 1886 | int attribute, int *value ) |
| 1887 | { |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 1888 | XMesaVisual v = (XMesaVisual) config; |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 1889 | (void) dpy; |
| 1890 | (void) config; |
Brian Paul | 7d5656b | 2001-09-01 20:23:25 +0000 | [diff] [blame] | 1891 | |
| 1892 | if (!dpy || !config || !value) |
| 1893 | return -1; |
| 1894 | |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 1895 | return get_config(v, attribute, value, GL_TRUE); |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 1896 | } |
| 1897 | |
| 1898 | |
Brian Paul | 5605798 | 2000-04-10 21:13:19 +0000 | [diff] [blame] | 1899 | static GLXFBConfig * |
| 1900 | Fake_glXGetFBConfigs( Display *dpy, int screen, int *nelements ) |
| 1901 | { |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 1902 | XVisualInfo *visuals, visTemplate; |
| 1903 | const long visMask = VisualScreenMask; |
| 1904 | int i; |
| 1905 | |
| 1906 | /* Get list of all X visuals */ |
| 1907 | visTemplate.screen = screen; |
| 1908 | visuals = XGetVisualInfo(dpy, visMask, &visTemplate, nelements); |
| 1909 | if (*nelements > 0) { |
| 1910 | XMesaVisual *results; |
Brian Paul | 4039cb8 | 2003-02-25 19:25:52 +0000 | [diff] [blame] | 1911 | results = (XMesaVisual *) _mesa_malloc(*nelements * sizeof(XMesaVisual)); |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 1912 | if (!results) { |
| 1913 | *nelements = 0; |
| 1914 | return NULL; |
| 1915 | } |
| 1916 | for (i = 0; i < *nelements; i++) { |
| 1917 | results[i] = create_glx_visual(dpy, visuals + i); |
| 1918 | } |
| 1919 | return (GLXFBConfig *) results; |
| 1920 | } |
| 1921 | return NULL; |
Brian Paul | 5605798 | 2000-04-10 21:13:19 +0000 | [diff] [blame] | 1922 | } |
| 1923 | |
| 1924 | |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 1925 | static XVisualInfo * |
| 1926 | Fake_glXGetVisualFromFBConfig( Display *dpy, GLXFBConfig config ) |
| 1927 | { |
Brian Paul | 7d5656b | 2001-09-01 20:23:25 +0000 | [diff] [blame] | 1928 | if (dpy && config) { |
Brian Paul | f104619 | 2002-11-10 17:07:06 +0000 | [diff] [blame] | 1929 | XMesaVisual xmvis = (XMesaVisual) config; |
| 1930 | #if 0 |
| 1931 | return xmvis->vishandle; |
| 1932 | #else |
| 1933 | /* create a new vishandle - the cached one may be stale */ |
Brian Paul | 4039cb8 | 2003-02-25 19:25:52 +0000 | [diff] [blame] | 1934 | xmvis->vishandle = (XVisualInfo *) _mesa_malloc(sizeof(XVisualInfo)); |
Brian Paul | f104619 | 2002-11-10 17:07:06 +0000 | [diff] [blame] | 1935 | if (xmvis->vishandle) { |
| 1936 | _mesa_memcpy(xmvis->vishandle, xmvis->visinfo, sizeof(XVisualInfo)); |
| 1937 | } |
| 1938 | return xmvis->vishandle; |
| 1939 | #endif |
Brian Paul | 7d5656b | 2001-09-01 20:23:25 +0000 | [diff] [blame] | 1940 | } |
| 1941 | else { |
| 1942 | return NULL; |
| 1943 | } |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 1944 | } |
| 1945 | |
| 1946 | |
| 1947 | static GLXWindow |
| 1948 | Fake_glXCreateWindow( Display *dpy, GLXFBConfig config, Window win, |
| 1949 | const int *attribList ) |
| 1950 | { |
Brian Paul | 529614c | 2004-02-08 00:11:14 +0000 | [diff] [blame] | 1951 | XMesaVisual xmvis = (XMesaVisual) config; |
| 1952 | XMesaBuffer xmbuf; |
| 1953 | if (!xmvis) |
| 1954 | return 0; |
| 1955 | |
| 1956 | xmbuf = XMesaCreateWindowBuffer2(xmvis, win, NULL); |
| 1957 | if (!xmbuf) |
| 1958 | return 0; |
| 1959 | |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 1960 | (void) dpy; |
Brian Paul | 7d5656b | 2001-09-01 20:23:25 +0000 | [diff] [blame] | 1961 | (void) attribList; /* Ignored in GLX 1.3 */ |
| 1962 | |
| 1963 | return win; /* A hack for now */ |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 1964 | } |
| 1965 | |
| 1966 | |
| 1967 | static void |
| 1968 | Fake_glXDestroyWindow( Display *dpy, GLXWindow window ) |
| 1969 | { |
Brian Paul | 7d5656b | 2001-09-01 20:23:25 +0000 | [diff] [blame] | 1970 | XMesaBuffer b = XMesaFindBuffer(dpy, (XMesaDrawable) window); |
| 1971 | if (b) |
| 1972 | XMesaDestroyBuffer(b); |
| 1973 | /* don't destroy X window */ |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 1974 | } |
| 1975 | |
| 1976 | |
Brian Paul | 7d5656b | 2001-09-01 20:23:25 +0000 | [diff] [blame] | 1977 | /* XXX untested */ |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 1978 | static GLXPixmap |
| 1979 | Fake_glXCreatePixmap( Display *dpy, GLXFBConfig config, Pixmap pixmap, |
| 1980 | const int *attribList ) |
| 1981 | { |
Brian Paul | 7d5656b | 2001-09-01 20:23:25 +0000 | [diff] [blame] | 1982 | XMesaVisual v = (XMesaVisual) config; |
Brian Paul | 7d5656b | 2001-09-01 20:23:25 +0000 | [diff] [blame] | 1983 | XMesaBuffer b; |
| 1984 | |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 1985 | (void) dpy; |
| 1986 | (void) config; |
| 1987 | (void) pixmap; |
Brian Paul | 7d5656b | 2001-09-01 20:23:25 +0000 | [diff] [blame] | 1988 | (void) attribList; /* Ignored in GLX 1.3 */ |
| 1989 | |
| 1990 | if (!dpy || !config || !pixmap) |
| 1991 | return 0; |
| 1992 | |
Brian Paul | 7d5656b | 2001-09-01 20:23:25 +0000 | [diff] [blame] | 1993 | b = XMesaCreatePixmapBuffer( v, pixmap, 0 ); |
| 1994 | if (!b) { |
| 1995 | return 0; |
| 1996 | } |
| 1997 | |
| 1998 | return pixmap; |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 1999 | } |
| 2000 | |
| 2001 | |
| 2002 | static void |
| 2003 | Fake_glXDestroyPixmap( Display *dpy, GLXPixmap pixmap ) |
| 2004 | { |
Brian Paul | 7d5656b | 2001-09-01 20:23:25 +0000 | [diff] [blame] | 2005 | XMesaBuffer b = XMesaFindBuffer(dpy, (XMesaDrawable)pixmap); |
| 2006 | if (b) |
| 2007 | XMesaDestroyBuffer(b); |
| 2008 | /* don't destroy X pixmap */ |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 2009 | } |
| 2010 | |
| 2011 | |
| 2012 | static GLXPbuffer |
| 2013 | Fake_glXCreatePbuffer( Display *dpy, GLXFBConfig config, |
| 2014 | const int *attribList ) |
| 2015 | { |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 2016 | XMesaVisual xmvis = (XMesaVisual) config; |
| 2017 | XMesaBuffer xmbuf; |
Brian Paul | 7d5656b | 2001-09-01 20:23:25 +0000 | [diff] [blame] | 2018 | const int *attrib; |
| 2019 | int width = 0, height = 0; |
| 2020 | GLboolean useLargest = GL_FALSE, preserveContents = GL_FALSE; |
| 2021 | |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 2022 | (void) dpy; |
Brian Paul | 7d5656b | 2001-09-01 20:23:25 +0000 | [diff] [blame] | 2023 | |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 2024 | for (attrib = attribList; *attrib; attrib++) { |
Brian Paul | 7d5656b | 2001-09-01 20:23:25 +0000 | [diff] [blame] | 2025 | switch (*attrib) { |
| 2026 | case GLX_PBUFFER_WIDTH: |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 2027 | attrib++; |
| 2028 | width = *attrib; |
Brian Paul | 7d5656b | 2001-09-01 20:23:25 +0000 | [diff] [blame] | 2029 | break; |
| 2030 | case GLX_PBUFFER_HEIGHT: |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 2031 | attrib++; |
| 2032 | height = *attrib; |
Brian Paul | 7d5656b | 2001-09-01 20:23:25 +0000 | [diff] [blame] | 2033 | break; |
| 2034 | case GLX_PRESERVED_CONTENTS: |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 2035 | attrib++; |
| 2036 | preserveContents = *attrib; /* ignored */ |
Brian Paul | 7d5656b | 2001-09-01 20:23:25 +0000 | [diff] [blame] | 2037 | break; |
| 2038 | case GLX_LARGEST_PBUFFER: |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 2039 | attrib++; |
| 2040 | useLargest = *attrib; /* ignored */ |
Brian Paul | 7d5656b | 2001-09-01 20:23:25 +0000 | [diff] [blame] | 2041 | break; |
| 2042 | default: |
| 2043 | return 0; |
| 2044 | } |
| 2045 | } |
| 2046 | |
Brian Paul | b305028 | 2003-12-04 03:19:46 +0000 | [diff] [blame] | 2047 | /* not used at this time */ |
| 2048 | (void) useLargest; |
| 2049 | (void) preserveContents; |
| 2050 | |
Brian Paul | 7d5656b | 2001-09-01 20:23:25 +0000 | [diff] [blame] | 2051 | if (width == 0 || height == 0) |
| 2052 | return 0; |
| 2053 | |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 2054 | xmbuf = XMesaCreatePBuffer( xmvis, 0, width, height); |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 2055 | /* A GLXPbuffer handle must be an X Drawable because that's what |
| 2056 | * glXMakeCurrent takes. |
| 2057 | */ |
| 2058 | return (GLXPbuffer) xmbuf->frontbuffer; |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 2059 | } |
| 2060 | |
| 2061 | |
| 2062 | static void |
| 2063 | Fake_glXDestroyPbuffer( Display *dpy, GLXPbuffer pbuf ) |
| 2064 | { |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 2065 | XMesaBuffer b = XMesaFindBuffer(dpy, pbuf); |
| 2066 | if (b) { |
| 2067 | XMesaDestroyBuffer(b); |
| 2068 | } |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 2069 | } |
| 2070 | |
| 2071 | |
| 2072 | static void |
| 2073 | Fake_glXQueryDrawable( Display *dpy, GLXDrawable draw, int attribute, |
| 2074 | unsigned int *value ) |
| 2075 | { |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 2076 | XMesaBuffer xmbuf = XMesaFindBuffer(dpy, draw); |
| 2077 | if (!xmbuf) |
| 2078 | return; |
Brian Paul | 7d5656b | 2001-09-01 20:23:25 +0000 | [diff] [blame] | 2079 | |
| 2080 | switch (attribute) { |
| 2081 | case GLX_WIDTH: |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 2082 | *value = xmbuf->width; |
| 2083 | break; |
Brian Paul | 7d5656b | 2001-09-01 20:23:25 +0000 | [diff] [blame] | 2084 | case GLX_HEIGHT: |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 2085 | *value = xmbuf->height; |
| 2086 | break; |
Brian Paul | 7d5656b | 2001-09-01 20:23:25 +0000 | [diff] [blame] | 2087 | case GLX_PRESERVED_CONTENTS: |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 2088 | *value = True; |
| 2089 | break; |
Brian Paul | 7d5656b | 2001-09-01 20:23:25 +0000 | [diff] [blame] | 2090 | case GLX_LARGEST_PBUFFER: |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 2091 | *value = xmbuf->width * xmbuf->height; |
| 2092 | break; |
Brian Paul | 7d5656b | 2001-09-01 20:23:25 +0000 | [diff] [blame] | 2093 | case GLX_FBCONFIG_ID: |
Brian Paul | f104619 | 2002-11-10 17:07:06 +0000 | [diff] [blame] | 2094 | *value = xmbuf->xm_visual->visinfo->visualid; |
Brian Paul | 7d5656b | 2001-09-01 20:23:25 +0000 | [diff] [blame] | 2095 | return; |
| 2096 | default: |
| 2097 | return; /* GLX_BAD_ATTRIBUTE? */ |
| 2098 | } |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 2099 | } |
| 2100 | |
| 2101 | |
| 2102 | static GLXContext |
| 2103 | Fake_glXCreateNewContext( Display *dpy, GLXFBConfig config, |
| 2104 | int renderType, GLXContext shareList, Bool direct ) |
| 2105 | { |
Brian Paul | f104619 | 2002-11-10 17:07:06 +0000 | [diff] [blame] | 2106 | struct fake_glx_context *glxCtx; |
| 2107 | struct fake_glx_context *shareCtx = (struct fake_glx_context *) shareList; |
| 2108 | XMesaVisual xmvis = (XMesaVisual) config; |
Brian Paul | 7d5656b | 2001-09-01 20:23:25 +0000 | [diff] [blame] | 2109 | |
| 2110 | if (!dpy || !config || |
| 2111 | (renderType != GLX_RGBA_TYPE && renderType != GLX_COLOR_INDEX_TYPE)) |
| 2112 | return 0; |
| 2113 | |
Brian Paul | f104619 | 2002-11-10 17:07:06 +0000 | [diff] [blame] | 2114 | glxCtx = CALLOC_STRUCT(fake_glx_context); |
| 2115 | if (!glxCtx) |
| 2116 | return 0; |
| 2117 | |
| 2118 | /* deallocate unused windows/buffers */ |
| 2119 | XMesaGarbageCollect(); |
| 2120 | |
| 2121 | glxCtx->xmesaContext = XMesaCreateContext(xmvis, |
| 2122 | shareCtx ? shareCtx->xmesaContext : NULL); |
| 2123 | if (!glxCtx->xmesaContext) { |
| 2124 | FREE(glxCtx); |
| 2125 | return NULL; |
| 2126 | } |
| 2127 | |
| 2128 | glxCtx->xmesaContext->direct = GL_FALSE; |
| 2129 | glxCtx->glxContext.isDirect = GL_FALSE; |
| 2130 | glxCtx->glxContext.currentDpy = dpy; |
| 2131 | glxCtx->glxContext.xid = (XID) glxCtx; /* self pointer */ |
| 2132 | |
| 2133 | assert((void *) glxCtx == (void *) &(glxCtx->glxContext)); |
| 2134 | |
| 2135 | return (GLXContext) glxCtx; |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 2136 | } |
| 2137 | |
| 2138 | |
| 2139 | static int |
| 2140 | Fake_glXQueryContext( Display *dpy, GLXContext ctx, int attribute, int *value ) |
| 2141 | { |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 2142 | struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx; |
| 2143 | XMesaContext xmctx = glxCtx->xmesaContext; |
| 2144 | |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 2145 | (void) dpy; |
| 2146 | (void) ctx; |
Brian Paul | 7d5656b | 2001-09-01 20:23:25 +0000 | [diff] [blame] | 2147 | |
| 2148 | switch (attribute) { |
| 2149 | case GLX_FBCONFIG_ID: |
Brian Paul | f104619 | 2002-11-10 17:07:06 +0000 | [diff] [blame] | 2150 | *value = xmctx->xm_visual->visinfo->visualid; |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 2151 | break; |
Brian Paul | 7d5656b | 2001-09-01 20:23:25 +0000 | [diff] [blame] | 2152 | case GLX_RENDER_TYPE: |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 2153 | if (xmctx->xm_visual->mesa_visual.rgbMode) |
| 2154 | *value = GLX_RGBA_BIT; |
| 2155 | else |
| 2156 | *value = GLX_COLOR_INDEX_BIT; |
| 2157 | break; |
Brian Paul | 7d5656b | 2001-09-01 20:23:25 +0000 | [diff] [blame] | 2158 | case GLX_SCREEN: |
| 2159 | *value = 0; |
| 2160 | return Success; |
| 2161 | default: |
| 2162 | return GLX_BAD_ATTRIBUTE; |
| 2163 | } |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 2164 | return 0; |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 2165 | } |
| 2166 | |
| 2167 | |
| 2168 | static void |
| 2169 | Fake_glXSelectEvent( Display *dpy, GLXDrawable drawable, unsigned long mask ) |
| 2170 | { |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 2171 | XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable); |
| 2172 | if (xmbuf) |
| 2173 | xmbuf->selectedEvents = mask; |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 2174 | } |
| 2175 | |
| 2176 | |
| 2177 | static void |
| 2178 | Fake_glXGetSelectedEvent( Display *dpy, GLXDrawable drawable, |
| 2179 | unsigned long *mask ) |
| 2180 | { |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 2181 | XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable); |
| 2182 | if (xmbuf) |
| 2183 | *mask = xmbuf->selectedEvents; |
| 2184 | else |
| 2185 | *mask = 0; |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 2186 | } |
Brian Paul | b82d993 | 1999-11-22 21:52:23 +0000 | [diff] [blame] | 2187 | |
| 2188 | |
| 2189 | |
Brian Paul | b0bb4f6 | 2001-05-25 21:51:02 +0000 | [diff] [blame] | 2190 | /*** GLX_SGI_swap_control ***/ |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2191 | |
| 2192 | static int |
| 2193 | Fake_glXSwapIntervalSGI(int interval) |
| 2194 | { |
| 2195 | (void) interval; |
| 2196 | return 0; |
| 2197 | } |
| 2198 | |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2199 | |
| 2200 | |
Brian Paul | b0bb4f6 | 2001-05-25 21:51:02 +0000 | [diff] [blame] | 2201 | /*** GLX_SGI_video_sync ***/ |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2202 | |
| 2203 | static int |
| 2204 | Fake_glXGetVideoSyncSGI(unsigned int *count) |
| 2205 | { |
| 2206 | (void) count; |
| 2207 | return 0; |
| 2208 | } |
| 2209 | |
| 2210 | static int |
| 2211 | Fake_glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count) |
| 2212 | { |
| 2213 | (void) divisor; |
| 2214 | (void) remainder; |
| 2215 | (void) count; |
| 2216 | return 0; |
| 2217 | } |
| 2218 | |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2219 | |
| 2220 | |
Brian Paul | b0bb4f6 | 2001-05-25 21:51:02 +0000 | [diff] [blame] | 2221 | /*** GLX_SGI_make_current_read ***/ |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2222 | |
| 2223 | static Bool |
| 2224 | Fake_glXMakeCurrentReadSGI(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx) |
| 2225 | { |
Brian Paul | a078d75 | 2002-05-27 17:06:59 +0000 | [diff] [blame] | 2226 | return Fake_glXMakeContextCurrent( dpy, draw, read, ctx ); |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2227 | } |
| 2228 | |
Brian Paul | 7cf50e1 | 2001-05-24 19:06:21 +0000 | [diff] [blame] | 2229 | /* not used |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2230 | static GLXDrawable |
Brian Paul | b0bb4f6 | 2001-05-25 21:51:02 +0000 | [diff] [blame] | 2231 | Fake_glXGetCurrentReadDrawableSGI(void) |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2232 | { |
| 2233 | return 0; |
| 2234 | } |
Brian Paul | 7cf50e1 | 2001-05-24 19:06:21 +0000 | [diff] [blame] | 2235 | */ |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2236 | |
| 2237 | |
Brian Paul | b0bb4f6 | 2001-05-25 21:51:02 +0000 | [diff] [blame] | 2238 | /*** GLX_SGIX_video_source ***/ |
| 2239 | #if defined(_VL_H) |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2240 | |
| 2241 | static GLXVideoSourceSGIX |
| 2242 | Fake_glXCreateGLXVideoSourceSGIX(Display *dpy, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode) |
| 2243 | { |
| 2244 | (void) dpy; |
| 2245 | (void) screen; |
| 2246 | (void) server; |
| 2247 | (void) path; |
| 2248 | (void) nodeClass; |
| 2249 | (void) drainNode; |
| 2250 | return 0; |
| 2251 | } |
| 2252 | |
| 2253 | static void |
| 2254 | Fake_glXDestroyGLXVideoSourceSGIX(Display *dpy, GLXVideoSourceSGIX src) |
| 2255 | { |
| 2256 | (void) dpy; |
| 2257 | (void) src; |
| 2258 | } |
| 2259 | |
| 2260 | #endif |
| 2261 | |
| 2262 | |
Brian Paul | b0bb4f6 | 2001-05-25 21:51:02 +0000 | [diff] [blame] | 2263 | /*** GLX_EXT_import_context ***/ |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2264 | |
| 2265 | static void |
| 2266 | Fake_glXFreeContextEXT(Display *dpy, GLXContext context) |
| 2267 | { |
| 2268 | (void) dpy; |
| 2269 | (void) context; |
| 2270 | } |
| 2271 | |
| 2272 | static GLXContextID |
| 2273 | Fake_glXGetContextIDEXT(const GLXContext context) |
| 2274 | { |
| 2275 | (void) context; |
| 2276 | return 0; |
| 2277 | } |
| 2278 | |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2279 | static GLXContext |
| 2280 | Fake_glXImportContextEXT(Display *dpy, GLXContextID contextID) |
| 2281 | { |
| 2282 | (void) dpy; |
| 2283 | (void) contextID; |
| 2284 | return 0; |
| 2285 | } |
| 2286 | |
| 2287 | static int |
| 2288 | Fake_glXQueryContextInfoEXT(Display *dpy, GLXContext context, int attribute, int *value) |
| 2289 | { |
| 2290 | (void) dpy; |
| 2291 | (void) context; |
| 2292 | (void) attribute; |
| 2293 | (void) value; |
| 2294 | return 0; |
| 2295 | } |
| 2296 | |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2297 | |
| 2298 | |
Brian Paul | b0bb4f6 | 2001-05-25 21:51:02 +0000 | [diff] [blame] | 2299 | /*** GLX_SGIX_fbconfig ***/ |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2300 | |
| 2301 | static int |
| 2302 | Fake_glXGetFBConfigAttribSGIX(Display *dpy, GLXFBConfigSGIX config, int attribute, int *value) |
| 2303 | { |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 2304 | return Fake_glXGetFBConfigAttrib(dpy, config, attribute, value); |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2305 | } |
| 2306 | |
| 2307 | static GLXFBConfigSGIX * |
| 2308 | Fake_glXChooseFBConfigSGIX(Display *dpy, int screen, int *attrib_list, int *nelements) |
| 2309 | { |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 2310 | return (GLXFBConfig *) Fake_glXChooseFBConfig(dpy, screen, attrib_list, nelements); |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2311 | } |
| 2312 | |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 2313 | |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2314 | static GLXPixmap |
| 2315 | Fake_glXCreateGLXPixmapWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap) |
| 2316 | { |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 2317 | XMesaVisual xmvis = (XMesaVisual) config; |
| 2318 | XMesaBuffer xmbuf = XMesaCreatePixmapBuffer(xmvis, pixmap, 0); |
| 2319 | return xmbuf->frontbuffer; /* need to return an X ID */ |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2320 | } |
| 2321 | |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 2322 | |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2323 | static GLXContext |
| 2324 | Fake_glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct) |
| 2325 | { |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 2326 | XMesaVisual xmvis = (XMesaVisual) config; |
| 2327 | struct fake_glx_context *glxCtx; |
| 2328 | struct fake_glx_context *shareCtx = (struct fake_glx_context *) share_list; |
| 2329 | |
| 2330 | glxCtx = CALLOC_STRUCT(fake_glx_context); |
| 2331 | if (!glxCtx) |
| 2332 | return 0; |
| 2333 | |
| 2334 | /* deallocate unused windows/buffers */ |
| 2335 | XMesaGarbageCollect(); |
| 2336 | |
| 2337 | glxCtx->xmesaContext = XMesaCreateContext(xmvis, |
| 2338 | shareCtx ? shareCtx->xmesaContext : NULL); |
| 2339 | if (!glxCtx->xmesaContext) { |
| 2340 | FREE(glxCtx); |
| 2341 | return NULL; |
| 2342 | } |
| 2343 | |
| 2344 | glxCtx->xmesaContext->direct = GL_FALSE; |
| 2345 | glxCtx->glxContext.isDirect = GL_FALSE; |
| 2346 | glxCtx->glxContext.currentDpy = dpy; |
| 2347 | glxCtx->glxContext.xid = (XID) glxCtx; /* self pointer */ |
| 2348 | |
| 2349 | assert((void *) glxCtx == (void *) &(glxCtx->glxContext)); |
| 2350 | |
| 2351 | return (GLXContext) glxCtx; |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2352 | } |
| 2353 | |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 2354 | |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2355 | static XVisualInfo * |
| 2356 | Fake_glXGetVisualFromFBConfigSGIX(Display *dpy, GLXFBConfigSGIX config) |
| 2357 | { |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 2358 | return Fake_glXGetVisualFromFBConfig(dpy, config); |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2359 | } |
| 2360 | |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 2361 | |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2362 | static GLXFBConfigSGIX |
| 2363 | Fake_glXGetFBConfigFromVisualSGIX(Display *dpy, XVisualInfo *vis) |
| 2364 | { |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 2365 | XMesaVisual xmvis = find_glx_visual(dpy, vis); |
| 2366 | if (!xmvis) { |
| 2367 | /* This visual wasn't found with glXChooseVisual() */ |
| 2368 | xmvis = create_glx_visual(dpy, vis); |
| 2369 | } |
| 2370 | |
| 2371 | return (GLXFBConfigSGIX) xmvis; |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2372 | } |
| 2373 | |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2374 | |
| 2375 | |
Brian Paul | b0bb4f6 | 2001-05-25 21:51:02 +0000 | [diff] [blame] | 2376 | /*** GLX_SGIX_pbuffer ***/ |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2377 | |
| 2378 | static GLXPbufferSGIX |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 2379 | Fake_glXCreateGLXPbufferSGIX(Display *dpy, GLXFBConfigSGIX config, |
| 2380 | unsigned int width, unsigned int height, |
| 2381 | int *attribList) |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2382 | { |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 2383 | XMesaVisual xmvis = (XMesaVisual) config; |
| 2384 | XMesaBuffer xmbuf; |
| 2385 | const int *attrib; |
| 2386 | GLboolean useLargest = GL_FALSE, preserveContents = GL_FALSE; |
| 2387 | |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2388 | (void) dpy; |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 2389 | |
Brian Paul | 11b3028 | 2004-05-29 14:41:52 +0000 | [diff] [blame] | 2390 | for (attrib = attribList; attrib && *attrib; attrib++) { |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 2391 | switch (*attrib) { |
| 2392 | case GLX_PRESERVED_CONTENTS_SGIX: |
| 2393 | attrib++; |
| 2394 | preserveContents = *attrib; /* ignored */ |
| 2395 | break; |
| 2396 | case GLX_LARGEST_PBUFFER_SGIX: |
| 2397 | attrib++; |
| 2398 | useLargest = *attrib; /* ignored */ |
| 2399 | break; |
| 2400 | default: |
| 2401 | return 0; |
| 2402 | } |
| 2403 | } |
| 2404 | |
Brian Paul | b305028 | 2003-12-04 03:19:46 +0000 | [diff] [blame] | 2405 | /* not used at this time */ |
| 2406 | (void) useLargest; |
| 2407 | (void) preserveContents; |
| 2408 | |
Brian Paul | 3265fe5 | 2002-10-05 03:02:34 +0000 | [diff] [blame] | 2409 | xmbuf = XMesaCreatePBuffer( xmvis, 0, width, height); |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 2410 | /* A GLXPbuffer handle must be an X Drawable because that's what |
| 2411 | * glXMakeCurrent takes. |
| 2412 | */ |
| 2413 | return (GLXPbuffer) xmbuf->frontbuffer; |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2414 | } |
| 2415 | |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 2416 | |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2417 | static void |
| 2418 | Fake_glXDestroyGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf) |
| 2419 | { |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 2420 | XMesaBuffer xmbuf = XMesaFindBuffer(dpy, pbuf); |
| 2421 | if (xmbuf) { |
| 2422 | XMesaDestroyBuffer(xmbuf); |
| 2423 | } |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2424 | } |
| 2425 | |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 2426 | |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2427 | static int |
| 2428 | Fake_glXQueryGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value) |
| 2429 | { |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 2430 | const XMesaBuffer xmbuf = XMesaFindBuffer(dpy, pbuf); |
| 2431 | |
| 2432 | if (!xmbuf) { |
| 2433 | /* Generate GLXBadPbufferSGIX for bad pbuffer */ |
| 2434 | return 0; |
| 2435 | } |
| 2436 | |
| 2437 | switch (attribute) { |
| 2438 | case GLX_PRESERVED_CONTENTS_SGIX: |
| 2439 | *value = True; |
| 2440 | break; |
| 2441 | case GLX_LARGEST_PBUFFER_SGIX: |
| 2442 | *value = xmbuf->width * xmbuf->height; |
| 2443 | break; |
| 2444 | case GLX_WIDTH_SGIX: |
| 2445 | *value = xmbuf->width; |
| 2446 | break; |
| 2447 | case GLX_HEIGHT_SGIX: |
| 2448 | *value = xmbuf->height; |
| 2449 | break; |
| 2450 | case GLX_EVENT_MASK_SGIX: |
| 2451 | *value = 0; /* XXX might be wrong */ |
| 2452 | break; |
| 2453 | default: |
| 2454 | *value = 0; |
| 2455 | } |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2456 | return 0; |
| 2457 | } |
| 2458 | |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 2459 | |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2460 | static void |
| 2461 | Fake_glXSelectEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long mask) |
| 2462 | { |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 2463 | XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable); |
| 2464 | if (xmbuf) { |
| 2465 | /* Note: we'll never generate clobber events */ |
| 2466 | xmbuf->selectedEvents = mask; |
| 2467 | } |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2468 | } |
| 2469 | |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 2470 | |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2471 | static void |
| 2472 | Fake_glXGetSelectedEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long *mask) |
| 2473 | { |
Brian Paul | e465600 | 2002-10-05 18:27:41 +0000 | [diff] [blame] | 2474 | XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable); |
| 2475 | if (xmbuf) { |
| 2476 | *mask = xmbuf->selectedEvents; |
| 2477 | } |
| 2478 | else { |
| 2479 | *mask = 0; |
| 2480 | } |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2481 | } |
| 2482 | |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2483 | |
| 2484 | |
Brian Paul | b0bb4f6 | 2001-05-25 21:51:02 +0000 | [diff] [blame] | 2485 | /*** GLX_SGI_cushion ***/ |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2486 | |
| 2487 | static void |
| 2488 | Fake_glXCushionSGI(Display *dpy, Window win, float cushion) |
| 2489 | { |
| 2490 | (void) dpy; |
| 2491 | (void) win; |
| 2492 | (void) cushion; |
| 2493 | } |
| 2494 | |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2495 | |
| 2496 | |
Brian Paul | b0bb4f6 | 2001-05-25 21:51:02 +0000 | [diff] [blame] | 2497 | /*** GLX_SGIX_video_resize ***/ |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2498 | |
| 2499 | static int |
| 2500 | Fake_glXBindChannelToWindowSGIX(Display *dpy, int screen, int channel , Window window) |
| 2501 | { |
| 2502 | (void) dpy; |
| 2503 | (void) screen; |
| 2504 | (void) channel; |
| 2505 | (void) window; |
| 2506 | return 0; |
| 2507 | } |
| 2508 | |
| 2509 | static int |
| 2510 | Fake_glXChannelRectSGIX(Display *dpy, int screen, int channel, int x, int y, int w, int h) |
| 2511 | { |
| 2512 | (void) dpy; |
| 2513 | (void) screen; |
| 2514 | (void) channel; |
| 2515 | (void) x; |
| 2516 | (void) y; |
| 2517 | (void) w; |
| 2518 | (void) h; |
| 2519 | return 0; |
| 2520 | } |
| 2521 | |
| 2522 | static int |
| 2523 | Fake_glXQueryChannelRectSGIX(Display *dpy, int screen, int channel, int *x, int *y, int *w, int *h) |
| 2524 | { |
| 2525 | (void) dpy; |
| 2526 | (void) screen; |
| 2527 | (void) channel; |
| 2528 | (void) x; |
| 2529 | (void) y; |
| 2530 | (void) w; |
| 2531 | (void) h; |
| 2532 | return 0; |
| 2533 | } |
| 2534 | |
| 2535 | static int |
| 2536 | Fake_glXQueryChannelDeltasSGIX(Display *dpy, int screen, int channel, int *dx, int *dy, int *dw, int *dh) |
| 2537 | { |
| 2538 | (void) dpy; |
| 2539 | (void) screen; |
| 2540 | (void) channel; |
| 2541 | (void) dx; |
| 2542 | (void) dy; |
| 2543 | (void) dw; |
| 2544 | (void) dh; |
| 2545 | return 0; |
| 2546 | } |
| 2547 | |
| 2548 | static int |
| 2549 | Fake_glXChannelRectSyncSGIX(Display *dpy, int screen, int channel, GLenum synctype) |
| 2550 | { |
| 2551 | (void) dpy; |
| 2552 | (void) screen; |
| 2553 | (void) channel; |
| 2554 | (void) synctype; |
| 2555 | return 0; |
| 2556 | } |
| 2557 | |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2558 | |
| 2559 | |
Brian Paul | b0bb4f6 | 2001-05-25 21:51:02 +0000 | [diff] [blame] | 2560 | /*** GLX_SGIX_dmbuffer **/ |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2561 | |
Brian Paul | b0bb4f6 | 2001-05-25 21:51:02 +0000 | [diff] [blame] | 2562 | #if defined(_DM_BUFFER_H_) |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2563 | static Bool |
| 2564 | Fake_glXAssociateDMPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer) |
| 2565 | { |
| 2566 | (void) dpy; |
| 2567 | (void) pbuffer; |
| 2568 | (void) params; |
| 2569 | (void) dmbuffer; |
| 2570 | return False; |
| 2571 | } |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2572 | #endif |
| 2573 | |
| 2574 | |
Brian Paul | b0bb4f6 | 2001-05-25 21:51:02 +0000 | [diff] [blame] | 2575 | /*** GLX_SGIX_swap_group ***/ |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2576 | |
| 2577 | static void |
| 2578 | Fake_glXJoinSwapGroupSGIX(Display *dpy, GLXDrawable drawable, GLXDrawable member) |
| 2579 | { |
| 2580 | (void) dpy; |
| 2581 | (void) drawable; |
| 2582 | (void) member; |
| 2583 | } |
| 2584 | |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2585 | |
| 2586 | |
Brian Paul | b0bb4f6 | 2001-05-25 21:51:02 +0000 | [diff] [blame] | 2587 | /*** GLX_SGIX_swap_barrier ***/ |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2588 | |
| 2589 | static void |
| 2590 | Fake_glXBindSwapBarrierSGIX(Display *dpy, GLXDrawable drawable, int barrier) |
| 2591 | { |
| 2592 | (void) dpy; |
| 2593 | (void) drawable; |
| 2594 | (void) barrier; |
| 2595 | } |
| 2596 | |
| 2597 | static Bool |
| 2598 | Fake_glXQueryMaxSwapBarriersSGIX(Display *dpy, int screen, int *max) |
| 2599 | { |
| 2600 | (void) dpy; |
| 2601 | (void) screen; |
| 2602 | (void) max; |
| 2603 | return False; |
| 2604 | } |
| 2605 | |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2606 | |
| 2607 | |
Brian Paul | b0bb4f6 | 2001-05-25 21:51:02 +0000 | [diff] [blame] | 2608 | /*** GLX_SUN_get_transparent_index ***/ |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2609 | |
| 2610 | static Status |
| 2611 | Fake_glXGetTransparentIndexSUN(Display *dpy, Window overlay, Window underlay, long *pTransparent) |
| 2612 | { |
| 2613 | (void) dpy; |
| 2614 | (void) overlay; |
| 2615 | (void) underlay; |
| 2616 | (void) pTransparent; |
| 2617 | return 0; |
| 2618 | } |
| 2619 | |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2620 | |
| 2621 | |
Brian Paul | b0bb4f6 | 2001-05-25 21:51:02 +0000 | [diff] [blame] | 2622 | /*** GLX_MESA_release_buffers ***/ |
| 2623 | |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 2624 | /* |
| 2625 | * Release the depth, stencil, accum buffers attached to a GLXDrawable |
| 2626 | * (a window or pixmap) prior to destroying the GLXDrawable. |
| 2627 | */ |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 2628 | static Bool |
| 2629 | Fake_glXReleaseBuffersMESA( Display *dpy, GLXDrawable d ) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 2630 | { |
| 2631 | XMesaBuffer b = XMesaFindBuffer(dpy, d); |
| 2632 | if (b) { |
| 2633 | XMesaDestroyBuffer(b); |
| 2634 | return True; |
| 2635 | } |
| 2636 | return False; |
| 2637 | } |
| 2638 | |
| 2639 | |
Brian Paul | 4c07bd5 | 2000-06-08 22:50:28 +0000 | [diff] [blame] | 2640 | |
Brian Paul | b0bb4f6 | 2001-05-25 21:51:02 +0000 | [diff] [blame] | 2641 | /*** GLX_MESA_set_3dfx_mode ***/ |
| 2642 | |
Brian Paul | 4536021 | 2000-12-14 17:44:08 +0000 | [diff] [blame] | 2643 | static Bool |
| 2644 | Fake_glXSet3DfxModeMESA( int mode ) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 2645 | { |
Brian Paul | 43c9c2c | 1999-09-16 15:52:51 +0000 | [diff] [blame] | 2646 | return XMesaSetFXmode( mode ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 2647 | } |
Brian Paul | 4c07bd5 | 2000-06-08 22:50:28 +0000 | [diff] [blame] | 2648 | |
Brian Paul | 89a42b7 | 1999-09-11 11:33:45 +0000 | [diff] [blame] | 2649 | |
| 2650 | |
Brian Paul | 3c5bfac | 2003-01-14 04:49:07 +0000 | [diff] [blame] | 2651 | /*** GLX_NV_vertex_array range ***/ |
Brian Paul | 8fefafa | 2002-08-22 21:10:01 +0000 | [diff] [blame] | 2652 | static void * |
| 2653 | Fake_glXAllocateMemoryNV( GLsizei size, |
| 2654 | GLfloat readFrequency, |
| 2655 | GLfloat writeFrequency, |
| 2656 | GLfloat priority ) |
| 2657 | { |
| 2658 | (void) size; |
| 2659 | (void) readFrequency; |
| 2660 | (void) writeFrequency; |
| 2661 | (void) priority; |
| 2662 | return NULL; |
| 2663 | } |
| 2664 | |
| 2665 | |
| 2666 | static void |
| 2667 | Fake_glXFreeMemoryNV( GLvoid *pointer ) |
| 2668 | { |
| 2669 | (void) pointer; |
| 2670 | } |
| 2671 | |
| 2672 | |
Brian Paul | 3c5bfac | 2003-01-14 04:49:07 +0000 | [diff] [blame] | 2673 | /*** GLX_MESA_agp_offset ***/ |
Brian Paul | d6113fc | 2002-11-18 15:11:49 +0000 | [diff] [blame] | 2674 | |
| 2675 | static GLuint |
| 2676 | Fake_glXGetAGPOffsetMESA( const GLvoid *pointer ) |
| 2677 | { |
| 2678 | (void) pointer; |
| 2679 | return ~0; |
| 2680 | } |
| 2681 | |
| 2682 | |
Brian Paul | 7287bbf | 2004-09-23 17:30:54 +0000 | [diff] [blame] | 2683 | /* silence warning */ |
Brian Paul | e7b16b7 | 2000-03-17 15:33:09 +0000 | [diff] [blame] | 2684 | extern struct _glxapi_table *_mesa_GetGLXDispatchTable(void); |
Brian Paul | 7287bbf | 2004-09-23 17:30:54 +0000 | [diff] [blame] | 2685 | |
| 2686 | |
| 2687 | /** |
| 2688 | * Create a new GLX API dispatch table with its function pointers |
| 2689 | * initialized to point to Mesa's "fake" GLX API functions. |
| 2690 | * Note: there's a similar function (_real_GetGLXDispatchTable) that |
| 2691 | * returns a new dispatch table with all pointers initalized to point |
| 2692 | * to "real" GLX functions (which understand GLX wire protocol, etc). |
| 2693 | */ |
| 2694 | struct _glxapi_table * |
| 2695 | _mesa_GetGLXDispatchTable(void) |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 2696 | { |
| 2697 | static struct _glxapi_table glx; |
| 2698 | |
| 2699 | /* be sure our dispatch table size <= libGL's table */ |
| 2700 | { |
Brian Paul | 01915e9 | 2001-03-08 15:23:46 +0000 | [diff] [blame] | 2701 | GLuint size = sizeof(struct _glxapi_table) / sizeof(void *); |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 2702 | (void) size; |
| 2703 | assert(_glxapi_get_dispatch_table_size() >= size); |
| 2704 | } |
| 2705 | |
| 2706 | /* initialize the whole table to no-ops */ |
| 2707 | _glxapi_set_no_op_table(&glx); |
| 2708 | |
| 2709 | /* now initialize the table with the functions I implement */ |
| 2710 | glx.ChooseVisual = Fake_glXChooseVisual; |
| 2711 | glx.CopyContext = Fake_glXCopyContext; |
| 2712 | glx.CreateContext = Fake_glXCreateContext; |
| 2713 | glx.CreateGLXPixmap = Fake_glXCreateGLXPixmap; |
| 2714 | glx.DestroyContext = Fake_glXDestroyContext; |
| 2715 | glx.DestroyGLXPixmap = Fake_glXDestroyGLXPixmap; |
| 2716 | glx.GetConfig = Fake_glXGetConfig; |
| 2717 | /*glx.GetCurrentContext = Fake_glXGetCurrentContext;*/ |
| 2718 | /*glx.GetCurrentDrawable = Fake_glXGetCurrentDrawable;*/ |
| 2719 | glx.IsDirect = Fake_glXIsDirect; |
| 2720 | glx.MakeCurrent = Fake_glXMakeCurrent; |
| 2721 | glx.QueryExtension = Fake_glXQueryExtension; |
| 2722 | glx.QueryVersion = Fake_glXQueryVersion; |
| 2723 | glx.SwapBuffers = Fake_glXSwapBuffers; |
| 2724 | glx.UseXFont = Fake_glXUseXFont; |
| 2725 | glx.WaitGL = Fake_glXWaitGL; |
| 2726 | glx.WaitX = Fake_glXWaitX; |
| 2727 | |
Brian Paul | b0bb4f6 | 2001-05-25 21:51:02 +0000 | [diff] [blame] | 2728 | /*** GLX_VERSION_1_1 ***/ |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 2729 | glx.GetClientString = Fake_glXGetClientString; |
| 2730 | glx.QueryExtensionsString = Fake_glXQueryExtensionsString; |
| 2731 | glx.QueryServerString = Fake_glXQueryServerString; |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 2732 | |
Brian Paul | b0bb4f6 | 2001-05-25 21:51:02 +0000 | [diff] [blame] | 2733 | /*** GLX_VERSION_1_2 ***/ |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 2734 | /*glx.GetCurrentDisplay = Fake_glXGetCurrentDisplay;*/ |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 2735 | |
Brian Paul | b0bb4f6 | 2001-05-25 21:51:02 +0000 | [diff] [blame] | 2736 | /*** GLX_VERSION_1_3 ***/ |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 2737 | glx.ChooseFBConfig = Fake_glXChooseFBConfig; |
| 2738 | glx.CreateNewContext = Fake_glXCreateNewContext; |
| 2739 | glx.CreatePbuffer = Fake_glXCreatePbuffer; |
| 2740 | glx.CreatePixmap = Fake_glXCreatePixmap; |
| 2741 | glx.CreateWindow = Fake_glXCreateWindow; |
| 2742 | glx.DestroyPbuffer = Fake_glXDestroyPbuffer; |
| 2743 | glx.DestroyPixmap = Fake_glXDestroyPixmap; |
| 2744 | glx.DestroyWindow = Fake_glXDestroyWindow; |
| 2745 | /*glx.GetCurrentReadDrawable = Fake_glXGetCurrentReadDrawable;*/ |
| 2746 | glx.GetFBConfigAttrib = Fake_glXGetFBConfigAttrib; |
Brian Paul | 71dea34 | 2000-04-19 01:44:01 +0000 | [diff] [blame] | 2747 | glx.GetFBConfigs = Fake_glXGetFBConfigs; |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 2748 | glx.GetSelectedEvent = Fake_glXGetSelectedEvent; |
| 2749 | glx.GetVisualFromFBConfig = Fake_glXGetVisualFromFBConfig; |
| 2750 | glx.MakeContextCurrent = Fake_glXMakeContextCurrent; |
| 2751 | glx.QueryContext = Fake_glXQueryContext; |
| 2752 | glx.QueryDrawable = Fake_glXQueryDrawable; |
| 2753 | glx.SelectEvent = Fake_glXSelectEvent; |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 2754 | |
Brian Paul | b0bb4f6 | 2001-05-25 21:51:02 +0000 | [diff] [blame] | 2755 | /*** GLX_SGI_swap_control ***/ |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2756 | glx.SwapIntervalSGI = Fake_glXSwapIntervalSGI; |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2757 | |
Brian Paul | b0bb4f6 | 2001-05-25 21:51:02 +0000 | [diff] [blame] | 2758 | /*** GLX_SGI_video_sync ***/ |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 2759 | glx.GetVideoSyncSGI = Fake_glXGetVideoSyncSGI; |
| 2760 | glx.WaitVideoSyncSGI = Fake_glXWaitVideoSyncSGI; |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 2761 | |
Brian Paul | b0bb4f6 | 2001-05-25 21:51:02 +0000 | [diff] [blame] | 2762 | /*** GLX_SGI_make_current_read ***/ |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2763 | glx.MakeCurrentReadSGI = Fake_glXMakeCurrentReadSGI; |
Brian Paul | 7cf50e1 | 2001-05-24 19:06:21 +0000 | [diff] [blame] | 2764 | /*glx.GetCurrentReadDrawableSGI = Fake_glXGetCurrentReadDrawableSGI;*/ |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2765 | |
Brian Paul | b0bb4f6 | 2001-05-25 21:51:02 +0000 | [diff] [blame] | 2766 | /*** GLX_SGIX_video_source ***/ |
| 2767 | #if defined(_VL_H) |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2768 | glx.CreateGLXVideoSourceSGIX = Fake_glXCreateGLXVideoSourceSGIX; |
| 2769 | glx.DestroyGLXVideoSourceSGIX = Fake_glXDestroyGLXVideoSourceSGIX; |
| 2770 | #endif |
| 2771 | |
Brian Paul | b0bb4f6 | 2001-05-25 21:51:02 +0000 | [diff] [blame] | 2772 | /*** GLX_EXT_import_context ***/ |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2773 | glx.FreeContextEXT = Fake_glXFreeContextEXT; |
| 2774 | glx.GetContextIDEXT = Fake_glXGetContextIDEXT; |
Brian Paul | 7cf50e1 | 2001-05-24 19:06:21 +0000 | [diff] [blame] | 2775 | /*glx.GetCurrentDisplayEXT = Fake_glXGetCurrentDisplayEXT;*/ |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2776 | glx.ImportContextEXT = Fake_glXImportContextEXT; |
| 2777 | glx.QueryContextInfoEXT = Fake_glXQueryContextInfoEXT; |
Brian Paul | 4536021 | 2000-12-14 17:44:08 +0000 | [diff] [blame] | 2778 | |
Brian Paul | b0bb4f6 | 2001-05-25 21:51:02 +0000 | [diff] [blame] | 2779 | /*** GLX_SGIX_fbconfig ***/ |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2780 | glx.GetFBConfigAttribSGIX = Fake_glXGetFBConfigAttribSGIX; |
| 2781 | glx.ChooseFBConfigSGIX = Fake_glXChooseFBConfigSGIX; |
| 2782 | glx.CreateGLXPixmapWithConfigSGIX = Fake_glXCreateGLXPixmapWithConfigSGIX; |
| 2783 | glx.CreateContextWithConfigSGIX = Fake_glXCreateContextWithConfigSGIX; |
| 2784 | glx.GetVisualFromFBConfigSGIX = Fake_glXGetVisualFromFBConfigSGIX; |
| 2785 | glx.GetFBConfigFromVisualSGIX = Fake_glXGetFBConfigFromVisualSGIX; |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2786 | |
Brian Paul | b0bb4f6 | 2001-05-25 21:51:02 +0000 | [diff] [blame] | 2787 | /*** GLX_SGIX_pbuffer ***/ |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2788 | glx.CreateGLXPbufferSGIX = Fake_glXCreateGLXPbufferSGIX; |
| 2789 | glx.DestroyGLXPbufferSGIX = Fake_glXDestroyGLXPbufferSGIX; |
| 2790 | glx.QueryGLXPbufferSGIX = Fake_glXQueryGLXPbufferSGIX; |
| 2791 | glx.SelectEventSGIX = Fake_glXSelectEventSGIX; |
| 2792 | glx.GetSelectedEventSGIX = Fake_glXGetSelectedEventSGIX; |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2793 | |
Brian Paul | b0bb4f6 | 2001-05-25 21:51:02 +0000 | [diff] [blame] | 2794 | /*** GLX_SGI_cushion ***/ |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2795 | glx.CushionSGI = Fake_glXCushionSGI; |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2796 | |
Brian Paul | b0bb4f6 | 2001-05-25 21:51:02 +0000 | [diff] [blame] | 2797 | /*** GLX_SGIX_video_resize ***/ |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2798 | glx.BindChannelToWindowSGIX = Fake_glXBindChannelToWindowSGIX; |
| 2799 | glx.ChannelRectSGIX = Fake_glXChannelRectSGIX; |
| 2800 | glx.QueryChannelRectSGIX = Fake_glXQueryChannelRectSGIX; |
| 2801 | glx.QueryChannelDeltasSGIX = Fake_glXQueryChannelDeltasSGIX; |
| 2802 | glx.ChannelRectSyncSGIX = Fake_glXChannelRectSyncSGIX; |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2803 | |
Brian Paul | b0bb4f6 | 2001-05-25 21:51:02 +0000 | [diff] [blame] | 2804 | /*** GLX_SGIX_dmbuffer **/ |
| 2805 | #if defined(_DM_BUFFER_H_) |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2806 | glx.AssociateDMPbufferSGIX = NULL; |
| 2807 | #endif |
| 2808 | |
Brian Paul | b0bb4f6 | 2001-05-25 21:51:02 +0000 | [diff] [blame] | 2809 | /*** GLX_SGIX_swap_group ***/ |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2810 | glx.JoinSwapGroupSGIX = Fake_glXJoinSwapGroupSGIX; |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2811 | |
Brian Paul | b0bb4f6 | 2001-05-25 21:51:02 +0000 | [diff] [blame] | 2812 | /*** GLX_SGIX_swap_barrier ***/ |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2813 | glx.BindSwapBarrierSGIX = Fake_glXBindSwapBarrierSGIX; |
| 2814 | glx.QueryMaxSwapBarriersSGIX = Fake_glXQueryMaxSwapBarriersSGIX; |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2815 | |
Brian Paul | b0bb4f6 | 2001-05-25 21:51:02 +0000 | [diff] [blame] | 2816 | /*** GLX_SUN_get_transparent_index ***/ |
Brian Paul | 783d7df | 2000-12-15 04:02:50 +0000 | [diff] [blame] | 2817 | glx.GetTransparentIndexSUN = Fake_glXGetTransparentIndexSUN; |
Brian Paul | 4536021 | 2000-12-14 17:44:08 +0000 | [diff] [blame] | 2818 | |
Brian Paul | b0bb4f6 | 2001-05-25 21:51:02 +0000 | [diff] [blame] | 2819 | /*** GLX_MESA_copy_sub_buffer ***/ |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 2820 | glx.CopySubBufferMESA = Fake_glXCopySubBufferMESA; |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 2821 | |
Brian Paul | b0bb4f6 | 2001-05-25 21:51:02 +0000 | [diff] [blame] | 2822 | /*** GLX_MESA_release_buffers ***/ |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 2823 | glx.ReleaseBuffersMESA = Fake_glXReleaseBuffersMESA; |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 2824 | |
Brian Paul | b0bb4f6 | 2001-05-25 21:51:02 +0000 | [diff] [blame] | 2825 | /*** GLX_MESA_pixmap_colormap ***/ |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 2826 | glx.CreateGLXPixmapMESA = Fake_glXCreateGLXPixmapMESA; |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 2827 | |
Brian Paul | b0bb4f6 | 2001-05-25 21:51:02 +0000 | [diff] [blame] | 2828 | /*** GLX_MESA_set_3dfx_mode ***/ |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 2829 | glx.Set3DfxModeMESA = Fake_glXSet3DfxModeMESA; |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 2830 | |
Brian Paul | d6113fc | 2002-11-18 15:11:49 +0000 | [diff] [blame] | 2831 | /*** GLX_NV_vertex_array_range ***/ |
Brian Paul | 8fefafa | 2002-08-22 21:10:01 +0000 | [diff] [blame] | 2832 | glx.AllocateMemoryNV = Fake_glXAllocateMemoryNV; |
| 2833 | glx.FreeMemoryNV = Fake_glXFreeMemoryNV; |
| 2834 | |
Brian Paul | d6113fc | 2002-11-18 15:11:49 +0000 | [diff] [blame] | 2835 | /*** GLX_MESA_agp_offset ***/ |
| 2836 | glx.GetAGPOffsetMESA = Fake_glXGetAGPOffsetMESA; |
| 2837 | |
Brian Paul | 426cb9f | 1999-11-28 20:08:02 +0000 | [diff] [blame] | 2838 | return &glx; |
| 2839 | } |