fakeglx.c revision 99aab341998e84d9fa208c525cae8021b3845812
199aab341998e84d9fa208c525cae8021b3845812Brian Paul/* $Id: fakeglx.c,v 1.62 2002/04/02 23:52:53 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 {
272afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            fprintf(stderr, "Mesa: invalid value for MESA_BACK_BUFFER ");
273afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            fprintf(stderr, "environment variable, using an XImage.\n");
274afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
275afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
276afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
277afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
278afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* Comparing IDs uses less memory but sometimes fails. */
279afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* XXX revisit this after 3.0 is finished. */
280afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (getenv("MESA_GLX_VISUAL_HACK"))
281afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      comparePointers = GL_TRUE;
282afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else
283afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      comparePointers = GL_FALSE;
284afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
285afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* First check if a matching visual is already in the list */
286afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   for (i=0; i<NumVisuals; i++) {
287afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      XMesaVisual v = VisualTable[i];
288afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (v->display == dpy
289afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg          && v->level == level
290afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg          && v->ximage_flag == ximageFlag
2911832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && v->mesa_visual.rgbMode == rgbFlag
2921832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && v->mesa_visual.doubleBufferMode == dbFlag
2931832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && v->mesa_visual.stereoMode == stereoFlag
2941832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && (v->mesa_visual.alphaBits > 0) == alphaFlag
2951832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && (v->mesa_visual.depthBits >= depth_size || depth_size == 0)
2961832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && (v->mesa_visual.stencilBits >= stencil_size || stencil_size == 0)
2971832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && (v->mesa_visual.accumRedBits >= accumRedSize || accumRedSize == 0)
2981832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && (v->mesa_visual.accumGreenBits >= accumGreenSize || accumGreenSize == 0)
2991832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && (v->mesa_visual.accumBlueBits >= accumBlueSize || accumBlueSize == 0)
3001832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && (v->mesa_visual.accumAlphaBits >= accumAlphaSize || accumAlphaSize == 0)) {
301afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* now either compare XVisualInfo pointers or visual IDs */
302d0247f53aea8fa8677aadc8a00f75c8993be9ebcBrian Paul         if ((!comparePointers && v->visinfo->visualid == vinfo->visualid)
303afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg             || (comparePointers && v->vishandle == vinfo)) {
304afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            return v;
305afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
306afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
307afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
308afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
309afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* Create a new visual and add it to the list. */
310afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
311afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (NumVisuals>=MAX_VISUALS) {
312afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      fprintf( stderr, "GLX Error: maximum number of visuals exceeded\n");
313afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return NULL;
314afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
315afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
316c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul   xmvis = XMesaCreateVisual( dpy, vinfo, rgbFlag, alphaFlag, dbFlag,
317c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul                              stereoFlag, ximageFlag,
318c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul                              depth_size, stencil_size,
319c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul                              accumRedSize, accumBlueSize,
320c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul                              accumBlueSize, accumAlphaSize, 0, level,
321c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul                              GLX_NONE_EXT );
322afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (xmvis) {
323afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      VisualTable[NumVisuals] = xmvis;
324afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      NumVisuals++;
325afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
326afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return xmvis;
327afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
328afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
329afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
330afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
331afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
332afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Create a GLX visual from a regular XVisualInfo.
333ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * This is called when Fake GLX is given an XVisualInfo which wasn't
334ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * returned by glXChooseVisual.  Since this is the first time we're
335ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * considering this visual we'll take a guess at reasonable values
336ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * for depth buffer size, stencil size, accum size, etc.
337ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * This is the best we can do with a client-side emulation of GLX.
338afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
339afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XMesaVisual
340afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgcreate_glx_visual( Display *dpy, XVisualInfo *visinfo )
341afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
342afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int vislevel;
343afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
344afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   vislevel = level_of_visual( dpy, visinfo );
345afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (vislevel) {
346afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* Configure this visual as a CI, single-buffered overlay */
347afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return save_glx_visual( dpy, visinfo,
348afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                              GL_FALSE,  /* rgb */
349afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                              GL_FALSE,  /* alpha */
350afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                              GL_FALSE,  /* double */
351afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                              GL_FALSE,  /* stereo */
352afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                              0,         /* depth bits */
353afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                              0,         /* stencil bits */
354b2e460018375f699198073a6167e0ee96ba1d267Brian Paul                              0,0,0,0,   /* accum bits */
355afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                              vislevel   /* level */
356afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                            );
357afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
358afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else if (is_usable_visual( visinfo )) {
3598f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul      if (getenv("MESA_GLX_FORCE_CI")) {
3608f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul         /* Configure this visual as a COLOR INDEX visual. */
3618f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul         return save_glx_visual( dpy, visinfo,
3628f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 GL_FALSE,   /* rgb */
3638f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 GL_FALSE,  /* alpha */
3648f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 GL_TRUE,   /* double */
3658f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 GL_FALSE,  /* stereo */
3668f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 DEFAULT_SOFTWARE_DEPTH_BITS,
3678f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 8 * sizeof(GLstencil),
3688f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 0 * sizeof(GLaccum), /* r */
3698f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 0 * sizeof(GLaccum), /* g */
3708f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 0 * sizeof(GLaccum), /* b */
3718f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 0 * sizeof(GLaccum), /* a */
3728f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 0          /* level */
3738f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                               );
3748f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul      }
3758f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul      else {
3768f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul         /* Configure this visual as RGB, double-buffered, depth-buffered. */
3778f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul         /* This is surely wrong for some people's needs but what else */
3788f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul         /* can be done?  They should use glXChooseVisual(). */
3798f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul         return save_glx_visual( dpy, visinfo,
3808f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 GL_TRUE,   /* rgb */
3818f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 GL_FALSE,  /* alpha */
3828f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 GL_TRUE,   /* double */
3838f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 GL_FALSE,  /* stereo */
3848f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 DEFAULT_SOFTWARE_DEPTH_BITS,
3858f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 8 * sizeof(GLstencil),
3868f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 8 * sizeof(GLaccum), /* r */
3878f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 8 * sizeof(GLaccum), /* g */
3888f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 8 * sizeof(GLaccum), /* b */
3898f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 8 * sizeof(GLaccum), /* a */
3908f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 0          /* level */
3918f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                               );
3928f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul      }
393afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
394afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else {
395afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      fprintf(stderr,"Mesa: error in glXCreateContext: bad visual\n");
396afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return NULL;
397afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
398afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
399afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
400afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
401afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
402afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
403afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Find the GLX visual associated with an XVisualInfo.
404afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
405afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XMesaVisual
406afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgfind_glx_visual( Display *dpy, XVisualInfo *vinfo )
407afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
408afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int i;
409afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
410afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* First try to match pointers */
411afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   for (i=0;i<NumVisuals;i++) {
412afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (VisualTable[i]->display==dpy && VisualTable[i]->vishandle==vinfo) {
413afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return VisualTable[i];
414afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
415afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
416afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* try to match visual id */
417afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   for (i=0;i<NumVisuals;i++) {
418afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (VisualTable[i]->display==dpy
419afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg          && VisualTable[i]->visinfo->visualid == vinfo->visualid) {
420afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return VisualTable[i];
421afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
422afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
423afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return NULL;
424afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
425afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
426afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
427afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
428afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
429afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return the transparent pixel value for a GLX visual.
430afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input:  glxvis - the glx_visual
431afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return:  a pixel value or -1 if no transparent pixel
432afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
433afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic int transparent_pixel( XMesaVisual glxvis )
434afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
435afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   Display *dpy = glxvis->display;
436afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XVisualInfo *vinfo = glxvis->visinfo;
437afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   Atom overlayVisualsAtom;
438afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   OverlayInfo *overlay_info = NULL;
439afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int numOverlaysPerScreen;
440afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   Status status;
441afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   Atom actualType;
442afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int actualFormat;
443afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   unsigned long sizeData, bytesLeft;
444afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int i;
445afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
446afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /*
447afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * The SERVER_OVERLAY_VISUALS property on the root window contains
448afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * a list of overlay visuals.  Get that list now.
449afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    */
450afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   overlayVisualsAtom = XInternAtom(dpy,"SERVER_OVERLAY_VISUALS", True);
451afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (overlayVisualsAtom == None) {
452afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return -1;
453afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
454afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
455afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   status = XGetWindowProperty(dpy, RootWindow( dpy, vinfo->screen ),
456afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               overlayVisualsAtom, 0L, (long) 10000, False,
457afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               overlayVisualsAtom, &actualType, &actualFormat,
458afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               &sizeData, &bytesLeft,
459afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               (unsigned char **) &overlay_info );
460afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
461afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (status != Success || actualType != overlayVisualsAtom ||
462afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg       actualFormat != 32 || sizeData < 4) {
463afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* something went wrong */
464afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      XFree((void *) overlay_info);
465afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return -1;
466afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
467afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
468afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* search the overlay visual list for the visual ID of interest */
469afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   numOverlaysPerScreen = (int) (sizeData / 4);
470afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   for (i=0;i<numOverlaysPerScreen;i++) {
471afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      OverlayInfo *ov;
472afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      ov = overlay_info + i;
473afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (ov->overlay_visual==vinfo->visualid) {
474afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* found it! */
475afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         if (ov->transparent_type==0) {
476afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* type 0 indicates no transparency */
477afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            XFree((void *) overlay_info);
478afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            return -1;
479afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
480afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         else {
481afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* ov->value is the transparent pixel */
482afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            XFree((void *) overlay_info);
483afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            return ov->value;
484afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
485afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
486afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
487afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
488afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* The visual ID was not found in the overlay list. */
489afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XFree((void *) overlay_info);
490afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return -1;
491afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
492afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
493afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
494afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
495afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
496afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Try to get an X visual which matches the given arguments.
497afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
498afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XVisualInfo *get_visual( Display *dpy, int scr,
499afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg			        unsigned int depth, int xclass )
500afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
501afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XVisualInfo temp, *vis;
502afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   long mask;
503afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int n;
504afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   unsigned int default_depth;
505afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int default_class;
506afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
507afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   mask = VisualScreenMask | VisualDepthMask | VisualClassMask;
508afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   temp.screen = scr;
509afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   temp.depth = depth;
510afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   temp.CLASS = xclass;
511afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
512afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   default_depth = DefaultDepth(dpy,scr);
513afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   default_class = DefaultVisual(dpy,scr)->CLASS;
514afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
515afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (depth==default_depth && xclass==default_class) {
516afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* try to get root window's visual */
517afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      temp.visualid = DefaultVisual(dpy,scr)->visualid;
518afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      mask |= VisualIDMask;
519afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
520afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
521afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   vis = XGetVisualInfo( dpy, mask, &temp, &n );
522afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
523afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* In case bits/pixel > 24, make sure color channels are still <=8 bits.
524afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * An SGI Infinite Reality system, for example, can have 30bpp pixels:
525afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * 10 bits per color channel.  Mesa's limited to a max of 8 bits/channel.
526afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    */
527afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (vis && depth > 24 && (xclass==TrueColor || xclass==DirectColor)) {
52871dea349d2be623b7819389428b0d6a124e8d184Brian Paul      if (_mesa_bitcount((GLuint) vis->red_mask  ) <= 8 &&
52971dea349d2be623b7819389428b0d6a124e8d184Brian Paul          _mesa_bitcount((GLuint) vis->green_mask) <= 8 &&
53071dea349d2be623b7819389428b0d6a124e8d184Brian Paul          _mesa_bitcount((GLuint) vis->blue_mask ) <= 8) {
531afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return vis;
532afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
533afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      else {
534afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         XFree((void *) vis);
535afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return NULL;
536afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
537afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
538afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
539afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return vis;
540afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
541afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
542afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
543afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
544afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
545afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Retrieve the value of the given environment variable and find
546afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * the X visual which matches it.
547afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input:  dpy - the display
548afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         screen - the screen number
549afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         varname - the name of the environment variable
550afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return:  an XVisualInfo pointer to NULL if error.
551afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
552afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XVisualInfo *get_env_visual(Display *dpy, int scr, const char *varname)
553afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
554afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   char value[100], type[100];
555afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int depth, xclass = -1;
556afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XVisualInfo *vis;
557afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
558afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (!getenv( varname )) {
559afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return NULL;
560afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
561afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
562afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   strncpy( value, getenv(varname), 100 );
563afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   value[99] = 0;
564afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
565afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   sscanf( value, "%s %d", type, &depth );
566afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
567afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (strcmp(type,"TrueColor")==0)          xclass = TrueColor;
568afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else if (strcmp(type,"DirectColor")==0)   xclass = DirectColor;
569afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else if (strcmp(type,"PseudoColor")==0)   xclass = PseudoColor;
570afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else if (strcmp(type,"StaticColor")==0)   xclass = StaticColor;
571afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else if (strcmp(type,"GrayScale")==0)     xclass = GrayScale;
572afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else if (strcmp(type,"StaticGray")==0)    xclass = StaticGray;
573afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
574afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (xclass>-1 && depth>0) {
575afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      vis = get_visual( dpy, scr, depth, xclass );
576afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (vis) {
577afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return vis;
578afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
579afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
580afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
581afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   fprintf( stderr, "Mesa: GLX unable to find visual class=%s, depth=%d.\n",
582afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    type, depth );
583afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return NULL;
584afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
585afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
586afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
587afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
588afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
589afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Select an X visual which satisfies the RGBA/CI flag and minimum depth.
590afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input:  dpy, screen - X display and screen number
591afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         rgba - GL_TRUE = RGBA mode, GL_FALSE = CI mode
592afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         min_depth - minimum visual depth
593afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         preferred_class - preferred GLX visual class or DONT_CARE
594afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return:  pointer to an XVisualInfo or NULL.
595afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
596afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XVisualInfo *choose_x_visual( Display *dpy, int screen,
597afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg				     GLboolean rgba, int min_depth,
598afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                                     int preferred_class )
599afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
600afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XVisualInfo *vis;
601db6aa58267cad3f502f03ab80b9deb6b75320a91Brian Paul   int xclass, visclass = 0;
602afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int depth;
603afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
604afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (rgba) {
605afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      Atom hp_cr_maps = XInternAtom(dpy, "_HP_RGB_SMOOTH_MAP_LIST", True);
606afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* First see if the MESA_RGB_VISUAL env var is defined */
607afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      vis = get_env_visual( dpy, screen, "MESA_RGB_VISUAL" );
608afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (vis) {
609afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return vis;
610afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
611afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* Otherwise, search for a suitable visual */
612afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (preferred_class==DONT_CARE) {
613afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         for (xclass=0;xclass<6;xclass++) {
614afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            switch (xclass) {
615afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 0:  visclass = TrueColor;    break;
616afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 1:  visclass = DirectColor;  break;
617afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 2:  visclass = PseudoColor;  break;
618afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 3:  visclass = StaticColor;  break;
619afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 4:  visclass = GrayScale;    break;
620afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 5:  visclass = StaticGray;   break;
621afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
622afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            if (min_depth==0) {
623afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               /* start with shallowest */
624afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               for (depth=0;depth<=32;depth++) {
625afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  if (visclass==TrueColor && depth==8 && !hp_cr_maps) {
626afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     /* Special case:  try to get 8-bit PseudoColor before */
627afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     /* 8-bit TrueColor */
628afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     vis = get_visual( dpy, screen, 8, PseudoColor );
629afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     if (vis) {
630afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                        return vis;
631afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     }
632afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  }
633afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  vis = get_visual( dpy, screen, depth, visclass );
634afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  if (vis) {
635afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     return vis;
636afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  }
637afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               }
638afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
639afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            else {
640afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               /* start with deepest */
641afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               for (depth=32;depth>=min_depth;depth--) {
642afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  if (visclass==TrueColor && depth==8 && !hp_cr_maps) {
643afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     /* Special case:  try to get 8-bit PseudoColor before */
644afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     /* 8-bit TrueColor */
645afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     vis = get_visual( dpy, screen, 8, PseudoColor );
646afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     if (vis) {
647afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                        return vis;
648afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     }
649afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  }
650afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  vis = get_visual( dpy, screen, depth, visclass );
651afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  if (vis) {
652afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     return vis;
653afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  }
654afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               }
655afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
656afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
657afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
658afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      else {
659afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* search for a specific visual class */
660afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         switch (preferred_class) {
661afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_TRUE_COLOR_EXT:    visclass = TrueColor;    break;
662afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_DIRECT_COLOR_EXT:  visclass = DirectColor;  break;
663afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_PSEUDO_COLOR_EXT:  visclass = PseudoColor;  break;
664afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_STATIC_COLOR_EXT:  visclass = StaticColor;  break;
665afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_GRAY_SCALE_EXT:    visclass = GrayScale;    break;
666afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_STATIC_GRAY_EXT:   visclass = StaticGray;   break;
667afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            default:   return NULL;
668afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
669afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         if (min_depth==0) {
670afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* start with shallowest */
671afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            for (depth=0;depth<=32;depth++) {
672afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               vis = get_visual( dpy, screen, depth, visclass );
673afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               if (vis) {
674afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  return vis;
675afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               }
676afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
677afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
678afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         else {
679afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* start with deepest */
680afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            for (depth=32;depth>=min_depth;depth--) {
681afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               vis = get_visual( dpy, screen, depth, visclass );
682afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               if (vis) {
683afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  return vis;
684afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               }
685afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
686afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
687afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
688afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
689afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else {
690afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* First see if the MESA_CI_VISUAL env var is defined */
691afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      vis = get_env_visual( dpy, screen, "MESA_CI_VISUAL" );
692afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (vis) {
693afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return vis;
694afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
695afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* Otherwise, search for a suitable visual, starting with shallowest */
696afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (preferred_class==DONT_CARE) {
697afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         for (xclass=0;xclass<4;xclass++) {
698afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            switch (xclass) {
699afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 0:  visclass = PseudoColor;  break;
700afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 1:  visclass = StaticColor;  break;
701afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 2:  visclass = GrayScale;    break;
702afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 3:  visclass = StaticGray;   break;
703afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
704afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* try 8-bit up through 16-bit */
705afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            for (depth=8;depth<=16;depth++) {
706afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               vis = get_visual( dpy, screen, depth, visclass );
707afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               if (vis) {
708afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  return vis;
709afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               }
710afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
711afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* try min_depth up to 8-bit */
712afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            for (depth=min_depth;depth<8;depth++) {
713afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               vis = get_visual( dpy, screen, depth, visclass );
714afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               if (vis) {
715afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  return vis;
716afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               }
717afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
718afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
719afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
720afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      else {
721afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* search for a specific visual class */
722afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         switch (preferred_class) {
723afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_TRUE_COLOR_EXT:    visclass = TrueColor;    break;
724afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_DIRECT_COLOR_EXT:  visclass = DirectColor;  break;
725afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_PSEUDO_COLOR_EXT:  visclass = PseudoColor;  break;
726afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_STATIC_COLOR_EXT:  visclass = StaticColor;  break;
727afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_GRAY_SCALE_EXT:    visclass = GrayScale;    break;
728afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_STATIC_GRAY_EXT:   visclass = StaticGray;   break;
729afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            default:   return NULL;
730afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
731afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* try 8-bit up through 16-bit */
732afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         for (depth=8;depth<=16;depth++) {
733afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            vis = get_visual( dpy, screen, depth, visclass );
734afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            if (vis) {
735afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               return vis;
736afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
737afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
738afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* try min_depth up to 8-bit */
739afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         for (depth=min_depth;depth<8;depth++) {
740afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            vis = get_visual( dpy, screen, depth, visclass );
741afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            if (vis) {
742afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               return vis;
743afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
744afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
745afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
746afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
747afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
748afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* didn't find a visual */
749afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return NULL;
750afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
751afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
752afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
753afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
754afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
755afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Find the deepest X over/underlay visual of at least min_depth.
756afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input:  dpy, screen - X display and screen number
757afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         level - the over/underlay level
758afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         trans_type - transparent pixel type: GLX_NONE_EXT,
759afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *                      GLX_TRANSPARENT_RGB_EXT, GLX_TRANSPARENT_INDEX_EXT,
760afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *                      or DONT_CARE
761afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         trans_value - transparent pixel value or DONT_CARE
762afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         min_depth - minimum visual depth
763afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         preferred_class - preferred GLX visual class or DONT_CARE
764afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return:  pointer to an XVisualInfo or NULL.
765afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
766afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XVisualInfo *choose_x_overlay_visual( Display *dpy, int scr,
76742f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul                                             GLboolean rgbFlag,
768afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                                             int level, int trans_type,
769afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                                             int trans_value,
770afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                                             int min_depth,
771afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                                             int preferred_class )
772afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
773afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   Atom overlayVisualsAtom;
774afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   OverlayInfo *overlay_info;
775afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int numOverlaysPerScreen;
776afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   Status status;
777afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   Atom actualType;
778afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int actualFormat;
779afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   unsigned long sizeData, bytesLeft;
780afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int i;
781afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XVisualInfo *deepvis;
782afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int deepest;
783afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
784afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /*DEBUG int tt, tv; */
785afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
786afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   switch (preferred_class) {
787afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_TRUE_COLOR_EXT:    preferred_class = TrueColor;    break;
788afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_DIRECT_COLOR_EXT:  preferred_class = DirectColor;  break;
789afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_PSEUDO_COLOR_EXT:  preferred_class = PseudoColor;  break;
790afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_STATIC_COLOR_EXT:  preferred_class = StaticColor;  break;
791afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_GRAY_SCALE_EXT:    preferred_class = GrayScale;    break;
792afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_STATIC_GRAY_EXT:   preferred_class = StaticGray;   break;
793afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      default:                    preferred_class = DONT_CARE;
794afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
795afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
796afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /*
797afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * The SERVER_OVERLAY_VISUALS property on the root window contains
798afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * a list of overlay visuals.  Get that list now.
799afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    */
800afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   overlayVisualsAtom = XInternAtom(dpy,"SERVER_OVERLAY_VISUALS", True);
801afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (overlayVisualsAtom == (Atom) None) {
802afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return NULL;
803afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
804afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
805afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   status = XGetWindowProperty(dpy, RootWindow( dpy, scr ),
806afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               overlayVisualsAtom, 0L, (long) 10000, False,
807afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               overlayVisualsAtom, &actualType, &actualFormat,
808afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               &sizeData, &bytesLeft,
809afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               (unsigned char **) &overlay_info );
810afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
811afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (status != Success || actualType != overlayVisualsAtom ||
812afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg       actualFormat != 32 || sizeData < 4) {
813afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* something went wrong */
814afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return NULL;
815afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
816afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
817afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* Search for the deepest overlay which satisifies all criteria. */
818afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   deepest = min_depth;
819afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   deepvis = NULL;
820afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
821afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   numOverlaysPerScreen = (int) (sizeData / 4);
822afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   for (i=0;i<numOverlaysPerScreen;i++) {
823afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      XVisualInfo *vislist, vistemplate;
824afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      int count;
825afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      OverlayInfo *ov;
826afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      ov = overlay_info + i;
827afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
828afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (ov->layer!=level) {
829afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* failed overlay level criteria */
830afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         continue;
831afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
832afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (!(trans_type==DONT_CARE
833afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            || (trans_type==GLX_TRANSPARENT_INDEX_EXT
834afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                && ov->transparent_type>0)
835afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            || (trans_type==GLX_NONE_EXT && ov->transparent_type==0))) {
836afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* failed transparent pixel type criteria */
837afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         continue;
838afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
839afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (trans_value!=DONT_CARE && trans_value!=ov->value) {
840afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* failed transparent pixel value criteria */
841afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         continue;
842afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
843afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
844afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* get XVisualInfo and check the depth */
845afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      vistemplate.visualid = ov->overlay_visual;
846afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      vistemplate.screen = scr;
847afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      vislist = XGetVisualInfo( dpy, VisualIDMask | VisualScreenMask,
848afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                                &vistemplate, &count );
849afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
850afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (count!=1) {
851afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* something went wrong */
852afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         continue;
853afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
854afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (preferred_class!=DONT_CARE && preferred_class!=vislist->CLASS) {
855afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* wrong visual class */
856afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         continue;
857afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
858afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
85942f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      /* if RGB was requested, make sure we have True/DirectColor */
86042f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      if (rgbFlag && vislist->CLASS != TrueColor
86142f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul          && vislist->CLASS != DirectColor)
86242f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         continue;
86342f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul
86442f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      /* if CI was requested, make sure we have a color indexed visual */
86542f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      if (!rgbFlag
86642f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul          && (vislist->CLASS == TrueColor || vislist->CLASS == DirectColor))
86742f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         continue;
86842f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul
869afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (deepvis==NULL || vislist->depth > deepest) {
870afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* YES!  found a satisfactory visual */
871afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         if (deepvis) {
87280af3614d88c0cac160e787de7f34b37e96cb626Brian Paul            XFree( deepvis );
873afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
874afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         deepest = vislist->depth;
875afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         deepvis = vislist;
876afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* DEBUG  tt = ov->transparent_type;*/
877afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* DEBUG  tv = ov->value; */
878afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
879afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
880afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
881afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*DEBUG
882afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (deepvis) {
883afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      printf("chose 0x%x:  layer=%d depth=%d trans_type=%d trans_value=%d\n",
884afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg             deepvis->visualid, level, deepvis->depth, tt, tv );
885afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
886afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg*/
887afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return deepvis;
888afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
889afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
890afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
8917cf50e137da497a590ec9001a9918972a6246142Brian Paul/**********************************************************************/
8927cf50e137da497a590ec9001a9918972a6246142Brian Paul/***                  Begin Fake GLX API Functions                  ***/
8937cf50e137da497a590ec9001a9918972a6246142Brian Paul/**********************************************************************/
8947cf50e137da497a590ec9001a9918972a6246142Brian Paul
895afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
896426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic XVisualInfo *
897426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXChooseVisual( Display *dpy, int screen, int *list )
898afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
899afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int *parselist;
900afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XVisualInfo *vis;
901afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int min_ci = 0;
902afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int min_red=0, min_green=0, min_blue=0;
903afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLboolean rgb_flag = GL_FALSE;
904afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLboolean alpha_flag = GL_FALSE;
905afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLboolean double_flag = GL_FALSE;
906afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLboolean stereo_flag = GL_FALSE;
907afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLint depth_size = 0;
908afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLint stencil_size = 0;
909b2e460018375f699198073a6167e0ee96ba1d267Brian Paul   GLint accumRedSize = 0;
910b2e460018375f699198073a6167e0ee96ba1d267Brian Paul   GLint accumGreenSize = 0;
911b2e460018375f699198073a6167e0ee96ba1d267Brian Paul   GLint accumBlueSize = 0;
912b2e460018375f699198073a6167e0ee96ba1d267Brian Paul   GLint accumAlphaSize = 0;
913afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int level = 0;
914afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int visual_type = DONT_CARE;
915afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int trans_type = DONT_CARE;
916afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int trans_value = DONT_CARE;
917e1210b176926349b258c7ec77b7f36716025c82aBrian Paul   GLint caveat = DONT_CARE;
918afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
919afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   parselist = list;
920afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
921afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   while (*parselist) {
922afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
923afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      switch (*parselist) {
924afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_USE_GL:
925afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    /* ignore */
926afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
927afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
928afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_BUFFER_SIZE:
929afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
930afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    min_ci = *parselist++;
931afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
932afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_LEVEL:
933afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
934afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            level = *parselist++;
935afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
936afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_RGBA:
937afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    rgb_flag = GL_TRUE;
938afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
939afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
940afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_DOUBLEBUFFER:
941afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    double_flag = GL_TRUE;
942afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
943afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
944afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_STEREO:
945afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            stereo_flag = GL_TRUE;
946afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            return NULL;
947afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_AUX_BUFFERS:
948afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    /* ignore */
949afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
950afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
951afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
952afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_RED_SIZE:
953afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
954afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    min_red = *parselist++;
955afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
956afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_GREEN_SIZE:
957afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
958afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    min_green = *parselist++;
959afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
960afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_BLUE_SIZE:
961afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
962afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    min_blue = *parselist++;
963afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
964afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_ALPHA_SIZE:
965afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
966afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            {
967afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               GLint size = *parselist++;
968afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               alpha_flag = size>0 ? 1 : 0;
969afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
970afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
971afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_DEPTH_SIZE:
972afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
973afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    depth_size = *parselist++;
974afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
975afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_STENCIL_SIZE:
976afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
977afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    stencil_size = *parselist++;
978afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
979afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_ACCUM_RED_SIZE:
980b2e460018375f699198073a6167e0ee96ba1d267Brian Paul	    parselist++;
981b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            {
982b2e460018375f699198073a6167e0ee96ba1d267Brian Paul               GLint size = *parselist++;
983b2e460018375f699198073a6167e0ee96ba1d267Brian Paul               accumRedSize = MAX2( accumRedSize, size );
984b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            }
985b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            break;
986afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_ACCUM_GREEN_SIZE:
987b2e460018375f699198073a6167e0ee96ba1d267Brian Paul	    parselist++;
988b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            {
989b2e460018375f699198073a6167e0ee96ba1d267Brian Paul               GLint size = *parselist++;
990b2e460018375f699198073a6167e0ee96ba1d267Brian Paul               accumGreenSize = MAX2( accumGreenSize, size );
991b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            }
992b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            break;
993afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_ACCUM_BLUE_SIZE:
994b2e460018375f699198073a6167e0ee96ba1d267Brian Paul	    parselist++;
995b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            {
996b2e460018375f699198073a6167e0ee96ba1d267Brian Paul               GLint size = *parselist++;
997b2e460018375f699198073a6167e0ee96ba1d267Brian Paul               accumBlueSize = MAX2( accumBlueSize, size );
998b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            }
999b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            break;
1000afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_ACCUM_ALPHA_SIZE:
1001afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
1002afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            {
1003afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               GLint size = *parselist++;
1004b2e460018375f699198073a6167e0ee96ba1d267Brian Paul               accumAlphaSize = MAX2( accumAlphaSize, size );
1005afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
1006afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
1007afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1008afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /*
1009afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg          * GLX_EXT_visual_info extension
1010afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg          */
1011afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         case GLX_X_VISUAL_TYPE_EXT:
1012afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            parselist++;
1013afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            visual_type = *parselist++;
1014afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            break;
1015afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         case GLX_TRANSPARENT_TYPE_EXT:
1016afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            parselist++;
1017afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            trans_type = *parselist++;
1018afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            break;
1019afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         case GLX_TRANSPARENT_INDEX_VALUE_EXT:
1020afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            parselist++;
1021afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            trans_value = *parselist++;
1022afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            break;
1023afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         case GLX_TRANSPARENT_RED_VALUE_EXT:
1024afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         case GLX_TRANSPARENT_GREEN_VALUE_EXT:
1025afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         case GLX_TRANSPARENT_BLUE_VALUE_EXT:
1026afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         case GLX_TRANSPARENT_ALPHA_VALUE_EXT:
1027afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    /* ignore */
1028afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
1029afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
1030afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
10315e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen
1032e1210b176926349b258c7ec77b7f36716025c82aBrian Paul         /*
1033e1210b176926349b258c7ec77b7f36716025c82aBrian Paul          * GLX_EXT_visual_info extension
1034e1210b176926349b258c7ec77b7f36716025c82aBrian Paul          */
1035e1210b176926349b258c7ec77b7f36716025c82aBrian Paul         case GLX_VISUAL_CAVEAT_EXT:
1036e1210b176926349b258c7ec77b7f36716025c82aBrian Paul            parselist++;
1037e1210b176926349b258c7ec77b7f36716025c82aBrian Paul            caveat = *parselist++; /* ignored for now */
1038e1210b176926349b258c7ec77b7f36716025c82aBrian Paul            break;
1039e1210b176926349b258c7ec77b7f36716025c82aBrian Paul
1040afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case None:
1041afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
1042afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 default:
1043afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    /* undefined attribute */
1044afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    return NULL;
1045afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
1046afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1047afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1048afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /*
1049afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * Since we're only simulating the GLX extension this function will never
1050afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * find any real GL visuals.  Instead, all we can do is try to find an RGB
1051afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * or CI visual of appropriate depth.  Other requested attributes such as
1052afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * double buffering, depth buffer, etc. will be associated with the X
1053afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * visual and stored in the VisualTable[].
1054afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    */
1055afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (level==0) {
1056afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* normal color planes */
1057afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (rgb_flag) {
1058afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* Get an RGB visual */
1059afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         int min_rgb = min_red + min_green + min_blue;
1060afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         if (min_rgb>1 && min_rgb<8) {
1061afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* a special case to be sure we can get a monochrome visual */
1062afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            min_rgb = 1;
1063afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
1064afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         vis = choose_x_visual( dpy, screen, rgb_flag, min_rgb, visual_type );
1065afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
1066afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      else {
1067afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* Get a color index visual */
1068afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         vis = choose_x_visual( dpy, screen, rgb_flag, min_ci, visual_type );
1069b2e460018375f699198073a6167e0ee96ba1d267Brian Paul         accumRedSize = accumGreenSize = accumBlueSize = accumAlphaSize = 0;
1070afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
1071afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1072afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else {
1073afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* over/underlay planes */
107442f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      if (rgb_flag) {
107542f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         /* rgba overlay */
107642f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         int min_rgb = min_red + min_green + min_blue;
107742f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         if (min_rgb>1 && min_rgb<8) {
107842f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul            /* a special case to be sure we can get a monochrome visual */
107942f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul            min_rgb = 1;
108042f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         }
108142f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         vis = choose_x_overlay_visual( dpy, screen, rgb_flag, level,
108242f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul                              trans_type, trans_value, min_rgb, visual_type );
108342f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      }
108442f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      else {
108542f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         /* color index overlay */
108642f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         vis = choose_x_overlay_visual( dpy, screen, rgb_flag, level,
108742f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul                              trans_type, trans_value, min_ci, visual_type );
108842f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      }
1089afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1090afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1091afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (vis) {
1092ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul      /* Note: we're not exactly obeying the glXChooseVisual rules here.
1093ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul       * When GLX_DEPTH_SIZE = 1 is specified we're supposed to choose the
10942c7e6334ec81c2fab2cce9e0fe52cd30256e37eaBrian Paul       * largest depth buffer size, which is 32bits/value.  Instead, we
1095ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul       * return 16 to maintain performance with earlier versions of Mesa.
1096ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul       */
10972c7e6334ec81c2fab2cce9e0fe52cd30256e37eaBrian Paul      if (depth_size > 24)
10982c7e6334ec81c2fab2cce9e0fe52cd30256e37eaBrian Paul         depth_size = 31;   /* 32 causes int overflow problems */
1099ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul      else if (depth_size > 16)
1100ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul         depth_size = 24;
11012c7e6334ec81c2fab2cce9e0fe52cd30256e37eaBrian Paul      else if (depth_size > 0)
11022c7e6334ec81c2fab2cce9e0fe52cd30256e37eaBrian Paul         depth_size = DEFAULT_SOFTWARE_DEPTH_BITS; /*16*/
11032c7e6334ec81c2fab2cce9e0fe52cd30256e37eaBrian Paul
1104ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul      /* we only support one size of stencil and accum buffers. */
1105ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul      if (stencil_size > 0)
1106ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul         stencil_size = STENCIL_BITS;
11076d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul      if (accumRedSize > 0 || accumGreenSize > 0 || accumBlueSize > 0 ||
11086d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul          accumAlphaSize > 0) {
1109b2e460018375f699198073a6167e0ee96ba1d267Brian Paul         accumRedSize = ACCUM_BITS;
1110b2e460018375f699198073a6167e0ee96ba1d267Brian Paul         accumGreenSize = ACCUM_BITS;
1111b2e460018375f699198073a6167e0ee96ba1d267Brian Paul         accumBlueSize = ACCUM_BITS;
11126d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul         accumAlphaSize = alpha_flag ? ACCUM_BITS : 0;
11136d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul      }
11146d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul
1115afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (!save_glx_visual( dpy, vis, rgb_flag, alpha_flag, double_flag,
1116b2e460018375f699198073a6167e0ee96ba1d267Brian Paul                            stereo_flag, depth_size, stencil_size,
1117b2e460018375f699198073a6167e0ee96ba1d267Brian Paul                            accumRedSize, accumGreenSize,
1118b2e460018375f699198073a6167e0ee96ba1d267Brian Paul                            accumBlueSize, accumAlphaSize,
1119b2e460018375f699198073a6167e0ee96ba1d267Brian Paul                            level ))
1120afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return NULL;
1121afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1122afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1123afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return vis;
1124afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1125afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1126afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1127afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1128afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1129426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXContext
1130426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateContext( Display *dpy, XVisualInfo *visinfo,
1131426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                       GLXContext share_list, Bool direct )
1132afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1133afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaVisual glxvis;
11347cf50e137da497a590ec9001a9918972a6246142Brian Paul   struct fake_glx_context *glxCtx;
11355e1680ce1d8296b2182e8909856927bbeddf3b95Brian Paul   struct fake_glx_context *shareCtx = (struct fake_glx_context *) share_list;
113699aab341998e84d9fa208c525cae8021b3845812Brian Paul
113799aab341998e84d9fa208c525cae8021b3845812Brian Paul   if (!dpy || !visinfo)
113899aab341998e84d9fa208c525cae8021b3845812Brian Paul      return 0;
113999aab341998e84d9fa208c525cae8021b3845812Brian Paul
11407cf50e137da497a590ec9001a9918972a6246142Brian Paul   glxCtx = CALLOC_STRUCT(fake_glx_context);
11417cf50e137da497a590ec9001a9918972a6246142Brian Paul   if (!glxCtx)
11427cf50e137da497a590ec9001a9918972a6246142Brian Paul      return 0;
1143afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1144afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* deallocate unused windows/buffers */
1145afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaGarbageCollect();
1146afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1147afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   glxvis = find_glx_visual( dpy, visinfo );
1148afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (!glxvis) {
1149afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* This visual wasn't found with glXChooseVisual() */
1150afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      glxvis = create_glx_visual( dpy, visinfo );
1151afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (!glxvis) {
1152afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* unusable visual */
11537cf50e137da497a590ec9001a9918972a6246142Brian Paul         FREE(glxCtx);
1154afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return NULL;
1155afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
1156afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1157afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
11587cf50e137da497a590ec9001a9918972a6246142Brian Paul   glxCtx->xmesaContext = XMesaCreateContext(glxvis,
11595e1680ce1d8296b2182e8909856927bbeddf3b95Brian Paul                                   shareCtx ? shareCtx->xmesaContext : NULL);
11607cf50e137da497a590ec9001a9918972a6246142Brian Paul   if (!glxCtx->xmesaContext) {
11617cf50e137da497a590ec9001a9918972a6246142Brian Paul      FREE(glxCtx);
11627cf50e137da497a590ec9001a9918972a6246142Brian Paul      return NULL;
1163afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
11647cf50e137da497a590ec9001a9918972a6246142Brian Paul
11657cf50e137da497a590ec9001a9918972a6246142Brian Paul   glxCtx->xmesaContext->direct = GL_FALSE;
11667cf50e137da497a590ec9001a9918972a6246142Brian Paul   glxCtx->glxContext.isDirect = GL_FALSE;
11677cf50e137da497a590ec9001a9918972a6246142Brian Paul   glxCtx->glxContext.currentDpy = dpy;
11687cf50e137da497a590ec9001a9918972a6246142Brian Paul   glxCtx->glxContext.xid = (XID) glxCtx;  /* self pointer */
11697cf50e137da497a590ec9001a9918972a6246142Brian Paul
11707cf50e137da497a590ec9001a9918972a6246142Brian Paul   assert((void *) glxCtx == (void *) &(glxCtx->glxContext));
11717cf50e137da497a590ec9001a9918972a6246142Brian Paul
11727cf50e137da497a590ec9001a9918972a6246142Brian Paul   return (GLXContext) glxCtx;
1173afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1174afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1175afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
11767cf50e137da497a590ec9001a9918972a6246142Brian Paul/* XXX these may have to be removed due to thread-safety issues. */
1177afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic GLXContext MakeCurrent_PrevContext = 0;
1178086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic GLXDrawable MakeCurrent_PrevDrawable = 0;
1179086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic GLXDrawable MakeCurrent_PrevReadable = 0;
1180086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic XMesaBuffer MakeCurrent_PrevDrawBuffer = 0;
1181086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic XMesaBuffer MakeCurrent_PrevReadBuffer = 0;
1182afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
11837cf50e137da497a590ec9001a9918972a6246142Brian Paul
1184086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul/* GLX 1.3 and later */
1185426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool
1186426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXMakeContextCurrent( Display *dpy, GLXDrawable draw,
11877a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell                            GLXDrawable read, GLXContext ctx )
1188086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul{
11897cf50e137da497a590ec9001a9918972a6246142Brian Paul   struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx;
11907cf50e137da497a590ec9001a9918972a6246142Brian Paul
11917a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell   if (ctx && draw && read) {
1192086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      XMesaBuffer drawBuffer, readBuffer;
11937cf50e137da497a590ec9001a9918972a6246142Brian Paul      XMesaContext xmctx = glxCtx->xmesaContext;
1194086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul
1195086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      /* Find the XMesaBuffer which corresponds to the GLXDrawable 'draw' */
11967a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell      if (ctx == MakeCurrent_PrevContext
11977a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell          && draw == MakeCurrent_PrevDrawable) {
1198086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         drawBuffer = MakeCurrent_PrevDrawBuffer;
1199086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      }
1200086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      else {
1201086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         drawBuffer = XMesaFindBuffer( dpy, draw );
1202086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      }
1203086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      if (!drawBuffer) {
1204086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         /* drawable must be a new window! */
12057cf50e137da497a590ec9001a9918972a6246142Brian Paul         drawBuffer = XMesaCreateWindowBuffer2( xmctx->xm_visual, draw, xmctx);
1206086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         if (!drawBuffer) {
1207086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul            /* Out of memory, or context/drawable depth mismatch */
1208086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul            return False;
1209086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         }
1210086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      }
1211086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul
1212086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      /* Find the XMesaBuffer which corresponds to the GLXDrawable 'read' */
12137a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell      if (ctx == MakeCurrent_PrevContext
1214086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul          && read == MakeCurrent_PrevReadable) {
1215086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         readBuffer = MakeCurrent_PrevReadBuffer;
1216086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      }
1217086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      else {
1218086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         readBuffer = XMesaFindBuffer( dpy, read );
1219086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      }
1220086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      if (!readBuffer) {
1221086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         /* drawable must be a new window! */
12227cf50e137da497a590ec9001a9918972a6246142Brian Paul         readBuffer = XMesaCreateWindowBuffer2(glxCtx->xmesaContext->xm_visual,
12237cf50e137da497a590ec9001a9918972a6246142Brian Paul                                               read, xmctx);
1224086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         if (!readBuffer) {
1225086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul            /* Out of memory, or context/drawable depth mismatch */
1226086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul            return False;
1227086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         }
1228086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      }
1229086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul
12307a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell      MakeCurrent_PrevContext = ctx;
1231086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevDrawable = draw;
1232086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevReadable = read;
1233086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevDrawBuffer = drawBuffer;
1234086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevReadBuffer = readBuffer;
1235086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul
1236086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      /* Now make current! */
12377cf50e137da497a590ec9001a9918972a6246142Brian Paul      if (XMesaMakeCurrent2(xmctx, drawBuffer, readBuffer)) {
123812c1bee87fcc3a0912685bb6e83447972e5de64eBrian Paul         ((__GLXcontext *) ctx)->currentDpy = dpy;
123912c1bee87fcc3a0912685bb6e83447972e5de64eBrian Paul         ((__GLXcontext *) ctx)->currentDrawable = draw;
12408d687e7e58a148f3f16573636023e54755372010Brian Paul#ifndef GLX_BUILT_IN_XMESA
124112c1bee87fcc3a0912685bb6e83447972e5de64eBrian Paul         ((__GLXcontext *) ctx)->currentReadable = read;
12428d687e7e58a148f3f16573636023e54755372010Brian Paul#else
12437cf50e137da497a590ec9001a9918972a6246142Brian Paul         __glXSetCurrentContext(ctx);
12447cf50e137da497a590ec9001a9918972a6246142Brian Paul#endif
12457cf50e137da497a590ec9001a9918972a6246142Brian Paul         return True;
12467cf50e137da497a590ec9001a9918972a6246142Brian Paul      }
12477cf50e137da497a590ec9001a9918972a6246142Brian Paul      else {
12487cf50e137da497a590ec9001a9918972a6246142Brian Paul         return False;
12497cf50e137da497a590ec9001a9918972a6246142Brian Paul      }
1250086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul   }
12517a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell   else if (!ctx && !draw && !read) {
1252086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      /* release current context w/out assigning new one. */
1253086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      XMesaMakeCurrent( NULL, NULL );
1254086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevContext = 0;
1255086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevDrawable = 0;
1256086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevReadable = 0;
1257086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevDrawBuffer = 0;
1258086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevReadBuffer = 0;
125984cac8441fcf5f692cd220e9fa86cab398a4c159Brian Paul#ifdef GLX_BUILT_IN_XMESA
1260b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul      /* XXX bind dummy context with __glXSetCurrentContext(ctx); */
1261b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#endif
1262086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      return True;
1263086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul   }
1264086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul   else {
1265086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      /* The args must either all be non-zero or all zero.
1266086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul       * This is an error.
1267086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul       */
1268086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      return False;
1269086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul   }
1270086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul}
1271086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul
1272086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul
1273426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1274426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool
1275426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXMakeCurrent( Display *dpy, GLXDrawable drawable, GLXContext ctx )
1276426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
1277426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   return Fake_glXMakeContextCurrent( dpy, drawable, drawable, ctx );
1278426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
1279426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1280426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1281426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1282426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPixmap
1283426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateGLXPixmap( Display *dpy, XVisualInfo *visinfo, Pixmap pixmap )
1284afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1285afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaVisual v;
1286afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaBuffer b;
1287afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1288afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   v = find_glx_visual( dpy, visinfo );
1289afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (!v) {
1290afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      v = create_glx_visual( dpy, visinfo );
1291afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (!v) {
1292afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* unusable visual */
1293afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1294afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
1295afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1296afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1297afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   b = XMesaCreatePixmapBuffer( v, pixmap, 0 );
1298afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (!b) {
1299afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return 0;
1300afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1301afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return b->frontbuffer;
1302afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1303afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1304afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1305b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_MESA_pixmap_colormap ***/
1306b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul
1307426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPixmap
1308426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visinfo,
1309426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                             Pixmap pixmap, Colormap cmap )
1310afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1311afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaVisual v;
1312afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaBuffer b;
1313afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1314afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   v = find_glx_visual( dpy, visinfo );
1315afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (!v) {
1316afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      v = create_glx_visual( dpy, visinfo );
1317afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (!v) {
1318afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* unusable visual */
1319afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1320afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
1321afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1322afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1323afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   b = XMesaCreatePixmapBuffer( v, pixmap, cmap );
1324afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (!b) {
1325afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return 0;
1326afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1327afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return b->frontbuffer;
1328afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1329afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1330afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1331426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1332426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyGLXPixmap( Display *dpy, GLXPixmap pixmap )
1333afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1334afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaBuffer b = XMesaFindBuffer(dpy, pixmap);
1335afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (b) {
1336afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      XMesaDestroyBuffer(b);
1337afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1338afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else if (getenv("MESA_DEBUG")) {
1339afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      fprintf( stderr, "Mesa: glXDestroyGLXPixmap: invalid pixmap\n");
1340afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1341afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1342afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1343afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
13444c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul
1345426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1346426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCopyContext( Display *dpy, GLXContext src, GLXContext dst,
13473994b77bab8c62a4c1a4dffdfba233ef46662b99Brian Paul                     unsigned long mask )
1348afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
13497a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell   XMesaContext xm_src = (XMesaContext) src;
13507a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell   XMesaContext xm_dst = (XMesaContext) dst;
1351afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
13527a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell   _mesa_copy_context( xm_src->gl_ctx, xm_dst->gl_ctx, (GLuint) mask );
1353afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1354afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1355afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1356afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1357426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool
1358426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryExtension( Display *dpy, int *errorb, int *event )
1359afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1360afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* Mesa's GLX isn't really an X extension but we try to act like one. */
1361afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
1362afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) errorb;
1363afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) event;
1364afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return True;
1365afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1366afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1367afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1368e7b16b74bf5d13331b5a88bbbbb9096560297b63Brian Paulextern void _kw_ungrab_all( Display *dpy );
1369afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgvoid _kw_ungrab_all( Display *dpy )
1370afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1371afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XUngrabPointer( dpy, CurrentTime );
1372afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XUngrabKeyboard( dpy, CurrentTime );
1373afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1374afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1375afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1376426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1377426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyContext( Display *dpy, GLXContext ctx )
1378afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
13797cf50e137da497a590ec9001a9918972a6246142Brian Paul   struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx;
1380afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
1381afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   MakeCurrent_PrevContext = 0;
1382afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   MakeCurrent_PrevDrawable = 0;
1383086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul   MakeCurrent_PrevReadable = 0;
1384086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul   MakeCurrent_PrevDrawBuffer = 0;
1385086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul   MakeCurrent_PrevReadBuffer = 0;
13867cf50e137da497a590ec9001a9918972a6246142Brian Paul   XMesaDestroyContext( glxCtx->xmesaContext );
1387afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaGarbageCollect();
1388afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1389afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1390afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1391afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1392426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool
1393426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXIsDirect( Display *dpy, GLXContext ctx )
1394afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
13957cf50e137da497a590ec9001a9918972a6246142Brian Paul   struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx;
1396afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
13977cf50e137da497a590ec9001a9918972a6246142Brian Paul   return glxCtx->xmesaContext->direct;
1398afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1399afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1400afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1401afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1402426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1403426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXSwapBuffers( Display *dpy, GLXDrawable drawable )
1404afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1405afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaBuffer buffer = XMesaFindBuffer( dpy, drawable );
1406afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1407afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (buffer) {
1408afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      XMesaSwapBuffers(buffer);
1409afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1410afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else if (getenv("MESA_DEBUG")) {
1411afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      fprintf(stderr, "Mesa Warning: glXSwapBuffers: invalid drawable\n");
1412afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1413afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1414afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1415afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
14164c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul
1417b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_MESA_copy_sub_buffer ***/
1418b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul
1419426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1420426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCopySubBufferMESA( Display *dpy, GLXDrawable drawable,
1421426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                           int x, int y, int width, int height )
1422afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1423afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaBuffer buffer = XMesaFindBuffer( dpy, drawable );
1424afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (buffer) {
1425afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      XMesaCopySubBuffer(buffer, x, y, width, height);
1426afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1427afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else if (getenv("MESA_DEBUG")) {
1428afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      fprintf(stderr, "Mesa Warning: glXCopySubBufferMESA: invalid drawable\n");
1429afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1430afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1431afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1432afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1433afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1434426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool
1435426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryVersion( Display *dpy, int *maj, int *min )
1436afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1437afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
1438afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* Return GLX version, not Mesa version */
143978fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul   assert(CLIENT_MAJOR_VERSION == SERVER_MAJOR_VERSION);
144078fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul   *maj = CLIENT_MAJOR_VERSION;
144178fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul   *min = MIN2( CLIENT_MINOR_VERSION, SERVER_MINOR_VERSION );
1442afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return True;
1443afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1444afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1445afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1446afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1447afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
1448afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Query the GLX attributes of the given XVisualInfo.
1449afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
1450426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int
1451426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetConfig( Display *dpy, XVisualInfo *visinfo,
1452426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                   int attrib, int *value )
1453afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1454afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaVisual glxvis;
1455afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1456afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   glxvis = find_glx_visual( dpy, visinfo );
1457afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (!glxvis) {
1458afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* this visual wasn't obtained with glXChooseVisual */
1459afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      glxvis = create_glx_visual( dpy, visinfo );
1460afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (!glxvis) {
1461afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 /* this visual can't be used for GL rendering */
1462afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 if (attrib==GLX_USE_GL) {
1463afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    *value = (int) False;
1464afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    return 0;
1465afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 }
1466afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 else {
1467afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    /*fprintf( stderr, "Mesa: Error in glXGetConfig: bad visual\n");*/
1468afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    return GLX_BAD_VISUAL;
1469afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 }
1470afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
1471afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1472afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1473afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   switch(attrib) {
1474afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_USE_GL:
1475afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         *value = (int) True;
1476afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1477afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_BUFFER_SIZE:
1478afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 *value = visinfo->depth;
1479afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1480afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_LEVEL:
1481afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 *value = glxvis->level;
1482afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1483afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_RGBA:
14841832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul	 if (glxvis->mesa_visual.rgbMode) {
1485afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    *value = True;
1486afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 }
1487afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 else {
1488afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    *value = False;
1489afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 }
1490afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1491afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_DOUBLEBUFFER:
14921832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul	 *value = (int) glxvis->mesa_visual.doubleBufferMode;
1493afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1494afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_STEREO:
14951832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul	 *value = (int) glxvis->mesa_visual.stereoMode;
1496afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1497afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_AUX_BUFFERS:
1498afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 *value = (int) False;
1499afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1500afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_RED_SIZE:
15011832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul         *value = glxvis->mesa_visual.redBits;
1502afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1503afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_GREEN_SIZE:
15041832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul         *value = glxvis->mesa_visual.greenBits;
1505afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1506afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_BLUE_SIZE:
15071832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul         *value = glxvis->mesa_visual.blueBits;
1508afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1509afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_ALPHA_SIZE:
15101832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul         *value = glxvis->mesa_visual.alphaBits;
1511afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1512afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_DEPTH_SIZE:
15131832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul         *value = glxvis->mesa_visual.depthBits;
1514afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1515afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_STENCIL_SIZE:
15161832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul	 *value = glxvis->mesa_visual.stencilBits;
1517afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1518afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_ACCUM_RED_SIZE:
15191832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul	 *value = glxvis->mesa_visual.accumRedBits;
1520b2e460018375f699198073a6167e0ee96ba1d267Brian Paul	 return 0;
1521afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_ACCUM_GREEN_SIZE:
15221832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul	 *value = glxvis->mesa_visual.accumGreenBits;
1523b2e460018375f699198073a6167e0ee96ba1d267Brian Paul	 return 0;
1524afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_ACCUM_BLUE_SIZE:
15251832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul	 *value = glxvis->mesa_visual.accumBlueBits;
1526afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1527afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_ACCUM_ALPHA_SIZE:
15281832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul         *value = glxvis->mesa_visual.accumAlphaBits;
1529afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1530afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1531afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /*
1532afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg       * GLX_EXT_visual_info extension
1533afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg       */
1534afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_X_VISUAL_TYPE_EXT:
1535afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         switch (glxvis->visinfo->CLASS) {
1536afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case StaticGray:   *value = GLX_STATIC_GRAY_EXT;   return 0;
1537afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GrayScale:    *value = GLX_GRAY_SCALE_EXT;    return 0;
1538afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case StaticColor:  *value = GLX_STATIC_GRAY_EXT;   return 0;
1539afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case PseudoColor:  *value = GLX_PSEUDO_COLOR_EXT;  return 0;
1540afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case TrueColor:    *value = GLX_TRUE_COLOR_EXT;    return 0;
1541afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case DirectColor:  *value = GLX_DIRECT_COLOR_EXT;  return 0;
1542afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
1543afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1544afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_TRANSPARENT_TYPE_EXT:
1545afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         if (glxvis->level==0) {
1546afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* normal planes */
1547afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            *value = GLX_NONE_EXT;
1548afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
1549afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         else if (glxvis->level>0) {
1550afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* overlay */
15511832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul            if (glxvis->mesa_visual.rgbMode) {
1552afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               *value = GLX_TRANSPARENT_RGB_EXT;
1553afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
1554afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            else {
1555afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               *value = GLX_TRANSPARENT_INDEX_EXT;
1556afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
1557afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
1558afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         else if (glxvis->level<0) {
1559afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* underlay */
1560afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            *value = GLX_NONE_EXT;
1561afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
1562afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1563afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_TRANSPARENT_INDEX_VALUE_EXT:
1564afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         {
1565afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            int pixel = transparent_pixel( glxvis );
1566afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            if (pixel>=0) {
1567afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               *value = pixel;
1568afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
1569afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* else undefined */
1570afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
1571afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1572afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_TRANSPARENT_RED_VALUE_EXT:
1573afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* undefined */
1574afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1575afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_TRANSPARENT_GREEN_VALUE_EXT:
1576afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* undefined */
1577afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1578afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_TRANSPARENT_BLUE_VALUE_EXT:
1579afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* undefined */
1580afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1581afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_TRANSPARENT_ALPHA_VALUE_EXT:
1582afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* undefined */
1583afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1584afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1585afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /*
1586b2e460018375f699198073a6167e0ee96ba1d267Brian Paul       * GLX_EXT_visual_info extension
1587b2e460018375f699198073a6167e0ee96ba1d267Brian Paul       */
1588b2e460018375f699198073a6167e0ee96ba1d267Brian Paul      case GLX_VISUAL_CAVEAT_EXT:
1589fc68be6b111473a0bf8f991468f973bb9dd275f4Brian Paul         /* test for zero, just in case */
1590962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul         if (glxvis->VisualCaveat > 0)
1591962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul            *value = glxvis->VisualCaveat;
1592962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul         else
1593962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul            *value = GLX_NONE_EXT;
1594962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul         return 0;
1595b2e460018375f699198073a6167e0ee96ba1d267Brian Paul
1596b2e460018375f699198073a6167e0ee96ba1d267Brian Paul      /*
1597afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg       * Extensions
1598afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg       */
1599afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      default:
1600afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return GLX_BAD_ATTRIBUTE;
1601afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1602afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1603afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1604afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1605afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1606426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1607426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXWaitGL( void )
1608afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1609afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaContext xmesa = XMesaGetCurrentContext();
1610afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaFlush( xmesa );
1611afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1612afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1613afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1614afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1615426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1616426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXWaitX( void )
1617afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1618afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaContext xmesa = XMesaGetCurrentContext();
1619afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaFlush( xmesa );
1620afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1621afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1622afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
162343c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul/*
162443c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul * Return the extensions string, which is 3Dfx-dependant.
162543c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul */
162643c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paulstatic const char *get_extensions( void )
162743c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul{
162843c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul#ifdef FX
162943c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul   const char *fx = getenv("MESA_GLX_FX");
163043c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul   if (fx && fx[0] != 'd') {
1631e1210b176926349b258c7ec77b7f36716025c82aBrian 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";
163243c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul   }
163343c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul#endif
1634e1210b176926349b258c7ec77b7f36716025c82aBrian 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";
163543c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul}
1636afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1637afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1638afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1639afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* GLX 1.1 and later */
1640426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic const char *
1641426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryExtensionsString( Display *dpy, int screen )
1642afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1643afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
1644afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) screen;
164543c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul   return get_extensions();
1646afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1647afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1648afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1649afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1650afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* GLX 1.1 and later */
1651426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic const char *
1652426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryServerString( Display *dpy, int screen, int name )
1653afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
165478fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul   static char version[1000];
165578fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul   sprintf(version, "%d.%d %s", SERVER_MAJOR_VERSION, SERVER_MINOR_VERSION,
165678fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul           MESA_GLX_VERSION);
1657afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1658afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
1659afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) screen;
1660afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1661afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   switch (name) {
1662afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_EXTENSIONS:
166343c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul         return get_extensions();
1664afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_VENDOR:
166578fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul	 return VENDOR;
1666afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_VERSION:
1667afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return version;
1668afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      default:
1669afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return NULL;
1670afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1671afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1672afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1673afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1674afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1675afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* GLX 1.1 and later */
1676426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic const char *
1677426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetClientString( Display *dpy, int name )
1678afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
167978fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul   static char version[1000];
168078fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul   sprintf(version, "%d.%d %s", CLIENT_MAJOR_VERSION, CLIENT_MINOR_VERSION,
168178fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul           MESA_GLX_VERSION);
1682afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1683afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
1684afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1685afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   switch (name) {
1686afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_EXTENSIONS:
168743c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul         return get_extensions();
1688afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_VENDOR:
168978fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul	 return VENDOR;
1690afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_VERSION:
1691afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return version;
1692afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      default:
1693afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return NULL;
1694afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1695afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1696afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1697afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1698afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1699426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul/*
1700426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul * GLX 1.3 and later
1701426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul */
1702426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
17037d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul/* XXX Move this when done.
17047d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul * Create an XMesaBuffer as a Pbuffer.
1705a573803ed3fe9ef6489f45bd4c5455b77cb33a43Brian Paul * New in Mesa 4.0 but untested.
17067d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul */
17077d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paulextern XMesaBuffer XMesaCreatePBuffer( XMesaVisual v, XMesaColormap cmap,
17087d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul                                    unsigned int width, unsigned int height );
17097d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
17107d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
17117d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
17125605798e56ca6e9f968623f33b58ee7ca90594afBrian Paulstatic GLXFBConfig *
1713426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXChooseFBConfig( Display *dpy, int screen,
1714426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                        const int *attribList, int *nitems )
1715426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
1716426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
1717426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) screen;
1718426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) attribList;
1719426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) nitems;
1720426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   return 0;
1721426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
1722426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1723426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1724426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int
1725426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetFBConfigAttrib( Display *dpy, GLXFBConfig config,
1726426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                           int attribute, int *value )
1727426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
17287d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   XMesaVisual v = NULL; /* XXX Fix this */
1729426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
1730426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) config;
1731426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) attribute;
1732426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) value;
17337d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
17347d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (!dpy || !config || !value)
17357d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return -1;
17367d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
17377d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   switch (attribute) {
17387d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_FBCONFIG_ID:
17397d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_BUFFER_SIZE:
17407d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         if (v->mesa_visual.rgbMode)
17417d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            *value = v->mesa_visual.redBits + v->mesa_visual.greenBits +
17427d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul                     v->mesa_visual.blueBits + v->mesa_visual.alphaBits;
17437d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         else
17447d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            *value = v->mesa_visual.indexBits;
17457d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
17467d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_LEVEL:
17477d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = v->level;
17487d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
17497d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_DOUBLEBUFFER:
17507d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = v->mesa_visual.doubleBufferMode;
17517d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
17527d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_STEREO:
17537d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = v->mesa_visual.stereoMode;
17547d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
17557d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_AUX_BUFFERS:
17567d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = v->mesa_visual.numAuxBuffers;
17577d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
17587d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_RED_SIZE:
17597d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = v->mesa_visual.redBits;
17607d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
17617d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_GREEN_SIZE:
17627d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = v->mesa_visual.greenBits;
17637d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
17647d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_BLUE_SIZE:
17657d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = v->mesa_visual.blueBits;
17667d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
17677d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_ALPHA_SIZE:
17687d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = v->mesa_visual.alphaBits;
17697d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
17707d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_DEPTH_SIZE:
17717d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = v->mesa_visual.depthBits;
17727d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
17737d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_STENCIL_SIZE:
17747d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = v->mesa_visual.stencilBits;
17757d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
17767d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_ACCUM_RED_SIZE:
17777d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = v->mesa_visual.accumRedBits;
17787d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
17797d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_ACCUM_GREEN_SIZE:
17807d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = v->mesa_visual.accumGreenBits;
17817d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
17827d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_ACCUM_BLUE_SIZE:
17837d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = v->mesa_visual.accumBlueBits;
17847d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
17857d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_ACCUM_ALPHA_SIZE:
17867d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = v->mesa_visual.accumAlphaBits;
17877d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
17887d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_RENDER_TYPE:
17897d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = 0; /* XXX ??? */
17907d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
17917d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_DRAWABLE_TYPE:
17927d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = GLX_PBUFFER_BIT; /* XXX fix? */
17937d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
17947d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_X_RENDERABLE:
17957d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = False; /* XXX ??? */
17967d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
17977d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_X_VISUAL_TYPE:
17987d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         switch (v->vishandle->class) {
17997d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            case GrayScale:
18007d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul               *value = GLX_GRAY_SCALE;
18017d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul               break;
18027d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            case StaticGray:
18037d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul               *value = GLX_STATIC_GRAY;
18047d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul               break;
18057d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            case StaticColor:
18067d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul               *value = GLX_STATIC_COLOR;
18077d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul               break;
18087d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            case PseudoColor:
18097d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul               *value = GLX_PSEUDO_COLOR;
18107d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul               break;
18117d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            case TrueColor:
18127d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul               *value = GLX_TRUE_COLOR;
18137d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul               break;
18147d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            case DirectColor:
18157d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul               *value = GLX_DIRECT_COLOR;
18167d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul               break;
18177d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            default:
18187d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul               *value = 0;
18197d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         }
18207d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
18217d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_CONFIG_CAVEAT:
18227d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = 0; /* XXX ??? */
18237d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
18247d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_TRANSPARENT_TYPE:
18257d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         if (v->level == 0) {
18267d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            /* normal planes */
18277d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            *value = GLX_NONE_EXT;
18287d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         }
18297d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         else if (v->level > 0) {
18307d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            /* overlay */
18317d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            if (v->mesa_visual.rgbMode) {
18327d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul               *value = GLX_TRANSPARENT_RGB_EXT;
18337d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            }
18347d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            else {
18357d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul               *value = GLX_TRANSPARENT_INDEX_EXT;
18367d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            }
18377d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         }
18387d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         else if (v->level < 0) {
18397d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            /* underlay */
18407d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            *value = GLX_NONE_EXT;
18417d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         }
18427d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
18437d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_TRANSPARENT_INDEX_VALUE:
18447d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = transparent_pixel( v );
18457d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
18467d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_TRANSPARENT_RED_VALUE:
18477d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = 0;  /* not implemented */
18487d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
18497d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_TRANSPARENT_GREEN_VALUE:
18507d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = 0;  /* not implemented */
18517d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
18527d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_TRANSPARENT_BLUE_VALUE:
18537d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = 0;  /* not implemented */
18547d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
18557d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_TRANSPARENT_ALPHA_VALUE:
18567d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = 0;  /* not implemented */
18577d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
18587d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_MAX_PBUFFER_WIDTH:
18597d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = DisplayWidth(dpy, v->vishandle->screen);
18607d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
18617d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_MAX_PBUFFER_HEIGHT:
18627d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = DisplayHeight(dpy, v->vishandle->screen);
18637d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
18647d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_MAX_PBUFFER_PIXELS:
18657d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = DisplayWidth(dpy, v->vishandle->screen) *
18667d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul                  DisplayHeight(dpy, v->vishandle->screen);
18677d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
18687d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_VISUAL_ID:
18697d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = v->vishandle->visualid;
18707d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         break;
18717d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      default:
18727d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         return GLX_BAD_ATTRIBUTE;
18737d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   }
18747d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
18757d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   return Success;
1876426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
1877426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1878426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
18795605798e56ca6e9f968623f33b58ee7ca90594afBrian Paulstatic GLXFBConfig *
18805605798e56ca6e9f968623f33b58ee7ca90594afBrian PaulFake_glXGetFBConfigs( Display *dpy, int screen, int *nelements )
18815605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul{
18825605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul   (void) dpy;
18835605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul   (void) screen;
18845605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul   (void) nelements;
18855605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul   return 0;
18865605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul}
18875605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul
18885605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul
1889426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic XVisualInfo *
1890426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetVisualFromFBConfig( Display *dpy, GLXFBConfig config )
1891426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
18927d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (dpy && config) {
18937d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      XMesaVisual v = (XMesaVisual) config;
18947d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return v->vishandle;
18957d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   }
18967d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   else {
18977d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return NULL;
18987d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   }
1899426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
1900426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1901426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1902426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXWindow
1903426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateWindow( Display *dpy, GLXFBConfig config, Window win,
1904426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                      const int *attribList )
1905426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
1906426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
1907426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) config;
1908426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) win;
19097d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   (void) attribList;  /* Ignored in GLX 1.3 */
19107d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
19117d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   return win;  /* A hack for now */
1912426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
1913426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1914426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1915426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1916426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyWindow( Display *dpy, GLXWindow window )
1917426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
19187d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   XMesaBuffer b = XMesaFindBuffer(dpy, (XMesaDrawable) window);
19197d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (b)
19207d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      XMesaDestroyBuffer(b);
19217d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   /* don't destroy X window */
1922426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
1923426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1924426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
19257d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul/* XXX untested */
1926426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPixmap
1927426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreatePixmap( Display *dpy, GLXFBConfig config, Pixmap pixmap,
1928426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                      const int *attribList )
1929426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
19307d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   XMesaVisual v = (XMesaVisual) config;
19317d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   XVisualInfo *visinfo;
19327d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   XMesaBuffer b;
19337d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
1934426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
1935426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) config;
1936426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) pixmap;
19377d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   (void) attribList;  /* Ignored in GLX 1.3 */
19387d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
19397d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (!dpy || !config || !pixmap)
19407d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return 0;
19417d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
19427d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   visinfo = v->vishandle;
19437d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
19447d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   v = find_glx_visual( dpy, visinfo );
19457d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (!v) {
19467d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      v = create_glx_visual( dpy, visinfo );
19477d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      if (!v) {
19487d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         /* unusable visual */
19497d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         return 0;
19507d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      }
19517d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   }
19527d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
19537d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   b = XMesaCreatePixmapBuffer( v, pixmap, 0 );
19547d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (!b) {
19557d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return 0;
19567d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   }
19577d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
19587d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   return pixmap;
1959426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
1960426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1961426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1962426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1963426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyPixmap( Display *dpy, GLXPixmap pixmap )
1964426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
19657d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   XMesaBuffer b = XMesaFindBuffer(dpy, (XMesaDrawable)pixmap);
19667d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (b)
19677d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      XMesaDestroyBuffer(b);
19687d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   /* don't destroy X pixmap */
1969426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
1970426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1971426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1972426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPbuffer
1973426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreatePbuffer( Display *dpy, GLXFBConfig config,
1974426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                       const int *attribList )
1975426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
19767d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   const int *attrib;
19777d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   int width = 0, height = 0;
19787d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   GLboolean useLargest = GL_FALSE, preserveContents = GL_FALSE;
19797d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
1980426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
1981426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) config;
19827d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
19837d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   for (attrib = attribList; attrib; attrib++) {
19847d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      switch (*attrib) {
19857d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         case GLX_PBUFFER_WIDTH:
19867d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            width = *(++attrib);
19877d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            break;
19887d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         case GLX_PBUFFER_HEIGHT:
19897d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            height = *(++attrib);
19907d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            break;
19917d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         case GLX_PRESERVED_CONTENTS:
19927d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            preserveContents = GL_TRUE; /* ignored */
19937d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            break;
19947d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         case GLX_LARGEST_PBUFFER:
19957d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            useLargest = GL_TRUE; /* ignored */
19967d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            break;
19977d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         default:
19987d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            return 0;
19997d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      }
20007d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   }
20017d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
20027d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (width == 0 || height == 0)
20037d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return 0;
20047d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
20057d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
2006426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   return 0;
2007426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2008426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2009426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2010426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
2011426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyPbuffer( Display *dpy, GLXPbuffer pbuf )
2012426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2013426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
2014426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) pbuf;
2015426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2016426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2017426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2018426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
2019426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryDrawable( Display *dpy, GLXDrawable draw, int attribute,
2020426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                       unsigned int *value )
2021426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2022426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
2023426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) draw;
20247d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
20257d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   switch (attribute) {
20267d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_WIDTH:
20277d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_HEIGHT:
20287d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_PRESERVED_CONTENTS:
20297d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_LARGEST_PBUFFER:
20307d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_FBCONFIG_ID:
20317d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = 0;
20327d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         return;
20337d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      default:
20347d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         return;  /* GLX_BAD_ATTRIBUTE? */
20357d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   }
2036426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2037426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2038426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2039426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXContext
2040426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateNewContext( Display *dpy, GLXFBConfig config,
2041426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                          int renderType, GLXContext shareList, Bool direct )
2042426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
20437d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   XMesaVisual v = (XMesaVisual) config;
20447d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
20457d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (!dpy || !config ||
20467d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul       (renderType != GLX_RGBA_TYPE && renderType != GLX_COLOR_INDEX_TYPE))
20477d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return 0;
20487d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
20497d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   return Fake_glXCreateContext(dpy, v->vishandle, shareList, direct);
2050426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2051426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2052426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2053426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int
2054426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryContext( Display *dpy, GLXContext ctx, int attribute, int *value )
2055426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2056426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
2057426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) ctx;
20587d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
20597d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   switch (attribute) {
20607d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   case GLX_FBCONFIG_ID:
20617d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   case GLX_RENDER_TYPE:
20627d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   case GLX_SCREEN:
20637d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      *value = 0;
20647d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return Success;
20657d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   default:
20667d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return GLX_BAD_ATTRIBUTE;
20677d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   }
2068426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2069426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2070426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2071426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
2072426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXSelectEvent( Display *dpy, GLXDrawable drawable, unsigned long mask )
2073426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2074426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
2075426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) drawable;
2076426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) mask;
2077426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2078426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2079426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2080426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
2081426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetSelectedEvent( Display *dpy, GLXDrawable drawable,
2082426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                          unsigned long *mask )
2083426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2084426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
2085426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) drawable;
2086426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) mask;
2087426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2088b82d993b03320818f88f792a9e713f7ed491bfcbBrian Paul
2089b82d993b03320818f88f792a9e713f7ed491bfcbBrian Paul
2090b82d993b03320818f88f792a9e713f7ed491bfcbBrian Paul
2091b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGI_swap_control ***/
2092783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2093783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2094783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXSwapIntervalSGI(int interval)
2095783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2096783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) interval;
2097783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2098783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2099783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2100783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2101783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2102b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGI_video_sync ***/
2103783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2104783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2105783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetVideoSyncSGI(unsigned int *count)
2106783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2107783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) count;
2108783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2109783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2110783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2111783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2112783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count)
2113783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2114783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) divisor;
2115783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) remainder;
2116783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) count;
2117783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2118783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2119783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2120783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2121783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2122b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGI_make_current_read ***/
2123783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2124426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool
2125783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXMakeCurrentReadSGI(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx)
2126afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
2127783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2128783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) draw;
2129783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) read;
2130783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) ctx;
2131afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return False;
2132afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
2133783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
21347cf50e137da497a590ec9001a9918972a6246142Brian Paul/* not used
2135783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXDrawable
2136b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian PaulFake_glXGetCurrentReadDrawableSGI(void)
2137783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2138783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2139783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
21407cf50e137da497a590ec9001a9918972a6246142Brian Paul*/
2141afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
2142afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
2143b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_video_source ***/
2144b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#if defined(_VL_H)
21454c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul
2146783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXVideoSourceSGIX
2147783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXCreateGLXVideoSourceSGIX(Display *dpy, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode)
2148afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
2149783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2150783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2151783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) server;
2152783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) path;
2153783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) nodeClass;
2154783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) drainNode;
2155783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2156783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2157783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2158783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2159783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXDestroyGLXVideoSourceSGIX(Display *dpy, GLXVideoSourceSGIX src)
2160783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2161783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2162783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) src;
2163afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
2164783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
21654c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul#endif
21664c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul
216789a42b7e736bd9b0ab090906cab0cd047a6ec12eBrian Paul
2168b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_EXT_import_context ***/
216989a42b7e736bd9b0ab090906cab0cd047a6ec12eBrian Paul
2170783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2171783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXFreeContextEXT(Display *dpy, GLXContext context)
2172783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2173783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2174783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) context;
2175783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2176426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2177783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXContextID
2178783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetContextIDEXT(const GLXContext context)
2179783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2180783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) context;
2181783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2182783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2183783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2184783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXContext
2185783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXImportContextEXT(Display *dpy, GLXContextID contextID)
2186783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2187783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2188783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) contextID;
2189783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2190783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2191426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2192426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int
2193783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryContextInfoEXT(Display *dpy, GLXContext context, int attribute, int *value)
2194426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2195783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2196783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) context;
2197783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) attribute;
2198783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) value;
2199426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   return 0;
2200426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2201426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2202783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2203783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2204b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_fbconfig ***/
2205426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2206426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int
2207783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetFBConfigAttribSGIX(Display *dpy, GLXFBConfigSGIX config, int attribute, int *value)
2208783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2209783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2210783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) config;
2211783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) attribute;
2212783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) value;
2213783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2214783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2215783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2216783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXFBConfigSGIX *
2217783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXChooseFBConfigSGIX(Display *dpy, int screen, int *attrib_list, int *nelements)
2218783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2219783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2220783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2221783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) attrib_list;
2222783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) nelements;
2223783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2224783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2225783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2226783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXPixmap
2227783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXCreateGLXPixmapWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap)
2228783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2229783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2230783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) config;
2231783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) pixmap;
2232783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2233783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2234783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2235783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXContext
2236783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct)
2237783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2238783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2239783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) config;
2240783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) render_type;
2241783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) share_list;
2242783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) direct;
2243783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2244783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2245783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2246783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic XVisualInfo *
2247783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetVisualFromFBConfigSGIX(Display *dpy, GLXFBConfigSGIX config)
2248783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2249783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2250783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) config;
2251783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return NULL;
2252783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2253783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2254783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXFBConfigSGIX
2255783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetFBConfigFromVisualSGIX(Display *dpy, XVisualInfo *vis)
2256426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2257783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2258783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) vis;
2259426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   return 0;
2260426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2261426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2262426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2263426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2264b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_pbuffer ***/
2265783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2266783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXPbufferSGIX
2267783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXCreateGLXPbufferSGIX(Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list)
2268783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2269783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2270783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) config;
2271783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) width;
2272783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) height;
2273783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) attrib_list;
2274783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2275783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2276783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2277783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2278783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXDestroyGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf)
2279783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2280783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2281783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) pbuf;
2282783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2283783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2284783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2285783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value)
2286783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2287783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2288783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) pbuf;
2289783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) attribute;
2290783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) value;
2291783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2292783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2293783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2294783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2295783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXSelectEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long mask)
2296783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2297783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2298783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) drawable;
2299783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) mask;
2300783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2301783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2302783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2303783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetSelectedEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long *mask)
2304783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2305783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2306783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) drawable;
2307783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) mask;
2308783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2309783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2310783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2311783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2312b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGI_cushion ***/
2313783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2314783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2315783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXCushionSGI(Display *dpy, Window win, float cushion)
2316783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2317783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2318783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) win;
2319783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) cushion;
2320783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2321783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2322783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2323783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2324b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_video_resize ***/
2325783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2326783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2327783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXBindChannelToWindowSGIX(Display *dpy, int screen, int channel , Window window)
2328783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2329783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2330783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2331783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) channel;
2332783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) window;
2333783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2334783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2335783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2336783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2337783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXChannelRectSGIX(Display *dpy, int screen, int channel, int x, int y, int w, int h)
2338783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2339783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2340783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2341783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) channel;
2342783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) x;
2343783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) y;
2344783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) w;
2345783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) h;
2346783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2347783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2348783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2349783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2350783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryChannelRectSGIX(Display *dpy, int screen, int channel, int *x, int *y, int *w, int *h)
2351783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2352783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2353783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2354783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) channel;
2355783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) x;
2356783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) y;
2357783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) w;
2358783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) h;
2359783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2360783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2361783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2362783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2363783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryChannelDeltasSGIX(Display *dpy, int screen, int channel, int *dx, int *dy, int *dw, int *dh)
2364783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2365783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2366783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2367783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) channel;
2368783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dx;
2369783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dy;
2370783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dw;
2371783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dh;
2372783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2373783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2374783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2375783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2376783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXChannelRectSyncSGIX(Display *dpy, int screen, int channel, GLenum synctype)
2377783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2378783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2379783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2380783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) channel;
2381783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) synctype;
2382783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2383783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2384783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2385783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2386783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2387b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_dmbuffer **/
2388783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2389b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#if defined(_DM_BUFFER_H_)
2390783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Bool
2391783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXAssociateDMPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer)
2392783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2393783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2394783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) pbuffer;
2395783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) params;
2396783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dmbuffer;
2397783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return False;
2398783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2399783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul#endif
2400783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2401783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2402b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_swap_group ***/
2403783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2404783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2405783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXJoinSwapGroupSGIX(Display *dpy, GLXDrawable drawable, GLXDrawable member)
2406783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2407783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2408783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) drawable;
2409783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) member;
2410783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2411783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2412783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2413783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2414b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_swap_barrier ***/
2415783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2416783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2417783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXBindSwapBarrierSGIX(Display *dpy, GLXDrawable drawable, int barrier)
2418783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2419783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2420783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) drawable;
2421783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) barrier;
2422783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2423783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2424783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Bool
2425783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryMaxSwapBarriersSGIX(Display *dpy, int screen, int *max)
2426783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2427783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2428783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2429783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) max;
2430783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return False;
2431783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2432783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2433783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2434783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2435b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SUN_get_transparent_index ***/
2436783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2437783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Status
2438783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetTransparentIndexSUN(Display *dpy, Window overlay, Window underlay, long *pTransparent)
2439783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2440783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2441783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) overlay;
2442783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) underlay;
2443783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) pTransparent;
2444783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2445783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2446783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2447783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2448783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2449b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_MESA_release_buffers ***/
2450b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul
2451783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul/*
2452783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul * Release the depth, stencil, accum buffers attached to a GLXDrawable
2453783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul * (a window or pixmap) prior to destroying the GLXDrawable.
2454783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul */
2455783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Bool
2456783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXReleaseBuffersMESA( Display *dpy, GLXDrawable d )
2457783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2458783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   XMesaBuffer b = XMesaFindBuffer(dpy, d);
2459783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   if (b) {
2460783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul      XMesaDestroyBuffer(b);
2461783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul      return True;
2462783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   }
2463783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return False;
2464783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2465783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2466783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2467783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2468b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_MESA_set_3dfx_mode ***/
2469b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul
2470783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Bool
2471783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXSet3DfxModeMESA( int mode )
2472783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2473783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return XMesaSetFXmode( mode );
2474783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2475783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2476783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2477783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
247843c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul
2479e7b16b74bf5d13331b5a88bbbbb9096560297b63Brian Paulextern struct _glxapi_table *_mesa_GetGLXDispatchTable(void);
2480426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstruct _glxapi_table *_mesa_GetGLXDispatchTable(void)
2481426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2482426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   static struct _glxapi_table glx;
2483426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2484426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   /* be sure our dispatch table size <= libGL's table */
2485426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   {
248601915e90e6912f06d43d443a09157f7bbc96ddc5Brian Paul      GLuint size = sizeof(struct _glxapi_table) / sizeof(void *);
2487426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul      (void) size;
2488426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul      assert(_glxapi_get_dispatch_table_size() >= size);
2489426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   }
2490426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2491426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   /* initialize the whole table to no-ops */
2492426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   _glxapi_set_no_op_table(&glx);
2493426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2494426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   /* now initialize the table with the functions I implement */
2495426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.ChooseVisual = Fake_glXChooseVisual;
2496426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CopyContext = Fake_glXCopyContext;
2497426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CreateContext = Fake_glXCreateContext;
2498426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CreateGLXPixmap = Fake_glXCreateGLXPixmap;
2499426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.DestroyContext = Fake_glXDestroyContext;
2500426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.DestroyGLXPixmap = Fake_glXDestroyGLXPixmap;
2501426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.GetConfig = Fake_glXGetConfig;
2502426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   /*glx.GetCurrentContext = Fake_glXGetCurrentContext;*/
2503426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   /*glx.GetCurrentDrawable = Fake_glXGetCurrentDrawable;*/
2504426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.IsDirect = Fake_glXIsDirect;
2505426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.MakeCurrent = Fake_glXMakeCurrent;
2506426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.QueryExtension = Fake_glXQueryExtension;
2507426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.QueryVersion = Fake_glXQueryVersion;
2508426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.SwapBuffers = Fake_glXSwapBuffers;
2509426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.UseXFont = Fake_glXUseXFont;
2510426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.WaitGL = Fake_glXWaitGL;
2511426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.WaitX = Fake_glXWaitX;
2512426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2513b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_VERSION_1_1 ***/
2514426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.GetClientString = Fake_glXGetClientString;
2515426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.QueryExtensionsString = Fake_glXQueryExtensionsString;
2516426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.QueryServerString = Fake_glXQueryServerString;
2517426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2518b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_VERSION_1_2 ***/
2519426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   /*glx.GetCurrentDisplay = Fake_glXGetCurrentDisplay;*/
2520426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2521b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_VERSION_1_3 ***/
2522426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.ChooseFBConfig = Fake_glXChooseFBConfig;
2523426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CreateNewContext = Fake_glXCreateNewContext;
2524426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CreatePbuffer = Fake_glXCreatePbuffer;
2525426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CreatePixmap = Fake_glXCreatePixmap;
2526426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CreateWindow = Fake_glXCreateWindow;
2527426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.DestroyPbuffer = Fake_glXDestroyPbuffer;
2528426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.DestroyPixmap = Fake_glXDestroyPixmap;
2529426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.DestroyWindow = Fake_glXDestroyWindow;
2530426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   /*glx.GetCurrentReadDrawable = Fake_glXGetCurrentReadDrawable;*/
2531426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.GetFBConfigAttrib = Fake_glXGetFBConfigAttrib;
253271dea349d2be623b7819389428b0d6a124e8d184Brian Paul   glx.GetFBConfigs = Fake_glXGetFBConfigs;
2533426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.GetSelectedEvent = Fake_glXGetSelectedEvent;
2534426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.GetVisualFromFBConfig = Fake_glXGetVisualFromFBConfig;
2535426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.MakeContextCurrent = Fake_glXMakeContextCurrent;
2536426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.QueryContext = Fake_glXQueryContext;
2537426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.QueryDrawable = Fake_glXQueryDrawable;
2538426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.SelectEvent = Fake_glXSelectEvent;
2539426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2540b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGI_swap_control ***/
2541783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.SwapIntervalSGI = Fake_glXSwapIntervalSGI;
2542783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2543b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGI_video_sync ***/
2544426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.GetVideoSyncSGI = Fake_glXGetVideoSyncSGI;
2545426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.WaitVideoSyncSGI = Fake_glXWaitVideoSyncSGI;
2546426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2547b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGI_make_current_read ***/
2548783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.MakeCurrentReadSGI = Fake_glXMakeCurrentReadSGI;
25497cf50e137da497a590ec9001a9918972a6246142Brian Paul   /*glx.GetCurrentReadDrawableSGI = Fake_glXGetCurrentReadDrawableSGI;*/
2550783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2551b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_video_source ***/
2552b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#if defined(_VL_H)
2553783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.CreateGLXVideoSourceSGIX = Fake_glXCreateGLXVideoSourceSGIX;
2554783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.DestroyGLXVideoSourceSGIX = Fake_glXDestroyGLXVideoSourceSGIX;
2555783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul#endif
2556783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2557b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_EXT_import_context ***/
2558783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.FreeContextEXT = Fake_glXFreeContextEXT;
2559783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.GetContextIDEXT = Fake_glXGetContextIDEXT;
25607cf50e137da497a590ec9001a9918972a6246142Brian Paul   /*glx.GetCurrentDisplayEXT = Fake_glXGetCurrentDisplayEXT;*/
2561783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.ImportContextEXT = Fake_glXImportContextEXT;
2562783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.QueryContextInfoEXT = Fake_glXQueryContextInfoEXT;
25634536021a62e02fceaa6e8eb889b0f61743109cc4Brian Paul
2564b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGIX_fbconfig ***/
2565783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.GetFBConfigAttribSGIX = Fake_glXGetFBConfigAttribSGIX;
2566783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.ChooseFBConfigSGIX = Fake_glXChooseFBConfigSGIX;
2567783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.CreateGLXPixmapWithConfigSGIX = Fake_glXCreateGLXPixmapWithConfigSGIX;
2568783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.CreateContextWithConfigSGIX = Fake_glXCreateContextWithConfigSGIX;
2569783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.GetVisualFromFBConfigSGIX = Fake_glXGetVisualFromFBConfigSGIX;
2570783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.GetFBConfigFromVisualSGIX = Fake_glXGetFBConfigFromVisualSGIX;
2571783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2572b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGIX_pbuffer ***/
2573783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.CreateGLXPbufferSGIX = Fake_glXCreateGLXPbufferSGIX;
2574783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.DestroyGLXPbufferSGIX = Fake_glXDestroyGLXPbufferSGIX;
2575783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.QueryGLXPbufferSGIX = Fake_glXQueryGLXPbufferSGIX;
2576783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.SelectEventSGIX = Fake_glXSelectEventSGIX;
2577783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.GetSelectedEventSGIX = Fake_glXGetSelectedEventSGIX;
2578783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2579b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGI_cushion ***/
2580783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.CushionSGI = Fake_glXCushionSGI;
2581783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2582b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGIX_video_resize ***/
2583783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.BindChannelToWindowSGIX = Fake_glXBindChannelToWindowSGIX;
2584783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.ChannelRectSGIX = Fake_glXChannelRectSGIX;
2585783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.QueryChannelRectSGIX = Fake_glXQueryChannelRectSGIX;
2586783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.QueryChannelDeltasSGIX = Fake_glXQueryChannelDeltasSGIX;
2587783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.ChannelRectSyncSGIX = Fake_glXChannelRectSyncSGIX;
2588783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2589b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGIX_dmbuffer **/
2590b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#if defined(_DM_BUFFER_H_)
2591783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.AssociateDMPbufferSGIX = NULL;
2592783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul#endif
2593783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2594b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGIX_swap_group ***/
2595783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.JoinSwapGroupSGIX = Fake_glXJoinSwapGroupSGIX;
2596783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2597b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGIX_swap_barrier ***/
2598783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.BindSwapBarrierSGIX = Fake_glXBindSwapBarrierSGIX;
2599783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.QueryMaxSwapBarriersSGIX = Fake_glXQueryMaxSwapBarriersSGIX;
2600783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2601b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SUN_get_transparent_index ***/
2602783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.GetTransparentIndexSUN = Fake_glXGetTransparentIndexSUN;
26034536021a62e02fceaa6e8eb889b0f61743109cc4Brian Paul
2604b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_MESA_copy_sub_buffer ***/
2605426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CopySubBufferMESA = Fake_glXCopySubBufferMESA;
2606426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2607b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_MESA_release_buffers ***/
2608426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.ReleaseBuffersMESA = Fake_glXReleaseBuffersMESA;
2609426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2610b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_MESA_pixmap_colormap ***/
2611426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CreateGLXPixmapMESA = Fake_glXCreateGLXPixmapMESA;
2612426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2613b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_MESA_set_3dfx_mode ***/
2614426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.Set3DfxModeMESA = Fake_glXSet3DfxModeMESA;
2615426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2616426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   return &glx;
2617426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2618