fakeglx.c revision 70cf1f0cf83fc3f2df241cc638e23f8df3b89923
1afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
2afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Mesa 3-D graphics library
3be2de8b299c9fc7bdc22372ed799e894a8582c62Brian Paul * Version:  6.3
45e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen *
51f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul * Copyright (C) 1999-2005  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
5570cf1f0cf83fc3f2df241cc638e23f8df3b89923Jouk Jansen#ifdef __VMS
5670cf1f0cf83fc3f2df241cc638e23f8df3b89923Jouk Jansen#define _mesa_sprintf sprintf
5770cf1f0cf83fc3f2df241cc638e23f8df3b89923Jouk Jansen#endif
58afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
5978fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul/* This indicates the client-side GLX API and GLX encoder version. */
6078fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul#define CLIENT_MAJOR_VERSION 1
61a573803ed3fe9ef6489f45bd4c5455b77cb33a43Brian Paul#define CLIENT_MINOR_VERSION 4  /* but don't have 1.3's pbuffers, etc yet */
6278fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul
6378fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul/* This indicates the server-side GLX decoder version.
64ba57e5297d60eef37e43dd4d7f10d1e62f5e97ceBrian Paul * GLX 1.4 indicates OpenGL 1.3 support
6578fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul */
6678fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul#define SERVER_MAJOR_VERSION 1
67ba57e5297d60eef37e43dd4d7f10d1e62f5e97ceBrian Paul#define SERVER_MINOR_VERSION 4
6878fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul
6978fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul/* This is appended onto the glXGetClient/ServerString version strings. */
702c5f93784ea1ba28ae15181917ff3e47656a93adBrian Paul#define MESA_GLX_VERSION "Mesa " MESA_VERSION_STRING
7178fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul
7278fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul/* Who implemented this GLX? */
7378fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul#define VENDOR "Brian Paul"
7478fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul
75e4656003caee346d9c4eb23256d73409271291a7Brian Paul#define EXTENSIONS \
76e4656003caee346d9c4eb23256d73409271291a7Brian Paul   "GLX_MESA_set_3dfx_mode " \
77e4656003caee346d9c4eb23256d73409271291a7Brian Paul   "GLX_MESA_copy_sub_buffer " \
78e4656003caee346d9c4eb23256d73409271291a7Brian Paul   "GLX_MESA_pixmap_colormap " \
79e4656003caee346d9c4eb23256d73409271291a7Brian Paul   "GLX_MESA_release_buffers " \
80e4656003caee346d9c4eb23256d73409271291a7Brian Paul   "GLX_ARB_get_proc_address " \
81e4656003caee346d9c4eb23256d73409271291a7Brian Paul   "GLX_EXT_visual_info " \
82e4656003caee346d9c4eb23256d73409271291a7Brian Paul   "GLX_EXT_visual_rating " \
83e4656003caee346d9c4eb23256d73409271291a7Brian Paul   "GLX_SGI_video_sync " \
84e4656003caee346d9c4eb23256d73409271291a7Brian Paul   "GLX_SGIX_fbconfig " \
856d6efd605f662c1f07e183e58416db804f0a058fBrian Paul   "GLX_SGIX_pbuffer "
8643c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul
877cf50e137da497a590ec9001a9918972a6246142Brian Paul/*
887cf50e137da497a590ec9001a9918972a6246142Brian Paul * Our fake GLX context will contain a "real" GLX context and an XMesa context.
897cf50e137da497a590ec9001a9918972a6246142Brian Paul *
907cf50e137da497a590ec9001a9918972a6246142Brian Paul * Note that a pointer to a __GLXcontext is a pointer to a fake_glx_context,
917cf50e137da497a590ec9001a9918972a6246142Brian Paul * and vice versa.
927cf50e137da497a590ec9001a9918972a6246142Brian Paul *
937cf50e137da497a590ec9001a9918972a6246142Brian Paul * We really just need this structure in order to make the libGL functions
947cf50e137da497a590ec9001a9918972a6246142Brian Paul * glXGetCurrentContext(), glXGetCurrentDrawable() and glXGetCurrentDisplay()
957cf50e137da497a590ec9001a9918972a6246142Brian Paul * work correctly.
967cf50e137da497a590ec9001a9918972a6246142Brian Paul */
977cf50e137da497a590ec9001a9918972a6246142Brian Paulstruct fake_glx_context {
987cf50e137da497a590ec9001a9918972a6246142Brian Paul   __GLXcontext glxContext;   /* this MUST be first! */
997cf50e137da497a590ec9001a9918972a6246142Brian Paul   XMesaContext xmesaContext;
1007cf50e137da497a590ec9001a9918972a6246142Brian Paul};
10143c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul
102afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
103afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1047cf50e137da497a590ec9001a9918972a6246142Brian Paul/**********************************************************************/
1057cf50e137da497a590ec9001a9918972a6246142Brian Paul/***                       GLX Visual Code                          ***/
1067cf50e137da497a590ec9001a9918972a6246142Brian Paul/**********************************************************************/
1077cf50e137da497a590ec9001a9918972a6246142Brian Paul
1087cf50e137da497a590ec9001a9918972a6246142Brian Paul#define DONT_CARE -1
1097cf50e137da497a590ec9001a9918972a6246142Brian Paul
110afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
11164034c4fb5c56f63d37faa6f64f3183ca106856aAlan Hourihanestatic XMesaVisual *VisualTable = NULL;
112afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic int NumVisuals = 0;
113afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
114afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
115afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
116afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * This struct and some code fragments borrowed
117afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * from Mark Kilgard's GLUT library.
118afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
119afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgtypedef struct _OverlayInfo {
120afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg  /* Avoid 64-bit portability problems by being careful to use
121afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg     longs due to the way XGetWindowProperty is specified. Note
122afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg     that these parameters are passed as CARD32s over X
123afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg     protocol. */
124afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg  unsigned long overlay_visual;
125afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg  long transparent_type;
126afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg  long value;
127afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg  long layer;
128afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} OverlayInfo;
129afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
130afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
131afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
132afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* Macro to handle c_class vs class field name in XVisualInfo struct */
133afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#if defined(__cplusplus) || defined(c_plusplus)
134afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#define CLASS c_class
135afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#else
136afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#define CLASS class
137afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#endif
138afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
139afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
140afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
141afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
142afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Test if the given XVisualInfo is usable for Mesa rendering.
143afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
1447287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulstatic GLboolean
1457287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulis_usable_visual( XVisualInfo *vinfo )
146afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
147afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   switch (vinfo->CLASS) {
148afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case StaticGray:
149afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GrayScale:
150afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* Any StaticGray/GrayScale visual works in RGB or CI mode */
151afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return GL_TRUE;
152afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case StaticColor:
153afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case PseudoColor:
154afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 /* Any StaticColor/PseudoColor visual of at least 4 bits */
155afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 if (vinfo->depth>=4) {
156afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    return GL_TRUE;
157afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 }
158afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 else {
159afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    return GL_FALSE;
160afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 }
161afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case TrueColor:
162afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case DirectColor:
163afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 /* Any depth of TrueColor or DirectColor works in RGB mode */
164afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return GL_TRUE;
165afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      default:
166afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 /* This should never happen */
167afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return GL_FALSE;
168afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
169afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
170afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
171afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
172afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1731d97c277e0cb2b75559d495a58222f2511212a66Brian Paul/**
1741d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * Get an array OverlayInfo records for specified screen.
1751d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * \param dpy  the display
1761d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * \param screen  screen number
1771d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * \param numOverlays  returns numver of OverlayInfo records
1781d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * \return  pointer to OverlayInfo array, free with XFree()
179afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
1801d97c277e0cb2b75559d495a58222f2511212a66Brian Paulstatic OverlayInfo *
1811d97c277e0cb2b75559d495a58222f2511212a66Brian PaulGetOverlayInfo(Display *dpy, int screen, int *numOverlays)
182afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
183afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   Atom overlayVisualsAtom;
184afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   Atom actualType;
1851d97c277e0cb2b75559d495a58222f2511212a66Brian Paul   Status status;
1861d97c277e0cb2b75559d495a58222f2511212a66Brian Paul   unsigned char *ovInfo;
187afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   unsigned long sizeData, bytesLeft;
1881d97c277e0cb2b75559d495a58222f2511212a66Brian Paul   int actualFormat;
189afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
190afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /*
191afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * The SERVER_OVERLAY_VISUALS property on the root window contains
192afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * a list of overlay visuals.  Get that list now.
193afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    */
194afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   overlayVisualsAtom = XInternAtom(dpy,"SERVER_OVERLAY_VISUALS", True);
195afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (overlayVisualsAtom == None) {
196afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return 0;
197afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
198afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1991d97c277e0cb2b75559d495a58222f2511212a66Brian Paul   status = XGetWindowProperty(dpy, RootWindow(dpy, screen),
200afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               overlayVisualsAtom, 0L, (long) 10000, False,
201afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               overlayVisualsAtom, &actualType, &actualFormat,
202afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                               &sizeData, &bytesLeft,
2031d97c277e0cb2b75559d495a58222f2511212a66Brian Paul                               &ovInfo);
204afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
205afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (status != Success || actualType != overlayVisualsAtom ||
206afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg       actualFormat != 32 || sizeData < 4) {
207afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* something went wrong */
2081d97c277e0cb2b75559d495a58222f2511212a66Brian Paul      XFree((void *) ovInfo);
2091d97c277e0cb2b75559d495a58222f2511212a66Brian Paul      *numOverlays = 0;
2101d97c277e0cb2b75559d495a58222f2511212a66Brian Paul      return NULL;
2111d97c277e0cb2b75559d495a58222f2511212a66Brian Paul   }
2121d97c277e0cb2b75559d495a58222f2511212a66Brian Paul
2131d97c277e0cb2b75559d495a58222f2511212a66Brian Paul   *numOverlays = sizeData / 4;
2141d97c277e0cb2b75559d495a58222f2511212a66Brian Paul   return (OverlayInfo *) ovInfo;
2151d97c277e0cb2b75559d495a58222f2511212a66Brian Paul}
2161d97c277e0cb2b75559d495a58222f2511212a66Brian Paul
2171d97c277e0cb2b75559d495a58222f2511212a66Brian Paul
2181d97c277e0cb2b75559d495a58222f2511212a66Brian Paul
2191d97c277e0cb2b75559d495a58222f2511212a66Brian Paul/**
2201d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * Return the level (overlay, normal, underlay) of a given XVisualInfo.
2211d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * Input:  dpy - the X display
2221d97c277e0cb2b75559d495a58222f2511212a66Brian Paul *         vinfo - the XVisualInfo to test
2231d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * Return:  level of the visual:
2241d97c277e0cb2b75559d495a58222f2511212a66Brian Paul *             0 = normal planes
2251d97c277e0cb2b75559d495a58222f2511212a66Brian Paul *            >0 = overlay planes
2261d97c277e0cb2b75559d495a58222f2511212a66Brian Paul *            <0 = underlay planes
2271d97c277e0cb2b75559d495a58222f2511212a66Brian Paul */
2281d97c277e0cb2b75559d495a58222f2511212a66Brian Paulstatic int
2291d97c277e0cb2b75559d495a58222f2511212a66Brian Paullevel_of_visual( Display *dpy, XVisualInfo *vinfo )
2301d97c277e0cb2b75559d495a58222f2511212a66Brian Paul{
2311d97c277e0cb2b75559d495a58222f2511212a66Brian Paul   OverlayInfo *overlay_info;
2321d97c277e0cb2b75559d495a58222f2511212a66Brian Paul   int numOverlaysPerScreen, i;
2331d97c277e0cb2b75559d495a58222f2511212a66Brian Paul
2341d97c277e0cb2b75559d495a58222f2511212a66Brian Paul   overlay_info = GetOverlayInfo(dpy, vinfo->screen, &numOverlaysPerScreen);
2351d97c277e0cb2b75559d495a58222f2511212a66Brian Paul   if (!overlay_info) {
236afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return 0;
237afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
238afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
239afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* search the overlay visual list for the visual ID of interest */
2401d97c277e0cb2b75559d495a58222f2511212a66Brian Paul   for (i = 0; i < numOverlaysPerScreen; i++) {
2411d97c277e0cb2b75559d495a58222f2511212a66Brian Paul      const OverlayInfo *ov = overlay_info + i;
2421d97c277e0cb2b75559d495a58222f2511212a66Brian Paul      if (ov->overlay_visual == vinfo->visualid) {
243afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* found the visual */
244afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         if (/*ov->transparent_type==1 &&*/ ov->layer!=0) {
245afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            int level = ov->layer;
246afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            XFree((void *) overlay_info);
247afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            return level;
248afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
249afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         else {
250afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            XFree((void *) overlay_info);
251afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            return 0;
252afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
253afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
254afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
255afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
256afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* The visual ID was not found in the overlay list. */
257afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XFree((void *) overlay_info);
258afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return 0;
259afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
260afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
261afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
262afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
263afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
264afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
265afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Given an XVisualInfo and RGB, Double, and Depth buffer flags, save the
266afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * configuration in our list of GLX visuals.
267afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
268afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XMesaVisual
269afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgsave_glx_visual( Display *dpy, XVisualInfo *vinfo,
270afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                 GLboolean rgbFlag, GLboolean alphaFlag, GLboolean dbFlag,
271afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                 GLboolean stereoFlag,
272afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                 GLint depth_size, GLint stencil_size,
273b2e460018375f699198073a6167e0ee96ba1d267Brian Paul                 GLint accumRedSize, GLint accumGreenSize,
274b2e460018375f699198073a6167e0ee96ba1d267Brian Paul                 GLint accumBlueSize, GLint accumAlphaSize,
275894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul                 GLint level, GLint numAuxBuffers )
276afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
277afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLboolean ximageFlag = GL_TRUE;
278afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaVisual xmvis;
279afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLint i;
280afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLboolean comparePointers;
281afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
282afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (dbFlag) {
283afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* Check if the MESA_BACK_BUFFER env var is set */
284367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul      char *backbuffer = _mesa_getenv("MESA_BACK_BUFFER");
285afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (backbuffer) {
286afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         if (backbuffer[0]=='p' || backbuffer[0]=='P') {
287afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            ximageFlag = GL_FALSE;
288afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
289afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         else if (backbuffer[0]=='x' || backbuffer[0]=='X') {
290afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            ximageFlag = GL_TRUE;
291afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
292afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         else {
293d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul            _mesa_warning(NULL, "Mesa: invalid value for MESA_BACK_BUFFER environment variable, using an XImage.");
294afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
295afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
296afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
297afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
298afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* Comparing IDs uses less memory but sometimes fails. */
299afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* XXX revisit this after 3.0 is finished. */
300367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul   if (_mesa_getenv("MESA_GLX_VISUAL_HACK"))
301afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      comparePointers = GL_TRUE;
302afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else
303afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      comparePointers = GL_FALSE;
304afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
305a13331d59b535aa4a1ddad695420de5d6f814550Brian Paul   /* Force the visual to have an alpha channel */
306a13331d59b535aa4a1ddad695420de5d6f814550Brian Paul   if (rgbFlag && _mesa_getenv("MESA_GLX_FORCE_ALPHA"))
307a13331d59b535aa4a1ddad695420de5d6f814550Brian Paul      alphaFlag = GL_TRUE;
308a13331d59b535aa4a1ddad695420de5d6f814550Brian Paul
309afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* First check if a matching visual is already in the list */
310afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   for (i=0; i<NumVisuals; i++) {
311afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      XMesaVisual v = VisualTable[i];
312afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (v->display == dpy
313304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick          && v->mesa_visual.level == level
314894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul          && v->mesa_visual.numAuxBuffers == numAuxBuffers
315afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg          && v->ximage_flag == ximageFlag
3161832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && v->mesa_visual.rgbMode == rgbFlag
3171832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && v->mesa_visual.doubleBufferMode == dbFlag
3181832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && v->mesa_visual.stereoMode == stereoFlag
3191832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && (v->mesa_visual.alphaBits > 0) == alphaFlag
3201832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && (v->mesa_visual.depthBits >= depth_size || depth_size == 0)
3211832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && (v->mesa_visual.stencilBits >= stencil_size || stencil_size == 0)
3221832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && (v->mesa_visual.accumRedBits >= accumRedSize || accumRedSize == 0)
3231832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && (v->mesa_visual.accumGreenBits >= accumGreenSize || accumGreenSize == 0)
3241832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && (v->mesa_visual.accumBlueBits >= accumBlueSize || accumBlueSize == 0)
3251832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul          && (v->mesa_visual.accumAlphaBits >= accumAlphaSize || accumAlphaSize == 0)) {
326afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* now either compare XVisualInfo pointers or visual IDs */
327d0247f53aea8fa8677aadc8a00f75c8993be9ebcBrian Paul         if ((!comparePointers && v->visinfo->visualid == vinfo->visualid)
328afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg             || (comparePointers && v->vishandle == vinfo)) {
329afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            return v;
330afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
331afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
332afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
333afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
334afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* Create a new visual and add it to the list. */
335afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
336c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul   xmvis = XMesaCreateVisual( dpy, vinfo, rgbFlag, alphaFlag, dbFlag,
337c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul                              stereoFlag, ximageFlag,
338c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul                              depth_size, stencil_size,
339c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul                              accumRedSize, accumBlueSize,
340c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul                              accumBlueSize, accumAlphaSize, 0, level,
341c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul                              GLX_NONE_EXT );
342afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (xmvis) {
343f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      /* Save a copy of the pointer now so we can find this visual again
344f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul       * if we need to search for it in find_glx_visual().
345f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul       */
346f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      xmvis->vishandle = vinfo;
34764034c4fb5c56f63d37faa6f64f3183ca106856aAlan Hourihane      /* Allocate more space for additional visual */
34864034c4fb5c56f63d37faa6f64f3183ca106856aAlan Hourihane      VisualTable = _mesa_realloc( VisualTable,
34964034c4fb5c56f63d37faa6f64f3183ca106856aAlan Hourihane                                   sizeof(XMesaVisual) * NumVisuals,
350394fd40a536faade5ccfbbb1f2920394e89ad4aaBrian Paul                                   sizeof(XMesaVisual) * (NumVisuals + 1));
351f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      /* add xmvis to the list */
352afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      VisualTable[NumVisuals] = xmvis;
353afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      NumVisuals++;
3547287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul      /* XXX minor hack, because XMesaCreateVisual doesn't support an
3557287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul       * aux buffers parameter.
3567287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul       */
357894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul      xmvis->mesa_visual.numAuxBuffers = numAuxBuffers;
358afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
359afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return xmvis;
360afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
361afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
362afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
363dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul/**
364dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul * Return the default number of bits for the Z buffer.
365dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul * If defined, use the MESA_GLX_DEPTH_BITS env var value.
366dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul * Otherwise, use the DEFAULT_SOFTWARE_DEPTH_BITS constant.
367dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul * XXX probably do the same thing for stencil, accum, etc.
368dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul */
369dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paulstatic GLint
370dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Pauldefault_depth_bits(void)
371dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul{
372dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul   int zBits;
373dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul   const char *zEnv = _mesa_getenv("MESA_GLX_DEPTH_BITS");
374dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul   if (zEnv)
375dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul      zBits = _mesa_atoi(zEnv);
376dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul   else
377dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul      zBits = DEFAULT_SOFTWARE_DEPTH_BITS;
378dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul   return zBits;
379dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul}
380dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul
381dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul
382afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
383afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
384afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Create a GLX visual from a regular XVisualInfo.
385ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * This is called when Fake GLX is given an XVisualInfo which wasn't
386ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * returned by glXChooseVisual.  Since this is the first time we're
387ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * considering this visual we'll take a guess at reasonable values
388ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * for depth buffer size, stencil size, accum size, etc.
389ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * This is the best we can do with a client-side emulation of GLX.
390afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
391afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XMesaVisual
392afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgcreate_glx_visual( Display *dpy, XVisualInfo *visinfo )
393afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
394afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int vislevel;
395dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul   GLint zBits = default_depth_bits();
396afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
397afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   vislevel = level_of_visual( dpy, visinfo );
398afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (vislevel) {
399afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* Configure this visual as a CI, single-buffered overlay */
400afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return save_glx_visual( dpy, visinfo,
401afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                              GL_FALSE,  /* rgb */
402afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                              GL_FALSE,  /* alpha */
403afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                              GL_FALSE,  /* double */
404afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                              GL_FALSE,  /* stereo */
405afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                              0,         /* depth bits */
406afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                              0,         /* stencil bits */
407b2e460018375f699198073a6167e0ee96ba1d267Brian Paul                              0,0,0,0,   /* accum bits */
408894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul                              vislevel,  /* level */
409894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul                              0          /* numAux */
410afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                            );
411afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
412afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else if (is_usable_visual( visinfo )) {
413367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul      if (_mesa_getenv("MESA_GLX_FORCE_CI")) {
4148f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul         /* Configure this visual as a COLOR INDEX visual. */
4158f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul         return save_glx_visual( dpy, visinfo,
4168f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 GL_FALSE,   /* rgb */
4178f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 GL_FALSE,  /* alpha */
4188f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 GL_TRUE,   /* double */
4198f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 GL_FALSE,  /* stereo */
420dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul                                 zBits,
421e4b2356c07d31fbeeabb13b2fb47db703b473080Brian Paul                                 STENCIL_BITS,
422e4b2356c07d31fbeeabb13b2fb47db703b473080Brian Paul                                 0, 0, 0, 0, /* accum bits */
423894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul                                 0,         /* level */
424894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul                                 0          /* numAux */
4258f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                               );
4268f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul      }
4278f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul      else {
4288f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul         /* Configure this visual as RGB, double-buffered, depth-buffered. */
4298f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul         /* This is surely wrong for some people's needs but what else */
4308f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul         /* can be done?  They should use glXChooseVisual(). */
4318f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul         return save_glx_visual( dpy, visinfo,
4328f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 GL_TRUE,   /* rgb */
4338f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 GL_FALSE,  /* alpha */
4348f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 GL_TRUE,   /* double */
4358f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                                 GL_FALSE,  /* stereo */
436dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul                                 zBits,
437e4b2356c07d31fbeeabb13b2fb47db703b473080Brian Paul                                 STENCIL_BITS,
438e4b2356c07d31fbeeabb13b2fb47db703b473080Brian Paul                                 ACCUM_BITS, /* r */
439e4b2356c07d31fbeeabb13b2fb47db703b473080Brian Paul                                 ACCUM_BITS, /* g */
440e4b2356c07d31fbeeabb13b2fb47db703b473080Brian Paul                                 ACCUM_BITS, /* b */
441e4b2356c07d31fbeeabb13b2fb47db703b473080Brian Paul                                 ACCUM_BITS, /* a */
442894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul                                 0,         /* level */
443894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul                                 0          /* numAux */
4448f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul                               );
4458f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul      }
446afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
447afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else {
448d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul      _mesa_warning(NULL, "Mesa: error in glXCreateContext: bad visual\n");
449afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return NULL;
450afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
451afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
452afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
453afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
454afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
455afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
456afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Find the GLX visual associated with an XVisualInfo.
457afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
458afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XMesaVisual
459afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgfind_glx_visual( Display *dpy, XVisualInfo *vinfo )
460afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
461afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int i;
462afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
463f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   /* try to match visual id */
464afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   for (i=0;i<NumVisuals;i++) {
465f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      if (VisualTable[i]->display==dpy
466f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul          && VisualTable[i]->visinfo->visualid == vinfo->visualid) {
467afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return VisualTable[i];
468afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
469afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
470f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul
471f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   /* if that fails, try to match pointers */
472afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   for (i=0;i<NumVisuals;i++) {
473f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      if (VisualTable[i]->display==dpy && VisualTable[i]->vishandle==vinfo) {
474afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return VisualTable[i];
475afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
476afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
477f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul
478afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return NULL;
479afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
480afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
481afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
482afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
4831d97c277e0cb2b75559d495a58222f2511212a66Brian Paul/**
484afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return the transparent pixel value for a GLX visual.
485afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input:  glxvis - the glx_visual
486afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return:  a pixel value or -1 if no transparent pixel
487afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
4887287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulstatic int
4897287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paultransparent_pixel( XMesaVisual glxvis )
490afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
491afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   Display *dpy = glxvis->display;
492afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XVisualInfo *vinfo = glxvis->visinfo;
4931d97c277e0cb2b75559d495a58222f2511212a66Brian Paul   OverlayInfo *overlay_info;
4941d97c277e0cb2b75559d495a58222f2511212a66Brian Paul   int numOverlaysPerScreen, i;
495afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
4961d97c277e0cb2b75559d495a58222f2511212a66Brian Paul   overlay_info = GetOverlayInfo(dpy, vinfo->screen, &numOverlaysPerScreen);
4971d97c277e0cb2b75559d495a58222f2511212a66Brian Paul   if (!overlay_info) {
498afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return -1;
499afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
500afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
5011d97c277e0cb2b75559d495a58222f2511212a66Brian Paul   for (i = 0; i < numOverlaysPerScreen; i++) {
5021d97c277e0cb2b75559d495a58222f2511212a66Brian Paul      const OverlayInfo *ov = overlay_info + i;
5031d97c277e0cb2b75559d495a58222f2511212a66Brian Paul      if (ov->overlay_visual == vinfo->visualid) {
504afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* found it! */
5051d97c277e0cb2b75559d495a58222f2511212a66Brian Paul         if (ov->transparent_type == 0) {
506afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* type 0 indicates no transparency */
507afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            XFree((void *) overlay_info);
508afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            return -1;
509afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
510afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         else {
511afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* ov->value is the transparent pixel */
512afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            XFree((void *) overlay_info);
513afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            return ov->value;
514afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
515afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
516afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
517afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
518afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* The visual ID was not found in the overlay list. */
519afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XFree((void *) overlay_info);
520afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return -1;
521afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
522afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
523afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
524afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
5251d97c277e0cb2b75559d495a58222f2511212a66Brian Paul/**
526afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Try to get an X visual which matches the given arguments.
527afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
5287287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulstatic XVisualInfo *
5297287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulget_visual( Display *dpy, int scr, unsigned int depth, int xclass )
530afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
531afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XVisualInfo temp, *vis;
532afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   long mask;
533afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int n;
534afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   unsigned int default_depth;
535afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int default_class;
536afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
537afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   mask = VisualScreenMask | VisualDepthMask | VisualClassMask;
538afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   temp.screen = scr;
539afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   temp.depth = depth;
540afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   temp.CLASS = xclass;
541afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
542afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   default_depth = DefaultDepth(dpy,scr);
543afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   default_class = DefaultVisual(dpy,scr)->CLASS;
544afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
545afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (depth==default_depth && xclass==default_class) {
546afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* try to get root window's visual */
547afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      temp.visualid = DefaultVisual(dpy,scr)->visualid;
548afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      mask |= VisualIDMask;
549afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
550afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
551afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   vis = XGetVisualInfo( dpy, mask, &temp, &n );
552afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
553afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* In case bits/pixel > 24, make sure color channels are still <=8 bits.
554afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * An SGI Infinite Reality system, for example, can have 30bpp pixels:
555afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * 10 bits per color channel.  Mesa's limited to a max of 8 bits/channel.
556afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    */
557afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (vis && depth > 24 && (xclass==TrueColor || xclass==DirectColor)) {
55871dea349d2be623b7819389428b0d6a124e8d184Brian Paul      if (_mesa_bitcount((GLuint) vis->red_mask  ) <= 8 &&
55971dea349d2be623b7819389428b0d6a124e8d184Brian Paul          _mesa_bitcount((GLuint) vis->green_mask) <= 8 &&
56071dea349d2be623b7819389428b0d6a124e8d184Brian Paul          _mesa_bitcount((GLuint) vis->blue_mask ) <= 8) {
561afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return vis;
562afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
563afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      else {
564afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         XFree((void *) vis);
565afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return NULL;
566afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
567afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
568afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
569afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return vis;
570afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
571afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
572afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
573afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
574afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
575afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Retrieve the value of the given environment variable and find
576afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * the X visual which matches it.
577afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input:  dpy - the display
578afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         screen - the screen number
579afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         varname - the name of the environment variable
580afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return:  an XVisualInfo pointer to NULL if error.
581afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
5827287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulstatic XVisualInfo *
5837287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulget_env_visual(Display *dpy, int scr, const char *varname)
584afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
585afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   char value[100], type[100];
586afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int depth, xclass = -1;
587afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XVisualInfo *vis;
588afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
589367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul   if (!_mesa_getenv( varname )) {
590afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return NULL;
591afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
592afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
593367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul   _mesa_strncpy( value, _mesa_getenv(varname), 100 );
594afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   value[99] = 0;
595afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
596afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   sscanf( value, "%s %d", type, &depth );
597afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
598367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul   if (_mesa_strcmp(type,"TrueColor")==0)          xclass = TrueColor;
599367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul   else if (_mesa_strcmp(type,"DirectColor")==0)   xclass = DirectColor;
600367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul   else if (_mesa_strcmp(type,"PseudoColor")==0)   xclass = PseudoColor;
601367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul   else if (_mesa_strcmp(type,"StaticColor")==0)   xclass = StaticColor;
602367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul   else if (_mesa_strcmp(type,"GrayScale")==0)     xclass = GrayScale;
603367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul   else if (_mesa_strcmp(type,"StaticGray")==0)    xclass = StaticGray;
604afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
605afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (xclass>-1 && depth>0) {
606afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      vis = get_visual( dpy, scr, depth, xclass );
607afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (vis) {
608afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return vis;
609afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
610afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
611afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
6122ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul   _mesa_warning(NULL, "GLX unable to find visual class=%s, depth=%d.",
6132ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul                 type, depth);
614d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul
615afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return NULL;
616afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
617afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
618afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
619afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
620afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
621afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Select an X visual which satisfies the RGBA/CI flag and minimum depth.
622afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input:  dpy, screen - X display and screen number
623afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         rgba - GL_TRUE = RGBA mode, GL_FALSE = CI mode
624afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         min_depth - minimum visual depth
625afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         preferred_class - preferred GLX visual class or DONT_CARE
626afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return:  pointer to an XVisualInfo or NULL.
627afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
6287287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulstatic XVisualInfo *
6297287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulchoose_x_visual( Display *dpy, int screen, GLboolean rgba, int min_depth,
6307287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul                 int preferred_class )
631afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
632afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XVisualInfo *vis;
633db6aa58267cad3f502f03ab80b9deb6b75320a91Brian Paul   int xclass, visclass = 0;
634afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int depth;
635afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
636afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (rgba) {
637afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      Atom hp_cr_maps = XInternAtom(dpy, "_HP_RGB_SMOOTH_MAP_LIST", True);
638afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* First see if the MESA_RGB_VISUAL env var is defined */
639afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      vis = get_env_visual( dpy, screen, "MESA_RGB_VISUAL" );
640afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (vis) {
641afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return vis;
642afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
643afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* Otherwise, search for a suitable visual */
644afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (preferred_class==DONT_CARE) {
645afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         for (xclass=0;xclass<6;xclass++) {
646afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            switch (xclass) {
647afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 0:  visclass = TrueColor;    break;
648afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 1:  visclass = DirectColor;  break;
649afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 2:  visclass = PseudoColor;  break;
650afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 3:  visclass = StaticColor;  break;
651afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 4:  visclass = GrayScale;    break;
652afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 5:  visclass = StaticGray;   break;
653afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
654afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            if (min_depth==0) {
655afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               /* start with shallowest */
656afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               for (depth=0;depth<=32;depth++) {
657afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  if (visclass==TrueColor && depth==8 && !hp_cr_maps) {
658afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     /* Special case:  try to get 8-bit PseudoColor before */
659afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     /* 8-bit TrueColor */
660afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     vis = get_visual( dpy, screen, 8, PseudoColor );
661afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     if (vis) {
662afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                        return vis;
663afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     }
664afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  }
665afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  vis = get_visual( dpy, screen, depth, visclass );
666afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  if (vis) {
667afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     return vis;
668afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  }
669afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               }
670afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
671afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            else {
672afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               /* start with deepest */
673afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               for (depth=32;depth>=min_depth;depth--) {
674afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  if (visclass==TrueColor && depth==8 && !hp_cr_maps) {
675afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     /* Special case:  try to get 8-bit PseudoColor before */
676afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     /* 8-bit TrueColor */
677afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     vis = get_visual( dpy, screen, 8, PseudoColor );
678afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     if (vis) {
679afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                        return vis;
680afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     }
681afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  }
682afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  vis = get_visual( dpy, screen, depth, visclass );
683afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  if (vis) {
684afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                     return vis;
685afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  }
686afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               }
687afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
688afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
689afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
690afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      else {
691afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* search for a specific visual class */
692afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         switch (preferred_class) {
693afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_TRUE_COLOR_EXT:    visclass = TrueColor;    break;
694afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_DIRECT_COLOR_EXT:  visclass = DirectColor;  break;
695afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_PSEUDO_COLOR_EXT:  visclass = PseudoColor;  break;
696afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_STATIC_COLOR_EXT:  visclass = StaticColor;  break;
697afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_GRAY_SCALE_EXT:    visclass = GrayScale;    break;
698afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_STATIC_GRAY_EXT:   visclass = StaticGray;   break;
699afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            default:   return NULL;
700afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
701afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         if (min_depth==0) {
702afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* start with shallowest */
703afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            for (depth=0;depth<=32;depth++) {
704afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               vis = get_visual( dpy, screen, depth, visclass );
705afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               if (vis) {
706afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  return vis;
707afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               }
708afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
709afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
710afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         else {
711afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* start with deepest */
712afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            for (depth=32;depth>=min_depth;depth--) {
713afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               vis = get_visual( dpy, screen, depth, visclass );
714afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               if (vis) {
715afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  return vis;
716afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               }
717afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
718afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
719afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
720afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
721afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else {
722afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* First see if the MESA_CI_VISUAL env var is defined */
723afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      vis = get_env_visual( dpy, screen, "MESA_CI_VISUAL" );
724afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (vis) {
725afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return vis;
726afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
727afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* Otherwise, search for a suitable visual, starting with shallowest */
728afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (preferred_class==DONT_CARE) {
729afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         for (xclass=0;xclass<4;xclass++) {
730afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            switch (xclass) {
731afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 0:  visclass = PseudoColor;  break;
732afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 1:  visclass = StaticColor;  break;
733afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 2:  visclass = GrayScale;    break;
734afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               case 3:  visclass = StaticGray;   break;
735afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
736afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* try 8-bit up through 16-bit */
737afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            for (depth=8;depth<=16;depth++) {
738afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               vis = get_visual( dpy, screen, depth, visclass );
739afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               if (vis) {
740afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  return vis;
741afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               }
742afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
743afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* try min_depth up to 8-bit */
744afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            for (depth=min_depth;depth<8;depth++) {
745afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               vis = get_visual( dpy, screen, depth, visclass );
746afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               if (vis) {
747afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                  return vis;
748afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               }
749afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
750afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
751afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
752afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      else {
753afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* search for a specific visual class */
754afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         switch (preferred_class) {
755afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_TRUE_COLOR_EXT:    visclass = TrueColor;    break;
756afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_DIRECT_COLOR_EXT:  visclass = DirectColor;  break;
757afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_PSEUDO_COLOR_EXT:  visclass = PseudoColor;  break;
758afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_STATIC_COLOR_EXT:  visclass = StaticColor;  break;
759afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_GRAY_SCALE_EXT:    visclass = GrayScale;    break;
760afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GLX_STATIC_GRAY_EXT:   visclass = StaticGray;   break;
761afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            default:   return NULL;
762afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
763afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* try 8-bit up through 16-bit */
764afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         for (depth=8;depth<=16;depth++) {
765afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            vis = get_visual( dpy, screen, depth, visclass );
766afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            if (vis) {
767afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               return vis;
768afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
769afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
770afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* try min_depth up to 8-bit */
771afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         for (depth=min_depth;depth<8;depth++) {
772afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            vis = get_visual( dpy, screen, depth, visclass );
773afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            if (vis) {
774afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               return vis;
775afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
776afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
777afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
778afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
779afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
780afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* didn't find a visual */
781afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return NULL;
782afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
783afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
784afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
785afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
786afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
787afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Find the deepest X over/underlay visual of at least min_depth.
788afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input:  dpy, screen - X display and screen number
789afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         level - the over/underlay level
790afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         trans_type - transparent pixel type: GLX_NONE_EXT,
791afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *                      GLX_TRANSPARENT_RGB_EXT, GLX_TRANSPARENT_INDEX_EXT,
792afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *                      or DONT_CARE
793afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         trans_value - transparent pixel value or DONT_CARE
794afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         min_depth - minimum visual depth
795afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *         preferred_class - preferred GLX visual class or DONT_CARE
796afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return:  pointer to an XVisualInfo or NULL.
797afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
7987287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulstatic XVisualInfo *
7997287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulchoose_x_overlay_visual( Display *dpy, int scr, GLboolean rgbFlag,
8007287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul                         int level, int trans_type, int trans_value,
8017287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul                         int min_depth, int preferred_class )
802afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
803afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   OverlayInfo *overlay_info;
804afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int numOverlaysPerScreen;
805afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int i;
806afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XVisualInfo *deepvis;
807afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int deepest;
808afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
809afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /*DEBUG int tt, tv; */
810afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
811afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   switch (preferred_class) {
812afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_TRUE_COLOR_EXT:    preferred_class = TrueColor;    break;
813afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_DIRECT_COLOR_EXT:  preferred_class = DirectColor;  break;
814afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_PSEUDO_COLOR_EXT:  preferred_class = PseudoColor;  break;
815afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_STATIC_COLOR_EXT:  preferred_class = StaticColor;  break;
816afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_GRAY_SCALE_EXT:    preferred_class = GrayScale;    break;
817afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_STATIC_GRAY_EXT:   preferred_class = StaticGray;   break;
818afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      default:                    preferred_class = DONT_CARE;
819afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
820afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
8211d97c277e0cb2b75559d495a58222f2511212a66Brian Paul   overlay_info = GetOverlayInfo(dpy, scr, &numOverlaysPerScreen);
8221d97c277e0cb2b75559d495a58222f2511212a66Brian Paul   if (!overlay_info) {
823afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return NULL;
824afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
825afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
826afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* Search for the deepest overlay which satisifies all criteria. */
827afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   deepest = min_depth;
828afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   deepvis = NULL;
829afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
8301d97c277e0cb2b75559d495a58222f2511212a66Brian Paul   for (i = 0; i < numOverlaysPerScreen; i++) {
8311d97c277e0cb2b75559d495a58222f2511212a66Brian Paul      const OverlayInfo *ov = overlay_info + i;
832afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      XVisualInfo *vislist, vistemplate;
833afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      int count;
834afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
835afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (ov->layer!=level) {
836afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* failed overlay level criteria */
837afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         continue;
838afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
839afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (!(trans_type==DONT_CARE
840afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            || (trans_type==GLX_TRANSPARENT_INDEX_EXT
841afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                && ov->transparent_type>0)
842afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            || (trans_type==GLX_NONE_EXT && ov->transparent_type==0))) {
843afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* failed transparent pixel type criteria */
844afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         continue;
845afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
846afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (trans_value!=DONT_CARE && trans_value!=ov->value) {
847afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* failed transparent pixel value criteria */
848afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         continue;
849afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
850afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
851afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* get XVisualInfo and check the depth */
852afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      vistemplate.visualid = ov->overlay_visual;
853afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      vistemplate.screen = scr;
854afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      vislist = XGetVisualInfo( dpy, VisualIDMask | VisualScreenMask,
855afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg                                &vistemplate, &count );
856afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
857afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (count!=1) {
858afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* something went wrong */
859afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         continue;
860afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
861afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (preferred_class!=DONT_CARE && preferred_class!=vislist->CLASS) {
862afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* wrong visual class */
863afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         continue;
864afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
865afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
86642f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      /* if RGB was requested, make sure we have True/DirectColor */
86742f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      if (rgbFlag && vislist->CLASS != TrueColor
86842f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul          && vislist->CLASS != DirectColor)
86942f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         continue;
87042f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul
87142f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      /* if CI was requested, make sure we have a color indexed visual */
87242f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      if (!rgbFlag
87342f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul          && (vislist->CLASS == TrueColor || vislist->CLASS == DirectColor))
87442f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         continue;
87542f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul
876afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (deepvis==NULL || vislist->depth > deepest) {
877afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* YES!  found a satisfactory visual */
878afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         if (deepvis) {
87980af3614d88c0cac160e787de7f34b37e96cb626Brian Paul            XFree( deepvis );
880afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
881afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         deepest = vislist->depth;
882afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         deepvis = vislist;
883afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* DEBUG  tt = ov->transparent_type;*/
884afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* DEBUG  tv = ov->value; */
885afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
886afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
887afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
888afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*DEBUG
889afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (deepvis) {
890afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      printf("chose 0x%x:  layer=%d depth=%d trans_type=%d trans_value=%d\n",
891afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg             deepvis->visualid, level, deepvis->depth, tt, tv );
892afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
893afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg*/
894afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return deepvis;
895afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
896afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
897afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
8987cf50e137da497a590ec9001a9918972a6246142Brian Paul/**********************************************************************/
8997cf50e137da497a590ec9001a9918972a6246142Brian Paul/***                  Begin Fake GLX API Functions                  ***/
9007cf50e137da497a590ec9001a9918972a6246142Brian Paul/**********************************************************************/
9017cf50e137da497a590ec9001a9918972a6246142Brian Paul
902afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
903ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul/**
904ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul * Helper used by glXChooseVisual and glXChooseFBConfig.
905ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul * The fbConfig parameter must be GL_FALSE for the former and GL_TRUE for
906ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul * the later.
907ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul * In either case, the attribute list is terminated with the value 'None'.
908ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul */
9097287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulstatic XMesaVisual
9101f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paulchoose_visual( Display *dpy, int screen, const int *list, GLboolean fbConfig )
911afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
9121f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul   const GLboolean rgbModeDefault = fbConfig;
9133265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   const int *parselist;
914afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XVisualInfo *vis;
915afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int min_ci = 0;
916afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int min_red=0, min_green=0, min_blue=0;
917b3063ac398b72e6a4fd2015d4e220495b9779294Brian Paul   GLboolean rgb_flag = rgbModeDefault;
918afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLboolean alpha_flag = GL_FALSE;
919afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLboolean double_flag = GL_FALSE;
920afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLboolean stereo_flag = GL_FALSE;
921afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLint depth_size = 0;
922afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLint stencil_size = 0;
923b2e460018375f699198073a6167e0ee96ba1d267Brian Paul   GLint accumRedSize = 0;
924b2e460018375f699198073a6167e0ee96ba1d267Brian Paul   GLint accumGreenSize = 0;
925b2e460018375f699198073a6167e0ee96ba1d267Brian Paul   GLint accumBlueSize = 0;
926b2e460018375f699198073a6167e0ee96ba1d267Brian Paul   GLint accumAlphaSize = 0;
927afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int level = 0;
928afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int visual_type = DONT_CARE;
929afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int trans_type = DONT_CARE;
930afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   int trans_value = DONT_CARE;
931e1210b176926349b258c7ec77b7f36716025c82aBrian Paul   GLint caveat = DONT_CARE;
9323265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   XMesaVisual xmvis = NULL;
9333a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul   int desiredVisualID = -1;
934894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul   int numAux = 0;
935afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
936afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   parselist = list;
937afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
938afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   while (*parselist) {
939afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
940afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      switch (*parselist) {
941afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_USE_GL:
9421f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul            if (fbConfig) {
9431f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul               /* invalid token */
9441f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul               return NULL;
9451f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul            }
9461f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul            else {
9471f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul               /* skip */
9481f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul               parselist++;
9491f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul            }
950afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
951afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_BUFFER_SIZE:
952afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
953afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    min_ci = *parselist++;
954afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
955afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_LEVEL:
956afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
957afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            level = *parselist++;
958afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
959afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_RGBA:
9601f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul            if (fbConfig) {
9611f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul               /* invalid token */
9621f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul               return NULL;
9631f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul            }
9641f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul            else {
9651f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul               rgb_flag = GL_TRUE;
9661f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul               parselist++;
9671f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul            }
968afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
969afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_DOUBLEBUFFER:
9701f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul            parselist++;
9711f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul            if (fbConfig) {
9721f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul               double_flag = *parselist++;
9731f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul            }
9741f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul            else {
9751f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul               double_flag = GL_TRUE;
9761f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul            }
977afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
978afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_STEREO:
9791f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul            parselist++;
9801f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul            if (fbConfig) {
9811f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul               stereo_flag = *parselist++;
9821f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul            }
9831f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul            else {
9841f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul               stereo_flag = GL_TRUE;
9851f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul            }
9861f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul            return NULL; /* stereo not supported */
987afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_AUX_BUFFERS:
988afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
989894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul            numAux = *parselist++;
990894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul            if (numAux > MAX_AUX_BUFFERS)
991894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul               return NULL;
992afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
993afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_RED_SIZE:
994afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
995afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    min_red = *parselist++;
996afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
997afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_GREEN_SIZE:
998afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
999afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    min_green = *parselist++;
1000afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
1001afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_BLUE_SIZE:
1002afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
1003afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    min_blue = *parselist++;
1004afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
1005afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_ALPHA_SIZE:
1006afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
1007afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            {
1008afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               GLint size = *parselist++;
1009afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               alpha_flag = size>0 ? 1 : 0;
1010afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
1011afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
1012afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_DEPTH_SIZE:
1013afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
1014afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    depth_size = *parselist++;
1015afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
1016afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_STENCIL_SIZE:
1017afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
1018afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    stencil_size = *parselist++;
1019afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
1020afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_ACCUM_RED_SIZE:
1021b2e460018375f699198073a6167e0ee96ba1d267Brian Paul	    parselist++;
1022b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            {
1023b2e460018375f699198073a6167e0ee96ba1d267Brian Paul               GLint size = *parselist++;
1024b2e460018375f699198073a6167e0ee96ba1d267Brian Paul               accumRedSize = MAX2( accumRedSize, size );
1025b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            }
1026b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            break;
1027afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_ACCUM_GREEN_SIZE:
1028b2e460018375f699198073a6167e0ee96ba1d267Brian Paul	    parselist++;
1029b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            {
1030b2e460018375f699198073a6167e0ee96ba1d267Brian Paul               GLint size = *parselist++;
1031b2e460018375f699198073a6167e0ee96ba1d267Brian Paul               accumGreenSize = MAX2( accumGreenSize, size );
1032b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            }
1033b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            break;
1034afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_ACCUM_BLUE_SIZE:
1035b2e460018375f699198073a6167e0ee96ba1d267Brian Paul	    parselist++;
1036b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            {
1037b2e460018375f699198073a6167e0ee96ba1d267Brian Paul               GLint size = *parselist++;
1038b2e460018375f699198073a6167e0ee96ba1d267Brian Paul               accumBlueSize = MAX2( accumBlueSize, size );
1039b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            }
1040b2e460018375f699198073a6167e0ee96ba1d267Brian Paul            break;
1041afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case GLX_ACCUM_ALPHA_SIZE:
1042afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
1043afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            {
1044afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               GLint size = *parselist++;
1045b2e460018375f699198073a6167e0ee96ba1d267Brian Paul               accumAlphaSize = MAX2( accumAlphaSize, size );
1046afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
1047afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
1048afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1049afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /*
1050afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg          * GLX_EXT_visual_info extension
1051afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg          */
1052afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         case GLX_X_VISUAL_TYPE_EXT:
1053afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            parselist++;
1054afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            visual_type = *parselist++;
1055afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            break;
1056afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         case GLX_TRANSPARENT_TYPE_EXT:
1057afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            parselist++;
1058afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            trans_type = *parselist++;
1059afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            break;
1060afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         case GLX_TRANSPARENT_INDEX_VALUE_EXT:
1061afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            parselist++;
1062afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            trans_value = *parselist++;
1063afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            break;
1064afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         case GLX_TRANSPARENT_RED_VALUE_EXT:
1065afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         case GLX_TRANSPARENT_GREEN_VALUE_EXT:
1066afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         case GLX_TRANSPARENT_BLUE_VALUE_EXT:
1067afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         case GLX_TRANSPARENT_ALPHA_VALUE_EXT:
1068afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    /* ignore */
1069afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
1070afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    parselist++;
1071afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
10725e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen
1073e1210b176926349b258c7ec77b7f36716025c82aBrian Paul         /*
1074e1210b176926349b258c7ec77b7f36716025c82aBrian Paul          * GLX_EXT_visual_info extension
1075e1210b176926349b258c7ec77b7f36716025c82aBrian Paul          */
1076e1210b176926349b258c7ec77b7f36716025c82aBrian Paul         case GLX_VISUAL_CAVEAT_EXT:
1077e1210b176926349b258c7ec77b7f36716025c82aBrian Paul            parselist++;
1078e1210b176926349b258c7ec77b7f36716025c82aBrian Paul            caveat = *parselist++; /* ignored for now */
1079e1210b176926349b258c7ec77b7f36716025c82aBrian Paul            break;
1080e1210b176926349b258c7ec77b7f36716025c82aBrian Paul
10813265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         /*
108266ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul          * GLX_ARB_multisample
108366ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul          */
108466ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul         case GLX_SAMPLE_BUFFERS_ARB:
108566ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul            /* ms not supported */
108666ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul            return NULL;
108766ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul         case GLX_SAMPLES_ARB:
108866ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul            /* ms not supported */
108966ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul            return NULL;
109066ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul
109166ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul         /*
10923265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul          * FBConfig attribs.
10933265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul          */
10943265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         case GLX_RENDER_TYPE:
10953265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            parselist++;
10963265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            if (*parselist == GLX_RGBA_BIT) {
10973265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul               rgb_flag = GL_TRUE;
10983265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            }
10993265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            else if (*parselist == GLX_COLOR_INDEX_BIT) {
11003265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul               rgb_flag = GL_FALSE;
11013265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            }
11023265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            else if (*parselist == 0) {
11033265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul               rgb_flag = GL_TRUE;
11043265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            }
11053265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            parselist++;
11063265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            break;
11073265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         case GLX_DRAWABLE_TYPE:
11083265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            parselist++;
11093265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            if (*parselist & ~(GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT)) {
11103265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul               return NULL; /* bad bit */
11113265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            }
11123265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            parselist++;
11133265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            break;
11143a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul         case GLX_FBCONFIG_ID:
11153a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul            parselist++;
11163a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul            desiredVisualID = *parselist;
11173a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul            break;
11183265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul
1119afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case None:
11203a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul            /* end of list */
1121afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
11223265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul
1123afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 default:
1124afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    /* undefined attribute */
11252ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul            _mesa_warning(NULL, "unexpected attrib 0x%x in choose_visual()",
11262ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul                          *parselist);
1127afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    return NULL;
1128afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
1129afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1130afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1131b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul   (void) caveat;
1132b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul
1133afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /*
1134afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * Since we're only simulating the GLX extension this function will never
1135afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * find any real GL visuals.  Instead, all we can do is try to find an RGB
1136afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * or CI visual of appropriate depth.  Other requested attributes such as
1137afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * double buffering, depth buffer, etc. will be associated with the X
1138afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * visual and stored in the VisualTable[].
1139afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    */
11403a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul   if (desiredVisualID != -1) {
11413a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul      /* try to get a specific visual, by visualID */
11423a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul      XVisualInfo temp;
11433a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul      int n;
11443a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul      temp.visualid = desiredVisualID;
11453a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul      temp.screen = screen;
11463a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul      vis = XGetVisualInfo(dpy, VisualIDMask | VisualScreenMask, &temp, &n);
11473a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul      if (vis) {
11483a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul         /* give the visual some useful GLX attributes */
11493a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul         double_flag = GL_TRUE;
11503a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul         if (vis->depth > 8)
11513a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul            rgb_flag = GL_TRUE;
1152dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul         depth_size = default_depth_bits();
11533a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul         stencil_size = STENCIL_BITS;
11543a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul         /* XXX accum??? */
11553a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul      }
11563a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul   }
11573a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul   else if (level==0) {
1158afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* normal color planes */
1159afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (rgb_flag) {
1160afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* Get an RGB visual */
1161afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         int min_rgb = min_red + min_green + min_blue;
1162afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         if (min_rgb>1 && min_rgb<8) {
1163afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* a special case to be sure we can get a monochrome visual */
1164afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            min_rgb = 1;
1165afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
1166afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         vis = choose_x_visual( dpy, screen, rgb_flag, min_rgb, visual_type );
1167afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
1168afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      else {
1169afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* Get a color index visual */
1170afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         vis = choose_x_visual( dpy, screen, rgb_flag, min_ci, visual_type );
1171b2e460018375f699198073a6167e0ee96ba1d267Brian Paul         accumRedSize = accumGreenSize = accumBlueSize = accumAlphaSize = 0;
1172afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
1173afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1174afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else {
1175afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* over/underlay planes */
117642f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      if (rgb_flag) {
117742f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         /* rgba overlay */
117842f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         int min_rgb = min_red + min_green + min_blue;
117942f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         if (min_rgb>1 && min_rgb<8) {
118042f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul            /* a special case to be sure we can get a monochrome visual */
118142f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul            min_rgb = 1;
118242f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         }
118342f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         vis = choose_x_overlay_visual( dpy, screen, rgb_flag, level,
118442f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul                              trans_type, trans_value, min_rgb, visual_type );
118542f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      }
118642f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      else {
118742f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         /* color index overlay */
118842f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         vis = choose_x_overlay_visual( dpy, screen, rgb_flag, level,
118942f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul                              trans_type, trans_value, min_ci, visual_type );
119042f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      }
1191afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1192afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1193afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (vis) {
1194ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul      /* Note: we're not exactly obeying the glXChooseVisual rules here.
1195ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul       * When GLX_DEPTH_SIZE = 1 is specified we're supposed to choose the
11962c7e6334ec81c2fab2cce9e0fe52cd30256e37eaBrian Paul       * largest depth buffer size, which is 32bits/value.  Instead, we
1197ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul       * return 16 to maintain performance with earlier versions of Mesa.
1198ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul       */
11992c7e6334ec81c2fab2cce9e0fe52cd30256e37eaBrian Paul      if (depth_size > 24)
12002c7e6334ec81c2fab2cce9e0fe52cd30256e37eaBrian Paul         depth_size = 31;   /* 32 causes int overflow problems */
1201ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul      else if (depth_size > 16)
1202ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul         depth_size = 24;
1203dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul      else if (depth_size > 0) {
1204dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul         depth_size = default_depth_bits();
1205dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul      }
12062c7e6334ec81c2fab2cce9e0fe52cd30256e37eaBrian Paul
1207ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul      /* we only support one size of stencil and accum buffers. */
1208ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul      if (stencil_size > 0)
1209ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul         stencil_size = STENCIL_BITS;
12106d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul      if (accumRedSize > 0 || accumGreenSize > 0 || accumBlueSize > 0 ||
12116d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul          accumAlphaSize > 0) {
1212b2e460018375f699198073a6167e0ee96ba1d267Brian Paul         accumRedSize = ACCUM_BITS;
1213b2e460018375f699198073a6167e0ee96ba1d267Brian Paul         accumGreenSize = ACCUM_BITS;
1214b2e460018375f699198073a6167e0ee96ba1d267Brian Paul         accumBlueSize = ACCUM_BITS;
12156d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul         accumAlphaSize = alpha_flag ? ACCUM_BITS : 0;
12166d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul      }
12176d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul
12183265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      xmvis = save_glx_visual( dpy, vis, rgb_flag, alpha_flag, double_flag,
12193265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul                               stereo_flag, depth_size, stencil_size,
12203265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul                               accumRedSize, accumGreenSize,
1221894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul                               accumBlueSize, accumAlphaSize, level, numAux );
1222afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1223afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
12243265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   return xmvis;
1225afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1226afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1227afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
12283265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paulstatic XVisualInfo *
12293265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian PaulFake_glXChooseVisual( Display *dpy, int screen, int *list )
12303265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul{
1231b3063ac398b72e6a4fd2015d4e220495b9779294Brian Paul   XMesaVisual xmvis = choose_visual(dpy, screen, list, GL_FALSE);
1232f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   if (xmvis) {
1233f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul#if 0
1234f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      return xmvis->vishandle;
1235f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul#else
1236f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      /* create a new vishandle - the cached one may be stale */
12374039cb8ca82d59451a6de8902fe35e693cdca3baBrian Paul      xmvis->vishandle = (XVisualInfo *) _mesa_malloc(sizeof(XVisualInfo));
1238f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      if (xmvis->vishandle) {
1239f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul         _mesa_memcpy(xmvis->vishandle, xmvis->visinfo, sizeof(XVisualInfo));
1240f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      }
12413265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      return xmvis->vishandle;
1242f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul#endif
1243f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   }
12443265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   else
12453265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      return NULL;
12463265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul}
1247afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1248afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1249426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXContext
1250426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateContext( Display *dpy, XVisualInfo *visinfo,
1251426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                       GLXContext share_list, Bool direct )
1252afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1253e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaVisual xmvis;
12547cf50e137da497a590ec9001a9918972a6246142Brian Paul   struct fake_glx_context *glxCtx;
12555e1680ce1d8296b2182e8909856927bbeddf3b95Brian Paul   struct fake_glx_context *shareCtx = (struct fake_glx_context *) share_list;
125699aab341998e84d9fa208c525cae8021b3845812Brian Paul
125799aab341998e84d9fa208c525cae8021b3845812Brian Paul   if (!dpy || !visinfo)
125899aab341998e84d9fa208c525cae8021b3845812Brian Paul      return 0;
125999aab341998e84d9fa208c525cae8021b3845812Brian Paul
12607cf50e137da497a590ec9001a9918972a6246142Brian Paul   glxCtx = CALLOC_STRUCT(fake_glx_context);
12617cf50e137da497a590ec9001a9918972a6246142Brian Paul   if (!glxCtx)
12627cf50e137da497a590ec9001a9918972a6246142Brian Paul      return 0;
1263afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1264afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* deallocate unused windows/buffers */
1265afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaGarbageCollect();
1266afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1267e4656003caee346d9c4eb23256d73409271291a7Brian Paul   xmvis = find_glx_visual( dpy, visinfo );
1268e4656003caee346d9c4eb23256d73409271291a7Brian Paul   if (!xmvis) {
1269afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* This visual wasn't found with glXChooseVisual() */
1270e4656003caee346d9c4eb23256d73409271291a7Brian Paul      xmvis = create_glx_visual( dpy, visinfo );
1271e4656003caee346d9c4eb23256d73409271291a7Brian Paul      if (!xmvis) {
1272afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* unusable visual */
12737cf50e137da497a590ec9001a9918972a6246142Brian Paul         FREE(glxCtx);
1274afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return NULL;
1275afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
1276afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1277afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1278e4656003caee346d9c4eb23256d73409271291a7Brian Paul   glxCtx->xmesaContext = XMesaCreateContext(xmvis,
12795e1680ce1d8296b2182e8909856927bbeddf3b95Brian Paul                                   shareCtx ? shareCtx->xmesaContext : NULL);
12807cf50e137da497a590ec9001a9918972a6246142Brian Paul   if (!glxCtx->xmesaContext) {
12817cf50e137da497a590ec9001a9918972a6246142Brian Paul      FREE(glxCtx);
12827cf50e137da497a590ec9001a9918972a6246142Brian Paul      return NULL;
1283afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
12847cf50e137da497a590ec9001a9918972a6246142Brian Paul
12857cf50e137da497a590ec9001a9918972a6246142Brian Paul   glxCtx->xmesaContext->direct = GL_FALSE;
12867cf50e137da497a590ec9001a9918972a6246142Brian Paul   glxCtx->glxContext.isDirect = GL_FALSE;
12877cf50e137da497a590ec9001a9918972a6246142Brian Paul   glxCtx->glxContext.currentDpy = dpy;
12887cf50e137da497a590ec9001a9918972a6246142Brian Paul   glxCtx->glxContext.xid = (XID) glxCtx;  /* self pointer */
12897cf50e137da497a590ec9001a9918972a6246142Brian Paul
12907cf50e137da497a590ec9001a9918972a6246142Brian Paul   assert((void *) glxCtx == (void *) &(glxCtx->glxContext));
12917cf50e137da497a590ec9001a9918972a6246142Brian Paul
12927cf50e137da497a590ec9001a9918972a6246142Brian Paul   return (GLXContext) glxCtx;
1293afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1294afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1295afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
12967cf50e137da497a590ec9001a9918972a6246142Brian Paul/* XXX these may have to be removed due to thread-safety issues. */
1297afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic GLXContext MakeCurrent_PrevContext = 0;
1298086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic GLXDrawable MakeCurrent_PrevDrawable = 0;
1299086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic GLXDrawable MakeCurrent_PrevReadable = 0;
1300086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic XMesaBuffer MakeCurrent_PrevDrawBuffer = 0;
1301086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic XMesaBuffer MakeCurrent_PrevReadBuffer = 0;
1302afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
13037cf50e137da497a590ec9001a9918972a6246142Brian Paul
1304086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul/* GLX 1.3 and later */
1305426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool
1306426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXMakeContextCurrent( Display *dpy, GLXDrawable draw,
13077a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell                            GLXDrawable read, GLXContext ctx )
1308086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul{
13097cf50e137da497a590ec9001a9918972a6246142Brian Paul   struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx;
13107cf50e137da497a590ec9001a9918972a6246142Brian Paul
13117a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell   if (ctx && draw && read) {
1312086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      XMesaBuffer drawBuffer, readBuffer;
13137cf50e137da497a590ec9001a9918972a6246142Brian Paul      XMesaContext xmctx = glxCtx->xmesaContext;
1314086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul
1315086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      /* Find the XMesaBuffer which corresponds to the GLXDrawable 'draw' */
13167a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell      if (ctx == MakeCurrent_PrevContext
13177a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell          && draw == MakeCurrent_PrevDrawable) {
1318086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         drawBuffer = MakeCurrent_PrevDrawBuffer;
1319086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      }
1320086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      else {
1321086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         drawBuffer = XMesaFindBuffer( dpy, draw );
1322086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      }
1323086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      if (!drawBuffer) {
1324086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         /* drawable must be a new window! */
13257cf50e137da497a590ec9001a9918972a6246142Brian Paul         drawBuffer = XMesaCreateWindowBuffer2( xmctx->xm_visual, draw, xmctx);
1326086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         if (!drawBuffer) {
1327086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul            /* Out of memory, or context/drawable depth mismatch */
1328086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul            return False;
1329086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         }
1330086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      }
1331086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul
1332086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      /* Find the XMesaBuffer which corresponds to the GLXDrawable 'read' */
13337a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell      if (ctx == MakeCurrent_PrevContext
1334086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul          && read == MakeCurrent_PrevReadable) {
1335086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         readBuffer = MakeCurrent_PrevReadBuffer;
1336086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      }
1337086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      else {
1338086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         readBuffer = XMesaFindBuffer( dpy, read );
1339086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      }
1340086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      if (!readBuffer) {
1341086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         /* drawable must be a new window! */
13427cf50e137da497a590ec9001a9918972a6246142Brian Paul         readBuffer = XMesaCreateWindowBuffer2(glxCtx->xmesaContext->xm_visual,
13437cf50e137da497a590ec9001a9918972a6246142Brian Paul                                               read, xmctx);
1344086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         if (!readBuffer) {
1345086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul            /* Out of memory, or context/drawable depth mismatch */
1346086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul            return False;
1347086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         }
1348086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      }
1349086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul
13507a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell      MakeCurrent_PrevContext = ctx;
1351086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevDrawable = draw;
1352086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevReadable = read;
1353086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevDrawBuffer = drawBuffer;
1354086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevReadBuffer = readBuffer;
1355086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul
1356086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      /* Now make current! */
13577cf50e137da497a590ec9001a9918972a6246142Brian Paul      if (XMesaMakeCurrent2(xmctx, drawBuffer, readBuffer)) {
135812c1bee87fcc3a0912685bb6e83447972e5de64eBrian Paul         ((__GLXcontext *) ctx)->currentDpy = dpy;
135912c1bee87fcc3a0912685bb6e83447972e5de64eBrian Paul         ((__GLXcontext *) ctx)->currentDrawable = draw;
13608d687e7e58a148f3f16573636023e54755372010Brian Paul#ifndef GLX_BUILT_IN_XMESA
136112c1bee87fcc3a0912685bb6e83447972e5de64eBrian Paul         ((__GLXcontext *) ctx)->currentReadable = read;
13628d687e7e58a148f3f16573636023e54755372010Brian Paul#else
13637cf50e137da497a590ec9001a9918972a6246142Brian Paul         __glXSetCurrentContext(ctx);
13647cf50e137da497a590ec9001a9918972a6246142Brian Paul#endif
13657cf50e137da497a590ec9001a9918972a6246142Brian Paul         return True;
13667cf50e137da497a590ec9001a9918972a6246142Brian Paul      }
13677cf50e137da497a590ec9001a9918972a6246142Brian Paul      else {
13687cf50e137da497a590ec9001a9918972a6246142Brian Paul         return False;
13697cf50e137da497a590ec9001a9918972a6246142Brian Paul      }
1370086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul   }
13717a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell   else if (!ctx && !draw && !read) {
1372086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      /* release current context w/out assigning new one. */
1373086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      XMesaMakeCurrent( NULL, NULL );
1374086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevContext = 0;
1375086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevDrawable = 0;
1376086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevReadable = 0;
1377086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevDrawBuffer = 0;
1378086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevReadBuffer = 0;
137984cac8441fcf5f692cd220e9fa86cab398a4c159Brian Paul#ifdef GLX_BUILT_IN_XMESA
1380b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul      /* XXX bind dummy context with __glXSetCurrentContext(ctx); */
1381b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#endif
1382086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      return True;
1383086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul   }
1384086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul   else {
1385086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      /* The args must either all be non-zero or all zero.
1386086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul       * This is an error.
1387086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul       */
1388086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      return False;
1389086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul   }
1390086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul}
1391086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul
1392086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul
1393426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool
1394426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXMakeCurrent( Display *dpy, GLXDrawable drawable, GLXContext ctx )
1395426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
1396426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   return Fake_glXMakeContextCurrent( dpy, drawable, drawable, ctx );
1397426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
1398426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1399426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1400426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPixmap
1401426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateGLXPixmap( Display *dpy, XVisualInfo *visinfo, Pixmap pixmap )
1402afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1403afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaVisual v;
1404afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaBuffer b;
1405afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1406afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   v = find_glx_visual( dpy, visinfo );
1407afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (!v) {
1408afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      v = create_glx_visual( dpy, visinfo );
1409afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (!v) {
1410afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* unusable visual */
1411afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1412afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
1413afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1414afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1415afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   b = XMesaCreatePixmapBuffer( v, pixmap, 0 );
1416afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (!b) {
1417afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return 0;
1418afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1419e4b2356c07d31fbeeabb13b2fb47db703b473080Brian Paul   return b->frontxrb->pixmap;
1420afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1421afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1422afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1423b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_MESA_pixmap_colormap ***/
1424b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul
1425426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPixmap
1426426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visinfo,
1427426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                             Pixmap pixmap, Colormap cmap )
1428afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1429afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaVisual v;
1430afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaBuffer b;
1431afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1432afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   v = find_glx_visual( dpy, visinfo );
1433afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (!v) {
1434afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      v = create_glx_visual( dpy, visinfo );
1435afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (!v) {
1436afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* unusable visual */
1437afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1438afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
1439afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1440afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1441afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   b = XMesaCreatePixmapBuffer( v, pixmap, cmap );
1442afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (!b) {
1443afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return 0;
1444afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1445e4b2356c07d31fbeeabb13b2fb47db703b473080Brian Paul   return b->frontxrb->pixmap;
1446afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1447afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1448afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1449426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1450426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyGLXPixmap( Display *dpy, GLXPixmap pixmap )
1451afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1452afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaBuffer b = XMesaFindBuffer(dpy, pixmap);
1453afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (b) {
1454afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      XMesaDestroyBuffer(b);
1455afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1456367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul   else if (_mesa_getenv("MESA_DEBUG")) {
1457d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul      _mesa_warning(NULL, "Mesa: glXDestroyGLXPixmap: invalid pixmap\n");
1458afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1459afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1460afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1461afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1462426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1463426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCopyContext( Display *dpy, GLXContext src, GLXContext dst,
14643994b77bab8c62a4c1a4dffdfba233ef46662b99Brian Paul                     unsigned long mask )
1465afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
146683b820aa98931ef30fa73c72b2a96fe23885955eBrian Paul   struct fake_glx_context *fakeSrc = (struct fake_glx_context *) src;
146783b820aa98931ef30fa73c72b2a96fe23885955eBrian Paul   struct fake_glx_context *fakeDst = (struct fake_glx_context *) dst;
146883b820aa98931ef30fa73c72b2a96fe23885955eBrian Paul   XMesaContext xm_src = fakeSrc->xmesaContext;
146983b820aa98931ef30fa73c72b2a96fe23885955eBrian Paul   XMesaContext xm_dst = fakeDst->xmesaContext;
1470afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
14711e24d3318df57b36e3b68695ff64b4b8bd822c9eBrian Paul   _mesa_copy_context( &(xm_src->mesa), &(xm_dst->mesa), (GLuint) mask );
1472afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1473afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1474afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1475426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool
1476426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryExtension( Display *dpy, int *errorb, int *event )
1477afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1478afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* Mesa's GLX isn't really an X extension but we try to act like one. */
1479afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
1480afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) errorb;
1481afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) event;
1482afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return True;
1483afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1484afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1485afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1486e7b16b74bf5d13331b5a88bbbbb9096560297b63Brian Paulextern void _kw_ungrab_all( Display *dpy );
1487afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgvoid _kw_ungrab_all( Display *dpy )
1488afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1489afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XUngrabPointer( dpy, CurrentTime );
1490afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XUngrabKeyboard( dpy, CurrentTime );
1491afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1492afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1493afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1494426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1495426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyContext( Display *dpy, GLXContext ctx )
1496afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
14977cf50e137da497a590ec9001a9918972a6246142Brian Paul   struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx;
1498afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
1499afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   MakeCurrent_PrevContext = 0;
1500afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   MakeCurrent_PrevDrawable = 0;
1501086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul   MakeCurrent_PrevReadable = 0;
1502086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul   MakeCurrent_PrevDrawBuffer = 0;
1503086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul   MakeCurrent_PrevReadBuffer = 0;
15047cf50e137da497a590ec9001a9918972a6246142Brian Paul   XMesaDestroyContext( glxCtx->xmesaContext );
1505afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaGarbageCollect();
1506afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1507afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1508afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1509426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool
1510426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXIsDirect( Display *dpy, GLXContext ctx )
1511afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
15127cf50e137da497a590ec9001a9918972a6246142Brian Paul   struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx;
1513afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
15147cf50e137da497a590ec9001a9918972a6246142Brian Paul   return glxCtx->xmesaContext->direct;
1515afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1516afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1517afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1518afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1519426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1520426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXSwapBuffers( Display *dpy, GLXDrawable drawable )
1521afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1522afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaBuffer buffer = XMesaFindBuffer( dpy, drawable );
1523afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1524afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (buffer) {
1525afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      XMesaSwapBuffers(buffer);
1526afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1527367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul   else if (_mesa_getenv("MESA_DEBUG")) {
1528ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul      _mesa_warning(NULL, "glXSwapBuffers: invalid drawable 0x%x\n",
1529ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul                    (int) drawable);
1530afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1531afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1532afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1533afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
15344c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul
1535b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_MESA_copy_sub_buffer ***/
1536b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul
1537426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1538426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCopySubBufferMESA( Display *dpy, GLXDrawable drawable,
1539426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                           int x, int y, int width, int height )
1540afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1541afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaBuffer buffer = XMesaFindBuffer( dpy, drawable );
1542afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (buffer) {
1543afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      XMesaCopySubBuffer(buffer, x, y, width, height);
1544afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1545367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul   else if (_mesa_getenv("MESA_DEBUG")) {
1546d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul      _mesa_warning(NULL, "Mesa: glXCopySubBufferMESA: invalid drawable\n");
1547afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1548afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1549afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1550afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1551426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool
1552426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryVersion( Display *dpy, int *maj, int *min )
1553afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1554afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
1555afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* Return GLX version, not Mesa version */
155678fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul   assert(CLIENT_MAJOR_VERSION == SERVER_MAJOR_VERSION);
155778fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul   *maj = CLIENT_MAJOR_VERSION;
155878fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul   *min = MIN2( CLIENT_MINOR_VERSION, SERVER_MINOR_VERSION );
1559afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return True;
1560afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1561afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1562afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1563afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
1564afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Query the GLX attributes of the given XVisualInfo.
1565afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
1566426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int
1567e4656003caee346d9c4eb23256d73409271291a7Brian Paulget_config( XMesaVisual xmvis, int attrib, int *value, GLboolean fbconfig )
1568afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1569e4656003caee346d9c4eb23256d73409271291a7Brian Paul   ASSERT(xmvis);
1570afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   switch(attrib) {
1571afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_USE_GL:
15721f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul         if (fbconfig)
15731f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul            return GLX_BAD_ATTRIBUTE;
1574afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         *value = (int) True;
1575afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1576afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_BUFFER_SIZE:
1577e4656003caee346d9c4eb23256d73409271291a7Brian Paul	 *value = xmvis->visinfo->depth;
1578afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1579afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_LEVEL:
1580304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick	 *value = xmvis->mesa_visual.level;
1581afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1582afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_RGBA:
15831f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul         if (fbconfig)
15841f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul            return GLX_BAD_ATTRIBUTE;
1585e4656003caee346d9c4eb23256d73409271291a7Brian Paul	 if (xmvis->mesa_visual.rgbMode) {
1586afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    *value = True;
1587afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 }
1588afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 else {
1589afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    *value = False;
1590afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 }
1591afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1592afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_DOUBLEBUFFER:
1593e4656003caee346d9c4eb23256d73409271291a7Brian Paul	 *value = (int) xmvis->mesa_visual.doubleBufferMode;
1594afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1595afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_STEREO:
1596e4656003caee346d9c4eb23256d73409271291a7Brian Paul	 *value = (int) xmvis->mesa_visual.stereoMode;
1597afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1598afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_AUX_BUFFERS:
1599894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul	 *value = xmvis->mesa_visual.numAuxBuffers;
1600afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1601afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_RED_SIZE:
1602e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = xmvis->mesa_visual.redBits;
1603afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1604afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_GREEN_SIZE:
1605e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = xmvis->mesa_visual.greenBits;
1606afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1607afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_BLUE_SIZE:
1608e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = xmvis->mesa_visual.blueBits;
1609afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1610afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_ALPHA_SIZE:
1611e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = xmvis->mesa_visual.alphaBits;
1612afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1613afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_DEPTH_SIZE:
1614e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = xmvis->mesa_visual.depthBits;
1615afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1616afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_STENCIL_SIZE:
1617e4656003caee346d9c4eb23256d73409271291a7Brian Paul	 *value = xmvis->mesa_visual.stencilBits;
1618afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1619afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_ACCUM_RED_SIZE:
1620e4656003caee346d9c4eb23256d73409271291a7Brian Paul	 *value = xmvis->mesa_visual.accumRedBits;
1621b2e460018375f699198073a6167e0ee96ba1d267Brian Paul	 return 0;
1622afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_ACCUM_GREEN_SIZE:
1623e4656003caee346d9c4eb23256d73409271291a7Brian Paul	 *value = xmvis->mesa_visual.accumGreenBits;
1624b2e460018375f699198073a6167e0ee96ba1d267Brian Paul	 return 0;
1625afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_ACCUM_BLUE_SIZE:
1626e4656003caee346d9c4eb23256d73409271291a7Brian Paul	 *value = xmvis->mesa_visual.accumBlueBits;
1627afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1628afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_ACCUM_ALPHA_SIZE:
1629e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = xmvis->mesa_visual.accumAlphaBits;
1630afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1631afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1632afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /*
1633afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg       * GLX_EXT_visual_info extension
1634afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg       */
1635afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_X_VISUAL_TYPE_EXT:
1636e4656003caee346d9c4eb23256d73409271291a7Brian Paul         switch (xmvis->visinfo->CLASS) {
1637afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case StaticGray:   *value = GLX_STATIC_GRAY_EXT;   return 0;
1638afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GrayScale:    *value = GLX_GRAY_SCALE_EXT;    return 0;
1639afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case StaticColor:  *value = GLX_STATIC_GRAY_EXT;   return 0;
1640afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case PseudoColor:  *value = GLX_PSEUDO_COLOR_EXT;  return 0;
1641afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case TrueColor:    *value = GLX_TRUE_COLOR_EXT;    return 0;
1642afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case DirectColor:  *value = GLX_DIRECT_COLOR_EXT;  return 0;
1643afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
1644afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1645afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_TRANSPARENT_TYPE_EXT:
1646304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick         if (xmvis->mesa_visual.level==0) {
1647afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* normal planes */
1648afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            *value = GLX_NONE_EXT;
1649afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
1650304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick         else if (xmvis->mesa_visual.level>0) {
1651afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* overlay */
1652e4656003caee346d9c4eb23256d73409271291a7Brian Paul            if (xmvis->mesa_visual.rgbMode) {
1653afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               *value = GLX_TRANSPARENT_RGB_EXT;
1654afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
1655afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            else {
1656afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               *value = GLX_TRANSPARENT_INDEX_EXT;
1657afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
1658afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
1659304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick         else if (xmvis->mesa_visual.level<0) {
1660afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* underlay */
1661afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            *value = GLX_NONE_EXT;
1662afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
1663afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1664afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_TRANSPARENT_INDEX_VALUE_EXT:
1665afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         {
1666e4656003caee346d9c4eb23256d73409271291a7Brian Paul            int pixel = transparent_pixel( xmvis );
1667afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            if (pixel>=0) {
1668afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               *value = pixel;
1669afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
1670afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* else undefined */
1671afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
1672afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1673afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_TRANSPARENT_RED_VALUE_EXT:
1674afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* undefined */
1675afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1676afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_TRANSPARENT_GREEN_VALUE_EXT:
1677afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* undefined */
1678afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1679afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_TRANSPARENT_BLUE_VALUE_EXT:
1680afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* undefined */
1681afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1682afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_TRANSPARENT_ALPHA_VALUE_EXT:
1683afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* undefined */
1684afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1685afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1686afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /*
1687b2e460018375f699198073a6167e0ee96ba1d267Brian Paul       * GLX_EXT_visual_info extension
1688b2e460018375f699198073a6167e0ee96ba1d267Brian Paul       */
1689b2e460018375f699198073a6167e0ee96ba1d267Brian Paul      case GLX_VISUAL_CAVEAT_EXT:
1690fc68be6b111473a0bf8f991468f973bb9dd275f4Brian Paul         /* test for zero, just in case */
1691304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick         if (xmvis->mesa_visual.visualRating > 0)
1692304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick            *value = xmvis->mesa_visual.visualRating;
1693962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul         else
1694962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul            *value = GLX_NONE_EXT;
1695962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul         return 0;
1696b2e460018375f699198073a6167e0ee96ba1d267Brian Paul
1697b2e460018375f699198073a6167e0ee96ba1d267Brian Paul      /*
169866ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul       * GLX_ARB_multisample
1699afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg       */
170066ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul      case GLX_SAMPLE_BUFFERS_ARB:
17013265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         *value = 0;
17023265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         return 0;
170366ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul      case GLX_SAMPLES_ARB:
17043265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         *value = 0;
17053265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         return 0;
17063265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul
17073265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      /*
17083265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul       * For FBConfigs:
17093265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul       */
17103265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      case GLX_SCREEN_EXT:
17113265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         if (!fbconfig)
17123265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            return GLX_BAD_ATTRIBUTE;
1713e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = xmvis->visinfo->screen;
17143265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         break;
17153265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      case GLX_DRAWABLE_TYPE: /*SGIX too */
17163265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         if (!fbconfig)
17173265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            return GLX_BAD_ATTRIBUTE;
17183265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         *value = GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT;
17193265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         break;
17203265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      case GLX_RENDER_TYPE_SGIX:
17213265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         if (!fbconfig)
17223265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            return GLX_BAD_ATTRIBUTE;
1723e4656003caee346d9c4eb23256d73409271291a7Brian Paul         if (xmvis->mesa_visual.rgbMode)
17243265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            *value = GLX_RGBA_BIT;
17253265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         else
17263265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            *value = GLX_COLOR_INDEX_BIT;
17273265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         break;
17283265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      case GLX_X_RENDERABLE_SGIX:
17293265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         if (!fbconfig)
17303265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            return GLX_BAD_ATTRIBUTE;
17313265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         *value = True; /* XXX really? */
17323265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         break;
17333265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      case GLX_FBCONFIG_ID_SGIX:
17343265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         if (!fbconfig)
17353265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            return GLX_BAD_ATTRIBUTE;
1736f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul         *value = xmvis->visinfo->visualid;
17373265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         break;
17383265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      case GLX_MAX_PBUFFER_WIDTH:
17393265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         if (!fbconfig)
17403265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            return GLX_BAD_ATTRIBUTE;
17413265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         /* XXX or MAX_WIDTH? */
1742f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul         *value = DisplayWidth(xmvis->display, xmvis->visinfo->screen);
17433265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         break;
17443265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      case GLX_MAX_PBUFFER_HEIGHT:
17453265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         if (!fbconfig)
17463265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            return GLX_BAD_ATTRIBUTE;
1747f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul         *value = DisplayHeight(xmvis->display, xmvis->visinfo->screen);
17483265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         break;
17493265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      case GLX_MAX_PBUFFER_PIXELS:
17503265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         if (!fbconfig)
17513265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            return GLX_BAD_ATTRIBUTE;
1752f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul         *value = DisplayWidth(xmvis->display, xmvis->visinfo->screen) *
1753f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul                  DisplayHeight(xmvis->display, xmvis->visinfo->screen);
17543265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         break;
17553265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      case GLX_VISUAL_ID:
17563265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         if (!fbconfig)
17573265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            return GLX_BAD_ATTRIBUTE;
1758f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul         *value = xmvis->visinfo->visualid;
17593265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         break;
17603265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul
1761afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      default:
1762afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return GLX_BAD_ATTRIBUTE;
1763afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
17643265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   return Success;
1765afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1766afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1767afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
17683265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paulstatic int
17693265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian PaulFake_glXGetConfig( Display *dpy, XVisualInfo *visinfo,
17703265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul                   int attrib, int *value )
17713265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul{
1772e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaVisual xmvis;
1773ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul   int k;
1774379641956d134b8dc761b6411d7c4dca8f94a092Brian Paul   if (!dpy || !visinfo)
1775a9a1c3f20f2d6aad4afc47cf2b29c5393fddb6b6Brian Paul      return GLX_BAD_ATTRIBUTE;
1776a9a1c3f20f2d6aad4afc47cf2b29c5393fddb6b6Brian Paul
1777e4656003caee346d9c4eb23256d73409271291a7Brian Paul   xmvis = find_glx_visual( dpy, visinfo );
1778e4656003caee346d9c4eb23256d73409271291a7Brian Paul   if (!xmvis) {
17793265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      /* this visual wasn't obtained with glXChooseVisual */
1780e4656003caee346d9c4eb23256d73409271291a7Brian Paul      xmvis = create_glx_visual( dpy, visinfo );
1781e4656003caee346d9c4eb23256d73409271291a7Brian Paul      if (!xmvis) {
17823265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul	 /* this visual can't be used for GL rendering */
17833265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul	 if (attrib==GLX_USE_GL) {
17843265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul	    *value = (int) False;
17853265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul	    return 0;
17863265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul	 }
17873265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul	 else {
17883265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul	    return GLX_BAD_VISUAL;
17893265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul	 }
17903265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      }
17913265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   }
17923265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul
1793ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul   k = get_config(xmvis, attrib, value, GL_FALSE);
1794ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul   return k;
17953265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul}
17963265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul
1797afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1798426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1799426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXWaitGL( void )
1800afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1801afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaContext xmesa = XMesaGetCurrentContext();
1802afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaFlush( xmesa );
1803afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1804afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1805afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1806afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1807426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1808426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXWaitX( void )
1809afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1810afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaContext xmesa = XMesaGetCurrentContext();
1811afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaFlush( xmesa );
1812afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1813afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1814afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1815e4656003caee346d9c4eb23256d73409271291a7Brian Paulstatic const char *
1816e4656003caee346d9c4eb23256d73409271291a7Brian Paulget_extensions( void )
181743c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul{
181843c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul#ifdef FX
1819367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul   const char *fx = _mesa_getenv("MESA_GLX_FX");
182043c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul   if (fx && fx[0] != 'd') {
1821e4656003caee346d9c4eb23256d73409271291a7Brian Paul      return EXTENSIONS;
182243c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul   }
182343c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul#endif
1824e4656003caee346d9c4eb23256d73409271291a7Brian Paul   return EXTENSIONS + 23; /* skip "GLX_MESA_set_3dfx_mode" */
182543c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul}
1826afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1827afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1828afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1829afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* GLX 1.1 and later */
1830426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic const char *
1831426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryExtensionsString( Display *dpy, int screen )
1832afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1833afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
1834afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) screen;
183543c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul   return get_extensions();
1836afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1837afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1838afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1839afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1840afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* GLX 1.1 and later */
1841426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic const char *
1842426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryServerString( Display *dpy, int screen, int name )
1843afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
184478fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul   static char version[1000];
18452ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul   _mesa_sprintf(version, "%d.%d %s",
18462ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul                 SERVER_MAJOR_VERSION, SERVER_MINOR_VERSION, MESA_GLX_VERSION);
1847afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1848afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
1849afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) screen;
1850afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1851afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   switch (name) {
1852afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_EXTENSIONS:
185343c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul         return get_extensions();
1854afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_VENDOR:
185578fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul	 return VENDOR;
1856afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_VERSION:
1857afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return version;
1858afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      default:
1859afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return NULL;
1860afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1861afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1862afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1863afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1864afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1865afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* GLX 1.1 and later */
1866426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic const char *
1867426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetClientString( Display *dpy, int name )
1868afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
186978fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul   static char version[1000];
18702ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul   _mesa_sprintf(version, "%d.%d %s", CLIENT_MAJOR_VERSION,
18712ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul                 CLIENT_MINOR_VERSION, MESA_GLX_VERSION);
1872afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1873afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
1874afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1875afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   switch (name) {
1876afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_EXTENSIONS:
187743c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul         return get_extensions();
1878afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_VENDOR:
187978fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul	 return VENDOR;
1880afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_VERSION:
1881afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return version;
1882afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      default:
1883afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return NULL;
1884afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1885afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1886afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1887afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1888afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1889426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul/*
1890426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul * GLX 1.3 and later
1891426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul */
1892426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
18937d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
1894426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int
1895426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetFBConfigAttrib( Display *dpy, GLXFBConfig config,
1896426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                           int attribute, int *value )
1897426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
18983265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   XMesaVisual v = (XMesaVisual) config;
1899426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
1900426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) config;
19017d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
19027d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (!dpy || !config || !value)
19037d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return -1;
19047d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
19053265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   return get_config(v, attribute, value, GL_TRUE);
1906426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
1907426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1908426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
19095605798e56ca6e9f968623f33b58ee7ca90594afBrian Paulstatic GLXFBConfig *
19105605798e56ca6e9f968623f33b58ee7ca90594afBrian PaulFake_glXGetFBConfigs( Display *dpy, int screen, int *nelements )
19115605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul{
19123265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   XVisualInfo *visuals, visTemplate;
19133265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   const long visMask = VisualScreenMask;
19143265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   int i;
19153265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul
19163265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   /* Get list of all X visuals */
19173265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   visTemplate.screen = screen;
19183265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   visuals = XGetVisualInfo(dpy, visMask, &visTemplate, nelements);
19193265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   if (*nelements > 0) {
19203265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      XMesaVisual *results;
19214039cb8ca82d59451a6de8902fe35e693cdca3baBrian Paul      results = (XMesaVisual *) _mesa_malloc(*nelements * sizeof(XMesaVisual));
19223265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      if (!results) {
19233265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         *nelements = 0;
19243265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         return NULL;
19253265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      }
19263265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      for (i = 0; i < *nelements; i++) {
19273265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         results[i] = create_glx_visual(dpy, visuals + i);
19283265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      }
19293265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      return (GLXFBConfig *) results;
19303265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   }
19313265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   return NULL;
19325605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul}
19335605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul
19345605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul
1935481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paulstatic GLXFBConfig *
1936481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian PaulFake_glXChooseFBConfig( Display *dpy, int screen,
1937481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul                        const int *attribList, int *nitems )
1938481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul{
1939481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul   XMesaVisual xmvis;
1940481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul
1941481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul   if (!attribList || !attribList[0]) {
1942481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul      /* return list of all configs (per GLX_SGIX_fbconfig spec) */
1943481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul      return Fake_glXGetFBConfigs(dpy, screen, nitems);
1944481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul   }
1945481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul
1946481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul   xmvis = choose_visual(dpy, screen, attribList, GL_TRUE);
1947481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul   if (xmvis) {
1948481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul      GLXFBConfig *config = (GLXFBConfig *) _mesa_malloc(sizeof(XMesaVisual));
1949481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul      if (!config) {
1950481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul         *nitems = 0;
1951481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul         return NULL;
1952481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul      }
1953481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul      *nitems = 1;
1954481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul      config[0] = (GLXFBConfig) xmvis;
1955481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul      return (GLXFBConfig *) config;
1956481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul   }
1957481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul   else {
1958481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul      *nitems = 0;
1959481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul      return NULL;
1960481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul   }
1961481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul}
1962481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul
1963481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul
1964426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic XVisualInfo *
1965426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetVisualFromFBConfig( Display *dpy, GLXFBConfig config )
1966426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
19677d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (dpy && config) {
1968f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      XMesaVisual xmvis = (XMesaVisual) config;
1969f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul#if 0
1970f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      return xmvis->vishandle;
1971f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul#else
1972f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      /* create a new vishandle - the cached one may be stale */
19734039cb8ca82d59451a6de8902fe35e693cdca3baBrian Paul      xmvis->vishandle = (XVisualInfo *) _mesa_malloc(sizeof(XVisualInfo));
1974f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      if (xmvis->vishandle) {
1975f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul         _mesa_memcpy(xmvis->vishandle, xmvis->visinfo, sizeof(XVisualInfo));
1976f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      }
1977f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      return xmvis->vishandle;
1978f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul#endif
19797d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   }
19807d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   else {
19817d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return NULL;
19827d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   }
1983426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
1984426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1985426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1986426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXWindow
1987426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateWindow( Display *dpy, GLXFBConfig config, Window win,
1988426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                      const int *attribList )
1989426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
1990529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul   XMesaVisual xmvis = (XMesaVisual) config;
1991529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul   XMesaBuffer xmbuf;
1992529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul   if (!xmvis)
1993529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul      return 0;
1994529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul
1995529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul   xmbuf = XMesaCreateWindowBuffer2(xmvis, win, NULL);
1996529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul   if (!xmbuf)
1997529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul      return 0;
1998529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul
1999426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
20007d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   (void) attribList;  /* Ignored in GLX 1.3 */
20017d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
20027d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   return win;  /* A hack for now */
2003426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2004426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2005426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2006426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
2007426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyWindow( Display *dpy, GLXWindow window )
2008426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
20097d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   XMesaBuffer b = XMesaFindBuffer(dpy, (XMesaDrawable) window);
20107d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (b)
20117d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      XMesaDestroyBuffer(b);
20127d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   /* don't destroy X window */
2013426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2014426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2015426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
20167d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul/* XXX untested */
2017426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPixmap
2018426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreatePixmap( Display *dpy, GLXFBConfig config, Pixmap pixmap,
2019426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                      const int *attribList )
2020426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
20217d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   XMesaVisual v = (XMesaVisual) config;
20227d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   XMesaBuffer b;
20237d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
2024426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
2025426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) config;
2026426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) pixmap;
20277d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   (void) attribList;  /* Ignored in GLX 1.3 */
20287d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
20297d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (!dpy || !config || !pixmap)
20307d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return 0;
20317d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
20327d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   b = XMesaCreatePixmapBuffer( v, pixmap, 0 );
20337d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (!b) {
20347d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return 0;
20357d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   }
20367d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
20377d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   return pixmap;
2038426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2039426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2040426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2041426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
2042426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyPixmap( Display *dpy, GLXPixmap pixmap )
2043426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
20447d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   XMesaBuffer b = XMesaFindBuffer(dpy, (XMesaDrawable)pixmap);
20457d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (b)
20467d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      XMesaDestroyBuffer(b);
20477d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   /* don't destroy X pixmap */
2048426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2049426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2050426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2051426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPbuffer
2052426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreatePbuffer( Display *dpy, GLXFBConfig config,
2053426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                       const int *attribList )
2054426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
20553265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   XMesaVisual xmvis = (XMesaVisual) config;
20563265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   XMesaBuffer xmbuf;
20577d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   const int *attrib;
20587d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   int width = 0, height = 0;
20597d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   GLboolean useLargest = GL_FALSE, preserveContents = GL_FALSE;
20607d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
2061426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
20627d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
20633265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   for (attrib = attribList; *attrib; attrib++) {
20647d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      switch (*attrib) {
20657d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         case GLX_PBUFFER_WIDTH:
20663265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            attrib++;
20673265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            width = *attrib;
20687d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            break;
20697d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         case GLX_PBUFFER_HEIGHT:
20703265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            attrib++;
20713265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            height = *attrib;
20727d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            break;
20737d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         case GLX_PRESERVED_CONTENTS:
20743265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            attrib++;
20753265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            preserveContents = *attrib; /* ignored */
20767d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            break;
20777d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         case GLX_LARGEST_PBUFFER:
20783265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            attrib++;
20793265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            useLargest = *attrib; /* ignored */
20807d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            break;
20817d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         default:
20827d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            return 0;
20837d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      }
20847d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   }
20857d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
2086b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul   /* not used at this time */
2087b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul   (void) useLargest;
2088b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul   (void) preserveContents;
2089b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul
20907d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (width == 0 || height == 0)
20917d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return 0;
20927d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
20933265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   xmbuf = XMesaCreatePBuffer( xmvis, 0, width, height);
2094e4656003caee346d9c4eb23256d73409271291a7Brian Paul   /* A GLXPbuffer handle must be an X Drawable because that's what
2095e4656003caee346d9c4eb23256d73409271291a7Brian Paul    * glXMakeCurrent takes.
2096e4656003caee346d9c4eb23256d73409271291a7Brian Paul    */
2097e4b2356c07d31fbeeabb13b2fb47db703b473080Brian Paul   return (GLXPbuffer) xmbuf->frontxrb->pixmap;
2098426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2099426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2100426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2101426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
2102426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyPbuffer( Display *dpy, GLXPbuffer pbuf )
2103426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2104e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaBuffer b = XMesaFindBuffer(dpy, pbuf);
2105e4656003caee346d9c4eb23256d73409271291a7Brian Paul   if (b) {
2106e4656003caee346d9c4eb23256d73409271291a7Brian Paul      XMesaDestroyBuffer(b);
2107e4656003caee346d9c4eb23256d73409271291a7Brian Paul   }
2108426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2109426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2110426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2111426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
2112426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryDrawable( Display *dpy, GLXDrawable draw, int attribute,
2113426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                       unsigned int *value )
2114426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2115e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaBuffer xmbuf = XMesaFindBuffer(dpy, draw);
2116e4656003caee346d9c4eb23256d73409271291a7Brian Paul   if (!xmbuf)
2117e4656003caee346d9c4eb23256d73409271291a7Brian Paul      return;
21187d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
21197d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   switch (attribute) {
21207d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_WIDTH:
212129926a11b16ec7a235947d95e9a46777605dd30eBrian Paul         *value = xmbuf->mesa_buffer.Width;
2122e4656003caee346d9c4eb23256d73409271291a7Brian Paul         break;
21237d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_HEIGHT:
212429926a11b16ec7a235947d95e9a46777605dd30eBrian Paul         *value = xmbuf->mesa_buffer.Height;
2125e4656003caee346d9c4eb23256d73409271291a7Brian Paul         break;
21267d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_PRESERVED_CONTENTS:
2127e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = True;
2128e4656003caee346d9c4eb23256d73409271291a7Brian Paul         break;
21297d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_LARGEST_PBUFFER:
213029926a11b16ec7a235947d95e9a46777605dd30eBrian Paul         *value = xmbuf->mesa_buffer.Width * xmbuf->mesa_buffer.Height;
2131e4656003caee346d9c4eb23256d73409271291a7Brian Paul         break;
21327d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_FBCONFIG_ID:
2133f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul         *value = xmbuf->xm_visual->visinfo->visualid;
21347d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         return;
21357d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      default:
21367d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         return;  /* GLX_BAD_ATTRIBUTE? */
21377d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   }
2138426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2139426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2140426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2141426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXContext
2142426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateNewContext( Display *dpy, GLXFBConfig config,
2143426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                          int renderType, GLXContext shareList, Bool direct )
2144426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2145f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   struct fake_glx_context *glxCtx;
2146f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   struct fake_glx_context *shareCtx = (struct fake_glx_context *) shareList;
2147f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   XMesaVisual xmvis = (XMesaVisual) config;
21487d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
21497d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (!dpy || !config ||
21507d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul       (renderType != GLX_RGBA_TYPE && renderType != GLX_COLOR_INDEX_TYPE))
21517d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return 0;
21527d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
2153f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   glxCtx = CALLOC_STRUCT(fake_glx_context);
2154f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   if (!glxCtx)
2155f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      return 0;
2156f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul
2157f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   /* deallocate unused windows/buffers */
2158f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   XMesaGarbageCollect();
2159f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul
2160f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   glxCtx->xmesaContext = XMesaCreateContext(xmvis,
2161f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul                                   shareCtx ? shareCtx->xmesaContext : NULL);
2162f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   if (!glxCtx->xmesaContext) {
2163f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      FREE(glxCtx);
2164f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      return NULL;
2165f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   }
2166f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul
2167f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   glxCtx->xmesaContext->direct = GL_FALSE;
2168f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   glxCtx->glxContext.isDirect = GL_FALSE;
2169f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   glxCtx->glxContext.currentDpy = dpy;
2170f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   glxCtx->glxContext.xid = (XID) glxCtx;  /* self pointer */
2171f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul
2172f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   assert((void *) glxCtx == (void *) &(glxCtx->glxContext));
2173f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul
2174f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   return (GLXContext) glxCtx;
2175426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2176426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2177426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2178426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int
2179426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryContext( Display *dpy, GLXContext ctx, int attribute, int *value )
2180426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2181e4656003caee346d9c4eb23256d73409271291a7Brian Paul   struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx;
2182e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaContext xmctx = glxCtx->xmesaContext;
2183e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2184426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
2185426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) ctx;
21867d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
21877d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   switch (attribute) {
21887d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   case GLX_FBCONFIG_ID:
2189f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      *value = xmctx->xm_visual->visinfo->visualid;
2190e4656003caee346d9c4eb23256d73409271291a7Brian Paul      break;
21917d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   case GLX_RENDER_TYPE:
2192e4656003caee346d9c4eb23256d73409271291a7Brian Paul      if (xmctx->xm_visual->mesa_visual.rgbMode)
2193e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = GLX_RGBA_BIT;
2194e4656003caee346d9c4eb23256d73409271291a7Brian Paul      else
2195e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = GLX_COLOR_INDEX_BIT;
2196e4656003caee346d9c4eb23256d73409271291a7Brian Paul      break;
21977d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   case GLX_SCREEN:
21987d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      *value = 0;
21997d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return Success;
22007d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   default:
22017d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return GLX_BAD_ATTRIBUTE;
22027d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   }
2203e4656003caee346d9c4eb23256d73409271291a7Brian Paul   return 0;
2204426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2205426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2206426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2207426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
2208426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXSelectEvent( Display *dpy, GLXDrawable drawable, unsigned long mask )
2209426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2210e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable);
2211e4656003caee346d9c4eb23256d73409271291a7Brian Paul   if (xmbuf)
2212e4656003caee346d9c4eb23256d73409271291a7Brian Paul      xmbuf->selectedEvents = mask;
2213426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2214426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2215426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2216426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
2217426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetSelectedEvent( Display *dpy, GLXDrawable drawable,
2218426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                          unsigned long *mask )
2219426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2220e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable);
2221e4656003caee346d9c4eb23256d73409271291a7Brian Paul   if (xmbuf)
2222e4656003caee346d9c4eb23256d73409271291a7Brian Paul      *mask = xmbuf->selectedEvents;
2223e4656003caee346d9c4eb23256d73409271291a7Brian Paul   else
2224e4656003caee346d9c4eb23256d73409271291a7Brian Paul      *mask = 0;
2225426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2226b82d993b03320818f88f792a9e713f7ed491bfcbBrian Paul
2227b82d993b03320818f88f792a9e713f7ed491bfcbBrian Paul
2228b82d993b03320818f88f792a9e713f7ed491bfcbBrian Paul
2229b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGI_swap_control ***/
2230783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2231783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2232783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXSwapIntervalSGI(int interval)
2233783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2234783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) interval;
2235783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2236783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2237783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2238783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2239783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2240b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGI_video_sync ***/
2241783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2242783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2243783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetVideoSyncSGI(unsigned int *count)
2244783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2245783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) count;
2246783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2247783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2248783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2249783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2250783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count)
2251783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2252783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) divisor;
2253783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) remainder;
2254783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) count;
2255783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2256783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2257783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2258783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2259783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2260b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGI_make_current_read ***/
2261783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2262426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool
2263783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXMakeCurrentReadSGI(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx)
2264afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
2265a078d75a27b99252ede6520e24b145106ab98aa2Brian Paul   return Fake_glXMakeContextCurrent( dpy, draw, read, ctx );
2266afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
2267783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
22687cf50e137da497a590ec9001a9918972a6246142Brian Paul/* not used
2269783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXDrawable
2270b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian PaulFake_glXGetCurrentReadDrawableSGI(void)
2271783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2272783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2273783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
22747cf50e137da497a590ec9001a9918972a6246142Brian Paul*/
2275afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
2276afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
2277b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_video_source ***/
2278b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#if defined(_VL_H)
22794c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul
2280783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXVideoSourceSGIX
2281783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXCreateGLXVideoSourceSGIX(Display *dpy, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode)
2282afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
2283783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2284783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2285783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) server;
2286783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) path;
2287783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) nodeClass;
2288783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) drainNode;
2289783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2290783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2291783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2292783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2293783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXDestroyGLXVideoSourceSGIX(Display *dpy, GLXVideoSourceSGIX src)
2294783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2295783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2296783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) src;
2297afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
2298783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
22994c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul#endif
23004c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul
230189a42b7e736bd9b0ab090906cab0cd047a6ec12eBrian Paul
2302b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_EXT_import_context ***/
230389a42b7e736bd9b0ab090906cab0cd047a6ec12eBrian Paul
2304783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2305783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXFreeContextEXT(Display *dpy, GLXContext context)
2306783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2307783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2308783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) context;
2309783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2310426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2311783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXContextID
2312783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetContextIDEXT(const GLXContext context)
2313783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2314783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) context;
2315783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2316783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2317783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2318783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXContext
2319783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXImportContextEXT(Display *dpy, GLXContextID contextID)
2320783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2321783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2322783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) contextID;
2323783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2324783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2325426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2326426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int
2327783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryContextInfoEXT(Display *dpy, GLXContext context, int attribute, int *value)
2328426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2329783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2330783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) context;
2331783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) attribute;
2332783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) value;
2333426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   return 0;
2334426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2335426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2336783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2337783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2338b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_fbconfig ***/
2339426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2340426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int
2341783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetFBConfigAttribSGIX(Display *dpy, GLXFBConfigSGIX config, int attribute, int *value)
2342783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
23433265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   return Fake_glXGetFBConfigAttrib(dpy, config, attribute, value);
2344783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2345783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2346783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXFBConfigSGIX *
2347783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXChooseFBConfigSGIX(Display *dpy, int screen, int *attrib_list, int *nelements)
2348783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
23493265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   return (GLXFBConfig *) Fake_glXChooseFBConfig(dpy, screen, attrib_list, nelements);
2350783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2351783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2352e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2353783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXPixmap
2354783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXCreateGLXPixmapWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap)
2355783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2356e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaVisual xmvis = (XMesaVisual) config;
2357e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaBuffer xmbuf = XMesaCreatePixmapBuffer(xmvis, pixmap, 0);
2358e4b2356c07d31fbeeabb13b2fb47db703b473080Brian Paul   return xmbuf->frontxrb->pixmap; /* need to return an X ID */
2359783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2360783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2361e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2362783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXContext
2363783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct)
2364783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2365e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaVisual xmvis = (XMesaVisual) config;
2366e4656003caee346d9c4eb23256d73409271291a7Brian Paul   struct fake_glx_context *glxCtx;
2367e4656003caee346d9c4eb23256d73409271291a7Brian Paul   struct fake_glx_context *shareCtx = (struct fake_glx_context *) share_list;
2368e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2369e4656003caee346d9c4eb23256d73409271291a7Brian Paul   glxCtx = CALLOC_STRUCT(fake_glx_context);
2370e4656003caee346d9c4eb23256d73409271291a7Brian Paul   if (!glxCtx)
2371e4656003caee346d9c4eb23256d73409271291a7Brian Paul      return 0;
2372e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2373e4656003caee346d9c4eb23256d73409271291a7Brian Paul   /* deallocate unused windows/buffers */
2374e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaGarbageCollect();
2375e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2376e4656003caee346d9c4eb23256d73409271291a7Brian Paul   glxCtx->xmesaContext = XMesaCreateContext(xmvis,
2377e4656003caee346d9c4eb23256d73409271291a7Brian Paul                                   shareCtx ? shareCtx->xmesaContext : NULL);
2378e4656003caee346d9c4eb23256d73409271291a7Brian Paul   if (!glxCtx->xmesaContext) {
2379e4656003caee346d9c4eb23256d73409271291a7Brian Paul      FREE(glxCtx);
2380e4656003caee346d9c4eb23256d73409271291a7Brian Paul      return NULL;
2381e4656003caee346d9c4eb23256d73409271291a7Brian Paul   }
2382e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2383e4656003caee346d9c4eb23256d73409271291a7Brian Paul   glxCtx->xmesaContext->direct = GL_FALSE;
2384e4656003caee346d9c4eb23256d73409271291a7Brian Paul   glxCtx->glxContext.isDirect = GL_FALSE;
2385e4656003caee346d9c4eb23256d73409271291a7Brian Paul   glxCtx->glxContext.currentDpy = dpy;
2386e4656003caee346d9c4eb23256d73409271291a7Brian Paul   glxCtx->glxContext.xid = (XID) glxCtx;  /* self pointer */
2387e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2388e4656003caee346d9c4eb23256d73409271291a7Brian Paul   assert((void *) glxCtx == (void *) &(glxCtx->glxContext));
2389e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2390e4656003caee346d9c4eb23256d73409271291a7Brian Paul   return (GLXContext) glxCtx;
2391783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2392783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2393e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2394783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic XVisualInfo *
2395783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetVisualFromFBConfigSGIX(Display *dpy, GLXFBConfigSGIX config)
2396783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
23973265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   return Fake_glXGetVisualFromFBConfig(dpy, config);
2398783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2399783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2400e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2401783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXFBConfigSGIX
2402783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetFBConfigFromVisualSGIX(Display *dpy, XVisualInfo *vis)
2403426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2404e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaVisual xmvis = find_glx_visual(dpy, vis);
2405e4656003caee346d9c4eb23256d73409271291a7Brian Paul   if (!xmvis) {
2406e4656003caee346d9c4eb23256d73409271291a7Brian Paul      /* This visual wasn't found with glXChooseVisual() */
2407e4656003caee346d9c4eb23256d73409271291a7Brian Paul      xmvis = create_glx_visual(dpy, vis);
2408e4656003caee346d9c4eb23256d73409271291a7Brian Paul   }
2409e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2410e4656003caee346d9c4eb23256d73409271291a7Brian Paul   return (GLXFBConfigSGIX) xmvis;
2411426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2412426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2413426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2414426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2415b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_pbuffer ***/
2416783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2417783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXPbufferSGIX
24183265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian PaulFake_glXCreateGLXPbufferSGIX(Display *dpy, GLXFBConfigSGIX config,
24193265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul                             unsigned int width, unsigned int height,
24203265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul                             int *attribList)
2421783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
24223265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   XMesaVisual xmvis = (XMesaVisual) config;
24233265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   XMesaBuffer xmbuf;
24243265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   const int *attrib;
24253265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   GLboolean useLargest = GL_FALSE, preserveContents = GL_FALSE;
24263265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul
2427783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
24283265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul
242911b3028e7ba2fc3b985ab84d7227c290608f83f6Brian Paul   for (attrib = attribList; attrib && *attrib; attrib++) {
24303265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      switch (*attrib) {
24313265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         case GLX_PRESERVED_CONTENTS_SGIX:
24323265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            attrib++;
24333265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            preserveContents = *attrib; /* ignored */
24343265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            break;
24353265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         case GLX_LARGEST_PBUFFER_SGIX:
24363265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            attrib++;
24373265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            useLargest = *attrib; /* ignored */
24383265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            break;
24393265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         default:
24403265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            return 0;
24413265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      }
24423265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   }
24433265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul
2444b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul   /* not used at this time */
2445b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul   (void) useLargest;
2446b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul   (void) preserveContents;
2447b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul
24483265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   xmbuf = XMesaCreatePBuffer( xmvis, 0, width, height);
2449e4656003caee346d9c4eb23256d73409271291a7Brian Paul   /* A GLXPbuffer handle must be an X Drawable because that's what
2450e4656003caee346d9c4eb23256d73409271291a7Brian Paul    * glXMakeCurrent takes.
2451e4656003caee346d9c4eb23256d73409271291a7Brian Paul    */
2452e4b2356c07d31fbeeabb13b2fb47db703b473080Brian Paul   return (GLXPbuffer) xmbuf->frontxrb->pixmap;
2453783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2454783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2455e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2456783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2457783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXDestroyGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf)
2458783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2459e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaBuffer xmbuf = XMesaFindBuffer(dpy, pbuf);
2460e4656003caee346d9c4eb23256d73409271291a7Brian Paul   if (xmbuf) {
2461e4656003caee346d9c4eb23256d73409271291a7Brian Paul      XMesaDestroyBuffer(xmbuf);
2462e4656003caee346d9c4eb23256d73409271291a7Brian Paul   }
2463783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2464783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2465e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2466783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2467783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value)
2468783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2469e4656003caee346d9c4eb23256d73409271291a7Brian Paul   const XMesaBuffer xmbuf = XMesaFindBuffer(dpy, pbuf);
2470e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2471e4656003caee346d9c4eb23256d73409271291a7Brian Paul   if (!xmbuf) {
2472e4656003caee346d9c4eb23256d73409271291a7Brian Paul      /* Generate GLXBadPbufferSGIX for bad pbuffer */
2473e4656003caee346d9c4eb23256d73409271291a7Brian Paul      return 0;
2474e4656003caee346d9c4eb23256d73409271291a7Brian Paul   }
2475e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2476e4656003caee346d9c4eb23256d73409271291a7Brian Paul   switch (attribute) {
2477e4656003caee346d9c4eb23256d73409271291a7Brian Paul      case GLX_PRESERVED_CONTENTS_SGIX:
2478e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = True;
2479e4656003caee346d9c4eb23256d73409271291a7Brian Paul         break;
2480e4656003caee346d9c4eb23256d73409271291a7Brian Paul      case GLX_LARGEST_PBUFFER_SGIX:
248129926a11b16ec7a235947d95e9a46777605dd30eBrian Paul         *value = xmbuf->mesa_buffer.Width * xmbuf->mesa_buffer.Height;
2482e4656003caee346d9c4eb23256d73409271291a7Brian Paul         break;
2483e4656003caee346d9c4eb23256d73409271291a7Brian Paul      case GLX_WIDTH_SGIX:
248429926a11b16ec7a235947d95e9a46777605dd30eBrian Paul         *value = xmbuf->mesa_buffer.Width;
2485e4656003caee346d9c4eb23256d73409271291a7Brian Paul         break;
2486e4656003caee346d9c4eb23256d73409271291a7Brian Paul      case GLX_HEIGHT_SGIX:
248729926a11b16ec7a235947d95e9a46777605dd30eBrian Paul         *value = xmbuf->mesa_buffer.Height;
2488e4656003caee346d9c4eb23256d73409271291a7Brian Paul         break;
2489e4656003caee346d9c4eb23256d73409271291a7Brian Paul      case GLX_EVENT_MASK_SGIX:
2490e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = 0;  /* XXX might be wrong */
2491e4656003caee346d9c4eb23256d73409271291a7Brian Paul         break;
2492e4656003caee346d9c4eb23256d73409271291a7Brian Paul      default:
2493e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = 0;
2494e4656003caee346d9c4eb23256d73409271291a7Brian Paul   }
2495783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2496783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2497783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2498e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2499783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2500783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXSelectEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long mask)
2501783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2502e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable);
2503e4656003caee346d9c4eb23256d73409271291a7Brian Paul   if (xmbuf) {
2504e4656003caee346d9c4eb23256d73409271291a7Brian Paul      /* Note: we'll never generate clobber events */
2505e4656003caee346d9c4eb23256d73409271291a7Brian Paul      xmbuf->selectedEvents = mask;
2506e4656003caee346d9c4eb23256d73409271291a7Brian Paul   }
2507783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2508783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2509e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2510783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2511783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetSelectedEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long *mask)
2512783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2513e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable);
2514e4656003caee346d9c4eb23256d73409271291a7Brian Paul   if (xmbuf) {
2515e4656003caee346d9c4eb23256d73409271291a7Brian Paul      *mask = xmbuf->selectedEvents;
2516e4656003caee346d9c4eb23256d73409271291a7Brian Paul   }
2517e4656003caee346d9c4eb23256d73409271291a7Brian Paul   else {
2518e4656003caee346d9c4eb23256d73409271291a7Brian Paul      *mask = 0;
2519e4656003caee346d9c4eb23256d73409271291a7Brian Paul   }
2520783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2521783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2522783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2523783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2524b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGI_cushion ***/
2525783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2526783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2527783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXCushionSGI(Display *dpy, Window win, float cushion)
2528783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2529783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2530783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) win;
2531783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) cushion;
2532783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2533783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2534783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2535783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2536b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_video_resize ***/
2537783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2538783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2539783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXBindChannelToWindowSGIX(Display *dpy, int screen, int channel , Window window)
2540783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2541783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2542783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2543783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) channel;
2544783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) window;
2545783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2546783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2547783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2548783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2549783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXChannelRectSGIX(Display *dpy, int screen, int channel, int x, int y, int w, int h)
2550783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2551783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2552783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2553783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) channel;
2554783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) x;
2555783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) y;
2556783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) w;
2557783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) h;
2558783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2559783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2560783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2561783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2562783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryChannelRectSGIX(Display *dpy, int screen, int channel, int *x, int *y, int *w, int *h)
2563783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2564783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2565783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2566783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) channel;
2567783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) x;
2568783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) y;
2569783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) w;
2570783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) h;
2571783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2572783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2573783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2574783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2575783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryChannelDeltasSGIX(Display *dpy, int screen, int channel, int *dx, int *dy, int *dw, int *dh)
2576783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2577783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2578783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2579783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) channel;
2580783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dx;
2581783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dy;
2582783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dw;
2583783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dh;
2584783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2585783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2586783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2587783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2588783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXChannelRectSyncSGIX(Display *dpy, int screen, int channel, GLenum synctype)
2589783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2590783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2591783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2592783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) channel;
2593783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) synctype;
2594783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2595783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2596783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2597783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2598783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2599b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_dmbuffer **/
2600783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2601b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#if defined(_DM_BUFFER_H_)
2602783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Bool
2603783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXAssociateDMPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer)
2604783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2605783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2606783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) pbuffer;
2607783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) params;
2608783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dmbuffer;
2609783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return False;
2610783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2611783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul#endif
2612783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2613783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2614b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_swap_group ***/
2615783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2616783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2617783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXJoinSwapGroupSGIX(Display *dpy, GLXDrawable drawable, GLXDrawable member)
2618783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2619783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2620783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) drawable;
2621783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) member;
2622783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2623783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2624783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2625783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2626b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_swap_barrier ***/
2627783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2628783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2629783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXBindSwapBarrierSGIX(Display *dpy, GLXDrawable drawable, int barrier)
2630783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2631783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2632783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) drawable;
2633783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) barrier;
2634783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2635783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2636783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Bool
2637783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryMaxSwapBarriersSGIX(Display *dpy, int screen, int *max)
2638783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2639783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2640783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2641783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) max;
2642783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return False;
2643783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2644783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2645783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2646783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2647b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SUN_get_transparent_index ***/
2648783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2649783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Status
2650783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetTransparentIndexSUN(Display *dpy, Window overlay, Window underlay, long *pTransparent)
2651783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2652783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2653783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) overlay;
2654783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) underlay;
2655783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) pTransparent;
2656783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2657783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2658783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2659783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2660783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2661b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_MESA_release_buffers ***/
2662b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul
2663783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul/*
2664783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul * Release the depth, stencil, accum buffers attached to a GLXDrawable
2665783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul * (a window or pixmap) prior to destroying the GLXDrawable.
2666783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul */
2667783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Bool
2668783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXReleaseBuffersMESA( Display *dpy, GLXDrawable d )
2669783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2670783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   XMesaBuffer b = XMesaFindBuffer(dpy, d);
2671783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   if (b) {
2672783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul      XMesaDestroyBuffer(b);
2673783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul      return True;
2674783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   }
2675783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return False;
2676783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2677783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2678783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2679783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2680b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_MESA_set_3dfx_mode ***/
2681b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul
2682783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Bool
2683783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXSet3DfxModeMESA( int mode )
2684783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2685783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return XMesaSetFXmode( mode );
2686783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2687783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2688783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2689783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
26903c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian Paul/*** GLX_NV_vertex_array range ***/
26918fefafa2200d3ea44ec46592b190654a10685b46Brian Paulstatic void *
26928fefafa2200d3ea44ec46592b190654a10685b46Brian PaulFake_glXAllocateMemoryNV( GLsizei size,
26938fefafa2200d3ea44ec46592b190654a10685b46Brian Paul                          GLfloat readFrequency,
26948fefafa2200d3ea44ec46592b190654a10685b46Brian Paul                          GLfloat writeFrequency,
26958fefafa2200d3ea44ec46592b190654a10685b46Brian Paul                          GLfloat priority )
26968fefafa2200d3ea44ec46592b190654a10685b46Brian Paul{
26978fefafa2200d3ea44ec46592b190654a10685b46Brian Paul   (void) size;
26988fefafa2200d3ea44ec46592b190654a10685b46Brian Paul   (void) readFrequency;
26998fefafa2200d3ea44ec46592b190654a10685b46Brian Paul   (void) writeFrequency;
27008fefafa2200d3ea44ec46592b190654a10685b46Brian Paul   (void) priority;
27018fefafa2200d3ea44ec46592b190654a10685b46Brian Paul   return NULL;
27028fefafa2200d3ea44ec46592b190654a10685b46Brian Paul}
27038fefafa2200d3ea44ec46592b190654a10685b46Brian Paul
27048fefafa2200d3ea44ec46592b190654a10685b46Brian Paul
27058fefafa2200d3ea44ec46592b190654a10685b46Brian Paulstatic void
27068fefafa2200d3ea44ec46592b190654a10685b46Brian PaulFake_glXFreeMemoryNV( GLvoid *pointer )
27078fefafa2200d3ea44ec46592b190654a10685b46Brian Paul{
27088fefafa2200d3ea44ec46592b190654a10685b46Brian Paul   (void) pointer;
27098fefafa2200d3ea44ec46592b190654a10685b46Brian Paul}
27108fefafa2200d3ea44ec46592b190654a10685b46Brian Paul
27118fefafa2200d3ea44ec46592b190654a10685b46Brian Paul
27123c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian Paul/*** GLX_MESA_agp_offset ***/
2713d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul
2714d6113fc20d68f5720740b89c594227d0312bab3eBrian Paulstatic GLuint
2715d6113fc20d68f5720740b89c594227d0312bab3eBrian PaulFake_glXGetAGPOffsetMESA( const GLvoid *pointer )
2716d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul{
2717d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul   (void) pointer;
2718d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul   return ~0;
2719d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul}
2720d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul
2721d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul
27227287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul/* silence warning */
2723e7b16b74bf5d13331b5a88bbbbb9096560297b63Brian Paulextern struct _glxapi_table *_mesa_GetGLXDispatchTable(void);
27247287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul
27257287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul
27267287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul/**
27277287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul * Create a new GLX API dispatch table with its function pointers
27287287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul * initialized to point to Mesa's "fake" GLX API functions.
27297287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul * Note: there's a similar function (_real_GetGLXDispatchTable) that
27307287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul * returns a new dispatch table with all pointers initalized to point
27317287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul * to "real" GLX functions (which understand GLX wire protocol, etc).
27327287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul */
27337287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulstruct _glxapi_table *
27347287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul_mesa_GetGLXDispatchTable(void)
2735426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2736426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   static struct _glxapi_table glx;
2737426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2738426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   /* be sure our dispatch table size <= libGL's table */
2739426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   {
274001915e90e6912f06d43d443a09157f7bbc96ddc5Brian Paul      GLuint size = sizeof(struct _glxapi_table) / sizeof(void *);
2741426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul      (void) size;
2742426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul      assert(_glxapi_get_dispatch_table_size() >= size);
2743426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   }
2744426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2745426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   /* initialize the whole table to no-ops */
2746426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   _glxapi_set_no_op_table(&glx);
2747426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2748426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   /* now initialize the table with the functions I implement */
2749426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.ChooseVisual = Fake_glXChooseVisual;
2750426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CopyContext = Fake_glXCopyContext;
2751426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CreateContext = Fake_glXCreateContext;
2752426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CreateGLXPixmap = Fake_glXCreateGLXPixmap;
2753426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.DestroyContext = Fake_glXDestroyContext;
2754426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.DestroyGLXPixmap = Fake_glXDestroyGLXPixmap;
2755426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.GetConfig = Fake_glXGetConfig;
2756426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   /*glx.GetCurrentContext = Fake_glXGetCurrentContext;*/
2757426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   /*glx.GetCurrentDrawable = Fake_glXGetCurrentDrawable;*/
2758426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.IsDirect = Fake_glXIsDirect;
2759426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.MakeCurrent = Fake_glXMakeCurrent;
2760426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.QueryExtension = Fake_glXQueryExtension;
2761426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.QueryVersion = Fake_glXQueryVersion;
2762426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.SwapBuffers = Fake_glXSwapBuffers;
2763426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.UseXFont = Fake_glXUseXFont;
2764426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.WaitGL = Fake_glXWaitGL;
2765426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.WaitX = Fake_glXWaitX;
2766426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2767b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_VERSION_1_1 ***/
2768426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.GetClientString = Fake_glXGetClientString;
2769426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.QueryExtensionsString = Fake_glXQueryExtensionsString;
2770426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.QueryServerString = Fake_glXQueryServerString;
2771426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2772b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_VERSION_1_2 ***/
2773426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   /*glx.GetCurrentDisplay = Fake_glXGetCurrentDisplay;*/
2774426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2775b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_VERSION_1_3 ***/
2776426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.ChooseFBConfig = Fake_glXChooseFBConfig;
2777426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CreateNewContext = Fake_glXCreateNewContext;
2778426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CreatePbuffer = Fake_glXCreatePbuffer;
2779426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CreatePixmap = Fake_glXCreatePixmap;
2780426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CreateWindow = Fake_glXCreateWindow;
2781426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.DestroyPbuffer = Fake_glXDestroyPbuffer;
2782426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.DestroyPixmap = Fake_glXDestroyPixmap;
2783426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.DestroyWindow = Fake_glXDestroyWindow;
2784426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   /*glx.GetCurrentReadDrawable = Fake_glXGetCurrentReadDrawable;*/
2785426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.GetFBConfigAttrib = Fake_glXGetFBConfigAttrib;
278671dea349d2be623b7819389428b0d6a124e8d184Brian Paul   glx.GetFBConfigs = Fake_glXGetFBConfigs;
2787426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.GetSelectedEvent = Fake_glXGetSelectedEvent;
2788426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.GetVisualFromFBConfig = Fake_glXGetVisualFromFBConfig;
2789426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.MakeContextCurrent = Fake_glXMakeContextCurrent;
2790426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.QueryContext = Fake_glXQueryContext;
2791426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.QueryDrawable = Fake_glXQueryDrawable;
2792426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.SelectEvent = Fake_glXSelectEvent;
2793426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2794b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGI_swap_control ***/
2795783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.SwapIntervalSGI = Fake_glXSwapIntervalSGI;
2796783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2797b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGI_video_sync ***/
2798426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.GetVideoSyncSGI = Fake_glXGetVideoSyncSGI;
2799426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.WaitVideoSyncSGI = Fake_glXWaitVideoSyncSGI;
2800426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2801b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGI_make_current_read ***/
2802783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.MakeCurrentReadSGI = Fake_glXMakeCurrentReadSGI;
28037cf50e137da497a590ec9001a9918972a6246142Brian Paul   /*glx.GetCurrentReadDrawableSGI = Fake_glXGetCurrentReadDrawableSGI;*/
2804783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2805b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_video_source ***/
2806b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#if defined(_VL_H)
2807783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.CreateGLXVideoSourceSGIX = Fake_glXCreateGLXVideoSourceSGIX;
2808783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.DestroyGLXVideoSourceSGIX = Fake_glXDestroyGLXVideoSourceSGIX;
2809783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul#endif
2810783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2811b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_EXT_import_context ***/
2812783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.FreeContextEXT = Fake_glXFreeContextEXT;
2813783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.GetContextIDEXT = Fake_glXGetContextIDEXT;
28147cf50e137da497a590ec9001a9918972a6246142Brian Paul   /*glx.GetCurrentDisplayEXT = Fake_glXGetCurrentDisplayEXT;*/
2815783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.ImportContextEXT = Fake_glXImportContextEXT;
2816783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.QueryContextInfoEXT = Fake_glXQueryContextInfoEXT;
28174536021a62e02fceaa6e8eb889b0f61743109cc4Brian Paul
2818b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGIX_fbconfig ***/
2819783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.GetFBConfigAttribSGIX = Fake_glXGetFBConfigAttribSGIX;
2820783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.ChooseFBConfigSGIX = Fake_glXChooseFBConfigSGIX;
2821783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.CreateGLXPixmapWithConfigSGIX = Fake_glXCreateGLXPixmapWithConfigSGIX;
2822783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.CreateContextWithConfigSGIX = Fake_glXCreateContextWithConfigSGIX;
2823783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.GetVisualFromFBConfigSGIX = Fake_glXGetVisualFromFBConfigSGIX;
2824783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.GetFBConfigFromVisualSGIX = Fake_glXGetFBConfigFromVisualSGIX;
2825783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2826b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGIX_pbuffer ***/
2827783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.CreateGLXPbufferSGIX = Fake_glXCreateGLXPbufferSGIX;
2828783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.DestroyGLXPbufferSGIX = Fake_glXDestroyGLXPbufferSGIX;
2829783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.QueryGLXPbufferSGIX = Fake_glXQueryGLXPbufferSGIX;
2830783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.SelectEventSGIX = Fake_glXSelectEventSGIX;
2831783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.GetSelectedEventSGIX = Fake_glXGetSelectedEventSGIX;
2832783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2833b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGI_cushion ***/
2834783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.CushionSGI = Fake_glXCushionSGI;
2835783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2836b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGIX_video_resize ***/
2837783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.BindChannelToWindowSGIX = Fake_glXBindChannelToWindowSGIX;
2838783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.ChannelRectSGIX = Fake_glXChannelRectSGIX;
2839783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.QueryChannelRectSGIX = Fake_glXQueryChannelRectSGIX;
2840783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.QueryChannelDeltasSGIX = Fake_glXQueryChannelDeltasSGIX;
2841783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.ChannelRectSyncSGIX = Fake_glXChannelRectSyncSGIX;
2842783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2843b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGIX_dmbuffer **/
2844b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#if defined(_DM_BUFFER_H_)
2845783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.AssociateDMPbufferSGIX = NULL;
2846783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul#endif
2847783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2848b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGIX_swap_group ***/
2849783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.JoinSwapGroupSGIX = Fake_glXJoinSwapGroupSGIX;
2850783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2851b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGIX_swap_barrier ***/
2852783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.BindSwapBarrierSGIX = Fake_glXBindSwapBarrierSGIX;
2853783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.QueryMaxSwapBarriersSGIX = Fake_glXQueryMaxSwapBarriersSGIX;
2854783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2855b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SUN_get_transparent_index ***/
2856783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.GetTransparentIndexSUN = Fake_glXGetTransparentIndexSUN;
28574536021a62e02fceaa6e8eb889b0f61743109cc4Brian Paul
2858b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_MESA_copy_sub_buffer ***/
2859426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CopySubBufferMESA = Fake_glXCopySubBufferMESA;
2860426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2861b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_MESA_release_buffers ***/
2862426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.ReleaseBuffersMESA = Fake_glXReleaseBuffersMESA;
2863426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2864b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_MESA_pixmap_colormap ***/
2865426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CreateGLXPixmapMESA = Fake_glXCreateGLXPixmapMESA;
2866426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2867b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_MESA_set_3dfx_mode ***/
2868426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.Set3DfxModeMESA = Fake_glXSet3DfxModeMESA;
2869426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2870d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul   /*** GLX_NV_vertex_array_range ***/
28718fefafa2200d3ea44ec46592b190654a10685b46Brian Paul   glx.AllocateMemoryNV = Fake_glXAllocateMemoryNV;
28728fefafa2200d3ea44ec46592b190654a10685b46Brian Paul   glx.FreeMemoryNV = Fake_glXFreeMemoryNV;
28738fefafa2200d3ea44ec46592b190654a10685b46Brian Paul
2874d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul   /*** GLX_MESA_agp_offset ***/
2875d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul   glx.GetAGPOffsetMESA = Fake_glXGetAGPOffsetMESA;
2876d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul
2877426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   return &glx;
2878426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2879