fakeglx.c revision 9e4e3adcf82a72e9a74f21b492fbf5552ebfd47f
1afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
2afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Mesa 3-D graphics library
39e4e3adcf82a72e9a74f21b492fbf5552ebfd47fBrian Paul * Version:  6.5
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:
1095dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul            if (!fbConfig)
1096dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul               return NULL;
10973265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            parselist++;
10983265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            if (*parselist == GLX_RGBA_BIT) {
10993265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul               rgb_flag = GL_TRUE;
11003265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            }
11013265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            else if (*parselist == GLX_COLOR_INDEX_BIT) {
11023265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul               rgb_flag = GL_FALSE;
11033265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            }
11043265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            else if (*parselist == 0) {
11053265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul               rgb_flag = GL_TRUE;
11063265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            }
11073265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            parselist++;
11083265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            break;
11093265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         case GLX_DRAWABLE_TYPE:
1110dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul            if (!fbConfig)
1111dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul               return NULL;
11123265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            parselist++;
11133265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            if (*parselist & ~(GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT)) {
11143265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul               return NULL; /* bad bit */
11153265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            }
11163265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            parselist++;
11173265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            break;
11183a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul         case GLX_FBCONFIG_ID:
1119dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul            if (!fbConfig)
1120dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul               return NULL;
11213a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul            parselist++;
1122dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul            desiredVisualID = *parselist++;
1123dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul            break;
1124dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul         case GLX_X_RENDERABLE:
1125dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul            if (!fbConfig)
1126dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul               return NULL;
1127dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul            parselist += 2;
1128dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul            /* ignore */
11293a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul            break;
11303265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul
1131afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 case None:
11323a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul            /* end of list */
1133afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    break;
11343265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul
1135afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 default:
1136afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    /* undefined attribute */
11372ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul            _mesa_warning(NULL, "unexpected attrib 0x%x in choose_visual()",
11382ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul                          *parselist);
1139afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    return NULL;
1140afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
1141afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1142afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1143b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul   (void) caveat;
1144b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul
1145afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /*
1146afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * Since we're only simulating the GLX extension this function will never
1147afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * find any real GL visuals.  Instead, all we can do is try to find an RGB
1148afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * or CI visual of appropriate depth.  Other requested attributes such as
1149afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * double buffering, depth buffer, etc. will be associated with the X
1150afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    * visual and stored in the VisualTable[].
1151afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg    */
11523a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul   if (desiredVisualID != -1) {
11533a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul      /* try to get a specific visual, by visualID */
11543a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul      XVisualInfo temp;
11553a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul      int n;
11563a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul      temp.visualid = desiredVisualID;
11573a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul      temp.screen = screen;
11583a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul      vis = XGetVisualInfo(dpy, VisualIDMask | VisualScreenMask, &temp, &n);
11593a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul      if (vis) {
11603a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul         /* give the visual some useful GLX attributes */
11613a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul         double_flag = GL_TRUE;
11623a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul         if (vis->depth > 8)
11633a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul            rgb_flag = GL_TRUE;
1164dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul         depth_size = default_depth_bits();
11653a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul         stencil_size = STENCIL_BITS;
11663a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul         /* XXX accum??? */
11673a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul      }
11683a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul   }
11693a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul   else if (level==0) {
1170afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* normal color planes */
1171afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (rgb_flag) {
1172afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* Get an RGB visual */
1173afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         int min_rgb = min_red + min_green + min_blue;
1174afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         if (min_rgb>1 && min_rgb<8) {
1175afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* a special case to be sure we can get a monochrome visual */
1176afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            min_rgb = 1;
1177afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
1178afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         vis = choose_x_visual( dpy, screen, rgb_flag, min_rgb, visual_type );
1179afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
1180afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      else {
1181afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* Get a color index visual */
1182afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         vis = choose_x_visual( dpy, screen, rgb_flag, min_ci, visual_type );
1183b2e460018375f699198073a6167e0ee96ba1d267Brian Paul         accumRedSize = accumGreenSize = accumBlueSize = accumAlphaSize = 0;
1184afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
1185afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1186afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else {
1187afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* over/underlay planes */
118842f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      if (rgb_flag) {
118942f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         /* rgba overlay */
119042f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         int min_rgb = min_red + min_green + min_blue;
119142f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         if (min_rgb>1 && min_rgb<8) {
119242f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul            /* a special case to be sure we can get a monochrome visual */
119342f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul            min_rgb = 1;
119442f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         }
119542f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         vis = choose_x_overlay_visual( dpy, screen, rgb_flag, level,
119642f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul                              trans_type, trans_value, min_rgb, visual_type );
119742f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      }
119842f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      else {
119942f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         /* color index overlay */
120042f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul         vis = choose_x_overlay_visual( dpy, screen, rgb_flag, level,
120142f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul                              trans_type, trans_value, min_ci, visual_type );
120242f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul      }
1203afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1204afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1205afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (vis) {
1206ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul      /* Note: we're not exactly obeying the glXChooseVisual rules here.
1207ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul       * When GLX_DEPTH_SIZE = 1 is specified we're supposed to choose the
12082c7e6334ec81c2fab2cce9e0fe52cd30256e37eaBrian Paul       * largest depth buffer size, which is 32bits/value.  Instead, we
1209ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul       * return 16 to maintain performance with earlier versions of Mesa.
1210ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul       */
12112c7e6334ec81c2fab2cce9e0fe52cd30256e37eaBrian Paul      if (depth_size > 24)
12129e4e3adcf82a72e9a74f21b492fbf5552ebfd47fBrian Paul         depth_size = 32;
1213ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul      else if (depth_size > 16)
1214ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul         depth_size = 24;
1215dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul      else if (depth_size > 0) {
1216dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul         depth_size = default_depth_bits();
1217dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul      }
12182c7e6334ec81c2fab2cce9e0fe52cd30256e37eaBrian Paul
1219ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul      /* we only support one size of stencil and accum buffers. */
1220ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul      if (stencil_size > 0)
1221ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul         stencil_size = STENCIL_BITS;
12226d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul      if (accumRedSize > 0 || accumGreenSize > 0 || accumBlueSize > 0 ||
12236d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul          accumAlphaSize > 0) {
1224b2e460018375f699198073a6167e0ee96ba1d267Brian Paul         accumRedSize = ACCUM_BITS;
1225b2e460018375f699198073a6167e0ee96ba1d267Brian Paul         accumGreenSize = ACCUM_BITS;
1226b2e460018375f699198073a6167e0ee96ba1d267Brian Paul         accumBlueSize = ACCUM_BITS;
12276d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul         accumAlphaSize = alpha_flag ? ACCUM_BITS : 0;
12286d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul      }
12296d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul
12303265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      xmvis = save_glx_visual( dpy, vis, rgb_flag, alpha_flag, double_flag,
12313265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul                               stereo_flag, depth_size, stencil_size,
12323265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul                               accumRedSize, accumGreenSize,
1233894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul                               accumBlueSize, accumAlphaSize, level, numAux );
1234afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1235afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
12363265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   return xmvis;
1237afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1238afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1239afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
12403265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paulstatic XVisualInfo *
12413265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian PaulFake_glXChooseVisual( Display *dpy, int screen, int *list )
12423265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul{
1243b3063ac398b72e6a4fd2015d4e220495b9779294Brian Paul   XMesaVisual xmvis = choose_visual(dpy, screen, list, GL_FALSE);
1244f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   if (xmvis) {
1245f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul#if 0
1246f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      return xmvis->vishandle;
1247f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul#else
1248f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      /* create a new vishandle - the cached one may be stale */
12494039cb8ca82d59451a6de8902fe35e693cdca3baBrian Paul      xmvis->vishandle = (XVisualInfo *) _mesa_malloc(sizeof(XVisualInfo));
1250f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      if (xmvis->vishandle) {
1251f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul         _mesa_memcpy(xmvis->vishandle, xmvis->visinfo, sizeof(XVisualInfo));
1252f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      }
12533265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      return xmvis->vishandle;
1254f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul#endif
1255f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   }
12563265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   else
12573265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      return NULL;
12583265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul}
1259afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1260afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1261426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXContext
1262426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateContext( Display *dpy, XVisualInfo *visinfo,
1263426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                       GLXContext share_list, Bool direct )
1264afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1265e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaVisual xmvis;
12667cf50e137da497a590ec9001a9918972a6246142Brian Paul   struct fake_glx_context *glxCtx;
12675e1680ce1d8296b2182e8909856927bbeddf3b95Brian Paul   struct fake_glx_context *shareCtx = (struct fake_glx_context *) share_list;
126899aab341998e84d9fa208c525cae8021b3845812Brian Paul
126999aab341998e84d9fa208c525cae8021b3845812Brian Paul   if (!dpy || !visinfo)
127099aab341998e84d9fa208c525cae8021b3845812Brian Paul      return 0;
127199aab341998e84d9fa208c525cae8021b3845812Brian Paul
12727cf50e137da497a590ec9001a9918972a6246142Brian Paul   glxCtx = CALLOC_STRUCT(fake_glx_context);
12737cf50e137da497a590ec9001a9918972a6246142Brian Paul   if (!glxCtx)
12747cf50e137da497a590ec9001a9918972a6246142Brian Paul      return 0;
1275afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1276afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* deallocate unused windows/buffers */
1277afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaGarbageCollect();
1278afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1279e4656003caee346d9c4eb23256d73409271291a7Brian Paul   xmvis = find_glx_visual( dpy, visinfo );
1280e4656003caee346d9c4eb23256d73409271291a7Brian Paul   if (!xmvis) {
1281afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /* This visual wasn't found with glXChooseVisual() */
1282e4656003caee346d9c4eb23256d73409271291a7Brian Paul      xmvis = create_glx_visual( dpy, visinfo );
1283e4656003caee346d9c4eb23256d73409271291a7Brian Paul      if (!xmvis) {
1284afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* unusable visual */
12857cf50e137da497a590ec9001a9918972a6246142Brian Paul         FREE(glxCtx);
1286afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return NULL;
1287afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
1288afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1289afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1290e4656003caee346d9c4eb23256d73409271291a7Brian Paul   glxCtx->xmesaContext = XMesaCreateContext(xmvis,
12915e1680ce1d8296b2182e8909856927bbeddf3b95Brian Paul                                   shareCtx ? shareCtx->xmesaContext : NULL);
12927cf50e137da497a590ec9001a9918972a6246142Brian Paul   if (!glxCtx->xmesaContext) {
12937cf50e137da497a590ec9001a9918972a6246142Brian Paul      FREE(glxCtx);
12947cf50e137da497a590ec9001a9918972a6246142Brian Paul      return NULL;
1295afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
12967cf50e137da497a590ec9001a9918972a6246142Brian Paul
12977cf50e137da497a590ec9001a9918972a6246142Brian Paul   glxCtx->xmesaContext->direct = GL_FALSE;
12987cf50e137da497a590ec9001a9918972a6246142Brian Paul   glxCtx->glxContext.isDirect = GL_FALSE;
12997cf50e137da497a590ec9001a9918972a6246142Brian Paul   glxCtx->glxContext.currentDpy = dpy;
13007cf50e137da497a590ec9001a9918972a6246142Brian Paul   glxCtx->glxContext.xid = (XID) glxCtx;  /* self pointer */
13017cf50e137da497a590ec9001a9918972a6246142Brian Paul
13027cf50e137da497a590ec9001a9918972a6246142Brian Paul   assert((void *) glxCtx == (void *) &(glxCtx->glxContext));
13037cf50e137da497a590ec9001a9918972a6246142Brian Paul
13047cf50e137da497a590ec9001a9918972a6246142Brian Paul   return (GLXContext) glxCtx;
1305afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1306afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1307afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
13087cf50e137da497a590ec9001a9918972a6246142Brian Paul/* XXX these may have to be removed due to thread-safety issues. */
1309afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic GLXContext MakeCurrent_PrevContext = 0;
1310086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic GLXDrawable MakeCurrent_PrevDrawable = 0;
1311086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic GLXDrawable MakeCurrent_PrevReadable = 0;
1312086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic XMesaBuffer MakeCurrent_PrevDrawBuffer = 0;
1313086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic XMesaBuffer MakeCurrent_PrevReadBuffer = 0;
1314afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
13157cf50e137da497a590ec9001a9918972a6246142Brian Paul
1316086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul/* GLX 1.3 and later */
1317426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool
1318426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXMakeContextCurrent( Display *dpy, GLXDrawable draw,
13197a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell                            GLXDrawable read, GLXContext ctx )
1320086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul{
13217cf50e137da497a590ec9001a9918972a6246142Brian Paul   struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx;
13227cf50e137da497a590ec9001a9918972a6246142Brian Paul
13237a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell   if (ctx && draw && read) {
1324086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      XMesaBuffer drawBuffer, readBuffer;
13257cf50e137da497a590ec9001a9918972a6246142Brian Paul      XMesaContext xmctx = glxCtx->xmesaContext;
1326086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul
1327086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      /* Find the XMesaBuffer which corresponds to the GLXDrawable 'draw' */
13287a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell      if (ctx == MakeCurrent_PrevContext
13297a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell          && draw == MakeCurrent_PrevDrawable) {
1330086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         drawBuffer = MakeCurrent_PrevDrawBuffer;
1331086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      }
1332086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      else {
1333086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         drawBuffer = XMesaFindBuffer( dpy, draw );
1334086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      }
1335086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      if (!drawBuffer) {
1336086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         /* drawable must be a new window! */
13377cf50e137da497a590ec9001a9918972a6246142Brian Paul         drawBuffer = XMesaCreateWindowBuffer2( xmctx->xm_visual, draw, xmctx);
1338086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         if (!drawBuffer) {
1339086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul            /* Out of memory, or context/drawable depth mismatch */
1340086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul            return False;
1341086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         }
1342086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      }
1343086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul
1344086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      /* Find the XMesaBuffer which corresponds to the GLXDrawable 'read' */
13457a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell      if (ctx == MakeCurrent_PrevContext
1346086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul          && read == MakeCurrent_PrevReadable) {
1347086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         readBuffer = MakeCurrent_PrevReadBuffer;
1348086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      }
1349086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      else {
1350086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         readBuffer = XMesaFindBuffer( dpy, read );
1351086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      }
1352086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      if (!readBuffer) {
1353086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         /* drawable must be a new window! */
13547cf50e137da497a590ec9001a9918972a6246142Brian Paul         readBuffer = XMesaCreateWindowBuffer2(glxCtx->xmesaContext->xm_visual,
13557cf50e137da497a590ec9001a9918972a6246142Brian Paul                                               read, xmctx);
1356086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         if (!readBuffer) {
1357086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul            /* Out of memory, or context/drawable depth mismatch */
1358086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul            return False;
1359086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul         }
1360086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      }
1361086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul
13627a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell      MakeCurrent_PrevContext = ctx;
1363086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevDrawable = draw;
1364086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevReadable = read;
1365086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevDrawBuffer = drawBuffer;
1366086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevReadBuffer = readBuffer;
1367086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul
1368086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      /* Now make current! */
13697cf50e137da497a590ec9001a9918972a6246142Brian Paul      if (XMesaMakeCurrent2(xmctx, drawBuffer, readBuffer)) {
137012c1bee87fcc3a0912685bb6e83447972e5de64eBrian Paul         ((__GLXcontext *) ctx)->currentDpy = dpy;
137112c1bee87fcc3a0912685bb6e83447972e5de64eBrian Paul         ((__GLXcontext *) ctx)->currentDrawable = draw;
137212c1bee87fcc3a0912685bb6e83447972e5de64eBrian Paul         ((__GLXcontext *) ctx)->currentReadable = read;
13737cf50e137da497a590ec9001a9918972a6246142Brian Paul         return True;
13747cf50e137da497a590ec9001a9918972a6246142Brian Paul      }
13757cf50e137da497a590ec9001a9918972a6246142Brian Paul      else {
13767cf50e137da497a590ec9001a9918972a6246142Brian Paul         return False;
13777cf50e137da497a590ec9001a9918972a6246142Brian Paul      }
1378086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul   }
13797a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell   else if (!ctx && !draw && !read) {
1380086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      /* release current context w/out assigning new one. */
1381086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      XMesaMakeCurrent( NULL, NULL );
1382086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevContext = 0;
1383086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevDrawable = 0;
1384086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevReadable = 0;
1385086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevDrawBuffer = 0;
1386086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      MakeCurrent_PrevReadBuffer = 0;
1387086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      return True;
1388086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul   }
1389086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul   else {
1390086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      /* The args must either all be non-zero or all zero.
1391086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul       * This is an error.
1392086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul       */
1393086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul      return False;
1394086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul   }
1395086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul}
1396086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul
1397086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul
1398426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool
1399426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXMakeCurrent( Display *dpy, GLXDrawable drawable, GLXContext ctx )
1400426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
1401426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   return Fake_glXMakeContextCurrent( dpy, drawable, drawable, ctx );
1402426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
1403426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1404426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1405426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPixmap
1406426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateGLXPixmap( Display *dpy, XVisualInfo *visinfo, Pixmap pixmap )
1407afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1408afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaVisual v;
1409afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaBuffer b;
1410afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1411afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   v = find_glx_visual( dpy, visinfo );
1412afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (!v) {
1413afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      v = create_glx_visual( dpy, visinfo );
1414afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (!v) {
1415afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* unusable visual */
1416afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1417afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
1418afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1419afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1420afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   b = XMesaCreatePixmapBuffer( v, pixmap, 0 );
1421afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (!b) {
1422afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return 0;
1423afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1424e4b2356c07d31fbeeabb13b2fb47db703b473080Brian Paul   return b->frontxrb->pixmap;
1425afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1426afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1427afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1428b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_MESA_pixmap_colormap ***/
1429b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul
1430426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPixmap
1431426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visinfo,
1432426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                             Pixmap pixmap, Colormap cmap )
1433afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1434afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaVisual v;
1435afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaBuffer b;
1436afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1437afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   v = find_glx_visual( dpy, visinfo );
1438afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (!v) {
1439afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      v = create_glx_visual( dpy, visinfo );
1440afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      if (!v) {
1441afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* unusable visual */
1442afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1443afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      }
1444afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1445afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1446afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   b = XMesaCreatePixmapBuffer( v, pixmap, cmap );
1447afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (!b) {
1448afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return 0;
1449afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1450e4b2356c07d31fbeeabb13b2fb47db703b473080Brian Paul   return b->frontxrb->pixmap;
1451afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1452afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1453afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1454426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1455426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyGLXPixmap( Display *dpy, GLXPixmap pixmap )
1456afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1457afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaBuffer b = XMesaFindBuffer(dpy, pixmap);
1458afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (b) {
1459afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      XMesaDestroyBuffer(b);
1460afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1461367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul   else if (_mesa_getenv("MESA_DEBUG")) {
1462d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul      _mesa_warning(NULL, "Mesa: glXDestroyGLXPixmap: invalid pixmap\n");
1463afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1464afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1465afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1466afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1467426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1468426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCopyContext( Display *dpy, GLXContext src, GLXContext dst,
14693994b77bab8c62a4c1a4dffdfba233ef46662b99Brian Paul                     unsigned long mask )
1470afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
147183b820aa98931ef30fa73c72b2a96fe23885955eBrian Paul   struct fake_glx_context *fakeSrc = (struct fake_glx_context *) src;
147283b820aa98931ef30fa73c72b2a96fe23885955eBrian Paul   struct fake_glx_context *fakeDst = (struct fake_glx_context *) dst;
147383b820aa98931ef30fa73c72b2a96fe23885955eBrian Paul   XMesaContext xm_src = fakeSrc->xmesaContext;
147483b820aa98931ef30fa73c72b2a96fe23885955eBrian Paul   XMesaContext xm_dst = fakeDst->xmesaContext;
1475afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
14761e24d3318df57b36e3b68695ff64b4b8bd822c9eBrian Paul   _mesa_copy_context( &(xm_src->mesa), &(xm_dst->mesa), (GLuint) mask );
1477afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1478afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1479afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1480426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool
1481426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryExtension( Display *dpy, int *errorb, int *event )
1482afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1483afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* Mesa's GLX isn't really an X extension but we try to act like one. */
1484afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
1485afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) errorb;
1486afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) event;
1487afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return True;
1488afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1489afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1490afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1491e7b16b74bf5d13331b5a88bbbbb9096560297b63Brian Paulextern void _kw_ungrab_all( Display *dpy );
1492afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgvoid _kw_ungrab_all( Display *dpy )
1493afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1494afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XUngrabPointer( dpy, CurrentTime );
1495afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XUngrabKeyboard( dpy, CurrentTime );
1496afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1497afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1498afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1499426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1500426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyContext( Display *dpy, GLXContext ctx )
1501afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
15027cf50e137da497a590ec9001a9918972a6246142Brian Paul   struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx;
1503afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
1504afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   MakeCurrent_PrevContext = 0;
1505afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   MakeCurrent_PrevDrawable = 0;
1506086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul   MakeCurrent_PrevReadable = 0;
1507086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul   MakeCurrent_PrevDrawBuffer = 0;
1508086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul   MakeCurrent_PrevReadBuffer = 0;
15097cf50e137da497a590ec9001a9918972a6246142Brian Paul   XMesaDestroyContext( glxCtx->xmesaContext );
1510afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaGarbageCollect();
1511afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1512afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1513afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1514426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool
1515426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXIsDirect( Display *dpy, GLXContext ctx )
1516afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
15177cf50e137da497a590ec9001a9918972a6246142Brian Paul   struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx;
1518afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
15197cf50e137da497a590ec9001a9918972a6246142Brian Paul   return glxCtx->xmesaContext->direct;
1520afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1521afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1522afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1523afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1524426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1525426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXSwapBuffers( Display *dpy, GLXDrawable drawable )
1526afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1527afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaBuffer buffer = XMesaFindBuffer( dpy, drawable );
1528afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1529afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (buffer) {
1530afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      XMesaSwapBuffers(buffer);
1531afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1532367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul   else if (_mesa_getenv("MESA_DEBUG")) {
1533ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul      _mesa_warning(NULL, "glXSwapBuffers: invalid drawable 0x%x\n",
1534ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul                    (int) drawable);
1535afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1536afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1537afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1538afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
15394c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul
1540b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_MESA_copy_sub_buffer ***/
1541b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul
1542426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1543426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCopySubBufferMESA( Display *dpy, GLXDrawable drawable,
1544426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                           int x, int y, int width, int height )
1545afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1546afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaBuffer buffer = XMesaFindBuffer( dpy, drawable );
1547afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (buffer) {
1548afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      XMesaCopySubBuffer(buffer, x, y, width, height);
1549afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1550367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul   else if (_mesa_getenv("MESA_DEBUG")) {
1551d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul      _mesa_warning(NULL, "Mesa: glXCopySubBufferMESA: invalid drawable\n");
1552afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1553afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1554afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1555afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1556426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool
1557426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryVersion( Display *dpy, int *maj, int *min )
1558afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1559afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
1560afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* Return GLX version, not Mesa version */
156178fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul   assert(CLIENT_MAJOR_VERSION == SERVER_MAJOR_VERSION);
156278fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul   *maj = CLIENT_MAJOR_VERSION;
156378fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul   *min = MIN2( CLIENT_MINOR_VERSION, SERVER_MINOR_VERSION );
1564afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return True;
1565afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1566afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1567afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1568afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
1569afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Query the GLX attributes of the given XVisualInfo.
1570afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
1571426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int
1572e4656003caee346d9c4eb23256d73409271291a7Brian Paulget_config( XMesaVisual xmvis, int attrib, int *value, GLboolean fbconfig )
1573afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1574e4656003caee346d9c4eb23256d73409271291a7Brian Paul   ASSERT(xmvis);
1575afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   switch(attrib) {
1576afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_USE_GL:
15771f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul         if (fbconfig)
15781f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul            return GLX_BAD_ATTRIBUTE;
1579afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         *value = (int) True;
1580afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1581afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_BUFFER_SIZE:
1582e4656003caee346d9c4eb23256d73409271291a7Brian Paul	 *value = xmvis->visinfo->depth;
1583afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1584afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_LEVEL:
1585304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick	 *value = xmvis->mesa_visual.level;
1586afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1587afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_RGBA:
15881f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul         if (fbconfig)
15891f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul            return GLX_BAD_ATTRIBUTE;
1590e4656003caee346d9c4eb23256d73409271291a7Brian Paul	 if (xmvis->mesa_visual.rgbMode) {
1591afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    *value = True;
1592afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 }
1593afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 else {
1594afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    *value = False;
1595afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 }
1596afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1597afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_DOUBLEBUFFER:
1598e4656003caee346d9c4eb23256d73409271291a7Brian Paul	 *value = (int) xmvis->mesa_visual.doubleBufferMode;
1599afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1600afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_STEREO:
1601e4656003caee346d9c4eb23256d73409271291a7Brian Paul	 *value = (int) xmvis->mesa_visual.stereoMode;
1602afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1603afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_AUX_BUFFERS:
1604894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul	 *value = xmvis->mesa_visual.numAuxBuffers;
1605afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1606afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_RED_SIZE:
1607e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = xmvis->mesa_visual.redBits;
1608afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1609afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_GREEN_SIZE:
1610e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = xmvis->mesa_visual.greenBits;
1611afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1612afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_BLUE_SIZE:
1613e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = xmvis->mesa_visual.blueBits;
1614afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1615afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_ALPHA_SIZE:
1616e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = xmvis->mesa_visual.alphaBits;
1617afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1618afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_DEPTH_SIZE:
1619e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = xmvis->mesa_visual.depthBits;
1620afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1621afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_STENCIL_SIZE:
1622e4656003caee346d9c4eb23256d73409271291a7Brian Paul	 *value = xmvis->mesa_visual.stencilBits;
1623afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1624afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_ACCUM_RED_SIZE:
1625e4656003caee346d9c4eb23256d73409271291a7Brian Paul	 *value = xmvis->mesa_visual.accumRedBits;
1626b2e460018375f699198073a6167e0ee96ba1d267Brian Paul	 return 0;
1627afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_ACCUM_GREEN_SIZE:
1628e4656003caee346d9c4eb23256d73409271291a7Brian Paul	 *value = xmvis->mesa_visual.accumGreenBits;
1629b2e460018375f699198073a6167e0ee96ba1d267Brian Paul	 return 0;
1630afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_ACCUM_BLUE_SIZE:
1631e4656003caee346d9c4eb23256d73409271291a7Brian Paul	 *value = xmvis->mesa_visual.accumBlueBits;
1632afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1633afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_ACCUM_ALPHA_SIZE:
1634e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = xmvis->mesa_visual.accumAlphaBits;
1635afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return 0;
1636afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1637afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /*
1638afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg       * GLX_EXT_visual_info extension
1639afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg       */
1640afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_X_VISUAL_TYPE_EXT:
1641e4656003caee346d9c4eb23256d73409271291a7Brian Paul         switch (xmvis->visinfo->CLASS) {
1642afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case StaticGray:   *value = GLX_STATIC_GRAY_EXT;   return 0;
1643afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case GrayScale:    *value = GLX_GRAY_SCALE_EXT;    return 0;
1644afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case StaticColor:  *value = GLX_STATIC_GRAY_EXT;   return 0;
1645afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case PseudoColor:  *value = GLX_PSEUDO_COLOR_EXT;  return 0;
1646afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case TrueColor:    *value = GLX_TRUE_COLOR_EXT;    return 0;
1647afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            case DirectColor:  *value = GLX_DIRECT_COLOR_EXT;  return 0;
1648afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
1649afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1650afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_TRANSPARENT_TYPE_EXT:
1651304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick         if (xmvis->mesa_visual.level==0) {
1652afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* normal planes */
1653afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            *value = GLX_NONE_EXT;
1654afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
1655304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick         else if (xmvis->mesa_visual.level>0) {
1656afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* overlay */
1657e4656003caee346d9c4eb23256d73409271291a7Brian Paul            if (xmvis->mesa_visual.rgbMode) {
1658afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               *value = GLX_TRANSPARENT_RGB_EXT;
1659afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
1660afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            else {
1661afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               *value = GLX_TRANSPARENT_INDEX_EXT;
1662afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
1663afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
1664304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick         else if (xmvis->mesa_visual.level<0) {
1665afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* underlay */
1666afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            *value = GLX_NONE_EXT;
1667afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
1668afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1669afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_TRANSPARENT_INDEX_VALUE_EXT:
1670afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         {
1671e4656003caee346d9c4eb23256d73409271291a7Brian Paul            int pixel = transparent_pixel( xmvis );
1672afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            if (pixel>=0) {
1673afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg               *value = pixel;
1674afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            }
1675afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg            /* else undefined */
1676afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         }
1677afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1678afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_TRANSPARENT_RED_VALUE_EXT:
1679afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* undefined */
1680afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1681afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_TRANSPARENT_GREEN_VALUE_EXT:
1682afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* undefined */
1683afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1684afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_TRANSPARENT_BLUE_VALUE_EXT:
1685afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* undefined */
1686afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1687afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_TRANSPARENT_ALPHA_VALUE_EXT:
1688afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         /* undefined */
1689afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return 0;
1690afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1691afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      /*
1692b2e460018375f699198073a6167e0ee96ba1d267Brian Paul       * GLX_EXT_visual_info extension
1693b2e460018375f699198073a6167e0ee96ba1d267Brian Paul       */
1694b2e460018375f699198073a6167e0ee96ba1d267Brian Paul      case GLX_VISUAL_CAVEAT_EXT:
1695fc68be6b111473a0bf8f991468f973bb9dd275f4Brian Paul         /* test for zero, just in case */
1696304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick         if (xmvis->mesa_visual.visualRating > 0)
1697304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick            *value = xmvis->mesa_visual.visualRating;
1698962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul         else
1699962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul            *value = GLX_NONE_EXT;
1700962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul         return 0;
1701b2e460018375f699198073a6167e0ee96ba1d267Brian Paul
1702b2e460018375f699198073a6167e0ee96ba1d267Brian Paul      /*
170366ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul       * GLX_ARB_multisample
1704afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg       */
170566ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul      case GLX_SAMPLE_BUFFERS_ARB:
17063265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         *value = 0;
17073265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         return 0;
170866ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul      case GLX_SAMPLES_ARB:
17093265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         *value = 0;
17103265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         return 0;
17113265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul
17123265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      /*
17133265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul       * For FBConfigs:
17143265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul       */
17153265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      case GLX_SCREEN_EXT:
17163265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         if (!fbconfig)
17173265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            return GLX_BAD_ATTRIBUTE;
1718e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = xmvis->visinfo->screen;
17193265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         break;
17203265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      case GLX_DRAWABLE_TYPE: /*SGIX too */
17213265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         if (!fbconfig)
17223265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            return GLX_BAD_ATTRIBUTE;
17233265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         *value = GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT;
17243265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         break;
17253265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      case GLX_RENDER_TYPE_SGIX:
17263265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         if (!fbconfig)
17273265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            return GLX_BAD_ATTRIBUTE;
1728e4656003caee346d9c4eb23256d73409271291a7Brian Paul         if (xmvis->mesa_visual.rgbMode)
17293265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            *value = GLX_RGBA_BIT;
17303265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         else
17313265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            *value = GLX_COLOR_INDEX_BIT;
17323265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         break;
17333265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      case GLX_X_RENDERABLE_SGIX:
17343265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         if (!fbconfig)
17353265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            return GLX_BAD_ATTRIBUTE;
17363265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         *value = True; /* XXX really? */
17373265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         break;
17383265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      case GLX_FBCONFIG_ID_SGIX:
17393265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         if (!fbconfig)
17403265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            return GLX_BAD_ATTRIBUTE;
1741f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul         *value = xmvis->visinfo->visualid;
17423265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         break;
17433265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      case GLX_MAX_PBUFFER_WIDTH:
17443265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         if (!fbconfig)
17453265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            return GLX_BAD_ATTRIBUTE;
17463265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         /* XXX or MAX_WIDTH? */
1747f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul         *value = DisplayWidth(xmvis->display, xmvis->visinfo->screen);
17483265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         break;
17493265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      case GLX_MAX_PBUFFER_HEIGHT:
17503265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         if (!fbconfig)
17513265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            return GLX_BAD_ATTRIBUTE;
1752f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul         *value = DisplayHeight(xmvis->display, xmvis->visinfo->screen);
17533265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         break;
17543265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      case GLX_MAX_PBUFFER_PIXELS:
17553265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         if (!fbconfig)
17563265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            return GLX_BAD_ATTRIBUTE;
1757f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul         *value = DisplayWidth(xmvis->display, xmvis->visinfo->screen) *
1758f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul                  DisplayHeight(xmvis->display, xmvis->visinfo->screen);
17593265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         break;
17603265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      case GLX_VISUAL_ID:
17613265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         if (!fbconfig)
17623265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            return GLX_BAD_ATTRIBUTE;
1763f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul         *value = xmvis->visinfo->visualid;
17643265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         break;
17653265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul
1766afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      default:
1767afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return GLX_BAD_ATTRIBUTE;
1768afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
17693265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   return Success;
1770afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1771afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1772afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
17733265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paulstatic int
17743265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian PaulFake_glXGetConfig( Display *dpy, XVisualInfo *visinfo,
17753265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul                   int attrib, int *value )
17763265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul{
1777e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaVisual xmvis;
1778ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul   int k;
1779379641956d134b8dc761b6411d7c4dca8f94a092Brian Paul   if (!dpy || !visinfo)
1780a9a1c3f20f2d6aad4afc47cf2b29c5393fddb6b6Brian Paul      return GLX_BAD_ATTRIBUTE;
1781a9a1c3f20f2d6aad4afc47cf2b29c5393fddb6b6Brian Paul
1782e4656003caee346d9c4eb23256d73409271291a7Brian Paul   xmvis = find_glx_visual( dpy, visinfo );
1783e4656003caee346d9c4eb23256d73409271291a7Brian Paul   if (!xmvis) {
17843265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      /* this visual wasn't obtained with glXChooseVisual */
1785e4656003caee346d9c4eb23256d73409271291a7Brian Paul      xmvis = create_glx_visual( dpy, visinfo );
1786e4656003caee346d9c4eb23256d73409271291a7Brian Paul      if (!xmvis) {
17873265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul	 /* this visual can't be used for GL rendering */
17883265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul	 if (attrib==GLX_USE_GL) {
17893265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul	    *value = (int) False;
17903265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul	    return 0;
17913265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul	 }
17923265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul	 else {
17933265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul	    return GLX_BAD_VISUAL;
17943265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul	 }
17953265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      }
17963265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   }
17973265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul
1798ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul   k = get_config(xmvis, attrib, value, GL_FALSE);
1799ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul   return k;
18003265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul}
18013265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul
1802afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1803426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1804426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXWaitGL( void )
1805afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1806afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaContext xmesa = XMesaGetCurrentContext();
1807afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaFlush( xmesa );
1808afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1809afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1810afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1811afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1812426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
1813426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXWaitX( void )
1814afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1815afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaContext xmesa = XMesaGetCurrentContext();
1816afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   XMesaFlush( xmesa );
1817afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1818afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1819afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1820e4656003caee346d9c4eb23256d73409271291a7Brian Paulstatic const char *
1821e4656003caee346d9c4eb23256d73409271291a7Brian Paulget_extensions( void )
182243c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul{
182343c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul#ifdef FX
1824367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul   const char *fx = _mesa_getenv("MESA_GLX_FX");
182543c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul   if (fx && fx[0] != 'd') {
1826e4656003caee346d9c4eb23256d73409271291a7Brian Paul      return EXTENSIONS;
182743c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul   }
182843c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul#endif
1829e4656003caee346d9c4eb23256d73409271291a7Brian Paul   return EXTENSIONS + 23; /* skip "GLX_MESA_set_3dfx_mode" */
183043c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul}
1831afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1832afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1833afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1834afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* GLX 1.1 and later */
1835426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic const char *
1836426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryExtensionsString( Display *dpy, int screen )
1837afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
1838afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
1839afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) screen;
184043c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul   return get_extensions();
1841afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1842afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1843afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1844afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1845afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* GLX 1.1 and later */
1846426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic const char *
1847426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryServerString( Display *dpy, int screen, int name )
1848afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
184978fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul   static char version[1000];
18502ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul   _mesa_sprintf(version, "%d.%d %s",
18512ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul                 SERVER_MAJOR_VERSION, SERVER_MINOR_VERSION, MESA_GLX_VERSION);
1852afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1853afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
1854afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) screen;
1855afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1856afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   switch (name) {
1857afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_EXTENSIONS:
185843c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul         return get_extensions();
1859afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_VENDOR:
186078fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul	 return VENDOR;
1861afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_VERSION:
1862afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return version;
1863afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      default:
1864afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return NULL;
1865afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1866afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1867afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1868afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1869afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1870afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* GLX 1.1 and later */
1871426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic const char *
1872426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetClientString( Display *dpy, int name )
1873afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
187478fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul   static char version[1000];
18752ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul   _mesa_sprintf(version, "%d.%d %s", CLIENT_MAJOR_VERSION,
18762ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul                 CLIENT_MINOR_VERSION, MESA_GLX_VERSION);
1877afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1878afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   (void) dpy;
1879afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1880afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   switch (name) {
1881afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_EXTENSIONS:
188243c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul         return get_extensions();
1883afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_VENDOR:
188478fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul	 return VENDOR;
1885afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GLX_VERSION:
1886afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 return version;
1887afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      default:
1888afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         return NULL;
1889afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
1890afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
1891afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1892afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1893afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
1894426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul/*
1895426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul * GLX 1.3 and later
1896426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul */
1897426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
18987d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
1899426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int
1900426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetFBConfigAttrib( Display *dpy, GLXFBConfig config,
1901426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                           int attribute, int *value )
1902426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
19033265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   XMesaVisual v = (XMesaVisual) config;
1904426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
1905426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) config;
19067d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
19077d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (!dpy || !config || !value)
19087d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return -1;
19097d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
19103265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   return get_config(v, attribute, value, GL_TRUE);
1911426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
1912426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1913426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
19145605798e56ca6e9f968623f33b58ee7ca90594afBrian Paulstatic GLXFBConfig *
19155605798e56ca6e9f968623f33b58ee7ca90594afBrian PaulFake_glXGetFBConfigs( Display *dpy, int screen, int *nelements )
19165605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul{
19173265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   XVisualInfo *visuals, visTemplate;
19183265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   const long visMask = VisualScreenMask;
19193265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   int i;
19203265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul
19213265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   /* Get list of all X visuals */
19223265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   visTemplate.screen = screen;
19233265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   visuals = XGetVisualInfo(dpy, visMask, &visTemplate, nelements);
19243265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   if (*nelements > 0) {
19253265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      XMesaVisual *results;
19264039cb8ca82d59451a6de8902fe35e693cdca3baBrian Paul      results = (XMesaVisual *) _mesa_malloc(*nelements * sizeof(XMesaVisual));
19273265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      if (!results) {
19283265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         *nelements = 0;
19293265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         return NULL;
19303265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      }
19313265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      for (i = 0; i < *nelements; i++) {
19323265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         results[i] = create_glx_visual(dpy, visuals + i);
19333265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      }
19343265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      return (GLXFBConfig *) results;
19353265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   }
19363265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   return NULL;
19375605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul}
19385605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul
19395605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul
1940481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paulstatic GLXFBConfig *
1941481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian PaulFake_glXChooseFBConfig( Display *dpy, int screen,
1942481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul                        const int *attribList, int *nitems )
1943481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul{
1944481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul   XMesaVisual xmvis;
1945481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul
1946481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul   if (!attribList || !attribList[0]) {
1947481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul      /* return list of all configs (per GLX_SGIX_fbconfig spec) */
1948481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul      return Fake_glXGetFBConfigs(dpy, screen, nitems);
1949481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul   }
1950481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul
1951481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul   xmvis = choose_visual(dpy, screen, attribList, GL_TRUE);
1952481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul   if (xmvis) {
1953481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul      GLXFBConfig *config = (GLXFBConfig *) _mesa_malloc(sizeof(XMesaVisual));
1954481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul      if (!config) {
1955481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul         *nitems = 0;
1956481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul         return NULL;
1957481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul      }
1958481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul      *nitems = 1;
1959481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul      config[0] = (GLXFBConfig) xmvis;
1960481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul      return (GLXFBConfig *) config;
1961481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul   }
1962481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul   else {
1963481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul      *nitems = 0;
1964481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul      return NULL;
1965481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul   }
1966481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul}
1967481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul
1968481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul
1969426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic XVisualInfo *
1970426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetVisualFromFBConfig( Display *dpy, GLXFBConfig config )
1971426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
19727d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (dpy && config) {
1973f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      XMesaVisual xmvis = (XMesaVisual) config;
1974f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul#if 0
1975f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      return xmvis->vishandle;
1976f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul#else
1977f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      /* create a new vishandle - the cached one may be stale */
19784039cb8ca82d59451a6de8902fe35e693cdca3baBrian Paul      xmvis->vishandle = (XVisualInfo *) _mesa_malloc(sizeof(XVisualInfo));
1979f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      if (xmvis->vishandle) {
1980f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul         _mesa_memcpy(xmvis->vishandle, xmvis->visinfo, sizeof(XVisualInfo));
1981f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      }
1982f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      return xmvis->vishandle;
1983f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul#endif
19847d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   }
19857d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   else {
19867d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return NULL;
19877d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   }
1988426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
1989426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1990426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
1991426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXWindow
1992426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateWindow( Display *dpy, GLXFBConfig config, Window win,
1993426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                      const int *attribList )
1994426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
1995529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul   XMesaVisual xmvis = (XMesaVisual) config;
1996529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul   XMesaBuffer xmbuf;
1997529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul   if (!xmvis)
1998529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul      return 0;
1999529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul
2000529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul   xmbuf = XMesaCreateWindowBuffer2(xmvis, win, NULL);
2001529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul   if (!xmbuf)
2002529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul      return 0;
2003529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul
2004426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
20057d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   (void) attribList;  /* Ignored in GLX 1.3 */
20067d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
20077d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   return win;  /* A hack for now */
2008426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2009426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2010426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2011426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
2012426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyWindow( Display *dpy, GLXWindow window )
2013426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
20147d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   XMesaBuffer b = XMesaFindBuffer(dpy, (XMesaDrawable) window);
20157d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (b)
20167d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      XMesaDestroyBuffer(b);
20177d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   /* don't destroy X window */
2018426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2019426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2020426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
20217d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul/* XXX untested */
2022426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPixmap
2023426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreatePixmap( Display *dpy, GLXFBConfig config, Pixmap pixmap,
2024426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                      const int *attribList )
2025426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
20267d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   XMesaVisual v = (XMesaVisual) config;
20277d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   XMesaBuffer b;
20287d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
2029426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
2030426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) config;
2031426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) pixmap;
20327d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   (void) attribList;  /* Ignored in GLX 1.3 */
20337d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
20347d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (!dpy || !config || !pixmap)
20357d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return 0;
20367d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
20377d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   b = XMesaCreatePixmapBuffer( v, pixmap, 0 );
20387d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (!b) {
20397d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return 0;
20407d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   }
20417d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
20427d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   return pixmap;
2043426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2044426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2045426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2046426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
2047426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyPixmap( Display *dpy, GLXPixmap pixmap )
2048426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
20497d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   XMesaBuffer b = XMesaFindBuffer(dpy, (XMesaDrawable)pixmap);
20507d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (b)
20517d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      XMesaDestroyBuffer(b);
20527d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   /* don't destroy X pixmap */
2053426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2054426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2055426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2056426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPbuffer
2057426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreatePbuffer( Display *dpy, GLXFBConfig config,
2058426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                       const int *attribList )
2059426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
20603265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   XMesaVisual xmvis = (XMesaVisual) config;
20613265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   XMesaBuffer xmbuf;
20627d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   const int *attrib;
20637d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   int width = 0, height = 0;
20647d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   GLboolean useLargest = GL_FALSE, preserveContents = GL_FALSE;
20657d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
2066426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
20677d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
20683265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   for (attrib = attribList; *attrib; attrib++) {
20697d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      switch (*attrib) {
20707d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         case GLX_PBUFFER_WIDTH:
20713265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            attrib++;
20723265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            width = *attrib;
20737d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            break;
20747d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         case GLX_PBUFFER_HEIGHT:
20753265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            attrib++;
20763265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            height = *attrib;
20777d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            break;
20787d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         case GLX_PRESERVED_CONTENTS:
20793265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            attrib++;
20803265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            preserveContents = *attrib; /* ignored */
20817d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            break;
20827d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         case GLX_LARGEST_PBUFFER:
20833265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            attrib++;
20843265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            useLargest = *attrib; /* ignored */
20857d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            break;
20867d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         default:
20877d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul            return 0;
20887d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      }
20897d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   }
20907d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
2091b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul   /* not used at this time */
2092b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul   (void) useLargest;
2093b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul   (void) preserveContents;
2094b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul
20957d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (width == 0 || height == 0)
20967d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return 0;
20977d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
20983265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   xmbuf = XMesaCreatePBuffer( xmvis, 0, width, height);
2099e4656003caee346d9c4eb23256d73409271291a7Brian Paul   /* A GLXPbuffer handle must be an X Drawable because that's what
2100e4656003caee346d9c4eb23256d73409271291a7Brian Paul    * glXMakeCurrent takes.
2101e4656003caee346d9c4eb23256d73409271291a7Brian Paul    */
2102dd1a9f75dc1d29e3383f27aaa1cf024c83e5c8e2Brian Paul   if (xmbuf)
2103dd1a9f75dc1d29e3383f27aaa1cf024c83e5c8e2Brian Paul      return (GLXPbuffer) xmbuf->frontxrb->pixmap;
2104dd1a9f75dc1d29e3383f27aaa1cf024c83e5c8e2Brian Paul   else
2105dd1a9f75dc1d29e3383f27aaa1cf024c83e5c8e2Brian Paul      return 0;
2106426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2107426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2108426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2109426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
2110426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyPbuffer( Display *dpy, GLXPbuffer pbuf )
2111426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2112e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaBuffer b = XMesaFindBuffer(dpy, pbuf);
2113e4656003caee346d9c4eb23256d73409271291a7Brian Paul   if (b) {
2114e4656003caee346d9c4eb23256d73409271291a7Brian Paul      XMesaDestroyBuffer(b);
2115e4656003caee346d9c4eb23256d73409271291a7Brian Paul   }
2116426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2117426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2118426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2119426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
2120426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryDrawable( Display *dpy, GLXDrawable draw, int attribute,
2121426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                       unsigned int *value )
2122426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2123e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaBuffer xmbuf = XMesaFindBuffer(dpy, draw);
2124e4656003caee346d9c4eb23256d73409271291a7Brian Paul   if (!xmbuf)
2125e4656003caee346d9c4eb23256d73409271291a7Brian Paul      return;
21267d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
21277d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   switch (attribute) {
21287d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_WIDTH:
212929926a11b16ec7a235947d95e9a46777605dd30eBrian Paul         *value = xmbuf->mesa_buffer.Width;
2130e4656003caee346d9c4eb23256d73409271291a7Brian Paul         break;
21317d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_HEIGHT:
213229926a11b16ec7a235947d95e9a46777605dd30eBrian Paul         *value = xmbuf->mesa_buffer.Height;
2133e4656003caee346d9c4eb23256d73409271291a7Brian Paul         break;
21347d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_PRESERVED_CONTENTS:
2135e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = True;
2136e4656003caee346d9c4eb23256d73409271291a7Brian Paul         break;
21377d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_LARGEST_PBUFFER:
213829926a11b16ec7a235947d95e9a46777605dd30eBrian Paul         *value = xmbuf->mesa_buffer.Width * xmbuf->mesa_buffer.Height;
2139e4656003caee346d9c4eb23256d73409271291a7Brian Paul         break;
21407d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      case GLX_FBCONFIG_ID:
2141f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul         *value = xmbuf->xm_visual->visinfo->visualid;
21427d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         return;
21437d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      default:
21447d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul         return;  /* GLX_BAD_ATTRIBUTE? */
21457d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   }
2146426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2147426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2148426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2149426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXContext
2150426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateNewContext( Display *dpy, GLXFBConfig config,
2151426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                          int renderType, GLXContext shareList, Bool direct )
2152426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2153f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   struct fake_glx_context *glxCtx;
2154f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   struct fake_glx_context *shareCtx = (struct fake_glx_context *) shareList;
2155f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   XMesaVisual xmvis = (XMesaVisual) config;
21567d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
21577d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   if (!dpy || !config ||
21587d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul       (renderType != GLX_RGBA_TYPE && renderType != GLX_COLOR_INDEX_TYPE))
21597d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return 0;
21607d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
2161f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   glxCtx = CALLOC_STRUCT(fake_glx_context);
2162f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   if (!glxCtx)
2163f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      return 0;
2164f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul
2165f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   /* deallocate unused windows/buffers */
2166f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   XMesaGarbageCollect();
2167f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul
2168f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   glxCtx->xmesaContext = XMesaCreateContext(xmvis,
2169f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul                                   shareCtx ? shareCtx->xmesaContext : NULL);
2170f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   if (!glxCtx->xmesaContext) {
2171f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      FREE(glxCtx);
2172f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      return NULL;
2173f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   }
2174f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul
2175f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   glxCtx->xmesaContext->direct = GL_FALSE;
2176f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   glxCtx->glxContext.isDirect = GL_FALSE;
2177f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   glxCtx->glxContext.currentDpy = dpy;
2178f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   glxCtx->glxContext.xid = (XID) glxCtx;  /* self pointer */
2179f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul
2180f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   assert((void *) glxCtx == (void *) &(glxCtx->glxContext));
2181f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul
2182f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul   return (GLXContext) glxCtx;
2183426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2184426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2185426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2186426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int
2187426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryContext( Display *dpy, GLXContext ctx, int attribute, int *value )
2188426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2189e4656003caee346d9c4eb23256d73409271291a7Brian Paul   struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx;
2190e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaContext xmctx = glxCtx->xmesaContext;
2191e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2192426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) dpy;
2193426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   (void) ctx;
21947d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul
21957d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   switch (attribute) {
21967d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   case GLX_FBCONFIG_ID:
2197f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul      *value = xmctx->xm_visual->visinfo->visualid;
2198e4656003caee346d9c4eb23256d73409271291a7Brian Paul      break;
21997d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   case GLX_RENDER_TYPE:
2200e4656003caee346d9c4eb23256d73409271291a7Brian Paul      if (xmctx->xm_visual->mesa_visual.rgbMode)
2201e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = GLX_RGBA_BIT;
2202e4656003caee346d9c4eb23256d73409271291a7Brian Paul      else
2203e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = GLX_COLOR_INDEX_BIT;
2204e4656003caee346d9c4eb23256d73409271291a7Brian Paul      break;
22057d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   case GLX_SCREEN:
22067d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      *value = 0;
22077d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return Success;
22087d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   default:
22097d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul      return GLX_BAD_ATTRIBUTE;
22107d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul   }
2211e4656003caee346d9c4eb23256d73409271291a7Brian Paul   return 0;
2212426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2213426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2214426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2215426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
2216426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXSelectEvent( Display *dpy, GLXDrawable drawable, unsigned long mask )
2217426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2218e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable);
2219e4656003caee346d9c4eb23256d73409271291a7Brian Paul   if (xmbuf)
2220e4656003caee346d9c4eb23256d73409271291a7Brian Paul      xmbuf->selectedEvents = mask;
2221426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2222426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2223426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2224426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void
2225426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetSelectedEvent( Display *dpy, GLXDrawable drawable,
2226426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul                          unsigned long *mask )
2227426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2228e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable);
2229e4656003caee346d9c4eb23256d73409271291a7Brian Paul   if (xmbuf)
2230e4656003caee346d9c4eb23256d73409271291a7Brian Paul      *mask = xmbuf->selectedEvents;
2231e4656003caee346d9c4eb23256d73409271291a7Brian Paul   else
2232e4656003caee346d9c4eb23256d73409271291a7Brian Paul      *mask = 0;
2233426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2234b82d993b03320818f88f792a9e713f7ed491bfcbBrian Paul
2235b82d993b03320818f88f792a9e713f7ed491bfcbBrian Paul
2236b82d993b03320818f88f792a9e713f7ed491bfcbBrian Paul
2237b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGI_swap_control ***/
2238783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2239783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2240783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXSwapIntervalSGI(int interval)
2241783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2242783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) interval;
2243783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2244783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2245783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2246783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2247783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2248b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGI_video_sync ***/
2249783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2250783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2251783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetVideoSyncSGI(unsigned int *count)
2252783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2253783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) count;
2254783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2255783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2256783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2257783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2258783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count)
2259783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2260783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) divisor;
2261783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) remainder;
2262783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) count;
2263783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2264783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2265783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2266783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2267783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2268b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGI_make_current_read ***/
2269783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2270426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool
2271783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXMakeCurrentReadSGI(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx)
2272afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
2273a078d75a27b99252ede6520e24b145106ab98aa2Brian Paul   return Fake_glXMakeContextCurrent( dpy, draw, read, ctx );
2274afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
2275783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
22767cf50e137da497a590ec9001a9918972a6246142Brian Paul/* not used
2277783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXDrawable
2278b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian PaulFake_glXGetCurrentReadDrawableSGI(void)
2279783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2280783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2281783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
22827cf50e137da497a590ec9001a9918972a6246142Brian Paul*/
2283afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
2284afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
2285b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_video_source ***/
2286b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#if defined(_VL_H)
22874c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul
2288783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXVideoSourceSGIX
2289783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXCreateGLXVideoSourceSGIX(Display *dpy, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode)
2290afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
2291783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2292783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2293783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) server;
2294783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) path;
2295783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) nodeClass;
2296783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) drainNode;
2297783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2298783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2299783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2300783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2301783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXDestroyGLXVideoSourceSGIX(Display *dpy, GLXVideoSourceSGIX src)
2302783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2303783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2304783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) src;
2305afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
2306783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
23074c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul#endif
23084c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul
230989a42b7e736bd9b0ab090906cab0cd047a6ec12eBrian Paul
2310b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_EXT_import_context ***/
231189a42b7e736bd9b0ab090906cab0cd047a6ec12eBrian Paul
2312783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2313783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXFreeContextEXT(Display *dpy, GLXContext context)
2314783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2315783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2316783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) context;
2317783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2318426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2319783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXContextID
2320783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetContextIDEXT(const GLXContext context)
2321783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2322783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) context;
2323783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2324783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2325783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2326783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXContext
2327783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXImportContextEXT(Display *dpy, GLXContextID contextID)
2328783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2329783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2330783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) contextID;
2331783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2332783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2333426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2334426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int
2335783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryContextInfoEXT(Display *dpy, GLXContext context, int attribute, int *value)
2336426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2337783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2338783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) context;
2339783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) attribute;
2340783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) value;
2341426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   return 0;
2342426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2343426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2344783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2345783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2346b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_fbconfig ***/
2347426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2348426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int
2349783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetFBConfigAttribSGIX(Display *dpy, GLXFBConfigSGIX config, int attribute, int *value)
2350783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
23513265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   return Fake_glXGetFBConfigAttrib(dpy, config, attribute, value);
2352783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2353783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2354783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXFBConfigSGIX *
2355783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXChooseFBConfigSGIX(Display *dpy, int screen, int *attrib_list, int *nelements)
2356783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
23573265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   return (GLXFBConfig *) Fake_glXChooseFBConfig(dpy, screen, attrib_list, nelements);
2358783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2359783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2360e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2361783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXPixmap
2362783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXCreateGLXPixmapWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap)
2363783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2364e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaVisual xmvis = (XMesaVisual) config;
2365e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaBuffer xmbuf = XMesaCreatePixmapBuffer(xmvis, pixmap, 0);
2366e4b2356c07d31fbeeabb13b2fb47db703b473080Brian Paul   return xmbuf->frontxrb->pixmap; /* need to return an X ID */
2367783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2368783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2369e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2370783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXContext
2371783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct)
2372783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2373e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaVisual xmvis = (XMesaVisual) config;
2374e4656003caee346d9c4eb23256d73409271291a7Brian Paul   struct fake_glx_context *glxCtx;
2375e4656003caee346d9c4eb23256d73409271291a7Brian Paul   struct fake_glx_context *shareCtx = (struct fake_glx_context *) share_list;
2376e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2377e4656003caee346d9c4eb23256d73409271291a7Brian Paul   glxCtx = CALLOC_STRUCT(fake_glx_context);
2378e4656003caee346d9c4eb23256d73409271291a7Brian Paul   if (!glxCtx)
2379e4656003caee346d9c4eb23256d73409271291a7Brian Paul      return 0;
2380e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2381e4656003caee346d9c4eb23256d73409271291a7Brian Paul   /* deallocate unused windows/buffers */
2382e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaGarbageCollect();
2383e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2384e4656003caee346d9c4eb23256d73409271291a7Brian Paul   glxCtx->xmesaContext = XMesaCreateContext(xmvis,
2385e4656003caee346d9c4eb23256d73409271291a7Brian Paul                                   shareCtx ? shareCtx->xmesaContext : NULL);
2386e4656003caee346d9c4eb23256d73409271291a7Brian Paul   if (!glxCtx->xmesaContext) {
2387e4656003caee346d9c4eb23256d73409271291a7Brian Paul      FREE(glxCtx);
2388e4656003caee346d9c4eb23256d73409271291a7Brian Paul      return NULL;
2389e4656003caee346d9c4eb23256d73409271291a7Brian Paul   }
2390e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2391e4656003caee346d9c4eb23256d73409271291a7Brian Paul   glxCtx->xmesaContext->direct = GL_FALSE;
2392e4656003caee346d9c4eb23256d73409271291a7Brian Paul   glxCtx->glxContext.isDirect = GL_FALSE;
2393e4656003caee346d9c4eb23256d73409271291a7Brian Paul   glxCtx->glxContext.currentDpy = dpy;
2394e4656003caee346d9c4eb23256d73409271291a7Brian Paul   glxCtx->glxContext.xid = (XID) glxCtx;  /* self pointer */
2395e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2396e4656003caee346d9c4eb23256d73409271291a7Brian Paul   assert((void *) glxCtx == (void *) &(glxCtx->glxContext));
2397e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2398e4656003caee346d9c4eb23256d73409271291a7Brian Paul   return (GLXContext) glxCtx;
2399783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2400783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2401e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2402783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic XVisualInfo *
2403783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetVisualFromFBConfigSGIX(Display *dpy, GLXFBConfigSGIX config)
2404783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
24053265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   return Fake_glXGetVisualFromFBConfig(dpy, config);
2406783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2407783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2408e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2409783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXFBConfigSGIX
2410783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetFBConfigFromVisualSGIX(Display *dpy, XVisualInfo *vis)
2411426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2412e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaVisual xmvis = find_glx_visual(dpy, vis);
2413e4656003caee346d9c4eb23256d73409271291a7Brian Paul   if (!xmvis) {
2414e4656003caee346d9c4eb23256d73409271291a7Brian Paul      /* This visual wasn't found with glXChooseVisual() */
2415e4656003caee346d9c4eb23256d73409271291a7Brian Paul      xmvis = create_glx_visual(dpy, vis);
2416e4656003caee346d9c4eb23256d73409271291a7Brian Paul   }
2417e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2418e4656003caee346d9c4eb23256d73409271291a7Brian Paul   return (GLXFBConfigSGIX) xmvis;
2419426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2420426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2421426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2422426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2423b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_pbuffer ***/
2424783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2425783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXPbufferSGIX
24263265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian PaulFake_glXCreateGLXPbufferSGIX(Display *dpy, GLXFBConfigSGIX config,
24273265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul                             unsigned int width, unsigned int height,
24283265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul                             int *attribList)
2429783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
24303265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   XMesaVisual xmvis = (XMesaVisual) config;
24313265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   XMesaBuffer xmbuf;
24323265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   const int *attrib;
24333265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   GLboolean useLargest = GL_FALSE, preserveContents = GL_FALSE;
24343265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul
2435783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
24363265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul
243711b3028e7ba2fc3b985ab84d7227c290608f83f6Brian Paul   for (attrib = attribList; attrib && *attrib; attrib++) {
24383265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      switch (*attrib) {
24393265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         case GLX_PRESERVED_CONTENTS_SGIX:
24403265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            attrib++;
24413265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            preserveContents = *attrib; /* ignored */
24423265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            break;
24433265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         case GLX_LARGEST_PBUFFER_SGIX:
24443265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            attrib++;
24453265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            useLargest = *attrib; /* ignored */
24463265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            break;
24473265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul         default:
24483265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul            return 0;
24493265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul      }
24503265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   }
24513265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul
2452b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul   /* not used at this time */
2453b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul   (void) useLargest;
2454b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul   (void) preserveContents;
2455b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul
24563265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul   xmbuf = XMesaCreatePBuffer( xmvis, 0, width, height);
2457e4656003caee346d9c4eb23256d73409271291a7Brian Paul   /* A GLXPbuffer handle must be an X Drawable because that's what
2458e4656003caee346d9c4eb23256d73409271291a7Brian Paul    * glXMakeCurrent takes.
2459e4656003caee346d9c4eb23256d73409271291a7Brian Paul    */
2460e4b2356c07d31fbeeabb13b2fb47db703b473080Brian Paul   return (GLXPbuffer) xmbuf->frontxrb->pixmap;
2461783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2462783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2463e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2464783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2465783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXDestroyGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf)
2466783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2467e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaBuffer xmbuf = XMesaFindBuffer(dpy, pbuf);
2468e4656003caee346d9c4eb23256d73409271291a7Brian Paul   if (xmbuf) {
2469e4656003caee346d9c4eb23256d73409271291a7Brian Paul      XMesaDestroyBuffer(xmbuf);
2470e4656003caee346d9c4eb23256d73409271291a7Brian Paul   }
2471783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2472783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2473e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2474783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2475783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value)
2476783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2477e4656003caee346d9c4eb23256d73409271291a7Brian Paul   const XMesaBuffer xmbuf = XMesaFindBuffer(dpy, pbuf);
2478e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2479e4656003caee346d9c4eb23256d73409271291a7Brian Paul   if (!xmbuf) {
2480e4656003caee346d9c4eb23256d73409271291a7Brian Paul      /* Generate GLXBadPbufferSGIX for bad pbuffer */
2481e4656003caee346d9c4eb23256d73409271291a7Brian Paul      return 0;
2482e4656003caee346d9c4eb23256d73409271291a7Brian Paul   }
2483e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2484e4656003caee346d9c4eb23256d73409271291a7Brian Paul   switch (attribute) {
2485e4656003caee346d9c4eb23256d73409271291a7Brian Paul      case GLX_PRESERVED_CONTENTS_SGIX:
2486e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = True;
2487e4656003caee346d9c4eb23256d73409271291a7Brian Paul         break;
2488e4656003caee346d9c4eb23256d73409271291a7Brian Paul      case GLX_LARGEST_PBUFFER_SGIX:
248929926a11b16ec7a235947d95e9a46777605dd30eBrian Paul         *value = xmbuf->mesa_buffer.Width * xmbuf->mesa_buffer.Height;
2490e4656003caee346d9c4eb23256d73409271291a7Brian Paul         break;
2491e4656003caee346d9c4eb23256d73409271291a7Brian Paul      case GLX_WIDTH_SGIX:
249229926a11b16ec7a235947d95e9a46777605dd30eBrian Paul         *value = xmbuf->mesa_buffer.Width;
2493e4656003caee346d9c4eb23256d73409271291a7Brian Paul         break;
2494e4656003caee346d9c4eb23256d73409271291a7Brian Paul      case GLX_HEIGHT_SGIX:
249529926a11b16ec7a235947d95e9a46777605dd30eBrian Paul         *value = xmbuf->mesa_buffer.Height;
2496e4656003caee346d9c4eb23256d73409271291a7Brian Paul         break;
2497e4656003caee346d9c4eb23256d73409271291a7Brian Paul      case GLX_EVENT_MASK_SGIX:
2498e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = 0;  /* XXX might be wrong */
2499e4656003caee346d9c4eb23256d73409271291a7Brian Paul         break;
2500e4656003caee346d9c4eb23256d73409271291a7Brian Paul      default:
2501e4656003caee346d9c4eb23256d73409271291a7Brian Paul         *value = 0;
2502e4656003caee346d9c4eb23256d73409271291a7Brian Paul   }
2503783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2504783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2505783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2506e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2507783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2508783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXSelectEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long mask)
2509783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2510e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable);
2511e4656003caee346d9c4eb23256d73409271291a7Brian Paul   if (xmbuf) {
2512e4656003caee346d9c4eb23256d73409271291a7Brian Paul      /* Note: we'll never generate clobber events */
2513e4656003caee346d9c4eb23256d73409271291a7Brian Paul      xmbuf->selectedEvents = mask;
2514e4656003caee346d9c4eb23256d73409271291a7Brian Paul   }
2515783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2516783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2517e4656003caee346d9c4eb23256d73409271291a7Brian Paul
2518783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2519783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetSelectedEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long *mask)
2520783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2521e4656003caee346d9c4eb23256d73409271291a7Brian Paul   XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable);
2522e4656003caee346d9c4eb23256d73409271291a7Brian Paul   if (xmbuf) {
2523e4656003caee346d9c4eb23256d73409271291a7Brian Paul      *mask = xmbuf->selectedEvents;
2524e4656003caee346d9c4eb23256d73409271291a7Brian Paul   }
2525e4656003caee346d9c4eb23256d73409271291a7Brian Paul   else {
2526e4656003caee346d9c4eb23256d73409271291a7Brian Paul      *mask = 0;
2527e4656003caee346d9c4eb23256d73409271291a7Brian Paul   }
2528783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2529783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2530783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2531783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2532b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGI_cushion ***/
2533783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2534783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2535783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXCushionSGI(Display *dpy, Window win, float cushion)
2536783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2537783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2538783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) win;
2539783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) cushion;
2540783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2541783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2542783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2543783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2544b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_video_resize ***/
2545783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2546783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2547783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXBindChannelToWindowSGIX(Display *dpy, int screen, int channel , Window window)
2548783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2549783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2550783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2551783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) channel;
2552783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) window;
2553783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2554783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2555783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2556783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2557783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXChannelRectSGIX(Display *dpy, int screen, int channel, int x, int y, int w, int h)
2558783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2559783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2560783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2561783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) channel;
2562783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) x;
2563783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) y;
2564783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) w;
2565783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) h;
2566783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2567783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2568783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2569783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2570783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryChannelRectSGIX(Display *dpy, int screen, int channel, int *x, int *y, int *w, int *h)
2571783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2572783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2573783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2574783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) channel;
2575783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) x;
2576783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) y;
2577783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) w;
2578783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) h;
2579783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2580783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2581783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2582783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2583783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryChannelDeltasSGIX(Display *dpy, int screen, int channel, int *dx, int *dy, int *dw, int *dh)
2584783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2585783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2586783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2587783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) channel;
2588783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dx;
2589783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dy;
2590783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dw;
2591783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dh;
2592783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2593783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2594783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2595783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int
2596783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXChannelRectSyncSGIX(Display *dpy, int screen, int channel, GLenum synctype)
2597783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2598783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2599783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2600783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) channel;
2601783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) synctype;
2602783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2603783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2604783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2605783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2606783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2607b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_dmbuffer **/
2608783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2609b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#if defined(_DM_BUFFER_H_)
2610783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Bool
2611783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXAssociateDMPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer)
2612783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2613783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2614783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) pbuffer;
2615783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) params;
2616783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dmbuffer;
2617783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return False;
2618783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2619783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul#endif
2620783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2621783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2622b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_swap_group ***/
2623783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2624783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2625783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXJoinSwapGroupSGIX(Display *dpy, GLXDrawable drawable, GLXDrawable member)
2626783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2627783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2628783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) drawable;
2629783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) member;
2630783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2631783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2632783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2633783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2634b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_swap_barrier ***/
2635783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2636783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void
2637783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXBindSwapBarrierSGIX(Display *dpy, GLXDrawable drawable, int barrier)
2638783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2639783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2640783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) drawable;
2641783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) barrier;
2642783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2643783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2644783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Bool
2645783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryMaxSwapBarriersSGIX(Display *dpy, int screen, int *max)
2646783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2647783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2648783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) screen;
2649783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) max;
2650783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return False;
2651783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2652783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2653783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2654783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2655b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SUN_get_transparent_index ***/
2656783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2657783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Status
2658783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetTransparentIndexSUN(Display *dpy, Window overlay, Window underlay, long *pTransparent)
2659783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2660783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) dpy;
2661783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) overlay;
2662783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) underlay;
2663783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   (void) pTransparent;
2664783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return 0;
2665783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2666783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2667783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2668783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2669b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_MESA_release_buffers ***/
2670b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul
2671783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul/*
2672783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul * Release the depth, stencil, accum buffers attached to a GLXDrawable
2673783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul * (a window or pixmap) prior to destroying the GLXDrawable.
2674783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul */
2675783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Bool
2676783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXReleaseBuffersMESA( Display *dpy, GLXDrawable d )
2677783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2678783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   XMesaBuffer b = XMesaFindBuffer(dpy, d);
2679783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   if (b) {
2680783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul      XMesaDestroyBuffer(b);
2681783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul      return True;
2682783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   }
2683783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return False;
2684783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2685783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2686783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2687783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2688b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_MESA_set_3dfx_mode ***/
2689b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul
2690783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Bool
2691783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXSet3DfxModeMESA( int mode )
2692783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{
2693783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   return XMesaSetFXmode( mode );
2694783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul}
2695783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2696783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2697783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
26983c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian Paul/*** GLX_NV_vertex_array range ***/
26998fefafa2200d3ea44ec46592b190654a10685b46Brian Paulstatic void *
27008fefafa2200d3ea44ec46592b190654a10685b46Brian PaulFake_glXAllocateMemoryNV( GLsizei size,
27018fefafa2200d3ea44ec46592b190654a10685b46Brian Paul                          GLfloat readFrequency,
27028fefafa2200d3ea44ec46592b190654a10685b46Brian Paul                          GLfloat writeFrequency,
27038fefafa2200d3ea44ec46592b190654a10685b46Brian Paul                          GLfloat priority )
27048fefafa2200d3ea44ec46592b190654a10685b46Brian Paul{
27058fefafa2200d3ea44ec46592b190654a10685b46Brian Paul   (void) size;
27068fefafa2200d3ea44ec46592b190654a10685b46Brian Paul   (void) readFrequency;
27078fefafa2200d3ea44ec46592b190654a10685b46Brian Paul   (void) writeFrequency;
27088fefafa2200d3ea44ec46592b190654a10685b46Brian Paul   (void) priority;
27098fefafa2200d3ea44ec46592b190654a10685b46Brian Paul   return NULL;
27108fefafa2200d3ea44ec46592b190654a10685b46Brian Paul}
27118fefafa2200d3ea44ec46592b190654a10685b46Brian Paul
27128fefafa2200d3ea44ec46592b190654a10685b46Brian Paul
27138fefafa2200d3ea44ec46592b190654a10685b46Brian Paulstatic void
27148fefafa2200d3ea44ec46592b190654a10685b46Brian PaulFake_glXFreeMemoryNV( GLvoid *pointer )
27158fefafa2200d3ea44ec46592b190654a10685b46Brian Paul{
27168fefafa2200d3ea44ec46592b190654a10685b46Brian Paul   (void) pointer;
27178fefafa2200d3ea44ec46592b190654a10685b46Brian Paul}
27188fefafa2200d3ea44ec46592b190654a10685b46Brian Paul
27198fefafa2200d3ea44ec46592b190654a10685b46Brian Paul
27203c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian Paul/*** GLX_MESA_agp_offset ***/
2721d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul
2722d6113fc20d68f5720740b89c594227d0312bab3eBrian Paulstatic GLuint
2723d6113fc20d68f5720740b89c594227d0312bab3eBrian PaulFake_glXGetAGPOffsetMESA( const GLvoid *pointer )
2724d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul{
2725d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul   (void) pointer;
2726d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul   return ~0;
2727d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul}
2728d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul
2729d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul
27307287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul/* silence warning */
2731e7b16b74bf5d13331b5a88bbbbb9096560297b63Brian Paulextern struct _glxapi_table *_mesa_GetGLXDispatchTable(void);
27327287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul
27337287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul
27347287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul/**
27357287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul * Create a new GLX API dispatch table with its function pointers
27367287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul * initialized to point to Mesa's "fake" GLX API functions.
27377287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul * Note: there's a similar function (_real_GetGLXDispatchTable) that
27387287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul * returns a new dispatch table with all pointers initalized to point
27397287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul * to "real" GLX functions (which understand GLX wire protocol, etc).
27407287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul */
27417287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulstruct _glxapi_table *
27427287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul_mesa_GetGLXDispatchTable(void)
2743426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{
2744426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   static struct _glxapi_table glx;
2745426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2746426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   /* be sure our dispatch table size <= libGL's table */
2747426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   {
274801915e90e6912f06d43d443a09157f7bbc96ddc5Brian Paul      GLuint size = sizeof(struct _glxapi_table) / sizeof(void *);
2749426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul      (void) size;
2750426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul      assert(_glxapi_get_dispatch_table_size() >= size);
2751426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   }
2752426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2753426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   /* initialize the whole table to no-ops */
2754426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   _glxapi_set_no_op_table(&glx);
2755426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2756426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   /* now initialize the table with the functions I implement */
2757426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.ChooseVisual = Fake_glXChooseVisual;
2758426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CopyContext = Fake_glXCopyContext;
2759426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CreateContext = Fake_glXCreateContext;
2760426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CreateGLXPixmap = Fake_glXCreateGLXPixmap;
2761426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.DestroyContext = Fake_glXDestroyContext;
2762426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.DestroyGLXPixmap = Fake_glXDestroyGLXPixmap;
2763426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.GetConfig = Fake_glXGetConfig;
2764426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   /*glx.GetCurrentContext = Fake_glXGetCurrentContext;*/
2765426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   /*glx.GetCurrentDrawable = Fake_glXGetCurrentDrawable;*/
2766426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.IsDirect = Fake_glXIsDirect;
2767426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.MakeCurrent = Fake_glXMakeCurrent;
2768426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.QueryExtension = Fake_glXQueryExtension;
2769426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.QueryVersion = Fake_glXQueryVersion;
2770426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.SwapBuffers = Fake_glXSwapBuffers;
2771426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.UseXFont = Fake_glXUseXFont;
2772426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.WaitGL = Fake_glXWaitGL;
2773426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.WaitX = Fake_glXWaitX;
2774426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2775b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_VERSION_1_1 ***/
2776426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.GetClientString = Fake_glXGetClientString;
2777426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.QueryExtensionsString = Fake_glXQueryExtensionsString;
2778426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.QueryServerString = Fake_glXQueryServerString;
2779426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2780b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_VERSION_1_2 ***/
2781426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   /*glx.GetCurrentDisplay = Fake_glXGetCurrentDisplay;*/
2782426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2783b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_VERSION_1_3 ***/
2784426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.ChooseFBConfig = Fake_glXChooseFBConfig;
2785426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CreateNewContext = Fake_glXCreateNewContext;
2786426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CreatePbuffer = Fake_glXCreatePbuffer;
2787426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CreatePixmap = Fake_glXCreatePixmap;
2788426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CreateWindow = Fake_glXCreateWindow;
2789426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.DestroyPbuffer = Fake_glXDestroyPbuffer;
2790426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.DestroyPixmap = Fake_glXDestroyPixmap;
2791426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.DestroyWindow = Fake_glXDestroyWindow;
2792426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   /*glx.GetCurrentReadDrawable = Fake_glXGetCurrentReadDrawable;*/
2793426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.GetFBConfigAttrib = Fake_glXGetFBConfigAttrib;
279471dea349d2be623b7819389428b0d6a124e8d184Brian Paul   glx.GetFBConfigs = Fake_glXGetFBConfigs;
2795426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.GetSelectedEvent = Fake_glXGetSelectedEvent;
2796426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.GetVisualFromFBConfig = Fake_glXGetVisualFromFBConfig;
2797426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.MakeContextCurrent = Fake_glXMakeContextCurrent;
2798426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.QueryContext = Fake_glXQueryContext;
2799426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.QueryDrawable = Fake_glXQueryDrawable;
2800426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.SelectEvent = Fake_glXSelectEvent;
2801426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2802b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGI_swap_control ***/
2803783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.SwapIntervalSGI = Fake_glXSwapIntervalSGI;
2804783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2805b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGI_video_sync ***/
2806426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.GetVideoSyncSGI = Fake_glXGetVideoSyncSGI;
2807426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.WaitVideoSyncSGI = Fake_glXWaitVideoSyncSGI;
2808426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2809b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGI_make_current_read ***/
2810783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.MakeCurrentReadSGI = Fake_glXMakeCurrentReadSGI;
28117cf50e137da497a590ec9001a9918972a6246142Brian Paul   /*glx.GetCurrentReadDrawableSGI = Fake_glXGetCurrentReadDrawableSGI;*/
2812783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2813b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_video_source ***/
2814b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#if defined(_VL_H)
2815783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.CreateGLXVideoSourceSGIX = Fake_glXCreateGLXVideoSourceSGIX;
2816783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.DestroyGLXVideoSourceSGIX = Fake_glXDestroyGLXVideoSourceSGIX;
2817783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul#endif
2818783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2819b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_EXT_import_context ***/
2820783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.FreeContextEXT = Fake_glXFreeContextEXT;
2821783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.GetContextIDEXT = Fake_glXGetContextIDEXT;
28227cf50e137da497a590ec9001a9918972a6246142Brian Paul   /*glx.GetCurrentDisplayEXT = Fake_glXGetCurrentDisplayEXT;*/
2823783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.ImportContextEXT = Fake_glXImportContextEXT;
2824783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.QueryContextInfoEXT = Fake_glXQueryContextInfoEXT;
28254536021a62e02fceaa6e8eb889b0f61743109cc4Brian Paul
2826b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGIX_fbconfig ***/
2827783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.GetFBConfigAttribSGIX = Fake_glXGetFBConfigAttribSGIX;
2828783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.ChooseFBConfigSGIX = Fake_glXChooseFBConfigSGIX;
2829783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.CreateGLXPixmapWithConfigSGIX = Fake_glXCreateGLXPixmapWithConfigSGIX;
2830783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.CreateContextWithConfigSGIX = Fake_glXCreateContextWithConfigSGIX;
2831783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.GetVisualFromFBConfigSGIX = Fake_glXGetVisualFromFBConfigSGIX;
2832783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.GetFBConfigFromVisualSGIX = Fake_glXGetFBConfigFromVisualSGIX;
2833783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2834b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGIX_pbuffer ***/
2835783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.CreateGLXPbufferSGIX = Fake_glXCreateGLXPbufferSGIX;
2836783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.DestroyGLXPbufferSGIX = Fake_glXDestroyGLXPbufferSGIX;
2837783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.QueryGLXPbufferSGIX = Fake_glXQueryGLXPbufferSGIX;
2838783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.SelectEventSGIX = Fake_glXSelectEventSGIX;
2839783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.GetSelectedEventSGIX = Fake_glXGetSelectedEventSGIX;
2840783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2841b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGI_cushion ***/
2842783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.CushionSGI = Fake_glXCushionSGI;
2843783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2844b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGIX_video_resize ***/
2845783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.BindChannelToWindowSGIX = Fake_glXBindChannelToWindowSGIX;
2846783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.ChannelRectSGIX = Fake_glXChannelRectSGIX;
2847783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.QueryChannelRectSGIX = Fake_glXQueryChannelRectSGIX;
2848783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.QueryChannelDeltasSGIX = Fake_glXQueryChannelDeltasSGIX;
2849783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.ChannelRectSyncSGIX = Fake_glXChannelRectSyncSGIX;
2850783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2851b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGIX_dmbuffer **/
2852b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#if defined(_DM_BUFFER_H_)
2853783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.AssociateDMPbufferSGIX = NULL;
2854783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul#endif
2855783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2856b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGIX_swap_group ***/
2857783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.JoinSwapGroupSGIX = Fake_glXJoinSwapGroupSGIX;
2858783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2859b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SGIX_swap_barrier ***/
2860783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.BindSwapBarrierSGIX = Fake_glXBindSwapBarrierSGIX;
2861783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.QueryMaxSwapBarriersSGIX = Fake_glXQueryMaxSwapBarriersSGIX;
2862783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul
2863b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_SUN_get_transparent_index ***/
2864783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul   glx.GetTransparentIndexSUN = Fake_glXGetTransparentIndexSUN;
28654536021a62e02fceaa6e8eb889b0f61743109cc4Brian Paul
2866b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_MESA_copy_sub_buffer ***/
2867426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CopySubBufferMESA = Fake_glXCopySubBufferMESA;
2868426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2869b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_MESA_release_buffers ***/
2870426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.ReleaseBuffersMESA = Fake_glXReleaseBuffersMESA;
2871426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2872b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_MESA_pixmap_colormap ***/
2873426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.CreateGLXPixmapMESA = Fake_glXCreateGLXPixmapMESA;
2874426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2875b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul   /*** GLX_MESA_set_3dfx_mode ***/
2876426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   glx.Set3DfxModeMESA = Fake_glXSet3DfxModeMESA;
2877426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul
2878d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul   /*** GLX_NV_vertex_array_range ***/
28798fefafa2200d3ea44ec46592b190654a10685b46Brian Paul   glx.AllocateMemoryNV = Fake_glXAllocateMemoryNV;
28808fefafa2200d3ea44ec46592b190654a10685b46Brian Paul   glx.FreeMemoryNV = Fake_glXFreeMemoryNV;
28818fefafa2200d3ea44ec46592b190654a10685b46Brian Paul
2882d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul   /*** GLX_MESA_agp_offset ***/
2883d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul   glx.GetAGPOffsetMESA = Fake_glXGetAGPOffsetMESA;
2884d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul
2885426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul   return &glx;
2886426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul}
2887