fakeglx.c revision 83b820aa98931ef30fa73c72b2a96fe23885955e
183b820aa98931ef30fa73c72b2a96fe23885955eBrian Paul/* $Id: fakeglx.c,v 1.66 2002/06/16 03:56:11 brianp Exp $ */
2afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
3afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
4afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Mesa 3-D graphics library
53de5462ab1bb00f534c6f3d10eeb3b422f04c7c5Brian Paul * Version:  4.1
65e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen *
78d687e7e58a148f3f16573636023e54755372010Brian Paul * Copyright (C) 1999-2002  Brian Paul   All Rights Reserved.
85e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen *
9afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Permission is hereby granted, free of charge, to any person obtaining a
10afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * copy of this software and associated documentation files (the "Software"),
11afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * to deal in the Software without restriction, including without limitation
12afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * and/or sell copies of the Software, and to permit persons to whom the
14afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Software is furnished to do so, subject to the following conditions:
155e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen *
16afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * The above copyright notice and this permission notice shall be included
17afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * in all copies or substantial portions of the Software.
185e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen *
19afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
22afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
26afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
27afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
28afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
2936cfa38760cc2bd91c08b66bb62c4b6cf9eb5454Brian Paul * This is an emulation of the GLX API which allows Mesa/GLX-based programs
3036cfa38760cc2bd91c08b66bb62c4b6cf9eb5454Brian Paul * to run on X servers which do not have the real GLX extension.
31afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *
32afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Thanks to the contributors:
33afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *
34ddf69f247fdb246b99ef6525fcfa6eda7b2e2aa7Brian Paul * Initial version:  Philip Brown (phil@bolthole.com)
35afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Better glXGetConfig() support: Armin Liebchen (liebchen@asylum.cs.utah.edu)
36afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Further visual-handling refinements: Wolfram Gloger
37afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *    (wmglo@Dent.MED.Uni-Muenchen.DE).
38afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *
39afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Notes:
40afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *   Don't be fooled, stereo isn't supported yet.
41afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
42afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
43afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
44afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
45fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul#include "glxheader.h"
46426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul#include "glxapi.h"
47afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#include "GL/xmesa.h"
48afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#include "context.h"
49afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#include "config.h"
50afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#include "macros.h"
517cf50e137da497a590ec9001a9918972a6246142Brian Paul#include "mem.h"
5271dea349d2be623b7819389428b0d6a124e8d184Brian Paul#include "mmath.h"
535e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen#include "mtypes.h"
5471dea349d2be623b7819389428b0d6a124e8d184Brian Paul#include "xfonts.h"
55afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#include "xmesaP.h"
56afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
57afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
5878fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul/* This indicates the client-side GLX API and GLX encoder version. */
5978fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul#define CLIENT_MAJOR_VERSION 1
60a573803ed3fe9ef6489f45bd4c5455b77cb33a43Brian Paul#define CLIENT_MINOR_VERSION 4  /* but don't have 1.3's pbuffers, etc yet */
6178fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul
6278fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul/* This indicates the server-side GLX decoder version.
63ba57e5297d60eef37e43dd4d7f10d1e62f5e97ceBrian Paul * GLX 1.4 indicates OpenGL 1.3 support
6478fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul */
6578fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul#define SERVER_MAJOR_VERSION 1
66ba57e5297d60eef37e43dd4d7f10d1e62f5e97ceBrian Paul#define SERVER_MINOR_VERSION 4
6778fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul
6878fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul/* This is appended onto the glXGetClient/ServerString version strings. */
693de5462ab1bb00f534c6f3d10eeb3b422f04c7c5Brian Paul#define MESA_GLX_VERSION "Mesa 4.1"
7078fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul
7178fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul/* Who implemented this GLX? */
7278fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul#define VENDOR "Brian Paul"
7378fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul
7478fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul
75afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
7643c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul/* Silence compiler warnings */
77e7b16b74bf5d13331b5a88bbbbb9096560297b63Brian Paulextern void Fake_glXDummyFunc( void );
7843c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paulvoid Fake_glXDummyFunc( void )
7943c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul{
8043c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul   (void) kernel8;
8143c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul   (void) DitherValues;
8243c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul   (void) HPCR_DRGB;
8343c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul   (void) kernel1;
8443c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul}
8543c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul
8643c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul
877cf50e137da497a590ec9001a9918972a6246142Brian Paul/*
887cf50e137da497a590ec9001a9918972a6246142Brian Paul * Our fake GLX context will contain a "real" GLX context and an XMesa context.
897cf50e137da497a590ec9001a9918972a6246142Brian Paul *
907cf50e137da497a590ec9001a9918972a6246142Brian Paul * Note that a pointer to a __GLXcontext is a pointer to a fake_glx_context,
917cf50e137da497a590ec9001a9918972a6246142Brian Paul * and vice versa.
927cf50e137da497a590ec9001a9918972a6246142Brian Paul *
937cf50e137da497a590ec9001a9918972a6246142Brian Paul * We really just need this structure in order to make the libGL functions
947cf50e137da497a590ec9001a9918972a6246142Brian Paul * glXGetCurrentContext(), glXGetCurrentDrawable() and glXGetCurrentDisplay()
957cf50e137da497a590ec9001a9918972a6246142Brian Paul * work correctly.
967cf50e137da497a590ec9001a9918972a6246142Brian Paul */
977cf50e137da497a590ec9001a9918972a6246142Brian Paulstruct fake_glx_context {
987cf50e137da497a590ec9001a9918972a6246142Brian Paul   __GLXcontext glxContext;   /* this MUST be first! */
997cf50e137da497a590ec9001a9918972a6246142Brian Paul   XMesaContext xmesaContext;
1007cf50e137da497a590ec9001a9918972a6246142Brian Paul};
10143c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul
102afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
103afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1047cf50e137da497a590ec9001a9918972a6246142Brian Paul/**********************************************************************/
1057cf50e137da497a590ec9001a9918972a6246142Brian Paul/***                       GLX Visual Code                          ***/
1067cf50e137da497a590ec9001a9918972a6246142Brian Paul/**********************************************************************/
1077cf50e137da497a590ec9001a9918972a6246142Brian Paul
1087cf50e137da497a590ec9001a9918972a6246142Brian Paul#define DONT_CARE -1
1097cf50e137da497a590ec9001a9918972a6246142Brian Paul
110afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
111afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#define MAX_VISUALS 100
112afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XMesaVisual VisualTable[MAX_VISUALS];
113afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic int NumVisuals = 0;
114afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
115afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
116afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
117afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * This struct and some code fragments borrowed
118afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * from Mark Kilgard's GLUT library.
119afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
120afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgtypedef struct _OverlayInfo {
121afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg  /* Avoid 64-bit portability problems by being careful to use
122afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg     longs due to the way XGetWindowProperty is specified. Note
123afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg     that these parameters are passed as CARD32s over X
124afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg     protocol. */
125afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg  unsigned long overlay_visual;
126afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg  long transparent_type;
127afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg  long value;
128afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg  long layer;
129afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} OverlayInfo;
130afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
131afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
132afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
133afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* Macro to handle c_class vs class field name in XVisualInfo struct */
134afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#if defined(__cplusplus) || defined(c_plusplus)
135afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#define CLASS c_class
136afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#else
137afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#define CLASS class
138afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#endif
139afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
140afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
141afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
142afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
143afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
144afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Test if the given XVisualInfo is usable for Mesa rendering.
145afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
146afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic GLboolean is_usable_visual( XVisualInfo *vinfo )
147afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
148afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   switch (vinfo->CLASS) {
149afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case StaticGray:
150afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GrayScale:
151afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* Any StaticGray/GrayScale visual works in RGB or CI mode */
152afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return GL_TRUE;
153afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case StaticColor:
154afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case PseudoColor:
155afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 /* Any StaticColor/PseudoColor visual of at least 4 bits */
156afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 if (vinfo->depth>=4) {
157afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    return GL_TRUE;
158afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 }
159afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 else {
160afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    return GL_FALSE;
161afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 }
162afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case TrueColor:
163afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case DirectColor:
164afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 /* Any depth of TrueColor or DirectColor works in RGB mode */
165afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return GL_TRUE;
166afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      default:
167afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 /* This should never happen */
168afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return GL_FALSE;
169afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
170afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
171afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
172afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
173afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
174afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
175afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return the level (overlay, normal, underlay) of a given XVisualInfo.
176afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input:  dpy - the X display
177afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         vinfo - the XVisualInfo to test
178afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return:  level of the visual:
179afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *             0 = normal planes
180afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *            >0 = overlay planes
181afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *            <0 = underlay planes
182afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
183afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic int level_of_visual( Display *dpy, XVisualInfo *vinfo )
184afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
185afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   Atom overlayVisualsAtom;
186afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   OverlayInfo *overlay_info = NULL;
187afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int numOverlaysPerScreen;
188afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   Status status;
189afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   Atom actualType;
190afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int actualFormat;
191afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   unsigned long sizeData, bytesLeft;
192afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int i;
193afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
194afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /*
195afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * The SERVER_OVERLAY_VISUALS property on the root window contains
196afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * a list of overlay visuals.  Get that list now.
197afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    */
198afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   overlayVisualsAtom = XInternAtom(dpy,"SERVER_OVERLAY_VISUALS", True);
199afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (overlayVisualsAtom == None) {
200afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return 0;
201afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
202afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
203afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   status = XGetWindowProperty(dpy, RootWindow( dpy, vinfo->screen ),
204afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               overlayVisualsAtom, 0L, (long) 10000, False,
205afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               overlayVisualsAtom, &actualType, &actualFormat,
206afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               &sizeData, &bytesLeft,
207afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               (unsigned char **) &overlay_info );
208afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
209afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (status != Success || actualType != overlayVisualsAtom ||
210afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg       actualFormat != 32 || sizeData < 4) {
211afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* something went wrong */
212afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      XFree((void *) overlay_info);
213afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return 0;
214afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
215afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
216afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* search the overlay visual list for the visual ID of interest */
217afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   numOverlaysPerScreen = (int) (sizeData / 4);
218afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   for (i=0;i<numOverlaysPerScreen;i++) {
219afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      OverlayInfo *ov;
220afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      ov = overlay_info + i;
221afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (ov->overlay_visual==vinfo->visualid) {
222afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* found the visual */
223afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         if (/*ov->transparent_type==1 &&*/ ov->layer!=0) {
224afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            int level = ov->layer;
225afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            XFree((void *) overlay_info);
226afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            return level;
227afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
228afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         else {
229afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            XFree((void *) overlay_info);
230afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            return 0;
231afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
232afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
233afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
234afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
235afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* The visual ID was not found in the overlay list. */
236afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XFree((void *) overlay_info);
237afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return 0;
238afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
239afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
240afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
241afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
242afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
243afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
244afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Given an XVisualInfo and RGB, Double, and Depth buffer flags, save the
245afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * configuration in our list of GLX visuals.
246afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
247afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XMesaVisual
248afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgsave_glx_visual( Display *dpy, XVisualInfo *vinfo,
249afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                 GLboolean rgbFlag, GLboolean alphaFlag, GLboolean dbFlag,
250afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                 GLboolean stereoFlag,
251afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                 GLint depth_size, GLint stencil_size,
252b2e460018375f699198073a6167e0ee96ba1d267Brian Paul                 GLint accumRedSize, GLint accumGreenSize,
253b2e460018375f699198073a6167e0ee96ba1d267Brian Paul                 GLint accumBlueSize, GLint accumAlphaSize,
254b2e460018375f699198073a6167e0ee96ba1d267Brian Paul                 GLint level )
255afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
256afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLboolean ximageFlag = GL_TRUE;
257afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaVisual xmvis;
258afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLint i;
259afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLboolean comparePointers;
260afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
261afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (dbFlag) {
262afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* Check if the MESA_BACK_BUFFER env var is set */
263afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      char *backbuffer = getenv("MESA_BACK_BUFFER");
264afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (backbuffer) {
265afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         if (backbuffer[0]=='p' || backbuffer[0]=='P') {
266afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            ximageFlag = GL_FALSE;
267afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
268afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         else if (backbuffer[0]=='x' || backbuffer[0]=='X') {
269afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            ximageFlag = GL_TRUE;
270afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
271afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         else {
272d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul            _mesa_warning(NULL, "Mesa: invalid value for MESA_BACK_BUFFER environment variable, using an XImage.");
273afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
274afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
275afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
276afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
277afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* Comparing IDs uses less memory but sometimes fails. */
278afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* XXX revisit this after 3.0 is finished. */
279afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (getenv("MESA_GLX_VISUAL_HACK"))
280afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      comparePointers = GL_TRUE;
281afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else
282afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      comparePointers = GL_FALSE;
283afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
284afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* First check if a matching visual is already in the list */
285afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   for (i=0; i<NumVisuals; i++) {
286afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      XMesaVisual v = VisualTable[i];
287afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (v->display == dpy
288afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg          && v->level == level
289afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg          && v->ximage_flag == ximageFlag
2901832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && v->mesa_visual.rgbMode == rgbFlag
2911832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && v->mesa_visual.doubleBufferMode == dbFlag
2921832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && v->mesa_visual.stereoMode == stereoFlag
2931832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && (v->mesa_visual.alphaBits > 0) == alphaFlag
2941832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && (v->mesa_visual.depthBits >= depth_size || depth_size == 0)
2951832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && (v->mesa_visual.stencilBits >= stencil_size || stencil_size == 0)
2961832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && (v->mesa_visual.accumRedBits >= accumRedSize || accumRedSize == 0)
2971832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && (v->mesa_visual.accumGreenBits >= accumGreenSize || accumGreenSize == 0)
2981832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && (v->mesa_visual.accumBlueBits >= accumBlueSize || accumBlueSize == 0)
2991832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && (v->mesa_visual.accumAlphaBits >= accumAlphaSize || accumAlphaSize == 0)) {
300afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* now either compare XVisualInfo pointers or visual IDs */
301d0247f53aea8fa8677aadc8a00f75c8993be9ebcBrian Paul         if ((!comparePointers && v->visinfo->visualid == vinfo->visualid)
302afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg             || (comparePointers && v->vishandle == vinfo)) {
303afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            return v;
304afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
305afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
306afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
307afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
308afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* Create a new visual and add it to the list. */
309afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
310d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul   if (NumVisuals >= MAX_VISUALS) {
311d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul      _mesa_problem(NULL, "GLX Error: maximum number of visuals exceeded");
312afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return NULL;
313afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
314afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
315c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul   xmvis = XMesaCreateVisual( dpy, vinfo, rgbFlag, alphaFlag, dbFlag,
316c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul                              stereoFlag, ximageFlag,
317c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul                              depth_size, stencil_size,
318c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul                              accumRedSize, accumBlueSize,
319c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul                              accumBlueSize, accumAlphaSize, 0, level,
320c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul                              GLX_NONE_EXT );
321afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (xmvis) {
322afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      VisualTable[NumVisuals] = xmvis;
323afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      NumVisuals++;
324afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
325afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return xmvis;
326afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
327afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
328afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
329afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
330afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
331afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Create a GLX visual from a regular XVisualInfo.
332ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * This is called when Fake GLX is given an XVisualInfo which wasn't
333ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * returned by glXChooseVisual.  Since this is the first time we're
334ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * considering this visual we'll take a guess at reasonable values
335ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * for depth buffer size, stencil size, accum size, etc.
336ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * This is the best we can do with a client-side emulation of GLX.
337afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
338afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XMesaVisual
339afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgcreate_glx_visual( Display *dpy, XVisualInfo *visinfo )
340afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
341afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int vislevel;
342afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
343afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   vislevel = level_of_visual( dpy, visinfo );
344afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (vislevel) {
345afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* Configure this visual as a CI, single-buffered overlay */
346afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return save_glx_visual( dpy, visinfo,
347afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                              GL_FALSE,  /* rgb */
348afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                              GL_FALSE,  /* alpha */
349afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                              GL_FALSE,  /* double */
350afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                              GL_FALSE,  /* stereo */
351afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                              0,         /* depth bits */
352afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                              0,         /* stencil bits */
353b2e460018375f699198073a6167e0ee96ba1d267Brian Paul                              0,0,0,0,   /* accum bits */
354afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                              vislevel   /* level */
355afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                            );
356afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
357afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else if (is_usable_visual( visinfo )) {
3588f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul      if (getenv("MESA_GLX_FORCE_CI")) {
3598f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul         /* Configure this visual as a COLOR INDEX visual. */
3608f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul         return save_glx_visual( dpy, visinfo,
3618f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 GL_FALSE,   /* rgb */
3628f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 GL_FALSE,  /* alpha */
3638f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 GL_TRUE,   /* double */
3648f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 GL_FALSE,  /* stereo */
3658f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 DEFAULT_SOFTWARE_DEPTH_BITS,
3668f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 8 * sizeof(GLstencil),
3678f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 0 * sizeof(GLaccum), /* r */
3688f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 0 * sizeof(GLaccum), /* g */
3698f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 0 * sizeof(GLaccum), /* b */
3708f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 0 * sizeof(GLaccum), /* a */
3718f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 0          /* level */
3728f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                               );
3738f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul      }
3748f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul      else {
3758f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul         /* Configure this visual as RGB, double-buffered, depth-buffered. */
3768f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul         /* This is surely wrong for some people's needs but what else */
3778f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul         /* can be done?  They should use glXChooseVisual(). */
3788f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul         return save_glx_visual( dpy, visinfo,
3798f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 GL_TRUE,   /* rgb */
3808f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 GL_FALSE,  /* alpha */
3818f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 GL_TRUE,   /* double */
3828f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 GL_FALSE,  /* stereo */
3838f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 DEFAULT_SOFTWARE_DEPTH_BITS,
3848f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 8 * sizeof(GLstencil),
3858f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 8 * sizeof(GLaccum), /* r */
3868f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 8 * sizeof(GLaccum), /* g */
3878f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 8 * sizeof(GLaccum), /* b */
3888f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 8 * sizeof(GLaccum), /* a */
3898f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 0          /* level */
3908f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                               );
3918f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul      }
392afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
393afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else {
394d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul      _mesa_warning(NULL, "Mesa: error in glXCreateContext: bad visual\n");
395afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return NULL;
396afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
397afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
398afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
399afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
400afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
401afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
402afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Find the GLX visual associated with an XVisualInfo.
403afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
404afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XMesaVisual
405afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgfind_glx_visual( Display *dpy, XVisualInfo *vinfo )
406afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
407afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int i;
408afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
409afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* First try to match pointers */
410afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   for (i=0;i<NumVisuals;i++) {
411afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (VisualTable[i]->display==dpy && VisualTable[i]->vishandle==vinfo) {
412afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return VisualTable[i];
413afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
414afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
415afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* try to match visual id */
416afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   for (i=0;i<NumVisuals;i++) {
417afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (VisualTable[i]->display==dpy
418afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg          && VisualTable[i]->visinfo->visualid == vinfo->visualid) {
419afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return VisualTable[i];
420afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
421afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
422afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return NULL;
423afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
424afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
425afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
426afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
427afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
428afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return the transparent pixel value for a GLX visual.
429afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input:  glxvis - the glx_visual
430afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return:  a pixel value or -1 if no transparent pixel
431afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
432afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic int transparent_pixel( XMesaVisual glxvis )
433afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
434afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   Display *dpy = glxvis->display;
435afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XVisualInfo *vinfo = glxvis->visinfo;
436afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   Atom overlayVisualsAtom;
437afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   OverlayInfo *overlay_info = NULL;
438afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int numOverlaysPerScreen;
439afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   Status status;
440afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   Atom actualType;
441afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int actualFormat;
442afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   unsigned long sizeData, bytesLeft;
443afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int i;
444afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
445afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /*
446afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * The SERVER_OVERLAY_VISUALS property on the root window contains
447afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * a list of overlay visuals.  Get that list now.
448afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    */
449afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   overlayVisualsAtom = XInternAtom(dpy,"SERVER_OVERLAY_VISUALS", True);
450afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (overlayVisualsAtom == None) {
451afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return -1;
452afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
453afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
454afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   status = XGetWindowProperty(dpy, RootWindow( dpy, vinfo->screen ),
455afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               overlayVisualsAtom, 0L, (long) 10000, False,
456afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               overlayVisualsAtom, &actualType, &actualFormat,
457afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               &sizeData, &bytesLeft,
458afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               (unsigned char **) &overlay_info );
459afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
460afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (status != Success || actualType != overlayVisualsAtom ||
461afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg       actualFormat != 32 || sizeData < 4) {
462afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* something went wrong */
463afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      XFree((void *) overlay_info);
464afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return -1;
465afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
466afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
467afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* search the overlay visual list for the visual ID of interest */
468afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   numOverlaysPerScreen = (int) (sizeData / 4);
469afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   for (i=0;i<numOverlaysPerScreen;i++) {
470afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      OverlayInfo *ov;
471afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      ov = overlay_info + i;
472afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (ov->overlay_visual==vinfo->visualid) {
473afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* found it! */
474afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         if (ov->transparent_type==0) {
475afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* type 0 indicates no transparency */
476afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            XFree((void *) overlay_info);
477afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            return -1;
478afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
479afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         else {
480afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* ov->value is the transparent pixel */
481afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            XFree((void *) overlay_info);
482afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            return ov->value;
483afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
484afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
485afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
486afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
487afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* The visual ID was not found in the overlay list. */
488afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XFree((void *) overlay_info);
489afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return -1;
490afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
491afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
492afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
493afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
494afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
495afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Try to get an X visual which matches the given arguments.
496afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
497afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XVisualInfo *get_visual( Display *dpy, int scr,
498afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg			        unsigned int depth, int xclass )
499afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
500afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XVisualInfo temp, *vis;
501afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   long mask;
502afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int n;
503afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   unsigned int default_depth;
504afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int default_class;
505afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
506afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   mask = VisualScreenMask | VisualDepthMask | VisualClassMask;
507afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   temp.screen = scr;
508afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   temp.depth = depth;
509afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   temp.CLASS = xclass;
510afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
511afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   default_depth = DefaultDepth(dpy,scr);
512afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   default_class = DefaultVisual(dpy,scr)->CLASS;
513afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
514afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (depth==default_depth && xclass==default_class) {
515afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* try to get root window's visual */
516afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      temp.visualid = DefaultVisual(dpy,scr)->visualid;
517afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      mask |= VisualIDMask;
518afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
519afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
520afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   vis = XGetVisualInfo( dpy, mask, &temp, &n );
521afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
522afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* In case bits/pixel > 24, make sure color channels are still <=8 bits.
523afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * An SGI Infinite Reality system, for example, can have 30bpp pixels:
524afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * 10 bits per color channel.  Mesa's limited to a max of 8 bits/channel.
525afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    */
526afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (vis && depth > 24 && (xclass==TrueColor || xclass==DirectColor)) {
52771dea349d2be623b7819389428b0d6a124e8d184Brian Paul      if (_mesa_bitcount((GLuint) vis->red_mask  ) <= 8 &&
52871dea349d2be623b7819389428b0d6a124e8d184Brian Paul          _mesa_bitcount((GLuint) vis->green_mask) <= 8 &&
52971dea349d2be623b7819389428b0d6a124e8d184Brian Paul          _mesa_bitcount((GLuint) vis->blue_mask ) <= 8) {
530afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return vis;
531afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
532afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      else {
533afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         XFree((void *) vis);
534afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return NULL;
535afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
536afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
537afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
538afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return vis;
539afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
540afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
541afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
542afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
543afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
544afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Retrieve the value of the given environment variable and find
545afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * the X visual which matches it.
546afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input:  dpy - the display
547afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         screen - the screen number
548afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         varname - the name of the environment variable
549afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return:  an XVisualInfo pointer to NULL if error.
550afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
551afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XVisualInfo *get_env_visual(Display *dpy, int scr, const char *varname)
552afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
553afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   char value[100], type[100];
554afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int depth, xclass = -1;
555afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XVisualInfo *vis;
556afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
557afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (!getenv( varname )) {
558afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return NULL;
559afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
560afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
561afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   strncpy( value, getenv(varname), 100 );
562afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   value[99] = 0;
563afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
564afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   sscanf( value, "%s %d", type, &depth );
565afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
566afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (strcmp(type,"TrueColor")==0)          xclass = TrueColor;
567afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else if (strcmp(type,"DirectColor")==0)   xclass = DirectColor;
568afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else if (strcmp(type,"PseudoColor")==0)   xclass = PseudoColor;
569afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else if (strcmp(type,"StaticColor")==0)   xclass = StaticColor;
570afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else if (strcmp(type,"GrayScale")==0)     xclass = GrayScale;
571afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else if (strcmp(type,"StaticGray")==0)    xclass = StaticGray;
572afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
573afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (xclass>-1 && depth>0) {
574afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      vis = get_visual( dpy, scr, depth, xclass );
575afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (vis) {
576afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return vis;
577afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
578afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
579afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
580d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul   {
581d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul      char s[1000];
582d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul      sprintf(s, "Mesa: GLX unable to find visual class=%s, depth=%d.\n",
583d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul              type, depth );
584d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul      _mesa_warning(NULL, s);
585d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul   }
586d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul
587afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return NULL;
588afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
589afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
590afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
591afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
592afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
593afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Select an X visual which satisfies the RGBA/CI flag and minimum depth.
594afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input:  dpy, screen - X display and screen number
595afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         rgba - GL_TRUE = RGBA mode, GL_FALSE = CI mode
596afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         min_depth - minimum visual depth
597afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         preferred_class - preferred GLX visual class or DONT_CARE
598afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return:  pointer to an XVisualInfo or NULL.
599afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
600afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XVisualInfo *choose_x_visual( Display *dpy, int screen,
601afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg				     GLboolean rgba, int min_depth,
602afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                                     int preferred_class )
603afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
604afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XVisualInfo *vis;
605db6aa58267cad3f502f03ab80b9deb6b75320a91Brian Paul   int xclass, visclass = 0;
606afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int depth;
607afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
608afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (rgba) {
609afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      Atom hp_cr_maps = XInternAtom(dpy, "_HP_RGB_SMOOTH_MAP_LIST", True);
610afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* First see if the MESA_RGB_VISUAL env var is defined */
611afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      vis = get_env_visual( dpy, screen, "MESA_RGB_VISUAL" );
612afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (vis) {
613afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return vis;
614afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
615afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* Otherwise, search for a suitable visual */
616afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (preferred_class==DONT_CARE) {
617afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         for (xclass=0;xclass<6;xclass++) {
618afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            switch (xclass) {
619afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 0:  visclass = TrueColor;    break;
620afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 1:  visclass = DirectColor;  break;
621afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 2:  visclass = PseudoColor;  break;
622afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 3:  visclass = StaticColor;  break;
623afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 4:  visclass = GrayScale;    break;
624afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 5:  visclass = StaticGray;   break;
625afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
626afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            if (min_depth==0) {
627afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               /* start with shallowest */
628afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               for (depth=0;depth<=32;depth++) {
629afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  if (visclass==TrueColor && depth==8 && !hp_cr_maps) {
630afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     /* Special case:  try to get 8-bit PseudoColor before */
631afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     /* 8-bit TrueColor */
632afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     vis = get_visual( dpy, screen, 8, PseudoColor );
633afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     if (vis) {
634afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                        return vis;
635afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     }
636afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  }
637afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  vis = get_visual( dpy, screen, depth, visclass );
638afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  if (vis) {
639afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     return vis;
640afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  }
641afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               }
642afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
643afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            else {
644afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               /* start with deepest */
645afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               for (depth=32;depth>=min_depth;depth--) {
646afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  if (visclass==TrueColor && depth==8 && !hp_cr_maps) {
647afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     /* Special case:  try to get 8-bit PseudoColor before */
648afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     /* 8-bit TrueColor */
649afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     vis = get_visual( dpy, screen, 8, PseudoColor );
650afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     if (vis) {
651afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                        return vis;
652afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     }
653afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  }
654afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  vis = get_visual( dpy, screen, depth, visclass );
655afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  if (vis) {
656afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     return vis;
657afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  }
658afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               }
659afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
660afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
661afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
662afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      else {
663afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* search for a specific visual class */
664afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         switch (preferred_class) {
665afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_TRUE_COLOR_EXT:    visclass = TrueColor;    break;
666afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_DIRECT_COLOR_EXT:  visclass = DirectColor;  break;
667afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_PSEUDO_COLOR_EXT:  visclass = PseudoColor;  break;
668afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_STATIC_COLOR_EXT:  visclass = StaticColor;  break;
669afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_GRAY_SCALE_EXT:    visclass = GrayScale;    break;
670afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_STATIC_GRAY_EXT:   visclass = StaticGray;   break;
671afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            default:   return NULL;
672afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
673afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         if (min_depth==0) {
674afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* start with shallowest */
675afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            for (depth=0;depth<=32;depth++) {
676afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               vis = get_visual( dpy, screen, depth, visclass );
677afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               if (vis) {
678afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  return vis;
679afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               }
680afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
681afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
682afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         else {
683afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* start with deepest */
684afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            for (depth=32;depth>=min_depth;depth--) {
685afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               vis = get_visual( dpy, screen, depth, visclass );
686afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               if (vis) {
687afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  return vis;
688afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               }
689afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
690afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
691afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
692afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
693afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else {
694afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* First see if the MESA_CI_VISUAL env var is defined */
695afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      vis = get_env_visual( dpy, screen, "MESA_CI_VISUAL" );
696afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (vis) {
697afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return vis;
698afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
699afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* Otherwise, search for a suitable visual, starting with shallowest */
700afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (preferred_class==DONT_CARE) {
701afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         for (xclass=0;xclass<4;xclass++) {
702afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            switch (xclass) {
703afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 0:  visclass = PseudoColor;  break;
704afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 1:  visclass = StaticColor;  break;
705afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 2:  visclass = GrayScale;    break;
706afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 3:  visclass = StaticGray;   break;
707afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
708afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* try 8-bit up through 16-bit */
709afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            for (depth=8;depth<=16;depth++) {
710afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               vis = get_visual( dpy, screen, depth, visclass );
711afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               if (vis) {
712afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  return vis;
713afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               }
714afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
715afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* try min_depth up to 8-bit */
716afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            for (depth=min_depth;depth<8;depth++) {
717afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               vis = get_visual( dpy, screen, depth, visclass );
718afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               if (vis) {
719afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  return vis;
720afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               }
721afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
722afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
723afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
724afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      else {
725afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* search for a specific visual class */
726afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         switch (preferred_class) {
727afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_TRUE_COLOR_EXT:    visclass = TrueColor;    break;
728afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_DIRECT_COLOR_EXT:  visclass = DirectColor;  break;
729afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_PSEUDO_COLOR_EXT:  visclass = PseudoColor;  break;
730afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_STATIC_COLOR_EXT:  visclass = StaticColor;  break;
731afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_GRAY_SCALE_EXT:    visclass = GrayScale;    break;
732afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_STATIC_GRAY_EXT:   visclass = StaticGray;   break;
733afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            default:   return NULL;
734afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
735afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* try 8-bit up through 16-bit */
736afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         for (depth=8;depth<=16;depth++) {
737afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            vis = get_visual( dpy, screen, depth, visclass );
738afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            if (vis) {
739afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               return vis;
740afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
741afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
742afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* try min_depth up to 8-bit */
743afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         for (depth=min_depth;depth<8;depth++) {
744afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            vis = get_visual( dpy, screen, depth, visclass );
745afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            if (vis) {
746afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               return vis;
747afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
748afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
749afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
750afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
751afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
752afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* didn't find a visual */
753afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return NULL;
754afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
755afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
756afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
757afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
758afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
759afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Find the deepest X over/underlay visual of at least min_depth.
760afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input:  dpy, screen - X display and screen number
761afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         level - the over/underlay level
762afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         trans_type - transparent pixel type: GLX_NONE_EXT,
763afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *                      GLX_TRANSPARENT_RGB_EXT, GLX_TRANSPARENT_INDEX_EXT,
764afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *                      or DONT_CARE
765afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         trans_value - transparent pixel value or DONT_CARE
766afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         min_depth - minimum visual depth
767afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         preferred_class - preferred GLX visual class or DONT_CARE
768afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return:  pointer to an XVisualInfo or NULL.
769afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
770afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XVisualInfo *choose_x_overlay_visual( Display *dpy, int scr,
77142f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul                                             GLboolean rgbFlag,
772afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                                             int level, int trans_type,
773afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                                             int trans_value,
774afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                                             int min_depth,
775afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                                             int preferred_class )
776afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
777afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   Atom overlayVisualsAtom;
778afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   OverlayInfo *overlay_info;
779afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int numOverlaysPerScreen;
780afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   Status status;
781afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   Atom actualType;
782afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int actualFormat;
783afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   unsigned long sizeData, bytesLeft;
784afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int i;
785afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XVisualInfo *deepvis;
786afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int deepest;
787afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
788afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /*DEBUG int tt, tv; */
789afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
790afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   switch (preferred_class) {
791afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_TRUE_COLOR_EXT:    preferred_class = TrueColor;    break;
792afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_DIRECT_COLOR_EXT:  preferred_class = DirectColor;  break;
793afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_PSEUDO_COLOR_EXT:  preferred_class = PseudoColor;  break;
794afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_STATIC_COLOR_EXT:  preferred_class = StaticColor;  break;
795afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_GRAY_SCALE_EXT:    preferred_class = GrayScale;    break;
796afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_STATIC_GRAY_EXT:   preferred_class = StaticGray;   break;
797afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      default:                    preferred_class = DONT_CARE;
798afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
799afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
800afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /*
801afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * The SERVER_OVERLAY_VISUALS property on the root window contains
802afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * a list of overlay visuals.  Get that list now.
803afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    */
804afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   overlayVisualsAtom = XInternAtom(dpy,"SERVER_OVERLAY_VISUALS", True);
805afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (overlayVisualsAtom == (Atom) None) {
806afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return NULL;
807afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
808afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
809afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   status = XGetWindowProperty(dpy, RootWindow( dpy, scr ),
810afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               overlayVisualsAtom, 0L, (long) 10000, False,
811afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               overlayVisualsAtom, &actualType, &actualFormat,
812afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               &sizeData, &bytesLeft,
813afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               (unsigned char **) &overlay_info );
814afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
815afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (status != Success || actualType != overlayVisualsAtom ||
816afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg       actualFormat != 32 || sizeData < 4) {
817afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* something went wrong */
818afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return NULL;
819afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
820afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
821afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* Search for the deepest overlay which satisifies all criteria. */
822afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   deepest = min_depth;
823afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   deepvis = NULL;
824afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
825afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   numOverlaysPerScreen = (int) (sizeData / 4);
826afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   for (i=0;i<numOverlaysPerScreen;i++) {
827afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      XVisualInfo *vislist, vistemplate;
828afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      int count;
829afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      OverlayInfo *ov;
830afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      ov = overlay_info + i;
831afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
832afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (ov->layer!=level) {
833afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* failed overlay level criteria */
834afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         continue;
835afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
836afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (!(trans_type==DONT_CARE
837afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            || (trans_type==GLX_TRANSPARENT_INDEX_EXT
838afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                && ov->transparent_type>0)
839afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            || (trans_type==GLX_NONE_EXT && ov->transparent_type==0))) {
840afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* failed transparent pixel type criteria */
841afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         continue;
842afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
843afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (trans_value!=DONT_CARE && trans_value!=ov->value) {
844afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* failed transparent pixel value criteria */
845afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         continue;
846afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
847afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
848afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* get XVisualInfo and check the depth */
849afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      vistemplate.visualid = ov->overlay_visual;
850afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      vistemplate.screen = scr;
851afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      vislist = XGetVisualInfo( dpy, VisualIDMask | VisualScreenMask,
852afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                                &vistemplate, &count );
853afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
854afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (count!=1) {
855afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* something went wrong */
856afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         continue;
857afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
858afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (preferred_class!=DONT_CARE && preferred_class!=vislist->CLASS) {
859afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* wrong visual class */
860afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         continue;
861afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
862afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
86342f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      /* if RGB was requested, make sure we have True/DirectColor */
86442f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      if (rgbFlag && vislist->CLASS != TrueColor
86542f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul          && vislist->CLASS != DirectColor)
86642f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         continue;
86742f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul
86842f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      /* if CI was requested, make sure we have a color indexed visual */
86942f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      if (!rgbFlag
87042f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul          && (vislist->CLASS == TrueColor || vislist->CLASS == DirectColor))
87142f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         continue;
87242f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul
873afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (deepvis==NULL || vislist->depth > deepest) {
874afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* YES!  found a satisfactory visual */
875afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         if (deepvis) {
87680af3614d88c0cac160e787de7f34b37e96cb626Brian Paul            XFree( deepvis );
877afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
878afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         deepest = vislist->depth;
879afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         deepvis = vislist;
880afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* DEBUG  tt = ov->transparent_type;*/
881afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* DEBUG  tv = ov->value; */
882afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
883afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
884afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
885afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*DEBUG
886afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (deepvis) {
887afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      printf("chose 0x%x:  layer=%d depth=%d trans_type=%d trans_value=%d\n",
888afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg             deepvis->visualid, level, deepvis->depth, tt, tv );
889afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
890afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg*/
891afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return deepvis;
892afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
893afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
894afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
8957cf50e137da497a590ec9001a9918972a6246142Brian Paul/**********************************************************************/
8967cf50e137da497a590ec9001a9918972a6246142Brian Paul/***                  Begin Fake GLX API Functions                  ***/
8977cf50e137da497a590ec9001a9918972a6246142Brian Paul/**********************************************************************/
8987cf50e137da497a590ec9001a9918972a6246142Brian Paul
899afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
900426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic XVisualInfo *
901426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXChooseVisual( Display *dpy, int screen, int *list )
902afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
903afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int *parselist;
904afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XVisualInfo *vis;
905afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int min_ci = 0;
906afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int min_red=0, min_green=0, min_blue=0;
907afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLboolean rgb_flag = GL_FALSE;
908afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLboolean alpha_flag = GL_FALSE;
909afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLboolean double_flag = GL_FALSE;
910afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLboolean stereo_flag = GL_FALSE;
911afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLint depth_size = 0;
912afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLint stencil_size = 0;
913b2e460018375f699198073a6167e0ee96ba1d267Brian Paul   GLint accumRedSize = 0;
914b2e460018375f699198073a6167e0ee96ba1d267Brian Paul   GLint accumGreenSize = 0;
915b2e460018375f699198073a6167e0ee96ba1d267Brian Paul   GLint accumBlueSize = 0;
916b2e460018375f699198073a6167e0ee96ba1d267Brian Paul   GLint accumAlphaSize = 0;
917afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int level = 0;
918afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int visual_type = DONT_CARE;
919afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int trans_type = DONT_CARE;
920afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int trans_value = DONT_CARE;
921e1210b176926349b258c7ec77b7f36716025c82aBrian Paul   GLint caveat = DONT_CARE;
922afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
923afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   parselist = list;
924afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
925afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   while (*parselist) {
926afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
927afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      switch (*parselist) {
928afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_USE_GL:
929afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    /* ignore */
930afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
931afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
932afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_BUFFER_SIZE:
933afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
934afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    min_ci = *parselist++;
935afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
936afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_LEVEL:
937afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
938afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            level = *parselist++;
939afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
940afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_RGBA:
941afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    rgb_flag = GL_TRUE;
942afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
943afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
944afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_DOUBLEBUFFER:
945afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    double_flag = GL_TRUE;
946afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
947afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
948afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_STEREO:
949afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            stereo_flag = GL_TRUE;
950afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            return NULL;
951afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_AUX_BUFFERS:
952afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    /* ignore */
953afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
954afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
955afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
956afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_RED_SIZE:
957afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
958afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    min_red = *parselist++;
959afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
960afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_GREEN_SIZE:
961afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
962afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    min_green = *parselist++;
963afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
964afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_BLUE_SIZE:
965afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
966afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    min_blue = *parselist++;
967afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
968afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_ALPHA_SIZE:
969afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
970afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            {
971afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               GLint size = *parselist++;
972afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               alpha_flag = size>0 ? 1 : 0;
973afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
974afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
975afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_DEPTH_SIZE:
976afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
977afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    depth_size = *parselist++;
978afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
979afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_STENCIL_SIZE:
980afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
981afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    stencil_size = *parselist++;
982afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
983afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_ACCUM_RED_SIZE:
984b2e460018375f699198073a6167e0ee96ba1d267Brian Paul	    parselist++;
985b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            {
986b2e460018375f699198073a6167e0ee96ba1d267Brian Paul               GLint size = *parselist++;
987b2e460018375f699198073a6167e0ee96ba1d267Brian Paul               accumRedSize = MAX2( accumRedSize, size );
988b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            }
989b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            break;
990afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_ACCUM_GREEN_SIZE:
991b2e460018375f699198073a6167e0ee96ba1d267Brian Paul	    parselist++;
992b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            {
993b2e460018375f699198073a6167e0ee96ba1d267Brian Paul               GLint size = *parselist++;
994b2e460018375f699198073a6167e0ee96ba1d267Brian Paul               accumGreenSize = MAX2( accumGreenSize, size );
995b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            }
996b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            break;
997afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_ACCUM_BLUE_SIZE:
998b2e460018375f699198073a6167e0ee96ba1d267Brian Paul	    parselist++;
999b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            {
1000b2e460018375f699198073a6167e0ee96ba1d267Brian Paul               GLint size = *parselist++;
1001b2e460018375f699198073a6167e0ee96ba1d267Brian Paul               accumBlueSize = MAX2( accumBlueSize, size );
1002b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            }
1003b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            break;
1004afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_ACCUM_ALPHA_SIZE:
1005afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
1006afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            {
1007afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               GLint size = *parselist++;
1008b2e460018375f699198073a6167e0ee96ba1d267Brian Paul               accumAlphaSize = MAX2( accumAlphaSize, size );
1009afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
1010afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
1011afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1012afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /*
1013afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg          * GLX_EXT_visual_info extension
1014afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg          */
1015afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         case GLX_X_VISUAL_TYPE_EXT:
1016afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            parselist++;
1017afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            visual_type = *parselist++;
1018afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            break;
1019afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         case GLX_TRANSPARENT_TYPE_EXT:
1020afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            parselist++;
1021afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            trans_type = *parselist++;
1022afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            break;
1023afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         case GLX_TRANSPARENT_INDEX_VALUE_EXT:
1024afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            parselist++;
1025afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            trans_value = *parselist++;
1026afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            break;
1027afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         case GLX_TRANSPARENT_RED_VALUE_EXT:
1028afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         case GLX_TRANSPARENT_GREEN_VALUE_EXT:
1029afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         case GLX_TRANSPARENT_BLUE_VALUE_EXT:
1030afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         case GLX_TRANSPARENT_ALPHA_VALUE_EXT:
1031afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    /* ignore */
1032afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
1033afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
1034afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
10355e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen
1036e1210b176926349b258c7ec77b7f36716025c82aBrian Paul         /*
1037e1210b176926349b258c7ec77b7f36716025c82aBrian Paul          * GLX_EXT_visual_info extension
1038e1210b176926349b258c7ec77b7f36716025c82aBrian Paul          */
1039e1210b176926349b258c7ec77b7f36716025c82aBrian Paul         case GLX_VISUAL_CAVEAT_EXT:
1040e1210b176926349b258c7ec77b7f36716025c82aBrian Paul            parselist++;
1041e1210b176926349b258c7ec77b7f36716025c82aBrian Paul            caveat = *parselist++; /* ignored for now */
1042e1210b176926349b258c7ec77b7f36716025c82aBrian Paul            break;
1043e1210b176926349b258c7ec77b7f36716025c82aBrian Paul
1044afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case None:
1045afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
1046afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 default:
1047afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    /* undefined attribute */
1048afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    return NULL;
1049afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
1050afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1051afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1052afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /*
1053afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * Since we're only simulating the GLX extension this function will never
1054afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * find any real GL visuals.  Instead, all we can do is try to find an RGB
1055afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * or CI visual of appropriate depth.  Other requested attributes such as
1056afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * double buffering, depth buffer, etc. will be associated with the X
1057afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * visual and stored in the VisualTable[].
1058afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    */
1059afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (level==0) {
1060afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* normal color planes */
1061afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (rgb_flag) {
1062afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* Get an RGB visual */
1063afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         int min_rgb = min_red + min_green + min_blue;
1064afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         if (min_rgb>1 && min_rgb<8) {
1065afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* a special case to be sure we can get a monochrome visual */
1066afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            min_rgb = 1;
1067afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
1068afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         vis = choose_x_visual( dpy, screen, rgb_flag, min_rgb, visual_type );
1069afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
1070afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      else {
1071afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* Get a color index visual */
1072afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         vis = choose_x_visual( dpy, screen, rgb_flag, min_ci, visual_type );
1073b2e460018375f699198073a6167e0ee96ba1d267Brian Paul         accumRedSize = accumGreenSize = accumBlueSize = accumAlphaSize = 0;
1074afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
1075afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1076afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else {
1077afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* over/underlay planes */
107842f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      if (rgb_flag) {
107942f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         /* rgba overlay */
108042f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         int min_rgb = min_red + min_green + min_blue;
108142f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         if (min_rgb>1 && min_rgb<8) {
108242f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul            /* a special case to be sure we can get a monochrome visual */
108342f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul            min_rgb = 1;
108442f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         }
108542f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         vis = choose_x_overlay_visual( dpy, screen, rgb_flag, level,
108642f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul                              trans_type, trans_value, min_rgb, visual_type );
108742f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      }
108842f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      else {
108942f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         /* color index overlay */
109042f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         vis = choose_x_overlay_visual( dpy, screen, rgb_flag, level,
109142f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul                              trans_type, trans_value, min_ci, visual_type );
109242f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      }
1093afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1094afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1095afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (vis) {
1096ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul      /* Note: we're not exactly obeying the glXChooseVisual rules here.
1097ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul       * When GLX_DEPTH_SIZE = 1 is specified we're supposed to choose the
10982c7e6334ec81c2fab2cce9e0fe52cd30256e37eaBrian Paul       * largest depth buffer size, which is 32bits/value.  Instead, we
1099ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul       * return 16 to maintain performance with earlier versions of Mesa.
1100ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul       */
11012c7e6334ec81c2fab2cce9e0fe52cd30256e37eaBrian Paul      if (depth_size > 24)
11022c7e6334ec81c2fab2cce9e0fe52cd30256e37eaBrian Paul         depth_size = 31;   /* 32 causes int overflow problems */
1103ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul      else if (depth_size > 16)
1104ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul         depth_size = 24;
11052c7e6334ec81c2fab2cce9e0fe52cd30256e37eaBrian Paul      else if (depth_size > 0)
11062c7e6334ec81c2fab2cce9e0fe52cd30256e37eaBrian Paul         depth_size = DEFAULT_SOFTWARE_DEPTH_BITS; /*16*/
11072c7e6334ec81c2fab2cce9e0fe52cd30256e37eaBrian Paul
1108ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul      /* we only support one size of stencil and accum buffers. */
1109ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul      if (stencil_size > 0)
1110ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul         stencil_size = STENCIL_BITS;
11116d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul      if (accumRedSize > 0 || accumGreenSize > 0 || accumBlueSize > 0 ||
11126d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul          accumAlphaSize > 0) {
1113b2e460018375f699198073a6167e0ee96ba1d267Brian Paul         accumRedSize = ACCUM_BITS;
1114b2e460018375f699198073a6167e0ee96ba1d267Brian Paul         accumGreenSize = ACCUM_BITS;
1115b2e460018375f699198073a6167e0ee96ba1d267Brian Paul         accumBlueSize = ACCUM_BITS;
11166d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul         accumAlphaSize = alpha_flag ? ACCUM_BITS : 0;
11176d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul      }
11186d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul
1119afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (!save_glx_visual( dpy, vis, rgb_flag, alpha_flag, double_flag,
1120b2e460018375f699198073a6167e0ee96ba1d267Brian Paul                            stereo_flag, depth_size, stencil_size,
1121b2e460018375f699198073a6167e0ee96ba1d267Brian Paul                            accumRedSize, accumGreenSize,
1122b2e460018375f699198073a6167e0ee96ba1d267Brian Paul                            accumBlueSize, accumAlphaSize,
1123b2e460018375f699198073a6167e0ee96ba1d267Brian Paul                            level ))
1124afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return NULL;
1125afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1126afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1127afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return vis;
1128afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1129afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1130afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1131afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1132afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1133426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXContext
1134426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateContext( Display *dpy, XVisualInfo *visinfo,
1135426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                       GLXContext share_list, Bool direct )
1136afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1137afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaVisual glxvis;
11387cf50e137da497a590ec9001a9918972a6246142Brian Paul   struct fake_glx_context *glxCtx;
11395e1680ce1d8296b2182e8909856927bbeddf3b95Brian Paul   struct fake_glx_context *shareCtx = (struct fake_glx_context *) share_list;
114099aab341998e84d9fa208c525cae8021b3845812Brian Paul
114199aab341998e84d9fa208c525cae8021b3845812Brian Paul   if (!dpy || !visinfo)
114299aab341998e84d9fa208c525cae8021b3845812Brian Paul      return 0;
114399aab341998e84d9fa208c525cae8021b3845812Brian Paul
11447cf50e137da497a590ec9001a9918972a6246142Brian Paul   glxCtx = CALLOC_STRUCT(fake_glx_context);
11457cf50e137da497a590ec9001a9918972a6246142Brian Paul   if (!glxCtx)
11467cf50e137da497a590ec9001a9918972a6246142Brian Paul      return 0;
1147afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1148afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* deallocate unused windows/buffers */
1149afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaGarbageCollect();
1150afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1151afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   glxvis = find_glx_visual( dpy, visinfo );
1152afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (!glxvis) {
1153afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* This visual wasn't found with glXChooseVisual() */
1154afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      glxvis = create_glx_visual( dpy, visinfo );
1155afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (!glxvis) {
1156afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* unusable visual */
11577cf50e137da497a590ec9001a9918972a6246142Brian Paul         FREE(glxCtx);
1158afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return NULL;
1159afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
1160afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1161afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
11627cf50e137da497a590ec9001a9918972a6246142Brian Paul   glxCtx->xmesaContext = XMesaCreateContext(glxvis,
11635e1680ce1d8296b2182e8909856927bbeddf3b95Brian Paul                                   shareCtx ? shareCtx->xmesaContext : NULL);
11647cf50e137da497a590ec9001a9918972a6246142Brian Paul   if (!glxCtx->xmesaContext) {
11657cf50e137da497a590ec9001a9918972a6246142Brian Paul      FREE(glxCtx);
11667cf50e137da497a590ec9001a9918972a6246142Brian Paul      return NULL;
1167afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
11687cf50e137da497a590ec9001a9918972a6246142Brian Paul
11697cf50e137da497a590ec9001a9918972a6246142Brian Paul   glxCtx->xmesaContext->direct = GL_FALSE;
11707cf50e137da497a590ec9001a9918972a6246142Brian Paul   glxCtx->glxContext.isDirect = GL_FALSE;
11717cf50e137da497a590ec9001a9918972a6246142Brian Paul   glxCtx->glxContext.currentDpy = dpy;
11727cf50e137da497a590ec9001a9918972a6246142Brian Paul   glxCtx->glxContext.xid = (XID) glxCtx;  /* self pointer */
11737cf50e137da497a590ec9001a9918972a6246142Brian Paul
11747cf50e137da497a590ec9001a9918972a6246142Brian Paul   assert((void *) glxCtx == (void *) &(glxCtx->glxContext));
11757cf50e137da497a590ec9001a9918972a6246142Brian Paul
11767cf50e137da497a590ec9001a9918972a6246142Brian Paul   return (GLXContext) glxCtx;
1177afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1178afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1179afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
11807cf50e137da497a590ec9001a9918972a6246142Brian Paul/* XXX these may have to be removed due to thread-safety issues. */
1181afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic GLXContext MakeCurrent_PrevContext = 0;
1182086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic GLXDrawable MakeCurrent_PrevDrawable = 0;
1183086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic GLXDrawable MakeCurrent_PrevReadable = 0;
1184086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic XMesaBuffer MakeCurrent_PrevDrawBuffer = 0;
1185086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic XMesaBuffer MakeCurrent_PrevReadBuffer = 0;
1186afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
11877cf50e137da497a590ec9001a9918972a6246142Brian Paul
1188086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul/* GLX 1.3 and later */
1189426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool
1190426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXMakeContextCurrent( Display *dpy, GLXDrawable draw,
11917a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell                            GLXDrawable read, GLXContext ctx )
1192086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul{
11937cf50e137da497a590ec9001a9918972a6246142Brian Paul   struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx;
11947cf50e137da497a590ec9001a9918972a6246142Brian Paul
11957a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell   if (ctx && draw && read) {
1196086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      XMesaBuffer drawBuffer, readBuffer;
11977cf50e137da497a590ec9001a9918972a6246142Brian Paul      XMesaContext xmctx = glxCtx->xmesaContext;
1198086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul
1199086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      /* Find the XMesaBuffer which corresponds to the GLXDrawable 'draw' */
12007a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell      if (ctx == MakeCurrent_PrevContext
12017a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell          && draw == MakeCurrent_PrevDrawable) {
1202086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         drawBuffer = MakeCurrent_PrevDrawBuffer;
1203086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      }
1204086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      else {
1205086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         drawBuffer = XMesaFindBuffer( dpy, draw );
1206086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      }
1207086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      if (!drawBuffer) {
1208086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         /* drawable must be a new window! */
12097cf50e137da497a590ec9001a9918972a6246142Brian Paul         drawBuffer = XMesaCreateWindowBuffer2( xmctx->xm_visual, draw, xmctx);
1210086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         if (!drawBuffer) {
1211086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul            /* Out of memory, or context/drawable depth mismatch */
1212086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul            return False;
1213086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         }
1214086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      }
1215086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul
1216086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      /* Find the XMesaBuffer which corresponds to the GLXDrawable 'read' */
12177a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell      if (ctx == MakeCurrent_PrevContext
1218086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul          && read == MakeCurrent_PrevReadable) {
1219086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         readBuffer = MakeCurrent_PrevReadBuffer;
1220086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      }
1221086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      else {
1222086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         readBuffer = XMesaFindBuffer( dpy, read );
1223086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      }
1224086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      if (!readBuffer) {
1225086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         /* drawable must be a new window! */
12267cf50e137da497a590ec9001a9918972a6246142Brian Paul         readBuffer = XMesaCreateWindowBuffer2(glxCtx->xmesaContext->xm_visual,
12277cf50e137da497a590ec9001a9918972a6246142Brian Paul                                               read, xmctx);
1228086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         if (!readBuffer) {
1229086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul            /* Out of memory, or context/drawable depth mismatch */
1230086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul            return False;
1231086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         }
1232086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      }
1233086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul
12347a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell      MakeCurrent_PrevContext = ctx;
1235086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevDrawable = draw;
1236086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevReadable = read;
1237086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevDrawBuffer = drawBuffer;
1238086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevReadBuffer = readBuffer;
1239086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul
1240086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      /* Now make current! */
12417cf50e137da497a590ec9001a9918972a6246142Brian Paul      if (XMesaMakeCurrent2(xmctx, drawBuffer, readBuffer)) {
124212c1bee87fcc3a0912685bb6e83447972e5de64eBrian Paul         ((__GLXcontext *) ctx)->currentDpy = dpy;
124312c1bee87fcc3a0912685bb6e83447972e5de64eBrian Paul         ((__GLXcontext *) ctx)->currentDrawable = draw;
12448d687e7e58a148f3f16573636023e54755372010Brian Paul#ifndef GLX_BUILT_IN_XMESA
124512c1bee87fcc3a0912685bb6e83447972e5de64eBrian Paul         ((__GLXcontext *) ctx)->currentReadable = read;
12468d687e7e58a148f3f16573636023e54755372010Brian Paul#else
12477cf50e137da497a590ec9001a9918972a6246142Brian Paul         __glXSetCurrentContext(ctx);
12487cf50e137da497a590ec9001a9918972a6246142Brian Paul#endif
12497cf50e137da497a590ec9001a9918972a6246142Brian Paul         return True;
12507cf50e137da497a590ec9001a9918972a6246142Brian Paul      }
12517cf50e137da497a590ec9001a9918972a6246142Brian Paul      else {
12527cf50e137da497a590ec9001a9918972a6246142Brian Paul         return False;
12537cf50e137da497a590ec9001a9918972a6246142Brian Paul      }
1254086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul   }
12557a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell   else if (!ctx && !draw && !read) {
1256086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      /* release current context w/out assigning new one. */
1257086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      XMesaMakeCurrent( NULL, NULL );
1258086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevContext = 0;
1259086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevDrawable = 0;
1260086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevReadable = 0;
1261086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevDrawBuffer = 0;
1262086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevReadBuffer = 0;
126384cac8441fcf5f692cd220e9fa86cab398a4c159Brian Paul#ifdef GLX_BUILT_IN_XMESA
1264b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul      /* XXX bind dummy context with __glXSetCurrentContext(ctx); */
1265b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#endif
1266086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      return True;
1267086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul   }
1268086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul   else {
1269086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      /* The args must either all be non-zero or all zero.
1270086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul       * This is an error.
1271086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul       */
1272086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      return False;
1273086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul   }
1274086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul}
1275086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul
1276086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul
1277426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1278426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool
1279426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXMakeCurrent( Display *dpy, GLXDrawable drawable, GLXContext ctx )
1280426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
1281426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   return Fake_glXMakeContextCurrent( dpy, drawable, drawable, ctx );
1282426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
1283426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1284426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1285426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1286426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPixmap
1287426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateGLXPixmap( Display *dpy, XVisualInfo *visinfo, Pixmap pixmap )
1288afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1289afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaVisual v;
1290afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaBuffer b;
1291afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1292afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   v = find_glx_visual( dpy, visinfo );
1293afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (!v) {
1294afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      v = create_glx_visual( dpy, visinfo );
1295afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (!v) {
1296afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* unusable visual */
1297afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1298afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
1299afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1300afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1301afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   b = XMesaCreatePixmapBuffer( v, pixmap, 0 );
1302afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (!b) {
1303afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return 0;
1304afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1305afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return b->frontbuffer;
1306afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1307afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1308afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1309b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_MESA_pixmap_colormap ***/
1310b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul
1311426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPixmap
1312426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visinfo,
1313426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                             Pixmap pixmap, Colormap cmap )
1314afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1315afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaVisual v;
1316afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaBuffer b;
1317afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1318afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   v = find_glx_visual( dpy, visinfo );
1319afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (!v) {
1320afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      v = create_glx_visual( dpy, visinfo );
1321afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (!v) {
1322afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* unusable visual */
1323afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1324afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
1325afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1326afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1327afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   b = XMesaCreatePixmapBuffer( v, pixmap, cmap );
1328afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (!b) {
1329afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return 0;
1330afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1331afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return b->frontbuffer;
1332afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1333afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1334afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1335426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1336426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyGLXPixmap( Display *dpy, GLXPixmap pixmap )
1337afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1338afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaBuffer b = XMesaFindBuffer(dpy, pixmap);
1339afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (b) {
1340afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      XMesaDestroyBuffer(b);
1341afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1342afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else if (getenv("MESA_DEBUG")) {
1343d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul      _mesa_warning(NULL, "Mesa: glXDestroyGLXPixmap: invalid pixmap\n");
1344afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1345afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1346afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1347afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
13484c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul
1349426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1350426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCopyContext( Display *dpy, GLXContext src, GLXContext dst,
13513994b77bab8c62a4c1a4dffdfba233ef46662b99Brian Paul                     unsigned long mask )
1352afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
135383b820aa98931ef30fa73c72b2a96fe23885955eBrian Paul   struct fake_glx_context *fakeSrc = (struct fake_glx_context *) src;
135483b820aa98931ef30fa73c72b2a96fe23885955eBrian Paul   struct fake_glx_context *fakeDst = (struct fake_glx_context *) dst;
135583b820aa98931ef30fa73c72b2a96fe23885955eBrian Paul   XMesaContext xm_src = fakeSrc->xmesaContext;
135683b820aa98931ef30fa73c72b2a96fe23885955eBrian Paul   XMesaContext xm_dst = fakeDst->xmesaContext;
1357afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
13587a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell   _mesa_copy_context( xm_src->gl_ctx, xm_dst->gl_ctx, (GLuint) mask );
1359afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1360afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1361afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1362afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1363426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool
1364426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryExtension( Display *dpy, int *errorb, int *event )
1365afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1366afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* Mesa's GLX isn't really an X extension but we try to act like one. */
1367afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
1368afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) errorb;
1369afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) event;
1370afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return True;
1371afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1372afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1373afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1374e7b16b74bf5d13331b5a88bbbbb9096560297b63Brian Paulextern void _kw_ungrab_all( Display *dpy );
1375afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgvoid _kw_ungrab_all( Display *dpy )
1376afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1377afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XUngrabPointer( dpy, CurrentTime );
1378afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XUngrabKeyboard( dpy, CurrentTime );
1379afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1380afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1381afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1382426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1383426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyContext( Display *dpy, GLXContext ctx )
1384afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
13857cf50e137da497a590ec9001a9918972a6246142Brian Paul   struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx;
1386afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
1387afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   MakeCurrent_PrevContext = 0;
1388afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   MakeCurrent_PrevDrawable = 0;
1389086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul   MakeCurrent_PrevReadable = 0;
1390086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul   MakeCurrent_PrevDrawBuffer = 0;
1391086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul   MakeCurrent_PrevReadBuffer = 0;
13927cf50e137da497a590ec9001a9918972a6246142Brian Paul   XMesaDestroyContext( glxCtx->xmesaContext );
1393afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaGarbageCollect();
1394afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1395afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1396afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1397afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1398426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool
1399426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXIsDirect( Display *dpy, GLXContext ctx )
1400afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
14017cf50e137da497a590ec9001a9918972a6246142Brian Paul   struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx;
1402afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
14037cf50e137da497a590ec9001a9918972a6246142Brian Paul   return glxCtx->xmesaContext->direct;
1404afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1405afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1406afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1407afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1408426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1409426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXSwapBuffers( Display *dpy, GLXDrawable drawable )
1410afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1411afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaBuffer buffer = XMesaFindBuffer( dpy, drawable );
1412afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1413afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (buffer) {
1414afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      XMesaSwapBuffers(buffer);
1415afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1416afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else if (getenv("MESA_DEBUG")) {
1417d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul      _mesa_warning(NULL, "Mesa: glXSwapBuffers: invalid drawable\n");
1418afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1419afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1420afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1421afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
14224c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul
1423b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_MESA_copy_sub_buffer ***/
1424b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul
1425426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1426426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCopySubBufferMESA( Display *dpy, GLXDrawable drawable,
1427426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                           int x, int y, int width, int height )
1428afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1429afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaBuffer buffer = XMesaFindBuffer( dpy, drawable );
1430afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (buffer) {
1431afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      XMesaCopySubBuffer(buffer, x, y, width, height);
1432afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1433afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else if (getenv("MESA_DEBUG")) {
1434d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul      _mesa_warning(NULL, "Mesa: glXCopySubBufferMESA: invalid drawable\n");
1435afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1436afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1437afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1438afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1439afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1440426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool
1441426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryVersion( Display *dpy, int *maj, int *min )
1442afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1443afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
1444afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* Return GLX version, not Mesa version */
144578fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul   assert(CLIENT_MAJOR_VERSION == SERVER_MAJOR_VERSION);
144678fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul   *maj = CLIENT_MAJOR_VERSION;
144778fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul   *min = MIN2( CLIENT_MINOR_VERSION, SERVER_MINOR_VERSION );
1448afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return True;
1449afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1450afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1451afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1452afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1453afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
1454afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Query the GLX attributes of the given XVisualInfo.
1455afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
1456426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int
1457426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetConfig( Display *dpy, XVisualInfo *visinfo,
1458426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                   int attrib, int *value )
1459afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1460afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaVisual glxvis;
1461afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1462afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   glxvis = find_glx_visual( dpy, visinfo );
1463afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (!glxvis) {
1464afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* this visual wasn't obtained with glXChooseVisual */
1465afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      glxvis = create_glx_visual( dpy, visinfo );
1466afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (!glxvis) {
1467afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 /* this visual can't be used for GL rendering */
1468afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 if (attrib==GLX_USE_GL) {
1469afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    *value = (int) False;
1470afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    return 0;
1471afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 }
1472afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 else {
1473afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    return GLX_BAD_VISUAL;
1474afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 }
1475afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
1476afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1477afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1478afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   switch(attrib) {
1479afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_USE_GL:
1480afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         *value = (int) True;
1481afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1482afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_BUFFER_SIZE:
1483afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 *value = visinfo->depth;
1484afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1485afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_LEVEL:
1486afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 *value = glxvis->level;
1487afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1488afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_RGBA:
14891832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul	 if (glxvis->mesa_visual.rgbMode) {
1490afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    *value = True;
1491afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 }
1492afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 else {
1493afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    *value = False;
1494afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 }
1495afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1496afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_DOUBLEBUFFER:
14971832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul	 *value = (int) glxvis->mesa_visual.doubleBufferMode;
1498afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1499afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_STEREO:
15001832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul	 *value = (int) glxvis->mesa_visual.stereoMode;
1501afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1502afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_AUX_BUFFERS:
1503afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 *value = (int) False;
1504afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1505afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_RED_SIZE:
15061832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul         *value = glxvis->mesa_visual.redBits;
1507afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1508afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_GREEN_SIZE:
15091832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul         *value = glxvis->mesa_visual.greenBits;
1510afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1511afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_BLUE_SIZE:
15121832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul         *value = glxvis->mesa_visual.blueBits;
1513afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1514afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_ALPHA_SIZE:
15151832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul         *value = glxvis->mesa_visual.alphaBits;
1516afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1517afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_DEPTH_SIZE:
15181832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul         *value = glxvis->mesa_visual.depthBits;
1519afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1520afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_STENCIL_SIZE:
15211832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul	 *value = glxvis->mesa_visual.stencilBits;
1522afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1523afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_ACCUM_RED_SIZE:
15241832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul	 *value = glxvis->mesa_visual.accumRedBits;
1525b2e460018375f699198073a6167e0ee96ba1d267Brian Paul	 return 0;
1526afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_ACCUM_GREEN_SIZE:
15271832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul	 *value = glxvis->mesa_visual.accumGreenBits;
1528b2e460018375f699198073a6167e0ee96ba1d267Brian Paul	 return 0;
1529afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_ACCUM_BLUE_SIZE:
15301832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul	 *value = glxvis->mesa_visual.accumBlueBits;
1531afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1532afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_ACCUM_ALPHA_SIZE:
15331832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul         *value = glxvis->mesa_visual.accumAlphaBits;
1534afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1535afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1536afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /*
1537afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg       * GLX_EXT_visual_info extension
1538afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg       */
1539afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_X_VISUAL_TYPE_EXT:
1540afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         switch (glxvis->visinfo->CLASS) {
1541afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case StaticGray:   *value = GLX_STATIC_GRAY_EXT;   return 0;
1542afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GrayScale:    *value = GLX_GRAY_SCALE_EXT;    return 0;
1543afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case StaticColor:  *value = GLX_STATIC_GRAY_EXT;   return 0;
1544afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case PseudoColor:  *value = GLX_PSEUDO_COLOR_EXT;  return 0;
1545afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case TrueColor:    *value = GLX_TRUE_COLOR_EXT;    return 0;
1546afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case DirectColor:  *value = GLX_DIRECT_COLOR_EXT;  return 0;
1547afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
1548afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1549afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_TRANSPARENT_TYPE_EXT:
1550afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         if (glxvis->level==0) {
1551afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* normal planes */
1552afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            *value = GLX_NONE_EXT;
1553afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
1554afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         else if (glxvis->level>0) {
1555afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* overlay */
15561832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul            if (glxvis->mesa_visual.rgbMode) {
1557afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               *value = GLX_TRANSPARENT_RGB_EXT;
1558afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
1559afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            else {
1560afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               *value = GLX_TRANSPARENT_INDEX_EXT;
1561afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
1562afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
1563afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         else if (glxvis->level<0) {
1564afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* underlay */
1565afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            *value = GLX_NONE_EXT;
1566afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
1567afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1568afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_TRANSPARENT_INDEX_VALUE_EXT:
1569afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         {
1570afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            int pixel = transparent_pixel( glxvis );
1571afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            if (pixel>=0) {
1572afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               *value = pixel;
1573afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
1574afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* else undefined */
1575afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
1576afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1577afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_TRANSPARENT_RED_VALUE_EXT:
1578afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* undefined */
1579afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1580afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_TRANSPARENT_GREEN_VALUE_EXT:
1581afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* undefined */
1582afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1583afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_TRANSPARENT_BLUE_VALUE_EXT:
1584afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* undefined */
1585afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1586afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_TRANSPARENT_ALPHA_VALUE_EXT:
1587afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* undefined */
1588afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1589afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1590afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /*
1591b2e460018375f699198073a6167e0ee96ba1d267Brian Paul       * GLX_EXT_visual_info extension
1592b2e460018375f699198073a6167e0ee96ba1d267Brian Paul       */
1593b2e460018375f699198073a6167e0ee96ba1d267Brian Paul      case GLX_VISUAL_CAVEAT_EXT:
1594fc68be6b111473a0bf8f991468f973bb9dd275f4Brian Paul         /* test for zero, just in case */
1595962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul         if (glxvis->VisualCaveat > 0)
1596962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul            *value = glxvis->VisualCaveat;
1597962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul         else
1598962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul            *value = GLX_NONE_EXT;
1599962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul         return 0;
1600b2e460018375f699198073a6167e0ee96ba1d267Brian Paul
1601b2e460018375f699198073a6167e0ee96ba1d267Brian Paul      /*
1602afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg       * Extensions
1603afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg       */
1604afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      default:
1605afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return GLX_BAD_ATTRIBUTE;
1606afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1607afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1608afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1609afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1610afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1611426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1612426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXWaitGL( void )
1613afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1614afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaContext xmesa = XMesaGetCurrentContext();
1615afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaFlush( xmesa );
1616afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1617afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1618afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1619afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1620426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1621426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXWaitX( void )
1622afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1623afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaContext xmesa = XMesaGetCurrentContext();
1624afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaFlush( xmesa );
1625afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1626afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1627afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
162843c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul/*
162943c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul * Return the extensions string, which is 3Dfx-dependant.
163043c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul */
163143c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paulstatic const char *get_extensions( void )
163243c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul{
163343c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul#ifdef FX
163443c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul   const char *fx = getenv("MESA_GLX_FX");
163543c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul   if (fx && fx[0] != 'd') {
1636e1210b176926349b258c7ec77b7f36716025c82aBrian Paul      return "GLX_MESA_pixmap_colormap GLX_EXT_visual_info GLX_EXT_visual_rating GLX_MESA_release_buffers GLX_MESA_copy_sub_buffer GLX_SGI_video_sync GLX_MESA_set_3dfx_mode GLX_ARB_get_proc_address";
163743c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul   }
163843c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul#endif
1639e1210b176926349b258c7ec77b7f36716025c82aBrian Paul   return "GLX_MESA_pixmap_colormap GLX_EXT_visual_info GLX_EXT_visual_rating GLX_MESA_release_buffers GLX_MESA_copy_sub_buffer GLX_SGI_video_sync GLX_ARB_get_proc_address";
164043c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul}
1641afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1642afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1643afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1644afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* GLX 1.1 and later */
1645426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic const char *
1646426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryExtensionsString( Display *dpy, int screen )
1647afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1648afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
1649afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) screen;
165043c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul   return get_extensions();
1651afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1652afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1653afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1654afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1655afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* GLX 1.1 and later */
1656426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic const char *
1657426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryServerString( Display *dpy, int screen, int name )
1658afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
165978fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul   static char version[1000];
166078fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul   sprintf(version, "%d.%d %s", SERVER_MAJOR_VERSION, SERVER_MINOR_VERSION,
166178fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul           MESA_GLX_VERSION);
1662afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1663afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
1664afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) screen;
1665afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1666afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   switch (name) {
1667afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_EXTENSIONS:
166843c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul         return get_extensions();
1669afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_VENDOR:
167078fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul	 return VENDOR;
1671afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_VERSION:
1672afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return version;
1673afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      default:
1674afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return NULL;
1675afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1676afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1677afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1678afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1679afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1680afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* GLX 1.1 and later */
1681426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic const char *
1682426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetClientString( Display *dpy, int name )
1683afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
168478fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul   static char version[1000];
168578fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul   sprintf(version, "%d.%d %s", CLIENT_MAJOR_VERSION, CLIENT_MINOR_VERSION,
168678fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul           MESA_GLX_VERSION);
1687afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1688afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
1689afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1690afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   switch (name) {
1691afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_EXTENSIONS:
169243c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul         return get_extensions();
1693afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_VENDOR:
169478fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul	 return VENDOR;
1695afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_VERSION:
1696afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return version;
1697afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      default:
1698afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return NULL;
1699afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1700afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1701afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1702afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1703afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1704426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul/*
1705426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul * GLX 1.3 and later
1706426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul */
1707426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
17087d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul/* XXX Move this when done.
17097d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul * Create an XMesaBuffer as a Pbuffer.
1710a573803ed3fe9ef6489f45bd4c5455b77cb33a43Brian Paul * New in Mesa 4.0 but untested.
17117d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul */
17127d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paulextern XMesaBuffer XMesaCreatePBuffer( XMesaVisual v, XMesaColormap cmap,
17137d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul                                    unsigned int width, unsigned int height );
17147d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
17157d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
17167d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
1717a078d75a27b99252ede6520e24b145106ab98aa2Brian Paul/* PBUFFER */
17185605798e56ca6e9f968623f33b58ee7ca90594afBrian Paulstatic GLXFBConfig *
1719426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXChooseFBConfig( Display *dpy, int screen,
1720426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                        const int *attribList, int *nitems )
1721426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
1722426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
1723426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) screen;
1724426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) attribList;
1725426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) nitems;
1726426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   return 0;
1727426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
1728426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1729426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1730a078d75a27b99252ede6520e24b145106ab98aa2Brian Paul/* PBUFFER */
1731426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int
1732426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetFBConfigAttrib( Display *dpy, GLXFBConfig config,
1733426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                           int attribute, int *value )
1734426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
17357d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   XMesaVisual v = NULL; /* XXX Fix this */
1736426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
1737426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) config;
1738426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) attribute;
1739426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) value;
17407d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
17417d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (!dpy || !config || !value)
17427d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return -1;
17437d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
17447d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   switch (attribute) {
17457d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_FBCONFIG_ID:
17467d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_BUFFER_SIZE:
17477d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         if (v->mesa_visual.rgbMode)
17487d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            *value = v->mesa_visual.redBits + v->mesa_visual.greenBits +
17497d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul                     v->mesa_visual.blueBits + v->mesa_visual.alphaBits;
17507d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         else
17517d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            *value = v->mesa_visual.indexBits;
17527d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
17537d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_LEVEL:
17547d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = v->level;
17557d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
17567d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_DOUBLEBUFFER:
17577d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = v->mesa_visual.doubleBufferMode;
17587d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
17597d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_STEREO:
17607d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = v->mesa_visual.stereoMode;
17617d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
17627d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_AUX_BUFFERS:
17637d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = v->mesa_visual.numAuxBuffers;
17647d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
17657d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_RED_SIZE:
17667d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = v->mesa_visual.redBits;
17677d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
17687d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_GREEN_SIZE:
17697d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = v->mesa_visual.greenBits;
17707d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
17717d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_BLUE_SIZE:
17727d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = v->mesa_visual.blueBits;
17737d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
17747d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_ALPHA_SIZE:
17757d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = v->mesa_visual.alphaBits;
17767d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
17777d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_DEPTH_SIZE:
17787d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = v->mesa_visual.depthBits;
17797d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
17807d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_STENCIL_SIZE:
17817d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = v->mesa_visual.stencilBits;
17827d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
17837d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_ACCUM_RED_SIZE:
17847d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = v->mesa_visual.accumRedBits;
17857d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
17867d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_ACCUM_GREEN_SIZE:
17877d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = v->mesa_visual.accumGreenBits;
17887d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
17897d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_ACCUM_BLUE_SIZE:
17907d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = v->mesa_visual.accumBlueBits;
17917d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
17927d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_ACCUM_ALPHA_SIZE:
17937d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = v->mesa_visual.accumAlphaBits;
17947d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
17957d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_RENDER_TYPE:
17967d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = 0; /* XXX ??? */
17977d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
17987d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_DRAWABLE_TYPE:
17997d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = GLX_PBUFFER_BIT; /* XXX fix? */
18007d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
18017d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_X_RENDERABLE:
18027d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = False; /* XXX ??? */
18037d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
18047d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_X_VISUAL_TYPE:
18054c5f8a82072e7c88bec67fd1c971db28bd1e4462Brian Paul#if defined(__cplusplus) || defined(c_plusplus)
18064c5f8a82072e7c88bec67fd1c971db28bd1e4462Brian Paul         switch (v->vishandle->c_class) {
18074c5f8a82072e7c88bec67fd1c971db28bd1e4462Brian Paul#else
18087d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         switch (v->vishandle->class) {
18094c5f8a82072e7c88bec67fd1c971db28bd1e4462Brian Paul#endif
18107d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            case GrayScale:
18117d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul               *value = GLX_GRAY_SCALE;
18127d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul               break;
18137d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            case StaticGray:
18147d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul               *value = GLX_STATIC_GRAY;
18157d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul               break;
18167d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            case StaticColor:
18177d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul               *value = GLX_STATIC_COLOR;
18187d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul               break;
18197d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            case PseudoColor:
18207d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul               *value = GLX_PSEUDO_COLOR;
18217d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul               break;
18227d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            case TrueColor:
18237d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul               *value = GLX_TRUE_COLOR;
18247d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul               break;
18257d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            case DirectColor:
18267d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul               *value = GLX_DIRECT_COLOR;
18277d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul               break;
18287d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            default:
18297d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul               *value = 0;
18307d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         }
18317d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
18327d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_CONFIG_CAVEAT:
18337d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = 0; /* XXX ??? */
18347d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
18357d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_TRANSPARENT_TYPE:
18367d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         if (v->level == 0) {
18377d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            /* normal planes */
18387d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            *value = GLX_NONE_EXT;
18397d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         }
18407d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         else if (v->level > 0) {
18417d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            /* overlay */
18427d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            if (v->mesa_visual.rgbMode) {
18437d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul               *value = GLX_TRANSPARENT_RGB_EXT;
18447d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            }
18457d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            else {
18467d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul               *value = GLX_TRANSPARENT_INDEX_EXT;
18477d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            }
18487d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         }
18497d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         else if (v->level < 0) {
18507d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            /* underlay */
18517d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            *value = GLX_NONE_EXT;
18527d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         }
18537d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
18547d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_TRANSPARENT_INDEX_VALUE:
18557d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = transparent_pixel( v );
18567d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
18577d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_TRANSPARENT_RED_VALUE:
18587d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = 0;  /* not implemented */
18597d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
18607d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_TRANSPARENT_GREEN_VALUE:
18617d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = 0;  /* not implemented */
18627d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
18637d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_TRANSPARENT_BLUE_VALUE:
18647d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = 0;  /* not implemented */
18657d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
18667d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_TRANSPARENT_ALPHA_VALUE:
18677d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = 0;  /* not implemented */
18687d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
18697d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_MAX_PBUFFER_WIDTH:
18707d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = DisplayWidth(dpy, v->vishandle->screen);
18717d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
18727d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_MAX_PBUFFER_HEIGHT:
18737d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = DisplayHeight(dpy, v->vishandle->screen);
18747d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
18757d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_MAX_PBUFFER_PIXELS:
18767d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = DisplayWidth(dpy, v->vishandle->screen) *
18777d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul                  DisplayHeight(dpy, v->vishandle->screen);
18787d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
18797d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_VISUAL_ID:
18807d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = v->vishandle->visualid;
18817d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
18827d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      default:
18837d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         return GLX_BAD_ATTRIBUTE;
18847d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   }
18857d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
18867d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   return Success;
1887426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
1888426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1889426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1890a078d75a27b99252ede6520e24b145106ab98aa2Brian Paul/* PBUFFER */
18915605798e56ca6e9f968623f33b58ee7ca90594afBrian Paulstatic GLXFBConfig *
18925605798e56ca6e9f968623f33b58ee7ca90594afBrian PaulFake_glXGetFBConfigs( Display *dpy, int screen, int *nelements )
18935605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul{
1894a078d75a27b99252ede6520e24b145106ab98aa2Brian Paul   /* Get list of all X visuals, create FBconfigs from them */
18955605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul   (void) dpy;
18965605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul   (void) screen;
1897a078d75a27b99252ede6520e24b145106ab98aa2Brian Paul   nelements = 0;
18985605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul   return 0;
18995605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul}
19005605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul
19015605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul
1902a078d75a27b99252ede6520e24b145106ab98aa2Brian Paul/* PBUFFER */
1903426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic XVisualInfo *
1904426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetVisualFromFBConfig( Display *dpy, GLXFBConfig config )
1905426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
19067d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (dpy && config) {
19077d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      XMesaVisual v = (XMesaVisual) config;
19087d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return v->vishandle;
19097d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   }
19107d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   else {
19117d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return NULL;
19127d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   }
1913426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
1914426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1915426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1916a078d75a27b99252ede6520e24b145106ab98aa2Brian Paul/* PBUFFER */
1917426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXWindow
1918426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateWindow( Display *dpy, GLXFBConfig config, Window win,
1919426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                      const int *attribList )
1920426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
1921426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
1922426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) config;
1923426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) win;
19247d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   (void) attribList;  /* Ignored in GLX 1.3 */
19257d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
19267d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   return win;  /* A hack for now */
1927426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
1928426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1929426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1930426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1931426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyWindow( Display *dpy, GLXWindow window )
1932426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
19337d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   XMesaBuffer b = XMesaFindBuffer(dpy, (XMesaDrawable) window);
19347d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (b)
19357d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      XMesaDestroyBuffer(b);
19367d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   /* don't destroy X window */
1937426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
1938426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1939426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
19407d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul/* XXX untested */
1941426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPixmap
1942426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreatePixmap( Display *dpy, GLXFBConfig config, Pixmap pixmap,
1943426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                      const int *attribList )
1944426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
19457d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   XMesaVisual v = (XMesaVisual) config;
19467d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   XVisualInfo *visinfo;
19477d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   XMesaBuffer b;
19487d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
1949426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
1950426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) config;
1951426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) pixmap;
19527d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   (void) attribList;  /* Ignored in GLX 1.3 */
19537d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
19547d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (!dpy || !config || !pixmap)
19557d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return 0;
19567d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
19577d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   visinfo = v->vishandle;
19587d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
19597d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   v = find_glx_visual( dpy, visinfo );
19607d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (!v) {
19617d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      v = create_glx_visual( dpy, visinfo );
19627d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      if (!v) {
19637d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         /* unusable visual */
19647d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         return 0;
19657d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      }
19667d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   }
19677d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
19687d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   b = XMesaCreatePixmapBuffer( v, pixmap, 0 );
19697d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (!b) {
19707d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return 0;
19717d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   }
19727d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
19737d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   return pixmap;
1974426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
1975426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1976426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1977426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1978426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyPixmap( Display *dpy, GLXPixmap pixmap )
1979426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
19807d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   XMesaBuffer b = XMesaFindBuffer(dpy, (XMesaDrawable)pixmap);
19817d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (b)
19827d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      XMesaDestroyBuffer(b);
19837d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   /* don't destroy X pixmap */
1984426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
1985426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1986426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1987a078d75a27b99252ede6520e24b145106ab98aa2Brian Paul/* PBUFFER */
1988426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPbuffer
1989426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreatePbuffer( Display *dpy, GLXFBConfig config,
1990426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                       const int *attribList )
1991426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
19927d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   const int *attrib;
19937d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   int width = 0, height = 0;
19947d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   GLboolean useLargest = GL_FALSE, preserveContents = GL_FALSE;
19957d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
1996426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
1997426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) config;
19987d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
19997d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   for (attrib = attribList; attrib; attrib++) {
20007d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      switch (*attrib) {
20017d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         case GLX_PBUFFER_WIDTH:
20027d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            width = *(++attrib);
20037d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            break;
20047d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         case GLX_PBUFFER_HEIGHT:
20057d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            height = *(++attrib);
20067d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            break;
20077d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         case GLX_PRESERVED_CONTENTS:
20087d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            preserveContents = GL_TRUE; /* ignored */
20097d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            break;
20107d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         case GLX_LARGEST_PBUFFER:
20117d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            useLargest = GL_TRUE; /* ignored */
20127d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            break;
20137d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         default:
20147d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            return 0;
20157d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      }
20167d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   }
20177d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
20187d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (width == 0 || height == 0)
20197d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return 0;
20207d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
20217d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
2022426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   return 0;
2023426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2024426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2025426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2026a078d75a27b99252ede6520e24b145106ab98aa2Brian Paul/* PBUFFER */
2027426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
2028426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyPbuffer( Display *dpy, GLXPbuffer pbuf )
2029426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2030426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
2031426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) pbuf;
2032426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2033426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2034426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2035a078d75a27b99252ede6520e24b145106ab98aa2Brian Paul/* PBUFFER */
2036426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
2037426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryDrawable( Display *dpy, GLXDrawable draw, int attribute,
2038426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                       unsigned int *value )
2039426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2040426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
2041426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) draw;
20427d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
20437d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   switch (attribute) {
20447d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_WIDTH:
20457d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_HEIGHT:
20467d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_PRESERVED_CONTENTS:
20477d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_LARGEST_PBUFFER:
20487d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_FBCONFIG_ID:
20497d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = 0;
20507d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         return;
20517d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      default:
20527d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         return;  /* GLX_BAD_ATTRIBUTE? */
20537d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   }
2054426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2055426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2056426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2057426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXContext
2058426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateNewContext( Display *dpy, GLXFBConfig config,
2059426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                          int renderType, GLXContext shareList, Bool direct )
2060426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
20617d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   XMesaVisual v = (XMesaVisual) config;
20627d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
20637d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (!dpy || !config ||
20647d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul       (renderType != GLX_RGBA_TYPE && renderType != GLX_COLOR_INDEX_TYPE))
20657d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return 0;
20667d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
20677d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   return Fake_glXCreateContext(dpy, v->vishandle, shareList, direct);
2068426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2069426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2070426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2071a078d75a27b99252ede6520e24b145106ab98aa2Brian Paul/* PBUFFER */
2072426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int
2073426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryContext( Display *dpy, GLXContext ctx, int attribute, int *value )
2074426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2075426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
2076426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) ctx;
20777d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
20787d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   switch (attribute) {
20797d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   case GLX_FBCONFIG_ID:
20807d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   case GLX_RENDER_TYPE:
20817d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   case GLX_SCREEN:
20827d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      *value = 0;
20837d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return Success;
20847d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   default:
20857d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return GLX_BAD_ATTRIBUTE;
20867d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   }
2087426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2088426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2089426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2090a078d75a27b99252ede6520e24b145106ab98aa2Brian Paul/* PBUFFER */
2091426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
2092426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXSelectEvent( Display *dpy, GLXDrawable drawable, unsigned long mask )
2093426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2094426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
2095426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) drawable;
2096426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) mask;
2097426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2098426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2099426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2100a078d75a27b99252ede6520e24b145106ab98aa2Brian Paul/* PBUFFER */
2101426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
2102426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetSelectedEvent( Display *dpy, GLXDrawable drawable,
2103426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                          unsigned long *mask )
2104426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2105426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
2106426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) drawable;
2107426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) mask;
2108426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2109b82d993b03320818f88f792a9e713f7ed491bfcbBrian Paul
2110b82d993b03320818f88f792a9e713f7ed491bfcbBrian Paul
2111b82d993b03320818f88f792a9e713f7ed491bfcbBrian Paul
2112b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGI_swap_control ***/
2113783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2114783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2115783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXSwapIntervalSGI(int interval)
2116783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2117783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) interval;
2118783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2119783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2120783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2121783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2122783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2123b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGI_video_sync ***/
2124783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2125783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2126783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetVideoSyncSGI(unsigned int *count)
2127783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2128783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) count;
2129783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2130783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2131783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2132783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2133783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count)
2134783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2135783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) divisor;
2136783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) remainder;
2137783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) count;
2138783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2139783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2140783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2141783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2142783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2143b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGI_make_current_read ***/
2144783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2145426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool
2146783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXMakeCurrentReadSGI(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx)
2147afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
2148a078d75a27b99252ede6520e24b145106ab98aa2Brian Paul   return Fake_glXMakeContextCurrent( dpy, draw, read, ctx );
2149afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
2150783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
21517cf50e137da497a590ec9001a9918972a6246142Brian Paul/* not used
2152783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXDrawable
2153b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian PaulFake_glXGetCurrentReadDrawableSGI(void)
2154783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2155783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2156783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
21577cf50e137da497a590ec9001a9918972a6246142Brian Paul*/
2158afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
2159afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
2160b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_video_source ***/
2161b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#if defined(_VL_H)
21624c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul
2163783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXVideoSourceSGIX
2164783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXCreateGLXVideoSourceSGIX(Display *dpy, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode)
2165afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
2166783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2167783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2168783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) server;
2169783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) path;
2170783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) nodeClass;
2171783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) drainNode;
2172783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2173783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2174783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2175783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2176783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXDestroyGLXVideoSourceSGIX(Display *dpy, GLXVideoSourceSGIX src)
2177783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2178783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2179783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) src;
2180afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
2181783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
21824c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul#endif
21834c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul
218489a42b7e736bd9b0ab090906cab0cd047a6ec12eBrian Paul
2185b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_EXT_import_context ***/
218689a42b7e736bd9b0ab090906cab0cd047a6ec12eBrian Paul
2187783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2188783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXFreeContextEXT(Display *dpy, GLXContext context)
2189783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2190783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2191783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) context;
2192783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2193426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2194783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXContextID
2195783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetContextIDEXT(const GLXContext context)
2196783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2197783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) context;
2198783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2199783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2200783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2201783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXContext
2202783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXImportContextEXT(Display *dpy, GLXContextID contextID)
2203783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2204783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2205783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) contextID;
2206783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2207783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2208426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2209426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int
2210783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryContextInfoEXT(Display *dpy, GLXContext context, int attribute, int *value)
2211426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2212783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2213783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) context;
2214783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) attribute;
2215783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) value;
2216426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   return 0;
2217426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2218426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2219783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2220783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2221b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_fbconfig ***/
2222426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2223426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int
2224783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetFBConfigAttribSGIX(Display *dpy, GLXFBConfigSGIX config, int attribute, int *value)
2225783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2226783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2227783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) config;
2228783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) attribute;
2229783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) value;
2230783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2231783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2232783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2233783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXFBConfigSGIX *
2234783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXChooseFBConfigSGIX(Display *dpy, int screen, int *attrib_list, int *nelements)
2235783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2236783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2237783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2238783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) attrib_list;
2239783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) nelements;
2240783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2241783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2242783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2243783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXPixmap
2244783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXCreateGLXPixmapWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap)
2245783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2246783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2247783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) config;
2248783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) pixmap;
2249783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2250783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2251783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2252783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXContext
2253783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct)
2254783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2255783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2256783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) config;
2257783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) render_type;
2258783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) share_list;
2259783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) direct;
2260783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2261783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2262783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2263783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic XVisualInfo *
2264783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetVisualFromFBConfigSGIX(Display *dpy, GLXFBConfigSGIX config)
2265783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2266783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2267783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) config;
2268783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return NULL;
2269783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2270783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2271783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXFBConfigSGIX
2272783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetFBConfigFromVisualSGIX(Display *dpy, XVisualInfo *vis)
2273426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2274783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2275783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) vis;
2276426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   return 0;
2277426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2278426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2279426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2280426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2281b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_pbuffer ***/
2282783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2283783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXPbufferSGIX
2284783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXCreateGLXPbufferSGIX(Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list)
2285783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2286783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2287783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) config;
2288783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) width;
2289783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) height;
2290783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) attrib_list;
2291783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2292783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2293783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2294783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2295783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXDestroyGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf)
2296783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2297783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2298783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) pbuf;
2299783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2300783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2301783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2302783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value)
2303783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2304783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2305783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) pbuf;
2306783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) attribute;
2307783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) value;
2308783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2309783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2310783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2311783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2312783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXSelectEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long mask)
2313783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2314783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2315783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) drawable;
2316783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) mask;
2317783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2318783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2319783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2320783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetSelectedEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long *mask)
2321783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2322783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2323783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) drawable;
2324783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) mask;
2325783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2326783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2327783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2328783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2329b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGI_cushion ***/
2330783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2331783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2332783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXCushionSGI(Display *dpy, Window win, float cushion)
2333783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2334783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2335783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) win;
2336783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) cushion;
2337783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2338783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2339783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2340783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2341b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_video_resize ***/
2342783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2343783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2344783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXBindChannelToWindowSGIX(Display *dpy, int screen, int channel , Window window)
2345783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2346783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2347783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2348783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) channel;
2349783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) window;
2350783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2351783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2352783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2353783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2354783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXChannelRectSGIX(Display *dpy, int screen, int channel, int x, int y, int w, int h)
2355783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2356783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2357783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2358783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) channel;
2359783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) x;
2360783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) y;
2361783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) w;
2362783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) h;
2363783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2364783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2365783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2366783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2367783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryChannelRectSGIX(Display *dpy, int screen, int channel, int *x, int *y, int *w, int *h)
2368783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2369783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2370783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2371783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) channel;
2372783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) x;
2373783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) y;
2374783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) w;
2375783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) h;
2376783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2377783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2378783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2379783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2380783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryChannelDeltasSGIX(Display *dpy, int screen, int channel, int *dx, int *dy, int *dw, int *dh)
2381783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2382783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2383783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2384783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) channel;
2385783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dx;
2386783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dy;
2387783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dw;
2388783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dh;
2389783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2390783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2391783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2392783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2393783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXChannelRectSyncSGIX(Display *dpy, int screen, int channel, GLenum synctype)
2394783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2395783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2396783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2397783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) channel;
2398783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) synctype;
2399783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2400783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2401783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2402783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2403783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2404b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_dmbuffer **/
2405783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2406b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#if defined(_DM_BUFFER_H_)
2407783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Bool
2408783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXAssociateDMPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer)
2409783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2410783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2411783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) pbuffer;
2412783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) params;
2413783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dmbuffer;
2414783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return False;
2415783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2416783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul#endif
2417783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2418783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2419b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_swap_group ***/
2420783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2421783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2422783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXJoinSwapGroupSGIX(Display *dpy, GLXDrawable drawable, GLXDrawable member)
2423783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2424783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2425783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) drawable;
2426783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) member;
2427783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2428783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2429783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2430783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2431b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_swap_barrier ***/
2432783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2433783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2434783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXBindSwapBarrierSGIX(Display *dpy, GLXDrawable drawable, int barrier)
2435783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2436783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2437783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) drawable;
2438783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) barrier;
2439783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2440783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2441783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Bool
2442783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryMaxSwapBarriersSGIX(Display *dpy, int screen, int *max)
2443783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2444783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2445783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2446783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) max;
2447783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return False;
2448783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2449783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2450783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2451783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2452b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SUN_get_transparent_index ***/
2453783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2454783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Status
2455783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetTransparentIndexSUN(Display *dpy, Window overlay, Window underlay, long *pTransparent)
2456783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2457783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2458783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) overlay;
2459783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) underlay;
2460783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) pTransparent;
2461783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2462783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2463783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2464783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2465783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2466b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_MESA_release_buffers ***/
2467b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul
2468783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul/*
2469783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul * Release the depth, stencil, accum buffers attached to a GLXDrawable
2470783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul * (a window or pixmap) prior to destroying the GLXDrawable.
2471783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul */
2472783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Bool
2473783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXReleaseBuffersMESA( Display *dpy, GLXDrawable d )
2474783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2475783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   XMesaBuffer b = XMesaFindBuffer(dpy, d);
2476783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   if (b) {
2477783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul      XMesaDestroyBuffer(b);
2478783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul      return True;
2479783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   }
2480783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return False;
2481783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2482783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2483783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2484783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2485b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_MESA_set_3dfx_mode ***/
2486b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul
2487783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Bool
2488783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXSet3DfxModeMESA( int mode )
2489783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2490783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return XMesaSetFXmode( mode );
2491783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2492783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2493783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2494783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
249543c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul
2496e7b16b74bf5d13331b5a88bbbbb9096560297b63Brian Paulextern struct _glxapi_table *_mesa_GetGLXDispatchTable(void);
2497426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstruct _glxapi_table *_mesa_GetGLXDispatchTable(void)
2498426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2499426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   static struct _glxapi_table glx;
2500426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2501426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   /* be sure our dispatch table size <= libGL's table */
2502426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   {
250301915e90e6912f06d43d443a09157f7bbc96ddc5Brian Paul      GLuint size = sizeof(struct _glxapi_table) / sizeof(void *);
2504426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul      (void) size;
2505426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul      assert(_glxapi_get_dispatch_table_size() >= size);
2506426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   }
2507426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2508426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   /* initialize the whole table to no-ops */
2509426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   _glxapi_set_no_op_table(&glx);
2510426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2511426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   /* now initialize the table with the functions I implement */
2512426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.ChooseVisual = Fake_glXChooseVisual;
2513426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CopyContext = Fake_glXCopyContext;
2514426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CreateContext = Fake_glXCreateContext;
2515426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CreateGLXPixmap = Fake_glXCreateGLXPixmap;
2516426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.DestroyContext = Fake_glXDestroyContext;
2517426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.DestroyGLXPixmap = Fake_glXDestroyGLXPixmap;
2518426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.GetConfig = Fake_glXGetConfig;
2519426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   /*glx.GetCurrentContext = Fake_glXGetCurrentContext;*/
2520426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   /*glx.GetCurrentDrawable = Fake_glXGetCurrentDrawable;*/
2521426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.IsDirect = Fake_glXIsDirect;
2522426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.MakeCurrent = Fake_glXMakeCurrent;
2523426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.QueryExtension = Fake_glXQueryExtension;
2524426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.QueryVersion = Fake_glXQueryVersion;
2525426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.SwapBuffers = Fake_glXSwapBuffers;
2526426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.UseXFont = Fake_glXUseXFont;
2527426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.WaitGL = Fake_glXWaitGL;
2528426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.WaitX = Fake_glXWaitX;
2529426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2530b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_VERSION_1_1 ***/
2531426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.GetClientString = Fake_glXGetClientString;
2532426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.QueryExtensionsString = Fake_glXQueryExtensionsString;
2533426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.QueryServerString = Fake_glXQueryServerString;
2534426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2535b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_VERSION_1_2 ***/
2536426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   /*glx.GetCurrentDisplay = Fake_glXGetCurrentDisplay;*/
2537426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2538b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_VERSION_1_3 ***/
2539426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.ChooseFBConfig = Fake_glXChooseFBConfig;
2540426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CreateNewContext = Fake_glXCreateNewContext;
2541426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CreatePbuffer = Fake_glXCreatePbuffer;
2542426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CreatePixmap = Fake_glXCreatePixmap;
2543426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CreateWindow = Fake_glXCreateWindow;
2544426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.DestroyPbuffer = Fake_glXDestroyPbuffer;
2545426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.DestroyPixmap = Fake_glXDestroyPixmap;
2546426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.DestroyWindow = Fake_glXDestroyWindow;
2547426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   /*glx.GetCurrentReadDrawable = Fake_glXGetCurrentReadDrawable;*/
2548426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.GetFBConfigAttrib = Fake_glXGetFBConfigAttrib;
254971dea349d2be623b7819389428b0d6a124e8d184Brian Paul   glx.GetFBConfigs = Fake_glXGetFBConfigs;
2550426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.GetSelectedEvent = Fake_glXGetSelectedEvent;
2551426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.GetVisualFromFBConfig = Fake_glXGetVisualFromFBConfig;
2552426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.MakeContextCurrent = Fake_glXMakeContextCurrent;
2553426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.QueryContext = Fake_glXQueryContext;
2554426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.QueryDrawable = Fake_glXQueryDrawable;
2555426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.SelectEvent = Fake_glXSelectEvent;
2556426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2557b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGI_swap_control ***/
2558783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.SwapIntervalSGI = Fake_glXSwapIntervalSGI;
2559783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2560b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGI_video_sync ***/
2561426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.GetVideoSyncSGI = Fake_glXGetVideoSyncSGI;
2562426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.WaitVideoSyncSGI = Fake_glXWaitVideoSyncSGI;
2563426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2564b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGI_make_current_read ***/
2565783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.MakeCurrentReadSGI = Fake_glXMakeCurrentReadSGI;
25667cf50e137da497a590ec9001a9918972a6246142Brian Paul   /*glx.GetCurrentReadDrawableSGI = Fake_glXGetCurrentReadDrawableSGI;*/
2567783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2568b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_video_source ***/
2569b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#if defined(_VL_H)
2570783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.CreateGLXVideoSourceSGIX = Fake_glXCreateGLXVideoSourceSGIX;
2571783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.DestroyGLXVideoSourceSGIX = Fake_glXDestroyGLXVideoSourceSGIX;
2572783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul#endif
2573783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2574b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_EXT_import_context ***/
2575783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.FreeContextEXT = Fake_glXFreeContextEXT;
2576783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.GetContextIDEXT = Fake_glXGetContextIDEXT;
25777cf50e137da497a590ec9001a9918972a6246142Brian Paul   /*glx.GetCurrentDisplayEXT = Fake_glXGetCurrentDisplayEXT;*/
2578783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.ImportContextEXT = Fake_glXImportContextEXT;
2579783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.QueryContextInfoEXT = Fake_glXQueryContextInfoEXT;
25804536021a62e02fceaa6e8eb889b0f61743109cc4Brian Paul
2581b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGIX_fbconfig ***/
2582783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.GetFBConfigAttribSGIX = Fake_glXGetFBConfigAttribSGIX;
2583783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.ChooseFBConfigSGIX = Fake_glXChooseFBConfigSGIX;
2584783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.CreateGLXPixmapWithConfigSGIX = Fake_glXCreateGLXPixmapWithConfigSGIX;
2585783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.CreateContextWithConfigSGIX = Fake_glXCreateContextWithConfigSGIX;
2586783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.GetVisualFromFBConfigSGIX = Fake_glXGetVisualFromFBConfigSGIX;
2587783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.GetFBConfigFromVisualSGIX = Fake_glXGetFBConfigFromVisualSGIX;
2588783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2589b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGIX_pbuffer ***/
2590783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.CreateGLXPbufferSGIX = Fake_glXCreateGLXPbufferSGIX;
2591783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.DestroyGLXPbufferSGIX = Fake_glXDestroyGLXPbufferSGIX;
2592783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.QueryGLXPbufferSGIX = Fake_glXQueryGLXPbufferSGIX;
2593783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.SelectEventSGIX = Fake_glXSelectEventSGIX;
2594783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.GetSelectedEventSGIX = Fake_glXGetSelectedEventSGIX;
2595783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2596b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGI_cushion ***/
2597783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.CushionSGI = Fake_glXCushionSGI;
2598783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2599b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGIX_video_resize ***/
2600783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.BindChannelToWindowSGIX = Fake_glXBindChannelToWindowSGIX;
2601783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.ChannelRectSGIX = Fake_glXChannelRectSGIX;
2602783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.QueryChannelRectSGIX = Fake_glXQueryChannelRectSGIX;
2603783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.QueryChannelDeltasSGIX = Fake_glXQueryChannelDeltasSGIX;
2604783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.ChannelRectSyncSGIX = Fake_glXChannelRectSyncSGIX;
2605783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2606b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGIX_dmbuffer **/
2607b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#if defined(_DM_BUFFER_H_)
2608783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.AssociateDMPbufferSGIX = NULL;
2609783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul#endif
2610783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2611b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGIX_swap_group ***/
2612783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.JoinSwapGroupSGIX = Fake_glXJoinSwapGroupSGIX;
2613783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2614b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGIX_swap_barrier ***/
2615783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.BindSwapBarrierSGIX = Fake_glXBindSwapBarrierSGIX;
2616783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.QueryMaxSwapBarriersSGIX = Fake_glXQueryMaxSwapBarriersSGIX;
2617783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2618b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SUN_get_transparent_index ***/
2619783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.GetTransparentIndexSUN = Fake_glXGetTransparentIndexSUN;
26204536021a62e02fceaa6e8eb889b0f61743109cc4Brian Paul
2621b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_MESA_copy_sub_buffer ***/
2622426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CopySubBufferMESA = Fake_glXCopySubBufferMESA;
2623426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2624b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_MESA_release_buffers ***/
2625426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.ReleaseBuffersMESA = Fake_glXReleaseBuffersMESA;
2626426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2627b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_MESA_pixmap_colormap ***/
2628426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CreateGLXPixmapMESA = Fake_glXCreateGLXPixmapMESA;
2629426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2630b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_MESA_set_3dfx_mode ***/
2631426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.Set3DfxModeMESA = Fake_glXSet3DfxModeMESA;
2632426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2633426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   return &glx;
2634426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2635