fakeglx.c revision f69d1d1438361f10fd8db78d2d38f26e33db9747
1afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 2afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Mesa 3-D graphics library 349e80bf6b163310f7cd776261872201eea57053aBrian Paul * Version: 7.5 45e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen * 549e80bf6b163310f7cd776261872201eea57053aBrian Paul * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. 649e80bf6b163310f7cd776261872201eea57053aBrian Paul * Copyright (C) 2009 VMware, Inc. All Rights Reserved. 75e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen * 8afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Permission is hereby granted, free of charge, to any person obtaining a 9afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * copy of this software and associated documentation files (the "Software"), 10afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * to deal in the Software without restriction, including without limitation 11afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 12afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * and/or sell copies of the Software, and to permit persons to whom the 13afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Software is furnished to do so, subject to the following conditions: 145e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen * 15afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * The above copyright notice and this permission notice shall be included 16afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * in all copies or substantial portions of the Software. 175e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen * 18afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 22afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 25afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 26afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 27afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 2836cfa38760cc2bd91c08b66bb62c4b6cf9eb5454Brian Paul * This is an emulation of the GLX API which allows Mesa/GLX-based programs 2936cfa38760cc2bd91c08b66bb62c4b6cf9eb5454Brian Paul * to run on X servers which do not have the real GLX extension. 30afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * 31afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Thanks to the contributors: 32afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * 33ddf69f247fdb246b99ef6525fcfa6eda7b2e2aa7Brian Paul * Initial version: Philip Brown (phil@bolthole.com) 34afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Better glXGetConfig() support: Armin Liebchen (liebchen@asylum.cs.utah.edu) 35afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Further visual-handling refinements: Wolfram Gloger 36afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * (wmglo@Dent.MED.Uni-Muenchen.DE). 37afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * 38afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Notes: 39afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Don't be fooled, stereo isn't supported yet. 40afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 41afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 42afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 43afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 44fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul#include "glxheader.h" 45426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul#include "glxapi.h" 46374e7fd6cc95d3d91629a6e1c951d77e8a29c31cBrian Paul#include "main/context.h" 47374e7fd6cc95d3d91629a6e1c951d77e8a29c31cBrian Paul#include "main/config.h" 48374e7fd6cc95d3d91629a6e1c951d77e8a29c31cBrian Paul#include "main/macros.h" 49374e7fd6cc95d3d91629a6e1c951d77e8a29c31cBrian Paul#include "main/imports.h" 50374e7fd6cc95d3d91629a6e1c951d77e8a29c31cBrian Paul#include "main/mtypes.h" 51374e7fd6cc95d3d91629a6e1c951d77e8a29c31cBrian Paul#include "main/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 " \ 81fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian "GLX_EXT_texture_from_pixmap " \ 82e4656003caee346d9c4eb23256d73409271291a7Brian Paul "GLX_EXT_visual_info " \ 83e4656003caee346d9c4eb23256d73409271291a7Brian Paul "GLX_EXT_visual_rating " \ 84ee061060826df059f0ddb904a2160ed610423579Brian Paul /*"GLX_SGI_video_sync "*/ \ 85e4656003caee346d9c4eb23256d73409271291a7Brian Paul "GLX_SGIX_fbconfig " \ 866d6efd605f662c1f07e183e58416db804f0a058fBrian Paul "GLX_SGIX_pbuffer " 8743c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul 887cf50e137da497a590ec9001a9918972a6246142Brian Paul/* 897cf50e137da497a590ec9001a9918972a6246142Brian Paul * Our fake GLX context will contain a "real" GLX context and an XMesa context. 907cf50e137da497a590ec9001a9918972a6246142Brian Paul * 917cf50e137da497a590ec9001a9918972a6246142Brian Paul * Note that a pointer to a __GLXcontext is a pointer to a fake_glx_context, 927cf50e137da497a590ec9001a9918972a6246142Brian Paul * and vice versa. 937cf50e137da497a590ec9001a9918972a6246142Brian Paul * 947cf50e137da497a590ec9001a9918972a6246142Brian Paul * We really just need this structure in order to make the libGL functions 957cf50e137da497a590ec9001a9918972a6246142Brian Paul * glXGetCurrentContext(), glXGetCurrentDrawable() and glXGetCurrentDisplay() 967cf50e137da497a590ec9001a9918972a6246142Brian Paul * work correctly. 977cf50e137da497a590ec9001a9918972a6246142Brian Paul */ 987cf50e137da497a590ec9001a9918972a6246142Brian Paulstruct fake_glx_context { 997cf50e137da497a590ec9001a9918972a6246142Brian Paul __GLXcontext glxContext; /* this MUST be first! */ 1007cf50e137da497a590ec9001a9918972a6246142Brian Paul XMesaContext xmesaContext; 1017cf50e137da497a590ec9001a9918972a6246142Brian Paul}; 10243c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul 103afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 104afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1057cf50e137da497a590ec9001a9918972a6246142Brian Paul/**********************************************************************/ 1067cf50e137da497a590ec9001a9918972a6246142Brian Paul/*** GLX Visual Code ***/ 1077cf50e137da497a590ec9001a9918972a6246142Brian Paul/**********************************************************************/ 1087cf50e137da497a590ec9001a9918972a6246142Brian Paul 1097cf50e137da497a590ec9001a9918972a6246142Brian Paul#define DONT_CARE -1 1107cf50e137da497a590ec9001a9918972a6246142Brian Paul 111afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 11264034c4fb5c56f63d37faa6f64f3183ca106856aAlan Hourihanestatic XMesaVisual *VisualTable = NULL; 113afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic int NumVisuals = 0; 114afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 115afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 116afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 117afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * This struct and some code fragments borrowed 118afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * from Mark Kilgard's GLUT library. 119afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 120afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgtypedef struct _OverlayInfo { 121afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Avoid 64-bit portability problems by being careful to use 122afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg longs due to the way XGetWindowProperty is specified. Note 123afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg that these parameters are passed as CARD32s over X 124afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg protocol. */ 125afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg unsigned long overlay_visual; 126afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg long transparent_type; 127afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg long value; 128afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg long layer; 129afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} OverlayInfo; 130afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 131afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 132afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 133afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* Macro to handle c_class vs class field name in XVisualInfo struct */ 134afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#if defined(__cplusplus) || defined(c_plusplus) 135afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#define CLASS c_class 136afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#else 137afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#define CLASS class 138afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#endif 139afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 140afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 141afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 142afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 143afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Test if the given XVisualInfo is usable for Mesa rendering. 144afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 1457287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulstatic GLboolean 1467287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulis_usable_visual( XVisualInfo *vinfo ) 147afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 148afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (vinfo->CLASS) { 149afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case StaticGray: 150afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GrayScale: 151afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Any StaticGray/GrayScale visual works in RGB or CI mode */ 152afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return GL_TRUE; 153afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case StaticColor: 154afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case PseudoColor: 155afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Any StaticColor/PseudoColor visual of at least 4 bits */ 156afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vinfo->depth>=4) { 157afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return GL_TRUE; 158afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 159afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 160afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return GL_FALSE; 161afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 162afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case TrueColor: 163afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case DirectColor: 164afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Any depth of TrueColor or DirectColor works in RGB mode */ 165afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return GL_TRUE; 166afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: 167afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* This should never happen */ 168afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return GL_FALSE; 169afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 170afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 171afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 172afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 173afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1741d97c277e0cb2b75559d495a58222f2511212a66Brian Paul/** 1751d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * Get an array OverlayInfo records for specified screen. 1761d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * \param dpy the display 1771d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * \param screen screen number 1781d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * \param numOverlays returns numver of OverlayInfo records 1791d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * \return pointer to OverlayInfo array, free with XFree() 180afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 1811d97c277e0cb2b75559d495a58222f2511212a66Brian Paulstatic OverlayInfo * 1821d97c277e0cb2b75559d495a58222f2511212a66Brian PaulGetOverlayInfo(Display *dpy, int screen, int *numOverlays) 183afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 184afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg Atom overlayVisualsAtom; 185afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg Atom actualType; 1861d97c277e0cb2b75559d495a58222f2511212a66Brian Paul Status status; 1871d97c277e0cb2b75559d495a58222f2511212a66Brian Paul unsigned char *ovInfo; 188afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg unsigned long sizeData, bytesLeft; 1891d97c277e0cb2b75559d495a58222f2511212a66Brian Paul int actualFormat; 190afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 191afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* 192afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * The SERVER_OVERLAY_VISUALS property on the root window contains 193afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * a list of overlay visuals. Get that list now. 194afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 195afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg overlayVisualsAtom = XInternAtom(dpy,"SERVER_OVERLAY_VISUALS", True); 196afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (overlayVisualsAtom == None) { 197afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 198afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 199afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 2001d97c277e0cb2b75559d495a58222f2511212a66Brian Paul status = XGetWindowProperty(dpy, RootWindow(dpy, screen), 201afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg overlayVisualsAtom, 0L, (long) 10000, False, 202afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg overlayVisualsAtom, &actualType, &actualFormat, 203afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg &sizeData, &bytesLeft, 2041d97c277e0cb2b75559d495a58222f2511212a66Brian Paul &ovInfo); 205afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 206afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (status != Success || actualType != overlayVisualsAtom || 207afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg actualFormat != 32 || sizeData < 4) { 208afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* something went wrong */ 2091d97c277e0cb2b75559d495a58222f2511212a66Brian Paul XFree((void *) ovInfo); 2101d97c277e0cb2b75559d495a58222f2511212a66Brian Paul *numOverlays = 0; 2111d97c277e0cb2b75559d495a58222f2511212a66Brian Paul return NULL; 2121d97c277e0cb2b75559d495a58222f2511212a66Brian Paul } 2131d97c277e0cb2b75559d495a58222f2511212a66Brian Paul 2141d97c277e0cb2b75559d495a58222f2511212a66Brian Paul *numOverlays = sizeData / 4; 2151d97c277e0cb2b75559d495a58222f2511212a66Brian Paul return (OverlayInfo *) ovInfo; 2161d97c277e0cb2b75559d495a58222f2511212a66Brian Paul} 2171d97c277e0cb2b75559d495a58222f2511212a66Brian Paul 2181d97c277e0cb2b75559d495a58222f2511212a66Brian Paul 2191d97c277e0cb2b75559d495a58222f2511212a66Brian Paul 2201d97c277e0cb2b75559d495a58222f2511212a66Brian Paul/** 2211d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * Return the level (overlay, normal, underlay) of a given XVisualInfo. 2221d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * Input: dpy - the X display 2231d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * vinfo - the XVisualInfo to test 2241d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * Return: level of the visual: 2251d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * 0 = normal planes 2261d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * >0 = overlay planes 2271d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * <0 = underlay planes 2281d97c277e0cb2b75559d495a58222f2511212a66Brian Paul */ 2291d97c277e0cb2b75559d495a58222f2511212a66Brian Paulstatic int 2301d97c277e0cb2b75559d495a58222f2511212a66Brian Paullevel_of_visual( Display *dpy, XVisualInfo *vinfo ) 2311d97c277e0cb2b75559d495a58222f2511212a66Brian Paul{ 2321d97c277e0cb2b75559d495a58222f2511212a66Brian Paul OverlayInfo *overlay_info; 2331d97c277e0cb2b75559d495a58222f2511212a66Brian Paul int numOverlaysPerScreen, i; 2341d97c277e0cb2b75559d495a58222f2511212a66Brian Paul 2351d97c277e0cb2b75559d495a58222f2511212a66Brian Paul overlay_info = GetOverlayInfo(dpy, vinfo->screen, &numOverlaysPerScreen); 2361d97c277e0cb2b75559d495a58222f2511212a66Brian Paul if (!overlay_info) { 237afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 238afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 239afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 240afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* search the overlay visual list for the visual ID of interest */ 2411d97c277e0cb2b75559d495a58222f2511212a66Brian Paul for (i = 0; i < numOverlaysPerScreen; i++) { 2421d97c277e0cb2b75559d495a58222f2511212a66Brian Paul const OverlayInfo *ov = overlay_info + i; 2431d97c277e0cb2b75559d495a58222f2511212a66Brian Paul if (ov->overlay_visual == vinfo->visualid) { 244afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* found the visual */ 245afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (/*ov->transparent_type==1 &&*/ ov->layer!=0) { 246afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int level = ov->layer; 247afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XFree((void *) overlay_info); 248afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return level; 249afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 250afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 251afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XFree((void *) overlay_info); 252afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 253afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 254afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 255afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 256afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 257afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* The visual ID was not found in the overlay list. */ 258afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XFree((void *) overlay_info); 259afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 260afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 261afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 262afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 263afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 264afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 265afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 266afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Given an XVisualInfo and RGB, Double, and Depth buffer flags, save the 267afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * configuration in our list of GLX visuals. 268afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 269afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XMesaVisual 270afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgsave_glx_visual( Display *dpy, XVisualInfo *vinfo, 271afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLboolean rgbFlag, GLboolean alphaFlag, GLboolean dbFlag, 272afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLboolean stereoFlag, 273afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLint depth_size, GLint stencil_size, 274b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint accumRedSize, GLint accumGreenSize, 275b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint accumBlueSize, GLint accumAlphaSize, 276894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul GLint level, GLint numAuxBuffers ) 277afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 278afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLboolean ximageFlag = GL_TRUE; 279afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaVisual xmvis; 280afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLint i; 281afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLboolean comparePointers; 282afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 283afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (dbFlag) { 284afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Check if the MESA_BACK_BUFFER env var is set */ 285367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul char *backbuffer = _mesa_getenv("MESA_BACK_BUFFER"); 286afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (backbuffer) { 287afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (backbuffer[0]=='p' || backbuffer[0]=='P') { 288afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg ximageFlag = GL_FALSE; 289afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 290afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else if (backbuffer[0]=='x' || backbuffer[0]=='X') { 291afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg ximageFlag = GL_TRUE; 292afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 293afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 294d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul _mesa_warning(NULL, "Mesa: invalid value for MESA_BACK_BUFFER environment variable, using an XImage."); 295afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 296afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 297afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 298afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 299da2f1e88bc63403a95b89706905c070b7c894863Brian if (stereoFlag) { 300da2f1e88bc63403a95b89706905c070b7c894863Brian /* stereo not supported */ 301da2f1e88bc63403a95b89706905c070b7c894863Brian return NULL; 302da2f1e88bc63403a95b89706905c070b7c894863Brian } 303da2f1e88bc63403a95b89706905c070b7c894863Brian 304afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Comparing IDs uses less memory but sometimes fails. */ 305afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* XXX revisit this after 3.0 is finished. */ 306367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul if (_mesa_getenv("MESA_GLX_VISUAL_HACK")) 307afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg comparePointers = GL_TRUE; 308afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else 309afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg comparePointers = GL_FALSE; 310afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 311a13331d59b535aa4a1ddad695420de5d6f814550Brian Paul /* Force the visual to have an alpha channel */ 312a13331d59b535aa4a1ddad695420de5d6f814550Brian Paul if (rgbFlag && _mesa_getenv("MESA_GLX_FORCE_ALPHA")) 313a13331d59b535aa4a1ddad695420de5d6f814550Brian Paul alphaFlag = GL_TRUE; 314a13331d59b535aa4a1ddad695420de5d6f814550Brian Paul 315afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* First check if a matching visual is already in the list */ 316afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (i=0; i<NumVisuals; i++) { 317afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaVisual v = VisualTable[i]; 318afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (v->display == dpy 319304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick && v->mesa_visual.level == level 320894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul && v->mesa_visual.numAuxBuffers == numAuxBuffers 321afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg && v->ximage_flag == ximageFlag 3221832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul && v->mesa_visual.rgbMode == rgbFlag 3231832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul && v->mesa_visual.doubleBufferMode == dbFlag 3241832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul && v->mesa_visual.stereoMode == stereoFlag 3251832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul && (v->mesa_visual.alphaBits > 0) == alphaFlag 3261832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul && (v->mesa_visual.depthBits >= depth_size || depth_size == 0) 3271832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul && (v->mesa_visual.stencilBits >= stencil_size || stencil_size == 0) 3281832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul && (v->mesa_visual.accumRedBits >= accumRedSize || accumRedSize == 0) 3291832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul && (v->mesa_visual.accumGreenBits >= accumGreenSize || accumGreenSize == 0) 3301832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul && (v->mesa_visual.accumBlueBits >= accumBlueSize || accumBlueSize == 0) 3311832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul && (v->mesa_visual.accumAlphaBits >= accumAlphaSize || accumAlphaSize == 0)) { 332afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* now either compare XVisualInfo pointers or visual IDs */ 333d0247f53aea8fa8677aadc8a00f75c8993be9ebcBrian Paul if ((!comparePointers && v->visinfo->visualid == vinfo->visualid) 334afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg || (comparePointers && v->vishandle == vinfo)) { 335afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return v; 336afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 337afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 338afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 339afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 340afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Create a new visual and add it to the list. */ 341afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 342c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul xmvis = XMesaCreateVisual( dpy, vinfo, rgbFlag, alphaFlag, dbFlag, 343c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul stereoFlag, ximageFlag, 344c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul depth_size, stencil_size, 345c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul accumRedSize, accumBlueSize, 346c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul accumBlueSize, accumAlphaSize, 0, level, 347c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul GLX_NONE_EXT ); 348afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (xmvis) { 349f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul /* Save a copy of the pointer now so we can find this visual again 350f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul * if we need to search for it in find_glx_visual(). 351f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul */ 352f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul xmvis->vishandle = vinfo; 35364034c4fb5c56f63d37faa6f64f3183ca106856aAlan Hourihane /* Allocate more space for additional visual */ 3549580179dfb42d5b81ff6ec9704b82a556c7f1229Brian Paul VisualTable = (XMesaVisual *) _mesa_realloc( VisualTable, 35564034c4fb5c56f63d37faa6f64f3183ca106856aAlan Hourihane sizeof(XMesaVisual) * NumVisuals, 356394fd40a536faade5ccfbbb1f2920394e89ad4aaBrian Paul sizeof(XMesaVisual) * (NumVisuals + 1)); 357f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul /* add xmvis to the list */ 358afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg VisualTable[NumVisuals] = xmvis; 359afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg NumVisuals++; 3607287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul /* XXX minor hack, because XMesaCreateVisual doesn't support an 3617287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul * aux buffers parameter. 3627287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul */ 363894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul xmvis->mesa_visual.numAuxBuffers = numAuxBuffers; 364afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 365afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return xmvis; 366afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 367afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 368afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 369dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul/** 370dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul * Return the default number of bits for the Z buffer. 371dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul * If defined, use the MESA_GLX_DEPTH_BITS env var value. 372dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul * Otherwise, use the DEFAULT_SOFTWARE_DEPTH_BITS constant. 373dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul * XXX probably do the same thing for stencil, accum, etc. 374dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul */ 375dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paulstatic GLint 376dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Pauldefault_depth_bits(void) 377dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul{ 378dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul int zBits; 379dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul const char *zEnv = _mesa_getenv("MESA_GLX_DEPTH_BITS"); 380dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul if (zEnv) 381dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul zBits = _mesa_atoi(zEnv); 382dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul else 383dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul zBits = DEFAULT_SOFTWARE_DEPTH_BITS; 384dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul return zBits; 385dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul} 386dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul 387978ef2bb6d9ca4996a24f95820a699e22c84f70bBrian Paulstatic GLint 388c12ee99d119debe1a421a77c1cc6d99d958ae94bBrian Pauldefault_alpha_bits(void) 389c12ee99d119debe1a421a77c1cc6d99d958ae94bBrian Paul{ 390c12ee99d119debe1a421a77c1cc6d99d958ae94bBrian Paul int aBits; 391c12ee99d119debe1a421a77c1cc6d99d958ae94bBrian Paul const char *aEnv = _mesa_getenv("MESA_GLX_ALPHA_BITS"); 392c12ee99d119debe1a421a77c1cc6d99d958ae94bBrian Paul if (aEnv) 393c12ee99d119debe1a421a77c1cc6d99d958ae94bBrian Paul aBits = _mesa_atoi(aEnv); 394c12ee99d119debe1a421a77c1cc6d99d958ae94bBrian Paul else 395c12ee99d119debe1a421a77c1cc6d99d958ae94bBrian Paul aBits = 0; 396c12ee99d119debe1a421a77c1cc6d99d958ae94bBrian Paul return aBits; 397c12ee99d119debe1a421a77c1cc6d99d958ae94bBrian Paul} 398c12ee99d119debe1a421a77c1cc6d99d958ae94bBrian Paul 399c12ee99d119debe1a421a77c1cc6d99d958ae94bBrian Paulstatic GLint 400978ef2bb6d9ca4996a24f95820a699e22c84f70bBrian Pauldefault_accum_bits(void) 401978ef2bb6d9ca4996a24f95820a699e22c84f70bBrian Paul{ 402978ef2bb6d9ca4996a24f95820a699e22c84f70bBrian Paul return 16; 403978ef2bb6d9ca4996a24f95820a699e22c84f70bBrian Paul} 404978ef2bb6d9ca4996a24f95820a699e22c84f70bBrian Paul 405dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul 406afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 407afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 408afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Create a GLX visual from a regular XVisualInfo. 409ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * This is called when Fake GLX is given an XVisualInfo which wasn't 410ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * returned by glXChooseVisual. Since this is the first time we're 411ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * considering this visual we'll take a guess at reasonable values 412ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * for depth buffer size, stencil size, accum size, etc. 413ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * This is the best we can do with a client-side emulation of GLX. 414afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 415afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XMesaVisual 416afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgcreate_glx_visual( Display *dpy, XVisualInfo *visinfo ) 417afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 418afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int vislevel; 419dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul GLint zBits = default_depth_bits(); 420978ef2bb6d9ca4996a24f95820a699e22c84f70bBrian Paul GLint accBits = default_accum_bits(); 421c12ee99d119debe1a421a77c1cc6d99d958ae94bBrian Paul GLboolean alphaFlag = default_alpha_bits() > 0; 422afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 423afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vislevel = level_of_visual( dpy, visinfo ); 424afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vislevel) { 425afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Configure this visual as a CI, single-buffered overlay */ 426afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return save_glx_visual( dpy, visinfo, 427afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GL_FALSE, /* rgb */ 428afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GL_FALSE, /* alpha */ 429afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GL_FALSE, /* double */ 430afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GL_FALSE, /* stereo */ 431afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 0, /* depth bits */ 432afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 0, /* stencil bits */ 433b2e460018375f699198073a6167e0ee96ba1d267Brian Paul 0,0,0,0, /* accum bits */ 434894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul vislevel, /* level */ 435894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul 0 /* numAux */ 436afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg ); 437afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 438afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else if (is_usable_visual( visinfo )) { 439367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul if (_mesa_getenv("MESA_GLX_FORCE_CI")) { 4408f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul /* Configure this visual as a COLOR INDEX visual. */ 4418f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul return save_glx_visual( dpy, visinfo, 4428f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul GL_FALSE, /* rgb */ 4438f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul GL_FALSE, /* alpha */ 4448f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul GL_TRUE, /* double */ 4458f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul GL_FALSE, /* stereo */ 446dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul zBits, 447e4b2356c07d31fbeeabb13b2fb47db703b473080Brian Paul STENCIL_BITS, 448e4b2356c07d31fbeeabb13b2fb47db703b473080Brian Paul 0, 0, 0, 0, /* accum bits */ 449894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul 0, /* level */ 450894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul 0 /* numAux */ 4518f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul ); 4528f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul } 4538f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul else { 4548f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul /* Configure this visual as RGB, double-buffered, depth-buffered. */ 4558f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul /* This is surely wrong for some people's needs but what else */ 4568f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul /* can be done? They should use glXChooseVisual(). */ 4578f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul return save_glx_visual( dpy, visinfo, 4588f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul GL_TRUE, /* rgb */ 459c12ee99d119debe1a421a77c1cc6d99d958ae94bBrian Paul alphaFlag, /* alpha */ 4608f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul GL_TRUE, /* double */ 4618f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul GL_FALSE, /* stereo */ 462dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul zBits, 463e4b2356c07d31fbeeabb13b2fb47db703b473080Brian Paul STENCIL_BITS, 464978ef2bb6d9ca4996a24f95820a699e22c84f70bBrian Paul accBits, /* r */ 465978ef2bb6d9ca4996a24f95820a699e22c84f70bBrian Paul accBits, /* g */ 466978ef2bb6d9ca4996a24f95820a699e22c84f70bBrian Paul accBits, /* b */ 467978ef2bb6d9ca4996a24f95820a699e22c84f70bBrian Paul accBits, /* a */ 468894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul 0, /* level */ 469894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul 0 /* numAux */ 4708f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul ); 4718f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul } 472afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 473afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 474d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul _mesa_warning(NULL, "Mesa: error in glXCreateContext: bad visual\n"); 475afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 476afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 477afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 478afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 479afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 480afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 481afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 482afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Find the GLX visual associated with an XVisualInfo. 483afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 484afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XMesaVisual 485afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgfind_glx_visual( Display *dpy, XVisualInfo *vinfo ) 486afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 487afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int i; 488afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 489f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul /* try to match visual id */ 490afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (i=0;i<NumVisuals;i++) { 491f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul if (VisualTable[i]->display==dpy 492f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul && VisualTable[i]->visinfo->visualid == vinfo->visualid) { 493afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return VisualTable[i]; 494afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 495afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 496f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul 497f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul /* if that fails, try to match pointers */ 498afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (i=0;i<NumVisuals;i++) { 499f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul if (VisualTable[i]->display==dpy && VisualTable[i]->vishandle==vinfo) { 500afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return VisualTable[i]; 501afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 502afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 503f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul 504afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 505afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 506afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 507afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 508afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 5091d97c277e0cb2b75559d495a58222f2511212a66Brian Paul/** 510afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return the transparent pixel value for a GLX visual. 511afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input: glxvis - the glx_visual 512afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return: a pixel value or -1 if no transparent pixel 513afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 5147287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulstatic int 5157287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paultransparent_pixel( XMesaVisual glxvis ) 516afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 517afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg Display *dpy = glxvis->display; 518afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XVisualInfo *vinfo = glxvis->visinfo; 5191d97c277e0cb2b75559d495a58222f2511212a66Brian Paul OverlayInfo *overlay_info; 5201d97c277e0cb2b75559d495a58222f2511212a66Brian Paul int numOverlaysPerScreen, i; 521afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 5221d97c277e0cb2b75559d495a58222f2511212a66Brian Paul overlay_info = GetOverlayInfo(dpy, vinfo->screen, &numOverlaysPerScreen); 5231d97c277e0cb2b75559d495a58222f2511212a66Brian Paul if (!overlay_info) { 524afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return -1; 525afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 526afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 5271d97c277e0cb2b75559d495a58222f2511212a66Brian Paul for (i = 0; i < numOverlaysPerScreen; i++) { 5281d97c277e0cb2b75559d495a58222f2511212a66Brian Paul const OverlayInfo *ov = overlay_info + i; 5291d97c277e0cb2b75559d495a58222f2511212a66Brian Paul if (ov->overlay_visual == vinfo->visualid) { 530afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* found it! */ 5311d97c277e0cb2b75559d495a58222f2511212a66Brian Paul if (ov->transparent_type == 0) { 532afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* type 0 indicates no transparency */ 533afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XFree((void *) overlay_info); 534afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return -1; 535afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 536afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 537afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* ov->value is the transparent pixel */ 538afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XFree((void *) overlay_info); 539afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return ov->value; 540afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 541afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 542afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 543afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 544afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* The visual ID was not found in the overlay list. */ 545afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XFree((void *) overlay_info); 546afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return -1; 547afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 548afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 549afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 550afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 5511d97c277e0cb2b75559d495a58222f2511212a66Brian Paul/** 552afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Try to get an X visual which matches the given arguments. 553afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 5547287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulstatic XVisualInfo * 5557287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulget_visual( Display *dpy, int scr, unsigned int depth, int xclass ) 556afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 557afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XVisualInfo temp, *vis; 558afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg long mask; 559afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int n; 560afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg unsigned int default_depth; 561afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int default_class; 562afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 563afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg mask = VisualScreenMask | VisualDepthMask | VisualClassMask; 564afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg temp.screen = scr; 565afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg temp.depth = depth; 566afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg temp.CLASS = xclass; 567afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 568afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default_depth = DefaultDepth(dpy,scr); 569afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default_class = DefaultVisual(dpy,scr)->CLASS; 570afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 571afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (depth==default_depth && xclass==default_class) { 572afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* try to get root window's visual */ 573afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg temp.visualid = DefaultVisual(dpy,scr)->visualid; 574afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg mask |= VisualIDMask; 575afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 576afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 577afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = XGetVisualInfo( dpy, mask, &temp, &n ); 578afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 579afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* In case bits/pixel > 24, make sure color channels are still <=8 bits. 580afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * An SGI Infinite Reality system, for example, can have 30bpp pixels: 581afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * 10 bits per color channel. Mesa's limited to a max of 8 bits/channel. 582afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 583afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis && depth > 24 && (xclass==TrueColor || xclass==DirectColor)) { 58471dea349d2be623b7819389428b0d6a124e8d184Brian Paul if (_mesa_bitcount((GLuint) vis->red_mask ) <= 8 && 58571dea349d2be623b7819389428b0d6a124e8d184Brian Paul _mesa_bitcount((GLuint) vis->green_mask) <= 8 && 58671dea349d2be623b7819389428b0d6a124e8d184Brian Paul _mesa_bitcount((GLuint) vis->blue_mask ) <= 8) { 587afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 588afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 589afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 590afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XFree((void *) vis); 591afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 592afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 593afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 594afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 595afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 596afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 597afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 598afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 599afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 600afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 601afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Retrieve the value of the given environment variable and find 602afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * the X visual which matches it. 603afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input: dpy - the display 604afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * screen - the screen number 605afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * varname - the name of the environment variable 606afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return: an XVisualInfo pointer to NULL if error. 607afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 6087287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulstatic XVisualInfo * 6097287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulget_env_visual(Display *dpy, int scr, const char *varname) 610afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 611afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg char value[100], type[100]; 612afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int depth, xclass = -1; 613afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XVisualInfo *vis; 614afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 615367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul if (!_mesa_getenv( varname )) { 616afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 617afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 618afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 619f69d1d1438361f10fd8db78d2d38f26e33db9747Kenneth Graunke strncpy( value, _mesa_getenv(varname), 100 ); 620afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg value[99] = 0; 621afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 622afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg sscanf( value, "%s %d", type, &depth ); 623afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 624367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul if (_mesa_strcmp(type,"TrueColor")==0) xclass = TrueColor; 625367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul else if (_mesa_strcmp(type,"DirectColor")==0) xclass = DirectColor; 626367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul else if (_mesa_strcmp(type,"PseudoColor")==0) xclass = PseudoColor; 627367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul else if (_mesa_strcmp(type,"StaticColor")==0) xclass = StaticColor; 628367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul else if (_mesa_strcmp(type,"GrayScale")==0) xclass = GrayScale; 629367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul else if (_mesa_strcmp(type,"StaticGray")==0) xclass = StaticGray; 630afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 631afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (xclass>-1 && depth>0) { 632afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, scr, depth, xclass ); 633afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 634afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 635afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 636afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 637afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 6382ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul _mesa_warning(NULL, "GLX unable to find visual class=%s, depth=%d.", 6392ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul type, depth); 640d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul 641afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 642afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 643afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 644afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 645afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 646afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 647afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Select an X visual which satisfies the RGBA/CI flag and minimum depth. 648afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input: dpy, screen - X display and screen number 649afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * rgba - GL_TRUE = RGBA mode, GL_FALSE = CI mode 650afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * min_depth - minimum visual depth 651afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * preferred_class - preferred GLX visual class or DONT_CARE 652afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return: pointer to an XVisualInfo or NULL. 653afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 6547287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulstatic XVisualInfo * 6557287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulchoose_x_visual( Display *dpy, int screen, GLboolean rgba, int min_depth, 6567287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul int preferred_class ) 657afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 658afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XVisualInfo *vis; 659db6aa58267cad3f502f03ab80b9deb6b75320a91Brian Paul int xclass, visclass = 0; 660afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int depth; 661afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 662afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (rgba) { 663afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg Atom hp_cr_maps = XInternAtom(dpy, "_HP_RGB_SMOOTH_MAP_LIST", True); 664afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* First see if the MESA_RGB_VISUAL env var is defined */ 665afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_env_visual( dpy, screen, "MESA_RGB_VISUAL" ); 666afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 667afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 668afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 669afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Otherwise, search for a suitable visual */ 670afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (preferred_class==DONT_CARE) { 671afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (xclass=0;xclass<6;xclass++) { 672afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (xclass) { 673afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case 0: visclass = TrueColor; break; 674afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case 1: visclass = DirectColor; break; 675afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case 2: visclass = PseudoColor; break; 676afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case 3: visclass = StaticColor; break; 677afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case 4: visclass = GrayScale; break; 678afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case 5: visclass = StaticGray; break; 679afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 680afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (min_depth==0) { 681afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* start with shallowest */ 682afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (depth=0;depth<=32;depth++) { 683afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (visclass==TrueColor && depth==8 && !hp_cr_maps) { 684afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Special case: try to get 8-bit PseudoColor before */ 685afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* 8-bit TrueColor */ 686afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, screen, 8, PseudoColor ); 687afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 688afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 689afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 690afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 691afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, screen, depth, visclass ); 692afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 693afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 694afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 695afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 696afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 697afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 698afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* start with deepest */ 699afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (depth=32;depth>=min_depth;depth--) { 700afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (visclass==TrueColor && depth==8 && !hp_cr_maps) { 701afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Special case: try to get 8-bit PseudoColor before */ 702afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* 8-bit TrueColor */ 703afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, screen, 8, PseudoColor ); 704afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 705afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 706afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 707afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 708afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, screen, depth, visclass ); 709afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 710afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 711afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 712afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 713afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 714afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 715afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 716afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 717afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* search for a specific visual class */ 718afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (preferred_class) { 719afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRUE_COLOR_EXT: visclass = TrueColor; break; 720afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_DIRECT_COLOR_EXT: visclass = DirectColor; break; 721afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_PSEUDO_COLOR_EXT: visclass = PseudoColor; break; 722afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STATIC_COLOR_EXT: visclass = StaticColor; break; 723afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_GRAY_SCALE_EXT: visclass = GrayScale; break; 724afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STATIC_GRAY_EXT: visclass = StaticGray; break; 725afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: return NULL; 726afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 727afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (min_depth==0) { 728afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* start with shallowest */ 729afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (depth=0;depth<=32;depth++) { 730afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, screen, depth, visclass ); 731afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 732afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 733afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 734afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 735afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 736afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 737afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* start with deepest */ 738afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (depth=32;depth>=min_depth;depth--) { 739afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, screen, depth, visclass ); 740afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 741afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 742afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 743afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 744afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 745afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 746afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 747afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 748afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* First see if the MESA_CI_VISUAL env var is defined */ 749afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_env_visual( dpy, screen, "MESA_CI_VISUAL" ); 750afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 751afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 752afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 753afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Otherwise, search for a suitable visual, starting with shallowest */ 754afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (preferred_class==DONT_CARE) { 755afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (xclass=0;xclass<4;xclass++) { 756afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (xclass) { 757afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case 0: visclass = PseudoColor; break; 758afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case 1: visclass = StaticColor; break; 759afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case 2: visclass = GrayScale; break; 760afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case 3: visclass = StaticGray; break; 761afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 762afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* try 8-bit up through 16-bit */ 763afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (depth=8;depth<=16;depth++) { 764afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, screen, depth, visclass ); 765afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 766afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 767afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 768afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 769afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* try min_depth up to 8-bit */ 770afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (depth=min_depth;depth<8;depth++) { 771afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, screen, depth, visclass ); 772afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 773afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 774afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 775afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 776afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 777afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 778afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 779afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* search for a specific visual class */ 780afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (preferred_class) { 781afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRUE_COLOR_EXT: visclass = TrueColor; break; 782afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_DIRECT_COLOR_EXT: visclass = DirectColor; break; 783afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_PSEUDO_COLOR_EXT: visclass = PseudoColor; break; 784afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STATIC_COLOR_EXT: visclass = StaticColor; break; 785afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_GRAY_SCALE_EXT: visclass = GrayScale; break; 786afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STATIC_GRAY_EXT: visclass = StaticGray; break; 787afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: return NULL; 788afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 789afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* try 8-bit up through 16-bit */ 790afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (depth=8;depth<=16;depth++) { 791afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, screen, depth, visclass ); 792afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 793afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 794afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 795afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 796afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* try min_depth up to 8-bit */ 797afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (depth=min_depth;depth<8;depth++) { 798afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, screen, depth, visclass ); 799afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 800afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 801afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 802afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 803afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 804afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 805afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 806afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* didn't find a visual */ 807afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 808afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 809afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 810afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 811afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 812afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 813afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Find the deepest X over/underlay visual of at least min_depth. 814afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input: dpy, screen - X display and screen number 815afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * level - the over/underlay level 816afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * trans_type - transparent pixel type: GLX_NONE_EXT, 817afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * GLX_TRANSPARENT_RGB_EXT, GLX_TRANSPARENT_INDEX_EXT, 818afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * or DONT_CARE 819afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * trans_value - transparent pixel value or DONT_CARE 820afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * min_depth - minimum visual depth 821afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * preferred_class - preferred GLX visual class or DONT_CARE 822afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return: pointer to an XVisualInfo or NULL. 823afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 8247287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulstatic XVisualInfo * 8257287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulchoose_x_overlay_visual( Display *dpy, int scr, GLboolean rgbFlag, 8267287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul int level, int trans_type, int trans_value, 8277287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul int min_depth, int preferred_class ) 828afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 829afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg OverlayInfo *overlay_info; 830afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int numOverlaysPerScreen; 831afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int i; 832afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XVisualInfo *deepvis; 833afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int deepest; 834afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 835afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /*DEBUG int tt, tv; */ 836afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 837afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (preferred_class) { 838afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRUE_COLOR_EXT: preferred_class = TrueColor; break; 839afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_DIRECT_COLOR_EXT: preferred_class = DirectColor; break; 840afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_PSEUDO_COLOR_EXT: preferred_class = PseudoColor; break; 841afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STATIC_COLOR_EXT: preferred_class = StaticColor; break; 842afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_GRAY_SCALE_EXT: preferred_class = GrayScale; break; 843afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STATIC_GRAY_EXT: preferred_class = StaticGray; break; 844afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: preferred_class = DONT_CARE; 845afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 846afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 8471d97c277e0cb2b75559d495a58222f2511212a66Brian Paul overlay_info = GetOverlayInfo(dpy, scr, &numOverlaysPerScreen); 8481d97c277e0cb2b75559d495a58222f2511212a66Brian Paul if (!overlay_info) { 849afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 850afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 851afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 852afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Search for the deepest overlay which satisifies all criteria. */ 853afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg deepest = min_depth; 854afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg deepvis = NULL; 855afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 8561d97c277e0cb2b75559d495a58222f2511212a66Brian Paul for (i = 0; i < numOverlaysPerScreen; i++) { 8571d97c277e0cb2b75559d495a58222f2511212a66Brian Paul const OverlayInfo *ov = overlay_info + i; 858afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XVisualInfo *vislist, vistemplate; 859afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int count; 860afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 861afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (ov->layer!=level) { 862afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* failed overlay level criteria */ 863afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg continue; 864afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 865afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!(trans_type==DONT_CARE 866afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg || (trans_type==GLX_TRANSPARENT_INDEX_EXT 867afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg && ov->transparent_type>0) 868afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg || (trans_type==GLX_NONE_EXT && ov->transparent_type==0))) { 869afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* failed transparent pixel type criteria */ 870afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg continue; 871afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 872afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (trans_value!=DONT_CARE && trans_value!=ov->value) { 873afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* failed transparent pixel value criteria */ 874afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg continue; 875afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 876afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 877afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* get XVisualInfo and check the depth */ 878afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vistemplate.visualid = ov->overlay_visual; 879afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vistemplate.screen = scr; 880afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vislist = XGetVisualInfo( dpy, VisualIDMask | VisualScreenMask, 881afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg &vistemplate, &count ); 882afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 883afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (count!=1) { 884afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* something went wrong */ 885afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg continue; 886afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 887afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (preferred_class!=DONT_CARE && preferred_class!=vislist->CLASS) { 888afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* wrong visual class */ 889afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg continue; 890afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 891afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 89242f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul /* if RGB was requested, make sure we have True/DirectColor */ 89342f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul if (rgbFlag && vislist->CLASS != TrueColor 89442f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul && vislist->CLASS != DirectColor) 89542f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul continue; 89642f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul 89742f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul /* if CI was requested, make sure we have a color indexed visual */ 89842f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul if (!rgbFlag 89942f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul && (vislist->CLASS == TrueColor || vislist->CLASS == DirectColor)) 90042f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul continue; 90142f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul 902afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (deepvis==NULL || vislist->depth > deepest) { 903afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* YES! found a satisfactory visual */ 904afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (deepvis) { 90580af3614d88c0cac160e787de7f34b37e96cb626Brian Paul XFree( deepvis ); 906afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 907afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg deepest = vislist->depth; 908afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg deepvis = vislist; 909afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* DEBUG tt = ov->transparent_type;*/ 910afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* DEBUG tv = ov->value; */ 911afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 912afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 913afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 914afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*DEBUG 915afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (deepvis) { 916afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg printf("chose 0x%x: layer=%d depth=%d trans_type=%d trans_value=%d\n", 917afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg deepvis->visualid, level, deepvis->depth, tt, tv ); 918afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 919afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg*/ 920afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return deepvis; 921afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 922afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 923afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 9247cf50e137da497a590ec9001a9918972a6246142Brian Paul/**********************************************************************/ 9256c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul/*** Display-related functions ***/ 9266c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul/**********************************************************************/ 9276c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul 9286c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul 9296c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul/** 9306c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul * Free all XMesaVisuals which are associated with the given display. 9316c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul */ 9326c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paulstatic void 9336c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Pauldestroy_visuals_on_display(Display *dpy) 9346c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul{ 9356c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul int i; 9366c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul for (i = 0; i < NumVisuals; i++) { 9376c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul if (VisualTable[i]->display == dpy) { 9386c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul /* remove this visual */ 9396c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul int j; 9406c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul free(VisualTable[i]); 9416c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul for (j = i; j < NumVisuals - 1; j++) 9426c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul VisualTable[j] = VisualTable[j + 1]; 9436c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul NumVisuals--; 9446c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul } 9456c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul } 9466c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul} 9476c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul 9486c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul 9496c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul/** 9506c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul * Called from XCloseDisplay() to let us free our display-related data. 9516c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul */ 9526c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paulstatic int 9536c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paulclose_display_callback(Display *dpy, XExtCodes *codes) 9546c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul{ 9556c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul destroy_visuals_on_display(dpy); 9566c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul xmesa_destroy_buffers_on_display(dpy); 9576c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul return 0; 9586c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul} 9596c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul 9606c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul 9616c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul/** 9626c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul * Look for the named extension on given display and return a pointer 9636c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul * to the _XExtension data, or NULL if extension not found. 9646c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul */ 9656c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paulstatic _XExtension * 9666c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paullookup_extension(Display *dpy, const char *extName) 9676c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul{ 9686c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul _XExtension *ext; 9696c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul for (ext = dpy->ext_procs; ext; ext = ext->next) { 97052e36cd8d9a727d786c2db14ae8291d48fad8e47Brian Paul if (ext->name && strcmp(ext->name, extName) == 0) { 9716c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul return ext; 9726c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul } 9736c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul } 9746c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul return NULL; 9756c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul} 9766c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul 9776c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul 9786c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul/** 9796c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul * Whenever we're given a new Display pointer, call this function to 9806c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul * register our close_display_callback function. 9816c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul */ 9826c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paulstatic void 9836c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paulregister_with_display(Display *dpy) 9846c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul{ 9856c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul const char *extName = "MesaGLX"; 9866c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul _XExtension *ext; 9876c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul 9886c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul ext = lookup_extension(dpy, extName); 9896c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul if (!ext) { 9906c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul XExtCodes *c = XAddExtension(dpy); 9916c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul ext = dpy->ext_procs; /* new extension is at head of list */ 9926c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul assert(c->extension == ext->codes.extension); 9936c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul ext->name = _mesa_strdup(extName); 9946c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul ext->close_display = close_display_callback; 9956c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul } 9966c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul} 9976c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul 9986c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul 9996c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul/**********************************************************************/ 10007cf50e137da497a590ec9001a9918972a6246142Brian Paul/*** Begin Fake GLX API Functions ***/ 10017cf50e137da497a590ec9001a9918972a6246142Brian Paul/**********************************************************************/ 10027cf50e137da497a590ec9001a9918972a6246142Brian Paul 1003afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1004ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul/** 1005ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul * Helper used by glXChooseVisual and glXChooseFBConfig. 1006ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul * The fbConfig parameter must be GL_FALSE for the former and GL_TRUE for 1007ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul * the later. 1008ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul * In either case, the attribute list is terminated with the value 'None'. 1009ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul */ 10107287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulstatic XMesaVisual 10111f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paulchoose_visual( Display *dpy, int screen, const int *list, GLboolean fbConfig ) 1012afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 10131f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul const GLboolean rgbModeDefault = fbConfig; 10143265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul const int *parselist; 1015afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XVisualInfo *vis; 1016afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int min_ci = 0; 1017afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int min_red=0, min_green=0, min_blue=0; 1018b3063ac398b72e6a4fd2015d4e220495b9779294Brian Paul GLboolean rgb_flag = rgbModeDefault; 1019afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLboolean alpha_flag = GL_FALSE; 1020afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLboolean double_flag = GL_FALSE; 1021afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLboolean stereo_flag = GL_FALSE; 1022afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLint depth_size = 0; 1023afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLint stencil_size = 0; 1024b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint accumRedSize = 0; 1025b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint accumGreenSize = 0; 1026b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint accumBlueSize = 0; 1027b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint accumAlphaSize = 0; 1028afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int level = 0; 1029afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int visual_type = DONT_CARE; 1030afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int trans_type = DONT_CARE; 1031afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int trans_value = DONT_CARE; 1032e1210b176926349b258c7ec77b7f36716025c82aBrian Paul GLint caveat = DONT_CARE; 10333265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul XMesaVisual xmvis = NULL; 10343a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul int desiredVisualID = -1; 1035894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul int numAux = 0; 1036afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1037afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist = list; 1038afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1039afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg while (*parselist) { 1040afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1041afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (*parselist) { 1042afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_USE_GL: 10431f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul if (fbConfig) { 10441f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul /* invalid token */ 10451f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul return NULL; 10461f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul } 10471f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul else { 10481f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul /* skip */ 10491f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul parselist++; 10501f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul } 1051afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 1052afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_BUFFER_SIZE: 1053afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1054afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg min_ci = *parselist++; 1055afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 1056afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_LEVEL: 1057afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1058afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg level = *parselist++; 1059afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 1060afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_RGBA: 10611f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul if (fbConfig) { 10621f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul /* invalid token */ 10631f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul return NULL; 10641f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul } 10651f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul else { 10661f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul rgb_flag = GL_TRUE; 10671f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul parselist++; 10681f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul } 1069afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 1070afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_DOUBLEBUFFER: 10711f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul parselist++; 10721f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul if (fbConfig) { 10731f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul double_flag = *parselist++; 10741f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul } 10751f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul else { 10761f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul double_flag = GL_TRUE; 10771f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul } 1078afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 1079afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STEREO: 10801f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul parselist++; 10811f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul if (fbConfig) { 10821f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul stereo_flag = *parselist++; 10831f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul } 10841f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul else { 10851f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul stereo_flag = GL_TRUE; 10861f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul } 1087da2f1e88bc63403a95b89706905c070b7c894863Brian break; 1088afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_AUX_BUFFERS: 1089afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1090894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul numAux = *parselist++; 1091894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul if (numAux > MAX_AUX_BUFFERS) 1092894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul return NULL; 1093afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 1094afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_RED_SIZE: 1095afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1096afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg min_red = *parselist++; 1097afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 1098afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_GREEN_SIZE: 1099afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1100afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg min_green = *parselist++; 1101afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 1102afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_BLUE_SIZE: 1103afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1104afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg min_blue = *parselist++; 1105afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 1106afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ALPHA_SIZE: 1107afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1108afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg { 1109afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLint size = *parselist++; 1110c12ee99d119debe1a421a77c1cc6d99d958ae94bBrian Paul alpha_flag = size ? GL_TRUE : GL_FALSE; 1111afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1112afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 1113afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_DEPTH_SIZE: 1114afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1115afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg depth_size = *parselist++; 1116afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 1117afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STENCIL_SIZE: 1118afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1119afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg stencil_size = *parselist++; 1120afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 1121afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_RED_SIZE: 1122b2e460018375f699198073a6167e0ee96ba1d267Brian Paul parselist++; 1123b2e460018375f699198073a6167e0ee96ba1d267Brian Paul { 1124b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint size = *parselist++; 1125b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumRedSize = MAX2( accumRedSize, size ); 1126b2e460018375f699198073a6167e0ee96ba1d267Brian Paul } 1127b2e460018375f699198073a6167e0ee96ba1d267Brian Paul break; 1128afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_GREEN_SIZE: 1129b2e460018375f699198073a6167e0ee96ba1d267Brian Paul parselist++; 1130b2e460018375f699198073a6167e0ee96ba1d267Brian Paul { 1131b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint size = *parselist++; 1132b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumGreenSize = MAX2( accumGreenSize, size ); 1133b2e460018375f699198073a6167e0ee96ba1d267Brian Paul } 1134b2e460018375f699198073a6167e0ee96ba1d267Brian Paul break; 1135afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_BLUE_SIZE: 1136b2e460018375f699198073a6167e0ee96ba1d267Brian Paul parselist++; 1137b2e460018375f699198073a6167e0ee96ba1d267Brian Paul { 1138b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint size = *parselist++; 1139b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumBlueSize = MAX2( accumBlueSize, size ); 1140b2e460018375f699198073a6167e0ee96ba1d267Brian Paul } 1141b2e460018375f699198073a6167e0ee96ba1d267Brian Paul break; 1142afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_ALPHA_SIZE: 1143afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1144afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg { 1145afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLint size = *parselist++; 1146b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumAlphaSize = MAX2( accumAlphaSize, size ); 1147afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1148afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 1149afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1150afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* 1151afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * GLX_EXT_visual_info extension 1152afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 1153afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_X_VISUAL_TYPE_EXT: 1154afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1155afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg visual_type = *parselist++; 1156afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 1157afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_TYPE_EXT: 1158afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1159afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg trans_type = *parselist++; 1160afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 1161afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_INDEX_VALUE_EXT: 1162afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1163afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg trans_value = *parselist++; 1164afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 1165afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_RED_VALUE_EXT: 1166afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_GREEN_VALUE_EXT: 1167afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_BLUE_VALUE_EXT: 1168afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_ALPHA_VALUE_EXT: 1169afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* ignore */ 1170afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1171afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1172afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 11735e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen 1174e1210b176926349b258c7ec77b7f36716025c82aBrian Paul /* 1175e1210b176926349b258c7ec77b7f36716025c82aBrian Paul * GLX_EXT_visual_info extension 1176e1210b176926349b258c7ec77b7f36716025c82aBrian Paul */ 1177e1210b176926349b258c7ec77b7f36716025c82aBrian Paul case GLX_VISUAL_CAVEAT_EXT: 1178e1210b176926349b258c7ec77b7f36716025c82aBrian Paul parselist++; 1179e1210b176926349b258c7ec77b7f36716025c82aBrian Paul caveat = *parselist++; /* ignored for now */ 1180e1210b176926349b258c7ec77b7f36716025c82aBrian Paul break; 1181e1210b176926349b258c7ec77b7f36716025c82aBrian Paul 11823265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul /* 118366ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul * GLX_ARB_multisample 118466ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul */ 118566ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul case GLX_SAMPLE_BUFFERS_ARB: 118666ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul case GLX_SAMPLES_ARB: 1187e903f51bc43fde1f61a779fd8017c96a651781acBrian Paul parselist++; 1188e903f51bc43fde1f61a779fd8017c96a651781acBrian Paul if (*parselist++ != 0) 1189e903f51bc43fde1f61a779fd8017c96a651781acBrian Paul /* ms not supported */ 1190e903f51bc43fde1f61a779fd8017c96a651781acBrian Paul return NULL; 1191e903f51bc43fde1f61a779fd8017c96a651781acBrian Paul break; 119266ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul 119366ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul /* 11943265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul * FBConfig attribs. 11953265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul */ 11963265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_RENDER_TYPE: 1197dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul if (!fbConfig) 1198dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul return NULL; 11993265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul parselist++; 1200584b0879ac2ec2420ea6866e47eb90e1a980e758Brian Paul if (*parselist & GLX_RGBA_BIT) { 12013265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul rgb_flag = GL_TRUE; 12023265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 1203584b0879ac2ec2420ea6866e47eb90e1a980e758Brian Paul else if (*parselist & GLX_COLOR_INDEX_BIT) { 12043265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul rgb_flag = GL_FALSE; 12053265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 12063265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul else if (*parselist == 0) { 12073265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul rgb_flag = GL_TRUE; 12083265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 12093265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul parselist++; 12103265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 12113265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_DRAWABLE_TYPE: 1212dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul if (!fbConfig) 1213dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul return NULL; 12143265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul parselist++; 12153265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (*parselist & ~(GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT)) { 12163265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return NULL; /* bad bit */ 12173265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 12183265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul parselist++; 12193265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 12203a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul case GLX_FBCONFIG_ID: 1221dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul if (!fbConfig) 1222dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul return NULL; 12233a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul parselist++; 1224dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul desiredVisualID = *parselist++; 1225dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul break; 1226dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul case GLX_X_RENDERABLE: 1227dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul if (!fbConfig) 1228dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul return NULL; 1229dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul parselist += 2; 1230dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul /* ignore */ 12313a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul break; 12323265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul 1233fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian#ifdef GLX_EXT_texture_from_pixmap 1234fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_BIND_TO_TEXTURE_RGB_EXT: 1235fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian parselist++; /*skip*/ 1236fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 1237fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_BIND_TO_TEXTURE_RGBA_EXT: 1238fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian parselist++; /*skip*/ 1239fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 1240fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_BIND_TO_MIPMAP_TEXTURE_EXT: 1241fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian parselist++; /*skip*/ 1242fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 1243fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_BIND_TO_TEXTURE_TARGETS_EXT: 1244fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian parselist++; 1245fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (*parselist & ~(GLX_TEXTURE_1D_BIT_EXT | 1246fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian GLX_TEXTURE_2D_BIT_EXT | 1247fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian GLX_TEXTURE_RECTANGLE_BIT_EXT)) { 1248fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian /* invalid bit */ 1249fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian return NULL; 1250fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 1251fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 1252fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_Y_INVERTED_EXT: 1253fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian parselist++; /*skip*/ 1254fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 1255fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian#endif 1256fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian 1257afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case None: 12583a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul /* end of list */ 1259afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 12603265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul 1261afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: 1262afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* undefined attribute */ 12632ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul _mesa_warning(NULL, "unexpected attrib 0x%x in choose_visual()", 12642ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul *parselist); 1265afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 1266afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1267afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1268afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1269b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul (void) caveat; 1270b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul 1271afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* 1272afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Since we're only simulating the GLX extension this function will never 1273afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * find any real GL visuals. Instead, all we can do is try to find an RGB 1274afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * or CI visual of appropriate depth. Other requested attributes such as 1275afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * double buffering, depth buffer, etc. will be associated with the X 1276afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * visual and stored in the VisualTable[]. 1277afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 12783a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul if (desiredVisualID != -1) { 12793a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul /* try to get a specific visual, by visualID */ 12803a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul XVisualInfo temp; 12813a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul int n; 12823a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul temp.visualid = desiredVisualID; 12833a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul temp.screen = screen; 12843a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul vis = XGetVisualInfo(dpy, VisualIDMask | VisualScreenMask, &temp, &n); 12853a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul if (vis) { 12863a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul /* give the visual some useful GLX attributes */ 12873a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul double_flag = GL_TRUE; 12883a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul if (vis->depth > 8) 12893a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul rgb_flag = GL_TRUE; 1290dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul depth_size = default_depth_bits(); 12913a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul stencil_size = STENCIL_BITS; 12923a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul /* XXX accum??? */ 12933a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul } 12943a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul } 12953a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul else if (level==0) { 1296afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* normal color planes */ 1297afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (rgb_flag) { 1298afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Get an RGB visual */ 1299afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int min_rgb = min_red + min_green + min_blue; 1300afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (min_rgb>1 && min_rgb<8) { 1301afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* a special case to be sure we can get a monochrome visual */ 1302afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg min_rgb = 1; 1303afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1304afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = choose_x_visual( dpy, screen, rgb_flag, min_rgb, visual_type ); 1305afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1306afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 1307afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Get a color index visual */ 1308afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = choose_x_visual( dpy, screen, rgb_flag, min_ci, visual_type ); 1309b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumRedSize = accumGreenSize = accumBlueSize = accumAlphaSize = 0; 1310afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1311afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1312afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 1313afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* over/underlay planes */ 131442f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul if (rgb_flag) { 131542f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul /* rgba overlay */ 131642f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul int min_rgb = min_red + min_green + min_blue; 131742f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul if (min_rgb>1 && min_rgb<8) { 131842f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul /* a special case to be sure we can get a monochrome visual */ 131942f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul min_rgb = 1; 132042f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul } 132142f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul vis = choose_x_overlay_visual( dpy, screen, rgb_flag, level, 132242f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul trans_type, trans_value, min_rgb, visual_type ); 132342f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul } 132442f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul else { 132542f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul /* color index overlay */ 132642f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul vis = choose_x_overlay_visual( dpy, screen, rgb_flag, level, 132742f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul trans_type, trans_value, min_ci, visual_type ); 132842f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul } 1329afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1330afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1331afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 1332ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul /* Note: we're not exactly obeying the glXChooseVisual rules here. 1333ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * When GLX_DEPTH_SIZE = 1 is specified we're supposed to choose the 13342c7e6334ec81c2fab2cce9e0fe52cd30256e37eaBrian Paul * largest depth buffer size, which is 32bits/value. Instead, we 1335ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * return 16 to maintain performance with earlier versions of Mesa. 1336ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul */ 13372c7e6334ec81c2fab2cce9e0fe52cd30256e37eaBrian Paul if (depth_size > 24) 13389e4e3adcf82a72e9a74f21b492fbf5552ebfd47fBrian Paul depth_size = 32; 1339ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul else if (depth_size > 16) 1340ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul depth_size = 24; 1341dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul else if (depth_size > 0) { 1342dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul depth_size = default_depth_bits(); 1343dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul } 13442c7e6334ec81c2fab2cce9e0fe52cd30256e37eaBrian Paul 1345c12ee99d119debe1a421a77c1cc6d99d958ae94bBrian Paul if (!alpha_flag) { 1346c12ee99d119debe1a421a77c1cc6d99d958ae94bBrian Paul alpha_flag = default_alpha_bits() > 0; 1347c12ee99d119debe1a421a77c1cc6d99d958ae94bBrian Paul } 1348c12ee99d119debe1a421a77c1cc6d99d958ae94bBrian Paul 1349ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul /* we only support one size of stencil and accum buffers. */ 1350ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul if (stencil_size > 0) 1351ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul stencil_size = STENCIL_BITS; 13526d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul if (accumRedSize > 0 || accumGreenSize > 0 || accumBlueSize > 0 || 13536d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul accumAlphaSize > 0) { 1354978ef2bb6d9ca4996a24f95820a699e22c84f70bBrian Paul accumRedSize = 1355978ef2bb6d9ca4996a24f95820a699e22c84f70bBrian Paul accumGreenSize = 1356978ef2bb6d9ca4996a24f95820a699e22c84f70bBrian Paul accumBlueSize = default_accum_bits(); 1357978ef2bb6d9ca4996a24f95820a699e22c84f70bBrian Paul accumAlphaSize = alpha_flag ? accumRedSize : 0; 13586d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul } 13596d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul 13603265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul xmvis = save_glx_visual( dpy, vis, rgb_flag, alpha_flag, double_flag, 13613265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul stereo_flag, depth_size, stencil_size, 13623265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul accumRedSize, accumGreenSize, 1363894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul accumBlueSize, accumAlphaSize, level, numAux ); 1364afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1365afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 13663265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return xmvis; 1367afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1368afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1369afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 13703265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paulstatic XVisualInfo * 13713265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian PaulFake_glXChooseVisual( Display *dpy, int screen, int *list ) 13723265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul{ 13736c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul XMesaVisual xmvis; 13746c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul 13756c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul /* register ourselves as an extension on this display */ 13766c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul register_with_display(dpy); 13776c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul 13786c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul xmvis = choose_visual(dpy, screen, list, GL_FALSE); 1379f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul if (xmvis) { 1380f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul#if 0 1381f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul return xmvis->vishandle; 1382f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul#else 1383f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul /* create a new vishandle - the cached one may be stale */ 13844039cb8ca82d59451a6de8902fe35e693cdca3baBrian Paul xmvis->vishandle = (XVisualInfo *) _mesa_malloc(sizeof(XVisualInfo)); 1385f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul if (xmvis->vishandle) { 1386f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul _mesa_memcpy(xmvis->vishandle, xmvis->visinfo, sizeof(XVisualInfo)); 1387f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul } 13883265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return xmvis->vishandle; 1389f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul#endif 1390f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul } 13913265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul else 13923265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return NULL; 13933265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul} 1394afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1395afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 139649e80bf6b163310f7cd776261872201eea57053aBrian Paul/** 139749e80bf6b163310f7cd776261872201eea57053aBrian Paul * Init basic fields of a new fake_glx_context. 139849e80bf6b163310f7cd776261872201eea57053aBrian Paul */ 139949e80bf6b163310f7cd776261872201eea57053aBrian Paulstatic void 140049e80bf6b163310f7cd776261872201eea57053aBrian Paulinit_glx_context(struct fake_glx_context *glxCtx, Display *dpy) 140149e80bf6b163310f7cd776261872201eea57053aBrian Paul{ 1402c35a5aeb706d33b9c09b5a12bbbeae0f109885c9Brian Paul /* Always return True. See if anyone's confused... */ 1403c35a5aeb706d33b9c09b5a12bbbeae0f109885c9Brian Paul GLboolean direct = GL_TRUE; 1404c35a5aeb706d33b9c09b5a12bbbeae0f109885c9Brian Paul 140549e80bf6b163310f7cd776261872201eea57053aBrian Paul glxCtx->xmesaContext->direct = direct; 140649e80bf6b163310f7cd776261872201eea57053aBrian Paul glxCtx->glxContext.isDirect = direct; 140749e80bf6b163310f7cd776261872201eea57053aBrian Paul glxCtx->glxContext.currentDpy = dpy; 140849e80bf6b163310f7cd776261872201eea57053aBrian Paul glxCtx->glxContext.xid = (XID) glxCtx; /* self pointer */ 140949e80bf6b163310f7cd776261872201eea57053aBrian Paul 141049e80bf6b163310f7cd776261872201eea57053aBrian Paul assert((void *) glxCtx == (void *) &(glxCtx->glxContext)); 141149e80bf6b163310f7cd776261872201eea57053aBrian Paul} 141249e80bf6b163310f7cd776261872201eea57053aBrian Paul 141349e80bf6b163310f7cd776261872201eea57053aBrian Paul 141449e80bf6b163310f7cd776261872201eea57053aBrian Paul 1415426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXContext 1416426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateContext( Display *dpy, XVisualInfo *visinfo, 1417426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul GLXContext share_list, Bool direct ) 1418afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1419e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaVisual xmvis; 14207cf50e137da497a590ec9001a9918972a6246142Brian Paul struct fake_glx_context *glxCtx; 14215e1680ce1d8296b2182e8909856927bbeddf3b95Brian Paul struct fake_glx_context *shareCtx = (struct fake_glx_context *) share_list; 142299aab341998e84d9fa208c525cae8021b3845812Brian Paul 142399aab341998e84d9fa208c525cae8021b3845812Brian Paul if (!dpy || !visinfo) 142499aab341998e84d9fa208c525cae8021b3845812Brian Paul return 0; 142599aab341998e84d9fa208c525cae8021b3845812Brian Paul 14267cf50e137da497a590ec9001a9918972a6246142Brian Paul glxCtx = CALLOC_STRUCT(fake_glx_context); 14277cf50e137da497a590ec9001a9918972a6246142Brian Paul if (!glxCtx) 14287cf50e137da497a590ec9001a9918972a6246142Brian Paul return 0; 1429afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1430afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* deallocate unused windows/buffers */ 14316c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul#if 0 1432afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaGarbageCollect(); 14336c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul#endif 1434afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1435e4656003caee346d9c4eb23256d73409271291a7Brian Paul xmvis = find_glx_visual( dpy, visinfo ); 1436e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (!xmvis) { 1437afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* This visual wasn't found with glXChooseVisual() */ 1438e4656003caee346d9c4eb23256d73409271291a7Brian Paul xmvis = create_glx_visual( dpy, visinfo ); 1439e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (!xmvis) { 1440afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* unusable visual */ 14410c54e47c0e93f725b8bc028b0d4614011dbe3fefBrian Paul _mesa_free(glxCtx); 1442afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 1443afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1444afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1445afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1446e4656003caee346d9c4eb23256d73409271291a7Brian Paul glxCtx->xmesaContext = XMesaCreateContext(xmvis, 14475e1680ce1d8296b2182e8909856927bbeddf3b95Brian Paul shareCtx ? shareCtx->xmesaContext : NULL); 14487cf50e137da497a590ec9001a9918972a6246142Brian Paul if (!glxCtx->xmesaContext) { 14490c54e47c0e93f725b8bc028b0d4614011dbe3fefBrian Paul _mesa_free(glxCtx); 14507cf50e137da497a590ec9001a9918972a6246142Brian Paul return NULL; 1451afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 14527cf50e137da497a590ec9001a9918972a6246142Brian Paul 145349e80bf6b163310f7cd776261872201eea57053aBrian Paul init_glx_context(glxCtx, dpy); 14547cf50e137da497a590ec9001a9918972a6246142Brian Paul 14557cf50e137da497a590ec9001a9918972a6246142Brian Paul return (GLXContext) glxCtx; 1456afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1457afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1458afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 14597cf50e137da497a590ec9001a9918972a6246142Brian Paul/* XXX these may have to be removed due to thread-safety issues. */ 1460afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic GLXContext MakeCurrent_PrevContext = 0; 1461086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic GLXDrawable MakeCurrent_PrevDrawable = 0; 1462086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic GLXDrawable MakeCurrent_PrevReadable = 0; 1463086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic XMesaBuffer MakeCurrent_PrevDrawBuffer = 0; 1464086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic XMesaBuffer MakeCurrent_PrevReadBuffer = 0; 1465afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 14667cf50e137da497a590ec9001a9918972a6246142Brian Paul 1467086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul/* GLX 1.3 and later */ 1468426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool 1469426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXMakeContextCurrent( Display *dpy, GLXDrawable draw, 14707a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell GLXDrawable read, GLXContext ctx ) 1471086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul{ 14727cf50e137da497a590ec9001a9918972a6246142Brian Paul struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx; 14737cf50e137da497a590ec9001a9918972a6246142Brian Paul 14747a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell if (ctx && draw && read) { 1475086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul XMesaBuffer drawBuffer, readBuffer; 14767cf50e137da497a590ec9001a9918972a6246142Brian Paul XMesaContext xmctx = glxCtx->xmesaContext; 1477086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul 1478086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* Find the XMesaBuffer which corresponds to the GLXDrawable 'draw' */ 14797a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell if (ctx == MakeCurrent_PrevContext 14807a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell && draw == MakeCurrent_PrevDrawable) { 1481086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul drawBuffer = MakeCurrent_PrevDrawBuffer; 1482086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1483086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul else { 1484086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul drawBuffer = XMesaFindBuffer( dpy, draw ); 1485086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1486086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul if (!drawBuffer) { 1487086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* drawable must be a new window! */ 14886aa5668871e7f366b33e85fabc72885fc269a7d4George Sapountzis drawBuffer = XMesaCreateWindowBuffer( xmctx->xm_visual, draw ); 1489086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul if (!drawBuffer) { 1490086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* Out of memory, or context/drawable depth mismatch */ 1491086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul return False; 1492086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 14936aa5668871e7f366b33e85fabc72885fc269a7d4George Sapountzis#ifdef FX 14946aa5668871e7f366b33e85fabc72885fc269a7d4George Sapountzis FXcreateContext( xmctx->xm_visual, draw, xmctx, drawBuffer ); 14956aa5668871e7f366b33e85fabc72885fc269a7d4George Sapountzis#endif 1496086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1497086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul 1498086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* Find the XMesaBuffer which corresponds to the GLXDrawable 'read' */ 14997a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell if (ctx == MakeCurrent_PrevContext 1500086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul && read == MakeCurrent_PrevReadable) { 1501086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul readBuffer = MakeCurrent_PrevReadBuffer; 1502086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1503086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul else { 1504086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul readBuffer = XMesaFindBuffer( dpy, read ); 1505086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1506086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul if (!readBuffer) { 1507086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* drawable must be a new window! */ 15086aa5668871e7f366b33e85fabc72885fc269a7d4George Sapountzis readBuffer = XMesaCreateWindowBuffer( xmctx->xm_visual, read ); 1509086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul if (!readBuffer) { 1510086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* Out of memory, or context/drawable depth mismatch */ 1511086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul return False; 1512086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 15136aa5668871e7f366b33e85fabc72885fc269a7d4George Sapountzis#ifdef FX 15146aa5668871e7f366b33e85fabc72885fc269a7d4George Sapountzis FXcreateContext( xmctx->xm_visual, read, xmctx, readBuffer ); 15156aa5668871e7f366b33e85fabc72885fc269a7d4George Sapountzis#endif 1516086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1517086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul 15187a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell MakeCurrent_PrevContext = ctx; 1519086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevDrawable = draw; 1520086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevReadable = read; 1521086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevDrawBuffer = drawBuffer; 1522086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevReadBuffer = readBuffer; 1523086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul 1524086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* Now make current! */ 15257cf50e137da497a590ec9001a9918972a6246142Brian Paul if (XMesaMakeCurrent2(xmctx, drawBuffer, readBuffer)) { 152612c1bee87fcc3a0912685bb6e83447972e5de64eBrian Paul ((__GLXcontext *) ctx)->currentDpy = dpy; 152712c1bee87fcc3a0912685bb6e83447972e5de64eBrian Paul ((__GLXcontext *) ctx)->currentDrawable = draw; 152812c1bee87fcc3a0912685bb6e83447972e5de64eBrian Paul ((__GLXcontext *) ctx)->currentReadable = read; 15297cf50e137da497a590ec9001a9918972a6246142Brian Paul return True; 15307cf50e137da497a590ec9001a9918972a6246142Brian Paul } 15317cf50e137da497a590ec9001a9918972a6246142Brian Paul else { 15327cf50e137da497a590ec9001a9918972a6246142Brian Paul return False; 15337cf50e137da497a590ec9001a9918972a6246142Brian Paul } 1534086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 15357a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell else if (!ctx && !draw && !read) { 1536086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* release current context w/out assigning new one. */ 1537086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul XMesaMakeCurrent( NULL, NULL ); 1538086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevContext = 0; 1539086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevDrawable = 0; 1540086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevReadable = 0; 1541086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevDrawBuffer = 0; 1542086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevReadBuffer = 0; 1543086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul return True; 1544086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1545086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul else { 1546086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* The args must either all be non-zero or all zero. 1547086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul * This is an error. 1548086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul */ 1549086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul return False; 1550086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1551086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul} 1552086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul 1553086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul 1554426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool 1555426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXMakeCurrent( Display *dpy, GLXDrawable drawable, GLXContext ctx ) 1556426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 1557426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul return Fake_glXMakeContextCurrent( dpy, drawable, drawable, ctx ); 1558426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1559426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1560426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1561426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPixmap 1562426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateGLXPixmap( Display *dpy, XVisualInfo *visinfo, Pixmap pixmap ) 1563afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1564afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaVisual v; 1565afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaBuffer b; 1566afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1567afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg v = find_glx_visual( dpy, visinfo ); 1568afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!v) { 1569afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg v = create_glx_visual( dpy, visinfo ); 1570afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!v) { 1571afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* unusable visual */ 1572afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1573afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1574afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1575afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1576afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg b = XMesaCreatePixmapBuffer( v, pixmap, 0 ); 1577afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!b) { 1578afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1579afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1580e4b2356c07d31fbeeabb13b2fb47db703b473080Brian Paul return b->frontxrb->pixmap; 1581afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1582afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1583afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1584b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_MESA_pixmap_colormap ***/ 1585b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul 1586426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPixmap 1587426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visinfo, 1588426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul Pixmap pixmap, Colormap cmap ) 1589afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1590afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaVisual v; 1591afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaBuffer b; 1592afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1593afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg v = find_glx_visual( dpy, visinfo ); 1594afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!v) { 1595afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg v = create_glx_visual( dpy, visinfo ); 1596afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!v) { 1597afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* unusable visual */ 1598afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1599afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1600afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1601afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1602afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg b = XMesaCreatePixmapBuffer( v, pixmap, cmap ); 1603afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!b) { 1604afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1605afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1606e4b2356c07d31fbeeabb13b2fb47db703b473080Brian Paul return b->frontxrb->pixmap; 1607afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1608afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1609afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1610426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1611426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyGLXPixmap( Display *dpy, GLXPixmap pixmap ) 1612afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1613afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaBuffer b = XMesaFindBuffer(dpy, pixmap); 1614afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (b) { 1615afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaDestroyBuffer(b); 1616afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1617367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul else if (_mesa_getenv("MESA_DEBUG")) { 1618d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul _mesa_warning(NULL, "Mesa: glXDestroyGLXPixmap: invalid pixmap\n"); 1619afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1620afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1621afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1622afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1623426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1624426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCopyContext( Display *dpy, GLXContext src, GLXContext dst, 16253994b77bab8c62a4c1a4dffdfba233ef46662b99Brian Paul unsigned long mask ) 1626afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 162783b820aa98931ef30fa73c72b2a96fe23885955eBrian Paul struct fake_glx_context *fakeSrc = (struct fake_glx_context *) src; 162883b820aa98931ef30fa73c72b2a96fe23885955eBrian Paul struct fake_glx_context *fakeDst = (struct fake_glx_context *) dst; 162983b820aa98931ef30fa73c72b2a96fe23885955eBrian Paul XMesaContext xm_src = fakeSrc->xmesaContext; 163083b820aa98931ef30fa73c72b2a96fe23885955eBrian Paul XMesaContext xm_dst = fakeDst->xmesaContext; 1631afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 163268edf28df68701ac429e53c0fd6dbb70b39c3fd0Brian Paul if (MakeCurrent_PrevContext == src) { 163368edf28df68701ac429e53c0fd6dbb70b39c3fd0Brian Paul _mesa_Flush(); 163468edf28df68701ac429e53c0fd6dbb70b39c3fd0Brian Paul } 16351e24d3318df57b36e3b68695ff64b4b8bd822c9eBrian Paul _mesa_copy_context( &(xm_src->mesa), &(xm_dst->mesa), (GLuint) mask ); 1636afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1637afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1638afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1639426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool 1640e3fff3daf031a997a1d4316e1a0e5c831573221dBrian PaulFake_glXQueryExtension( Display *dpy, int *errorBase, int *eventBase ) 1641afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 16429f002e4aaa2d7ea085cd0a3c66ff0fa533905382Brian Paul int op, ev, err; 1643afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Mesa's GLX isn't really an X extension but we try to act like one. */ 16449f002e4aaa2d7ea085cd0a3c66ff0fa533905382Brian Paul if (!XQueryExtension(dpy, GLX_EXTENSION_NAME, &op, &ev, &err)) 16459f002e4aaa2d7ea085cd0a3c66ff0fa533905382Brian Paul ev = err = 0; 1646e3fff3daf031a997a1d4316e1a0e5c831573221dBrian Paul if (errorBase) 16479f002e4aaa2d7ea085cd0a3c66ff0fa533905382Brian Paul *errorBase = err; 1648e3fff3daf031a997a1d4316e1a0e5c831573221dBrian Paul if (eventBase) 16499f002e4aaa2d7ea085cd0a3c66ff0fa533905382Brian Paul *eventBase = ev; 16509f002e4aaa2d7ea085cd0a3c66ff0fa533905382Brian Paul return True; /* we're faking GLX so always return success */ 1651afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1652afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1653afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1654e7b16b74bf5d13331b5a88bbbbb9096560297b63Brian Paulextern void _kw_ungrab_all( Display *dpy ); 1655afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgvoid _kw_ungrab_all( Display *dpy ) 1656afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1657afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XUngrabPointer( dpy, CurrentTime ); 1658afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XUngrabKeyboard( dpy, CurrentTime ); 1659afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1660afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1661afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1662426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1663426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyContext( Display *dpy, GLXContext ctx ) 1664afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 16657cf50e137da497a590ec9001a9918972a6246142Brian Paul struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx; 1666afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 1667afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg MakeCurrent_PrevContext = 0; 1668afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg MakeCurrent_PrevDrawable = 0; 1669086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevReadable = 0; 1670086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevDrawBuffer = 0; 1671086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevReadBuffer = 0; 16727cf50e137da497a590ec9001a9918972a6246142Brian Paul XMesaDestroyContext( glxCtx->xmesaContext ); 1673afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaGarbageCollect(); 16740c54e47c0e93f725b8bc028b0d4614011dbe3fefBrian Paul _mesa_free(glxCtx); 1675afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1676afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1677afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1678426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool 1679426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXIsDirect( Display *dpy, GLXContext ctx ) 1680afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 16817cf50e137da497a590ec9001a9918972a6246142Brian Paul struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx; 1682afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 16837cf50e137da497a590ec9001a9918972a6246142Brian Paul return glxCtx->xmesaContext->direct; 1684afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1685afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1686afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1687afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1688426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1689426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXSwapBuffers( Display *dpy, GLXDrawable drawable ) 1690afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1691afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaBuffer buffer = XMesaFindBuffer( dpy, drawable ); 1692afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1693afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (buffer) { 1694afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaSwapBuffers(buffer); 1695afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1696367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul else if (_mesa_getenv("MESA_DEBUG")) { 1697ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul _mesa_warning(NULL, "glXSwapBuffers: invalid drawable 0x%x\n", 1698ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul (int) drawable); 1699afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1700afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1701afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1702afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 17034c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul 1704b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_MESA_copy_sub_buffer ***/ 1705b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul 1706426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1707426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCopySubBufferMESA( Display *dpy, GLXDrawable drawable, 1708426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul int x, int y, int width, int height ) 1709afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1710afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaBuffer buffer = XMesaFindBuffer( dpy, drawable ); 1711afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (buffer) { 1712afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaCopySubBuffer(buffer, x, y, width, height); 1713afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1714367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul else if (_mesa_getenv("MESA_DEBUG")) { 1715d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul _mesa_warning(NULL, "Mesa: glXCopySubBufferMESA: invalid drawable\n"); 1716afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1717afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1718afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1719afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1720426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool 1721426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryVersion( Display *dpy, int *maj, int *min ) 1722afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1723afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 1724afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Return GLX version, not Mesa version */ 172578fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul assert(CLIENT_MAJOR_VERSION == SERVER_MAJOR_VERSION); 172678fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul *maj = CLIENT_MAJOR_VERSION; 172778fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul *min = MIN2( CLIENT_MINOR_VERSION, SERVER_MINOR_VERSION ); 1728afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return True; 1729afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1730afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1731afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1732afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 1733afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Query the GLX attributes of the given XVisualInfo. 1734afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 1735426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int 1736e4656003caee346d9c4eb23256d73409271291a7Brian Paulget_config( XMesaVisual xmvis, int attrib, int *value, GLboolean fbconfig ) 1737afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1738e4656003caee346d9c4eb23256d73409271291a7Brian Paul ASSERT(xmvis); 1739afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch(attrib) { 1740afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_USE_GL: 17411f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul if (fbconfig) 17421f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul return GLX_BAD_ATTRIBUTE; 1743afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = (int) True; 1744afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1745afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_BUFFER_SIZE: 1746e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->visinfo->depth; 1747afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1748afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_LEVEL: 1749304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick *value = xmvis->mesa_visual.level; 1750afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1751afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_RGBA: 17521f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul if (fbconfig) 17531f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul return GLX_BAD_ATTRIBUTE; 1754e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (xmvis->mesa_visual.rgbMode) { 1755afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = True; 1756afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1757afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 1758afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = False; 1759afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1760afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1761afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_DOUBLEBUFFER: 1762e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = (int) xmvis->mesa_visual.doubleBufferMode; 1763afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1764afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STEREO: 1765e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = (int) xmvis->mesa_visual.stereoMode; 1766afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1767afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_AUX_BUFFERS: 1768894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul *value = xmvis->mesa_visual.numAuxBuffers; 1769afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1770afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_RED_SIZE: 1771e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->mesa_visual.redBits; 1772afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1773afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_GREEN_SIZE: 1774e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->mesa_visual.greenBits; 1775afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1776afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_BLUE_SIZE: 1777e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->mesa_visual.blueBits; 1778afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1779afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ALPHA_SIZE: 1780e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->mesa_visual.alphaBits; 1781afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1782afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_DEPTH_SIZE: 1783e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->mesa_visual.depthBits; 1784afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1785afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STENCIL_SIZE: 1786e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->mesa_visual.stencilBits; 1787afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1788afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_RED_SIZE: 1789e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->mesa_visual.accumRedBits; 1790b2e460018375f699198073a6167e0ee96ba1d267Brian Paul return 0; 1791afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_GREEN_SIZE: 1792e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->mesa_visual.accumGreenBits; 1793b2e460018375f699198073a6167e0ee96ba1d267Brian Paul return 0; 1794afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_BLUE_SIZE: 1795e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->mesa_visual.accumBlueBits; 1796afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1797afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_ALPHA_SIZE: 1798e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->mesa_visual.accumAlphaBits; 1799afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1800afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1801afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* 1802afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * GLX_EXT_visual_info extension 1803afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 1804afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_X_VISUAL_TYPE_EXT: 1805e4656003caee346d9c4eb23256d73409271291a7Brian Paul switch (xmvis->visinfo->CLASS) { 1806afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case StaticGray: *value = GLX_STATIC_GRAY_EXT; return 0; 1807afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GrayScale: *value = GLX_GRAY_SCALE_EXT; return 0; 1808afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case StaticColor: *value = GLX_STATIC_GRAY_EXT; return 0; 1809afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case PseudoColor: *value = GLX_PSEUDO_COLOR_EXT; return 0; 1810afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case TrueColor: *value = GLX_TRUE_COLOR_EXT; return 0; 1811afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case DirectColor: *value = GLX_DIRECT_COLOR_EXT; return 0; 1812afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1813afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1814afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_TYPE_EXT: 1815304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick if (xmvis->mesa_visual.level==0) { 1816afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* normal planes */ 1817afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = GLX_NONE_EXT; 1818afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1819304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick else if (xmvis->mesa_visual.level>0) { 1820afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* overlay */ 1821e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (xmvis->mesa_visual.rgbMode) { 1822afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = GLX_TRANSPARENT_RGB_EXT; 1823afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1824afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 1825afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = GLX_TRANSPARENT_INDEX_EXT; 1826afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1827afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1828304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick else if (xmvis->mesa_visual.level<0) { 1829afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* underlay */ 1830afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = GLX_NONE_EXT; 1831afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1832afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1833afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_INDEX_VALUE_EXT: 1834afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg { 1835e4656003caee346d9c4eb23256d73409271291a7Brian Paul int pixel = transparent_pixel( xmvis ); 1836afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (pixel>=0) { 1837afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = pixel; 1838afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1839afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* else undefined */ 1840afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1841afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1842afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_RED_VALUE_EXT: 1843afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* undefined */ 1844afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1845afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_GREEN_VALUE_EXT: 1846afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* undefined */ 1847afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1848afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_BLUE_VALUE_EXT: 1849afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* undefined */ 1850afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1851afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_ALPHA_VALUE_EXT: 1852afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* undefined */ 1853afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1854afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1855afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* 1856b2e460018375f699198073a6167e0ee96ba1d267Brian Paul * GLX_EXT_visual_info extension 1857b2e460018375f699198073a6167e0ee96ba1d267Brian Paul */ 1858b2e460018375f699198073a6167e0ee96ba1d267Brian Paul case GLX_VISUAL_CAVEAT_EXT: 1859fc68be6b111473a0bf8f991468f973bb9dd275f4Brian Paul /* test for zero, just in case */ 1860304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick if (xmvis->mesa_visual.visualRating > 0) 1861304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick *value = xmvis->mesa_visual.visualRating; 1862962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul else 1863962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul *value = GLX_NONE_EXT; 1864962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul return 0; 1865b2e460018375f699198073a6167e0ee96ba1d267Brian Paul 1866b2e460018375f699198073a6167e0ee96ba1d267Brian Paul /* 186766ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul * GLX_ARB_multisample 1868afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 186966ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul case GLX_SAMPLE_BUFFERS_ARB: 18703265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul *value = 0; 18713265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return 0; 187266ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul case GLX_SAMPLES_ARB: 18733265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul *value = 0; 18743265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return 0; 18753265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul 18763265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul /* 18773265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul * For FBConfigs: 18783265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul */ 18793265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_SCREEN_EXT: 18803265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (!fbconfig) 18813265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return GLX_BAD_ATTRIBUTE; 1882e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->visinfo->screen; 18833265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 18843265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_DRAWABLE_TYPE: /*SGIX too */ 18853265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (!fbconfig) 18863265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return GLX_BAD_ATTRIBUTE; 18873265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul *value = GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT; 18883265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 18893265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_RENDER_TYPE_SGIX: 18903265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (!fbconfig) 18913265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return GLX_BAD_ATTRIBUTE; 1892e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (xmvis->mesa_visual.rgbMode) 18933265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul *value = GLX_RGBA_BIT; 18943265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul else 18953265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul *value = GLX_COLOR_INDEX_BIT; 18963265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 18973265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_X_RENDERABLE_SGIX: 18983265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (!fbconfig) 18993265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return GLX_BAD_ATTRIBUTE; 19003265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul *value = True; /* XXX really? */ 19013265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 19023265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_FBCONFIG_ID_SGIX: 19033265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (!fbconfig) 19043265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return GLX_BAD_ATTRIBUTE; 1905f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul *value = xmvis->visinfo->visualid; 19063265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 19073265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_MAX_PBUFFER_WIDTH: 19083265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (!fbconfig) 19093265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return GLX_BAD_ATTRIBUTE; 19103265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul /* XXX or MAX_WIDTH? */ 1911f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul *value = DisplayWidth(xmvis->display, xmvis->visinfo->screen); 19123265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 19133265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_MAX_PBUFFER_HEIGHT: 19143265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (!fbconfig) 19153265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return GLX_BAD_ATTRIBUTE; 1916f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul *value = DisplayHeight(xmvis->display, xmvis->visinfo->screen); 19173265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 19183265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_MAX_PBUFFER_PIXELS: 19193265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (!fbconfig) 19203265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return GLX_BAD_ATTRIBUTE; 1921f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul *value = DisplayWidth(xmvis->display, xmvis->visinfo->screen) * 1922f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul DisplayHeight(xmvis->display, xmvis->visinfo->screen); 19233265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 19243265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_VISUAL_ID: 19253265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (!fbconfig) 19263265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return GLX_BAD_ATTRIBUTE; 1927f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul *value = xmvis->visinfo->visualid; 19283265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 19293265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul 1930fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian#ifdef GLX_EXT_texture_from_pixmap 1931fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_BIND_TO_TEXTURE_RGB_EXT: 1932fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian *value = True; /*XXX*/ 1933fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 1934fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_BIND_TO_TEXTURE_RGBA_EXT: 1935fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian /* XXX review */ 1936fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian *value = xmvis->mesa_visual.alphaBits > 0 ? True : False; 1937fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 1938fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_BIND_TO_MIPMAP_TEXTURE_EXT: 1939fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian *value = True; /*XXX*/ 1940fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 1941fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_BIND_TO_TEXTURE_TARGETS_EXT: 1942fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian *value = (GLX_TEXTURE_1D_BIT_EXT | 1943fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian GLX_TEXTURE_2D_BIT_EXT | 1944fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian GLX_TEXTURE_RECTANGLE_BIT_EXT); /*XXX*/ 1945fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 1946fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_Y_INVERTED_EXT: 1947a10ba38df7ac80e36db15aaae9f78e7223b2bfaeBrian *value = True; /*XXX*/ 1948fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 1949fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian#endif 1950fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian 1951afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: 1952afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return GLX_BAD_ATTRIBUTE; 1953afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 19543265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return Success; 1955afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1956afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1957afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 19583265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paulstatic int 19593265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian PaulFake_glXGetConfig( Display *dpy, XVisualInfo *visinfo, 19603265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul int attrib, int *value ) 19613265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul{ 1962e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaVisual xmvis; 1963ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul int k; 1964379641956d134b8dc761b6411d7c4dca8f94a092Brian Paul if (!dpy || !visinfo) 1965a9a1c3f20f2d6aad4afc47cf2b29c5393fddb6b6Brian Paul return GLX_BAD_ATTRIBUTE; 1966a9a1c3f20f2d6aad4afc47cf2b29c5393fddb6b6Brian Paul 1967e4656003caee346d9c4eb23256d73409271291a7Brian Paul xmvis = find_glx_visual( dpy, visinfo ); 1968e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (!xmvis) { 19693265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul /* this visual wasn't obtained with glXChooseVisual */ 1970e4656003caee346d9c4eb23256d73409271291a7Brian Paul xmvis = create_glx_visual( dpy, visinfo ); 1971e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (!xmvis) { 19723265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul /* this visual can't be used for GL rendering */ 19733265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (attrib==GLX_USE_GL) { 19743265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul *value = (int) False; 19753265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return 0; 19763265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 19773265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul else { 19783265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return GLX_BAD_VISUAL; 19793265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 19803265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 19813265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 19823265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul 1983ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul k = get_config(xmvis, attrib, value, GL_FALSE); 1984ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul return k; 19853265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul} 19863265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul 1987afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1988426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1989426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXWaitGL( void ) 1990afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1991afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaContext xmesa = XMesaGetCurrentContext(); 1992afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaFlush( xmesa ); 1993afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1994afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1995afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1996afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1997426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1998426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXWaitX( void ) 1999afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 2000afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaContext xmesa = XMesaGetCurrentContext(); 2001afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaFlush( xmesa ); 2002afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 2003afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 2004afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 2005e4656003caee346d9c4eb23256d73409271291a7Brian Paulstatic const char * 2006e4656003caee346d9c4eb23256d73409271291a7Brian Paulget_extensions( void ) 200743c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul{ 2008d60009bd6dba15d094b0d0bcb8180b7a2e1c1708George Sapountzis#ifdef FX 2009d60009bd6dba15d094b0d0bcb8180b7a2e1c1708George Sapountzis const char *fx = _mesa_getenv("MESA_GLX_FX"); 2010d60009bd6dba15d094b0d0bcb8180b7a2e1c1708George Sapountzis if (fx && fx[0] != 'd') { 2011d60009bd6dba15d094b0d0bcb8180b7a2e1c1708George Sapountzis return EXTENSIONS; 2012d60009bd6dba15d094b0d0bcb8180b7a2e1c1708George Sapountzis } 2013d60009bd6dba15d094b0d0bcb8180b7a2e1c1708George Sapountzis#endif 2014e4656003caee346d9c4eb23256d73409271291a7Brian Paul return EXTENSIONS + 23; /* skip "GLX_MESA_set_3dfx_mode" */ 201543c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul} 2016afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 2017afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 2018afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 2019afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* GLX 1.1 and later */ 2020426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic const char * 2021426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryExtensionsString( Display *dpy, int screen ) 2022afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 2023afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 2024afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) screen; 202543c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul return get_extensions(); 2026afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 2027afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 2028afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 2029afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 2030afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* GLX 1.1 and later */ 2031426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic const char * 2032426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryServerString( Display *dpy, int screen, int name ) 2033afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 203478fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul static char version[1000]; 20352ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul _mesa_sprintf(version, "%d.%d %s", 20362ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul SERVER_MAJOR_VERSION, SERVER_MINOR_VERSION, MESA_GLX_VERSION); 2037afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 2038afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 2039afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) screen; 2040afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 2041afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (name) { 2042afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_EXTENSIONS: 204343c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul return get_extensions(); 2044afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_VENDOR: 204578fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul return VENDOR; 2046afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_VERSION: 2047afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return version; 2048afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: 2049afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 2050afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 2051afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 2052afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 2053afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 2054afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 2055afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* GLX 1.1 and later */ 2056426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic const char * 2057426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetClientString( Display *dpy, int name ) 2058afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 205978fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul static char version[1000]; 20602ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul _mesa_sprintf(version, "%d.%d %s", CLIENT_MAJOR_VERSION, 20612ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul CLIENT_MINOR_VERSION, MESA_GLX_VERSION); 2062afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 2063afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 2064afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 2065afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (name) { 2066afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_EXTENSIONS: 206743c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul return get_extensions(); 2068afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_VENDOR: 206978fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul return VENDOR; 2070afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_VERSION: 2071afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return version; 2072afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: 2073afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 2074afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 2075afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 2076afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 2077afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 2078afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 2079426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul/* 2080426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul * GLX 1.3 and later 2081426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul */ 2082426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 20837d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 2084426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int 2085426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetFBConfigAttrib( Display *dpy, GLXFBConfig config, 2086426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul int attribute, int *value ) 2087426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 20883265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul XMesaVisual v = (XMesaVisual) config; 2089426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 2090426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) config; 20917d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 20927d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul if (!dpy || !config || !value) 20937d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return -1; 20947d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 20953265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return get_config(v, attribute, value, GL_TRUE); 2096426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2097426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2098426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 20995605798e56ca6e9f968623f33b58ee7ca90594afBrian Paulstatic GLXFBConfig * 21005605798e56ca6e9f968623f33b58ee7ca90594afBrian PaulFake_glXGetFBConfigs( Display *dpy, int screen, int *nelements ) 21015605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul{ 21023265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul XVisualInfo *visuals, visTemplate; 21033265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul const long visMask = VisualScreenMask; 21043265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul int i; 21053265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul 21063265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul /* Get list of all X visuals */ 21073265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul visTemplate.screen = screen; 21083265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul visuals = XGetVisualInfo(dpy, visMask, &visTemplate, nelements); 21093265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (*nelements > 0) { 21103265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul XMesaVisual *results; 21114039cb8ca82d59451a6de8902fe35e693cdca3baBrian Paul results = (XMesaVisual *) _mesa_malloc(*nelements * sizeof(XMesaVisual)); 21123265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (!results) { 21133265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul *nelements = 0; 21143265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return NULL; 21153265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 21163265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul for (i = 0; i < *nelements; i++) { 21173265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul results[i] = create_glx_visual(dpy, visuals + i); 21183265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 21193265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return (GLXFBConfig *) results; 21203265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 21213265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return NULL; 21225605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul} 21235605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul 21245605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul 2125481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paulstatic GLXFBConfig * 2126481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian PaulFake_glXChooseFBConfig( Display *dpy, int screen, 2127481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul const int *attribList, int *nitems ) 2128481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul{ 2129481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul XMesaVisual xmvis; 2130481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul 2131481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul if (!attribList || !attribList[0]) { 2132481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul /* return list of all configs (per GLX_SGIX_fbconfig spec) */ 2133481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul return Fake_glXGetFBConfigs(dpy, screen, nitems); 2134481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul } 2135481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul 2136481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul xmvis = choose_visual(dpy, screen, attribList, GL_TRUE); 2137481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul if (xmvis) { 2138481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul GLXFBConfig *config = (GLXFBConfig *) _mesa_malloc(sizeof(XMesaVisual)); 2139481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul if (!config) { 2140481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul *nitems = 0; 2141481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul return NULL; 2142481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul } 2143481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul *nitems = 1; 2144481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul config[0] = (GLXFBConfig) xmvis; 2145481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul return (GLXFBConfig *) config; 2146481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul } 2147481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul else { 2148481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul *nitems = 0; 2149481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul return NULL; 2150481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul } 2151481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul} 2152481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul 2153481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul 2154426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic XVisualInfo * 2155426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetVisualFromFBConfig( Display *dpy, GLXFBConfig config ) 2156426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 21577d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul if (dpy && config) { 2158f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul XMesaVisual xmvis = (XMesaVisual) config; 2159f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul#if 0 2160f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul return xmvis->vishandle; 2161f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul#else 2162f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul /* create a new vishandle - the cached one may be stale */ 21634039cb8ca82d59451a6de8902fe35e693cdca3baBrian Paul xmvis->vishandle = (XVisualInfo *) _mesa_malloc(sizeof(XVisualInfo)); 2164f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul if (xmvis->vishandle) { 2165f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul _mesa_memcpy(xmvis->vishandle, xmvis->visinfo, sizeof(XVisualInfo)); 2166f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul } 2167f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul return xmvis->vishandle; 2168f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul#endif 21697d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul } 21707d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul else { 21717d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return NULL; 21727d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul } 2173426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2174426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2175426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2176426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXWindow 2177426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateWindow( Display *dpy, GLXFBConfig config, Window win, 2178426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul const int *attribList ) 2179426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 2180529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul XMesaVisual xmvis = (XMesaVisual) config; 2181529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul XMesaBuffer xmbuf; 2182529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul if (!xmvis) 2183529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul return 0; 2184529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul 21856aa5668871e7f366b33e85fabc72885fc269a7d4George Sapountzis xmbuf = XMesaCreateWindowBuffer(xmvis, win); 2186529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul if (!xmbuf) 2187529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul return 0; 2188529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul 21896aa5668871e7f366b33e85fabc72885fc269a7d4George Sapountzis#ifdef FX 21906aa5668871e7f366b33e85fabc72885fc269a7d4George Sapountzis /* XXX this will segfault if actually called */ 21916aa5668871e7f366b33e85fabc72885fc269a7d4George Sapountzis FXcreateContext(xmvis, win, NULL, xmbuf); 21926aa5668871e7f366b33e85fabc72885fc269a7d4George Sapountzis#endif 21936aa5668871e7f366b33e85fabc72885fc269a7d4George Sapountzis 2194426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 21957d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul (void) attribList; /* Ignored in GLX 1.3 */ 21967d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 21977d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return win; /* A hack for now */ 2198426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2199426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2200426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2201426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 2202426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyWindow( Display *dpy, GLXWindow window ) 2203426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 22047d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul XMesaBuffer b = XMesaFindBuffer(dpy, (XMesaDrawable) window); 22057d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul if (b) 22067d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul XMesaDestroyBuffer(b); 22077d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul /* don't destroy X window */ 2208426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2209426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2210426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 22117d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul/* XXX untested */ 2212426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPixmap 2213426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreatePixmap( Display *dpy, GLXFBConfig config, Pixmap pixmap, 2214426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul const int *attribList ) 2215426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 22167d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul XMesaVisual v = (XMesaVisual) config; 22177d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul XMesaBuffer b; 2218fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian const int *attr; 2219fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian int target = 0, format = 0, mipmap = 0; 2220fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian int value; 22217d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 22227d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul if (!dpy || !config || !pixmap) 22237d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return 0; 22247d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 2225d18c57aaeac37cde0cb551191ecd3c3a56a0ffbaBrian Paul for (attr = attribList; attr && *attr; attr++) { 2226fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian switch (*attr) { 2227fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_TEXTURE_FORMAT_EXT: 2228fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian attr++; 2229fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian switch (*attr) { 2230fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_TEXTURE_FORMAT_NONE_EXT: 2231fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_TEXTURE_FORMAT_RGB_EXT: 2232fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_TEXTURE_FORMAT_RGBA_EXT: 2233fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian format = *attr; 2234fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 2235fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian default: 2236fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian /* error */ 2237fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian return 0; 2238fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2239fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 2240fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_TEXTURE_TARGET_EXT: 2241fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian attr++; 2242fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian switch (*attr) { 2243fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_TEXTURE_1D_EXT: 2244fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_TEXTURE_2D_EXT: 2245fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_TEXTURE_RECTANGLE_EXT: 2246fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian target = *attr; 2247fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 2248fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian default: 2249fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian /* error */ 2250fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian return 0; 2251fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2252fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 2253fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_MIPMAP_TEXTURE_EXT: 2254fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian attr++; 2255fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (*attr) 2256fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian mipmap = 1; 2257fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 2258fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian default: 2259fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian /* error */ 2260fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian return 0; 2261fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2262fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2263fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian 2264fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (format == GLX_TEXTURE_FORMAT_RGB_EXT) { 2265fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (get_config(v, GLX_BIND_TO_TEXTURE_RGB_EXT, 2266fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian &value, GL_TRUE) != Success 2267fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian || !value) { 2268fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian return 0; /* error! */ 2269fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2270fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2271fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian else if (format == GLX_TEXTURE_FORMAT_RGBA_EXT) { 2272fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (get_config(v, GLX_BIND_TO_TEXTURE_RGBA_EXT, 2273fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian &value, GL_TRUE) != Success 2274fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian || !value) { 2275fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian return 0; /* error! */ 2276fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2277fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2278fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (mipmap) { 2279fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (get_config(v, GLX_BIND_TO_MIPMAP_TEXTURE_EXT, 2280fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian &value, GL_TRUE) != Success 2281fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian || !value) { 2282fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian return 0; /* error! */ 2283fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2284fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2285fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (target == GLX_TEXTURE_1D_EXT) { 2286fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (get_config(v, GLX_BIND_TO_TEXTURE_TARGETS_EXT, 2287fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian &value, GL_TRUE) != Success 2288fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian || (value & GLX_TEXTURE_1D_BIT_EXT) == 0) { 2289fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian return 0; /* error! */ 2290fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2291fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2292fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian else if (target == GLX_TEXTURE_2D_EXT) { 2293fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (get_config(v, GLX_BIND_TO_TEXTURE_TARGETS_EXT, 2294fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian &value, GL_TRUE) != Success 2295fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian || (value & GLX_TEXTURE_2D_BIT_EXT) == 0) { 2296fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian return 0; /* error! */ 2297fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2298fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2299fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (target == GLX_TEXTURE_RECTANGLE_EXT) { 2300fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (get_config(v, GLX_BIND_TO_TEXTURE_TARGETS_EXT, 2301fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian &value, GL_TRUE) != Success 2302fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian || (value & GLX_TEXTURE_RECTANGLE_BIT_EXT) == 0) { 2303fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian return 0; /* error! */ 2304fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2305fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2306fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian 2307fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (format || target || mipmap) { 2308fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian /* texture from pixmap */ 2309fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian b = XMesaCreatePixmapTextureBuffer(v, pixmap, 0, format, target, mipmap); 2310fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2311fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian else { 2312fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian b = XMesaCreatePixmapBuffer( v, pixmap, 0 ); 2313fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 23147d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul if (!b) { 23157d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return 0; 23167d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul } 23177d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 23187d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return pixmap; 2319426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2320426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2321426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2322426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 2323426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyPixmap( Display *dpy, GLXPixmap pixmap ) 2324426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 23257d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul XMesaBuffer b = XMesaFindBuffer(dpy, (XMesaDrawable)pixmap); 23267d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul if (b) 23277d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul XMesaDestroyBuffer(b); 23287d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul /* don't destroy X pixmap */ 2329426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2330426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2331426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2332426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPbuffer 2333426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreatePbuffer( Display *dpy, GLXFBConfig config, 2334426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul const int *attribList ) 2335426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 23363265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul XMesaVisual xmvis = (XMesaVisual) config; 23373265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul XMesaBuffer xmbuf; 23387d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul const int *attrib; 23397d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul int width = 0, height = 0; 23407d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul GLboolean useLargest = GL_FALSE, preserveContents = GL_FALSE; 23417d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 2342426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 23437d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 23443265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul for (attrib = attribList; *attrib; attrib++) { 23457d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul switch (*attrib) { 23467d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_PBUFFER_WIDTH: 23473265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul attrib++; 23483265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul width = *attrib; 23497d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul break; 23507d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_PBUFFER_HEIGHT: 23513265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul attrib++; 23523265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul height = *attrib; 23537d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul break; 23547d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_PRESERVED_CONTENTS: 23553265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul attrib++; 2356c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul preserveContents = *attrib; 23577d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul break; 23587d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_LARGEST_PBUFFER: 23593265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul attrib++; 2360c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul useLargest = *attrib; 23617d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul break; 23627d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul default: 23637d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return 0; 23647d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul } 23657d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul } 23667d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 23677d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul if (width == 0 || height == 0) 23687d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return 0; 23697d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 2370c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul if (width > MAX_WIDTH || height > MAX_HEIGHT) { 2371c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul /* If allocation would have failed and GLX_LARGEST_PBUFFER is set, 2372c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul * allocate the largest possible buffer. 2373c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul */ 2374c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul if (useLargest) { 2375c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul width = MAX_WIDTH; 2376c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul height = MAX_HEIGHT; 2377c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul } 2378c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul } 2379c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul 23803265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul xmbuf = XMesaCreatePBuffer( xmvis, 0, width, height); 2381e4656003caee346d9c4eb23256d73409271291a7Brian Paul /* A GLXPbuffer handle must be an X Drawable because that's what 2382e4656003caee346d9c4eb23256d73409271291a7Brian Paul * glXMakeCurrent takes. 2383e4656003caee346d9c4eb23256d73409271291a7Brian Paul */ 2384c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul if (xmbuf) { 2385c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul xmbuf->largestPbuffer = useLargest; 2386c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul xmbuf->preservedContents = preserveContents; 2387dd1a9f75dc1d29e3383f27aaa1cf024c83e5c8e2Brian Paul return (GLXPbuffer) xmbuf->frontxrb->pixmap; 2388c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul } 2389c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul else { 2390dd1a9f75dc1d29e3383f27aaa1cf024c83e5c8e2Brian Paul return 0; 2391c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul } 2392426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2393426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2394426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2395426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 2396426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyPbuffer( Display *dpy, GLXPbuffer pbuf ) 2397426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 2398e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaBuffer b = XMesaFindBuffer(dpy, pbuf); 2399e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (b) { 2400e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaDestroyBuffer(b); 2401e4656003caee346d9c4eb23256d73409271291a7Brian Paul } 2402426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2403426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2404426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2405426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 2406426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryDrawable( Display *dpy, GLXDrawable draw, int attribute, 2407426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul unsigned int *value ) 2408426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 2409e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaBuffer xmbuf = XMesaFindBuffer(dpy, draw); 2410e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (!xmbuf) 2411e4656003caee346d9c4eb23256d73409271291a7Brian Paul return; 24127d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 2413c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul /* make sure buffer's dimensions are up to date */ 2414c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul xmesa_check_and_update_buffer_size(NULL, xmbuf); 2415c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul 24167d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul switch (attribute) { 24177d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_WIDTH: 241829926a11b16ec7a235947d95e9a46777605dd30eBrian Paul *value = xmbuf->mesa_buffer.Width; 2419e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 24207d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_HEIGHT: 242129926a11b16ec7a235947d95e9a46777605dd30eBrian Paul *value = xmbuf->mesa_buffer.Height; 2422e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 24237d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_PRESERVED_CONTENTS: 2424c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul *value = xmbuf->preservedContents; 2425e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 24267d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_LARGEST_PBUFFER: 2427c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul *value = xmbuf->largestPbuffer; 2428e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 24297d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_FBCONFIG_ID: 2430f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul *value = xmbuf->xm_visual->visinfo->visualid; 24317d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return; 2432fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian#ifdef GLX_EXT_texture_from_pixmap 2433fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_TEXTURE_FORMAT_EXT: 2434fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian *value = xmbuf->TextureFormat; 2435fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 2436fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_TEXTURE_TARGET_EXT: 2437fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian *value = xmbuf->TextureTarget; 2438fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 2439fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_MIPMAP_TEXTURE_EXT: 2440fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian *value = xmbuf->TextureMipmap; 2441fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 2442fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian#endif 2443fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian 24447d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul default: 2445fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian return; /* raise BadValue error */ 24467d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul } 2447426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2448426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2449426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2450426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXContext 2451426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateNewContext( Display *dpy, GLXFBConfig config, 2452426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul int renderType, GLXContext shareList, Bool direct ) 2453426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 2454f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul struct fake_glx_context *glxCtx; 2455f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul struct fake_glx_context *shareCtx = (struct fake_glx_context *) shareList; 2456f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul XMesaVisual xmvis = (XMesaVisual) config; 24577d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 24587d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul if (!dpy || !config || 24597d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul (renderType != GLX_RGBA_TYPE && renderType != GLX_COLOR_INDEX_TYPE)) 24607d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return 0; 24617d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 2462f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul glxCtx = CALLOC_STRUCT(fake_glx_context); 2463f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul if (!glxCtx) 2464f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul return 0; 2465f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul 2466f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul /* deallocate unused windows/buffers */ 2467f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul XMesaGarbageCollect(); 2468f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul 2469f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul glxCtx->xmesaContext = XMesaCreateContext(xmvis, 2470f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul shareCtx ? shareCtx->xmesaContext : NULL); 2471f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul if (!glxCtx->xmesaContext) { 24720c54e47c0e93f725b8bc028b0d4614011dbe3fefBrian Paul _mesa_free(glxCtx); 2473f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul return NULL; 2474f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul } 2475f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul 247649e80bf6b163310f7cd776261872201eea57053aBrian Paul init_glx_context(glxCtx, dpy); 2477f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul 2478f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul return (GLXContext) glxCtx; 2479426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2480426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2481426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2482426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int 2483426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryContext( Display *dpy, GLXContext ctx, int attribute, int *value ) 2484426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 2485e4656003caee346d9c4eb23256d73409271291a7Brian Paul struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx; 2486e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaContext xmctx = glxCtx->xmesaContext; 2487e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2488426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 2489426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) ctx; 24907d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 24917d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul switch (attribute) { 24927d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_FBCONFIG_ID: 2493f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul *value = xmctx->xm_visual->visinfo->visualid; 2494e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 24957d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_RENDER_TYPE: 2496e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (xmctx->xm_visual->mesa_visual.rgbMode) 249786ee448047e4f7be722b69da5296ccafc2307145Brian Paul *value = GLX_RGBA_TYPE; 2498e4656003caee346d9c4eb23256d73409271291a7Brian Paul else 249986ee448047e4f7be722b69da5296ccafc2307145Brian Paul *value = GLX_COLOR_INDEX_TYPE; 2500e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 25017d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_SCREEN: 25027d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul *value = 0; 25037d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return Success; 25047d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul default: 25057d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return GLX_BAD_ATTRIBUTE; 25067d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul } 2507e4656003caee346d9c4eb23256d73409271291a7Brian Paul return 0; 2508426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2509426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2510426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2511426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 2512426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXSelectEvent( Display *dpy, GLXDrawable drawable, unsigned long mask ) 2513426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 2514e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable); 2515e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (xmbuf) 2516e4656003caee346d9c4eb23256d73409271291a7Brian Paul xmbuf->selectedEvents = mask; 2517426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2518426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2519426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2520426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 2521426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetSelectedEvent( Display *dpy, GLXDrawable drawable, 2522426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul unsigned long *mask ) 2523426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 2524e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable); 2525e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (xmbuf) 2526e4656003caee346d9c4eb23256d73409271291a7Brian Paul *mask = xmbuf->selectedEvents; 2527e4656003caee346d9c4eb23256d73409271291a7Brian Paul else 2528e4656003caee346d9c4eb23256d73409271291a7Brian Paul *mask = 0; 2529426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2530b82d993b03320818f88f792a9e713f7ed491bfcbBrian Paul 2531b82d993b03320818f88f792a9e713f7ed491bfcbBrian Paul 2532b82d993b03320818f88f792a9e713f7ed491bfcbBrian Paul 2533b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGI_swap_control ***/ 2534783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2535783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int 2536783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXSwapIntervalSGI(int interval) 2537783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2538783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) interval; 2539783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2540783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2541783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2542783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2543783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2544b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGI_video_sync ***/ 2545783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2546ee061060826df059f0ddb904a2160ed610423579Brian Paulstatic unsigned int FrameCounter = 0; 2547ee061060826df059f0ddb904a2160ed610423579Brian Paul 2548783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int 2549783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetVideoSyncSGI(unsigned int *count) 2550783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2551ee061060826df059f0ddb904a2160ed610423579Brian Paul /* this is a bogus implementation */ 2552ee061060826df059f0ddb904a2160ed610423579Brian Paul *count = FrameCounter++; 2553783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2554783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2555783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2556783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int 2557783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count) 2558783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2559ee061060826df059f0ddb904a2160ed610423579Brian Paul if (divisor <= 0 || remainder < 0) 2560ee061060826df059f0ddb904a2160ed610423579Brian Paul return GLX_BAD_VALUE; 2561ee061060826df059f0ddb904a2160ed610423579Brian Paul /* this is a bogus implementation */ 2562ee061060826df059f0ddb904a2160ed610423579Brian Paul FrameCounter++; 2563ee061060826df059f0ddb904a2160ed610423579Brian Paul while (FrameCounter % divisor != remainder) 2564ee061060826df059f0ddb904a2160ed610423579Brian Paul FrameCounter++; 2565ee061060826df059f0ddb904a2160ed610423579Brian Paul *count = FrameCounter; 2566783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2567783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2568783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2569783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2570783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2571b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGI_make_current_read ***/ 2572783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2573426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool 2574783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXMakeCurrentReadSGI(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx) 2575afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 2576a078d75a27b99252ede6520e24b145106ab98aa2Brian Paul return Fake_glXMakeContextCurrent( dpy, draw, read, ctx ); 2577afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 2578783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 25797cf50e137da497a590ec9001a9918972a6246142Brian Paul/* not used 2580783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXDrawable 2581b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian PaulFake_glXGetCurrentReadDrawableSGI(void) 2582783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2583783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2584783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 25857cf50e137da497a590ec9001a9918972a6246142Brian Paul*/ 2586afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 2587afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 2588b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_video_source ***/ 2589b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#if defined(_VL_H) 25904c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul 2591783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXVideoSourceSGIX 2592783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXCreateGLXVideoSourceSGIX(Display *dpy, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode) 2593afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 2594783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2595783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) screen; 2596783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) server; 2597783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) path; 2598783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) nodeClass; 2599783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) drainNode; 2600783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2601783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2602783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2603783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void 2604783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXDestroyGLXVideoSourceSGIX(Display *dpy, GLXVideoSourceSGIX src) 2605783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2606783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2607783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) src; 2608afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 2609783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 26104c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul#endif 26114c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul 261289a42b7e736bd9b0ab090906cab0cd047a6ec12eBrian Paul 2613b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_EXT_import_context ***/ 261489a42b7e736bd9b0ab090906cab0cd047a6ec12eBrian Paul 2615783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void 2616783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXFreeContextEXT(Display *dpy, GLXContext context) 2617783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2618783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2619783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) context; 2620783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2621426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2622783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXContextID 2623783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetContextIDEXT(const GLXContext context) 2624783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2625783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) context; 2626783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2627783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2628783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2629783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXContext 2630783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXImportContextEXT(Display *dpy, GLXContextID contextID) 2631783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2632783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2633783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) contextID; 2634783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2635783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2636426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2637426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int 2638783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryContextInfoEXT(Display *dpy, GLXContext context, int attribute, int *value) 2639426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 2640783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2641783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) context; 2642783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) attribute; 2643783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) value; 2644426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul return 0; 2645426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2646426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2647783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2648783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2649b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_fbconfig ***/ 2650426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2651426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int 2652783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetFBConfigAttribSGIX(Display *dpy, GLXFBConfigSGIX config, int attribute, int *value) 2653783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 26543265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return Fake_glXGetFBConfigAttrib(dpy, config, attribute, value); 2655783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2656783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2657783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXFBConfigSGIX * 2658783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXChooseFBConfigSGIX(Display *dpy, int screen, int *attrib_list, int *nelements) 2659783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 26603265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return (GLXFBConfig *) Fake_glXChooseFBConfig(dpy, screen, attrib_list, nelements); 2661783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2662783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2663e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2664783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXPixmap 2665783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXCreateGLXPixmapWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap) 2666783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2667e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaVisual xmvis = (XMesaVisual) config; 2668e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaBuffer xmbuf = XMesaCreatePixmapBuffer(xmvis, pixmap, 0); 2669e4b2356c07d31fbeeabb13b2fb47db703b473080Brian Paul return xmbuf->frontxrb->pixmap; /* need to return an X ID */ 2670783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2671783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2672e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2673783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXContext 2674783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct) 2675783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2676e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaVisual xmvis = (XMesaVisual) config; 2677e4656003caee346d9c4eb23256d73409271291a7Brian Paul struct fake_glx_context *glxCtx; 2678e4656003caee346d9c4eb23256d73409271291a7Brian Paul struct fake_glx_context *shareCtx = (struct fake_glx_context *) share_list; 2679e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2680e4656003caee346d9c4eb23256d73409271291a7Brian Paul glxCtx = CALLOC_STRUCT(fake_glx_context); 2681e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (!glxCtx) 2682e4656003caee346d9c4eb23256d73409271291a7Brian Paul return 0; 2683e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2684e4656003caee346d9c4eb23256d73409271291a7Brian Paul /* deallocate unused windows/buffers */ 2685e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaGarbageCollect(); 2686e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2687e4656003caee346d9c4eb23256d73409271291a7Brian Paul glxCtx->xmesaContext = XMesaCreateContext(xmvis, 2688e4656003caee346d9c4eb23256d73409271291a7Brian Paul shareCtx ? shareCtx->xmesaContext : NULL); 2689e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (!glxCtx->xmesaContext) { 26900c54e47c0e93f725b8bc028b0d4614011dbe3fefBrian Paul _mesa_free(glxCtx); 2691e4656003caee346d9c4eb23256d73409271291a7Brian Paul return NULL; 2692e4656003caee346d9c4eb23256d73409271291a7Brian Paul } 2693e4656003caee346d9c4eb23256d73409271291a7Brian Paul 269449e80bf6b163310f7cd776261872201eea57053aBrian Paul init_glx_context(glxCtx, dpy); 2695e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2696e4656003caee346d9c4eb23256d73409271291a7Brian Paul return (GLXContext) glxCtx; 2697783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2698783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2699e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2700783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic XVisualInfo * 2701783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetVisualFromFBConfigSGIX(Display *dpy, GLXFBConfigSGIX config) 2702783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 27033265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return Fake_glXGetVisualFromFBConfig(dpy, config); 2704783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2705783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2706e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2707783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXFBConfigSGIX 2708783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetFBConfigFromVisualSGIX(Display *dpy, XVisualInfo *vis) 2709426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 2710e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaVisual xmvis = find_glx_visual(dpy, vis); 2711e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (!xmvis) { 2712e4656003caee346d9c4eb23256d73409271291a7Brian Paul /* This visual wasn't found with glXChooseVisual() */ 2713e4656003caee346d9c4eb23256d73409271291a7Brian Paul xmvis = create_glx_visual(dpy, vis); 2714e4656003caee346d9c4eb23256d73409271291a7Brian Paul } 2715e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2716e4656003caee346d9c4eb23256d73409271291a7Brian Paul return (GLXFBConfigSGIX) xmvis; 2717426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2718426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2719426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2720426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2721b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_pbuffer ***/ 2722783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2723783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXPbufferSGIX 27243265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian PaulFake_glXCreateGLXPbufferSGIX(Display *dpy, GLXFBConfigSGIX config, 27253265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul unsigned int width, unsigned int height, 27263265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul int *attribList) 2727783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 27283265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul XMesaVisual xmvis = (XMesaVisual) config; 27293265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul XMesaBuffer xmbuf; 27303265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul const int *attrib; 27313265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul GLboolean useLargest = GL_FALSE, preserveContents = GL_FALSE; 27323265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul 2733783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 27343265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul 273511b3028e7ba2fc3b985ab84d7227c290608f83f6Brian Paul for (attrib = attribList; attrib && *attrib; attrib++) { 27363265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul switch (*attrib) { 27373265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_PRESERVED_CONTENTS_SGIX: 27383265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul attrib++; 27393265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul preserveContents = *attrib; /* ignored */ 27403265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 27413265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_LARGEST_PBUFFER_SGIX: 27423265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul attrib++; 27433265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul useLargest = *attrib; /* ignored */ 27443265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 27453265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul default: 27463265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return 0; 27473265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 27483265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 27493265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul 2750b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul /* not used at this time */ 2751b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul (void) useLargest; 2752b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul (void) preserveContents; 2753b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul 27543265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul xmbuf = XMesaCreatePBuffer( xmvis, 0, width, height); 2755e4656003caee346d9c4eb23256d73409271291a7Brian Paul /* A GLXPbuffer handle must be an X Drawable because that's what 2756e4656003caee346d9c4eb23256d73409271291a7Brian Paul * glXMakeCurrent takes. 2757e4656003caee346d9c4eb23256d73409271291a7Brian Paul */ 2758e4b2356c07d31fbeeabb13b2fb47db703b473080Brian Paul return (GLXPbuffer) xmbuf->frontxrb->pixmap; 2759783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2760783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2761e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2762783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void 2763783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXDestroyGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf) 2764783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2765e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaBuffer xmbuf = XMesaFindBuffer(dpy, pbuf); 2766e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (xmbuf) { 2767e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaDestroyBuffer(xmbuf); 2768e4656003caee346d9c4eb23256d73409271291a7Brian Paul } 2769783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2770783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2771e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2772783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int 2773783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value) 2774783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2775e4656003caee346d9c4eb23256d73409271291a7Brian Paul const XMesaBuffer xmbuf = XMesaFindBuffer(dpy, pbuf); 2776e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2777e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (!xmbuf) { 2778e4656003caee346d9c4eb23256d73409271291a7Brian Paul /* Generate GLXBadPbufferSGIX for bad pbuffer */ 2779e4656003caee346d9c4eb23256d73409271291a7Brian Paul return 0; 2780e4656003caee346d9c4eb23256d73409271291a7Brian Paul } 2781e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2782e4656003caee346d9c4eb23256d73409271291a7Brian Paul switch (attribute) { 2783e4656003caee346d9c4eb23256d73409271291a7Brian Paul case GLX_PRESERVED_CONTENTS_SGIX: 2784c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul *value = xmbuf->preservedContents; 2785e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 2786e4656003caee346d9c4eb23256d73409271291a7Brian Paul case GLX_LARGEST_PBUFFER_SGIX: 2787c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul *value = xmbuf->largestPbuffer; 2788e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 2789e4656003caee346d9c4eb23256d73409271291a7Brian Paul case GLX_WIDTH_SGIX: 279029926a11b16ec7a235947d95e9a46777605dd30eBrian Paul *value = xmbuf->mesa_buffer.Width; 2791e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 2792e4656003caee346d9c4eb23256d73409271291a7Brian Paul case GLX_HEIGHT_SGIX: 279329926a11b16ec7a235947d95e9a46777605dd30eBrian Paul *value = xmbuf->mesa_buffer.Height; 2794e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 2795e4656003caee346d9c4eb23256d73409271291a7Brian Paul case GLX_EVENT_MASK_SGIX: 2796e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = 0; /* XXX might be wrong */ 2797e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 2798e4656003caee346d9c4eb23256d73409271291a7Brian Paul default: 2799e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = 0; 2800e4656003caee346d9c4eb23256d73409271291a7Brian Paul } 2801783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2802783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2803783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2804e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2805783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void 2806783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXSelectEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long mask) 2807783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2808e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable); 2809e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (xmbuf) { 2810e4656003caee346d9c4eb23256d73409271291a7Brian Paul /* Note: we'll never generate clobber events */ 2811e4656003caee346d9c4eb23256d73409271291a7Brian Paul xmbuf->selectedEvents = mask; 2812e4656003caee346d9c4eb23256d73409271291a7Brian Paul } 2813783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2814783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2815e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2816783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void 2817783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetSelectedEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long *mask) 2818783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2819e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable); 2820e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (xmbuf) { 2821e4656003caee346d9c4eb23256d73409271291a7Brian Paul *mask = xmbuf->selectedEvents; 2822e4656003caee346d9c4eb23256d73409271291a7Brian Paul } 2823e4656003caee346d9c4eb23256d73409271291a7Brian Paul else { 2824e4656003caee346d9c4eb23256d73409271291a7Brian Paul *mask = 0; 2825e4656003caee346d9c4eb23256d73409271291a7Brian Paul } 2826783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2827783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2828783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2829783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2830b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGI_cushion ***/ 2831783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2832783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void 2833783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXCushionSGI(Display *dpy, Window win, float cushion) 2834783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2835783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2836783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) win; 2837783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) cushion; 2838783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2839783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2840783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2841783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2842b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_video_resize ***/ 2843783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2844783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int 2845783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXBindChannelToWindowSGIX(Display *dpy, int screen, int channel , Window window) 2846783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2847783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2848783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) screen; 2849783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) channel; 2850783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) window; 2851783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2852783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2853783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2854783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int 2855783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXChannelRectSGIX(Display *dpy, int screen, int channel, int x, int y, int w, int h) 2856783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2857783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2858783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) screen; 2859783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) channel; 2860783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) x; 2861783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) y; 2862783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) w; 2863783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) h; 2864783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2865783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2866783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2867783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int 2868783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryChannelRectSGIX(Display *dpy, int screen, int channel, int *x, int *y, int *w, int *h) 2869783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2870783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2871783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) screen; 2872783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) channel; 2873783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) x; 2874783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) y; 2875783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) w; 2876783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) h; 2877783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2878783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2879783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2880783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int 2881783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryChannelDeltasSGIX(Display *dpy, int screen, int channel, int *dx, int *dy, int *dw, int *dh) 2882783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2883783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2884783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) screen; 2885783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) channel; 2886783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dx; 2887783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dy; 2888783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dw; 2889783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dh; 2890783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2891783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2892783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2893783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int 2894783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXChannelRectSyncSGIX(Display *dpy, int screen, int channel, GLenum synctype) 2895783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2896783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2897783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) screen; 2898783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) channel; 2899783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) synctype; 2900783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2901783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2902783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2903783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2904783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2905b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_dmbuffer **/ 2906783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2907b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#if defined(_DM_BUFFER_H_) 2908783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Bool 2909783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXAssociateDMPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer) 2910783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2911783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2912783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) pbuffer; 2913783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) params; 2914783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dmbuffer; 2915783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return False; 2916783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2917783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul#endif 2918783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2919783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2920b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_swap_group ***/ 2921783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2922783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void 2923783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXJoinSwapGroupSGIX(Display *dpy, GLXDrawable drawable, GLXDrawable member) 2924783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2925783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2926783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) drawable; 2927783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) member; 2928783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2929783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2930783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2931783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2932b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_swap_barrier ***/ 2933783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2934783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void 2935783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXBindSwapBarrierSGIX(Display *dpy, GLXDrawable drawable, int barrier) 2936783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2937783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2938783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) drawable; 2939783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) barrier; 2940783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2941783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2942783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Bool 2943783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryMaxSwapBarriersSGIX(Display *dpy, int screen, int *max) 2944783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2945783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2946783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) screen; 2947783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) max; 2948783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return False; 2949783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2950783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2951783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2952783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2953b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SUN_get_transparent_index ***/ 2954783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2955783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Status 2956783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetTransparentIndexSUN(Display *dpy, Window overlay, Window underlay, long *pTransparent) 2957783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2958783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2959783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) overlay; 2960783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) underlay; 2961783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) pTransparent; 2962783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2963783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2964783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2965783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2966783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2967b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_MESA_release_buffers ***/ 2968b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul 2969783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul/* 2970783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul * Release the depth, stencil, accum buffers attached to a GLXDrawable 2971783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul * (a window or pixmap) prior to destroying the GLXDrawable. 2972783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul */ 2973783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Bool 2974783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXReleaseBuffersMESA( Display *dpy, GLXDrawable d ) 2975783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2976783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul XMesaBuffer b = XMesaFindBuffer(dpy, d); 2977783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul if (b) { 2978783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul XMesaDestroyBuffer(b); 2979783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return True; 2980783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul } 2981783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return False; 2982783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2983783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2984783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2985783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2986b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_MESA_set_3dfx_mode ***/ 2987b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul 2988783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Bool 2989783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXSet3DfxModeMESA( int mode ) 2990783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2991783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return XMesaSetFXmode( mode ); 2992783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2993783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2994783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2995783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 29963c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian Paul/*** GLX_NV_vertex_array range ***/ 29978fefafa2200d3ea44ec46592b190654a10685b46Brian Paulstatic void * 29988fefafa2200d3ea44ec46592b190654a10685b46Brian PaulFake_glXAllocateMemoryNV( GLsizei size, 29998fefafa2200d3ea44ec46592b190654a10685b46Brian Paul GLfloat readFrequency, 30008fefafa2200d3ea44ec46592b190654a10685b46Brian Paul GLfloat writeFrequency, 30018fefafa2200d3ea44ec46592b190654a10685b46Brian Paul GLfloat priority ) 30028fefafa2200d3ea44ec46592b190654a10685b46Brian Paul{ 30038fefafa2200d3ea44ec46592b190654a10685b46Brian Paul (void) size; 30048fefafa2200d3ea44ec46592b190654a10685b46Brian Paul (void) readFrequency; 30058fefafa2200d3ea44ec46592b190654a10685b46Brian Paul (void) writeFrequency; 30068fefafa2200d3ea44ec46592b190654a10685b46Brian Paul (void) priority; 30078fefafa2200d3ea44ec46592b190654a10685b46Brian Paul return NULL; 30088fefafa2200d3ea44ec46592b190654a10685b46Brian Paul} 30098fefafa2200d3ea44ec46592b190654a10685b46Brian Paul 30108fefafa2200d3ea44ec46592b190654a10685b46Brian Paul 30118fefafa2200d3ea44ec46592b190654a10685b46Brian Paulstatic void 30128fefafa2200d3ea44ec46592b190654a10685b46Brian PaulFake_glXFreeMemoryNV( GLvoid *pointer ) 30138fefafa2200d3ea44ec46592b190654a10685b46Brian Paul{ 30148fefafa2200d3ea44ec46592b190654a10685b46Brian Paul (void) pointer; 30158fefafa2200d3ea44ec46592b190654a10685b46Brian Paul} 30168fefafa2200d3ea44ec46592b190654a10685b46Brian Paul 30178fefafa2200d3ea44ec46592b190654a10685b46Brian Paul 30183c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian Paul/*** GLX_MESA_agp_offset ***/ 3019d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul 3020d6113fc20d68f5720740b89c594227d0312bab3eBrian Paulstatic GLuint 3021d6113fc20d68f5720740b89c594227d0312bab3eBrian PaulFake_glXGetAGPOffsetMESA( const GLvoid *pointer ) 3022d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul{ 3023d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul (void) pointer; 3024d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul return ~0; 3025d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul} 3026d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul 3027d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul 3028fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian/*** GLX_EXT_texture_from_pixmap ***/ 3029fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian 3030fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrianstatic void 3031fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrianFake_glXBindTexImageEXT(Display *dpy, GLXDrawable drawable, int buffer, 3032fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian const int *attrib_list) 3033fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian{ 3034fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian XMesaBuffer b = XMesaFindBuffer(dpy, drawable); 3035fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (b) 3036fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian XMesaBindTexImage(dpy, b, buffer, attrib_list); 3037fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian} 3038fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian 3039fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrianstatic void 3040fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrianFake_glXReleaseTexImageEXT(Display *dpy, GLXDrawable drawable, int buffer) 3041fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian{ 3042fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian XMesaBuffer b = XMesaFindBuffer(dpy, drawable); 3043fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (b) 3044fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian XMesaReleaseTexImage(dpy, b, buffer); 3045fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian} 3046fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian 3047fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian 30487287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul/* silence warning */ 3049e7b16b74bf5d13331b5a88bbbbb9096560297b63Brian Paulextern struct _glxapi_table *_mesa_GetGLXDispatchTable(void); 30507287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul 30517287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul 30527287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul/** 30537287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul * Create a new GLX API dispatch table with its function pointers 30547287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul * initialized to point to Mesa's "fake" GLX API functions. 30557287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul * Note: there's a similar function (_real_GetGLXDispatchTable) that 30567287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul * returns a new dispatch table with all pointers initalized to point 30577287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul * to "real" GLX functions (which understand GLX wire protocol, etc). 30587287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul */ 30597287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulstruct _glxapi_table * 30607287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul_mesa_GetGLXDispatchTable(void) 3061426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 3062426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul static struct _glxapi_table glx; 3063426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 3064426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul /* be sure our dispatch table size <= libGL's table */ 3065426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul { 306601915e90e6912f06d43d443a09157f7bbc96ddc5Brian Paul GLuint size = sizeof(struct _glxapi_table) / sizeof(void *); 3067426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) size; 3068426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul assert(_glxapi_get_dispatch_table_size() >= size); 3069426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul } 3070426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 3071426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul /* initialize the whole table to no-ops */ 3072426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul _glxapi_set_no_op_table(&glx); 3073426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 3074426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul /* now initialize the table with the functions I implement */ 3075426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.ChooseVisual = Fake_glXChooseVisual; 3076426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CopyContext = Fake_glXCopyContext; 3077426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CreateContext = Fake_glXCreateContext; 3078426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CreateGLXPixmap = Fake_glXCreateGLXPixmap; 3079426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.DestroyContext = Fake_glXDestroyContext; 3080426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.DestroyGLXPixmap = Fake_glXDestroyGLXPixmap; 3081426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.GetConfig = Fake_glXGetConfig; 3082426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul /*glx.GetCurrentContext = Fake_glXGetCurrentContext;*/ 3083426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul /*glx.GetCurrentDrawable = Fake_glXGetCurrentDrawable;*/ 3084426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.IsDirect = Fake_glXIsDirect; 3085426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.MakeCurrent = Fake_glXMakeCurrent; 3086426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.QueryExtension = Fake_glXQueryExtension; 3087426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.QueryVersion = Fake_glXQueryVersion; 3088426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.SwapBuffers = Fake_glXSwapBuffers; 3089426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.UseXFont = Fake_glXUseXFont; 3090426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.WaitGL = Fake_glXWaitGL; 3091426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.WaitX = Fake_glXWaitX; 3092426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 3093b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_VERSION_1_1 ***/ 3094426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.GetClientString = Fake_glXGetClientString; 3095426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.QueryExtensionsString = Fake_glXQueryExtensionsString; 3096426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.QueryServerString = Fake_glXQueryServerString; 3097426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 3098b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_VERSION_1_2 ***/ 3099426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul /*glx.GetCurrentDisplay = Fake_glXGetCurrentDisplay;*/ 3100426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 3101b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_VERSION_1_3 ***/ 3102426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.ChooseFBConfig = Fake_glXChooseFBConfig; 3103426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CreateNewContext = Fake_glXCreateNewContext; 3104426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CreatePbuffer = Fake_glXCreatePbuffer; 3105426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CreatePixmap = Fake_glXCreatePixmap; 3106426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CreateWindow = Fake_glXCreateWindow; 3107426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.DestroyPbuffer = Fake_glXDestroyPbuffer; 3108426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.DestroyPixmap = Fake_glXDestroyPixmap; 3109426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.DestroyWindow = Fake_glXDestroyWindow; 3110426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul /*glx.GetCurrentReadDrawable = Fake_glXGetCurrentReadDrawable;*/ 3111426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.GetFBConfigAttrib = Fake_glXGetFBConfigAttrib; 311271dea349d2be623b7819389428b0d6a124e8d184Brian Paul glx.GetFBConfigs = Fake_glXGetFBConfigs; 3113426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.GetSelectedEvent = Fake_glXGetSelectedEvent; 3114426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.GetVisualFromFBConfig = Fake_glXGetVisualFromFBConfig; 3115426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.MakeContextCurrent = Fake_glXMakeContextCurrent; 3116426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.QueryContext = Fake_glXQueryContext; 3117426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.QueryDrawable = Fake_glXQueryDrawable; 3118426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.SelectEvent = Fake_glXSelectEvent; 3119426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 3120b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SGI_swap_control ***/ 3121783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.SwapIntervalSGI = Fake_glXSwapIntervalSGI; 3122783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 3123b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SGI_video_sync ***/ 3124426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.GetVideoSyncSGI = Fake_glXGetVideoSyncSGI; 3125426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.WaitVideoSyncSGI = Fake_glXWaitVideoSyncSGI; 3126426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 3127b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SGI_make_current_read ***/ 3128783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.MakeCurrentReadSGI = Fake_glXMakeCurrentReadSGI; 31297cf50e137da497a590ec9001a9918972a6246142Brian Paul /*glx.GetCurrentReadDrawableSGI = Fake_glXGetCurrentReadDrawableSGI;*/ 3130783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 3131b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_video_source ***/ 3132b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#if defined(_VL_H) 3133783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.CreateGLXVideoSourceSGIX = Fake_glXCreateGLXVideoSourceSGIX; 3134783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.DestroyGLXVideoSourceSGIX = Fake_glXDestroyGLXVideoSourceSGIX; 3135783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul#endif 3136783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 3137b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_EXT_import_context ***/ 3138783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.FreeContextEXT = Fake_glXFreeContextEXT; 3139783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.GetContextIDEXT = Fake_glXGetContextIDEXT; 31407cf50e137da497a590ec9001a9918972a6246142Brian Paul /*glx.GetCurrentDisplayEXT = Fake_glXGetCurrentDisplayEXT;*/ 3141783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.ImportContextEXT = Fake_glXImportContextEXT; 3142783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.QueryContextInfoEXT = Fake_glXQueryContextInfoEXT; 31434536021a62e02fceaa6e8eb889b0f61743109cc4Brian Paul 3144b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SGIX_fbconfig ***/ 3145783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.GetFBConfigAttribSGIX = Fake_glXGetFBConfigAttribSGIX; 3146783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.ChooseFBConfigSGIX = Fake_glXChooseFBConfigSGIX; 3147783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.CreateGLXPixmapWithConfigSGIX = Fake_glXCreateGLXPixmapWithConfigSGIX; 3148783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.CreateContextWithConfigSGIX = Fake_glXCreateContextWithConfigSGIX; 3149783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.GetVisualFromFBConfigSGIX = Fake_glXGetVisualFromFBConfigSGIX; 3150783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.GetFBConfigFromVisualSGIX = Fake_glXGetFBConfigFromVisualSGIX; 3151783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 3152b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SGIX_pbuffer ***/ 3153783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.CreateGLXPbufferSGIX = Fake_glXCreateGLXPbufferSGIX; 3154783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.DestroyGLXPbufferSGIX = Fake_glXDestroyGLXPbufferSGIX; 3155783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.QueryGLXPbufferSGIX = Fake_glXQueryGLXPbufferSGIX; 3156783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.SelectEventSGIX = Fake_glXSelectEventSGIX; 3157783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.GetSelectedEventSGIX = Fake_glXGetSelectedEventSGIX; 3158783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 3159b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SGI_cushion ***/ 3160783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.CushionSGI = Fake_glXCushionSGI; 3161783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 3162b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SGIX_video_resize ***/ 3163783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.BindChannelToWindowSGIX = Fake_glXBindChannelToWindowSGIX; 3164783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.ChannelRectSGIX = Fake_glXChannelRectSGIX; 3165783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.QueryChannelRectSGIX = Fake_glXQueryChannelRectSGIX; 3166783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.QueryChannelDeltasSGIX = Fake_glXQueryChannelDeltasSGIX; 3167783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.ChannelRectSyncSGIX = Fake_glXChannelRectSyncSGIX; 3168783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 3169b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SGIX_dmbuffer **/ 3170b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#if defined(_DM_BUFFER_H_) 3171783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.AssociateDMPbufferSGIX = NULL; 3172783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul#endif 3173783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 3174b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SGIX_swap_group ***/ 3175783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.JoinSwapGroupSGIX = Fake_glXJoinSwapGroupSGIX; 3176783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 3177b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SGIX_swap_barrier ***/ 3178783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.BindSwapBarrierSGIX = Fake_glXBindSwapBarrierSGIX; 3179783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.QueryMaxSwapBarriersSGIX = Fake_glXQueryMaxSwapBarriersSGIX; 3180783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 3181b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SUN_get_transparent_index ***/ 3182783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.GetTransparentIndexSUN = Fake_glXGetTransparentIndexSUN; 31834536021a62e02fceaa6e8eb889b0f61743109cc4Brian Paul 3184b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_MESA_copy_sub_buffer ***/ 3185426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CopySubBufferMESA = Fake_glXCopySubBufferMESA; 3186426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 3187b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_MESA_release_buffers ***/ 3188426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.ReleaseBuffersMESA = Fake_glXReleaseBuffersMESA; 3189426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 3190b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_MESA_pixmap_colormap ***/ 3191426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CreateGLXPixmapMESA = Fake_glXCreateGLXPixmapMESA; 3192426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 3193b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_MESA_set_3dfx_mode ***/ 3194426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.Set3DfxModeMESA = Fake_glXSet3DfxModeMESA; 3195426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 3196d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul /*** GLX_NV_vertex_array_range ***/ 31978fefafa2200d3ea44ec46592b190654a10685b46Brian Paul glx.AllocateMemoryNV = Fake_glXAllocateMemoryNV; 31988fefafa2200d3ea44ec46592b190654a10685b46Brian Paul glx.FreeMemoryNV = Fake_glXFreeMemoryNV; 31998fefafa2200d3ea44ec46592b190654a10685b46Brian Paul 3200d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul /*** GLX_MESA_agp_offset ***/ 3201d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul glx.GetAGPOffsetMESA = Fake_glXGetAGPOffsetMESA; 3202d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul 3203fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian /*** GLX_EXT_texture_from_pixmap ***/ 3204fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian glx.BindTexImageEXT = Fake_glXBindTexImageEXT; 3205fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian glx.ReleaseTexImageEXT = Fake_glXReleaseTexImageEXT; 3206fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian 3207426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul return &glx; 3208426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 3209