fakeglx.c revision dfa5c2bfbbba1e24829582863caeafd97f124d5e
1afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
2afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Mesa 3-D graphics library
311b3028e7ba2fc3b985ab84d7227c290608f83f6Brian Paul * Version:  6.1
45e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen *
53a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul * Copyright (C) 1999-2004  Brian Paul   All Rights Reserved.
65e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen *
7afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Permission is hereby granted, free of charge, to any person obtaining a
8afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * copy of this software and associated documentation files (the "Software"),
9afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * to deal in the Software without restriction, including without limitation
10afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * and/or sell copies of the Software, and to permit persons to whom the
12afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Software is furnished to do so, subject to the following conditions:
135e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen *
14afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * The above copyright notice and this permission notice shall be included
15afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * in all copies or substantial portions of the Software.
165e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen *
17afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
24afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
25afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
26afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
2736cfa38760cc2bd91c08b66bb62c4b6cf9eb5454Brian Paul * This is an emulation of the GLX API which allows Mesa/GLX-based programs
2836cfa38760cc2bd91c08b66bb62c4b6cf9eb5454Brian Paul * to run on X servers which do not have the real GLX extension.
29afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *
30afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Thanks to the contributors:
31afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *
32ddf69f247fdb246b99ef6525fcfa6eda7b2e2aa7Brian Paul * Initial version:  Philip Brown (phil@bolthole.com)
33afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Better glXGetConfig() support: Armin Liebchen (liebchen@asylum.cs.utah.edu)
34afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Further visual-handling refinements: Wolfram Gloger
35afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *    (wmglo@Dent.MED.Uni-Muenchen.DE).
36afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *
37afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Notes:
38afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *   Don't be fooled, stereo isn't supported yet.
39afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
40afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
41afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
42afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
43fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul#include "glxheader.h"
44426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul#include "glxapi.h"
45afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#include "GL/xmesa.h"
46afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#include "context.h"
47afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#include "config.h"
48afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#include "macros.h"
493c63452e64df7e10aa073c6c3b9492b1d7dabbb8Brian Paul#include "imports.h"
505e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen#include "mtypes.h"
512c5f93784ea1ba28ae15181917ff3e47656a93adBrian Paul#include "version.h"
5271dea349d2be623b7819389428b0d6a124e8d184Brian Paul#include "xfonts.h"
53afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#include "xmesaP.h"
54afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
55afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
5678fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul/* This indicates the client-side GLX API and GLX encoder version. */
5778fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul#define CLIENT_MAJOR_VERSION 1
58a573803ed3fe9ef6489f45bd4c5455b77cb33a43Brian Paul#define CLIENT_MINOR_VERSION 4  /* but don't have 1.3's pbuffers, etc yet */
5978fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul
6078fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul/* This indicates the server-side GLX decoder version.
61ba57e5297d60eef37e43dd4d7f10d1e62f5e97ceBrian Paul * GLX 1.4 indicates OpenGL 1.3 support
6278fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul */
6378fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul#define SERVER_MAJOR_VERSION 1
64ba57e5297d60eef37e43dd4d7f10d1e62f5e97ceBrian Paul#define SERVER_MINOR_VERSION 4
6578fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul
6678fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul/* This is appended onto the glXGetClient/ServerString version strings. */
672c5f93784ea1ba28ae15181917ff3e47656a93adBrian Paul#define MESA_GLX_VERSION "Mesa " MESA_VERSION_STRING
6878fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul
6978fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul/* Who implemented this GLX? */
7078fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul#define VENDOR "Brian Paul"
7178fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul
72e4656003caee346d9c4eb23256d73409271291a7Brian Paul#define EXTENSIONS \
73e4656003caee346d9c4eb23256d73409271291a7Brian Paul   "GLX_MESA_set_3dfx_mode " \
74e4656003caee346d9c4eb23256d73409271291a7Brian Paul   "GLX_MESA_copy_sub_buffer " \
75e4656003caee346d9c4eb23256d73409271291a7Brian Paul   "GLX_MESA_pixmap_colormap " \
76e4656003caee346d9c4eb23256d73409271291a7Brian Paul   "GLX_MESA_release_buffers " \
77e4656003caee346d9c4eb23256d73409271291a7Brian Paul   "GLX_ARB_get_proc_address " \
78e4656003caee346d9c4eb23256d73409271291a7Brian Paul   "GLX_EXT_visual_info " \
79e4656003caee346d9c4eb23256d73409271291a7Brian Paul   "GLX_EXT_visual_rating " \
80e4656003caee346d9c4eb23256d73409271291a7Brian Paul   "GLX_SGI_video_sync " \
81e4656003caee346d9c4eb23256d73409271291a7Brian Paul   "GLX_SGIX_fbconfig " \
826d6efd605f662c1f07e183e58416db804f0a058fBrian Paul   "GLX_SGIX_pbuffer "
836d6efd605f662c1f07e183e58416db804f0a058fBrian Paul/*
843c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian Paul   "GLX_ARB_render_texture"
856d6efd605f662c1f07e183e58416db804f0a058fBrian Paul*/
86afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
8743c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul
887cf50e137da497a590ec9001a9918972a6246142Brian Paul/*
897cf50e137da497a590ec9001a9918972a6246142Brian Paul * Our fake GLX context will contain a "real" GLX context and an XMesa context.
907cf50e137da497a590ec9001a9918972a6246142Brian Paul *
917cf50e137da497a590ec9001a9918972a6246142Brian Paul * Note that a pointer to a __GLXcontext is a pointer to a fake_glx_context,
927cf50e137da497a590ec9001a9918972a6246142Brian Paul * and vice versa.
937cf50e137da497a590ec9001a9918972a6246142Brian Paul *
947cf50e137da497a590ec9001a9918972a6246142Brian Paul * We really just need this structure in order to make the libGL functions
957cf50e137da497a590ec9001a9918972a6246142Brian Paul * glXGetCurrentContext(), glXGetCurrentDrawable() and glXGetCurrentDisplay()
967cf50e137da497a590ec9001a9918972a6246142Brian Paul * work correctly.
977cf50e137da497a590ec9001a9918972a6246142Brian Paul */
987cf50e137da497a590ec9001a9918972a6246142Brian Paulstruct fake_glx_context {
997cf50e137da497a590ec9001a9918972a6246142Brian Paul   __GLXcontext glxContext;   /* this MUST be first! */
1007cf50e137da497a590ec9001a9918972a6246142Brian Paul   XMesaContext xmesaContext;
1017cf50e137da497a590ec9001a9918972a6246142Brian Paul};
10243c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul
103afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
104afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1057cf50e137da497a590ec9001a9918972a6246142Brian Paul/**********************************************************************/
1067cf50e137da497a590ec9001a9918972a6246142Brian Paul/***                       GLX Visual Code                          ***/
1077cf50e137da497a590ec9001a9918972a6246142Brian Paul/**********************************************************************/
1087cf50e137da497a590ec9001a9918972a6246142Brian Paul
1097cf50e137da497a590ec9001a9918972a6246142Brian Paul#define DONT_CARE -1
1107cf50e137da497a590ec9001a9918972a6246142Brian Paul
111afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
112afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#define MAX_VISUALS 100
113afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XMesaVisual VisualTable[MAX_VISUALS];
114afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic int NumVisuals = 0;
115afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
116afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
117afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
118afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * This struct and some code fragments borrowed
119afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * from Mark Kilgard's GLUT library.
120afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
121afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgtypedef struct _OverlayInfo {
122afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg  /* Avoid 64-bit portability problems by being careful to use
123afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg     longs due to the way XGetWindowProperty is specified. Note
124afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg     that these parameters are passed as CARD32s over X
125afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg     protocol. */
126afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg  unsigned long overlay_visual;
127afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg  long transparent_type;
128afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg  long value;
129afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg  long layer;
130afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} OverlayInfo;
131afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
132afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
133afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
134afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* Macro to handle c_class vs class field name in XVisualInfo struct */
135afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#if defined(__cplusplus) || defined(c_plusplus)
136afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#define CLASS c_class
137afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#else
138afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#define CLASS class
139afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#endif
140afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
141afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
142afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
143afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
144afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
145afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Test if the given XVisualInfo is usable for Mesa rendering.
146afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
147afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic GLboolean is_usable_visual( XVisualInfo *vinfo )
148afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
149afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   switch (vinfo->CLASS) {
150afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case StaticGray:
151afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GrayScale:
152afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* Any StaticGray/GrayScale visual works in RGB or CI mode */
153afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return GL_TRUE;
154afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case StaticColor:
155afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case PseudoColor:
156afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 /* Any StaticColor/PseudoColor visual of at least 4 bits */
157afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 if (vinfo->depth>=4) {
158afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    return GL_TRUE;
159afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 }
160afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 else {
161afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    return GL_FALSE;
162afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 }
163afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case TrueColor:
164afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case DirectColor:
165afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 /* Any depth of TrueColor or DirectColor works in RGB mode */
166afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return GL_TRUE;
167afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      default:
168afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 /* This should never happen */
169afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return GL_FALSE;
170afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
171afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
172afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
173afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
174afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
175afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
176afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return the level (overlay, normal, underlay) of a given XVisualInfo.
177afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input:  dpy - the X display
178afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         vinfo - the XVisualInfo to test
179afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return:  level of the visual:
180afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *             0 = normal planes
181afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *            >0 = overlay planes
182afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *            <0 = underlay planes
183afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
184afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic int level_of_visual( Display *dpy, XVisualInfo *vinfo )
185afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
186afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   Atom overlayVisualsAtom;
187afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   OverlayInfo *overlay_info = NULL;
188afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int numOverlaysPerScreen;
189afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   Status status;
190afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   Atom actualType;
191afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int actualFormat;
192afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   unsigned long sizeData, bytesLeft;
193afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int i;
194afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
195afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /*
196afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * The SERVER_OVERLAY_VISUALS property on the root window contains
197afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * a list of overlay visuals.  Get that list now.
198afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    */
199afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   overlayVisualsAtom = XInternAtom(dpy,"SERVER_OVERLAY_VISUALS", True);
200afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (overlayVisualsAtom == None) {
201afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return 0;
202afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
203afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
204afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   status = XGetWindowProperty(dpy, RootWindow( dpy, vinfo->screen ),
205afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               overlayVisualsAtom, 0L, (long) 10000, False,
206afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               overlayVisualsAtom, &actualType, &actualFormat,
207afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               &sizeData, &bytesLeft,
208afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               (unsigned char **) &overlay_info );
209afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
210afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (status != Success || actualType != overlayVisualsAtom ||
211afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg       actualFormat != 32 || sizeData < 4) {
212afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* something went wrong */
213afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      XFree((void *) overlay_info);
214afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return 0;
215afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
216afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
217afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* search the overlay visual list for the visual ID of interest */
218afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   numOverlaysPerScreen = (int) (sizeData / 4);
219afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   for (i=0;i<numOverlaysPerScreen;i++) {
220afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      OverlayInfo *ov;
221afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      ov = overlay_info + i;
222afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (ov->overlay_visual==vinfo->visualid) {
223afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* found the visual */
224afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         if (/*ov->transparent_type==1 &&*/ ov->layer!=0) {
225afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            int level = ov->layer;
226afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            XFree((void *) overlay_info);
227afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            return level;
228afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
229afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         else {
230afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            XFree((void *) overlay_info);
231afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            return 0;
232afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
233afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
234afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
235afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
236afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* The visual ID was not found in the overlay list. */
237afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XFree((void *) overlay_info);
238afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return 0;
239afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
240afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
241afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
242afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
243afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
244afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
245afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Given an XVisualInfo and RGB, Double, and Depth buffer flags, save the
246afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * configuration in our list of GLX visuals.
247afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
248afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XMesaVisual
249afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgsave_glx_visual( Display *dpy, XVisualInfo *vinfo,
250afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                 GLboolean rgbFlag, GLboolean alphaFlag, GLboolean dbFlag,
251afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                 GLboolean stereoFlag,
252afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                 GLint depth_size, GLint stencil_size,
253b2e460018375f699198073a6167e0ee96ba1d267Brian Paul                 GLint accumRedSize, GLint accumGreenSize,
254b2e460018375f699198073a6167e0ee96ba1d267Brian Paul                 GLint accumBlueSize, GLint accumAlphaSize,
255894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul                 GLint level, GLint numAuxBuffers )
256afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
257afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLboolean ximageFlag = GL_TRUE;
258afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaVisual xmvis;
259afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLint i;
260afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLboolean comparePointers;
261afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
262afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (dbFlag) {
263afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* Check if the MESA_BACK_BUFFER env var is set */
264367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul      char *backbuffer = _mesa_getenv("MESA_BACK_BUFFER");
265afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (backbuffer) {
266afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         if (backbuffer[0]=='p' || backbuffer[0]=='P') {
267afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            ximageFlag = GL_FALSE;
268afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
269afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         else if (backbuffer[0]=='x' || backbuffer[0]=='X') {
270afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            ximageFlag = GL_TRUE;
271afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
272afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         else {
273d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul            _mesa_warning(NULL, "Mesa: invalid value for MESA_BACK_BUFFER environment variable, using an XImage.");
274afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
275afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
276afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
277afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
278afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* Comparing IDs uses less memory but sometimes fails. */
279afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* XXX revisit this after 3.0 is finished. */
280367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul   if (_mesa_getenv("MESA_GLX_VISUAL_HACK"))
281afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      comparePointers = GL_TRUE;
282afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else
283afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      comparePointers = GL_FALSE;
284afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
285a13331d59b535aa4a1ddad695420de5d6f814550Brian Paul   /* Force the visual to have an alpha channel */
286a13331d59b535aa4a1ddad695420de5d6f814550Brian Paul   if (rgbFlag && _mesa_getenv("MESA_GLX_FORCE_ALPHA"))
287a13331d59b535aa4a1ddad695420de5d6f814550Brian Paul      alphaFlag = GL_TRUE;
288a13331d59b535aa4a1ddad695420de5d6f814550Brian Paul
289afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* First check if a matching visual is already in the list */
290afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   for (i=0; i<NumVisuals; i++) {
291afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      XMesaVisual v = VisualTable[i];
292afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (v->display == dpy
293304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick          && v->mesa_visual.level == level
294894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul          && v->mesa_visual.numAuxBuffers == numAuxBuffers
295afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg          && v->ximage_flag == ximageFlag
2961832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && v->mesa_visual.rgbMode == rgbFlag
2971832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && v->mesa_visual.doubleBufferMode == dbFlag
2981832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && v->mesa_visual.stereoMode == stereoFlag
2991832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && (v->mesa_visual.alphaBits > 0) == alphaFlag
3001832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && (v->mesa_visual.depthBits >= depth_size || depth_size == 0)
3011832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && (v->mesa_visual.stencilBits >= stencil_size || stencil_size == 0)
3021832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && (v->mesa_visual.accumRedBits >= accumRedSize || accumRedSize == 0)
3031832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && (v->mesa_visual.accumGreenBits >= accumGreenSize || accumGreenSize == 0)
3041832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && (v->mesa_visual.accumBlueBits >= accumBlueSize || accumBlueSize == 0)
3051832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && (v->mesa_visual.accumAlphaBits >= accumAlphaSize || accumAlphaSize == 0)) {
306afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* now either compare XVisualInfo pointers or visual IDs */
307d0247f53aea8fa8677aadc8a00f75c8993be9ebcBrian Paul         if ((!comparePointers && v->visinfo->visualid == vinfo->visualid)
308afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg             || (comparePointers && v->vishandle == vinfo)) {
309afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            return v;
310afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
311afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
312afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
313afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
314afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* Create a new visual and add it to the list. */
315afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
316d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul   if (NumVisuals >= MAX_VISUALS) {
317d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul      _mesa_problem(NULL, "GLX Error: maximum number of visuals exceeded");
318afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return NULL;
319afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
320afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
321c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul   xmvis = XMesaCreateVisual( dpy, vinfo, rgbFlag, alphaFlag, dbFlag,
322c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul                              stereoFlag, ximageFlag,
323c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul                              depth_size, stencil_size,
324c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul                              accumRedSize, accumBlueSize,
325c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul                              accumBlueSize, accumAlphaSize, 0, level,
326c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul                              GLX_NONE_EXT );
327afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (xmvis) {
328f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      /* Save a copy of the pointer now so we can find this visual again
329f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul       * if we need to search for it in find_glx_visual().
330f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul       */
331f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      xmvis->vishandle = vinfo;
332f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      /* add xmvis to the list */
333afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      VisualTable[NumVisuals] = xmvis;
334afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      NumVisuals++;
335894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul      /* XXX minor hack */
336894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul      xmvis->mesa_visual.numAuxBuffers = numAuxBuffers;
337afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
338afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return xmvis;
339afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
340afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
341afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
342dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul/**
343dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul * Return the default number of bits for the Z buffer.
344dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul * If defined, use the MESA_GLX_DEPTH_BITS env var value.
345dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul * Otherwise, use the DEFAULT_SOFTWARE_DEPTH_BITS constant.
346dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul * XXX probably do the same thing for stencil, accum, etc.
347dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul */
348dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paulstatic GLint
349dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Pauldefault_depth_bits(void)
350dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul{
351dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul   int zBits;
352dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul   const char *zEnv = _mesa_getenv("MESA_GLX_DEPTH_BITS");
353dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul   if (zEnv)
354dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul      zBits = _mesa_atoi(zEnv);
355dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul   else
356dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul      zBits = DEFAULT_SOFTWARE_DEPTH_BITS;
357dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul   return zBits;
358dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul}
359dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul
360dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul
361afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
362afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
363afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Create a GLX visual from a regular XVisualInfo.
364ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * This is called when Fake GLX is given an XVisualInfo which wasn't
365ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * returned by glXChooseVisual.  Since this is the first time we're
366ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * considering this visual we'll take a guess at reasonable values
367ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * for depth buffer size, stencil size, accum size, etc.
368ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * This is the best we can do with a client-side emulation of GLX.
369afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
370afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XMesaVisual
371afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgcreate_glx_visual( Display *dpy, XVisualInfo *visinfo )
372afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
373afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int vislevel;
374dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul   GLint zBits = default_depth_bits();
375afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
376afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   vislevel = level_of_visual( dpy, visinfo );
377afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (vislevel) {
378afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* Configure this visual as a CI, single-buffered overlay */
379afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return save_glx_visual( dpy, visinfo,
380afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                              GL_FALSE,  /* rgb */
381afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                              GL_FALSE,  /* alpha */
382afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                              GL_FALSE,  /* double */
383afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                              GL_FALSE,  /* stereo */
384afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                              0,         /* depth bits */
385afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                              0,         /* stencil bits */
386b2e460018375f699198073a6167e0ee96ba1d267Brian Paul                              0,0,0,0,   /* accum bits */
387894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul                              vislevel,  /* level */
388894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul                              0          /* numAux */
389afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                            );
390afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
391afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else if (is_usable_visual( visinfo )) {
392367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul      if (_mesa_getenv("MESA_GLX_FORCE_CI")) {
3938f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul         /* Configure this visual as a COLOR INDEX visual. */
3948f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul         return save_glx_visual( dpy, visinfo,
3958f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 GL_FALSE,   /* rgb */
3968f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 GL_FALSE,  /* alpha */
3978f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 GL_TRUE,   /* double */
3988f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 GL_FALSE,  /* stereo */
399dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul                                 zBits,
4008f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 8 * sizeof(GLstencil),
4018f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 0 * sizeof(GLaccum), /* r */
4028f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 0 * sizeof(GLaccum), /* g */
4038f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 0 * sizeof(GLaccum), /* b */
4048f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 0 * sizeof(GLaccum), /* a */
405894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul                                 0,         /* level */
406894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul                                 0          /* numAux */
4078f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                               );
4088f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul      }
4098f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul      else {
4108f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul         /* Configure this visual as RGB, double-buffered, depth-buffered. */
4118f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul         /* This is surely wrong for some people's needs but what else */
4128f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul         /* can be done?  They should use glXChooseVisual(). */
4138f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul         return save_glx_visual( dpy, visinfo,
4148f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 GL_TRUE,   /* rgb */
4158f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 GL_FALSE,  /* alpha */
4168f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 GL_TRUE,   /* double */
4178f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 GL_FALSE,  /* stereo */
418dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul                                 zBits,
4198f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 8 * sizeof(GLstencil),
4208f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 8 * sizeof(GLaccum), /* r */
4218f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 8 * sizeof(GLaccum), /* g */
4228f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 8 * sizeof(GLaccum), /* b */
4238f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 8 * sizeof(GLaccum), /* a */
424894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul                                 0,         /* level */
425894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul                                 0          /* numAux */
4268f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                               );
4278f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul      }
428afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
429afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else {
430d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul      _mesa_warning(NULL, "Mesa: error in glXCreateContext: bad visual\n");
431afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return NULL;
432afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
433afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
434afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
435afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
436afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
437afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
438afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Find the GLX visual associated with an XVisualInfo.
439afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
440afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XMesaVisual
441afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgfind_glx_visual( Display *dpy, XVisualInfo *vinfo )
442afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
443afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int i;
444afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
445f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   /* try to match visual id */
446afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   for (i=0;i<NumVisuals;i++) {
447f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      if (VisualTable[i]->display==dpy
448f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul          && VisualTable[i]->visinfo->visualid == vinfo->visualid) {
449afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return VisualTable[i];
450afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
451afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
452f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul
453f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   /* if that fails, try to match pointers */
454afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   for (i=0;i<NumVisuals;i++) {
455f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      if (VisualTable[i]->display==dpy && VisualTable[i]->vishandle==vinfo) {
456afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return VisualTable[i];
457afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
458afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
459f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul
460afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return NULL;
461afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
462afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
463afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
464afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
465afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
466afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return the transparent pixel value for a GLX visual.
467afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input:  glxvis - the glx_visual
468afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return:  a pixel value or -1 if no transparent pixel
469afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
470afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic int transparent_pixel( XMesaVisual glxvis )
471afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
472afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   Display *dpy = glxvis->display;
473afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XVisualInfo *vinfo = glxvis->visinfo;
474afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   Atom overlayVisualsAtom;
475afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   OverlayInfo *overlay_info = NULL;
476afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int numOverlaysPerScreen;
477afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   Status status;
478afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   Atom actualType;
479afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int actualFormat;
480afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   unsigned long sizeData, bytesLeft;
481afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int i;
482afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
483afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /*
484afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * The SERVER_OVERLAY_VISUALS property on the root window contains
485afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * a list of overlay visuals.  Get that list now.
486afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    */
487afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   overlayVisualsAtom = XInternAtom(dpy,"SERVER_OVERLAY_VISUALS", True);
488afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (overlayVisualsAtom == None) {
489afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return -1;
490afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
491afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
492afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   status = XGetWindowProperty(dpy, RootWindow( dpy, vinfo->screen ),
493afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               overlayVisualsAtom, 0L, (long) 10000, False,
494afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               overlayVisualsAtom, &actualType, &actualFormat,
495afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               &sizeData, &bytesLeft,
496afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               (unsigned char **) &overlay_info );
497afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
498afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (status != Success || actualType != overlayVisualsAtom ||
499afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg       actualFormat != 32 || sizeData < 4) {
500afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* something went wrong */
501afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      XFree((void *) overlay_info);
502afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return -1;
503afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
504afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
505afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* search the overlay visual list for the visual ID of interest */
506afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   numOverlaysPerScreen = (int) (sizeData / 4);
507afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   for (i=0;i<numOverlaysPerScreen;i++) {
508afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      OverlayInfo *ov;
509afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      ov = overlay_info + i;
510afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (ov->overlay_visual==vinfo->visualid) {
511afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* found it! */
512afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         if (ov->transparent_type==0) {
513afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* type 0 indicates no transparency */
514afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            XFree((void *) overlay_info);
515afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            return -1;
516afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
517afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         else {
518afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* ov->value is the transparent pixel */
519afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            XFree((void *) overlay_info);
520afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            return ov->value;
521afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
522afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
523afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
524afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
525afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* The visual ID was not found in the overlay list. */
526afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XFree((void *) overlay_info);
527afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return -1;
528afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
529afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
530afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
531afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
532afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
533afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Try to get an X visual which matches the given arguments.
534afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
535afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XVisualInfo *get_visual( Display *dpy, int scr,
536afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg			        unsigned int depth, int xclass )
537afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
538afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XVisualInfo temp, *vis;
539afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   long mask;
540afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int n;
541afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   unsigned int default_depth;
542afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int default_class;
543afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
544afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   mask = VisualScreenMask | VisualDepthMask | VisualClassMask;
545afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   temp.screen = scr;
546afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   temp.depth = depth;
547afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   temp.CLASS = xclass;
548afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
549afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   default_depth = DefaultDepth(dpy,scr);
550afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   default_class = DefaultVisual(dpy,scr)->CLASS;
551afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
552afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (depth==default_depth && xclass==default_class) {
553afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* try to get root window's visual */
554afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      temp.visualid = DefaultVisual(dpy,scr)->visualid;
555afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      mask |= VisualIDMask;
556afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
557afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
558afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   vis = XGetVisualInfo( dpy, mask, &temp, &n );
559afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
560afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* In case bits/pixel > 24, make sure color channels are still <=8 bits.
561afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * An SGI Infinite Reality system, for example, can have 30bpp pixels:
562afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * 10 bits per color channel.  Mesa's limited to a max of 8 bits/channel.
563afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    */
564afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (vis && depth > 24 && (xclass==TrueColor || xclass==DirectColor)) {
56571dea349d2be623b7819389428b0d6a124e8d184Brian Paul      if (_mesa_bitcount((GLuint) vis->red_mask  ) <= 8 &&
56671dea349d2be623b7819389428b0d6a124e8d184Brian Paul          _mesa_bitcount((GLuint) vis->green_mask) <= 8 &&
56771dea349d2be623b7819389428b0d6a124e8d184Brian Paul          _mesa_bitcount((GLuint) vis->blue_mask ) <= 8) {
568afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return vis;
569afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
570afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      else {
571afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         XFree((void *) vis);
572afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return NULL;
573afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
574afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
575afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
576afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return vis;
577afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
578afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
579afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
580afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
581afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
582afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Retrieve the value of the given environment variable and find
583afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * the X visual which matches it.
584afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input:  dpy - the display
585afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         screen - the screen number
586afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         varname - the name of the environment variable
587afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return:  an XVisualInfo pointer to NULL if error.
588afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
589afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XVisualInfo *get_env_visual(Display *dpy, int scr, const char *varname)
590afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
591afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   char value[100], type[100];
592afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int depth, xclass = -1;
593afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XVisualInfo *vis;
594afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
595367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul   if (!_mesa_getenv( varname )) {
596afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return NULL;
597afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
598afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
599367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul   _mesa_strncpy( value, _mesa_getenv(varname), 100 );
600afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   value[99] = 0;
601afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
602afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   sscanf( value, "%s %d", type, &depth );
603afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
604367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul   if (_mesa_strcmp(type,"TrueColor")==0)          xclass = TrueColor;
605367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul   else if (_mesa_strcmp(type,"DirectColor")==0)   xclass = DirectColor;
606367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul   else if (_mesa_strcmp(type,"PseudoColor")==0)   xclass = PseudoColor;
607367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul   else if (_mesa_strcmp(type,"StaticColor")==0)   xclass = StaticColor;
608367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul   else if (_mesa_strcmp(type,"GrayScale")==0)     xclass = GrayScale;
609367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul   else if (_mesa_strcmp(type,"StaticGray")==0)    xclass = StaticGray;
610afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
611afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (xclass>-1 && depth>0) {
612afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      vis = get_visual( dpy, scr, depth, xclass );
613afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (vis) {
614afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return vis;
615afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
616afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
617afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
6182ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul   _mesa_warning(NULL, "GLX unable to find visual class=%s, depth=%d.",
6192ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul                 type, depth);
620d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul
621afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return NULL;
622afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
623afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
624afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
625afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
626afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
627afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Select an X visual which satisfies the RGBA/CI flag and minimum depth.
628afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input:  dpy, screen - X display and screen number
629afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         rgba - GL_TRUE = RGBA mode, GL_FALSE = CI mode
630afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         min_depth - minimum visual depth
631afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         preferred_class - preferred GLX visual class or DONT_CARE
632afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return:  pointer to an XVisualInfo or NULL.
633afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
634afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XVisualInfo *choose_x_visual( Display *dpy, int screen,
635afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg				     GLboolean rgba, int min_depth,
636afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                                     int preferred_class )
637afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
638afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XVisualInfo *vis;
639db6aa58267cad3f502f03ab80b9deb6b75320a91Brian Paul   int xclass, visclass = 0;
640afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int depth;
641afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
642afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (rgba) {
643afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      Atom hp_cr_maps = XInternAtom(dpy, "_HP_RGB_SMOOTH_MAP_LIST", True);
644afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* First see if the MESA_RGB_VISUAL env var is defined */
645afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      vis = get_env_visual( dpy, screen, "MESA_RGB_VISUAL" );
646afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (vis) {
647afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return vis;
648afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
649afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* Otherwise, search for a suitable visual */
650afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (preferred_class==DONT_CARE) {
651afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         for (xclass=0;xclass<6;xclass++) {
652afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            switch (xclass) {
653afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 0:  visclass = TrueColor;    break;
654afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 1:  visclass = DirectColor;  break;
655afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 2:  visclass = PseudoColor;  break;
656afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 3:  visclass = StaticColor;  break;
657afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 4:  visclass = GrayScale;    break;
658afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 5:  visclass = StaticGray;   break;
659afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
660afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            if (min_depth==0) {
661afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               /* start with shallowest */
662afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               for (depth=0;depth<=32;depth++) {
663afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  if (visclass==TrueColor && depth==8 && !hp_cr_maps) {
664afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     /* Special case:  try to get 8-bit PseudoColor before */
665afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     /* 8-bit TrueColor */
666afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     vis = get_visual( dpy, screen, 8, PseudoColor );
667afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     if (vis) {
668afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                        return vis;
669afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     }
670afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  }
671afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  vis = get_visual( dpy, screen, depth, visclass );
672afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  if (vis) {
673afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     return vis;
674afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  }
675afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               }
676afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
677afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            else {
678afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               /* start with deepest */
679afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               for (depth=32;depth>=min_depth;depth--) {
680afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  if (visclass==TrueColor && depth==8 && !hp_cr_maps) {
681afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     /* Special case:  try to get 8-bit PseudoColor before */
682afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     /* 8-bit TrueColor */
683afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     vis = get_visual( dpy, screen, 8, PseudoColor );
684afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     if (vis) {
685afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                        return vis;
686afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     }
687afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  }
688afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  vis = get_visual( dpy, screen, depth, visclass );
689afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  if (vis) {
690afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     return vis;
691afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  }
692afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               }
693afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
694afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
695afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
696afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      else {
697afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* search for a specific visual class */
698afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         switch (preferred_class) {
699afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_TRUE_COLOR_EXT:    visclass = TrueColor;    break;
700afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_DIRECT_COLOR_EXT:  visclass = DirectColor;  break;
701afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_PSEUDO_COLOR_EXT:  visclass = PseudoColor;  break;
702afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_STATIC_COLOR_EXT:  visclass = StaticColor;  break;
703afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_GRAY_SCALE_EXT:    visclass = GrayScale;    break;
704afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_STATIC_GRAY_EXT:   visclass = StaticGray;   break;
705afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            default:   return NULL;
706afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
707afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         if (min_depth==0) {
708afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* start with shallowest */
709afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            for (depth=0;depth<=32;depth++) {
710afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               vis = get_visual( dpy, screen, depth, visclass );
711afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               if (vis) {
712afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  return vis;
713afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               }
714afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
715afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
716afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         else {
717afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* start with deepest */
718afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            for (depth=32;depth>=min_depth;depth--) {
719afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               vis = get_visual( dpy, screen, depth, visclass );
720afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               if (vis) {
721afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  return vis;
722afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               }
723afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
724afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
725afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
726afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
727afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else {
728afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* First see if the MESA_CI_VISUAL env var is defined */
729afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      vis = get_env_visual( dpy, screen, "MESA_CI_VISUAL" );
730afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (vis) {
731afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return vis;
732afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
733afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* Otherwise, search for a suitable visual, starting with shallowest */
734afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (preferred_class==DONT_CARE) {
735afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         for (xclass=0;xclass<4;xclass++) {
736afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            switch (xclass) {
737afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 0:  visclass = PseudoColor;  break;
738afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 1:  visclass = StaticColor;  break;
739afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 2:  visclass = GrayScale;    break;
740afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 3:  visclass = StaticGray;   break;
741afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
742afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* try 8-bit up through 16-bit */
743afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            for (depth=8;depth<=16;depth++) {
744afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               vis = get_visual( dpy, screen, depth, visclass );
745afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               if (vis) {
746afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  return vis;
747afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               }
748afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
749afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* try min_depth up to 8-bit */
750afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            for (depth=min_depth;depth<8;depth++) {
751afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               vis = get_visual( dpy, screen, depth, visclass );
752afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               if (vis) {
753afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  return vis;
754afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               }
755afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
756afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
757afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
758afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      else {
759afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* search for a specific visual class */
760afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         switch (preferred_class) {
761afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_TRUE_COLOR_EXT:    visclass = TrueColor;    break;
762afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_DIRECT_COLOR_EXT:  visclass = DirectColor;  break;
763afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_PSEUDO_COLOR_EXT:  visclass = PseudoColor;  break;
764afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_STATIC_COLOR_EXT:  visclass = StaticColor;  break;
765afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_GRAY_SCALE_EXT:    visclass = GrayScale;    break;
766afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_STATIC_GRAY_EXT:   visclass = StaticGray;   break;
767afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            default:   return NULL;
768afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
769afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* try 8-bit up through 16-bit */
770afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         for (depth=8;depth<=16;depth++) {
771afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            vis = get_visual( dpy, screen, depth, visclass );
772afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            if (vis) {
773afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               return vis;
774afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
775afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
776afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* try min_depth up to 8-bit */
777afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         for (depth=min_depth;depth<8;depth++) {
778afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            vis = get_visual( dpy, screen, depth, visclass );
779afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            if (vis) {
780afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               return vis;
781afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
782afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
783afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
784afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
785afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
786afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* didn't find a visual */
787afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return NULL;
788afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
789afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
790afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
791afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
792afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
793afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Find the deepest X over/underlay visual of at least min_depth.
794afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input:  dpy, screen - X display and screen number
795afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         level - the over/underlay level
796afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         trans_type - transparent pixel type: GLX_NONE_EXT,
797afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *                      GLX_TRANSPARENT_RGB_EXT, GLX_TRANSPARENT_INDEX_EXT,
798afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *                      or DONT_CARE
799afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         trans_value - transparent pixel value or DONT_CARE
800afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         min_depth - minimum visual depth
801afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         preferred_class - preferred GLX visual class or DONT_CARE
802afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return:  pointer to an XVisualInfo or NULL.
803afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
804afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XVisualInfo *choose_x_overlay_visual( Display *dpy, int scr,
80542f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul                                             GLboolean rgbFlag,
806afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                                             int level, int trans_type,
807afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                                             int trans_value,
808afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                                             int min_depth,
809afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                                             int preferred_class )
810afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
811afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   Atom overlayVisualsAtom;
812afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   OverlayInfo *overlay_info;
813afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int numOverlaysPerScreen;
814afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   Status status;
815afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   Atom actualType;
816afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int actualFormat;
817afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   unsigned long sizeData, bytesLeft;
818afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int i;
819afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XVisualInfo *deepvis;
820afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int deepest;
821afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
822afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /*DEBUG int tt, tv; */
823afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
824afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   switch (preferred_class) {
825afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_TRUE_COLOR_EXT:    preferred_class = TrueColor;    break;
826afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_DIRECT_COLOR_EXT:  preferred_class = DirectColor;  break;
827afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_PSEUDO_COLOR_EXT:  preferred_class = PseudoColor;  break;
828afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_STATIC_COLOR_EXT:  preferred_class = StaticColor;  break;
829afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_GRAY_SCALE_EXT:    preferred_class = GrayScale;    break;
830afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_STATIC_GRAY_EXT:   preferred_class = StaticGray;   break;
831afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      default:                    preferred_class = DONT_CARE;
832afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
833afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
834afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /*
835afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * The SERVER_OVERLAY_VISUALS property on the root window contains
836afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * a list of overlay visuals.  Get that list now.
837afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    */
838afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   overlayVisualsAtom = XInternAtom(dpy,"SERVER_OVERLAY_VISUALS", True);
839afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (overlayVisualsAtom == (Atom) None) {
840afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return NULL;
841afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
842afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
843afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   status = XGetWindowProperty(dpy, RootWindow( dpy, scr ),
844afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               overlayVisualsAtom, 0L, (long) 10000, False,
845afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               overlayVisualsAtom, &actualType, &actualFormat,
846afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               &sizeData, &bytesLeft,
847afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               (unsigned char **) &overlay_info );
848afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
849afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (status != Success || actualType != overlayVisualsAtom ||
850afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg       actualFormat != 32 || sizeData < 4) {
851afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* something went wrong */
852afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return NULL;
853afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
854afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
855afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* Search for the deepest overlay which satisifies all criteria. */
856afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   deepest = min_depth;
857afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   deepvis = NULL;
858afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
859afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   numOverlaysPerScreen = (int) (sizeData / 4);
860afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   for (i=0;i<numOverlaysPerScreen;i++) {
861afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      XVisualInfo *vislist, vistemplate;
862afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      int count;
863afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      OverlayInfo *ov;
864afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      ov = overlay_info + i;
865afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
866afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (ov->layer!=level) {
867afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* failed overlay level criteria */
868afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         continue;
869afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
870afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (!(trans_type==DONT_CARE
871afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            || (trans_type==GLX_TRANSPARENT_INDEX_EXT
872afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                && ov->transparent_type>0)
873afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            || (trans_type==GLX_NONE_EXT && ov->transparent_type==0))) {
874afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* failed transparent pixel type criteria */
875afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         continue;
876afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
877afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (trans_value!=DONT_CARE && trans_value!=ov->value) {
878afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* failed transparent pixel value criteria */
879afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         continue;
880afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
881afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
882afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* get XVisualInfo and check the depth */
883afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      vistemplate.visualid = ov->overlay_visual;
884afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      vistemplate.screen = scr;
885afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      vislist = XGetVisualInfo( dpy, VisualIDMask | VisualScreenMask,
886afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                                &vistemplate, &count );
887afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
888afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (count!=1) {
889afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* something went wrong */
890afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         continue;
891afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
892afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (preferred_class!=DONT_CARE && preferred_class!=vislist->CLASS) {
893afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* wrong visual class */
894afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         continue;
895afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
896afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
89742f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      /* if RGB was requested, make sure we have True/DirectColor */
89842f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      if (rgbFlag && vislist->CLASS != TrueColor
89942f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul          && vislist->CLASS != DirectColor)
90042f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         continue;
90142f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul
90242f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      /* if CI was requested, make sure we have a color indexed visual */
90342f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      if (!rgbFlag
90442f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul          && (vislist->CLASS == TrueColor || vislist->CLASS == DirectColor))
90542f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         continue;
90642f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul
907afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (deepvis==NULL || vislist->depth > deepest) {
908afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* YES!  found a satisfactory visual */
909afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         if (deepvis) {
91080af3614d88c0cac160e787de7f34b37e96cb626Brian Paul            XFree( deepvis );
911afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
912afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         deepest = vislist->depth;
913afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         deepvis = vislist;
914afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* DEBUG  tt = ov->transparent_type;*/
915afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* DEBUG  tv = ov->value; */
916afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
917afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
918afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
919afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*DEBUG
920afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (deepvis) {
921afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      printf("chose 0x%x:  layer=%d depth=%d trans_type=%d trans_value=%d\n",
922afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg             deepvis->visualid, level, deepvis->depth, tt, tv );
923afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
924afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg*/
925afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return deepvis;
926afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
927afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
928afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
9297cf50e137da497a590ec9001a9918972a6246142Brian Paul/**********************************************************************/
9307cf50e137da497a590ec9001a9918972a6246142Brian Paul/***                  Begin Fake GLX API Functions                  ***/
9317cf50e137da497a590ec9001a9918972a6246142Brian Paul/**********************************************************************/
9327cf50e137da497a590ec9001a9918972a6246142Brian Paul
933afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
934b3063ac398b72e6a4fd2015d4e220495b9779294Brian Paulstatic XMesaVisual choose_visual( Display *dpy, int screen, const int *list,
935b3063ac398b72e6a4fd2015d4e220495b9779294Brian Paul                                  GLboolean rgbModeDefault )
936afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
9373265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   const int *parselist;
938afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XVisualInfo *vis;
939afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int min_ci = 0;
940afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int min_red=0, min_green=0, min_blue=0;
941b3063ac398b72e6a4fd2015d4e220495b9779294Brian Paul   GLboolean rgb_flag = rgbModeDefault;
942afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLboolean alpha_flag = GL_FALSE;
943afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLboolean double_flag = GL_FALSE;
944afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLboolean stereo_flag = GL_FALSE;
945afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLint depth_size = 0;
946afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLint stencil_size = 0;
947b2e460018375f699198073a6167e0ee96ba1d267Brian Paul   GLint accumRedSize = 0;
948b2e460018375f699198073a6167e0ee96ba1d267Brian Paul   GLint accumGreenSize = 0;
949b2e460018375f699198073a6167e0ee96ba1d267Brian Paul   GLint accumBlueSize = 0;
950b2e460018375f699198073a6167e0ee96ba1d267Brian Paul   GLint accumAlphaSize = 0;
951afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int level = 0;
952afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int visual_type = DONT_CARE;
953afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int trans_type = DONT_CARE;
954afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int trans_value = DONT_CARE;
955e1210b176926349b258c7ec77b7f36716025c82aBrian Paul   GLint caveat = DONT_CARE;
9563265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   XMesaVisual xmvis = NULL;
9573a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul   int desiredVisualID = -1;
958894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul   int numAux = 0;
959afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
960afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   parselist = list;
961afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
962afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   while (*parselist) {
963afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
964afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      switch (*parselist) {
965afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_USE_GL:
966afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    /* ignore */
967afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
968afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
969afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_BUFFER_SIZE:
970afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
971afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    min_ci = *parselist++;
972afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
973afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_LEVEL:
974afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
975afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            level = *parselist++;
976afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
977afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_RGBA:
978afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    rgb_flag = GL_TRUE;
979afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
980afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
981afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_DOUBLEBUFFER:
982afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    double_flag = GL_TRUE;
983afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
984afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
985afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_STEREO:
986afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            stereo_flag = GL_TRUE;
987afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            return NULL;
988afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_AUX_BUFFERS:
989afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    /* ignore */
990afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
991894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul            numAux = *parselist++;
992894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul            if (numAux > MAX_AUX_BUFFERS)
993894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul               return NULL;
994afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
995afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_RED_SIZE:
996afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
997afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    min_red = *parselist++;
998afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
999afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_GREEN_SIZE:
1000afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
1001afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    min_green = *parselist++;
1002afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
1003afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_BLUE_SIZE:
1004afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
1005afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    min_blue = *parselist++;
1006afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
1007afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_ALPHA_SIZE:
1008afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
1009afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            {
1010afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               GLint size = *parselist++;
1011afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               alpha_flag = size>0 ? 1 : 0;
1012afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
1013afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
1014afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_DEPTH_SIZE:
1015afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
1016afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    depth_size = *parselist++;
1017afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
1018afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_STENCIL_SIZE:
1019afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
1020afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    stencil_size = *parselist++;
1021afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
1022afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_ACCUM_RED_SIZE:
1023b2e460018375f699198073a6167e0ee96ba1d267Brian Paul	    parselist++;
1024b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            {
1025b2e460018375f699198073a6167e0ee96ba1d267Brian Paul               GLint size = *parselist++;
1026b2e460018375f699198073a6167e0ee96ba1d267Brian Paul               accumRedSize = MAX2( accumRedSize, size );
1027b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            }
1028b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            break;
1029afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_ACCUM_GREEN_SIZE:
1030b2e460018375f699198073a6167e0ee96ba1d267Brian Paul	    parselist++;
1031b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            {
1032b2e460018375f699198073a6167e0ee96ba1d267Brian Paul               GLint size = *parselist++;
1033b2e460018375f699198073a6167e0ee96ba1d267Brian Paul               accumGreenSize = MAX2( accumGreenSize, size );
1034b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            }
1035b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            break;
1036afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_ACCUM_BLUE_SIZE:
1037b2e460018375f699198073a6167e0ee96ba1d267Brian Paul	    parselist++;
1038b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            {
1039b2e460018375f699198073a6167e0ee96ba1d267Brian Paul               GLint size = *parselist++;
1040b2e460018375f699198073a6167e0ee96ba1d267Brian Paul               accumBlueSize = MAX2( accumBlueSize, size );
1041b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            }
1042b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            break;
1043afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_ACCUM_ALPHA_SIZE:
1044afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
1045afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            {
1046afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               GLint size = *parselist++;
1047b2e460018375f699198073a6167e0ee96ba1d267Brian Paul               accumAlphaSize = MAX2( accumAlphaSize, size );
1048afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
1049afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
1050afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1051afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /*
1052afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg          * GLX_EXT_visual_info extension
1053afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg          */
1054afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         case GLX_X_VISUAL_TYPE_EXT:
1055afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            parselist++;
1056afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            visual_type = *parselist++;
1057afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            break;
1058afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         case GLX_TRANSPARENT_TYPE_EXT:
1059afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            parselist++;
1060afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            trans_type = *parselist++;
1061afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            break;
1062afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         case GLX_TRANSPARENT_INDEX_VALUE_EXT:
1063afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            parselist++;
1064afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            trans_value = *parselist++;
1065afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            break;
1066afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         case GLX_TRANSPARENT_RED_VALUE_EXT:
1067afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         case GLX_TRANSPARENT_GREEN_VALUE_EXT:
1068afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         case GLX_TRANSPARENT_BLUE_VALUE_EXT:
1069afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         case GLX_TRANSPARENT_ALPHA_VALUE_EXT:
1070afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    /* ignore */
1071afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
1072afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
1073afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
10745e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen
1075e1210b176926349b258c7ec77b7f36716025c82aBrian Paul         /*
1076e1210b176926349b258c7ec77b7f36716025c82aBrian Paul          * GLX_EXT_visual_info extension
1077e1210b176926349b258c7ec77b7f36716025c82aBrian Paul          */
1078e1210b176926349b258c7ec77b7f36716025c82aBrian Paul         case GLX_VISUAL_CAVEAT_EXT:
1079e1210b176926349b258c7ec77b7f36716025c82aBrian Paul            parselist++;
1080e1210b176926349b258c7ec77b7f36716025c82aBrian Paul            caveat = *parselist++; /* ignored for now */
1081e1210b176926349b258c7ec77b7f36716025c82aBrian Paul            break;
1082e1210b176926349b258c7ec77b7f36716025c82aBrian Paul
10833265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         /*
108466ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul          * GLX_ARB_multisample
108566ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul          */
108666ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul         case GLX_SAMPLE_BUFFERS_ARB:
108766ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul            /* ms not supported */
108866ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul            return NULL;
108966ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul         case GLX_SAMPLES_ARB:
109066ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul            /* ms not supported */
109166ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul            return NULL;
109266ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul
109366ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul         /*
10943265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul          * FBConfig attribs.
10953265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul          */
10963265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         case GLX_RENDER_TYPE:
10973265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            parselist++;
10983265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            if (*parselist == GLX_RGBA_BIT) {
10993265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul               rgb_flag = GL_TRUE;
11003265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            }
11013265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            else if (*parselist == GLX_COLOR_INDEX_BIT) {
11023265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul               rgb_flag = GL_FALSE;
11033265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            }
11043265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            else if (*parselist == 0) {
11053265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul               rgb_flag = GL_TRUE;
11063265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            }
11073265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            parselist++;
11083265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            break;
11093265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         case GLX_DRAWABLE_TYPE:
11103265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            parselist++;
11113265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            if (*parselist & ~(GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT)) {
11123265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul               return NULL; /* bad bit */
11133265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            }
11143265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            parselist++;
11153265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            break;
11163a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul         case GLX_FBCONFIG_ID:
11173a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul            parselist++;
11183a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul            desiredVisualID = *parselist;
11193a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul            break;
11203265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul
1121afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case None:
11223a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul            /* end of list */
1123afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
11243265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul
1125afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 default:
1126afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    /* undefined attribute */
11272ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul            _mesa_warning(NULL, "unexpected attrib 0x%x in choose_visual()",
11282ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul                          *parselist);
1129afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    return NULL;
1130afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
1131afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1132afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1133b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul   (void) caveat;
1134b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul
1135afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /*
1136afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * Since we're only simulating the GLX extension this function will never
1137afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * find any real GL visuals.  Instead, all we can do is try to find an RGB
1138afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * or CI visual of appropriate depth.  Other requested attributes such as
1139afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * double buffering, depth buffer, etc. will be associated with the X
1140afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * visual and stored in the VisualTable[].
1141afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    */
11423a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul   if (desiredVisualID != -1) {
11433a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul      /* try to get a specific visual, by visualID */
11443a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul      XVisualInfo temp;
11453a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul      int n;
11463a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul      temp.visualid = desiredVisualID;
11473a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul      temp.screen = screen;
11483a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul      vis = XGetVisualInfo(dpy, VisualIDMask | VisualScreenMask, &temp, &n);
11493a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul      if (vis) {
11503a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul         /* give the visual some useful GLX attributes */
11513a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul         double_flag = GL_TRUE;
11523a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul         if (vis->depth > 8)
11533a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul            rgb_flag = GL_TRUE;
1154dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul         depth_size = default_depth_bits();
11553a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul         stencil_size = STENCIL_BITS;
11563a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul         /* XXX accum??? */
11573a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul      }
11583a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul   }
11593a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul   else if (level==0) {
1160afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* normal color planes */
1161afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (rgb_flag) {
1162afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* Get an RGB visual */
1163afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         int min_rgb = min_red + min_green + min_blue;
1164afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         if (min_rgb>1 && min_rgb<8) {
1165afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* a special case to be sure we can get a monochrome visual */
1166afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            min_rgb = 1;
1167afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
1168afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         vis = choose_x_visual( dpy, screen, rgb_flag, min_rgb, visual_type );
1169afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
1170afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      else {
1171afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* Get a color index visual */
1172afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         vis = choose_x_visual( dpy, screen, rgb_flag, min_ci, visual_type );
1173b2e460018375f699198073a6167e0ee96ba1d267Brian Paul         accumRedSize = accumGreenSize = accumBlueSize = accumAlphaSize = 0;
1174afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
1175afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1176afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else {
1177afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* over/underlay planes */
117842f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      if (rgb_flag) {
117942f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         /* rgba overlay */
118042f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         int min_rgb = min_red + min_green + min_blue;
118142f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         if (min_rgb>1 && min_rgb<8) {
118242f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul            /* a special case to be sure we can get a monochrome visual */
118342f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul            min_rgb = 1;
118442f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         }
118542f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         vis = choose_x_overlay_visual( dpy, screen, rgb_flag, level,
118642f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul                              trans_type, trans_value, min_rgb, visual_type );
118742f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      }
118842f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      else {
118942f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         /* color index overlay */
119042f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         vis = choose_x_overlay_visual( dpy, screen, rgb_flag, level,
119142f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul                              trans_type, trans_value, min_ci, visual_type );
119242f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      }
1193afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1194afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1195afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (vis) {
1196ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul      /* Note: we're not exactly obeying the glXChooseVisual rules here.
1197ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul       * When GLX_DEPTH_SIZE = 1 is specified we're supposed to choose the
11982c7e6334ec81c2fab2cce9e0fe52cd30256e37eaBrian Paul       * largest depth buffer size, which is 32bits/value.  Instead, we
1199ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul       * return 16 to maintain performance with earlier versions of Mesa.
1200ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul       */
12012c7e6334ec81c2fab2cce9e0fe52cd30256e37eaBrian Paul      if (depth_size > 24)
12022c7e6334ec81c2fab2cce9e0fe52cd30256e37eaBrian Paul         depth_size = 31;   /* 32 causes int overflow problems */
1203ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul      else if (depth_size > 16)
1204ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul         depth_size = 24;
1205dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul      else if (depth_size > 0) {
1206dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul         depth_size = default_depth_bits();
1207dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul      }
12082c7e6334ec81c2fab2cce9e0fe52cd30256e37eaBrian Paul
1209ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul      /* we only support one size of stencil and accum buffers. */
1210ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul      if (stencil_size > 0)
1211ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul         stencil_size = STENCIL_BITS;
12126d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul      if (accumRedSize > 0 || accumGreenSize > 0 || accumBlueSize > 0 ||
12136d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul          accumAlphaSize > 0) {
1214b2e460018375f699198073a6167e0ee96ba1d267Brian Paul         accumRedSize = ACCUM_BITS;
1215b2e460018375f699198073a6167e0ee96ba1d267Brian Paul         accumGreenSize = ACCUM_BITS;
1216b2e460018375f699198073a6167e0ee96ba1d267Brian Paul         accumBlueSize = ACCUM_BITS;
12176d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul         accumAlphaSize = alpha_flag ? ACCUM_BITS : 0;
12186d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul      }
12196d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul
12203265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      xmvis = save_glx_visual( dpy, vis, rgb_flag, alpha_flag, double_flag,
12213265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul                               stereo_flag, depth_size, stencil_size,
12223265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul                               accumRedSize, accumGreenSize,
1223894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul                               accumBlueSize, accumAlphaSize, level, numAux );
1224afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1225afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
12263265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   return xmvis;
1227afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1228afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1229afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
12303265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paulstatic XVisualInfo *
12313265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian PaulFake_glXChooseVisual( Display *dpy, int screen, int *list )
12323265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul{
1233b3063ac398b72e6a4fd2015d4e220495b9779294Brian Paul   XMesaVisual xmvis = choose_visual(dpy, screen, list, GL_FALSE);
1234f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   if (xmvis) {
1235f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul#if 0
1236f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      return xmvis->vishandle;
1237f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul#else
1238f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      /* create a new vishandle - the cached one may be stale */
12394039cb8ca82d59451a6de8902fe35e693cdca3baBrian Paul      xmvis->vishandle = (XVisualInfo *) _mesa_malloc(sizeof(XVisualInfo));
1240f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      if (xmvis->vishandle) {
1241f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul         _mesa_memcpy(xmvis->vishandle, xmvis->visinfo, sizeof(XVisualInfo));
1242f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      }
12433265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      return xmvis->vishandle;
1244f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul#endif
1245f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   }
12463265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   else
12473265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      return NULL;
12483265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul}
1249afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1250afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1251426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXContext
1252426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateContext( Display *dpy, XVisualInfo *visinfo,
1253426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                       GLXContext share_list, Bool direct )
1254afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1255e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaVisual xmvis;
12567cf50e137da497a590ec9001a9918972a6246142Brian Paul   struct fake_glx_context *glxCtx;
12575e1680ce1d8296b2182e8909856927bbeddf3b95Brian Paul   struct fake_glx_context *shareCtx = (struct fake_glx_context *) share_list;
125899aab341998e84d9fa208c525cae8021b3845812Brian Paul
125999aab341998e84d9fa208c525cae8021b3845812Brian Paul   if (!dpy || !visinfo)
126099aab341998e84d9fa208c525cae8021b3845812Brian Paul      return 0;
126199aab341998e84d9fa208c525cae8021b3845812Brian Paul
12627cf50e137da497a590ec9001a9918972a6246142Brian Paul   glxCtx = CALLOC_STRUCT(fake_glx_context);
12637cf50e137da497a590ec9001a9918972a6246142Brian Paul   if (!glxCtx)
12647cf50e137da497a590ec9001a9918972a6246142Brian Paul      return 0;
1265afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1266afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* deallocate unused windows/buffers */
1267afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaGarbageCollect();
1268afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1269e4656003caee346d9c4eb23256d73409271291a7Brian Paul   xmvis = find_glx_visual( dpy, visinfo );
1270e4656003caee346d9c4eb23256d73409271291a7Brian Paul   if (!xmvis) {
1271afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* This visual wasn't found with glXChooseVisual() */
1272e4656003caee346d9c4eb23256d73409271291a7Brian Paul      xmvis = create_glx_visual( dpy, visinfo );
1273e4656003caee346d9c4eb23256d73409271291a7Brian Paul      if (!xmvis) {
1274afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* unusable visual */
12757cf50e137da497a590ec9001a9918972a6246142Brian Paul         FREE(glxCtx);
1276afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return NULL;
1277afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
1278afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1279afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1280e4656003caee346d9c4eb23256d73409271291a7Brian Paul   glxCtx->xmesaContext = XMesaCreateContext(xmvis,
12815e1680ce1d8296b2182e8909856927bbeddf3b95Brian Paul                                   shareCtx ? shareCtx->xmesaContext : NULL);
12827cf50e137da497a590ec9001a9918972a6246142Brian Paul   if (!glxCtx->xmesaContext) {
12837cf50e137da497a590ec9001a9918972a6246142Brian Paul      FREE(glxCtx);
12847cf50e137da497a590ec9001a9918972a6246142Brian Paul      return NULL;
1285afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
12867cf50e137da497a590ec9001a9918972a6246142Brian Paul
12877cf50e137da497a590ec9001a9918972a6246142Brian Paul   glxCtx->xmesaContext->direct = GL_FALSE;
12887cf50e137da497a590ec9001a9918972a6246142Brian Paul   glxCtx->glxContext.isDirect = GL_FALSE;
12897cf50e137da497a590ec9001a9918972a6246142Brian Paul   glxCtx->glxContext.currentDpy = dpy;
12907cf50e137da497a590ec9001a9918972a6246142Brian Paul   glxCtx->glxContext.xid = (XID) glxCtx;  /* self pointer */
12917cf50e137da497a590ec9001a9918972a6246142Brian Paul
12927cf50e137da497a590ec9001a9918972a6246142Brian Paul   assert((void *) glxCtx == (void *) &(glxCtx->glxContext));
12937cf50e137da497a590ec9001a9918972a6246142Brian Paul
12947cf50e137da497a590ec9001a9918972a6246142Brian Paul   return (GLXContext) glxCtx;
1295afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1296afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1297afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
12987cf50e137da497a590ec9001a9918972a6246142Brian Paul/* XXX these may have to be removed due to thread-safety issues. */
1299afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic GLXContext MakeCurrent_PrevContext = 0;
1300086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic GLXDrawable MakeCurrent_PrevDrawable = 0;
1301086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic GLXDrawable MakeCurrent_PrevReadable = 0;
1302086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic XMesaBuffer MakeCurrent_PrevDrawBuffer = 0;
1303086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic XMesaBuffer MakeCurrent_PrevReadBuffer = 0;
1304afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
13057cf50e137da497a590ec9001a9918972a6246142Brian Paul
1306086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul/* GLX 1.3 and later */
1307426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool
1308426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXMakeContextCurrent( Display *dpy, GLXDrawable draw,
13097a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell                            GLXDrawable read, GLXContext ctx )
1310086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul{
13117cf50e137da497a590ec9001a9918972a6246142Brian Paul   struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx;
13127cf50e137da497a590ec9001a9918972a6246142Brian Paul
13137a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell   if (ctx && draw && read) {
1314086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      XMesaBuffer drawBuffer, readBuffer;
13157cf50e137da497a590ec9001a9918972a6246142Brian Paul      XMesaContext xmctx = glxCtx->xmesaContext;
1316086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul
1317086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      /* Find the XMesaBuffer which corresponds to the GLXDrawable 'draw' */
13187a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell      if (ctx == MakeCurrent_PrevContext
13197a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell          && draw == MakeCurrent_PrevDrawable) {
1320086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         drawBuffer = MakeCurrent_PrevDrawBuffer;
1321086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      }
1322086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      else {
1323086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         drawBuffer = XMesaFindBuffer( dpy, draw );
1324086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      }
1325086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      if (!drawBuffer) {
1326086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         /* drawable must be a new window! */
13277cf50e137da497a590ec9001a9918972a6246142Brian Paul         drawBuffer = XMesaCreateWindowBuffer2( xmctx->xm_visual, draw, xmctx);
1328086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         if (!drawBuffer) {
1329086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul            /* Out of memory, or context/drawable depth mismatch */
1330086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul            return False;
1331086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         }
1332086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      }
1333086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul
1334086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      /* Find the XMesaBuffer which corresponds to the GLXDrawable 'read' */
13357a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell      if (ctx == MakeCurrent_PrevContext
1336086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul          && read == MakeCurrent_PrevReadable) {
1337086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         readBuffer = MakeCurrent_PrevReadBuffer;
1338086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      }
1339086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      else {
1340086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         readBuffer = XMesaFindBuffer( dpy, read );
1341086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      }
1342086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      if (!readBuffer) {
1343086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         /* drawable must be a new window! */
13447cf50e137da497a590ec9001a9918972a6246142Brian Paul         readBuffer = XMesaCreateWindowBuffer2(glxCtx->xmesaContext->xm_visual,
13457cf50e137da497a590ec9001a9918972a6246142Brian Paul                                               read, xmctx);
1346086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         if (!readBuffer) {
1347086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul            /* Out of memory, or context/drawable depth mismatch */
1348086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul            return False;
1349086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         }
1350086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      }
1351086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul
13527a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell      MakeCurrent_PrevContext = ctx;
1353086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevDrawable = draw;
1354086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevReadable = read;
1355086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevDrawBuffer = drawBuffer;
1356086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevReadBuffer = readBuffer;
1357086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul
1358086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      /* Now make current! */
13597cf50e137da497a590ec9001a9918972a6246142Brian Paul      if (XMesaMakeCurrent2(xmctx, drawBuffer, readBuffer)) {
136012c1bee87fcc3a0912685bb6e83447972e5de64eBrian Paul         ((__GLXcontext *) ctx)->currentDpy = dpy;
136112c1bee87fcc3a0912685bb6e83447972e5de64eBrian Paul         ((__GLXcontext *) ctx)->currentDrawable = draw;
13628d687e7e58a148f3f16573636023e54755372010Brian Paul#ifndef GLX_BUILT_IN_XMESA
136312c1bee87fcc3a0912685bb6e83447972e5de64eBrian Paul         ((__GLXcontext *) ctx)->currentReadable = read;
13648d687e7e58a148f3f16573636023e54755372010Brian Paul#else
13657cf50e137da497a590ec9001a9918972a6246142Brian Paul         __glXSetCurrentContext(ctx);
13667cf50e137da497a590ec9001a9918972a6246142Brian Paul#endif
13677cf50e137da497a590ec9001a9918972a6246142Brian Paul         return True;
13687cf50e137da497a590ec9001a9918972a6246142Brian Paul      }
13697cf50e137da497a590ec9001a9918972a6246142Brian Paul      else {
13707cf50e137da497a590ec9001a9918972a6246142Brian Paul         return False;
13717cf50e137da497a590ec9001a9918972a6246142Brian Paul      }
1372086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul   }
13737a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell   else if (!ctx && !draw && !read) {
1374086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      /* release current context w/out assigning new one. */
1375086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      XMesaMakeCurrent( NULL, NULL );
1376086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevContext = 0;
1377086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevDrawable = 0;
1378086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevReadable = 0;
1379086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevDrawBuffer = 0;
1380086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevReadBuffer = 0;
138184cac8441fcf5f692cd220e9fa86cab398a4c159Brian Paul#ifdef GLX_BUILT_IN_XMESA
1382b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul      /* XXX bind dummy context with __glXSetCurrentContext(ctx); */
1383b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#endif
1384086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      return True;
1385086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul   }
1386086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul   else {
1387086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      /* The args must either all be non-zero or all zero.
1388086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul       * This is an error.
1389086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul       */
1390086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      return False;
1391086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul   }
1392086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul}
1393086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul
1394086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul
1395426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1396426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool
1397426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXMakeCurrent( Display *dpy, GLXDrawable drawable, GLXContext ctx )
1398426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
1399426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   return Fake_glXMakeContextCurrent( dpy, drawable, drawable, ctx );
1400426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
1401426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1402426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1403426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1404426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPixmap
1405426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateGLXPixmap( Display *dpy, XVisualInfo *visinfo, Pixmap pixmap )
1406afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1407afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaVisual v;
1408afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaBuffer b;
1409afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1410afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   v = find_glx_visual( dpy, visinfo );
1411afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (!v) {
1412afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      v = create_glx_visual( dpy, visinfo );
1413afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (!v) {
1414afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* unusable visual */
1415afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1416afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
1417afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1418afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1419afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   b = XMesaCreatePixmapBuffer( v, pixmap, 0 );
1420afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (!b) {
1421afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return 0;
1422afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1423afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return b->frontbuffer;
1424afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1425afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1426afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1427b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_MESA_pixmap_colormap ***/
1428b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul
1429426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPixmap
1430426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visinfo,
1431426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                             Pixmap pixmap, Colormap cmap )
1432afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1433afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaVisual v;
1434afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaBuffer b;
1435afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1436afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   v = find_glx_visual( dpy, visinfo );
1437afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (!v) {
1438afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      v = create_glx_visual( dpy, visinfo );
1439afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (!v) {
1440afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* unusable visual */
1441afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1442afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
1443afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1444afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1445afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   b = XMesaCreatePixmapBuffer( v, pixmap, cmap );
1446afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (!b) {
1447afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return 0;
1448afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1449afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return b->frontbuffer;
1450afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1451afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1452afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1453426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1454426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyGLXPixmap( Display *dpy, GLXPixmap pixmap )
1455afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1456afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaBuffer b = XMesaFindBuffer(dpy, pixmap);
1457afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (b) {
1458afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      XMesaDestroyBuffer(b);
1459afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1460367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul   else if (_mesa_getenv("MESA_DEBUG")) {
1461d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul      _mesa_warning(NULL, "Mesa: glXDestroyGLXPixmap: invalid pixmap\n");
1462afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1463afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1464afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1465afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
14664c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul
1467426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1468426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCopyContext( Display *dpy, GLXContext src, GLXContext dst,
14693994b77bab8c62a4c1a4dffdfba233ef46662b99Brian Paul                     unsigned long mask )
1470afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
147183b820aa98931ef30fa73c72b2a96fe23885955eBrian Paul   struct fake_glx_context *fakeSrc = (struct fake_glx_context *) src;
147283b820aa98931ef30fa73c72b2a96fe23885955eBrian Paul   struct fake_glx_context *fakeDst = (struct fake_glx_context *) dst;
147383b820aa98931ef30fa73c72b2a96fe23885955eBrian Paul   XMesaContext xm_src = fakeSrc->xmesaContext;
147483b820aa98931ef30fa73c72b2a96fe23885955eBrian Paul   XMesaContext xm_dst = fakeDst->xmesaContext;
1475afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
14761e24d3318df57b36e3b68695ff64b4b8bd822c9eBrian Paul   _mesa_copy_context( &(xm_src->mesa), &(xm_dst->mesa), (GLuint) mask );
1477afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1478afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1479afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1480afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1481426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool
1482426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryExtension( Display *dpy, int *errorb, int *event )
1483afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1484afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* Mesa's GLX isn't really an X extension but we try to act like one. */
1485afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
1486afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) errorb;
1487afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) event;
1488afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return True;
1489afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1490afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1491afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1492e7b16b74bf5d13331b5a88bbbbb9096560297b63Brian Paulextern void _kw_ungrab_all( Display *dpy );
1493afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgvoid _kw_ungrab_all( Display *dpy )
1494afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1495afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XUngrabPointer( dpy, CurrentTime );
1496afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XUngrabKeyboard( dpy, CurrentTime );
1497afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1498afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1499afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1500426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1501426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyContext( Display *dpy, GLXContext ctx )
1502afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
15037cf50e137da497a590ec9001a9918972a6246142Brian Paul   struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx;
1504afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
1505afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   MakeCurrent_PrevContext = 0;
1506afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   MakeCurrent_PrevDrawable = 0;
1507086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul   MakeCurrent_PrevReadable = 0;
1508086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul   MakeCurrent_PrevDrawBuffer = 0;
1509086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul   MakeCurrent_PrevReadBuffer = 0;
15107cf50e137da497a590ec9001a9918972a6246142Brian Paul   XMesaDestroyContext( glxCtx->xmesaContext );
1511afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaGarbageCollect();
1512afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1513afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1514afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1515afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1516426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool
1517426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXIsDirect( Display *dpy, GLXContext ctx )
1518afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
15197cf50e137da497a590ec9001a9918972a6246142Brian Paul   struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx;
1520afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
15217cf50e137da497a590ec9001a9918972a6246142Brian Paul   return glxCtx->xmesaContext->direct;
1522afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1523afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1524afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1525afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1526426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1527426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXSwapBuffers( Display *dpy, GLXDrawable drawable )
1528afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1529afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaBuffer buffer = XMesaFindBuffer( dpy, drawable );
1530afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1531afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (buffer) {
1532afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      XMesaSwapBuffers(buffer);
1533afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1534367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul   else if (_mesa_getenv("MESA_DEBUG")) {
1535d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul      _mesa_warning(NULL, "Mesa: glXSwapBuffers: invalid drawable\n");
1536afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1537afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1538afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1539afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
15404c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul
1541b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_MESA_copy_sub_buffer ***/
1542b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul
1543426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1544426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCopySubBufferMESA( Display *dpy, GLXDrawable drawable,
1545426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                           int x, int y, int width, int height )
1546afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1547afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaBuffer buffer = XMesaFindBuffer( dpy, drawable );
1548afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (buffer) {
1549afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      XMesaCopySubBuffer(buffer, x, y, width, height);
1550afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1551367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul   else if (_mesa_getenv("MESA_DEBUG")) {
1552d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul      _mesa_warning(NULL, "Mesa: glXCopySubBufferMESA: invalid drawable\n");
1553afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1554afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1555afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1556afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1557afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1558426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool
1559426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryVersion( Display *dpy, int *maj, int *min )
1560afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1561afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
1562afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* Return GLX version, not Mesa version */
156378fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul   assert(CLIENT_MAJOR_VERSION == SERVER_MAJOR_VERSION);
156478fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul   *maj = CLIENT_MAJOR_VERSION;
156578fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul   *min = MIN2( CLIENT_MINOR_VERSION, SERVER_MINOR_VERSION );
1566afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return True;
1567afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1568afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1569afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1570afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1571afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
1572afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Query the GLX attributes of the given XVisualInfo.
1573afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
1574426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int
1575e4656003caee346d9c4eb23256d73409271291a7Brian Paulget_config( XMesaVisual xmvis, int attrib, int *value, GLboolean fbconfig )
1576afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1577e4656003caee346d9c4eb23256d73409271291a7Brian Paul   ASSERT(xmvis);
1578afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   switch(attrib) {
1579afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_USE_GL:
1580afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         *value = (int) True;
1581afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1582afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_BUFFER_SIZE:
1583e4656003caee346d9c4eb23256d73409271291a7Brian Paul	 *value = xmvis->visinfo->depth;
1584afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1585afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_LEVEL:
1586304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick	 *value = xmvis->mesa_visual.level;
1587afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1588afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_RGBA:
1589e4656003caee346d9c4eb23256d73409271291a7Brian Paul	 if (xmvis->mesa_visual.rgbMode) {
1590afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    *value = True;
1591afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 }
1592afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 else {
1593afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    *value = False;
1594afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 }
1595afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1596afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_DOUBLEBUFFER:
1597e4656003caee346d9c4eb23256d73409271291a7Brian Paul	 *value = (int) xmvis->mesa_visual.doubleBufferMode;
1598afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1599afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_STEREO:
1600e4656003caee346d9c4eb23256d73409271291a7Brian Paul	 *value = (int) xmvis->mesa_visual.stereoMode;
1601afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1602afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_AUX_BUFFERS:
1603894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul	 *value = xmvis->mesa_visual.numAuxBuffers;
1604afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1605afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_RED_SIZE:
1606e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = xmvis->mesa_visual.redBits;
1607afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1608afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_GREEN_SIZE:
1609e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = xmvis->mesa_visual.greenBits;
1610afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1611afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_BLUE_SIZE:
1612e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = xmvis->mesa_visual.blueBits;
1613afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1614afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_ALPHA_SIZE:
1615e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = xmvis->mesa_visual.alphaBits;
1616afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1617afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_DEPTH_SIZE:
1618e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = xmvis->mesa_visual.depthBits;
1619afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1620afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_STENCIL_SIZE:
1621e4656003caee346d9c4eb23256d73409271291a7Brian Paul	 *value = xmvis->mesa_visual.stencilBits;
1622afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1623afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_ACCUM_RED_SIZE:
1624e4656003caee346d9c4eb23256d73409271291a7Brian Paul	 *value = xmvis->mesa_visual.accumRedBits;
1625b2e460018375f699198073a6167e0ee96ba1d267Brian Paul	 return 0;
1626afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_ACCUM_GREEN_SIZE:
1627e4656003caee346d9c4eb23256d73409271291a7Brian Paul	 *value = xmvis->mesa_visual.accumGreenBits;
1628b2e460018375f699198073a6167e0ee96ba1d267Brian Paul	 return 0;
1629afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_ACCUM_BLUE_SIZE:
1630e4656003caee346d9c4eb23256d73409271291a7Brian Paul	 *value = xmvis->mesa_visual.accumBlueBits;
1631afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1632afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_ACCUM_ALPHA_SIZE:
1633e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = xmvis->mesa_visual.accumAlphaBits;
1634afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1635afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1636afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /*
1637afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg       * GLX_EXT_visual_info extension
1638afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg       */
1639afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_X_VISUAL_TYPE_EXT:
1640e4656003caee346d9c4eb23256d73409271291a7Brian Paul         switch (xmvis->visinfo->CLASS) {
1641afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case StaticGray:   *value = GLX_STATIC_GRAY_EXT;   return 0;
1642afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GrayScale:    *value = GLX_GRAY_SCALE_EXT;    return 0;
1643afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case StaticColor:  *value = GLX_STATIC_GRAY_EXT;   return 0;
1644afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case PseudoColor:  *value = GLX_PSEUDO_COLOR_EXT;  return 0;
1645afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case TrueColor:    *value = GLX_TRUE_COLOR_EXT;    return 0;
1646afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case DirectColor:  *value = GLX_DIRECT_COLOR_EXT;  return 0;
1647afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
1648afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1649afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_TRANSPARENT_TYPE_EXT:
1650304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick         if (xmvis->mesa_visual.level==0) {
1651afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* normal planes */
1652afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            *value = GLX_NONE_EXT;
1653afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
1654304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick         else if (xmvis->mesa_visual.level>0) {
1655afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* overlay */
1656e4656003caee346d9c4eb23256d73409271291a7Brian Paul            if (xmvis->mesa_visual.rgbMode) {
1657afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               *value = GLX_TRANSPARENT_RGB_EXT;
1658afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
1659afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            else {
1660afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               *value = GLX_TRANSPARENT_INDEX_EXT;
1661afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
1662afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
1663304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick         else if (xmvis->mesa_visual.level<0) {
1664afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* underlay */
1665afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            *value = GLX_NONE_EXT;
1666afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
1667afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1668afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_TRANSPARENT_INDEX_VALUE_EXT:
1669afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         {
1670e4656003caee346d9c4eb23256d73409271291a7Brian Paul            int pixel = transparent_pixel( xmvis );
1671afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            if (pixel>=0) {
1672afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               *value = pixel;
1673afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
1674afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* else undefined */
1675afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
1676afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1677afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_TRANSPARENT_RED_VALUE_EXT:
1678afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* undefined */
1679afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1680afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_TRANSPARENT_GREEN_VALUE_EXT:
1681afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* undefined */
1682afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1683afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_TRANSPARENT_BLUE_VALUE_EXT:
1684afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* undefined */
1685afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1686afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_TRANSPARENT_ALPHA_VALUE_EXT:
1687afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* undefined */
1688afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1689afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1690afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /*
1691b2e460018375f699198073a6167e0ee96ba1d267Brian Paul       * GLX_EXT_visual_info extension
1692b2e460018375f699198073a6167e0ee96ba1d267Brian Paul       */
1693b2e460018375f699198073a6167e0ee96ba1d267Brian Paul      case GLX_VISUAL_CAVEAT_EXT:
1694fc68be6b111473a0bf8f991468f973bb9dd275f4Brian Paul         /* test for zero, just in case */
1695304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick         if (xmvis->mesa_visual.visualRating > 0)
1696304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick            *value = xmvis->mesa_visual.visualRating;
1697962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul         else
1698962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul            *value = GLX_NONE_EXT;
1699962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul         return 0;
1700b2e460018375f699198073a6167e0ee96ba1d267Brian Paul
1701b2e460018375f699198073a6167e0ee96ba1d267Brian Paul      /*
170266ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul       * GLX_ARB_multisample
1703afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg       */
170466ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul      case GLX_SAMPLE_BUFFERS_ARB:
17053265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         *value = 0;
17063265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         return 0;
170766ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul      case GLX_SAMPLES_ARB:
17083265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         *value = 0;
17093265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         return 0;
17103265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul
17113265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      /*
17123265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul       * For FBConfigs:
17133265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul       */
17143265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      case GLX_SCREEN_EXT:
17153265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         if (!fbconfig)
17163265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            return GLX_BAD_ATTRIBUTE;
1717e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = xmvis->visinfo->screen;
17183265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         break;
17193265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      case GLX_DRAWABLE_TYPE: /*SGIX too */
17203265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         if (!fbconfig)
17213265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            return GLX_BAD_ATTRIBUTE;
17223265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         *value = GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT;
17233265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         break;
17243265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      case GLX_RENDER_TYPE_SGIX:
17253265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         if (!fbconfig)
17263265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            return GLX_BAD_ATTRIBUTE;
1727e4656003caee346d9c4eb23256d73409271291a7Brian Paul         if (xmvis->mesa_visual.rgbMode)
17283265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            *value = GLX_RGBA_BIT;
17293265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         else
17303265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            *value = GLX_COLOR_INDEX_BIT;
17313265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         break;
17323265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      case GLX_X_RENDERABLE_SGIX:
17333265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         if (!fbconfig)
17343265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            return GLX_BAD_ATTRIBUTE;
17353265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         *value = True; /* XXX really? */
17363265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         break;
17373265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      case GLX_FBCONFIG_ID_SGIX:
17383265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         if (!fbconfig)
17393265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            return GLX_BAD_ATTRIBUTE;
1740f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul         *value = xmvis->visinfo->visualid;
17413265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         break;
17423265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      case GLX_MAX_PBUFFER_WIDTH:
17433265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         if (!fbconfig)
17443265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            return GLX_BAD_ATTRIBUTE;
17453265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         /* XXX or MAX_WIDTH? */
1746f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul         *value = DisplayWidth(xmvis->display, xmvis->visinfo->screen);
17473265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         break;
17483265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      case GLX_MAX_PBUFFER_HEIGHT:
17493265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         if (!fbconfig)
17503265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            return GLX_BAD_ATTRIBUTE;
1751f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul         *value = DisplayHeight(xmvis->display, xmvis->visinfo->screen);
17523265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         break;
17533265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      case GLX_MAX_PBUFFER_PIXELS:
17543265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         if (!fbconfig)
17553265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            return GLX_BAD_ATTRIBUTE;
1756f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul         *value = DisplayWidth(xmvis->display, xmvis->visinfo->screen) *
1757f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul                  DisplayHeight(xmvis->display, xmvis->visinfo->screen);
17583265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         break;
17593265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      case GLX_VISUAL_ID:
17603265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         if (!fbconfig)
17613265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            return GLX_BAD_ATTRIBUTE;
1762f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul         *value = xmvis->visinfo->visualid;
17633265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         break;
17643265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul
1765afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      default:
1766afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return GLX_BAD_ATTRIBUTE;
1767afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
17683265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   return Success;
1769afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1770afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1771afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
17723265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paulstatic int
17733265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian PaulFake_glXGetConfig( Display *dpy, XVisualInfo *visinfo,
17743265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul                   int attrib, int *value )
17753265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul{
1776e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaVisual xmvis;
17773265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul
1778379641956d134b8dc761b6411d7c4dca8f94a092Brian Paul   if (!dpy || !visinfo)
1779a9a1c3f20f2d6aad4afc47cf2b29c5393fddb6b6Brian Paul      return GLX_BAD_ATTRIBUTE;
1780a9a1c3f20f2d6aad4afc47cf2b29c5393fddb6b6Brian Paul
1781e4656003caee346d9c4eb23256d73409271291a7Brian Paul   xmvis = find_glx_visual( dpy, visinfo );
1782e4656003caee346d9c4eb23256d73409271291a7Brian Paul   if (!xmvis) {
17833265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      /* this visual wasn't obtained with glXChooseVisual */
1784e4656003caee346d9c4eb23256d73409271291a7Brian Paul      xmvis = create_glx_visual( dpy, visinfo );
1785e4656003caee346d9c4eb23256d73409271291a7Brian Paul      if (!xmvis) {
17863265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul	 /* this visual can't be used for GL rendering */
17873265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul	 if (attrib==GLX_USE_GL) {
17883265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul	    *value = (int) False;
17893265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul	    return 0;
17903265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul	 }
17913265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul	 else {
17923265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul	    return GLX_BAD_VISUAL;
17933265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul	 }
17943265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      }
17953265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   }
17963265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul
1797e4656003caee346d9c4eb23256d73409271291a7Brian Paul   return get_config(xmvis, attrib, value, GL_FALSE);
17983265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul}
17993265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul
1800afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1801426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1802426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXWaitGL( void )
1803afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1804afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaContext xmesa = XMesaGetCurrentContext();
1805afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaFlush( xmesa );
1806afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1807afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1808afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1809afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1810426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1811426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXWaitX( void )
1812afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1813afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaContext xmesa = XMesaGetCurrentContext();
1814afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaFlush( xmesa );
1815afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1816afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1817afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1818e4656003caee346d9c4eb23256d73409271291a7Brian Paulstatic const char *
1819e4656003caee346d9c4eb23256d73409271291a7Brian Paulget_extensions( void )
182043c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul{
182143c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul#ifdef FX
1822367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul   const char *fx = _mesa_getenv("MESA_GLX_FX");
182343c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul   if (fx && fx[0] != 'd') {
1824e4656003caee346d9c4eb23256d73409271291a7Brian Paul      return EXTENSIONS;
182543c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul   }
182643c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul#endif
1827e4656003caee346d9c4eb23256d73409271291a7Brian Paul   return EXTENSIONS + 23; /* skip "GLX_MESA_set_3dfx_mode" */
182843c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul}
1829afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1830afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1831afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1832afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* GLX 1.1 and later */
1833426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic const char *
1834426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryExtensionsString( Display *dpy, int screen )
1835afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1836afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
1837afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) screen;
183843c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul   return get_extensions();
1839afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1840afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1841afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1842afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1843afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* GLX 1.1 and later */
1844426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic const char *
1845426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryServerString( Display *dpy, int screen, int name )
1846afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
184778fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul   static char version[1000];
18482ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul   _mesa_sprintf(version, "%d.%d %s",
18492ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul                 SERVER_MAJOR_VERSION, SERVER_MINOR_VERSION, MESA_GLX_VERSION);
1850afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1851afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
1852afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) screen;
1853afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1854afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   switch (name) {
1855afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_EXTENSIONS:
185643c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul         return get_extensions();
1857afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_VENDOR:
185878fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul	 return VENDOR;
1859afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_VERSION:
1860afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return version;
1861afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      default:
1862afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return NULL;
1863afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1864afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1865afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1866afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1867afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1868afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* GLX 1.1 and later */
1869426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic const char *
1870426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetClientString( Display *dpy, int name )
1871afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
187278fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul   static char version[1000];
18732ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul   _mesa_sprintf(version, "%d.%d %s", CLIENT_MAJOR_VERSION,
18742ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul                 CLIENT_MINOR_VERSION, MESA_GLX_VERSION);
1875afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1876afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
1877afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1878afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   switch (name) {
1879afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_EXTENSIONS:
188043c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul         return get_extensions();
1881afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_VENDOR:
188278fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul	 return VENDOR;
1883afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_VERSION:
1884afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return version;
1885afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      default:
1886afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return NULL;
1887afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1888afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1889afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1890afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1891afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1892426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul/*
1893426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul * GLX 1.3 and later
1894426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul */
1895426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
18967d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
18975605798e56ca6e9f968623f33b58ee7ca90594afBrian Paulstatic GLXFBConfig *
1898426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXChooseFBConfig( Display *dpy, int screen,
1899426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                        const int *attribList, int *nitems )
1900426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
1901b3063ac398b72e6a4fd2015d4e220495b9779294Brian Paul   XMesaVisual xmvis = choose_visual(dpy, screen, attribList, GL_TRUE);
19023265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   if (xmvis) {
19034039cb8ca82d59451a6de8902fe35e693cdca3baBrian Paul      GLXFBConfig *config = (GLXFBConfig *) _mesa_malloc(sizeof(XMesaVisual));
19043265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      if (!config) {
19053265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         *nitems = 0;
19063265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         return NULL;
19073265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      }
19083265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      *nitems = 1;
19093265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      config[0] = (GLXFBConfig) xmvis;
19103265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      return (GLXFBConfig *) config;
19113265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   }
19123265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   else {
19133265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      *nitems = 0;
19143265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      return NULL;
19153265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   }
1916426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
1917426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1918426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1919426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int
1920426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetFBConfigAttrib( Display *dpy, GLXFBConfig config,
1921426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                           int attribute, int *value )
1922426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
19233265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   XMesaVisual v = (XMesaVisual) config;
1924426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
1925426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) config;
19267d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
19277d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (!dpy || !config || !value)
19287d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return -1;
19297d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
19303265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   return get_config(v, attribute, value, GL_TRUE);
1931426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
1932426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1933426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
19345605798e56ca6e9f968623f33b58ee7ca90594afBrian Paulstatic GLXFBConfig *
19355605798e56ca6e9f968623f33b58ee7ca90594afBrian PaulFake_glXGetFBConfigs( Display *dpy, int screen, int *nelements )
19365605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul{
19373265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   XVisualInfo *visuals, visTemplate;
19383265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   const long visMask = VisualScreenMask;
19393265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   int i;
19403265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul
19413265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   /* Get list of all X visuals */
19423265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   visTemplate.screen = screen;
19433265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   visuals = XGetVisualInfo(dpy, visMask, &visTemplate, nelements);
19443265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   if (*nelements > 0) {
19453265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      XMesaVisual *results;
19464039cb8ca82d59451a6de8902fe35e693cdca3baBrian Paul      results = (XMesaVisual *) _mesa_malloc(*nelements * sizeof(XMesaVisual));
19473265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      if (!results) {
19483265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         *nelements = 0;
19493265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         return NULL;
19503265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      }
19513265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      for (i = 0; i < *nelements; i++) {
19523265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         results[i] = create_glx_visual(dpy, visuals + i);
19533265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      }
19543265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      return (GLXFBConfig *) results;
19553265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   }
19563265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   return NULL;
19575605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul}
19585605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul
19595605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul
1960426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic XVisualInfo *
1961426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetVisualFromFBConfig( Display *dpy, GLXFBConfig config )
1962426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
19637d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (dpy && config) {
1964f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      XMesaVisual xmvis = (XMesaVisual) config;
1965f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul#if 0
1966f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      return xmvis->vishandle;
1967f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul#else
1968f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      /* create a new vishandle - the cached one may be stale */
19694039cb8ca82d59451a6de8902fe35e693cdca3baBrian Paul      xmvis->vishandle = (XVisualInfo *) _mesa_malloc(sizeof(XVisualInfo));
1970f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      if (xmvis->vishandle) {
1971f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul         _mesa_memcpy(xmvis->vishandle, xmvis->visinfo, sizeof(XVisualInfo));
1972f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      }
1973f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      return xmvis->vishandle;
1974f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul#endif
19757d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   }
19767d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   else {
19777d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return NULL;
19787d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   }
1979426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
1980426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1981426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1982426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXWindow
1983426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateWindow( Display *dpy, GLXFBConfig config, Window win,
1984426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                      const int *attribList )
1985426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
1986529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul   XMesaVisual xmvis = (XMesaVisual) config;
1987529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul   XMesaBuffer xmbuf;
1988529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul   if (!xmvis)
1989529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul      return 0;
1990529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul
1991529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul   xmbuf = XMesaCreateWindowBuffer2(xmvis, win, NULL);
1992529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul   if (!xmbuf)
1993529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul      return 0;
1994529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul
1995426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
19967d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   (void) attribList;  /* Ignored in GLX 1.3 */
19977d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
19987d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   return win;  /* A hack for now */
1999426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2000426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2001426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2002426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
2003426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyWindow( Display *dpy, GLXWindow window )
2004426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
20057d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   XMesaBuffer b = XMesaFindBuffer(dpy, (XMesaDrawable) window);
20067d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (b)
20077d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      XMesaDestroyBuffer(b);
20087d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   /* don't destroy X window */
2009426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2010426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2011426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
20127d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul/* XXX untested */
2013426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPixmap
2014426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreatePixmap( Display *dpy, GLXFBConfig config, Pixmap pixmap,
2015426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                      const int *attribList )
2016426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
20177d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   XMesaVisual v = (XMesaVisual) config;
20187d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   XMesaBuffer b;
20197d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
2020426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
2021426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) config;
2022426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) pixmap;
20237d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   (void) attribList;  /* Ignored in GLX 1.3 */
20247d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
20257d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (!dpy || !config || !pixmap)
20267d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return 0;
20277d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
20287d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   b = XMesaCreatePixmapBuffer( v, pixmap, 0 );
20297d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (!b) {
20307d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return 0;
20317d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   }
20327d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
20337d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   return pixmap;
2034426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2035426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2036426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2037426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
2038426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyPixmap( Display *dpy, GLXPixmap pixmap )
2039426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
20407d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   XMesaBuffer b = XMesaFindBuffer(dpy, (XMesaDrawable)pixmap);
20417d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (b)
20427d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      XMesaDestroyBuffer(b);
20437d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   /* don't destroy X pixmap */
2044426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2045426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2046426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2047426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPbuffer
2048426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreatePbuffer( Display *dpy, GLXFBConfig config,
2049426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                       const int *attribList )
2050426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
20513265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   XMesaVisual xmvis = (XMesaVisual) config;
20523265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   XMesaBuffer xmbuf;
20537d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   const int *attrib;
20547d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   int width = 0, height = 0;
20557d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   GLboolean useLargest = GL_FALSE, preserveContents = GL_FALSE;
20567d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
2057426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
20587d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
20593265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   for (attrib = attribList; *attrib; attrib++) {
20607d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      switch (*attrib) {
20617d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         case GLX_PBUFFER_WIDTH:
20623265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            attrib++;
20633265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            width = *attrib;
20647d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            break;
20657d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         case GLX_PBUFFER_HEIGHT:
20663265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            attrib++;
20673265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            height = *attrib;
20687d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            break;
20697d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         case GLX_PRESERVED_CONTENTS:
20703265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            attrib++;
20713265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            preserveContents = *attrib; /* ignored */
20727d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            break;
20737d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         case GLX_LARGEST_PBUFFER:
20743265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            attrib++;
20753265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            useLargest = *attrib; /* ignored */
20767d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            break;
20777d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         default:
20787d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            return 0;
20797d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      }
20807d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   }
20817d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
2082b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul   /* not used at this time */
2083b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul   (void) useLargest;
2084b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul   (void) preserveContents;
2085b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul
20867d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (width == 0 || height == 0)
20877d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return 0;
20887d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
20893265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   xmbuf = XMesaCreatePBuffer( xmvis, 0, width, height);
2090e4656003caee346d9c4eb23256d73409271291a7Brian Paul   /* A GLXPbuffer handle must be an X Drawable because that's what
2091e4656003caee346d9c4eb23256d73409271291a7Brian Paul    * glXMakeCurrent takes.
2092e4656003caee346d9c4eb23256d73409271291a7Brian Paul    */
2093e4656003caee346d9c4eb23256d73409271291a7Brian Paul   return (GLXPbuffer) xmbuf->frontbuffer;
2094426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2095426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2096426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2097426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
2098426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyPbuffer( Display *dpy, GLXPbuffer pbuf )
2099426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2100e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaBuffer b = XMesaFindBuffer(dpy, pbuf);
2101e4656003caee346d9c4eb23256d73409271291a7Brian Paul   if (b) {
2102e4656003caee346d9c4eb23256d73409271291a7Brian Paul      XMesaDestroyBuffer(b);
2103e4656003caee346d9c4eb23256d73409271291a7Brian Paul   }
2104426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2105426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2106426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2107426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
2108426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryDrawable( Display *dpy, GLXDrawable draw, int attribute,
2109426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                       unsigned int *value )
2110426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2111e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaBuffer xmbuf = XMesaFindBuffer(dpy, draw);
2112e4656003caee346d9c4eb23256d73409271291a7Brian Paul   if (!xmbuf)
2113e4656003caee346d9c4eb23256d73409271291a7Brian Paul      return;
21147d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
21157d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   switch (attribute) {
21167d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_WIDTH:
2117e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = xmbuf->width;
2118e4656003caee346d9c4eb23256d73409271291a7Brian Paul         break;
21197d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_HEIGHT:
2120e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = xmbuf->height;
2121e4656003caee346d9c4eb23256d73409271291a7Brian Paul         break;
21227d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_PRESERVED_CONTENTS:
2123e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = True;
2124e4656003caee346d9c4eb23256d73409271291a7Brian Paul         break;
21257d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_LARGEST_PBUFFER:
2126e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = xmbuf->width * xmbuf->height;
2127e4656003caee346d9c4eb23256d73409271291a7Brian Paul         break;
21287d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_FBCONFIG_ID:
2129f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul         *value = xmbuf->xm_visual->visinfo->visualid;
21307d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         return;
21317d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      default:
21327d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         return;  /* GLX_BAD_ATTRIBUTE? */
21337d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   }
2134426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2135426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2136426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2137426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXContext
2138426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateNewContext( Display *dpy, GLXFBConfig config,
2139426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                          int renderType, GLXContext shareList, Bool direct )
2140426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2141f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   struct fake_glx_context *glxCtx;
2142f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   struct fake_glx_context *shareCtx = (struct fake_glx_context *) shareList;
2143f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   XMesaVisual xmvis = (XMesaVisual) config;
21447d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
21457d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (!dpy || !config ||
21467d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul       (renderType != GLX_RGBA_TYPE && renderType != GLX_COLOR_INDEX_TYPE))
21477d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return 0;
21487d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
2149f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   glxCtx = CALLOC_STRUCT(fake_glx_context);
2150f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   if (!glxCtx)
2151f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      return 0;
2152f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul
2153f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   /* deallocate unused windows/buffers */
2154f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   XMesaGarbageCollect();
2155f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul
2156f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   glxCtx->xmesaContext = XMesaCreateContext(xmvis,
2157f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul                                   shareCtx ? shareCtx->xmesaContext : NULL);
2158f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   if (!glxCtx->xmesaContext) {
2159f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      FREE(glxCtx);
2160f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      return NULL;
2161f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   }
2162f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul
2163f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   glxCtx->xmesaContext->direct = GL_FALSE;
2164f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   glxCtx->glxContext.isDirect = GL_FALSE;
2165f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   glxCtx->glxContext.currentDpy = dpy;
2166f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   glxCtx->glxContext.xid = (XID) glxCtx;  /* self pointer */
2167f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul
2168f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   assert((void *) glxCtx == (void *) &(glxCtx->glxContext));
2169f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul
2170f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   return (GLXContext) glxCtx;
2171426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2172426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2173426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2174426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int
2175426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryContext( Display *dpy, GLXContext ctx, int attribute, int *value )
2176426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2177e4656003caee346d9c4eb23256d73409271291a7Brian Paul   struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx;
2178e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaContext xmctx = glxCtx->xmesaContext;
2179e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2180426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
2181426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) ctx;
21827d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
21837d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   switch (attribute) {
21847d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   case GLX_FBCONFIG_ID:
2185f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      *value = xmctx->xm_visual->visinfo->visualid;
2186e4656003caee346d9c4eb23256d73409271291a7Brian Paul      break;
21877d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   case GLX_RENDER_TYPE:
2188e4656003caee346d9c4eb23256d73409271291a7Brian Paul      if (xmctx->xm_visual->mesa_visual.rgbMode)
2189e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = GLX_RGBA_BIT;
2190e4656003caee346d9c4eb23256d73409271291a7Brian Paul      else
2191e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = GLX_COLOR_INDEX_BIT;
2192e4656003caee346d9c4eb23256d73409271291a7Brian Paul      break;
21937d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   case GLX_SCREEN:
21947d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      *value = 0;
21957d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return Success;
21967d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   default:
21977d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return GLX_BAD_ATTRIBUTE;
21987d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   }
2199e4656003caee346d9c4eb23256d73409271291a7Brian Paul   return 0;
2200426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2201426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2202426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2203426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
2204426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXSelectEvent( Display *dpy, GLXDrawable drawable, unsigned long mask )
2205426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2206e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable);
2207e4656003caee346d9c4eb23256d73409271291a7Brian Paul   if (xmbuf)
2208e4656003caee346d9c4eb23256d73409271291a7Brian Paul      xmbuf->selectedEvents = mask;
2209426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2210426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2211426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2212426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
2213426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetSelectedEvent( Display *dpy, GLXDrawable drawable,
2214426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                          unsigned long *mask )
2215426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2216e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable);
2217e4656003caee346d9c4eb23256d73409271291a7Brian Paul   if (xmbuf)
2218e4656003caee346d9c4eb23256d73409271291a7Brian Paul      *mask = xmbuf->selectedEvents;
2219e4656003caee346d9c4eb23256d73409271291a7Brian Paul   else
2220e4656003caee346d9c4eb23256d73409271291a7Brian Paul      *mask = 0;
2221426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2222b82d993b03320818f88f792a9e713f7ed491bfcbBrian Paul
2223b82d993b03320818f88f792a9e713f7ed491bfcbBrian Paul
2224b82d993b03320818f88f792a9e713f7ed491bfcbBrian Paul
2225b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGI_swap_control ***/
2226783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2227783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2228783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXSwapIntervalSGI(int interval)
2229783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2230783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) interval;
2231783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2232783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2233783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2234783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2235783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2236b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGI_video_sync ***/
2237783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2238783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2239783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetVideoSyncSGI(unsigned int *count)
2240783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2241783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) count;
2242783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2243783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2244783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2245783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2246783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count)
2247783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2248783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) divisor;
2249783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) remainder;
2250783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) count;
2251783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2252783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2253783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2254783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2255783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2256b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGI_make_current_read ***/
2257783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2258426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool
2259783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXMakeCurrentReadSGI(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx)
2260afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
2261a078d75a27b99252ede6520e24b145106ab98aa2Brian Paul   return Fake_glXMakeContextCurrent( dpy, draw, read, ctx );
2262afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
2263783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
22647cf50e137da497a590ec9001a9918972a6246142Brian Paul/* not used
2265783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXDrawable
2266b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian PaulFake_glXGetCurrentReadDrawableSGI(void)
2267783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2268783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2269783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
22707cf50e137da497a590ec9001a9918972a6246142Brian Paul*/
2271afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
2272afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
2273b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_video_source ***/
2274b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#if defined(_VL_H)
22754c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul
2276783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXVideoSourceSGIX
2277783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXCreateGLXVideoSourceSGIX(Display *dpy, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode)
2278afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
2279783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2280783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2281783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) server;
2282783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) path;
2283783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) nodeClass;
2284783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) drainNode;
2285783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2286783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2287783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2288783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2289783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXDestroyGLXVideoSourceSGIX(Display *dpy, GLXVideoSourceSGIX src)
2290783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2291783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2292783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) src;
2293afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
2294783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
22954c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul#endif
22964c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul
229789a42b7e736bd9b0ab090906cab0cd047a6ec12eBrian Paul
2298b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_EXT_import_context ***/
229989a42b7e736bd9b0ab090906cab0cd047a6ec12eBrian Paul
2300783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2301783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXFreeContextEXT(Display *dpy, GLXContext context)
2302783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2303783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2304783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) context;
2305783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2306426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2307783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXContextID
2308783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetContextIDEXT(const GLXContext context)
2309783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2310783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) context;
2311783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2312783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2313783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2314783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXContext
2315783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXImportContextEXT(Display *dpy, GLXContextID contextID)
2316783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2317783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2318783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) contextID;
2319783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2320783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2321426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2322426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int
2323783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryContextInfoEXT(Display *dpy, GLXContext context, int attribute, int *value)
2324426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2325783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2326783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) context;
2327783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) attribute;
2328783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) value;
2329426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   return 0;
2330426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2331426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2332783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2333783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2334b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_fbconfig ***/
2335426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2336426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int
2337783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetFBConfigAttribSGIX(Display *dpy, GLXFBConfigSGIX config, int attribute, int *value)
2338783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
23393265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   return Fake_glXGetFBConfigAttrib(dpy, config, attribute, value);
2340783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2341783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2342783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXFBConfigSGIX *
2343783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXChooseFBConfigSGIX(Display *dpy, int screen, int *attrib_list, int *nelements)
2344783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
23453265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   return (GLXFBConfig *) Fake_glXChooseFBConfig(dpy, screen, attrib_list, nelements);
2346783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2347783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2348e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2349783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXPixmap
2350783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXCreateGLXPixmapWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap)
2351783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2352e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaVisual xmvis = (XMesaVisual) config;
2353e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaBuffer xmbuf = XMesaCreatePixmapBuffer(xmvis, pixmap, 0);
2354e4656003caee346d9c4eb23256d73409271291a7Brian Paul   return xmbuf->frontbuffer; /* need to return an X ID */
2355783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2356783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2357e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2358783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXContext
2359783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct)
2360783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2361e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaVisual xmvis = (XMesaVisual) config;
2362e4656003caee346d9c4eb23256d73409271291a7Brian Paul   struct fake_glx_context *glxCtx;
2363e4656003caee346d9c4eb23256d73409271291a7Brian Paul   struct fake_glx_context *shareCtx = (struct fake_glx_context *) share_list;
2364e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2365e4656003caee346d9c4eb23256d73409271291a7Brian Paul   glxCtx = CALLOC_STRUCT(fake_glx_context);
2366e4656003caee346d9c4eb23256d73409271291a7Brian Paul   if (!glxCtx)
2367e4656003caee346d9c4eb23256d73409271291a7Brian Paul      return 0;
2368e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2369e4656003caee346d9c4eb23256d73409271291a7Brian Paul   /* deallocate unused windows/buffers */
2370e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaGarbageCollect();
2371e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2372e4656003caee346d9c4eb23256d73409271291a7Brian Paul   glxCtx->xmesaContext = XMesaCreateContext(xmvis,
2373e4656003caee346d9c4eb23256d73409271291a7Brian Paul                                   shareCtx ? shareCtx->xmesaContext : NULL);
2374e4656003caee346d9c4eb23256d73409271291a7Brian Paul   if (!glxCtx->xmesaContext) {
2375e4656003caee346d9c4eb23256d73409271291a7Brian Paul      FREE(glxCtx);
2376e4656003caee346d9c4eb23256d73409271291a7Brian Paul      return NULL;
2377e4656003caee346d9c4eb23256d73409271291a7Brian Paul   }
2378e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2379e4656003caee346d9c4eb23256d73409271291a7Brian Paul   glxCtx->xmesaContext->direct = GL_FALSE;
2380e4656003caee346d9c4eb23256d73409271291a7Brian Paul   glxCtx->glxContext.isDirect = GL_FALSE;
2381e4656003caee346d9c4eb23256d73409271291a7Brian Paul   glxCtx->glxContext.currentDpy = dpy;
2382e4656003caee346d9c4eb23256d73409271291a7Brian Paul   glxCtx->glxContext.xid = (XID) glxCtx;  /* self pointer */
2383e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2384e4656003caee346d9c4eb23256d73409271291a7Brian Paul   assert((void *) glxCtx == (void *) &(glxCtx->glxContext));
2385e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2386e4656003caee346d9c4eb23256d73409271291a7Brian Paul   return (GLXContext) glxCtx;
2387783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2388783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2389e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2390783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic XVisualInfo *
2391783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetVisualFromFBConfigSGIX(Display *dpy, GLXFBConfigSGIX config)
2392783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
23933265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   return Fake_glXGetVisualFromFBConfig(dpy, config);
2394783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2395783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2396e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2397783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXFBConfigSGIX
2398783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetFBConfigFromVisualSGIX(Display *dpy, XVisualInfo *vis)
2399426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2400e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaVisual xmvis = find_glx_visual(dpy, vis);
2401e4656003caee346d9c4eb23256d73409271291a7Brian Paul   if (!xmvis) {
2402e4656003caee346d9c4eb23256d73409271291a7Brian Paul      /* This visual wasn't found with glXChooseVisual() */
2403e4656003caee346d9c4eb23256d73409271291a7Brian Paul      xmvis = create_glx_visual(dpy, vis);
2404e4656003caee346d9c4eb23256d73409271291a7Brian Paul   }
2405e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2406e4656003caee346d9c4eb23256d73409271291a7Brian Paul   return (GLXFBConfigSGIX) xmvis;
2407426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2408426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2409426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2410426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2411b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_pbuffer ***/
2412783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2413783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXPbufferSGIX
24143265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian PaulFake_glXCreateGLXPbufferSGIX(Display *dpy, GLXFBConfigSGIX config,
24153265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul                             unsigned int width, unsigned int height,
24163265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul                             int *attribList)
2417783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
24183265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   XMesaVisual xmvis = (XMesaVisual) config;
24193265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   XMesaBuffer xmbuf;
24203265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   const int *attrib;
24213265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   GLboolean useLargest = GL_FALSE, preserveContents = GL_FALSE;
24223265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul
2423783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
24243265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul
242511b3028e7ba2fc3b985ab84d7227c290608f83f6Brian Paul   for (attrib = attribList; attrib && *attrib; attrib++) {
24263265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      switch (*attrib) {
24273265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         case GLX_PRESERVED_CONTENTS_SGIX:
24283265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            attrib++;
24293265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            preserveContents = *attrib; /* ignored */
24303265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            break;
24313265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         case GLX_LARGEST_PBUFFER_SGIX:
24323265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            attrib++;
24333265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            useLargest = *attrib; /* ignored */
24343265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            break;
24353265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         default:
24363265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            return 0;
24373265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      }
24383265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   }
24393265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul
2440b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul   /* not used at this time */
2441b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul   (void) useLargest;
2442b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul   (void) preserveContents;
2443b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul
24443265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   xmbuf = XMesaCreatePBuffer( xmvis, 0, width, height);
2445e4656003caee346d9c4eb23256d73409271291a7Brian Paul   /* A GLXPbuffer handle must be an X Drawable because that's what
2446e4656003caee346d9c4eb23256d73409271291a7Brian Paul    * glXMakeCurrent takes.
2447e4656003caee346d9c4eb23256d73409271291a7Brian Paul    */
2448e4656003caee346d9c4eb23256d73409271291a7Brian Paul   return (GLXPbuffer) xmbuf->frontbuffer;
2449783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2450783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2451e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2452783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2453783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXDestroyGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf)
2454783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2455e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaBuffer xmbuf = XMesaFindBuffer(dpy, pbuf);
2456e4656003caee346d9c4eb23256d73409271291a7Brian Paul   if (xmbuf) {
2457e4656003caee346d9c4eb23256d73409271291a7Brian Paul      XMesaDestroyBuffer(xmbuf);
2458e4656003caee346d9c4eb23256d73409271291a7Brian Paul   }
2459783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2460783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2461e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2462783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2463783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value)
2464783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2465e4656003caee346d9c4eb23256d73409271291a7Brian Paul   const XMesaBuffer xmbuf = XMesaFindBuffer(dpy, pbuf);
2466e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2467e4656003caee346d9c4eb23256d73409271291a7Brian Paul   if (!xmbuf) {
2468e4656003caee346d9c4eb23256d73409271291a7Brian Paul      /* Generate GLXBadPbufferSGIX for bad pbuffer */
2469e4656003caee346d9c4eb23256d73409271291a7Brian Paul      return 0;
2470e4656003caee346d9c4eb23256d73409271291a7Brian Paul   }
2471e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2472e4656003caee346d9c4eb23256d73409271291a7Brian Paul   switch (attribute) {
2473e4656003caee346d9c4eb23256d73409271291a7Brian Paul      case GLX_PRESERVED_CONTENTS_SGIX:
2474e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = True;
2475e4656003caee346d9c4eb23256d73409271291a7Brian Paul         break;
2476e4656003caee346d9c4eb23256d73409271291a7Brian Paul      case GLX_LARGEST_PBUFFER_SGIX:
2477e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = xmbuf->width * xmbuf->height;
2478e4656003caee346d9c4eb23256d73409271291a7Brian Paul         break;
2479e4656003caee346d9c4eb23256d73409271291a7Brian Paul      case GLX_WIDTH_SGIX:
2480e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = xmbuf->width;
2481e4656003caee346d9c4eb23256d73409271291a7Brian Paul         break;
2482e4656003caee346d9c4eb23256d73409271291a7Brian Paul      case GLX_HEIGHT_SGIX:
2483e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = xmbuf->height;
2484e4656003caee346d9c4eb23256d73409271291a7Brian Paul         break;
2485e4656003caee346d9c4eb23256d73409271291a7Brian Paul      case GLX_EVENT_MASK_SGIX:
2486e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = 0;  /* XXX might be wrong */
2487e4656003caee346d9c4eb23256d73409271291a7Brian Paul         break;
2488e4656003caee346d9c4eb23256d73409271291a7Brian Paul      default:
2489e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = 0;
2490e4656003caee346d9c4eb23256d73409271291a7Brian Paul   }
2491783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2492783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2493783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2494e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2495783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2496783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXSelectEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long mask)
2497783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2498e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable);
2499e4656003caee346d9c4eb23256d73409271291a7Brian Paul   if (xmbuf) {
2500e4656003caee346d9c4eb23256d73409271291a7Brian Paul      /* Note: we'll never generate clobber events */
2501e4656003caee346d9c4eb23256d73409271291a7Brian Paul      xmbuf->selectedEvents = mask;
2502e4656003caee346d9c4eb23256d73409271291a7Brian Paul   }
2503783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2504783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2505e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2506783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2507783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetSelectedEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long *mask)
2508783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2509e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable);
2510e4656003caee346d9c4eb23256d73409271291a7Brian Paul   if (xmbuf) {
2511e4656003caee346d9c4eb23256d73409271291a7Brian Paul      *mask = xmbuf->selectedEvents;
2512e4656003caee346d9c4eb23256d73409271291a7Brian Paul   }
2513e4656003caee346d9c4eb23256d73409271291a7Brian Paul   else {
2514e4656003caee346d9c4eb23256d73409271291a7Brian Paul      *mask = 0;
2515e4656003caee346d9c4eb23256d73409271291a7Brian Paul   }
2516783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2517783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2518783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2519783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2520b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGI_cushion ***/
2521783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2522783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2523783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXCushionSGI(Display *dpy, Window win, float cushion)
2524783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2525783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2526783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) win;
2527783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) cushion;
2528783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2529783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2530783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2531783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2532b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_video_resize ***/
2533783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2534783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2535783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXBindChannelToWindowSGIX(Display *dpy, int screen, int channel , Window window)
2536783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2537783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2538783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2539783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) channel;
2540783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) window;
2541783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2542783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2543783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2544783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2545783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXChannelRectSGIX(Display *dpy, int screen, int channel, int x, int y, int w, int h)
2546783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2547783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2548783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2549783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) channel;
2550783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) x;
2551783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) y;
2552783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) w;
2553783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) h;
2554783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2555783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2556783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2557783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2558783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryChannelRectSGIX(Display *dpy, int screen, int channel, int *x, int *y, int *w, int *h)
2559783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2560783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2561783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2562783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) channel;
2563783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) x;
2564783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) y;
2565783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) w;
2566783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) h;
2567783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2568783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2569783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2570783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2571783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryChannelDeltasSGIX(Display *dpy, int screen, int channel, int *dx, int *dy, int *dw, int *dh)
2572783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2573783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2574783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2575783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) channel;
2576783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dx;
2577783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dy;
2578783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dw;
2579783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dh;
2580783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2581783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2582783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2583783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2584783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXChannelRectSyncSGIX(Display *dpy, int screen, int channel, GLenum synctype)
2585783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2586783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2587783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2588783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) channel;
2589783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) synctype;
2590783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2591783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2592783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2593783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2594783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2595b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_dmbuffer **/
2596783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2597b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#if defined(_DM_BUFFER_H_)
2598783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Bool
2599783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXAssociateDMPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer)
2600783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2601783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2602783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) pbuffer;
2603783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) params;
2604783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dmbuffer;
2605783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return False;
2606783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2607783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul#endif
2608783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2609783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2610b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_swap_group ***/
2611783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2612783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2613783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXJoinSwapGroupSGIX(Display *dpy, GLXDrawable drawable, GLXDrawable member)
2614783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2615783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2616783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) drawable;
2617783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) member;
2618783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2619783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2620783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2621783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2622b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_swap_barrier ***/
2623783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2624783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2625783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXBindSwapBarrierSGIX(Display *dpy, GLXDrawable drawable, int barrier)
2626783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2627783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2628783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) drawable;
2629783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) barrier;
2630783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2631783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2632783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Bool
2633783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryMaxSwapBarriersSGIX(Display *dpy, int screen, int *max)
2634783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2635783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2636783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2637783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) max;
2638783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return False;
2639783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2640783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2641783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2642783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2643b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SUN_get_transparent_index ***/
2644783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2645783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Status
2646783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetTransparentIndexSUN(Display *dpy, Window overlay, Window underlay, long *pTransparent)
2647783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2648783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2649783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) overlay;
2650783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) underlay;
2651783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) pTransparent;
2652783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2653783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2654783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2655783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2656783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2657b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_MESA_release_buffers ***/
2658b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul
2659783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul/*
2660783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul * Release the depth, stencil, accum buffers attached to a GLXDrawable
2661783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul * (a window or pixmap) prior to destroying the GLXDrawable.
2662783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul */
2663783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Bool
2664783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXReleaseBuffersMESA( Display *dpy, GLXDrawable d )
2665783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2666783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   XMesaBuffer b = XMesaFindBuffer(dpy, d);
2667783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   if (b) {
2668783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul      XMesaDestroyBuffer(b);
2669783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul      return True;
2670783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   }
2671783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return False;
2672783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2673783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2674783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2675783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2676b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_MESA_set_3dfx_mode ***/
2677b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul
2678783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Bool
2679783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXSet3DfxModeMESA( int mode )
2680783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2681783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return XMesaSetFXmode( mode );
2682783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2683783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2684783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2685783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
26863c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian Paul/*** GLX_NV_vertex_array range ***/
26878fefafa2200d3ea44ec46592b190654a10685b46Brian Paulstatic void *
26888fefafa2200d3ea44ec46592b190654a10685b46Brian PaulFake_glXAllocateMemoryNV( GLsizei size,
26898fefafa2200d3ea44ec46592b190654a10685b46Brian Paul                          GLfloat readFrequency,
26908fefafa2200d3ea44ec46592b190654a10685b46Brian Paul                          GLfloat writeFrequency,
26918fefafa2200d3ea44ec46592b190654a10685b46Brian Paul                          GLfloat priority )
26928fefafa2200d3ea44ec46592b190654a10685b46Brian Paul{
26938fefafa2200d3ea44ec46592b190654a10685b46Brian Paul   (void) size;
26948fefafa2200d3ea44ec46592b190654a10685b46Brian Paul   (void) readFrequency;
26958fefafa2200d3ea44ec46592b190654a10685b46Brian Paul   (void) writeFrequency;
26968fefafa2200d3ea44ec46592b190654a10685b46Brian Paul   (void) priority;
26978fefafa2200d3ea44ec46592b190654a10685b46Brian Paul   return NULL;
26988fefafa2200d3ea44ec46592b190654a10685b46Brian Paul}
26998fefafa2200d3ea44ec46592b190654a10685b46Brian Paul
27008fefafa2200d3ea44ec46592b190654a10685b46Brian Paul
27018fefafa2200d3ea44ec46592b190654a10685b46Brian Paulstatic void
27028fefafa2200d3ea44ec46592b190654a10685b46Brian PaulFake_glXFreeMemoryNV( GLvoid *pointer )
27038fefafa2200d3ea44ec46592b190654a10685b46Brian Paul{
27048fefafa2200d3ea44ec46592b190654a10685b46Brian Paul   (void) pointer;
27058fefafa2200d3ea44ec46592b190654a10685b46Brian Paul}
27068fefafa2200d3ea44ec46592b190654a10685b46Brian Paul
27078fefafa2200d3ea44ec46592b190654a10685b46Brian Paul
27083c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian Paul/*** GLX_MESA_agp_offset ***/
2709d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul
2710d6113fc20d68f5720740b89c594227d0312bab3eBrian Paulstatic GLuint
2711d6113fc20d68f5720740b89c594227d0312bab3eBrian PaulFake_glXGetAGPOffsetMESA( const GLvoid *pointer )
2712d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul{
2713d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul   (void) pointer;
2714d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul   return ~0;
2715d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul}
2716d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul
2717d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul
27183c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian Paul/*** GLX_ARB_render_texture ***/
27193c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian Paul
27203c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian Paulstatic Bool
27213c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian PaulFake_glXBindTexImageARB( Display *dpy, GLXPbuffer pbuffer, int buffer )
27223c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian Paul{
27233c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian Paul   return False;
27243c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian Paul}
27253c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian Paul
27263c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian Paul
27273c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian Paulstatic Bool
27283c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian PaulFake_glXReleaseTexImageARB(Display *dpy, GLXPbuffer pbuffer, int buffer )
27293c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian Paul{
27303c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian Paul   return False;
27313c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian Paul}
27323c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian Paul
27333c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian Paul
27343c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian Paulstatic Bool
27353c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian PaulFake_glXDrawableAttribARB( Display *dpy, GLXDrawable draw, const int *attribList )
27363c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian Paul{
27373c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian Paul   return False;
27383c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian Paul}
27393c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian Paul
27403c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian Paul
274143c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul
2742e7b16b74bf5d13331b5a88bbbbb9096560297b63Brian Paulextern struct _glxapi_table *_mesa_GetGLXDispatchTable(void);
2743426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstruct _glxapi_table *_mesa_GetGLXDispatchTable(void)
2744426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2745426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   static struct _glxapi_table glx;
2746426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2747426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   /* be sure our dispatch table size <= libGL's table */
2748426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   {
274901915e90e6912f06d43d443a09157f7bbc96ddc5Brian Paul      GLuint size = sizeof(struct _glxapi_table) / sizeof(void *);
2750426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul      (void) size;
2751426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul      assert(_glxapi_get_dispatch_table_size() >= size);
2752426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   }
2753426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2754426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   /* initialize the whole table to no-ops */
2755426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   _glxapi_set_no_op_table(&glx);
2756426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2757426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   /* now initialize the table with the functions I implement */
2758426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.ChooseVisual = Fake_glXChooseVisual;
2759426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CopyContext = Fake_glXCopyContext;
2760426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CreateContext = Fake_glXCreateContext;
2761426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CreateGLXPixmap = Fake_glXCreateGLXPixmap;
2762426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.DestroyContext = Fake_glXDestroyContext;
2763426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.DestroyGLXPixmap = Fake_glXDestroyGLXPixmap;
2764426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.GetConfig = Fake_glXGetConfig;
2765426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   /*glx.GetCurrentContext = Fake_glXGetCurrentContext;*/
2766426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   /*glx.GetCurrentDrawable = Fake_glXGetCurrentDrawable;*/
2767426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.IsDirect = Fake_glXIsDirect;
2768426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.MakeCurrent = Fake_glXMakeCurrent;
2769426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.QueryExtension = Fake_glXQueryExtension;
2770426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.QueryVersion = Fake_glXQueryVersion;
2771426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.SwapBuffers = Fake_glXSwapBuffers;
2772426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.UseXFont = Fake_glXUseXFont;
2773426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.WaitGL = Fake_glXWaitGL;
2774426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.WaitX = Fake_glXWaitX;
2775426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2776b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_VERSION_1_1 ***/
2777426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.GetClientString = Fake_glXGetClientString;
2778426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.QueryExtensionsString = Fake_glXQueryExtensionsString;
2779426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.QueryServerString = Fake_glXQueryServerString;
2780426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2781b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_VERSION_1_2 ***/
2782426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   /*glx.GetCurrentDisplay = Fake_glXGetCurrentDisplay;*/
2783426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2784b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_VERSION_1_3 ***/
2785426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.ChooseFBConfig = Fake_glXChooseFBConfig;
2786426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CreateNewContext = Fake_glXCreateNewContext;
2787426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CreatePbuffer = Fake_glXCreatePbuffer;
2788426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CreatePixmap = Fake_glXCreatePixmap;
2789426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CreateWindow = Fake_glXCreateWindow;
2790426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.DestroyPbuffer = Fake_glXDestroyPbuffer;
2791426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.DestroyPixmap = Fake_glXDestroyPixmap;
2792426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.DestroyWindow = Fake_glXDestroyWindow;
2793426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   /*glx.GetCurrentReadDrawable = Fake_glXGetCurrentReadDrawable;*/
2794426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.GetFBConfigAttrib = Fake_glXGetFBConfigAttrib;
279571dea349d2be623b7819389428b0d6a124e8d184Brian Paul   glx.GetFBConfigs = Fake_glXGetFBConfigs;
2796426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.GetSelectedEvent = Fake_glXGetSelectedEvent;
2797426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.GetVisualFromFBConfig = Fake_glXGetVisualFromFBConfig;
2798426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.MakeContextCurrent = Fake_glXMakeContextCurrent;
2799426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.QueryContext = Fake_glXQueryContext;
2800426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.QueryDrawable = Fake_glXQueryDrawable;
2801426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.SelectEvent = Fake_glXSelectEvent;
2802426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2803b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGI_swap_control ***/
2804783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.SwapIntervalSGI = Fake_glXSwapIntervalSGI;
2805783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2806b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGI_video_sync ***/
2807426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.GetVideoSyncSGI = Fake_glXGetVideoSyncSGI;
2808426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.WaitVideoSyncSGI = Fake_glXWaitVideoSyncSGI;
2809426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2810b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGI_make_current_read ***/
2811783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.MakeCurrentReadSGI = Fake_glXMakeCurrentReadSGI;
28127cf50e137da497a590ec9001a9918972a6246142Brian Paul   /*glx.GetCurrentReadDrawableSGI = Fake_glXGetCurrentReadDrawableSGI;*/
2813783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2814b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_video_source ***/
2815b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#if defined(_VL_H)
2816783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.CreateGLXVideoSourceSGIX = Fake_glXCreateGLXVideoSourceSGIX;
2817783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.DestroyGLXVideoSourceSGIX = Fake_glXDestroyGLXVideoSourceSGIX;
2818783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul#endif
2819783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2820b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_EXT_import_context ***/
2821783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.FreeContextEXT = Fake_glXFreeContextEXT;
2822783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.GetContextIDEXT = Fake_glXGetContextIDEXT;
28237cf50e137da497a590ec9001a9918972a6246142Brian Paul   /*glx.GetCurrentDisplayEXT = Fake_glXGetCurrentDisplayEXT;*/
2824783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.ImportContextEXT = Fake_glXImportContextEXT;
2825783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.QueryContextInfoEXT = Fake_glXQueryContextInfoEXT;
28264536021a62e02fceaa6e8eb889b0f61743109cc4Brian Paul
2827b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGIX_fbconfig ***/
2828783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.GetFBConfigAttribSGIX = Fake_glXGetFBConfigAttribSGIX;
2829783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.ChooseFBConfigSGIX = Fake_glXChooseFBConfigSGIX;
2830783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.CreateGLXPixmapWithConfigSGIX = Fake_glXCreateGLXPixmapWithConfigSGIX;
2831783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.CreateContextWithConfigSGIX = Fake_glXCreateContextWithConfigSGIX;
2832783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.GetVisualFromFBConfigSGIX = Fake_glXGetVisualFromFBConfigSGIX;
2833783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.GetFBConfigFromVisualSGIX = Fake_glXGetFBConfigFromVisualSGIX;
2834783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2835b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGIX_pbuffer ***/
2836783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.CreateGLXPbufferSGIX = Fake_glXCreateGLXPbufferSGIX;
2837783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.DestroyGLXPbufferSGIX = Fake_glXDestroyGLXPbufferSGIX;
2838783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.QueryGLXPbufferSGIX = Fake_glXQueryGLXPbufferSGIX;
2839783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.SelectEventSGIX = Fake_glXSelectEventSGIX;
2840783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.GetSelectedEventSGIX = Fake_glXGetSelectedEventSGIX;
2841783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2842b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGI_cushion ***/
2843783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.CushionSGI = Fake_glXCushionSGI;
2844783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2845b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGIX_video_resize ***/
2846783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.BindChannelToWindowSGIX = Fake_glXBindChannelToWindowSGIX;
2847783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.ChannelRectSGIX = Fake_glXChannelRectSGIX;
2848783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.QueryChannelRectSGIX = Fake_glXQueryChannelRectSGIX;
2849783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.QueryChannelDeltasSGIX = Fake_glXQueryChannelDeltasSGIX;
2850783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.ChannelRectSyncSGIX = Fake_glXChannelRectSyncSGIX;
2851783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2852b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGIX_dmbuffer **/
2853b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#if defined(_DM_BUFFER_H_)
2854783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.AssociateDMPbufferSGIX = NULL;
2855783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul#endif
2856783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2857b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGIX_swap_group ***/
2858783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.JoinSwapGroupSGIX = Fake_glXJoinSwapGroupSGIX;
2859783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2860b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGIX_swap_barrier ***/
2861783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.BindSwapBarrierSGIX = Fake_glXBindSwapBarrierSGIX;
2862783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.QueryMaxSwapBarriersSGIX = Fake_glXQueryMaxSwapBarriersSGIX;
2863783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2864b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SUN_get_transparent_index ***/
2865783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.GetTransparentIndexSUN = Fake_glXGetTransparentIndexSUN;
28664536021a62e02fceaa6e8eb889b0f61743109cc4Brian Paul
2867b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_MESA_copy_sub_buffer ***/
2868426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CopySubBufferMESA = Fake_glXCopySubBufferMESA;
2869426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2870b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_MESA_release_buffers ***/
2871426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.ReleaseBuffersMESA = Fake_glXReleaseBuffersMESA;
2872426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2873b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_MESA_pixmap_colormap ***/
2874426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CreateGLXPixmapMESA = Fake_glXCreateGLXPixmapMESA;
2875426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2876b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_MESA_set_3dfx_mode ***/
2877426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.Set3DfxModeMESA = Fake_glXSet3DfxModeMESA;
2878426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2879d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul   /*** GLX_NV_vertex_array_range ***/
28808fefafa2200d3ea44ec46592b190654a10685b46Brian Paul   glx.AllocateMemoryNV = Fake_glXAllocateMemoryNV;
28818fefafa2200d3ea44ec46592b190654a10685b46Brian Paul   glx.FreeMemoryNV = Fake_glXFreeMemoryNV;
28828fefafa2200d3ea44ec46592b190654a10685b46Brian Paul
2883d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul   /*** GLX_MESA_agp_offset ***/
2884d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul   glx.GetAGPOffsetMESA = Fake_glXGetAGPOffsetMESA;
2885d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul
28863c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian Paul   /*** GLX_ARB_render_texture ***/
28873c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian Paul   glx.BindTexImageARB = Fake_glXBindTexImageARB;
28883c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian Paul   glx.ReleaseTexImageARB = Fake_glXReleaseTexImageARB;
28893c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian Paul   glx.DrawableAttribARB = Fake_glXDrawableAttribARB;
28903c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian Paul
2891426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   return &glx;
2892426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2893