fakeglx.c revision 3265fe5f8e47bfa42dd9e5e4a0e717816ad058a0
13265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul/* $Id: fakeglx.c,v 1.68 2002/10/05 03:02:34 brianp Exp $ */
2afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
3afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
4afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Mesa 3-D graphics library
53de5462ab1bb00f534c6f3d10eeb3b422f04c7c5Brian Paul * Version:  4.1
65e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen *
78d687e7e58a148f3f16573636023e54755372010Brian Paul * Copyright (C) 1999-2002  Brian Paul   All Rights Reserved.
85e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen *
9afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Permission is hereby granted, free of charge, to any person obtaining a
10afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * copy of this software and associated documentation files (the "Software"),
11afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * to deal in the Software without restriction, including without limitation
12afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * and/or sell copies of the Software, and to permit persons to whom the
14afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Software is furnished to do so, subject to the following conditions:
155e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen *
16afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * The above copyright notice and this permission notice shall be included
17afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * in all copies or substantial portions of the Software.
185e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen *
19afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
22afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
26afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
27afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
28afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
2936cfa38760cc2bd91c08b66bb62c4b6cf9eb5454Brian Paul * This is an emulation of the GLX API which allows Mesa/GLX-based programs
3036cfa38760cc2bd91c08b66bb62c4b6cf9eb5454Brian Paul * to run on X servers which do not have the real GLX extension.
31afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *
32afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Thanks to the contributors:
33afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *
34ddf69f247fdb246b99ef6525fcfa6eda7b2e2aa7Brian Paul * Initial version:  Philip Brown (phil@bolthole.com)
35afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Better glXGetConfig() support: Armin Liebchen (liebchen@asylum.cs.utah.edu)
36afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Further visual-handling refinements: Wolfram Gloger
37afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *    (wmglo@Dent.MED.Uni-Muenchen.DE).
38afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *
39afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Notes:
40afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *   Don't be fooled, stereo isn't supported yet.
41afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
42afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
43afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
44afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
45fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul#include "glxheader.h"
46426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul#include "glxapi.h"
47afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#include "GL/xmesa.h"
48afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#include "context.h"
49afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#include "config.h"
50afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#include "macros.h"
517cf50e137da497a590ec9001a9918972a6246142Brian Paul#include "mem.h"
5271dea349d2be623b7819389428b0d6a124e8d184Brian Paul#include "mmath.h"
535e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen#include "mtypes.h"
5471dea349d2be623b7819389428b0d6a124e8d184Brian Paul#include "xfonts.h"
55afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#include "xmesaP.h"
56afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
57afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
5878fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul/* This indicates the client-side GLX API and GLX encoder version. */
5978fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul#define CLIENT_MAJOR_VERSION 1
60a573803ed3fe9ef6489f45bd4c5455b77cb33a43Brian Paul#define CLIENT_MINOR_VERSION 4  /* but don't have 1.3's pbuffers, etc yet */
6178fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul
6278fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul/* This indicates the server-side GLX decoder version.
63ba57e5297d60eef37e43dd4d7f10d1e62f5e97ceBrian Paul * GLX 1.4 indicates OpenGL 1.3 support
6478fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul */
6578fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul#define SERVER_MAJOR_VERSION 1
66ba57e5297d60eef37e43dd4d7f10d1e62f5e97ceBrian Paul#define SERVER_MINOR_VERSION 4
6778fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul
6878fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul/* This is appended onto the glXGetClient/ServerString version strings. */
693de5462ab1bb00f534c6f3d10eeb3b422f04c7c5Brian Paul#define MESA_GLX_VERSION "Mesa 4.1"
7078fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul
7178fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul/* Who implemented this GLX? */
7278fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul#define VENDOR "Brian Paul"
7378fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul
7478fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul
75afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
7643c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul/* Silence compiler warnings */
77e7b16b74bf5d13331b5a88bbbbb9096560297b63Brian Paulextern void Fake_glXDummyFunc( void );
7843c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paulvoid Fake_glXDummyFunc( void )
7943c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul{
8043c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul   (void) kernel8;
8143c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul   (void) DitherValues;
8243c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul   (void) HPCR_DRGB;
8343c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul   (void) kernel1;
8443c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul}
8543c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul
8643c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul
877cf50e137da497a590ec9001a9918972a6246142Brian Paul/*
887cf50e137da497a590ec9001a9918972a6246142Brian Paul * Our fake GLX context will contain a "real" GLX context and an XMesa context.
897cf50e137da497a590ec9001a9918972a6246142Brian Paul *
907cf50e137da497a590ec9001a9918972a6246142Brian Paul * Note that a pointer to a __GLXcontext is a pointer to a fake_glx_context,
917cf50e137da497a590ec9001a9918972a6246142Brian Paul * and vice versa.
927cf50e137da497a590ec9001a9918972a6246142Brian Paul *
937cf50e137da497a590ec9001a9918972a6246142Brian Paul * We really just need this structure in order to make the libGL functions
947cf50e137da497a590ec9001a9918972a6246142Brian Paul * glXGetCurrentContext(), glXGetCurrentDrawable() and glXGetCurrentDisplay()
957cf50e137da497a590ec9001a9918972a6246142Brian Paul * work correctly.
967cf50e137da497a590ec9001a9918972a6246142Brian Paul */
977cf50e137da497a590ec9001a9918972a6246142Brian Paulstruct fake_glx_context {
987cf50e137da497a590ec9001a9918972a6246142Brian Paul   __GLXcontext glxContext;   /* this MUST be first! */
997cf50e137da497a590ec9001a9918972a6246142Brian Paul   XMesaContext xmesaContext;
1007cf50e137da497a590ec9001a9918972a6246142Brian Paul};
10143c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul
102afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
103afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1047cf50e137da497a590ec9001a9918972a6246142Brian Paul/**********************************************************************/
1057cf50e137da497a590ec9001a9918972a6246142Brian Paul/***                       GLX Visual Code                          ***/
1067cf50e137da497a590ec9001a9918972a6246142Brian Paul/**********************************************************************/
1077cf50e137da497a590ec9001a9918972a6246142Brian Paul
1087cf50e137da497a590ec9001a9918972a6246142Brian Paul#define DONT_CARE -1
1097cf50e137da497a590ec9001a9918972a6246142Brian Paul
110afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
111afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#define MAX_VISUALS 100
112afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XMesaVisual VisualTable[MAX_VISUALS];
113afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic int NumVisuals = 0;
114afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
115afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
116afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
117afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * This struct and some code fragments borrowed
118afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * from Mark Kilgard's GLUT library.
119afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
120afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgtypedef struct _OverlayInfo {
121afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg  /* Avoid 64-bit portability problems by being careful to use
122afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg     longs due to the way XGetWindowProperty is specified. Note
123afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg     that these parameters are passed as CARD32s over X
124afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg     protocol. */
125afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg  unsigned long overlay_visual;
126afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg  long transparent_type;
127afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg  long value;
128afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg  long layer;
129afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} OverlayInfo;
130afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
131afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
132afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
133afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* Macro to handle c_class vs class field name in XVisualInfo struct */
134afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#if defined(__cplusplus) || defined(c_plusplus)
135afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#define CLASS c_class
136afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#else
137afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#define CLASS class
138afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#endif
139afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
140afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
141afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
142afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
143afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
144afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Test if the given XVisualInfo is usable for Mesa rendering.
145afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
146afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic GLboolean is_usable_visual( XVisualInfo *vinfo )
147afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
148afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   switch (vinfo->CLASS) {
149afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case StaticGray:
150afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GrayScale:
151afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* Any StaticGray/GrayScale visual works in RGB or CI mode */
152afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return GL_TRUE;
153afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case StaticColor:
154afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case PseudoColor:
155afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 /* Any StaticColor/PseudoColor visual of at least 4 bits */
156afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 if (vinfo->depth>=4) {
157afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    return GL_TRUE;
158afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 }
159afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 else {
160afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    return GL_FALSE;
161afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 }
162afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case TrueColor:
163afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case DirectColor:
164afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 /* Any depth of TrueColor or DirectColor works in RGB mode */
165afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return GL_TRUE;
166afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      default:
167afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 /* This should never happen */
168afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return GL_FALSE;
169afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
170afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
171afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
172afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
173afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
174afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
175afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return the level (overlay, normal, underlay) of a given XVisualInfo.
176afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input:  dpy - the X display
177afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         vinfo - the XVisualInfo to test
178afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return:  level of the visual:
179afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *             0 = normal planes
180afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *            >0 = overlay planes
181afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *            <0 = underlay planes
182afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
183afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic int level_of_visual( Display *dpy, XVisualInfo *vinfo )
184afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
185afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   Atom overlayVisualsAtom;
186afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   OverlayInfo *overlay_info = NULL;
187afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int numOverlaysPerScreen;
188afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   Status status;
189afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   Atom actualType;
190afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int actualFormat;
191afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   unsigned long sizeData, bytesLeft;
192afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int i;
193afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
194afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /*
195afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * The SERVER_OVERLAY_VISUALS property on the root window contains
196afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * a list of overlay visuals.  Get that list now.
197afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    */
198afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   overlayVisualsAtom = XInternAtom(dpy,"SERVER_OVERLAY_VISUALS", True);
199afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (overlayVisualsAtom == None) {
200afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return 0;
201afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
202afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
203afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   status = XGetWindowProperty(dpy, RootWindow( dpy, vinfo->screen ),
204afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               overlayVisualsAtom, 0L, (long) 10000, False,
205afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               overlayVisualsAtom, &actualType, &actualFormat,
206afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               &sizeData, &bytesLeft,
207afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               (unsigned char **) &overlay_info );
208afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
209afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (status != Success || actualType != overlayVisualsAtom ||
210afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg       actualFormat != 32 || sizeData < 4) {
211afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* something went wrong */
212afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      XFree((void *) overlay_info);
213afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return 0;
214afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
215afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
216afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* search the overlay visual list for the visual ID of interest */
217afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   numOverlaysPerScreen = (int) (sizeData / 4);
218afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   for (i=0;i<numOverlaysPerScreen;i++) {
219afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      OverlayInfo *ov;
220afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      ov = overlay_info + i;
221afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (ov->overlay_visual==vinfo->visualid) {
222afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* found the visual */
223afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         if (/*ov->transparent_type==1 &&*/ ov->layer!=0) {
224afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            int level = ov->layer;
225afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            XFree((void *) overlay_info);
226afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            return level;
227afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
228afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         else {
229afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            XFree((void *) overlay_info);
230afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            return 0;
231afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
232afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
233afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
234afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
235afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* The visual ID was not found in the overlay list. */
236afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XFree((void *) overlay_info);
237afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return 0;
238afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
239afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
240afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
241afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
242afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
243afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
244afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Given an XVisualInfo and RGB, Double, and Depth buffer flags, save the
245afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * configuration in our list of GLX visuals.
246afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
247afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XMesaVisual
248afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgsave_glx_visual( Display *dpy, XVisualInfo *vinfo,
249afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                 GLboolean rgbFlag, GLboolean alphaFlag, GLboolean dbFlag,
250afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                 GLboolean stereoFlag,
251afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                 GLint depth_size, GLint stencil_size,
252b2e460018375f699198073a6167e0ee96ba1d267Brian Paul                 GLint accumRedSize, GLint accumGreenSize,
253b2e460018375f699198073a6167e0ee96ba1d267Brian Paul                 GLint accumBlueSize, GLint accumAlphaSize,
254b2e460018375f699198073a6167e0ee96ba1d267Brian Paul                 GLint level )
255afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
256afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLboolean ximageFlag = GL_TRUE;
257afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaVisual xmvis;
258afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLint i;
259afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLboolean comparePointers;
260afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
261afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (dbFlag) {
262afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* Check if the MESA_BACK_BUFFER env var is set */
263afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      char *backbuffer = getenv("MESA_BACK_BUFFER");
264afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (backbuffer) {
265afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         if (backbuffer[0]=='p' || backbuffer[0]=='P') {
266afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            ximageFlag = GL_FALSE;
267afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
268afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         else if (backbuffer[0]=='x' || backbuffer[0]=='X') {
269afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            ximageFlag = GL_TRUE;
270afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
271afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         else {
272d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul            _mesa_warning(NULL, "Mesa: invalid value for MESA_BACK_BUFFER environment variable, using an XImage.");
273afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
274afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
275afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
276afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
277afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* Comparing IDs uses less memory but sometimes fails. */
278afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* XXX revisit this after 3.0 is finished. */
279afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (getenv("MESA_GLX_VISUAL_HACK"))
280afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      comparePointers = GL_TRUE;
281afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else
282afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      comparePointers = GL_FALSE;
283afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
284afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* First check if a matching visual is already in the list */
285afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   for (i=0; i<NumVisuals; i++) {
286afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      XMesaVisual v = VisualTable[i];
287afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (v->display == dpy
288afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg          && v->level == level
289afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg          && v->ximage_flag == ximageFlag
2901832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && v->mesa_visual.rgbMode == rgbFlag
2911832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && v->mesa_visual.doubleBufferMode == dbFlag
2921832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && v->mesa_visual.stereoMode == stereoFlag
2931832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && (v->mesa_visual.alphaBits > 0) == alphaFlag
2941832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && (v->mesa_visual.depthBits >= depth_size || depth_size == 0)
2951832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && (v->mesa_visual.stencilBits >= stencil_size || stencil_size == 0)
2961832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && (v->mesa_visual.accumRedBits >= accumRedSize || accumRedSize == 0)
2971832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && (v->mesa_visual.accumGreenBits >= accumGreenSize || accumGreenSize == 0)
2981832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && (v->mesa_visual.accumBlueBits >= accumBlueSize || accumBlueSize == 0)
2991832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && (v->mesa_visual.accumAlphaBits >= accumAlphaSize || accumAlphaSize == 0)) {
300afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* now either compare XVisualInfo pointers or visual IDs */
301d0247f53aea8fa8677aadc8a00f75c8993be9ebcBrian Paul         if ((!comparePointers && v->visinfo->visualid == vinfo->visualid)
302afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg             || (comparePointers && v->vishandle == vinfo)) {
303afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            return v;
304afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
305afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
306afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
307afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
308afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* Create a new visual and add it to the list. */
309afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
310d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul   if (NumVisuals >= MAX_VISUALS) {
311d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul      _mesa_problem(NULL, "GLX Error: maximum number of visuals exceeded");
312afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return NULL;
313afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
314afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
315c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul   xmvis = XMesaCreateVisual( dpy, vinfo, rgbFlag, alphaFlag, dbFlag,
316c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul                              stereoFlag, ximageFlag,
317c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul                              depth_size, stencil_size,
318c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul                              accumRedSize, accumBlueSize,
319c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul                              accumBlueSize, accumAlphaSize, 0, level,
320c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul                              GLX_NONE_EXT );
321afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (xmvis) {
322afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      VisualTable[NumVisuals] = xmvis;
323afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      NumVisuals++;
324afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
325afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return xmvis;
326afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
327afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
328afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
329afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
330afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
331afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Create a GLX visual from a regular XVisualInfo.
332ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * This is called when Fake GLX is given an XVisualInfo which wasn't
333ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * returned by glXChooseVisual.  Since this is the first time we're
334ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * considering this visual we'll take a guess at reasonable values
335ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * for depth buffer size, stencil size, accum size, etc.
336ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * This is the best we can do with a client-side emulation of GLX.
337afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
338afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XMesaVisual
339afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgcreate_glx_visual( Display *dpy, XVisualInfo *visinfo )
340afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
341afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int vislevel;
342afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
343afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   vislevel = level_of_visual( dpy, visinfo );
344afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (vislevel) {
345afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* Configure this visual as a CI, single-buffered overlay */
346afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return save_glx_visual( dpy, visinfo,
347afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                              GL_FALSE,  /* rgb */
348afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                              GL_FALSE,  /* alpha */
349afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                              GL_FALSE,  /* double */
350afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                              GL_FALSE,  /* stereo */
351afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                              0,         /* depth bits */
352afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                              0,         /* stencil bits */
353b2e460018375f699198073a6167e0ee96ba1d267Brian Paul                              0,0,0,0,   /* accum bits */
354afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                              vislevel   /* level */
355afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                            );
356afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
357afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else if (is_usable_visual( visinfo )) {
3588f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul      if (getenv("MESA_GLX_FORCE_CI")) {
3598f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul         /* Configure this visual as a COLOR INDEX visual. */
3608f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul         return save_glx_visual( dpy, visinfo,
3618f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 GL_FALSE,   /* rgb */
3628f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 GL_FALSE,  /* alpha */
3638f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 GL_TRUE,   /* double */
3648f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 GL_FALSE,  /* stereo */
3658f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 DEFAULT_SOFTWARE_DEPTH_BITS,
3668f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 8 * sizeof(GLstencil),
3678f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 0 * sizeof(GLaccum), /* r */
3688f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 0 * sizeof(GLaccum), /* g */
3698f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 0 * sizeof(GLaccum), /* b */
3708f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 0 * sizeof(GLaccum), /* a */
3718f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 0          /* level */
3728f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                               );
3738f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul      }
3748f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul      else {
3758f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul         /* Configure this visual as RGB, double-buffered, depth-buffered. */
3768f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul         /* This is surely wrong for some people's needs but what else */
3778f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul         /* can be done?  They should use glXChooseVisual(). */
3788f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul         return save_glx_visual( dpy, visinfo,
3798f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 GL_TRUE,   /* rgb */
3808f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 GL_FALSE,  /* alpha */
3818f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 GL_TRUE,   /* double */
3828f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 GL_FALSE,  /* stereo */
3838f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 DEFAULT_SOFTWARE_DEPTH_BITS,
3848f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 8 * sizeof(GLstencil),
3858f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 8 * sizeof(GLaccum), /* r */
3868f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 8 * sizeof(GLaccum), /* g */
3878f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 8 * sizeof(GLaccum), /* b */
3888f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 8 * sizeof(GLaccum), /* a */
3898f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 0          /* level */
3908f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                               );
3918f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul      }
392afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
393afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else {
394d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul      _mesa_warning(NULL, "Mesa: error in glXCreateContext: bad visual\n");
395afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return NULL;
396afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
397afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
398afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
399afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
400afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
401afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
402afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Find the GLX visual associated with an XVisualInfo.
403afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
404afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XMesaVisual
405afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgfind_glx_visual( Display *dpy, XVisualInfo *vinfo )
406afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
407afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int i;
408afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
409afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* First try to match pointers */
410afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   for (i=0;i<NumVisuals;i++) {
411afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (VisualTable[i]->display==dpy && VisualTable[i]->vishandle==vinfo) {
412afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return VisualTable[i];
413afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
414afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
415afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* try to match visual id */
416afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   for (i=0;i<NumVisuals;i++) {
417afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (VisualTable[i]->display==dpy
418afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg          && VisualTable[i]->visinfo->visualid == vinfo->visualid) {
419afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return VisualTable[i];
420afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
421afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
422afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return NULL;
423afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
424afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
425afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
426afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
427afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
428afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return the transparent pixel value for a GLX visual.
429afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input:  glxvis - the glx_visual
430afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return:  a pixel value or -1 if no transparent pixel
431afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
432afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic int transparent_pixel( XMesaVisual glxvis )
433afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
434afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   Display *dpy = glxvis->display;
435afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XVisualInfo *vinfo = glxvis->visinfo;
436afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   Atom overlayVisualsAtom;
437afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   OverlayInfo *overlay_info = NULL;
438afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int numOverlaysPerScreen;
439afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   Status status;
440afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   Atom actualType;
441afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int actualFormat;
442afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   unsigned long sizeData, bytesLeft;
443afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int i;
444afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
445afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /*
446afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * The SERVER_OVERLAY_VISUALS property on the root window contains
447afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * a list of overlay visuals.  Get that list now.
448afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    */
449afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   overlayVisualsAtom = XInternAtom(dpy,"SERVER_OVERLAY_VISUALS", True);
450afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (overlayVisualsAtom == None) {
451afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return -1;
452afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
453afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
454afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   status = XGetWindowProperty(dpy, RootWindow( dpy, vinfo->screen ),
455afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               overlayVisualsAtom, 0L, (long) 10000, False,
456afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               overlayVisualsAtom, &actualType, &actualFormat,
457afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               &sizeData, &bytesLeft,
458afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               (unsigned char **) &overlay_info );
459afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
460afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (status != Success || actualType != overlayVisualsAtom ||
461afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg       actualFormat != 32 || sizeData < 4) {
462afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* something went wrong */
463afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      XFree((void *) overlay_info);
464afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return -1;
465afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
466afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
467afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* search the overlay visual list for the visual ID of interest */
468afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   numOverlaysPerScreen = (int) (sizeData / 4);
469afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   for (i=0;i<numOverlaysPerScreen;i++) {
470afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      OverlayInfo *ov;
471afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      ov = overlay_info + i;
472afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (ov->overlay_visual==vinfo->visualid) {
473afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* found it! */
474afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         if (ov->transparent_type==0) {
475afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* type 0 indicates no transparency */
476afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            XFree((void *) overlay_info);
477afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            return -1;
478afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
479afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         else {
480afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* ov->value is the transparent pixel */
481afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            XFree((void *) overlay_info);
482afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            return ov->value;
483afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
484afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
485afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
486afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
487afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* The visual ID was not found in the overlay list. */
488afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XFree((void *) overlay_info);
489afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return -1;
490afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
491afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
492afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
493afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
494afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
495afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Try to get an X visual which matches the given arguments.
496afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
497afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XVisualInfo *get_visual( Display *dpy, int scr,
498afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg			        unsigned int depth, int xclass )
499afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
500afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XVisualInfo temp, *vis;
501afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   long mask;
502afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int n;
503afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   unsigned int default_depth;
504afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int default_class;
505afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
506afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   mask = VisualScreenMask | VisualDepthMask | VisualClassMask;
507afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   temp.screen = scr;
508afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   temp.depth = depth;
509afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   temp.CLASS = xclass;
510afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
511afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   default_depth = DefaultDepth(dpy,scr);
512afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   default_class = DefaultVisual(dpy,scr)->CLASS;
513afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
514afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (depth==default_depth && xclass==default_class) {
515afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* try to get root window's visual */
516afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      temp.visualid = DefaultVisual(dpy,scr)->visualid;
517afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      mask |= VisualIDMask;
518afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
519afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
520afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   vis = XGetVisualInfo( dpy, mask, &temp, &n );
521afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
522afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* In case bits/pixel > 24, make sure color channels are still <=8 bits.
523afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * An SGI Infinite Reality system, for example, can have 30bpp pixels:
524afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * 10 bits per color channel.  Mesa's limited to a max of 8 bits/channel.
525afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    */
526afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (vis && depth > 24 && (xclass==TrueColor || xclass==DirectColor)) {
52771dea349d2be623b7819389428b0d6a124e8d184Brian Paul      if (_mesa_bitcount((GLuint) vis->red_mask  ) <= 8 &&
52871dea349d2be623b7819389428b0d6a124e8d184Brian Paul          _mesa_bitcount((GLuint) vis->green_mask) <= 8 &&
52971dea349d2be623b7819389428b0d6a124e8d184Brian Paul          _mesa_bitcount((GLuint) vis->blue_mask ) <= 8) {
530afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return vis;
531afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
532afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      else {
533afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         XFree((void *) vis);
534afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return NULL;
535afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
536afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
537afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
538afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return vis;
539afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
540afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
541afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
542afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
543afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
544afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Retrieve the value of the given environment variable and find
545afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * the X visual which matches it.
546afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input:  dpy - the display
547afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         screen - the screen number
548afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         varname - the name of the environment variable
549afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return:  an XVisualInfo pointer to NULL if error.
550afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
551afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XVisualInfo *get_env_visual(Display *dpy, int scr, const char *varname)
552afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
553afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   char value[100], type[100];
554afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int depth, xclass = -1;
555afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XVisualInfo *vis;
556afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
557afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (!getenv( varname )) {
558afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return NULL;
559afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
560afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
561afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   strncpy( value, getenv(varname), 100 );
562afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   value[99] = 0;
563afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
564afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   sscanf( value, "%s %d", type, &depth );
565afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
566afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (strcmp(type,"TrueColor")==0)          xclass = TrueColor;
567afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else if (strcmp(type,"DirectColor")==0)   xclass = DirectColor;
568afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else if (strcmp(type,"PseudoColor")==0)   xclass = PseudoColor;
569afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else if (strcmp(type,"StaticColor")==0)   xclass = StaticColor;
570afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else if (strcmp(type,"GrayScale")==0)     xclass = GrayScale;
571afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else if (strcmp(type,"StaticGray")==0)    xclass = StaticGray;
572afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
573afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (xclass>-1 && depth>0) {
574afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      vis = get_visual( dpy, scr, depth, xclass );
575afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (vis) {
576afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return vis;
577afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
578afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
579afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
580d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul   {
581d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul      char s[1000];
582d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul      sprintf(s, "Mesa: GLX unable to find visual class=%s, depth=%d.\n",
583d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul              type, depth );
584d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul      _mesa_warning(NULL, s);
585d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul   }
586d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul
587afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return NULL;
588afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
589afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
590afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
591afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
592afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
593afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Select an X visual which satisfies the RGBA/CI flag and minimum depth.
594afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input:  dpy, screen - X display and screen number
595afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         rgba - GL_TRUE = RGBA mode, GL_FALSE = CI mode
596afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         min_depth - minimum visual depth
597afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         preferred_class - preferred GLX visual class or DONT_CARE
598afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return:  pointer to an XVisualInfo or NULL.
599afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
600afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XVisualInfo *choose_x_visual( Display *dpy, int screen,
601afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg				     GLboolean rgba, int min_depth,
602afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                                     int preferred_class )
603afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
604afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XVisualInfo *vis;
605db6aa58267cad3f502f03ab80b9deb6b75320a91Brian Paul   int xclass, visclass = 0;
606afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int depth;
607afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
608afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (rgba) {
609afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      Atom hp_cr_maps = XInternAtom(dpy, "_HP_RGB_SMOOTH_MAP_LIST", True);
610afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* First see if the MESA_RGB_VISUAL env var is defined */
611afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      vis = get_env_visual( dpy, screen, "MESA_RGB_VISUAL" );
612afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (vis) {
613afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return vis;
614afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
615afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* Otherwise, search for a suitable visual */
616afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (preferred_class==DONT_CARE) {
617afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         for (xclass=0;xclass<6;xclass++) {
618afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            switch (xclass) {
619afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 0:  visclass = TrueColor;    break;
620afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 1:  visclass = DirectColor;  break;
621afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 2:  visclass = PseudoColor;  break;
622afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 3:  visclass = StaticColor;  break;
623afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 4:  visclass = GrayScale;    break;
624afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 5:  visclass = StaticGray;   break;
625afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
626afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            if (min_depth==0) {
627afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               /* start with shallowest */
628afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               for (depth=0;depth<=32;depth++) {
629afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  if (visclass==TrueColor && depth==8 && !hp_cr_maps) {
630afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     /* Special case:  try to get 8-bit PseudoColor before */
631afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     /* 8-bit TrueColor */
632afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     vis = get_visual( dpy, screen, 8, PseudoColor );
633afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     if (vis) {
634afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                        return vis;
635afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     }
636afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  }
637afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  vis = get_visual( dpy, screen, depth, visclass );
638afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  if (vis) {
639afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     return vis;
640afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  }
641afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               }
642afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
643afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            else {
644afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               /* start with deepest */
645afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               for (depth=32;depth>=min_depth;depth--) {
646afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  if (visclass==TrueColor && depth==8 && !hp_cr_maps) {
647afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     /* Special case:  try to get 8-bit PseudoColor before */
648afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     /* 8-bit TrueColor */
649afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     vis = get_visual( dpy, screen, 8, PseudoColor );
650afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     if (vis) {
651afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                        return vis;
652afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     }
653afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  }
654afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  vis = get_visual( dpy, screen, depth, visclass );
655afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  if (vis) {
656afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     return vis;
657afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  }
658afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               }
659afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
660afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
661afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
662afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      else {
663afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* search for a specific visual class */
664afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         switch (preferred_class) {
665afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_TRUE_COLOR_EXT:    visclass = TrueColor;    break;
666afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_DIRECT_COLOR_EXT:  visclass = DirectColor;  break;
667afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_PSEUDO_COLOR_EXT:  visclass = PseudoColor;  break;
668afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_STATIC_COLOR_EXT:  visclass = StaticColor;  break;
669afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_GRAY_SCALE_EXT:    visclass = GrayScale;    break;
670afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_STATIC_GRAY_EXT:   visclass = StaticGray;   break;
671afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            default:   return NULL;
672afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
673afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         if (min_depth==0) {
674afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* start with shallowest */
675afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            for (depth=0;depth<=32;depth++) {
676afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               vis = get_visual( dpy, screen, depth, visclass );
677afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               if (vis) {
678afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  return vis;
679afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               }
680afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
681afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
682afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         else {
683afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* start with deepest */
684afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            for (depth=32;depth>=min_depth;depth--) {
685afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               vis = get_visual( dpy, screen, depth, visclass );
686afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               if (vis) {
687afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  return vis;
688afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               }
689afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
690afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
691afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
692afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
693afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else {
694afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* First see if the MESA_CI_VISUAL env var is defined */
695afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      vis = get_env_visual( dpy, screen, "MESA_CI_VISUAL" );
696afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (vis) {
697afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return vis;
698afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
699afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* Otherwise, search for a suitable visual, starting with shallowest */
700afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (preferred_class==DONT_CARE) {
701afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         for (xclass=0;xclass<4;xclass++) {
702afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            switch (xclass) {
703afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 0:  visclass = PseudoColor;  break;
704afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 1:  visclass = StaticColor;  break;
705afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 2:  visclass = GrayScale;    break;
706afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 3:  visclass = StaticGray;   break;
707afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
708afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* try 8-bit up through 16-bit */
709afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            for (depth=8;depth<=16;depth++) {
710afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               vis = get_visual( dpy, screen, depth, visclass );
711afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               if (vis) {
712afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  return vis;
713afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               }
714afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
715afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* try min_depth up to 8-bit */
716afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            for (depth=min_depth;depth<8;depth++) {
717afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               vis = get_visual( dpy, screen, depth, visclass );
718afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               if (vis) {
719afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  return vis;
720afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               }
721afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
722afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
723afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
724afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      else {
725afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* search for a specific visual class */
726afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         switch (preferred_class) {
727afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_TRUE_COLOR_EXT:    visclass = TrueColor;    break;
728afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_DIRECT_COLOR_EXT:  visclass = DirectColor;  break;
729afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_PSEUDO_COLOR_EXT:  visclass = PseudoColor;  break;
730afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_STATIC_COLOR_EXT:  visclass = StaticColor;  break;
731afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_GRAY_SCALE_EXT:    visclass = GrayScale;    break;
732afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_STATIC_GRAY_EXT:   visclass = StaticGray;   break;
733afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            default:   return NULL;
734afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
735afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* try 8-bit up through 16-bit */
736afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         for (depth=8;depth<=16;depth++) {
737afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            vis = get_visual( dpy, screen, depth, visclass );
738afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            if (vis) {
739afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               return vis;
740afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
741afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
742afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* try min_depth up to 8-bit */
743afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         for (depth=min_depth;depth<8;depth++) {
744afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            vis = get_visual( dpy, screen, depth, visclass );
745afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            if (vis) {
746afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               return vis;
747afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
748afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
749afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
750afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
751afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
752afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* didn't find a visual */
753afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return NULL;
754afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
755afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
756afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
757afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
758afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
759afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Find the deepest X over/underlay visual of at least min_depth.
760afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input:  dpy, screen - X display and screen number
761afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         level - the over/underlay level
762afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         trans_type - transparent pixel type: GLX_NONE_EXT,
763afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *                      GLX_TRANSPARENT_RGB_EXT, GLX_TRANSPARENT_INDEX_EXT,
764afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *                      or DONT_CARE
765afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         trans_value - transparent pixel value or DONT_CARE
766afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         min_depth - minimum visual depth
767afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         preferred_class - preferred GLX visual class or DONT_CARE
768afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return:  pointer to an XVisualInfo or NULL.
769afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
770afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XVisualInfo *choose_x_overlay_visual( Display *dpy, int scr,
77142f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul                                             GLboolean rgbFlag,
772afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                                             int level, int trans_type,
773afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                                             int trans_value,
774afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                                             int min_depth,
775afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                                             int preferred_class )
776afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
777afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   Atom overlayVisualsAtom;
778afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   OverlayInfo *overlay_info;
779afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int numOverlaysPerScreen;
780afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   Status status;
781afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   Atom actualType;
782afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int actualFormat;
783afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   unsigned long sizeData, bytesLeft;
784afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int i;
785afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XVisualInfo *deepvis;
786afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int deepest;
787afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
788afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /*DEBUG int tt, tv; */
789afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
790afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   switch (preferred_class) {
791afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_TRUE_COLOR_EXT:    preferred_class = TrueColor;    break;
792afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_DIRECT_COLOR_EXT:  preferred_class = DirectColor;  break;
793afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_PSEUDO_COLOR_EXT:  preferred_class = PseudoColor;  break;
794afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_STATIC_COLOR_EXT:  preferred_class = StaticColor;  break;
795afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_GRAY_SCALE_EXT:    preferred_class = GrayScale;    break;
796afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_STATIC_GRAY_EXT:   preferred_class = StaticGray;   break;
797afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      default:                    preferred_class = DONT_CARE;
798afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
799afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
800afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /*
801afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * The SERVER_OVERLAY_VISUALS property on the root window contains
802afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * a list of overlay visuals.  Get that list now.
803afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    */
804afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   overlayVisualsAtom = XInternAtom(dpy,"SERVER_OVERLAY_VISUALS", True);
805afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (overlayVisualsAtom == (Atom) None) {
806afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return NULL;
807afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
808afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
809afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   status = XGetWindowProperty(dpy, RootWindow( dpy, scr ),
810afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               overlayVisualsAtom, 0L, (long) 10000, False,
811afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               overlayVisualsAtom, &actualType, &actualFormat,
812afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               &sizeData, &bytesLeft,
813afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               (unsigned char **) &overlay_info );
814afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
815afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (status != Success || actualType != overlayVisualsAtom ||
816afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg       actualFormat != 32 || sizeData < 4) {
817afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* something went wrong */
818afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return NULL;
819afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
820afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
821afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* Search for the deepest overlay which satisifies all criteria. */
822afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   deepest = min_depth;
823afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   deepvis = NULL;
824afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
825afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   numOverlaysPerScreen = (int) (sizeData / 4);
826afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   for (i=0;i<numOverlaysPerScreen;i++) {
827afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      XVisualInfo *vislist, vistemplate;
828afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      int count;
829afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      OverlayInfo *ov;
830afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      ov = overlay_info + i;
831afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
832afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (ov->layer!=level) {
833afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* failed overlay level criteria */
834afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         continue;
835afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
836afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (!(trans_type==DONT_CARE
837afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            || (trans_type==GLX_TRANSPARENT_INDEX_EXT
838afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                && ov->transparent_type>0)
839afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            || (trans_type==GLX_NONE_EXT && ov->transparent_type==0))) {
840afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* failed transparent pixel type criteria */
841afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         continue;
842afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
843afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (trans_value!=DONT_CARE && trans_value!=ov->value) {
844afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* failed transparent pixel value criteria */
845afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         continue;
846afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
847afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
848afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* get XVisualInfo and check the depth */
849afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      vistemplate.visualid = ov->overlay_visual;
850afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      vistemplate.screen = scr;
851afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      vislist = XGetVisualInfo( dpy, VisualIDMask | VisualScreenMask,
852afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                                &vistemplate, &count );
853afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
854afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (count!=1) {
855afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* something went wrong */
856afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         continue;
857afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
858afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (preferred_class!=DONT_CARE && preferred_class!=vislist->CLASS) {
859afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* wrong visual class */
860afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         continue;
861afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
862afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
86342f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      /* if RGB was requested, make sure we have True/DirectColor */
86442f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      if (rgbFlag && vislist->CLASS != TrueColor
86542f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul          && vislist->CLASS != DirectColor)
86642f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         continue;
86742f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul
86842f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      /* if CI was requested, make sure we have a color indexed visual */
86942f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      if (!rgbFlag
87042f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul          && (vislist->CLASS == TrueColor || vislist->CLASS == DirectColor))
87142f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         continue;
87242f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul
873afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (deepvis==NULL || vislist->depth > deepest) {
874afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* YES!  found a satisfactory visual */
875afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         if (deepvis) {
87680af3614d88c0cac160e787de7f34b37e96cb626Brian Paul            XFree( deepvis );
877afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
878afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         deepest = vislist->depth;
879afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         deepvis = vislist;
880afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* DEBUG  tt = ov->transparent_type;*/
881afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* DEBUG  tv = ov->value; */
882afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
883afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
884afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
885afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*DEBUG
886afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (deepvis) {
887afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      printf("chose 0x%x:  layer=%d depth=%d trans_type=%d trans_value=%d\n",
888afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg             deepvis->visualid, level, deepvis->depth, tt, tv );
889afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
890afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg*/
891afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return deepvis;
892afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
893afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
894afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
8957cf50e137da497a590ec9001a9918972a6246142Brian Paul/**********************************************************************/
8967cf50e137da497a590ec9001a9918972a6246142Brian Paul/***                  Begin Fake GLX API Functions                  ***/
8977cf50e137da497a590ec9001a9918972a6246142Brian Paul/**********************************************************************/
8987cf50e137da497a590ec9001a9918972a6246142Brian Paul
899afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
9003265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paulstatic XMesaVisual choose_visual( Display *dpy, int screen, const int *list )
901afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
9023265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   const int *parselist;
903afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XVisualInfo *vis;
904afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int min_ci = 0;
905afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int min_red=0, min_green=0, min_blue=0;
906afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLboolean rgb_flag = GL_FALSE;
907afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLboolean alpha_flag = GL_FALSE;
908afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLboolean double_flag = GL_FALSE;
909afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLboolean stereo_flag = GL_FALSE;
910afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLint depth_size = 0;
911afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLint stencil_size = 0;
912b2e460018375f699198073a6167e0ee96ba1d267Brian Paul   GLint accumRedSize = 0;
913b2e460018375f699198073a6167e0ee96ba1d267Brian Paul   GLint accumGreenSize = 0;
914b2e460018375f699198073a6167e0ee96ba1d267Brian Paul   GLint accumBlueSize = 0;
915b2e460018375f699198073a6167e0ee96ba1d267Brian Paul   GLint accumAlphaSize = 0;
916afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int level = 0;
917afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int visual_type = DONT_CARE;
918afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int trans_type = DONT_CARE;
919afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int trans_value = DONT_CARE;
920e1210b176926349b258c7ec77b7f36716025c82aBrian Paul   GLint caveat = DONT_CARE;
9213265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   XMesaVisual xmvis = NULL;
922afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
923afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   parselist = list;
924afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
925afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   while (*parselist) {
926afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
927afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      switch (*parselist) {
928afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_USE_GL:
929afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    /* ignore */
930afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
931afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
932afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_BUFFER_SIZE:
933afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
934afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    min_ci = *parselist++;
935afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
936afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_LEVEL:
937afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
938afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            level = *parselist++;
939afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
940afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_RGBA:
941afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    rgb_flag = GL_TRUE;
942afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
943afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
944afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_DOUBLEBUFFER:
945afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    double_flag = GL_TRUE;
946afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
947afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
948afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_STEREO:
949afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            stereo_flag = GL_TRUE;
950afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            return NULL;
951afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_AUX_BUFFERS:
952afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    /* ignore */
953afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
954afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
955afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
956afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_RED_SIZE:
957afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
958afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    min_red = *parselist++;
959afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
960afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_GREEN_SIZE:
961afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
962afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    min_green = *parselist++;
963afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
964afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_BLUE_SIZE:
965afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
966afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    min_blue = *parselist++;
967afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
968afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_ALPHA_SIZE:
969afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
970afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            {
971afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               GLint size = *parselist++;
972afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               alpha_flag = size>0 ? 1 : 0;
973afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
974afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
975afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_DEPTH_SIZE:
976afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
977afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    depth_size = *parselist++;
978afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
979afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_STENCIL_SIZE:
980afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
981afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    stencil_size = *parselist++;
982afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
983afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_ACCUM_RED_SIZE:
984b2e460018375f699198073a6167e0ee96ba1d267Brian Paul	    parselist++;
985b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            {
986b2e460018375f699198073a6167e0ee96ba1d267Brian Paul               GLint size = *parselist++;
987b2e460018375f699198073a6167e0ee96ba1d267Brian Paul               accumRedSize = MAX2( accumRedSize, size );
988b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            }
989b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            break;
990afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_ACCUM_GREEN_SIZE:
991b2e460018375f699198073a6167e0ee96ba1d267Brian Paul	    parselist++;
992b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            {
993b2e460018375f699198073a6167e0ee96ba1d267Brian Paul               GLint size = *parselist++;
994b2e460018375f699198073a6167e0ee96ba1d267Brian Paul               accumGreenSize = MAX2( accumGreenSize, size );
995b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            }
996b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            break;
997afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_ACCUM_BLUE_SIZE:
998b2e460018375f699198073a6167e0ee96ba1d267Brian Paul	    parselist++;
999b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            {
1000b2e460018375f699198073a6167e0ee96ba1d267Brian Paul               GLint size = *parselist++;
1001b2e460018375f699198073a6167e0ee96ba1d267Brian Paul               accumBlueSize = MAX2( accumBlueSize, size );
1002b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            }
1003b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            break;
1004afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_ACCUM_ALPHA_SIZE:
1005afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
1006afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            {
1007afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               GLint size = *parselist++;
1008b2e460018375f699198073a6167e0ee96ba1d267Brian Paul               accumAlphaSize = MAX2( accumAlphaSize, size );
1009afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
1010afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
1011afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1012afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /*
1013afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg          * GLX_EXT_visual_info extension
1014afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg          */
1015afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         case GLX_X_VISUAL_TYPE_EXT:
1016afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            parselist++;
1017afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            visual_type = *parselist++;
1018afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            break;
1019afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         case GLX_TRANSPARENT_TYPE_EXT:
1020afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            parselist++;
1021afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            trans_type = *parselist++;
1022afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            break;
1023afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         case GLX_TRANSPARENT_INDEX_VALUE_EXT:
1024afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            parselist++;
1025afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            trans_value = *parselist++;
1026afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            break;
1027afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         case GLX_TRANSPARENT_RED_VALUE_EXT:
1028afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         case GLX_TRANSPARENT_GREEN_VALUE_EXT:
1029afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         case GLX_TRANSPARENT_BLUE_VALUE_EXT:
1030afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         case GLX_TRANSPARENT_ALPHA_VALUE_EXT:
1031afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    /* ignore */
1032afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
1033afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
1034afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
10355e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen
1036e1210b176926349b258c7ec77b7f36716025c82aBrian Paul         /*
1037e1210b176926349b258c7ec77b7f36716025c82aBrian Paul          * GLX_EXT_visual_info extension
1038e1210b176926349b258c7ec77b7f36716025c82aBrian Paul          */
1039e1210b176926349b258c7ec77b7f36716025c82aBrian Paul         case GLX_VISUAL_CAVEAT_EXT:
1040e1210b176926349b258c7ec77b7f36716025c82aBrian Paul            parselist++;
1041e1210b176926349b258c7ec77b7f36716025c82aBrian Paul            caveat = *parselist++; /* ignored for now */
1042e1210b176926349b258c7ec77b7f36716025c82aBrian Paul            break;
1043e1210b176926349b258c7ec77b7f36716025c82aBrian Paul
10443265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         /*
10453265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul          * FBConfig attribs.
10463265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul          */
10473265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         case GLX_RENDER_TYPE:
10483265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            parselist++;
10493265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            if (*parselist == GLX_RGBA_BIT) {
10503265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul               rgb_flag = GL_TRUE;
10513265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            }
10523265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            else if (*parselist == GLX_COLOR_INDEX_BIT) {
10533265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul               rgb_flag = GL_FALSE;
10543265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            }
10553265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            else if (*parselist == 0) {
10563265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul               rgb_flag = GL_TRUE;
10573265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            }
10583265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            parselist++;
10593265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            break;
10603265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         case GLX_DRAWABLE_TYPE:
10613265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            parselist++;
10623265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            if (*parselist & ~(GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT)) {
10633265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul               return NULL; /* bad bit */
10643265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            }
10653265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            parselist++;
10663265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            break;
10673265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul
1068afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case None:
1069afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
10703265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul
1071afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 default:
1072afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    /* undefined attribute */
10733265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            printf("unexpected attrib 0x%x\n", *parselist);
1074afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    return NULL;
1075afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
1076afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1077afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1078afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /*
1079afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * Since we're only simulating the GLX extension this function will never
1080afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * find any real GL visuals.  Instead, all we can do is try to find an RGB
1081afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * or CI visual of appropriate depth.  Other requested attributes such as
1082afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * double buffering, depth buffer, etc. will be associated with the X
1083afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * visual and stored in the VisualTable[].
1084afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    */
1085afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (level==0) {
1086afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* normal color planes */
1087afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (rgb_flag) {
1088afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* Get an RGB visual */
1089afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         int min_rgb = min_red + min_green + min_blue;
1090afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         if (min_rgb>1 && min_rgb<8) {
1091afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* a special case to be sure we can get a monochrome visual */
1092afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            min_rgb = 1;
1093afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
1094afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         vis = choose_x_visual( dpy, screen, rgb_flag, min_rgb, visual_type );
1095afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
1096afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      else {
1097afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* Get a color index visual */
1098afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         vis = choose_x_visual( dpy, screen, rgb_flag, min_ci, visual_type );
1099b2e460018375f699198073a6167e0ee96ba1d267Brian Paul         accumRedSize = accumGreenSize = accumBlueSize = accumAlphaSize = 0;
1100afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
1101afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1102afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else {
1103afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* over/underlay planes */
110442f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      if (rgb_flag) {
110542f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         /* rgba overlay */
110642f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         int min_rgb = min_red + min_green + min_blue;
110742f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         if (min_rgb>1 && min_rgb<8) {
110842f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul            /* a special case to be sure we can get a monochrome visual */
110942f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul            min_rgb = 1;
111042f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         }
111142f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         vis = choose_x_overlay_visual( dpy, screen, rgb_flag, level,
111242f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul                              trans_type, trans_value, min_rgb, visual_type );
111342f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      }
111442f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      else {
111542f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         /* color index overlay */
111642f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         vis = choose_x_overlay_visual( dpy, screen, rgb_flag, level,
111742f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul                              trans_type, trans_value, min_ci, visual_type );
111842f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      }
1119afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1120afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1121afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (vis) {
1122ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul      /* Note: we're not exactly obeying the glXChooseVisual rules here.
1123ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul       * When GLX_DEPTH_SIZE = 1 is specified we're supposed to choose the
11242c7e6334ec81c2fab2cce9e0fe52cd30256e37eaBrian Paul       * largest depth buffer size, which is 32bits/value.  Instead, we
1125ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul       * return 16 to maintain performance with earlier versions of Mesa.
1126ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul       */
11272c7e6334ec81c2fab2cce9e0fe52cd30256e37eaBrian Paul      if (depth_size > 24)
11282c7e6334ec81c2fab2cce9e0fe52cd30256e37eaBrian Paul         depth_size = 31;   /* 32 causes int overflow problems */
1129ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul      else if (depth_size > 16)
1130ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul         depth_size = 24;
11312c7e6334ec81c2fab2cce9e0fe52cd30256e37eaBrian Paul      else if (depth_size > 0)
11322c7e6334ec81c2fab2cce9e0fe52cd30256e37eaBrian Paul         depth_size = DEFAULT_SOFTWARE_DEPTH_BITS; /*16*/
11332c7e6334ec81c2fab2cce9e0fe52cd30256e37eaBrian Paul
1134ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul      /* we only support one size of stencil and accum buffers. */
1135ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul      if (stencil_size > 0)
1136ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul         stencil_size = STENCIL_BITS;
11376d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul      if (accumRedSize > 0 || accumGreenSize > 0 || accumBlueSize > 0 ||
11386d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul          accumAlphaSize > 0) {
1139b2e460018375f699198073a6167e0ee96ba1d267Brian Paul         accumRedSize = ACCUM_BITS;
1140b2e460018375f699198073a6167e0ee96ba1d267Brian Paul         accumGreenSize = ACCUM_BITS;
1141b2e460018375f699198073a6167e0ee96ba1d267Brian Paul         accumBlueSize = ACCUM_BITS;
11426d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul         accumAlphaSize = alpha_flag ? ACCUM_BITS : 0;
11436d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul      }
11446d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul
11453265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      xmvis = save_glx_visual( dpy, vis, rgb_flag, alpha_flag, double_flag,
11463265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul                               stereo_flag, depth_size, stencil_size,
11473265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul                               accumRedSize, accumGreenSize,
11483265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul                               accumBlueSize, accumAlphaSize, level );
1149afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1150afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
11513265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   return xmvis;
1152afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1153afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1154afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
11553265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paulstatic XVisualInfo *
11563265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian PaulFake_glXChooseVisual( Display *dpy, int screen, int *list )
11573265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul{
11583265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   XMesaVisual xmvis = choose_visual(dpy, screen, list);
11593265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   if (xmvis)
11603265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      return xmvis->vishandle;
11613265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   else
11623265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      return NULL;
11633265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul}
1164afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1165afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1166426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXContext
1167426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateContext( Display *dpy, XVisualInfo *visinfo,
1168426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                       GLXContext share_list, Bool direct )
1169afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1170afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaVisual glxvis;
11717cf50e137da497a590ec9001a9918972a6246142Brian Paul   struct fake_glx_context *glxCtx;
11725e1680ce1d8296b2182e8909856927bbeddf3b95Brian Paul   struct fake_glx_context *shareCtx = (struct fake_glx_context *) share_list;
117399aab341998e84d9fa208c525cae8021b3845812Brian Paul
117499aab341998e84d9fa208c525cae8021b3845812Brian Paul   if (!dpy || !visinfo)
117599aab341998e84d9fa208c525cae8021b3845812Brian Paul      return 0;
117699aab341998e84d9fa208c525cae8021b3845812Brian Paul
11777cf50e137da497a590ec9001a9918972a6246142Brian Paul   glxCtx = CALLOC_STRUCT(fake_glx_context);
11787cf50e137da497a590ec9001a9918972a6246142Brian Paul   if (!glxCtx)
11797cf50e137da497a590ec9001a9918972a6246142Brian Paul      return 0;
1180afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1181afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* deallocate unused windows/buffers */
1182afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaGarbageCollect();
1183afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1184afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   glxvis = find_glx_visual( dpy, visinfo );
1185afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (!glxvis) {
1186afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* This visual wasn't found with glXChooseVisual() */
1187afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      glxvis = create_glx_visual( dpy, visinfo );
1188afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (!glxvis) {
1189afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* unusable visual */
11907cf50e137da497a590ec9001a9918972a6246142Brian Paul         FREE(glxCtx);
1191afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return NULL;
1192afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
1193afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1194afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
11957cf50e137da497a590ec9001a9918972a6246142Brian Paul   glxCtx->xmesaContext = XMesaCreateContext(glxvis,
11965e1680ce1d8296b2182e8909856927bbeddf3b95Brian Paul                                   shareCtx ? shareCtx->xmesaContext : NULL);
11977cf50e137da497a590ec9001a9918972a6246142Brian Paul   if (!glxCtx->xmesaContext) {
11987cf50e137da497a590ec9001a9918972a6246142Brian Paul      FREE(glxCtx);
11997cf50e137da497a590ec9001a9918972a6246142Brian Paul      return NULL;
1200afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
12017cf50e137da497a590ec9001a9918972a6246142Brian Paul
12027cf50e137da497a590ec9001a9918972a6246142Brian Paul   glxCtx->xmesaContext->direct = GL_FALSE;
12037cf50e137da497a590ec9001a9918972a6246142Brian Paul   glxCtx->glxContext.isDirect = GL_FALSE;
12047cf50e137da497a590ec9001a9918972a6246142Brian Paul   glxCtx->glxContext.currentDpy = dpy;
12057cf50e137da497a590ec9001a9918972a6246142Brian Paul   glxCtx->glxContext.xid = (XID) glxCtx;  /* self pointer */
12067cf50e137da497a590ec9001a9918972a6246142Brian Paul
12077cf50e137da497a590ec9001a9918972a6246142Brian Paul   assert((void *) glxCtx == (void *) &(glxCtx->glxContext));
12087cf50e137da497a590ec9001a9918972a6246142Brian Paul
12097cf50e137da497a590ec9001a9918972a6246142Brian Paul   return (GLXContext) glxCtx;
1210afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1211afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1212afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
12137cf50e137da497a590ec9001a9918972a6246142Brian Paul/* XXX these may have to be removed due to thread-safety issues. */
1214afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic GLXContext MakeCurrent_PrevContext = 0;
1215086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic GLXDrawable MakeCurrent_PrevDrawable = 0;
1216086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic GLXDrawable MakeCurrent_PrevReadable = 0;
1217086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic XMesaBuffer MakeCurrent_PrevDrawBuffer = 0;
1218086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic XMesaBuffer MakeCurrent_PrevReadBuffer = 0;
1219afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
12207cf50e137da497a590ec9001a9918972a6246142Brian Paul
1221086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul/* GLX 1.3 and later */
1222426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool
1223426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXMakeContextCurrent( Display *dpy, GLXDrawable draw,
12247a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell                            GLXDrawable read, GLXContext ctx )
1225086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul{
12267cf50e137da497a590ec9001a9918972a6246142Brian Paul   struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx;
12277cf50e137da497a590ec9001a9918972a6246142Brian Paul
12287a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell   if (ctx && draw && read) {
1229086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      XMesaBuffer drawBuffer, readBuffer;
12307cf50e137da497a590ec9001a9918972a6246142Brian Paul      XMesaContext xmctx = glxCtx->xmesaContext;
1231086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul
1232086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      /* Find the XMesaBuffer which corresponds to the GLXDrawable 'draw' */
12337a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell      if (ctx == MakeCurrent_PrevContext
12347a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell          && draw == MakeCurrent_PrevDrawable) {
1235086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         drawBuffer = MakeCurrent_PrevDrawBuffer;
1236086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      }
1237086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      else {
1238086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         drawBuffer = XMesaFindBuffer( dpy, draw );
1239086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      }
1240086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      if (!drawBuffer) {
1241086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         /* drawable must be a new window! */
12427cf50e137da497a590ec9001a9918972a6246142Brian Paul         drawBuffer = XMesaCreateWindowBuffer2( xmctx->xm_visual, draw, xmctx);
1243086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         if (!drawBuffer) {
1244086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul            /* Out of memory, or context/drawable depth mismatch */
1245086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul            return False;
1246086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         }
1247086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      }
1248086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul
1249086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      /* Find the XMesaBuffer which corresponds to the GLXDrawable 'read' */
12507a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell      if (ctx == MakeCurrent_PrevContext
1251086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul          && read == MakeCurrent_PrevReadable) {
1252086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         readBuffer = MakeCurrent_PrevReadBuffer;
1253086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      }
1254086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      else {
1255086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         readBuffer = XMesaFindBuffer( dpy, read );
1256086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      }
1257086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      if (!readBuffer) {
1258086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         /* drawable must be a new window! */
12597cf50e137da497a590ec9001a9918972a6246142Brian Paul         readBuffer = XMesaCreateWindowBuffer2(glxCtx->xmesaContext->xm_visual,
12607cf50e137da497a590ec9001a9918972a6246142Brian Paul                                               read, xmctx);
1261086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         if (!readBuffer) {
1262086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul            /* Out of memory, or context/drawable depth mismatch */
1263086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul            return False;
1264086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         }
1265086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      }
1266086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul
12677a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell      MakeCurrent_PrevContext = ctx;
1268086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevDrawable = draw;
1269086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevReadable = read;
1270086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevDrawBuffer = drawBuffer;
1271086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevReadBuffer = readBuffer;
1272086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul
1273086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      /* Now make current! */
12747cf50e137da497a590ec9001a9918972a6246142Brian Paul      if (XMesaMakeCurrent2(xmctx, drawBuffer, readBuffer)) {
127512c1bee87fcc3a0912685bb6e83447972e5de64eBrian Paul         ((__GLXcontext *) ctx)->currentDpy = dpy;
127612c1bee87fcc3a0912685bb6e83447972e5de64eBrian Paul         ((__GLXcontext *) ctx)->currentDrawable = draw;
12778d687e7e58a148f3f16573636023e54755372010Brian Paul#ifndef GLX_BUILT_IN_XMESA
127812c1bee87fcc3a0912685bb6e83447972e5de64eBrian Paul         ((__GLXcontext *) ctx)->currentReadable = read;
12798d687e7e58a148f3f16573636023e54755372010Brian Paul#else
12807cf50e137da497a590ec9001a9918972a6246142Brian Paul         __glXSetCurrentContext(ctx);
12817cf50e137da497a590ec9001a9918972a6246142Brian Paul#endif
12827cf50e137da497a590ec9001a9918972a6246142Brian Paul         return True;
12837cf50e137da497a590ec9001a9918972a6246142Brian Paul      }
12847cf50e137da497a590ec9001a9918972a6246142Brian Paul      else {
12857cf50e137da497a590ec9001a9918972a6246142Brian Paul         return False;
12867cf50e137da497a590ec9001a9918972a6246142Brian Paul      }
1287086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul   }
12887a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell   else if (!ctx && !draw && !read) {
1289086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      /* release current context w/out assigning new one. */
1290086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      XMesaMakeCurrent( NULL, NULL );
1291086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevContext = 0;
1292086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevDrawable = 0;
1293086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevReadable = 0;
1294086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevDrawBuffer = 0;
1295086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevReadBuffer = 0;
129684cac8441fcf5f692cd220e9fa86cab398a4c159Brian Paul#ifdef GLX_BUILT_IN_XMESA
1297b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul      /* XXX bind dummy context with __glXSetCurrentContext(ctx); */
1298b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#endif
1299086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      return True;
1300086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul   }
1301086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul   else {
1302086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      /* The args must either all be non-zero or all zero.
1303086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul       * This is an error.
1304086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul       */
1305086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      return False;
1306086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul   }
1307086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul}
1308086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul
1309086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul
1310426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1311426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool
1312426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXMakeCurrent( Display *dpy, GLXDrawable drawable, GLXContext ctx )
1313426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
1314426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   return Fake_glXMakeContextCurrent( dpy, drawable, drawable, ctx );
1315426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
1316426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1317426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1318426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1319426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPixmap
1320426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateGLXPixmap( Display *dpy, XVisualInfo *visinfo, Pixmap pixmap )
1321afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1322afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaVisual v;
1323afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaBuffer b;
1324afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1325afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   v = find_glx_visual( dpy, visinfo );
1326afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (!v) {
1327afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      v = create_glx_visual( dpy, visinfo );
1328afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (!v) {
1329afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* unusable visual */
1330afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1331afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
1332afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1333afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1334afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   b = XMesaCreatePixmapBuffer( v, pixmap, 0 );
1335afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (!b) {
1336afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return 0;
1337afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1338afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return b->frontbuffer;
1339afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1340afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1341afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1342b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_MESA_pixmap_colormap ***/
1343b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul
1344426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPixmap
1345426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visinfo,
1346426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                             Pixmap pixmap, Colormap cmap )
1347afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1348afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaVisual v;
1349afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaBuffer b;
1350afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1351afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   v = find_glx_visual( dpy, visinfo );
1352afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (!v) {
1353afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      v = create_glx_visual( dpy, visinfo );
1354afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (!v) {
1355afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* unusable visual */
1356afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1357afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
1358afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1359afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1360afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   b = XMesaCreatePixmapBuffer( v, pixmap, cmap );
1361afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (!b) {
1362afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return 0;
1363afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1364afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return b->frontbuffer;
1365afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1366afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1367afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1368426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1369426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyGLXPixmap( Display *dpy, GLXPixmap pixmap )
1370afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1371afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaBuffer b = XMesaFindBuffer(dpy, pixmap);
1372afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (b) {
1373afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      XMesaDestroyBuffer(b);
1374afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1375afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else if (getenv("MESA_DEBUG")) {
1376d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul      _mesa_warning(NULL, "Mesa: glXDestroyGLXPixmap: invalid pixmap\n");
1377afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1378afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1379afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1380afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
13814c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul
1382426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1383426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCopyContext( Display *dpy, GLXContext src, GLXContext dst,
13843994b77bab8c62a4c1a4dffdfba233ef46662b99Brian Paul                     unsigned long mask )
1385afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
138683b820aa98931ef30fa73c72b2a96fe23885955eBrian Paul   struct fake_glx_context *fakeSrc = (struct fake_glx_context *) src;
138783b820aa98931ef30fa73c72b2a96fe23885955eBrian Paul   struct fake_glx_context *fakeDst = (struct fake_glx_context *) dst;
138883b820aa98931ef30fa73c72b2a96fe23885955eBrian Paul   XMesaContext xm_src = fakeSrc->xmesaContext;
138983b820aa98931ef30fa73c72b2a96fe23885955eBrian Paul   XMesaContext xm_dst = fakeDst->xmesaContext;
1390afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
13917a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell   _mesa_copy_context( xm_src->gl_ctx, xm_dst->gl_ctx, (GLuint) mask );
1392afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1393afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1394afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1395afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1396426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool
1397426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryExtension( Display *dpy, int *errorb, int *event )
1398afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1399afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* Mesa's GLX isn't really an X extension but we try to act like one. */
1400afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
1401afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) errorb;
1402afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) event;
1403afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return True;
1404afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1405afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1406afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1407e7b16b74bf5d13331b5a88bbbbb9096560297b63Brian Paulextern void _kw_ungrab_all( Display *dpy );
1408afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgvoid _kw_ungrab_all( Display *dpy )
1409afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1410afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XUngrabPointer( dpy, CurrentTime );
1411afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XUngrabKeyboard( dpy, CurrentTime );
1412afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1413afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1414afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1415426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1416426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyContext( Display *dpy, GLXContext ctx )
1417afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
14187cf50e137da497a590ec9001a9918972a6246142Brian Paul   struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx;
1419afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
1420afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   MakeCurrent_PrevContext = 0;
1421afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   MakeCurrent_PrevDrawable = 0;
1422086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul   MakeCurrent_PrevReadable = 0;
1423086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul   MakeCurrent_PrevDrawBuffer = 0;
1424086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul   MakeCurrent_PrevReadBuffer = 0;
14257cf50e137da497a590ec9001a9918972a6246142Brian Paul   XMesaDestroyContext( glxCtx->xmesaContext );
1426afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaGarbageCollect();
1427afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1428afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1429afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1430afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1431426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool
1432426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXIsDirect( Display *dpy, GLXContext ctx )
1433afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
14347cf50e137da497a590ec9001a9918972a6246142Brian Paul   struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx;
1435afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
14367cf50e137da497a590ec9001a9918972a6246142Brian Paul   return glxCtx->xmesaContext->direct;
1437afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1438afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1439afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1440afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1441426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1442426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXSwapBuffers( Display *dpy, GLXDrawable drawable )
1443afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1444afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaBuffer buffer = XMesaFindBuffer( dpy, drawable );
1445afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1446afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (buffer) {
1447afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      XMesaSwapBuffers(buffer);
1448afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1449afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else if (getenv("MESA_DEBUG")) {
1450d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul      _mesa_warning(NULL, "Mesa: glXSwapBuffers: invalid drawable\n");
1451afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1452afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1453afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1454afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
14554c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul
1456b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_MESA_copy_sub_buffer ***/
1457b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul
1458426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1459426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCopySubBufferMESA( Display *dpy, GLXDrawable drawable,
1460426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                           int x, int y, int width, int height )
1461afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1462afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaBuffer buffer = XMesaFindBuffer( dpy, drawable );
1463afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (buffer) {
1464afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      XMesaCopySubBuffer(buffer, x, y, width, height);
1465afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1466afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else if (getenv("MESA_DEBUG")) {
1467d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul      _mesa_warning(NULL, "Mesa: glXCopySubBufferMESA: invalid drawable\n");
1468afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1469afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1470afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1471afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1472afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1473426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool
1474426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryVersion( Display *dpy, int *maj, int *min )
1475afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1476afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
1477afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* Return GLX version, not Mesa version */
147878fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul   assert(CLIENT_MAJOR_VERSION == SERVER_MAJOR_VERSION);
147978fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul   *maj = CLIENT_MAJOR_VERSION;
148078fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul   *min = MIN2( CLIENT_MINOR_VERSION, SERVER_MINOR_VERSION );
1481afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return True;
1482afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1483afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1484afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1485afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1486afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
1487afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Query the GLX attributes of the given XVisualInfo.
1488afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
1489426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int
14903265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paulget_config( XMesaVisual glxvis, int attrib, int *value, GLboolean fbconfig )
1491afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
14923265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   ASSERT(glxvis);
1493afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   switch(attrib) {
1494afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_USE_GL:
1495afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         *value = (int) True;
1496afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1497afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_BUFFER_SIZE:
14983265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul	 *value = glxvis->visinfo->depth;
1499afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1500afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_LEVEL:
1501afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 *value = glxvis->level;
1502afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1503afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_RGBA:
15041832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul	 if (glxvis->mesa_visual.rgbMode) {
1505afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    *value = True;
1506afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 }
1507afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 else {
1508afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    *value = False;
1509afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 }
1510afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1511afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_DOUBLEBUFFER:
15121832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul	 *value = (int) glxvis->mesa_visual.doubleBufferMode;
1513afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1514afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_STEREO:
15151832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul	 *value = (int) glxvis->mesa_visual.stereoMode;
1516afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1517afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_AUX_BUFFERS:
1518afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 *value = (int) False;
1519afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1520afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_RED_SIZE:
15211832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul         *value = glxvis->mesa_visual.redBits;
1522afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1523afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_GREEN_SIZE:
15241832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul         *value = glxvis->mesa_visual.greenBits;
1525afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1526afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_BLUE_SIZE:
15271832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul         *value = glxvis->mesa_visual.blueBits;
1528afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1529afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_ALPHA_SIZE:
15301832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul         *value = glxvis->mesa_visual.alphaBits;
1531afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1532afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_DEPTH_SIZE:
15331832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul         *value = glxvis->mesa_visual.depthBits;
1534afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1535afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_STENCIL_SIZE:
15361832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul	 *value = glxvis->mesa_visual.stencilBits;
1537afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1538afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_ACCUM_RED_SIZE:
15391832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul	 *value = glxvis->mesa_visual.accumRedBits;
1540b2e460018375f699198073a6167e0ee96ba1d267Brian Paul	 return 0;
1541afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_ACCUM_GREEN_SIZE:
15421832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul	 *value = glxvis->mesa_visual.accumGreenBits;
1543b2e460018375f699198073a6167e0ee96ba1d267Brian Paul	 return 0;
1544afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_ACCUM_BLUE_SIZE:
15451832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul	 *value = glxvis->mesa_visual.accumBlueBits;
1546afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1547afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_ACCUM_ALPHA_SIZE:
15481832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul         *value = glxvis->mesa_visual.accumAlphaBits;
1549afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1550afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1551afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /*
1552afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg       * GLX_EXT_visual_info extension
1553afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg       */
1554afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_X_VISUAL_TYPE_EXT:
1555afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         switch (glxvis->visinfo->CLASS) {
1556afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case StaticGray:   *value = GLX_STATIC_GRAY_EXT;   return 0;
1557afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GrayScale:    *value = GLX_GRAY_SCALE_EXT;    return 0;
1558afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case StaticColor:  *value = GLX_STATIC_GRAY_EXT;   return 0;
1559afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case PseudoColor:  *value = GLX_PSEUDO_COLOR_EXT;  return 0;
1560afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case TrueColor:    *value = GLX_TRUE_COLOR_EXT;    return 0;
1561afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case DirectColor:  *value = GLX_DIRECT_COLOR_EXT;  return 0;
1562afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
1563afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1564afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_TRANSPARENT_TYPE_EXT:
1565afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         if (glxvis->level==0) {
1566afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* normal planes */
1567afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            *value = GLX_NONE_EXT;
1568afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
1569afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         else if (glxvis->level>0) {
1570afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* overlay */
15711832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul            if (glxvis->mesa_visual.rgbMode) {
1572afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               *value = GLX_TRANSPARENT_RGB_EXT;
1573afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
1574afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            else {
1575afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               *value = GLX_TRANSPARENT_INDEX_EXT;
1576afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
1577afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
1578afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         else if (glxvis->level<0) {
1579afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* underlay */
1580afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            *value = GLX_NONE_EXT;
1581afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
1582afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1583afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_TRANSPARENT_INDEX_VALUE_EXT:
1584afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         {
1585afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            int pixel = transparent_pixel( glxvis );
1586afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            if (pixel>=0) {
1587afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               *value = pixel;
1588afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
1589afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* else undefined */
1590afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
1591afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1592afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_TRANSPARENT_RED_VALUE_EXT:
1593afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* undefined */
1594afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1595afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_TRANSPARENT_GREEN_VALUE_EXT:
1596afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* undefined */
1597afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1598afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_TRANSPARENT_BLUE_VALUE_EXT:
1599afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* undefined */
1600afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1601afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_TRANSPARENT_ALPHA_VALUE_EXT:
1602afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* undefined */
1603afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1604afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1605afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /*
1606b2e460018375f699198073a6167e0ee96ba1d267Brian Paul       * GLX_EXT_visual_info extension
1607b2e460018375f699198073a6167e0ee96ba1d267Brian Paul       */
1608b2e460018375f699198073a6167e0ee96ba1d267Brian Paul      case GLX_VISUAL_CAVEAT_EXT:
1609fc68be6b111473a0bf8f991468f973bb9dd275f4Brian Paul         /* test for zero, just in case */
1610962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul         if (glxvis->VisualCaveat > 0)
1611962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul            *value = glxvis->VisualCaveat;
1612962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul         else
1613962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul            *value = GLX_NONE_EXT;
1614962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul         return 0;
1615b2e460018375f699198073a6167e0ee96ba1d267Brian Paul
1616b2e460018375f699198073a6167e0ee96ba1d267Brian Paul      /*
16173265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul       * GLX_EXT_multisample
1618afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg       */
16193265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      case GLX_SAMPLE_BUFFERS_SGIS:
16203265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         *value = 0;
16213265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         return 0;
16223265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      case GLX_SAMPLES_SGIS:
16233265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         *value = 0;
16243265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         return 0;
16253265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul
16263265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      /*
16273265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul       * For FBConfigs:
16283265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul       */
16293265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      case GLX_SCREEN_EXT:
16303265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         if (!fbconfig)
16313265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            return GLX_BAD_ATTRIBUTE;
16323265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         *value = glxvis->visinfo->screen;
16333265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         break;
16343265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      case GLX_DRAWABLE_TYPE: /*SGIX too */
16353265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         if (!fbconfig)
16363265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            return GLX_BAD_ATTRIBUTE;
16373265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         *value = GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT;
16383265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         break;
16393265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      case GLX_RENDER_TYPE_SGIX:
16403265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         if (!fbconfig)
16413265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            return GLX_BAD_ATTRIBUTE;
16423265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         if (glxvis->mesa_visual.rgbMode)
16433265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            *value = GLX_RGBA_BIT;
16443265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         else
16453265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            *value = GLX_COLOR_INDEX_BIT;
16463265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         break;
16473265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      case GLX_X_RENDERABLE_SGIX:
16483265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         if (!fbconfig)
16493265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            return GLX_BAD_ATTRIBUTE;
16503265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         *value = True; /* XXX really? */
16513265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         break;
16523265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      case GLX_FBCONFIG_ID_SGIX:
16533265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         if (!fbconfig)
16543265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            return GLX_BAD_ATTRIBUTE;
16553265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         *value = glxvis->vishandle->visualid;
16563265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         break;
16573265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      case GLX_MAX_PBUFFER_WIDTH:
16583265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         if (!fbconfig)
16593265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            return GLX_BAD_ATTRIBUTE;
16603265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         /* XXX or MAX_WIDTH? */
16613265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         *value = DisplayWidth(glxvis->display, glxvis->vishandle->screen);
16623265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         break;
16633265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      case GLX_MAX_PBUFFER_HEIGHT:
16643265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         if (!fbconfig)
16653265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            return GLX_BAD_ATTRIBUTE;
16663265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         *value = DisplayHeight(glxvis->display, glxvis->vishandle->screen);
16673265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         break;
16683265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      case GLX_MAX_PBUFFER_PIXELS:
16693265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         if (!fbconfig)
16703265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            return GLX_BAD_ATTRIBUTE;
16713265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         *value = DisplayWidth(glxvis->display, glxvis->vishandle->screen) *
16723265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul                  DisplayHeight(glxvis->display, glxvis->vishandle->screen);
16733265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         break;
16743265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      case GLX_VISUAL_ID:
16753265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         if (!fbconfig)
16763265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            return GLX_BAD_ATTRIBUTE;
16773265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         *value = glxvis->vishandle->visualid;
16783265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         break;
16793265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul
1680afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      default:
1681afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return GLX_BAD_ATTRIBUTE;
1682afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
16833265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   return Success;
1684afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1685afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1686afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
16873265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paulstatic int
16883265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian PaulFake_glXGetConfig( Display *dpy, XVisualInfo *visinfo,
16893265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul                   int attrib, int *value )
16903265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul{
16913265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   XMesaVisual glxvis;
16923265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul
16933265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   glxvis = find_glx_visual( dpy, visinfo );
16943265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   if (!glxvis) {
16953265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      /* this visual wasn't obtained with glXChooseVisual */
16963265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      glxvis = create_glx_visual( dpy, visinfo );
16973265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      if (!glxvis) {
16983265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul	 /* this visual can't be used for GL rendering */
16993265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul	 if (attrib==GLX_USE_GL) {
17003265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul	    *value = (int) False;
17013265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul	    return 0;
17023265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul	 }
17033265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul	 else {
17043265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul	    return GLX_BAD_VISUAL;
17053265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul	 }
17063265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      }
17073265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   }
17083265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul
17093265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   return get_config(glxvis, attrib, value, GL_FALSE);
17103265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul}
17113265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul
1712afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1713426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1714426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXWaitGL( void )
1715afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1716afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaContext xmesa = XMesaGetCurrentContext();
1717afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaFlush( xmesa );
1718afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1719afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1720afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1721afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1722426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1723426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXWaitX( void )
1724afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1725afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaContext xmesa = XMesaGetCurrentContext();
1726afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaFlush( xmesa );
1727afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1728afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1729afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
173043c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul/*
173143c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul * Return the extensions string, which is 3Dfx-dependant.
173243c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul */
173343c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paulstatic const char *get_extensions( void )
173443c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul{
173543c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul#ifdef FX
173643c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul   const char *fx = getenv("MESA_GLX_FX");
173743c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul   if (fx && fx[0] != 'd') {
17383265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian 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_SGIX_fbconfig GLX_SGIX_pbuffer GLX_MESA_set_3dfx_mode GLX_ARB_get_proc_address";
173943c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul   }
174043c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul#endif
17413265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian 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_SGIX_fbconfig GLX_SGIX_pbuffer GLX_ARB_get_proc_address";
174243c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul}
1743afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1744afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1745afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1746afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* GLX 1.1 and later */
1747426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic const char *
1748426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryExtensionsString( Display *dpy, int screen )
1749afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1750afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
1751afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) screen;
175243c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul   return get_extensions();
1753afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1754afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1755afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1756afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1757afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* GLX 1.1 and later */
1758426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic const char *
1759426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryServerString( Display *dpy, int screen, int name )
1760afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
176178fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul   static char version[1000];
176278fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul   sprintf(version, "%d.%d %s", SERVER_MAJOR_VERSION, SERVER_MINOR_VERSION,
176378fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul           MESA_GLX_VERSION);
1764afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1765afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
1766afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) screen;
1767afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1768afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   switch (name) {
1769afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_EXTENSIONS:
177043c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul         return get_extensions();
1771afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_VENDOR:
177278fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul	 return VENDOR;
1773afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_VERSION:
1774afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return version;
1775afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      default:
1776afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return NULL;
1777afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1778afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1779afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1780afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1781afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1782afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* GLX 1.1 and later */
1783426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic const char *
1784426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetClientString( Display *dpy, int name )
1785afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
178678fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul   static char version[1000];
178778fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul   sprintf(version, "%d.%d %s", CLIENT_MAJOR_VERSION, CLIENT_MINOR_VERSION,
178878fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul           MESA_GLX_VERSION);
1789afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1790afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
1791afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1792afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   switch (name) {
1793afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_EXTENSIONS:
179443c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul         return get_extensions();
1795afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_VENDOR:
179678fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul	 return VENDOR;
1797afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_VERSION:
1798afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return version;
1799afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      default:
1800afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return NULL;
1801afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1802afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1803afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1804afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1805afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1806426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul/*
1807426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul * GLX 1.3 and later
1808426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul */
1809426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
18107d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
1811a078d75a27b99252ede6520e24b145106ab98aa2Brian Paul/* PBUFFER */
18125605798e56ca6e9f968623f33b58ee7ca90594afBrian Paulstatic GLXFBConfig *
1813426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXChooseFBConfig( Display *dpy, int screen,
1814426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                        const int *attribList, int *nitems )
1815426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
18163265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   XMesaVisual xmvis = choose_visual(dpy, screen, attribList);
18173265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   if (xmvis) {
18183265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      GLXFBConfig *config = malloc(sizeof(XMesaVisual));
18193265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      if (!config) {
18203265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         *nitems = 0;
18213265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         return NULL;
18223265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      }
18233265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      *nitems = 1;
18243265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      config[0] = (GLXFBConfig) xmvis;
18253265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      return (GLXFBConfig *) config;
18263265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   }
18273265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   else {
18283265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      *nitems = 0;
18293265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      return NULL;
18303265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   }
1831426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
1832426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1833426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1834a078d75a27b99252ede6520e24b145106ab98aa2Brian Paul/* PBUFFER */
1835426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int
1836426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetFBConfigAttrib( Display *dpy, GLXFBConfig config,
1837426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                           int attribute, int *value )
1838426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
18393265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   XMesaVisual v = (XMesaVisual) config;
1840426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
1841426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) config;
18427d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
18437d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (!dpy || !config || !value)
18447d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return -1;
18457d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
18463265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   return get_config(v, attribute, value, GL_TRUE);
1847426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
1848426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1849426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1850a078d75a27b99252ede6520e24b145106ab98aa2Brian Paul/* PBUFFER */
18515605798e56ca6e9f968623f33b58ee7ca90594afBrian Paulstatic GLXFBConfig *
18525605798e56ca6e9f968623f33b58ee7ca90594afBrian PaulFake_glXGetFBConfigs( Display *dpy, int screen, int *nelements )
18535605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul{
18543265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   XVisualInfo *visuals, visTemplate;
18553265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   const long visMask = VisualScreenMask;
18563265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   int i;
18573265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul
18583265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   /* Get list of all X visuals */
18593265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   visTemplate.screen = screen;
18603265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   visuals = XGetVisualInfo(dpy, visMask, &visTemplate, nelements);
18613265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   if (*nelements > 0) {
18623265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      XMesaVisual *results;
18633265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      results = malloc(*nelements * sizeof(XMesaVisual));
18643265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      if (!results) {
18653265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         *nelements = 0;
18663265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         return NULL;
18673265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      }
18683265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      for (i = 0; i < *nelements; i++) {
18693265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         results[i] = create_glx_visual(dpy, visuals + i);
18703265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      }
18713265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      return (GLXFBConfig *) results;
18723265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   }
18733265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   return NULL;
18745605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul}
18755605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul
18765605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul
1877a078d75a27b99252ede6520e24b145106ab98aa2Brian Paul/* PBUFFER */
1878426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic XVisualInfo *
1879426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetVisualFromFBConfig( Display *dpy, GLXFBConfig config )
1880426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
18817d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (dpy && config) {
18827d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      XMesaVisual v = (XMesaVisual) config;
18837d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return v->vishandle;
18847d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   }
18857d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   else {
18867d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return NULL;
18877d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   }
1888426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
1889426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1890426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1891a078d75a27b99252ede6520e24b145106ab98aa2Brian Paul/* PBUFFER */
1892426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXWindow
1893426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateWindow( Display *dpy, GLXFBConfig config, Window win,
1894426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                      const int *attribList )
1895426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
1896426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
1897426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) config;
1898426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) win;
18997d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   (void) attribList;  /* Ignored in GLX 1.3 */
19007d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
19017d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   return win;  /* A hack for now */
1902426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
1903426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1904426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1905426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1906426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyWindow( Display *dpy, GLXWindow window )
1907426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
19087d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   XMesaBuffer b = XMesaFindBuffer(dpy, (XMesaDrawable) window);
19097d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (b)
19107d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      XMesaDestroyBuffer(b);
19117d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   /* don't destroy X window */
1912426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
1913426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1914426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
19157d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul/* XXX untested */
1916426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPixmap
1917426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreatePixmap( Display *dpy, GLXFBConfig config, Pixmap pixmap,
1918426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                      const int *attribList )
1919426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
19207d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   XMesaVisual v = (XMesaVisual) config;
19217d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   XVisualInfo *visinfo;
19227d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   XMesaBuffer b;
19237d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
1924426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
1925426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) config;
1926426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) pixmap;
19277d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   (void) attribList;  /* Ignored in GLX 1.3 */
19287d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
19297d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (!dpy || !config || !pixmap)
19307d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return 0;
19317d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
19327d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   visinfo = v->vishandle;
19337d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
19347d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   v = find_glx_visual( dpy, visinfo );
19357d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (!v) {
19367d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      v = create_glx_visual( dpy, visinfo );
19377d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      if (!v) {
19387d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         /* unusable visual */
19397d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         return 0;
19407d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      }
19417d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   }
19427d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
19437d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   b = XMesaCreatePixmapBuffer( v, pixmap, 0 );
19447d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (!b) {
19457d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return 0;
19467d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   }
19477d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
19487d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   return pixmap;
1949426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
1950426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1951426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1952426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1953426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyPixmap( Display *dpy, GLXPixmap pixmap )
1954426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
19557d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   XMesaBuffer b = XMesaFindBuffer(dpy, (XMesaDrawable)pixmap);
19567d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (b)
19577d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      XMesaDestroyBuffer(b);
19587d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   /* don't destroy X pixmap */
1959426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
1960426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1961426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1962a078d75a27b99252ede6520e24b145106ab98aa2Brian Paul/* PBUFFER */
1963426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPbuffer
1964426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreatePbuffer( Display *dpy, GLXFBConfig config,
1965426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                       const int *attribList )
1966426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
19673265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   XMesaVisual xmvis = (XMesaVisual) config;
19683265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   XMesaBuffer xmbuf;
19697d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   const int *attrib;
19707d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   int width = 0, height = 0;
19717d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   GLboolean useLargest = GL_FALSE, preserveContents = GL_FALSE;
19727d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
1973426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
19747d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
19753265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   for (attrib = attribList; *attrib; attrib++) {
19767d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      switch (*attrib) {
19777d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         case GLX_PBUFFER_WIDTH:
19783265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            attrib++;
19793265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            width = *attrib;
19807d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            break;
19817d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         case GLX_PBUFFER_HEIGHT:
19823265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            attrib++;
19833265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            height = *attrib;
19847d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            break;
19857d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         case GLX_PRESERVED_CONTENTS:
19863265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            attrib++;
19873265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            preserveContents = *attrib; /* ignored */
19887d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            break;
19897d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         case GLX_LARGEST_PBUFFER:
19903265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            attrib++;
19913265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            useLargest = *attrib; /* ignored */
19927d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            break;
19937d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         default:
19947d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            return 0;
19957d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      }
19967d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   }
19977d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
19987d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (width == 0 || height == 0)
19997d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return 0;
20007d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
20013265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   xmbuf = XMesaCreatePBuffer( xmvis, 0, width, height);
20023265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   return (GLXPbuffer) xmbuf;
2003426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2004426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2005426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2006a078d75a27b99252ede6520e24b145106ab98aa2Brian Paul/* PBUFFER */
2007426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
2008426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyPbuffer( Display *dpy, GLXPbuffer pbuf )
2009426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2010426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
2011426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) pbuf;
2012426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2013426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2014426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2015a078d75a27b99252ede6520e24b145106ab98aa2Brian Paul/* PBUFFER */
2016426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
2017426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryDrawable( Display *dpy, GLXDrawable draw, int attribute,
2018426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                       unsigned int *value )
2019426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2020426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
2021426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) draw;
20227d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
20237d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   switch (attribute) {
20247d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_WIDTH:
20257d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_HEIGHT:
20267d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_PRESERVED_CONTENTS:
20277d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_LARGEST_PBUFFER:
20287d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_FBCONFIG_ID:
20297d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         *value = 0;
20307d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         return;
20317d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      default:
20327d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         return;  /* GLX_BAD_ATTRIBUTE? */
20337d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   }
2034426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2035426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2036426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2037426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXContext
2038426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateNewContext( Display *dpy, GLXFBConfig config,
2039426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                          int renderType, GLXContext shareList, Bool direct )
2040426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
20417d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   XMesaVisual v = (XMesaVisual) config;
20427d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
20437d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (!dpy || !config ||
20447d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul       (renderType != GLX_RGBA_TYPE && renderType != GLX_COLOR_INDEX_TYPE))
20457d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return 0;
20467d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
20477d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   return Fake_glXCreateContext(dpy, v->vishandle, shareList, direct);
2048426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2049426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2050426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2051a078d75a27b99252ede6520e24b145106ab98aa2Brian Paul/* PBUFFER */
2052426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int
2053426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryContext( Display *dpy, GLXContext ctx, int attribute, int *value )
2054426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2055426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
2056426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) ctx;
20577d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
20587d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   switch (attribute) {
20597d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   case GLX_FBCONFIG_ID:
20607d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   case GLX_RENDER_TYPE:
20617d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   case GLX_SCREEN:
20627d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      *value = 0;
20637d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return Success;
20647d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   default:
20657d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return GLX_BAD_ATTRIBUTE;
20667d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   }
2067426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2068426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2069426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2070a078d75a27b99252ede6520e24b145106ab98aa2Brian Paul/* PBUFFER */
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
2080a078d75a27b99252ede6520e24b145106ab98aa2Brian Paul/* PBUFFER */
2081426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
2082426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetSelectedEvent( Display *dpy, GLXDrawable drawable,
2083426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                          unsigned long *mask )
2084426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2085426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
2086426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) drawable;
2087426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) mask;
2088426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2089b82d993b03320818f88f792a9e713f7ed491bfcbBrian Paul
2090b82d993b03320818f88f792a9e713f7ed491bfcbBrian Paul
2091b82d993b03320818f88f792a9e713f7ed491bfcbBrian Paul
2092b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGI_swap_control ***/
2093783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2094783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2095783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXSwapIntervalSGI(int interval)
2096783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2097783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) interval;
2098783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2099783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2100783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2101783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2102783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2103b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGI_video_sync ***/
2104783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2105783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2106783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetVideoSyncSGI(unsigned int *count)
2107783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2108783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) count;
2109783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2110783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2111783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2112783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2113783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count)
2114783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2115783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) divisor;
2116783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) remainder;
2117783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) count;
2118783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2119783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2120783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2121783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2122783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2123b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGI_make_current_read ***/
2124783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2125426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool
2126783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXMakeCurrentReadSGI(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx)
2127afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
2128a078d75a27b99252ede6520e24b145106ab98aa2Brian Paul   return Fake_glXMakeContextCurrent( dpy, draw, read, ctx );
2129afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
2130783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
21317cf50e137da497a590ec9001a9918972a6246142Brian Paul/* not used
2132783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXDrawable
2133b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian PaulFake_glXGetCurrentReadDrawableSGI(void)
2134783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2135783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2136783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
21377cf50e137da497a590ec9001a9918972a6246142Brian Paul*/
2138afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
2139afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
2140b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_video_source ***/
2141b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#if defined(_VL_H)
21424c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul
2143783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXVideoSourceSGIX
2144783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXCreateGLXVideoSourceSGIX(Display *dpy, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode)
2145afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
2146783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2147783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2148783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) server;
2149783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) path;
2150783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) nodeClass;
2151783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) drainNode;
2152783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2153783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2154783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2155783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2156783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXDestroyGLXVideoSourceSGIX(Display *dpy, GLXVideoSourceSGIX src)
2157783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2158783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2159783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) src;
2160afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
2161783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
21624c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul#endif
21634c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul
216489a42b7e736bd9b0ab090906cab0cd047a6ec12eBrian Paul
2165b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_EXT_import_context ***/
216689a42b7e736bd9b0ab090906cab0cd047a6ec12eBrian Paul
2167783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2168783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXFreeContextEXT(Display *dpy, GLXContext context)
2169783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2170783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2171783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) context;
2172783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2173426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2174783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXContextID
2175783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetContextIDEXT(const GLXContext context)
2176783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2177783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) context;
2178783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2179783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2180783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2181783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXContext
2182783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXImportContextEXT(Display *dpy, GLXContextID contextID)
2183783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2184783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2185783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) contextID;
2186783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2187783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2188426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2189426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int
2190783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryContextInfoEXT(Display *dpy, GLXContext context, int attribute, int *value)
2191426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2192783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2193783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) context;
2194783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) attribute;
2195783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) value;
2196426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   return 0;
2197426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2198426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2199783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2200783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2201b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_fbconfig ***/
2202426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2203426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int
2204783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetFBConfigAttribSGIX(Display *dpy, GLXFBConfigSGIX config, int attribute, int *value)
2205783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
22063265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   return Fake_glXGetFBConfigAttrib(dpy, config, attribute, value);
2207783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2208783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2209783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXFBConfigSGIX *
2210783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXChooseFBConfigSGIX(Display *dpy, int screen, int *attrib_list, int *nelements)
2211783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
22123265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   return (GLXFBConfig *) Fake_glXChooseFBConfig(dpy, screen, attrib_list, nelements);
2213783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2214783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2215783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXPixmap
2216783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXCreateGLXPixmapWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap)
2217783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2218783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2219783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) config;
2220783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) pixmap;
2221783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2222783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2223783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2224783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXContext
2225783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct)
2226783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2227783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2228783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) config;
2229783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) render_type;
2230783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) share_list;
2231783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) direct;
2232783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2233783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2234783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2235783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic XVisualInfo *
2236783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetVisualFromFBConfigSGIX(Display *dpy, GLXFBConfigSGIX config)
2237783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
22383265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   return Fake_glXGetVisualFromFBConfig(dpy, config);
2239783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2240783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2241783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXFBConfigSGIX
2242783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetFBConfigFromVisualSGIX(Display *dpy, XVisualInfo *vis)
2243426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2244783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2245783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) vis;
2246426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   return 0;
2247426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2248426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2249426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2250426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2251b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_pbuffer ***/
2252783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2253783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXPbufferSGIX
22543265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian PaulFake_glXCreateGLXPbufferSGIX(Display *dpy, GLXFBConfigSGIX config,
22553265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul                             unsigned int width, unsigned int height,
22563265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul                             int *attribList)
2257783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
22583265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   XMesaVisual xmvis = (XMesaVisual) config;
22593265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   XMesaBuffer xmbuf;
22603265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   const int *attrib;
22613265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   GLboolean useLargest = GL_FALSE, preserveContents = GL_FALSE;
22623265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul
2263783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
22643265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul
22653265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   for (attrib = attribList; *attrib; attrib++) {
22663265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      switch (*attrib) {
22673265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         case GLX_PRESERVED_CONTENTS_SGIX:
22683265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            attrib++;
22693265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            preserveContents = *attrib; /* ignored */
22703265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            break;
22713265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         case GLX_LARGEST_PBUFFER_SGIX:
22723265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            attrib++;
22733265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            useLargest = *attrib; /* ignored */
22743265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            break;
22753265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         default:
22763265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            return 0;
22773265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      }
22783265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   }
22793265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul
22803265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   xmbuf = XMesaCreatePBuffer( xmvis, 0, width, height);
22813265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   return (GLXPbuffer) xmbuf;
2282783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2283783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2284783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2285783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXDestroyGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf)
2286783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2287783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2288783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) pbuf;
2289783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2290783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2291783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2292783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value)
2293783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2294783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2295783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) pbuf;
2296783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) attribute;
2297783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) value;
2298783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2299783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2300783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2301783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2302783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXSelectEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long mask)
2303783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2304783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2305783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) drawable;
2306783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) mask;
2307783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2308783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2309783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2310783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetSelectedEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long *mask)
2311783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2312783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2313783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) drawable;
2314783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) mask;
2315783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2316783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2317783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2318783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2319b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGI_cushion ***/
2320783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2321783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2322783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXCushionSGI(Display *dpy, Window win, float cushion)
2323783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2324783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2325783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) win;
2326783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) cushion;
2327783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2328783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2329783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2330783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2331b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_video_resize ***/
2332783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2333783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2334783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXBindChannelToWindowSGIX(Display *dpy, int screen, int channel , Window window)
2335783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2336783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2337783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2338783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) channel;
2339783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) window;
2340783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2341783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2342783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2343783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2344783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXChannelRectSGIX(Display *dpy, int screen, int channel, int x, int y, int w, int h)
2345783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2346783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2347783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2348783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) channel;
2349783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) x;
2350783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) y;
2351783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) w;
2352783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) h;
2353783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2354783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2355783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2356783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2357783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryChannelRectSGIX(Display *dpy, int screen, int channel, int *x, int *y, int *w, int *h)
2358783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2359783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2360783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2361783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) channel;
2362783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) x;
2363783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) y;
2364783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) w;
2365783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) h;
2366783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2367783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2368783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2369783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2370783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryChannelDeltasSGIX(Display *dpy, int screen, int channel, int *dx, int *dy, int *dw, int *dh)
2371783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2372783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2373783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2374783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) channel;
2375783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dx;
2376783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dy;
2377783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dw;
2378783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dh;
2379783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2380783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2381783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2382783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2383783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXChannelRectSyncSGIX(Display *dpy, int screen, int channel, GLenum synctype)
2384783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2385783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2386783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2387783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) channel;
2388783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) synctype;
2389783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2390783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2391783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2392783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2393783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2394b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_dmbuffer **/
2395783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2396b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#if defined(_DM_BUFFER_H_)
2397783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Bool
2398783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXAssociateDMPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer)
2399783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2400783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2401783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) pbuffer;
2402783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) params;
2403783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dmbuffer;
2404783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return False;
2405783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2406783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul#endif
2407783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2408783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2409b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_swap_group ***/
2410783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2411783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2412783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXJoinSwapGroupSGIX(Display *dpy, GLXDrawable drawable, GLXDrawable member)
2413783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2414783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2415783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) drawable;
2416783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) member;
2417783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2418783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2419783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2420783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2421b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_swap_barrier ***/
2422783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2423783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2424783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXBindSwapBarrierSGIX(Display *dpy, GLXDrawable drawable, int barrier)
2425783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2426783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2427783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) drawable;
2428783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) barrier;
2429783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2430783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2431783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Bool
2432783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryMaxSwapBarriersSGIX(Display *dpy, int screen, int *max)
2433783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2434783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2435783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2436783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) max;
2437783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return False;
2438783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2439783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2440783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2441783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2442b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SUN_get_transparent_index ***/
2443783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2444783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Status
2445783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetTransparentIndexSUN(Display *dpy, Window overlay, Window underlay, long *pTransparent)
2446783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2447783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2448783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) overlay;
2449783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) underlay;
2450783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) pTransparent;
2451783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2452783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2453783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2454783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2455783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2456b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_MESA_release_buffers ***/
2457b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul
2458783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul/*
2459783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul * Release the depth, stencil, accum buffers attached to a GLXDrawable
2460783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul * (a window or pixmap) prior to destroying the GLXDrawable.
2461783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul */
2462783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Bool
2463783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXReleaseBuffersMESA( Display *dpy, GLXDrawable d )
2464783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2465783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   XMesaBuffer b = XMesaFindBuffer(dpy, d);
2466783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   if (b) {
2467783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul      XMesaDestroyBuffer(b);
2468783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul      return True;
2469783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   }
2470783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return False;
2471783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2472783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2473783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2474783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2475b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_MESA_set_3dfx_mode ***/
2476b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul
2477783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Bool
2478783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXSet3DfxModeMESA( int mode )
2479783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2480783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return XMesaSetFXmode( mode );
2481783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2482783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2483783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2484783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
24858fefafa2200d3ea44ec46592b190654a10685b46Brian Paul/*** AGP memory allocation ***/
24868fefafa2200d3ea44ec46592b190654a10685b46Brian Paulstatic void *
24878fefafa2200d3ea44ec46592b190654a10685b46Brian PaulFake_glXAllocateMemoryNV( GLsizei size,
24888fefafa2200d3ea44ec46592b190654a10685b46Brian Paul                          GLfloat readFrequency,
24898fefafa2200d3ea44ec46592b190654a10685b46Brian Paul                          GLfloat writeFrequency,
24908fefafa2200d3ea44ec46592b190654a10685b46Brian Paul                          GLfloat priority )
24918fefafa2200d3ea44ec46592b190654a10685b46Brian Paul{
24928fefafa2200d3ea44ec46592b190654a10685b46Brian Paul   (void) size;
24938fefafa2200d3ea44ec46592b190654a10685b46Brian Paul   (void) readFrequency;
24948fefafa2200d3ea44ec46592b190654a10685b46Brian Paul   (void) writeFrequency;
24958fefafa2200d3ea44ec46592b190654a10685b46Brian Paul   (void) priority;
24968fefafa2200d3ea44ec46592b190654a10685b46Brian Paul   return NULL;
24978fefafa2200d3ea44ec46592b190654a10685b46Brian Paul}
24988fefafa2200d3ea44ec46592b190654a10685b46Brian Paul
24998fefafa2200d3ea44ec46592b190654a10685b46Brian Paul
25008fefafa2200d3ea44ec46592b190654a10685b46Brian Paulstatic void
25018fefafa2200d3ea44ec46592b190654a10685b46Brian PaulFake_glXFreeMemoryNV( GLvoid *pointer )
25028fefafa2200d3ea44ec46592b190654a10685b46Brian Paul{
25038fefafa2200d3ea44ec46592b190654a10685b46Brian Paul   (void) pointer;
25048fefafa2200d3ea44ec46592b190654a10685b46Brian Paul}
25058fefafa2200d3ea44ec46592b190654a10685b46Brian Paul
25068fefafa2200d3ea44ec46592b190654a10685b46Brian Paul
250743c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul
2508e7b16b74bf5d13331b5a88bbbbb9096560297b63Brian Paulextern struct _glxapi_table *_mesa_GetGLXDispatchTable(void);
2509426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstruct _glxapi_table *_mesa_GetGLXDispatchTable(void)
2510426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2511426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   static struct _glxapi_table glx;
2512426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2513426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   /* be sure our dispatch table size <= libGL's table */
2514426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   {
251501915e90e6912f06d43d443a09157f7bbc96ddc5Brian Paul      GLuint size = sizeof(struct _glxapi_table) / sizeof(void *);
2516426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul      (void) size;
2517426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul      assert(_glxapi_get_dispatch_table_size() >= size);
2518426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   }
2519426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2520426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   /* initialize the whole table to no-ops */
2521426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   _glxapi_set_no_op_table(&glx);
2522426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2523426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   /* now initialize the table with the functions I implement */
2524426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.ChooseVisual = Fake_glXChooseVisual;
2525426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CopyContext = Fake_glXCopyContext;
2526426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CreateContext = Fake_glXCreateContext;
2527426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CreateGLXPixmap = Fake_glXCreateGLXPixmap;
2528426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.DestroyContext = Fake_glXDestroyContext;
2529426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.DestroyGLXPixmap = Fake_glXDestroyGLXPixmap;
2530426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.GetConfig = Fake_glXGetConfig;
2531426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   /*glx.GetCurrentContext = Fake_glXGetCurrentContext;*/
2532426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   /*glx.GetCurrentDrawable = Fake_glXGetCurrentDrawable;*/
2533426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.IsDirect = Fake_glXIsDirect;
2534426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.MakeCurrent = Fake_glXMakeCurrent;
2535426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.QueryExtension = Fake_glXQueryExtension;
2536426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.QueryVersion = Fake_glXQueryVersion;
2537426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.SwapBuffers = Fake_glXSwapBuffers;
2538426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.UseXFont = Fake_glXUseXFont;
2539426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.WaitGL = Fake_glXWaitGL;
2540426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.WaitX = Fake_glXWaitX;
2541426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2542b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_VERSION_1_1 ***/
2543426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.GetClientString = Fake_glXGetClientString;
2544426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.QueryExtensionsString = Fake_glXQueryExtensionsString;
2545426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.QueryServerString = Fake_glXQueryServerString;
2546426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2547b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_VERSION_1_2 ***/
2548426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   /*glx.GetCurrentDisplay = Fake_glXGetCurrentDisplay;*/
2549426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2550b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_VERSION_1_3 ***/
2551426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.ChooseFBConfig = Fake_glXChooseFBConfig;
2552426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CreateNewContext = Fake_glXCreateNewContext;
2553426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CreatePbuffer = Fake_glXCreatePbuffer;
2554426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CreatePixmap = Fake_glXCreatePixmap;
2555426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CreateWindow = Fake_glXCreateWindow;
2556426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.DestroyPbuffer = Fake_glXDestroyPbuffer;
2557426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.DestroyPixmap = Fake_glXDestroyPixmap;
2558426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.DestroyWindow = Fake_glXDestroyWindow;
2559426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   /*glx.GetCurrentReadDrawable = Fake_glXGetCurrentReadDrawable;*/
2560426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.GetFBConfigAttrib = Fake_glXGetFBConfigAttrib;
256171dea349d2be623b7819389428b0d6a124e8d184Brian Paul   glx.GetFBConfigs = Fake_glXGetFBConfigs;
2562426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.GetSelectedEvent = Fake_glXGetSelectedEvent;
2563426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.GetVisualFromFBConfig = Fake_glXGetVisualFromFBConfig;
2564426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.MakeContextCurrent = Fake_glXMakeContextCurrent;
2565426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.QueryContext = Fake_glXQueryContext;
2566426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.QueryDrawable = Fake_glXQueryDrawable;
2567426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.SelectEvent = Fake_glXSelectEvent;
2568426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2569b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGI_swap_control ***/
2570783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.SwapIntervalSGI = Fake_glXSwapIntervalSGI;
2571783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2572b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGI_video_sync ***/
2573426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.GetVideoSyncSGI = Fake_glXGetVideoSyncSGI;
2574426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.WaitVideoSyncSGI = Fake_glXWaitVideoSyncSGI;
2575426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2576b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGI_make_current_read ***/
2577783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.MakeCurrentReadSGI = Fake_glXMakeCurrentReadSGI;
25787cf50e137da497a590ec9001a9918972a6246142Brian Paul   /*glx.GetCurrentReadDrawableSGI = Fake_glXGetCurrentReadDrawableSGI;*/
2579783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2580b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_video_source ***/
2581b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#if defined(_VL_H)
2582783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.CreateGLXVideoSourceSGIX = Fake_glXCreateGLXVideoSourceSGIX;
2583783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.DestroyGLXVideoSourceSGIX = Fake_glXDestroyGLXVideoSourceSGIX;
2584783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul#endif
2585783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2586b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_EXT_import_context ***/
2587783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.FreeContextEXT = Fake_glXFreeContextEXT;
2588783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.GetContextIDEXT = Fake_glXGetContextIDEXT;
25897cf50e137da497a590ec9001a9918972a6246142Brian Paul   /*glx.GetCurrentDisplayEXT = Fake_glXGetCurrentDisplayEXT;*/
2590783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.ImportContextEXT = Fake_glXImportContextEXT;
2591783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.QueryContextInfoEXT = Fake_glXQueryContextInfoEXT;
25924536021a62e02fceaa6e8eb889b0f61743109cc4Brian Paul
2593b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGIX_fbconfig ***/
2594783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.GetFBConfigAttribSGIX = Fake_glXGetFBConfigAttribSGIX;
2595783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.ChooseFBConfigSGIX = Fake_glXChooseFBConfigSGIX;
2596783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.CreateGLXPixmapWithConfigSGIX = Fake_glXCreateGLXPixmapWithConfigSGIX;
2597783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.CreateContextWithConfigSGIX = Fake_glXCreateContextWithConfigSGIX;
2598783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.GetVisualFromFBConfigSGIX = Fake_glXGetVisualFromFBConfigSGIX;
2599783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.GetFBConfigFromVisualSGIX = Fake_glXGetFBConfigFromVisualSGIX;
2600783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2601b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGIX_pbuffer ***/
2602783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.CreateGLXPbufferSGIX = Fake_glXCreateGLXPbufferSGIX;
2603783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.DestroyGLXPbufferSGIX = Fake_glXDestroyGLXPbufferSGIX;
2604783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.QueryGLXPbufferSGIX = Fake_glXQueryGLXPbufferSGIX;
2605783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.SelectEventSGIX = Fake_glXSelectEventSGIX;
2606783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.GetSelectedEventSGIX = Fake_glXGetSelectedEventSGIX;
2607783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2608b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGI_cushion ***/
2609783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.CushionSGI = Fake_glXCushionSGI;
2610783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2611b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGIX_video_resize ***/
2612783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.BindChannelToWindowSGIX = Fake_glXBindChannelToWindowSGIX;
2613783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.ChannelRectSGIX = Fake_glXChannelRectSGIX;
2614783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.QueryChannelRectSGIX = Fake_glXQueryChannelRectSGIX;
2615783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.QueryChannelDeltasSGIX = Fake_glXQueryChannelDeltasSGIX;
2616783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.ChannelRectSyncSGIX = Fake_glXChannelRectSyncSGIX;
2617783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2618b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGIX_dmbuffer **/
2619b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#if defined(_DM_BUFFER_H_)
2620783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.AssociateDMPbufferSGIX = NULL;
2621783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul#endif
2622783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2623b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGIX_swap_group ***/
2624783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.JoinSwapGroupSGIX = Fake_glXJoinSwapGroupSGIX;
2625783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2626b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGIX_swap_barrier ***/
2627783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.BindSwapBarrierSGIX = Fake_glXBindSwapBarrierSGIX;
2628783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.QueryMaxSwapBarriersSGIX = Fake_glXQueryMaxSwapBarriersSGIX;
2629783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2630b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SUN_get_transparent_index ***/
2631783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.GetTransparentIndexSUN = Fake_glXGetTransparentIndexSUN;
26324536021a62e02fceaa6e8eb889b0f61743109cc4Brian Paul
2633b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_MESA_copy_sub_buffer ***/
2634426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CopySubBufferMESA = Fake_glXCopySubBufferMESA;
2635426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2636b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_MESA_release_buffers ***/
2637426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.ReleaseBuffersMESA = Fake_glXReleaseBuffersMESA;
2638426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2639b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_MESA_pixmap_colormap ***/
2640426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CreateGLXPixmapMESA = Fake_glXCreateGLXPixmapMESA;
2641426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2642b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_MESA_set_3dfx_mode ***/
2643426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.Set3DfxModeMESA = Fake_glXSet3DfxModeMESA;
2644426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
26458fefafa2200d3ea44ec46592b190654a10685b46Brian Paul   /*** GLX AGP memory allocation ***/
26468fefafa2200d3ea44ec46592b190654a10685b46Brian Paul   glx.AllocateMemoryNV = Fake_glXAllocateMemoryNV;
26478fefafa2200d3ea44ec46592b190654a10685b46Brian Paul   glx.FreeMemoryNV = Fake_glXFreeMemoryNV;
26488fefafa2200d3ea44ec46592b190654a10685b46Brian Paul
2649426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   return &glx;
2650426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2651