fakeglx.c revision 3f8a61ffa256b4fe36e93a0904b8893c805eb313
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 56298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg#define 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: 15581fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick /* Color-index rendering is not supported. */ 15681fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick return GL_FALSE; 157afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case TrueColor: 158afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case DirectColor: 159afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Any depth of TrueColor or DirectColor works in RGB mode */ 160afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return GL_TRUE; 161afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: 162afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* This should never happen */ 163afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return GL_FALSE; 164afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 165afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 166afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 167afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 168afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1691d97c277e0cb2b75559d495a58222f2511212a66Brian Paul/** 1701d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * Get an array OverlayInfo records for specified screen. 1711d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * \param dpy the display 1721d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * \param screen screen number 1731d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * \param numOverlays returns numver of OverlayInfo records 1741d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * \return pointer to OverlayInfo array, free with XFree() 175afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 1761d97c277e0cb2b75559d495a58222f2511212a66Brian Paulstatic OverlayInfo * 1771d97c277e0cb2b75559d495a58222f2511212a66Brian PaulGetOverlayInfo(Display *dpy, int screen, int *numOverlays) 178afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 179afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg Atom overlayVisualsAtom; 180afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg Atom actualType; 1811d97c277e0cb2b75559d495a58222f2511212a66Brian Paul Status status; 1821d97c277e0cb2b75559d495a58222f2511212a66Brian Paul unsigned char *ovInfo; 183afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg unsigned long sizeData, bytesLeft; 1841d97c277e0cb2b75559d495a58222f2511212a66Brian Paul int actualFormat; 185afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 186afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* 187afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * The SERVER_OVERLAY_VISUALS property on the root window contains 188afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * a list of overlay visuals. Get that list now. 189afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 190afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg overlayVisualsAtom = XInternAtom(dpy,"SERVER_OVERLAY_VISUALS", True); 191afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (overlayVisualsAtom == None) { 192afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 193afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 194afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1951d97c277e0cb2b75559d495a58222f2511212a66Brian Paul status = XGetWindowProperty(dpy, RootWindow(dpy, screen), 196afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg overlayVisualsAtom, 0L, (long) 10000, False, 197afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg overlayVisualsAtom, &actualType, &actualFormat, 198afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg &sizeData, &bytesLeft, 1991d97c277e0cb2b75559d495a58222f2511212a66Brian Paul &ovInfo); 200afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 201afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (status != Success || actualType != overlayVisualsAtom || 202afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg actualFormat != 32 || sizeData < 4) { 203afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* something went wrong */ 2041d97c277e0cb2b75559d495a58222f2511212a66Brian Paul XFree((void *) ovInfo); 2051d97c277e0cb2b75559d495a58222f2511212a66Brian Paul *numOverlays = 0; 2061d97c277e0cb2b75559d495a58222f2511212a66Brian Paul return NULL; 2071d97c277e0cb2b75559d495a58222f2511212a66Brian Paul } 2081d97c277e0cb2b75559d495a58222f2511212a66Brian Paul 2091d97c277e0cb2b75559d495a58222f2511212a66Brian Paul *numOverlays = sizeData / 4; 2101d97c277e0cb2b75559d495a58222f2511212a66Brian Paul return (OverlayInfo *) ovInfo; 2111d97c277e0cb2b75559d495a58222f2511212a66Brian Paul} 2121d97c277e0cb2b75559d495a58222f2511212a66Brian Paul 2131d97c277e0cb2b75559d495a58222f2511212a66Brian Paul 2141d97c277e0cb2b75559d495a58222f2511212a66Brian Paul 2151d97c277e0cb2b75559d495a58222f2511212a66Brian Paul/** 2161d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * Return the level (overlay, normal, underlay) of a given XVisualInfo. 2171d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * Input: dpy - the X display 2181d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * vinfo - the XVisualInfo to test 2191d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * Return: level of the visual: 2201d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * 0 = normal planes 2211d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * >0 = overlay planes 2221d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * <0 = underlay planes 2231d97c277e0cb2b75559d495a58222f2511212a66Brian Paul */ 2241d97c277e0cb2b75559d495a58222f2511212a66Brian Paulstatic int 2251d97c277e0cb2b75559d495a58222f2511212a66Brian Paullevel_of_visual( Display *dpy, XVisualInfo *vinfo ) 2261d97c277e0cb2b75559d495a58222f2511212a66Brian Paul{ 2271d97c277e0cb2b75559d495a58222f2511212a66Brian Paul OverlayInfo *overlay_info; 2281d97c277e0cb2b75559d495a58222f2511212a66Brian Paul int numOverlaysPerScreen, i; 2291d97c277e0cb2b75559d495a58222f2511212a66Brian Paul 2301d97c277e0cb2b75559d495a58222f2511212a66Brian Paul overlay_info = GetOverlayInfo(dpy, vinfo->screen, &numOverlaysPerScreen); 2311d97c277e0cb2b75559d495a58222f2511212a66Brian Paul if (!overlay_info) { 232afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 233afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 234afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 235afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* search the overlay visual list for the visual ID of interest */ 2361d97c277e0cb2b75559d495a58222f2511212a66Brian Paul for (i = 0; i < numOverlaysPerScreen; i++) { 2371d97c277e0cb2b75559d495a58222f2511212a66Brian Paul const OverlayInfo *ov = overlay_info + i; 2381d97c277e0cb2b75559d495a58222f2511212a66Brian Paul if (ov->overlay_visual == vinfo->visualid) { 239afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* found the visual */ 240afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (/*ov->transparent_type==1 &&*/ ov->layer!=0) { 241afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int level = ov->layer; 242afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XFree((void *) overlay_info); 243afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return level; 244afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 245afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 246afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XFree((void *) overlay_info); 247afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 248afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 249afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 250afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 251afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 252afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* The visual ID was not found in the overlay list. */ 253afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XFree((void *) overlay_info); 254afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 255afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 256afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 257afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 258afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 259afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 260afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 261afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Given an XVisualInfo and RGB, Double, and Depth buffer flags, save the 262afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * configuration in our list of GLX visuals. 263afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 264afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XMesaVisual 265afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgsave_glx_visual( Display *dpy, XVisualInfo *vinfo, 26681fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick GLboolean alphaFlag, GLboolean dbFlag, 267afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLboolean stereoFlag, 268afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLint depth_size, GLint stencil_size, 269b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint accumRedSize, GLint accumGreenSize, 270b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint accumBlueSize, GLint accumAlphaSize, 271894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul GLint level, GLint numAuxBuffers ) 272afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 273afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLboolean ximageFlag = GL_TRUE; 274afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaVisual xmvis; 275afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLint i; 276afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLboolean comparePointers; 277afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 278afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (dbFlag) { 279afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Check if the MESA_BACK_BUFFER env var is set */ 280367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul char *backbuffer = _mesa_getenv("MESA_BACK_BUFFER"); 281afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (backbuffer) { 282afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (backbuffer[0]=='p' || backbuffer[0]=='P') { 283afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg ximageFlag = GL_FALSE; 284afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 285afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else if (backbuffer[0]=='x' || backbuffer[0]=='X') { 286afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg ximageFlag = GL_TRUE; 287afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 288afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 289d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul _mesa_warning(NULL, "Mesa: invalid value for MESA_BACK_BUFFER environment variable, using an XImage."); 290afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 291afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 292afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 293afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 294da2f1e88bc63403a95b89706905c070b7c894863Brian if (stereoFlag) { 295da2f1e88bc63403a95b89706905c070b7c894863Brian /* stereo not supported */ 296da2f1e88bc63403a95b89706905c070b7c894863Brian return NULL; 297da2f1e88bc63403a95b89706905c070b7c894863Brian } 298da2f1e88bc63403a95b89706905c070b7c894863Brian 299afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Comparing IDs uses less memory but sometimes fails. */ 300afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* XXX revisit this after 3.0 is finished. */ 301367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul if (_mesa_getenv("MESA_GLX_VISUAL_HACK")) 302afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg comparePointers = GL_TRUE; 303afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else 304afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg comparePointers = GL_FALSE; 305afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 306a13331d59b535aa4a1ddad695420de5d6f814550Brian Paul /* Force the visual to have an alpha channel */ 30781fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick if (_mesa_getenv("MESA_GLX_FORCE_ALPHA")) 308a13331d59b535aa4a1ddad695420de5d6f814550Brian Paul alphaFlag = GL_TRUE; 309a13331d59b535aa4a1ddad695420de5d6f814550Brian Paul 310afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* First check if a matching visual is already in the list */ 311afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (i=0; i<NumVisuals; i++) { 312afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaVisual v = VisualTable[i]; 313afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (v->display == dpy 314304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick && v->mesa_visual.level == level 315894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul && v->mesa_visual.numAuxBuffers == numAuxBuffers 316afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg && v->ximage_flag == ximageFlag 3171832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul && v->mesa_visual.doubleBufferMode == dbFlag 3181832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul && v->mesa_visual.stereoMode == stereoFlag 3191832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul && (v->mesa_visual.alphaBits > 0) == alphaFlag 3201832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul && (v->mesa_visual.depthBits >= depth_size || depth_size == 0) 3211832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul && (v->mesa_visual.stencilBits >= stencil_size || stencil_size == 0) 3221832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul && (v->mesa_visual.accumRedBits >= accumRedSize || accumRedSize == 0) 3231832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul && (v->mesa_visual.accumGreenBits >= accumGreenSize || accumGreenSize == 0) 3241832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul && (v->mesa_visual.accumBlueBits >= accumBlueSize || accumBlueSize == 0) 3251832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul && (v->mesa_visual.accumAlphaBits >= accumAlphaSize || accumAlphaSize == 0)) { 326afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* now either compare XVisualInfo pointers or visual IDs */ 327d0247f53aea8fa8677aadc8a00f75c8993be9ebcBrian Paul if ((!comparePointers && v->visinfo->visualid == vinfo->visualid) 328afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg || (comparePointers && v->vishandle == vinfo)) { 329afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return v; 330afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 331afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 332afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 333afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 334afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Create a new visual and add it to the list. */ 335afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 33681fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick xmvis = XMesaCreateVisual( dpy, vinfo, GL_TRUE, alphaFlag, dbFlag, 337c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul stereoFlag, ximageFlag, 338c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul depth_size, stencil_size, 339c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul accumRedSize, accumBlueSize, 340c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul accumBlueSize, accumAlphaSize, 0, level, 341c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul GLX_NONE_EXT ); 342afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (xmvis) { 343f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul /* Save a copy of the pointer now so we can find this visual again 344f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul * if we need to search for it in find_glx_visual(). 345f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul */ 346f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul xmvis->vishandle = vinfo; 34764034c4fb5c56f63d37faa6f64f3183ca106856aAlan Hourihane /* Allocate more space for additional visual */ 3489580179dfb42d5b81ff6ec9704b82a556c7f1229Brian Paul VisualTable = (XMesaVisual *) _mesa_realloc( VisualTable, 34964034c4fb5c56f63d37faa6f64f3183ca106856aAlan Hourihane sizeof(XMesaVisual) * NumVisuals, 350394fd40a536faade5ccfbbb1f2920394e89ad4aaBrian Paul sizeof(XMesaVisual) * (NumVisuals + 1)); 351f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul /* add xmvis to the list */ 352afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg VisualTable[NumVisuals] = xmvis; 353afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg NumVisuals++; 3547287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul /* XXX minor hack, because XMesaCreateVisual doesn't support an 3557287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul * aux buffers parameter. 3567287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul */ 357894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul xmvis->mesa_visual.numAuxBuffers = numAuxBuffers; 358afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 359afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return xmvis; 360afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 361afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 362afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 363dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul/** 364dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul * Return the default number of bits for the Z buffer. 365dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul * If defined, use the MESA_GLX_DEPTH_BITS env var value. 366dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul * Otherwise, use the DEFAULT_SOFTWARE_DEPTH_BITS constant. 367dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul * XXX probably do the same thing for stencil, accum, etc. 368dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul */ 369dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paulstatic GLint 370dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Pauldefault_depth_bits(void) 371dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul{ 372dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul int zBits; 373dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul const char *zEnv = _mesa_getenv("MESA_GLX_DEPTH_BITS"); 374dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul if (zEnv) 37560b0cae412029e53654f38d0de151908f1feb310Kenneth Graunke zBits = atoi(zEnv); 376dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul else 377dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul zBits = DEFAULT_SOFTWARE_DEPTH_BITS; 378dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul return zBits; 379dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul} 380dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul 381978ef2bb6d9ca4996a24f95820a699e22c84f70bBrian Paulstatic GLint 382c12ee99d119debe1a421a77c1cc6d99d958ae94bBrian Pauldefault_alpha_bits(void) 383c12ee99d119debe1a421a77c1cc6d99d958ae94bBrian Paul{ 384c12ee99d119debe1a421a77c1cc6d99d958ae94bBrian Paul int aBits; 385c12ee99d119debe1a421a77c1cc6d99d958ae94bBrian Paul const char *aEnv = _mesa_getenv("MESA_GLX_ALPHA_BITS"); 386c12ee99d119debe1a421a77c1cc6d99d958ae94bBrian Paul if (aEnv) 38760b0cae412029e53654f38d0de151908f1feb310Kenneth Graunke aBits = atoi(aEnv); 388c12ee99d119debe1a421a77c1cc6d99d958ae94bBrian Paul else 389c12ee99d119debe1a421a77c1cc6d99d958ae94bBrian Paul aBits = 0; 390c12ee99d119debe1a421a77c1cc6d99d958ae94bBrian Paul return aBits; 391c12ee99d119debe1a421a77c1cc6d99d958ae94bBrian Paul} 392c12ee99d119debe1a421a77c1cc6d99d958ae94bBrian Paul 393c12ee99d119debe1a421a77c1cc6d99d958ae94bBrian Paulstatic GLint 394978ef2bb6d9ca4996a24f95820a699e22c84f70bBrian Pauldefault_accum_bits(void) 395978ef2bb6d9ca4996a24f95820a699e22c84f70bBrian Paul{ 396978ef2bb6d9ca4996a24f95820a699e22c84f70bBrian Paul return 16; 397978ef2bb6d9ca4996a24f95820a699e22c84f70bBrian Paul} 398978ef2bb6d9ca4996a24f95820a699e22c84f70bBrian Paul 399dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul 400afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 401afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 402afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Create a GLX visual from a regular XVisualInfo. 403ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * This is called when Fake GLX is given an XVisualInfo which wasn't 404ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * returned by glXChooseVisual. Since this is the first time we're 405ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * considering this visual we'll take a guess at reasonable values 406ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * for depth buffer size, stencil size, accum size, etc. 407ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * This is the best we can do with a client-side emulation of GLX. 408afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 409afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XMesaVisual 410afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgcreate_glx_visual( Display *dpy, XVisualInfo *visinfo ) 411afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 412afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int vislevel; 413dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul GLint zBits = default_depth_bits(); 414978ef2bb6d9ca4996a24f95820a699e22c84f70bBrian Paul GLint accBits = default_accum_bits(); 415c12ee99d119debe1a421a77c1cc6d99d958ae94bBrian Paul GLboolean alphaFlag = default_alpha_bits() > 0; 416afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 417afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vislevel = level_of_visual( dpy, visinfo ); 418afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vislevel) { 41981fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick /* Color-index rendering to overlays is not supported. */ 42081fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick return NULL; 421afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 422afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else if (is_usable_visual( visinfo )) { 42381fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick /* Configure this visual as RGB, double-buffered, depth-buffered. */ 42481fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick /* This is surely wrong for some people's needs but what else */ 42581fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick /* can be done? They should use glXChooseVisual(). */ 42681fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick return save_glx_visual( dpy, visinfo, 42781fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick alphaFlag, /* alpha */ 42881fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick GL_TRUE, /* double */ 42981fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick GL_FALSE, /* stereo */ 43081fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick zBits, 43181fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick STENCIL_BITS, 43281fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick accBits, /* r */ 43381fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick accBits, /* g */ 43481fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick accBits, /* b */ 43581fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick accBits, /* a */ 43681fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick 0, /* level */ 43781fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick 0 /* numAux */ 43881fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick ); 439afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 440afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 441d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul _mesa_warning(NULL, "Mesa: error in glXCreateContext: bad visual\n"); 442afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 443afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 444afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 445afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 446afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 447afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 448afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 449afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Find the GLX visual associated with an XVisualInfo. 450afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 451afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XMesaVisual 452afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgfind_glx_visual( Display *dpy, XVisualInfo *vinfo ) 453afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 454afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int i; 455afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 456f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul /* try to match visual id */ 457afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (i=0;i<NumVisuals;i++) { 458f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul if (VisualTable[i]->display==dpy 459f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul && VisualTable[i]->visinfo->visualid == vinfo->visualid) { 460afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return VisualTable[i]; 461afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 462afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 463f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul 464f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul /* if that fails, try to match pointers */ 465afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (i=0;i<NumVisuals;i++) { 466f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul if (VisualTable[i]->display==dpy && VisualTable[i]->vishandle==vinfo) { 467afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return VisualTable[i]; 468afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 469afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 470f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul 471afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 472afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 473afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 474afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 475afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 4761d97c277e0cb2b75559d495a58222f2511212a66Brian Paul/** 477afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return the transparent pixel value for a GLX visual. 478afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input: glxvis - the glx_visual 479afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return: a pixel value or -1 if no transparent pixel 480afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 4817287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulstatic int 4827287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paultransparent_pixel( XMesaVisual glxvis ) 483afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 484afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg Display *dpy = glxvis->display; 485afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XVisualInfo *vinfo = glxvis->visinfo; 4861d97c277e0cb2b75559d495a58222f2511212a66Brian Paul OverlayInfo *overlay_info; 4871d97c277e0cb2b75559d495a58222f2511212a66Brian Paul int numOverlaysPerScreen, i; 488afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 4891d97c277e0cb2b75559d495a58222f2511212a66Brian Paul overlay_info = GetOverlayInfo(dpy, vinfo->screen, &numOverlaysPerScreen); 4901d97c277e0cb2b75559d495a58222f2511212a66Brian Paul if (!overlay_info) { 491afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return -1; 492afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 493afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 4941d97c277e0cb2b75559d495a58222f2511212a66Brian Paul for (i = 0; i < numOverlaysPerScreen; i++) { 4951d97c277e0cb2b75559d495a58222f2511212a66Brian Paul const OverlayInfo *ov = overlay_info + i; 4961d97c277e0cb2b75559d495a58222f2511212a66Brian Paul if (ov->overlay_visual == vinfo->visualid) { 497afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* found it! */ 4981d97c277e0cb2b75559d495a58222f2511212a66Brian Paul if (ov->transparent_type == 0) { 499afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* type 0 indicates no transparency */ 500afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XFree((void *) overlay_info); 501afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return -1; 502afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 503afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 504afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* ov->value is the transparent pixel */ 505afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XFree((void *) overlay_info); 506afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return ov->value; 507afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 508afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 509afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 510afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 511afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* The visual ID was not found in the overlay list. */ 512afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XFree((void *) overlay_info); 513afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return -1; 514afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 515afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 516afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 517afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 5181d97c277e0cb2b75559d495a58222f2511212a66Brian Paul/** 519afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Try to get an X visual which matches the given arguments. 520afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 5217287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulstatic XVisualInfo * 5227287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulget_visual( Display *dpy, int scr, unsigned int depth, int xclass ) 523afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 524afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XVisualInfo temp, *vis; 525afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg long mask; 526afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int n; 527afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg unsigned int default_depth; 528afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int default_class; 529afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 530afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg mask = VisualScreenMask | VisualDepthMask | VisualClassMask; 531afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg temp.screen = scr; 532afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg temp.depth = depth; 533afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg temp.CLASS = xclass; 534afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 535afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default_depth = DefaultDepth(dpy,scr); 536afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default_class = DefaultVisual(dpy,scr)->CLASS; 537afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 538afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (depth==default_depth && xclass==default_class) { 539afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* try to get root window's visual */ 540afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg temp.visualid = DefaultVisual(dpy,scr)->visualid; 541afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg mask |= VisualIDMask; 542afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 543afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 544afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = XGetVisualInfo( dpy, mask, &temp, &n ); 545afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 546afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* In case bits/pixel > 24, make sure color channels are still <=8 bits. 547afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * An SGI Infinite Reality system, for example, can have 30bpp pixels: 548afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * 10 bits per color channel. Mesa's limited to a max of 8 bits/channel. 549afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 550afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis && depth > 24 && (xclass==TrueColor || xclass==DirectColor)) { 55171dea349d2be623b7819389428b0d6a124e8d184Brian Paul if (_mesa_bitcount((GLuint) vis->red_mask ) <= 8 && 55271dea349d2be623b7819389428b0d6a124e8d184Brian Paul _mesa_bitcount((GLuint) vis->green_mask) <= 8 && 55371dea349d2be623b7819389428b0d6a124e8d184Brian Paul _mesa_bitcount((GLuint) vis->blue_mask ) <= 8) { 554afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 555afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 556afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 557afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XFree((void *) vis); 558afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 559afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 560afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 561afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 562afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 563afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 564afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 565afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 566afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 567afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 568afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Retrieve the value of the given environment variable and find 569afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * the X visual which matches it. 570afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input: dpy - the display 571afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * screen - the screen number 572afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * varname - the name of the environment variable 573afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return: an XVisualInfo pointer to NULL if error. 574afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 5757287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulstatic XVisualInfo * 5767287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulget_env_visual(Display *dpy, int scr, const char *varname) 577afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 578afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg char value[100], type[100]; 579afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int depth, xclass = -1; 580afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XVisualInfo *vis; 581afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 582367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul if (!_mesa_getenv( varname )) { 583afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 584afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 585afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 586f69d1d1438361f10fd8db78d2d38f26e33db9747Kenneth Graunke strncpy( value, _mesa_getenv(varname), 100 ); 587afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg value[99] = 0; 588afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 589afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg sscanf( value, "%s %d", type, &depth ); 590afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 5918d73aa6d1ae6e89bb2cd8f52f5586d569a4b6eebKenneth Graunke if (strcmp(type,"TrueColor")==0) xclass = TrueColor; 5928d73aa6d1ae6e89bb2cd8f52f5586d569a4b6eebKenneth Graunke else if (strcmp(type,"DirectColor")==0) xclass = DirectColor; 5938d73aa6d1ae6e89bb2cd8f52f5586d569a4b6eebKenneth Graunke else if (strcmp(type,"GrayScale")==0) xclass = GrayScale; 5948d73aa6d1ae6e89bb2cd8f52f5586d569a4b6eebKenneth Graunke else if (strcmp(type,"StaticGray")==0) xclass = StaticGray; 595afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 596afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (xclass>-1 && depth>0) { 597afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, scr, depth, xclass ); 598afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 599afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 600afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 601afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 602afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 6032ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul _mesa_warning(NULL, "GLX unable to find visual class=%s, depth=%d.", 6042ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul type, depth); 605d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul 606afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 607afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 608afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 609afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 610afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 611afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 612afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Select an X visual which satisfies the RGBA/CI flag and minimum depth. 613afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input: dpy, screen - X display and screen number 614afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * min_depth - minimum visual depth 615afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * preferred_class - preferred GLX visual class or DONT_CARE 616afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return: pointer to an XVisualInfo or NULL. 617afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 6187287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulstatic XVisualInfo * 61981fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanickchoose_x_visual(Display *dpy, int screen, int min_depth, int preferred_class) 620afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 621afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XVisualInfo *vis; 622db6aa58267cad3f502f03ab80b9deb6b75320a91Brian Paul int xclass, visclass = 0; 623afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int depth; 624afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 62581fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick /* First see if the MESA_RGB_VISUAL env var is defined */ 62681fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick vis = get_env_visual( dpy, screen, "MESA_RGB_VISUAL" ); 62781fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick if (vis) { 62881fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick return vis; 62981fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick } 63081fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick /* Otherwise, search for a suitable visual */ 63181fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick if (preferred_class==DONT_CARE) { 63281fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick for (xclass=0;xclass<4;xclass++) { 63381fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick switch (xclass) { 63481fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick case 0: visclass = TrueColor; break; 63581fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick case 1: visclass = DirectColor; break; 63681fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick case 2: visclass = GrayScale; break; 63781fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick case 3: visclass = StaticGray; break; 63881fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick } 63981fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick if (min_depth==0) { 64081fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick /* start with shallowest */ 64181fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick for (depth=0;depth<=32;depth++) { 64281fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick vis = get_visual( dpy, screen, depth, visclass ); 64381fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick if (vis) { 64481fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick return vis; 64581fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick } 64681fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick } 64781fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick } 64881fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick else { 64981fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick /* start with deepest */ 65081fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick for (depth=32;depth>=min_depth;depth--) { 65181fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick vis = get_visual( dpy, screen, depth, visclass ); 65281fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick if (vis) { 65381fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick return vis; 65481fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick } 65581fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick } 65681fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick } 657afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 658afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 659afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 66081fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick /* search for a specific visual class */ 66181fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick switch (preferred_class) { 66281fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick case GLX_TRUE_COLOR_EXT: visclass = TrueColor; break; 66381fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick case GLX_DIRECT_COLOR_EXT: visclass = DirectColor; break; 66481fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick case GLX_GRAY_SCALE_EXT: visclass = GrayScale; break; 66581fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick case GLX_STATIC_GRAY_EXT: visclass = StaticGray; break; 66681fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick case GLX_PSEUDO_COLOR_EXT: 66781fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick case GLX_STATIC_COLOR_EXT: 66881fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick default: return NULL; 669afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 67081fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick if (min_depth==0) { 67181fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick /* start with shallowest */ 67281fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick for (depth=0;depth<=32;depth++) { 67381fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick vis = get_visual( dpy, screen, depth, visclass ); 67481fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick if (vis) { 67581fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick return vis; 67681fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick } 67781fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick } 678afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 679afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 68081fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick /* start with deepest */ 68181fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick for (depth=32;depth>=min_depth;depth--) { 68281fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick vis = get_visual( dpy, screen, depth, visclass ); 68381fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick if (vis) { 68481fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick return vis; 68581fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick } 68681fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick } 687afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 688afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 689afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 690afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* didn't find a visual */ 691afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 692afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 693afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 694afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 695afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 696afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 697afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Find the deepest X over/underlay visual of at least min_depth. 698afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input: dpy, screen - X display and screen number 699afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * level - the over/underlay level 700afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * trans_type - transparent pixel type: GLX_NONE_EXT, 701afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * GLX_TRANSPARENT_RGB_EXT, GLX_TRANSPARENT_INDEX_EXT, 702afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * or DONT_CARE 703afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * trans_value - transparent pixel value or DONT_CARE 704afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * min_depth - minimum visual depth 705afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * preferred_class - preferred GLX visual class or DONT_CARE 706afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return: pointer to an XVisualInfo or NULL. 707afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 7087287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulstatic XVisualInfo * 70981fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanickchoose_x_overlay_visual( Display *dpy, int scr, 7107287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul int level, int trans_type, int trans_value, 7117287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul int min_depth, int preferred_class ) 712afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 713afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg OverlayInfo *overlay_info; 714afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int numOverlaysPerScreen; 715afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int i; 716afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XVisualInfo *deepvis; 717afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int deepest; 718afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 719afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /*DEBUG int tt, tv; */ 720afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 721afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (preferred_class) { 722afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRUE_COLOR_EXT: preferred_class = TrueColor; break; 723afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_DIRECT_COLOR_EXT: preferred_class = DirectColor; break; 724afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_PSEUDO_COLOR_EXT: preferred_class = PseudoColor; break; 725afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STATIC_COLOR_EXT: preferred_class = StaticColor; break; 726afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_GRAY_SCALE_EXT: preferred_class = GrayScale; break; 727afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STATIC_GRAY_EXT: preferred_class = StaticGray; break; 728afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: preferred_class = DONT_CARE; 729afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 730afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 7311d97c277e0cb2b75559d495a58222f2511212a66Brian Paul overlay_info = GetOverlayInfo(dpy, scr, &numOverlaysPerScreen); 7321d97c277e0cb2b75559d495a58222f2511212a66Brian Paul if (!overlay_info) { 733afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 734afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 735afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 736afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Search for the deepest overlay which satisifies all criteria. */ 737afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg deepest = min_depth; 738afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg deepvis = NULL; 739afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 7401d97c277e0cb2b75559d495a58222f2511212a66Brian Paul for (i = 0; i < numOverlaysPerScreen; i++) { 7411d97c277e0cb2b75559d495a58222f2511212a66Brian Paul const OverlayInfo *ov = overlay_info + i; 742afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XVisualInfo *vislist, vistemplate; 743afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int count; 744afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 745afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (ov->layer!=level) { 746afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* failed overlay level criteria */ 747afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg continue; 748afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 749afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!(trans_type==DONT_CARE 750afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg || (trans_type==GLX_TRANSPARENT_INDEX_EXT 751afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg && ov->transparent_type>0) 752afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg || (trans_type==GLX_NONE_EXT && ov->transparent_type==0))) { 753afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* failed transparent pixel type criteria */ 754afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg continue; 755afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 756afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (trans_value!=DONT_CARE && trans_value!=ov->value) { 757afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* failed transparent pixel value criteria */ 758afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg continue; 759afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 760afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 761afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* get XVisualInfo and check the depth */ 762afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vistemplate.visualid = ov->overlay_visual; 763afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vistemplate.screen = scr; 764afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vislist = XGetVisualInfo( dpy, VisualIDMask | VisualScreenMask, 765afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg &vistemplate, &count ); 766afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 767afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (count!=1) { 768afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* something went wrong */ 769afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg continue; 770afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 771afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (preferred_class!=DONT_CARE && preferred_class!=vislist->CLASS) { 772afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* wrong visual class */ 773afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg continue; 774afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 775afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 77681fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick /* Color-index rendering is not supported. Make sure we have True/DirectColor */ 77781fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick if (vislist->CLASS != TrueColor && vislist->CLASS != DirectColor) 77842f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul continue; 77942f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul 780afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (deepvis==NULL || vislist->depth > deepest) { 781afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* YES! found a satisfactory visual */ 782afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (deepvis) { 78380af3614d88c0cac160e787de7f34b37e96cb626Brian Paul XFree( deepvis ); 784afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 785afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg deepest = vislist->depth; 786afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg deepvis = vislist; 787afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* DEBUG tt = ov->transparent_type;*/ 788afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* DEBUG tv = ov->value; */ 789afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 790afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 791afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 792afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*DEBUG 793afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (deepvis) { 794afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg printf("chose 0x%x: layer=%d depth=%d trans_type=%d trans_value=%d\n", 795afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg deepvis->visualid, level, deepvis->depth, tt, tv ); 796afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 797afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg*/ 798afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return deepvis; 799afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 800afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 801afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 8027cf50e137da497a590ec9001a9918972a6246142Brian Paul/**********************************************************************/ 8036c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul/*** Display-related functions ***/ 8046c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul/**********************************************************************/ 8056c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul 8066c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul 8076c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul/** 8086c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul * Free all XMesaVisuals which are associated with the given display. 8096c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul */ 8106c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paulstatic void 8116c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Pauldestroy_visuals_on_display(Display *dpy) 8126c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul{ 8136c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul int i; 8146c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul for (i = 0; i < NumVisuals; i++) { 8156c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul if (VisualTable[i]->display == dpy) { 8166c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul /* remove this visual */ 8176c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul int j; 8186c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul free(VisualTable[i]); 8196c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul for (j = i; j < NumVisuals - 1; j++) 8206c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul VisualTable[j] = VisualTable[j + 1]; 8216c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul NumVisuals--; 8226c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul } 8236c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul } 8246c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul} 8256c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul 8266c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul 8276c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul/** 8286c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul * Called from XCloseDisplay() to let us free our display-related data. 8296c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul */ 8306c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paulstatic int 8316c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paulclose_display_callback(Display *dpy, XExtCodes *codes) 8326c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul{ 8336c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul destroy_visuals_on_display(dpy); 8346c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul xmesa_destroy_buffers_on_display(dpy); 8356c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul return 0; 8366c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul} 8376c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul 8386c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul 8396c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul/** 8406c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul * Look for the named extension on given display and return a pointer 8416c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul * to the _XExtension data, or NULL if extension not found. 8426c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul */ 8436c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paulstatic _XExtension * 8446c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paullookup_extension(Display *dpy, const char *extName) 8456c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul{ 8466c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul _XExtension *ext; 8476c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul for (ext = dpy->ext_procs; ext; ext = ext->next) { 84852e36cd8d9a727d786c2db14ae8291d48fad8e47Brian Paul if (ext->name && strcmp(ext->name, extName) == 0) { 8496c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul return ext; 8506c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul } 8516c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul } 8526c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul return NULL; 8536c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul} 8546c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul 8556c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul 8566c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul/** 8576c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul * Whenever we're given a new Display pointer, call this function to 8586c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul * register our close_display_callback function. 8596c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul */ 8606c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paulstatic void 8616c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paulregister_with_display(Display *dpy) 8626c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul{ 8636c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul const char *extName = "MesaGLX"; 8646c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul _XExtension *ext; 8656c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul 8666c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul ext = lookup_extension(dpy, extName); 8676c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul if (!ext) { 8686c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul XExtCodes *c = XAddExtension(dpy); 8696c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul ext = dpy->ext_procs; /* new extension is at head of list */ 8706c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul assert(c->extension == ext->codes.extension); 871da580dbbe8833fbc49325bb0f7aadf05ea03b526Brian Paul (void) c; /* silence warning */ 8726c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul ext->name = _mesa_strdup(extName); 8736c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul ext->close_display = close_display_callback; 8746c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul } 8756c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul} 8766c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul 8776c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul 8786c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul/**********************************************************************/ 8797cf50e137da497a590ec9001a9918972a6246142Brian Paul/*** Begin Fake GLX API Functions ***/ 8807cf50e137da497a590ec9001a9918972a6246142Brian Paul/**********************************************************************/ 8817cf50e137da497a590ec9001a9918972a6246142Brian Paul 882afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 883ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul/** 884ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul * Helper used by glXChooseVisual and glXChooseFBConfig. 885ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul * The fbConfig parameter must be GL_FALSE for the former and GL_TRUE for 886ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul * the later. 887ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul * In either case, the attribute list is terminated with the value 'None'. 888ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul */ 8897287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulstatic XMesaVisual 8901f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paulchoose_visual( Display *dpy, int screen, const int *list, GLboolean fbConfig ) 891afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 8921f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul const GLboolean rgbModeDefault = fbConfig; 8933265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul const int *parselist; 894afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XVisualInfo *vis; 895afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int min_ci = 0; 896afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int min_red=0, min_green=0, min_blue=0; 897b3063ac398b72e6a4fd2015d4e220495b9779294Brian Paul GLboolean rgb_flag = rgbModeDefault; 898afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLboolean alpha_flag = GL_FALSE; 899afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLboolean double_flag = GL_FALSE; 900afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLboolean stereo_flag = GL_FALSE; 901afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLint depth_size = 0; 902afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLint stencil_size = 0; 903b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint accumRedSize = 0; 904b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint accumGreenSize = 0; 905b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint accumBlueSize = 0; 906b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint accumAlphaSize = 0; 907afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int level = 0; 908afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int visual_type = DONT_CARE; 909afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int trans_type = DONT_CARE; 910afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int trans_value = DONT_CARE; 911e1210b176926349b258c7ec77b7f36716025c82aBrian Paul GLint caveat = DONT_CARE; 9123265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul XMesaVisual xmvis = NULL; 9133a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul int desiredVisualID = -1; 914894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul int numAux = 0; 915afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 916afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist = list; 917afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 918afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg while (*parselist) { 919afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 920afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (*parselist) { 921afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_USE_GL: 9221f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul if (fbConfig) { 9231f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul /* invalid token */ 9241f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul return NULL; 9251f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul } 9261f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul else { 9271f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul /* skip */ 9281f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul parselist++; 9291f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul } 930afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 931afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_BUFFER_SIZE: 932afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 933afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg min_ci = *parselist++; 934afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 935afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_LEVEL: 936afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 937afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg level = *parselist++; 938afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 939afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_RGBA: 9401f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul if (fbConfig) { 9411f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul /* invalid token */ 9421f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul return NULL; 9431f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul } 9441f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul else { 9451f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul rgb_flag = GL_TRUE; 9461f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul parselist++; 9471f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul } 948afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 949afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_DOUBLEBUFFER: 9501f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul parselist++; 9511f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul if (fbConfig) { 9521f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul double_flag = *parselist++; 9531f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul } 9541f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul else { 9551f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul double_flag = GL_TRUE; 9561f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul } 957afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 958afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STEREO: 9591f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul parselist++; 9601f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul if (fbConfig) { 9611f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul stereo_flag = *parselist++; 9621f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul } 9631f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul else { 9641f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul stereo_flag = GL_TRUE; 9651f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul } 966da2f1e88bc63403a95b89706905c070b7c894863Brian break; 967afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_AUX_BUFFERS: 968afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 969894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul numAux = *parselist++; 970894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul if (numAux > MAX_AUX_BUFFERS) 971894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul return NULL; 972afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 973afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_RED_SIZE: 974afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 975afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg min_red = *parselist++; 976afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 977afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_GREEN_SIZE: 978afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 979afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg min_green = *parselist++; 980afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 981afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_BLUE_SIZE: 982afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 983afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg min_blue = *parselist++; 984afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 985afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ALPHA_SIZE: 986afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 987afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg { 988afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLint size = *parselist++; 989c12ee99d119debe1a421a77c1cc6d99d958ae94bBrian Paul alpha_flag = size ? GL_TRUE : GL_FALSE; 990afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 991afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 992afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_DEPTH_SIZE: 993afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 994afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg depth_size = *parselist++; 995afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 996afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STENCIL_SIZE: 997afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 998afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg stencil_size = *parselist++; 999afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 1000afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_RED_SIZE: 1001b2e460018375f699198073a6167e0ee96ba1d267Brian Paul parselist++; 1002b2e460018375f699198073a6167e0ee96ba1d267Brian Paul { 1003b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint size = *parselist++; 1004b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumRedSize = MAX2( accumRedSize, size ); 1005b2e460018375f699198073a6167e0ee96ba1d267Brian Paul } 1006b2e460018375f699198073a6167e0ee96ba1d267Brian Paul break; 1007afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_GREEN_SIZE: 1008b2e460018375f699198073a6167e0ee96ba1d267Brian Paul parselist++; 1009b2e460018375f699198073a6167e0ee96ba1d267Brian Paul { 1010b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint size = *parselist++; 1011b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumGreenSize = MAX2( accumGreenSize, size ); 1012b2e460018375f699198073a6167e0ee96ba1d267Brian Paul } 1013b2e460018375f699198073a6167e0ee96ba1d267Brian Paul break; 1014afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_BLUE_SIZE: 1015b2e460018375f699198073a6167e0ee96ba1d267Brian Paul parselist++; 1016b2e460018375f699198073a6167e0ee96ba1d267Brian Paul { 1017b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint size = *parselist++; 1018b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumBlueSize = MAX2( accumBlueSize, size ); 1019b2e460018375f699198073a6167e0ee96ba1d267Brian Paul } 1020b2e460018375f699198073a6167e0ee96ba1d267Brian Paul break; 1021afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_ALPHA_SIZE: 1022afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1023afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg { 1024afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLint size = *parselist++; 1025b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumAlphaSize = MAX2( accumAlphaSize, size ); 1026afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1027afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 1028afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1029afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* 1030afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * GLX_EXT_visual_info extension 1031afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 1032afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_X_VISUAL_TYPE_EXT: 1033afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1034afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg visual_type = *parselist++; 1035afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 1036afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_TYPE_EXT: 1037afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1038afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg trans_type = *parselist++; 1039afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 1040afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_INDEX_VALUE_EXT: 1041afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1042afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg trans_value = *parselist++; 1043afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 1044afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_RED_VALUE_EXT: 1045afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_GREEN_VALUE_EXT: 1046afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_BLUE_VALUE_EXT: 1047afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_ALPHA_VALUE_EXT: 1048afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* ignore */ 1049afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1050afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1051afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 10525e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen 1053e1210b176926349b258c7ec77b7f36716025c82aBrian Paul /* 1054e1210b176926349b258c7ec77b7f36716025c82aBrian Paul * GLX_EXT_visual_info extension 1055e1210b176926349b258c7ec77b7f36716025c82aBrian Paul */ 1056e1210b176926349b258c7ec77b7f36716025c82aBrian Paul case GLX_VISUAL_CAVEAT_EXT: 1057e1210b176926349b258c7ec77b7f36716025c82aBrian Paul parselist++; 1058e1210b176926349b258c7ec77b7f36716025c82aBrian Paul caveat = *parselist++; /* ignored for now */ 1059e1210b176926349b258c7ec77b7f36716025c82aBrian Paul break; 1060e1210b176926349b258c7ec77b7f36716025c82aBrian Paul 10613265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul /* 106266ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul * GLX_ARB_multisample 106366ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul */ 106466ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul case GLX_SAMPLE_BUFFERS_ARB: 106566ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul case GLX_SAMPLES_ARB: 1066e903f51bc43fde1f61a779fd8017c96a651781acBrian Paul parselist++; 1067e903f51bc43fde1f61a779fd8017c96a651781acBrian Paul if (*parselist++ != 0) 1068e903f51bc43fde1f61a779fd8017c96a651781acBrian Paul /* ms not supported */ 1069e903f51bc43fde1f61a779fd8017c96a651781acBrian Paul return NULL; 1070e903f51bc43fde1f61a779fd8017c96a651781acBrian Paul break; 107166ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul 107266ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul /* 10733265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul * FBConfig attribs. 10743265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul */ 10753265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_RENDER_TYPE: 1076dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul if (!fbConfig) 1077dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul return NULL; 10783265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul parselist++; 1079584b0879ac2ec2420ea6866e47eb90e1a980e758Brian Paul if (*parselist & GLX_RGBA_BIT) { 10803265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul rgb_flag = GL_TRUE; 10813265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 1082584b0879ac2ec2420ea6866e47eb90e1a980e758Brian Paul else if (*parselist & GLX_COLOR_INDEX_BIT) { 10833265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul rgb_flag = GL_FALSE; 10843265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 10853265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul else if (*parselist == 0) { 10863265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul rgb_flag = GL_TRUE; 10873265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 10883265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul parselist++; 10893265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 10903265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_DRAWABLE_TYPE: 1091dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul if (!fbConfig) 1092dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul return NULL; 10933265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul parselist++; 10943265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (*parselist & ~(GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT)) { 10953265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return NULL; /* bad bit */ 10963265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 10973265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul parselist++; 10983265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 10993a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul case GLX_FBCONFIG_ID: 1100d60880db35fd11d9348ce4b2bfbcc9325d2ebf91Brian Paul case GLX_VISUAL_ID: 1101dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul if (!fbConfig) 1102dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul return NULL; 11033a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul parselist++; 1104dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul desiredVisualID = *parselist++; 1105dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul break; 1106dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul case GLX_X_RENDERABLE: 1107d60880db35fd11d9348ce4b2bfbcc9325d2ebf91Brian Paul case GLX_MAX_PBUFFER_WIDTH: 1108d60880db35fd11d9348ce4b2bfbcc9325d2ebf91Brian Paul case GLX_MAX_PBUFFER_HEIGHT: 1109d60880db35fd11d9348ce4b2bfbcc9325d2ebf91Brian Paul case GLX_MAX_PBUFFER_PIXELS: 1110dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul if (!fbConfig) 1111dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul return NULL; 1112dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul parselist += 2; 1113dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul /* ignore */ 11143a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul break; 11153265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul 1116fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian#ifdef GLX_EXT_texture_from_pixmap 1117fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_BIND_TO_TEXTURE_RGB_EXT: 1118fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian parselist++; /*skip*/ 1119fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 1120fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_BIND_TO_TEXTURE_RGBA_EXT: 1121fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian parselist++; /*skip*/ 1122fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 1123fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_BIND_TO_MIPMAP_TEXTURE_EXT: 1124fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian parselist++; /*skip*/ 1125fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 1126fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_BIND_TO_TEXTURE_TARGETS_EXT: 1127fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian parselist++; 1128fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (*parselist & ~(GLX_TEXTURE_1D_BIT_EXT | 1129fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian GLX_TEXTURE_2D_BIT_EXT | 1130fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian GLX_TEXTURE_RECTANGLE_BIT_EXT)) { 1131fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian /* invalid bit */ 1132fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian return NULL; 1133fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 1134fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 1135fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_Y_INVERTED_EXT: 1136fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian parselist++; /*skip*/ 1137fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 1138fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian#endif 1139fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian 1140afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case None: 11413a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul /* end of list */ 1142afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 11433265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul 1144afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: 1145afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* undefined attribute */ 11462ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul _mesa_warning(NULL, "unexpected attrib 0x%x in choose_visual()", 11472ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul *parselist); 1148afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 1149afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1150afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1151afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 115281fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick if (!rgb_flag) 115381fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick return NULL; 115481fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick 1155b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul (void) caveat; 1156b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul 1157afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* 1158afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Since we're only simulating the GLX extension this function will never 1159afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * find any real GL visuals. Instead, all we can do is try to find an RGB 1160afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * or CI visual of appropriate depth. Other requested attributes such as 1161afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * double buffering, depth buffer, etc. will be associated with the X 1162afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * visual and stored in the VisualTable[]. 1163afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 11643a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul if (desiredVisualID != -1) { 11653a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul /* try to get a specific visual, by visualID */ 11663a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul XVisualInfo temp; 11673a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul int n; 11683a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul temp.visualid = desiredVisualID; 11693a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul temp.screen = screen; 11703a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul vis = XGetVisualInfo(dpy, VisualIDMask | VisualScreenMask, &temp, &n); 11713a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul if (vis) { 11723a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul /* give the visual some useful GLX attributes */ 11733a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul double_flag = GL_TRUE; 117481fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick if (vis->depth <= 8) 117581fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick return NULL; 1176dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul depth_size = default_depth_bits(); 11773a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul stencil_size = STENCIL_BITS; 11783a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul /* XXX accum??? */ 11793a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul } 11803a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul } 1181afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 118281fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick /* RGB visual */ 118381fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick int min_rgb = min_red + min_green + min_blue; 118481fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick if (min_rgb>1 && min_rgb<8) { 118581fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick /* a special case to be sure we can get a monochrome visual */ 118681fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick min_rgb = 1; 118781fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick } 118881fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick 118981fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick if (level==0) { 119081fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick vis = choose_x_visual(dpy, screen, min_rgb, visual_type); 119142f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul } 119242f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul else { 119381fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick vis = choose_x_overlay_visual(dpy, screen, level, 119481fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick trans_type, trans_value, min_rgb, visual_type); 119542f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul } 1196afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1197afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1198afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 1199ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul /* Note: we're not exactly obeying the glXChooseVisual rules here. 1200ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * When GLX_DEPTH_SIZE = 1 is specified we're supposed to choose the 12012c7e6334ec81c2fab2cce9e0fe52cd30256e37eaBrian Paul * largest depth buffer size, which is 32bits/value. Instead, we 1202ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * return 16 to maintain performance with earlier versions of Mesa. 1203ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul */ 12042c7e6334ec81c2fab2cce9e0fe52cd30256e37eaBrian Paul if (depth_size > 24) 12059e4e3adcf82a72e9a74f21b492fbf5552ebfd47fBrian Paul depth_size = 32; 1206ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul else if (depth_size > 16) 1207ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul depth_size = 24; 1208dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul else if (depth_size > 0) { 1209dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul depth_size = default_depth_bits(); 1210dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul } 12112c7e6334ec81c2fab2cce9e0fe52cd30256e37eaBrian Paul 1212c12ee99d119debe1a421a77c1cc6d99d958ae94bBrian Paul if (!alpha_flag) { 1213c12ee99d119debe1a421a77c1cc6d99d958ae94bBrian Paul alpha_flag = default_alpha_bits() > 0; 1214c12ee99d119debe1a421a77c1cc6d99d958ae94bBrian Paul } 1215c12ee99d119debe1a421a77c1cc6d99d958ae94bBrian Paul 1216ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul /* we only support one size of stencil and accum buffers. */ 1217ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul if (stencil_size > 0) 1218ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul stencil_size = STENCIL_BITS; 12196d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul if (accumRedSize > 0 || accumGreenSize > 0 || accumBlueSize > 0 || 12206d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul accumAlphaSize > 0) { 1221978ef2bb6d9ca4996a24f95820a699e22c84f70bBrian Paul accumRedSize = 1222978ef2bb6d9ca4996a24f95820a699e22c84f70bBrian Paul accumGreenSize = 1223978ef2bb6d9ca4996a24f95820a699e22c84f70bBrian Paul accumBlueSize = default_accum_bits(); 1224978ef2bb6d9ca4996a24f95820a699e22c84f70bBrian Paul accumAlphaSize = alpha_flag ? accumRedSize : 0; 12256d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul } 12266d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul 122781fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick xmvis = save_glx_visual( dpy, vis, alpha_flag, double_flag, 12283265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul stereo_flag, depth_size, stencil_size, 12293265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul accumRedSize, accumGreenSize, 1230894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul accumBlueSize, accumAlphaSize, level, numAux ); 1231afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1232afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 12333265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return xmvis; 1234afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1235afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1236afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 12373265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paulstatic XVisualInfo * 12383265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian PaulFake_glXChooseVisual( Display *dpy, int screen, int *list ) 12393265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul{ 12406c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul XMesaVisual xmvis; 12416c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul 12426c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul /* register ourselves as an extension on this display */ 12436c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul register_with_display(dpy); 12446c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul 12456c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul xmvis = choose_visual(dpy, screen, list, GL_FALSE); 1246f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul if (xmvis) { 1247f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul#if 0 1248f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul return xmvis->vishandle; 1249f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul#else 1250f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul /* create a new vishandle - the cached one may be stale */ 125132f2fd1c5d6088692551c80352b7d6fa35b0cd09Kristian Høgsberg xmvis->vishandle = (XVisualInfo *) malloc(sizeof(XVisualInfo)); 1252f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul if (xmvis->vishandle) { 1253c7ac486261ad30ef654f6d0b1608da4e8483cd40Kenneth Graunke memcpy(xmvis->vishandle, xmvis->visinfo, sizeof(XVisualInfo)); 1254f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul } 12553265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return xmvis->vishandle; 1256f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul#endif 1257f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul } 12583265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul else 12593265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return NULL; 12603265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul} 1261afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1262afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 126349e80bf6b163310f7cd776261872201eea57053aBrian Paul/** 126449e80bf6b163310f7cd776261872201eea57053aBrian Paul * Init basic fields of a new fake_glx_context. 126549e80bf6b163310f7cd776261872201eea57053aBrian Paul */ 126649e80bf6b163310f7cd776261872201eea57053aBrian Paulstatic void 126749e80bf6b163310f7cd776261872201eea57053aBrian Paulinit_glx_context(struct fake_glx_context *glxCtx, Display *dpy) 126849e80bf6b163310f7cd776261872201eea57053aBrian Paul{ 1269c35a5aeb706d33b9c09b5a12bbbeae0f109885c9Brian Paul /* Always return True. See if anyone's confused... */ 1270c35a5aeb706d33b9c09b5a12bbbeae0f109885c9Brian Paul GLboolean direct = GL_TRUE; 1271c35a5aeb706d33b9c09b5a12bbbeae0f109885c9Brian Paul 127249e80bf6b163310f7cd776261872201eea57053aBrian Paul glxCtx->xmesaContext->direct = direct; 127349e80bf6b163310f7cd776261872201eea57053aBrian Paul glxCtx->glxContext.isDirect = direct; 127449e80bf6b163310f7cd776261872201eea57053aBrian Paul glxCtx->glxContext.currentDpy = dpy; 127549e80bf6b163310f7cd776261872201eea57053aBrian Paul glxCtx->glxContext.xid = (XID) glxCtx; /* self pointer */ 127649e80bf6b163310f7cd776261872201eea57053aBrian Paul 127749e80bf6b163310f7cd776261872201eea57053aBrian Paul assert((void *) glxCtx == (void *) &(glxCtx->glxContext)); 127849e80bf6b163310f7cd776261872201eea57053aBrian Paul} 127949e80bf6b163310f7cd776261872201eea57053aBrian Paul 128049e80bf6b163310f7cd776261872201eea57053aBrian Paul 128149e80bf6b163310f7cd776261872201eea57053aBrian Paul 1282426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXContext 1283426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateContext( Display *dpy, XVisualInfo *visinfo, 1284426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul GLXContext share_list, Bool direct ) 1285afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1286e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaVisual xmvis; 12877cf50e137da497a590ec9001a9918972a6246142Brian Paul struct fake_glx_context *glxCtx; 12885e1680ce1d8296b2182e8909856927bbeddf3b95Brian Paul struct fake_glx_context *shareCtx = (struct fake_glx_context *) share_list; 128999aab341998e84d9fa208c525cae8021b3845812Brian Paul 129099aab341998e84d9fa208c525cae8021b3845812Brian Paul if (!dpy || !visinfo) 129199aab341998e84d9fa208c525cae8021b3845812Brian Paul return 0; 129299aab341998e84d9fa208c525cae8021b3845812Brian Paul 12937cf50e137da497a590ec9001a9918972a6246142Brian Paul glxCtx = CALLOC_STRUCT(fake_glx_context); 12947cf50e137da497a590ec9001a9918972a6246142Brian Paul if (!glxCtx) 12957cf50e137da497a590ec9001a9918972a6246142Brian Paul return 0; 1296afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1297afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* deallocate unused windows/buffers */ 12986c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul#if 0 129990e227f0791cb585dc4e4e1f71e32c67f5e20436Andy Skinner XMesaGarbageCollect(dpy); 13006c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul#endif 1301afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1302e4656003caee346d9c4eb23256d73409271291a7Brian Paul xmvis = find_glx_visual( dpy, visinfo ); 1303e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (!xmvis) { 1304afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* This visual wasn't found with glXChooseVisual() */ 1305e4656003caee346d9c4eb23256d73409271291a7Brian Paul xmvis = create_glx_visual( dpy, visinfo ); 1306e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (!xmvis) { 1307afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* unusable visual */ 130832f2fd1c5d6088692551c80352b7d6fa35b0cd09Kristian Høgsberg free(glxCtx); 1309afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 1310afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1311afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1312afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1313e4656003caee346d9c4eb23256d73409271291a7Brian Paul glxCtx->xmesaContext = XMesaCreateContext(xmvis, 13145e1680ce1d8296b2182e8909856927bbeddf3b95Brian Paul shareCtx ? shareCtx->xmesaContext : NULL); 13157cf50e137da497a590ec9001a9918972a6246142Brian Paul if (!glxCtx->xmesaContext) { 131632f2fd1c5d6088692551c80352b7d6fa35b0cd09Kristian Høgsberg free(glxCtx); 13177cf50e137da497a590ec9001a9918972a6246142Brian Paul return NULL; 1318afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 13197cf50e137da497a590ec9001a9918972a6246142Brian Paul 132049e80bf6b163310f7cd776261872201eea57053aBrian Paul init_glx_context(glxCtx, dpy); 13217cf50e137da497a590ec9001a9918972a6246142Brian Paul 13227cf50e137da497a590ec9001a9918972a6246142Brian Paul return (GLXContext) glxCtx; 1323afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1324afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1325afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 13267cf50e137da497a590ec9001a9918972a6246142Brian Paul/* XXX these may have to be removed due to thread-safety issues. */ 1327afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic GLXContext MakeCurrent_PrevContext = 0; 1328086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic GLXDrawable MakeCurrent_PrevDrawable = 0; 1329086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic GLXDrawable MakeCurrent_PrevReadable = 0; 1330086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic XMesaBuffer MakeCurrent_PrevDrawBuffer = 0; 1331086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic XMesaBuffer MakeCurrent_PrevReadBuffer = 0; 1332afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 13337cf50e137da497a590ec9001a9918972a6246142Brian Paul 1334086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul/* GLX 1.3 and later */ 1335426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool 1336426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXMakeContextCurrent( Display *dpy, GLXDrawable draw, 13377a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell GLXDrawable read, GLXContext ctx ) 1338086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul{ 13397cf50e137da497a590ec9001a9918972a6246142Brian Paul struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx; 13407cf50e137da497a590ec9001a9918972a6246142Brian Paul 13417a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell if (ctx && draw && read) { 1342086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul XMesaBuffer drawBuffer, readBuffer; 13437cf50e137da497a590ec9001a9918972a6246142Brian Paul XMesaContext xmctx = glxCtx->xmesaContext; 1344086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul 1345086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* Find the XMesaBuffer which corresponds to the GLXDrawable 'draw' */ 13467a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell if (ctx == MakeCurrent_PrevContext 13477a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell && draw == MakeCurrent_PrevDrawable) { 1348086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul drawBuffer = MakeCurrent_PrevDrawBuffer; 1349086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1350086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul else { 1351086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul drawBuffer = XMesaFindBuffer( dpy, draw ); 1352086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1353086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul if (!drawBuffer) { 1354086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* drawable must be a new window! */ 13556aa5668871e7f366b33e85fabc72885fc269a7d4George Sapountzis drawBuffer = XMesaCreateWindowBuffer( xmctx->xm_visual, draw ); 1356086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul if (!drawBuffer) { 1357086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* Out of memory, or context/drawable depth mismatch */ 1358086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul return False; 1359086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1360086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1361086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul 1362086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* Find the XMesaBuffer which corresponds to the GLXDrawable 'read' */ 13637a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell if (ctx == MakeCurrent_PrevContext 1364086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul && read == MakeCurrent_PrevReadable) { 1365086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul readBuffer = MakeCurrent_PrevReadBuffer; 1366086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1367086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul else { 1368086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul readBuffer = XMesaFindBuffer( dpy, read ); 1369086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1370086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul if (!readBuffer) { 1371086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* drawable must be a new window! */ 13726aa5668871e7f366b33e85fabc72885fc269a7d4George Sapountzis readBuffer = XMesaCreateWindowBuffer( xmctx->xm_visual, read ); 1373086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul if (!readBuffer) { 1374086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* Out of memory, or context/drawable depth mismatch */ 1375086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul return False; 1376086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1377086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1378086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul 13797a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell MakeCurrent_PrevContext = ctx; 1380086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevDrawable = draw; 1381086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevReadable = read; 1382086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevDrawBuffer = drawBuffer; 1383086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevReadBuffer = readBuffer; 1384086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul 1385086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* Now make current! */ 13867cf50e137da497a590ec9001a9918972a6246142Brian Paul if (XMesaMakeCurrent2(xmctx, drawBuffer, readBuffer)) { 138712c1bee87fcc3a0912685bb6e83447972e5de64eBrian Paul ((__GLXcontext *) ctx)->currentDpy = dpy; 138812c1bee87fcc3a0912685bb6e83447972e5de64eBrian Paul ((__GLXcontext *) ctx)->currentDrawable = draw; 138912c1bee87fcc3a0912685bb6e83447972e5de64eBrian Paul ((__GLXcontext *) ctx)->currentReadable = read; 13907cf50e137da497a590ec9001a9918972a6246142Brian Paul return True; 13917cf50e137da497a590ec9001a9918972a6246142Brian Paul } 13927cf50e137da497a590ec9001a9918972a6246142Brian Paul else { 13937cf50e137da497a590ec9001a9918972a6246142Brian Paul return False; 13947cf50e137da497a590ec9001a9918972a6246142Brian Paul } 1395086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 13967a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell else if (!ctx && !draw && !read) { 1397086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* release current context w/out assigning new one. */ 1398086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul XMesaMakeCurrent( NULL, NULL ); 1399086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevContext = 0; 1400086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevDrawable = 0; 1401086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevReadable = 0; 1402086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevDrawBuffer = 0; 1403086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevReadBuffer = 0; 1404086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul return True; 1405086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1406086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul else { 1407086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* The args must either all be non-zero or all zero. 1408086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul * This is an error. 1409086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul */ 1410086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul return False; 1411086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1412086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul} 1413086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul 1414086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul 1415426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool 1416426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXMakeCurrent( Display *dpy, GLXDrawable drawable, GLXContext ctx ) 1417426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 1418426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul return Fake_glXMakeContextCurrent( dpy, drawable, drawable, ctx ); 1419426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1420426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1421426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1422426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPixmap 1423426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateGLXPixmap( Display *dpy, XVisualInfo *visinfo, Pixmap pixmap ) 1424afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1425afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaVisual v; 1426afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaBuffer b; 1427afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1428afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg v = find_glx_visual( dpy, visinfo ); 1429afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!v) { 1430afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg v = create_glx_visual( dpy, visinfo ); 1431afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!v) { 1432afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* unusable visual */ 1433afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1434afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1435afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1436afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1437afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg b = XMesaCreatePixmapBuffer( v, pixmap, 0 ); 1438afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!b) { 1439afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1440afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1441e4b2356c07d31fbeeabb13b2fb47db703b473080Brian Paul return b->frontxrb->pixmap; 1442afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1443afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1444afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1445b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_MESA_pixmap_colormap ***/ 1446b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul 1447426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPixmap 1448426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visinfo, 1449426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul Pixmap pixmap, Colormap cmap ) 1450afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1451afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaVisual v; 1452afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaBuffer b; 1453afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1454afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg v = find_glx_visual( dpy, visinfo ); 1455afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!v) { 1456afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg v = create_glx_visual( dpy, visinfo ); 1457afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!v) { 1458afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* unusable visual */ 1459afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1460afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1461afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1462afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1463afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg b = XMesaCreatePixmapBuffer( v, pixmap, cmap ); 1464afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!b) { 1465afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1466afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1467e4b2356c07d31fbeeabb13b2fb47db703b473080Brian Paul return b->frontxrb->pixmap; 1468afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1469afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1470afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1471426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1472426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyGLXPixmap( Display *dpy, GLXPixmap pixmap ) 1473afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1474afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaBuffer b = XMesaFindBuffer(dpy, pixmap); 1475afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (b) { 1476afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaDestroyBuffer(b); 1477afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1478367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul else if (_mesa_getenv("MESA_DEBUG")) { 1479d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul _mesa_warning(NULL, "Mesa: glXDestroyGLXPixmap: invalid pixmap\n"); 1480afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1481afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1482afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1483afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1484426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1485426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCopyContext( Display *dpy, GLXContext src, GLXContext dst, 14863994b77bab8c62a4c1a4dffdfba233ef46662b99Brian Paul unsigned long mask ) 1487afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 148883b820aa98931ef30fa73c72b2a96fe23885955eBrian Paul struct fake_glx_context *fakeSrc = (struct fake_glx_context *) src; 148983b820aa98931ef30fa73c72b2a96fe23885955eBrian Paul struct fake_glx_context *fakeDst = (struct fake_glx_context *) dst; 149083b820aa98931ef30fa73c72b2a96fe23885955eBrian Paul XMesaContext xm_src = fakeSrc->xmesaContext; 149183b820aa98931ef30fa73c72b2a96fe23885955eBrian Paul XMesaContext xm_dst = fakeDst->xmesaContext; 1492afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 149368edf28df68701ac429e53c0fd6dbb70b39c3fd0Brian Paul if (MakeCurrent_PrevContext == src) { 149468edf28df68701ac429e53c0fd6dbb70b39c3fd0Brian Paul _mesa_Flush(); 149568edf28df68701ac429e53c0fd6dbb70b39c3fd0Brian Paul } 14961e24d3318df57b36e3b68695ff64b4b8bd822c9eBrian Paul _mesa_copy_context( &(xm_src->mesa), &(xm_dst->mesa), (GLuint) mask ); 1497afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1498afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1499afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1500426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool 1501e3fff3daf031a997a1d4316e1a0e5c831573221dBrian PaulFake_glXQueryExtension( Display *dpy, int *errorBase, int *eventBase ) 1502afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 15039f002e4aaa2d7ea085cd0a3c66ff0fa533905382Brian Paul int op, ev, err; 1504afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Mesa's GLX isn't really an X extension but we try to act like one. */ 15059f002e4aaa2d7ea085cd0a3c66ff0fa533905382Brian Paul if (!XQueryExtension(dpy, GLX_EXTENSION_NAME, &op, &ev, &err)) 15069f002e4aaa2d7ea085cd0a3c66ff0fa533905382Brian Paul ev = err = 0; 1507e3fff3daf031a997a1d4316e1a0e5c831573221dBrian Paul if (errorBase) 15089f002e4aaa2d7ea085cd0a3c66ff0fa533905382Brian Paul *errorBase = err; 1509e3fff3daf031a997a1d4316e1a0e5c831573221dBrian Paul if (eventBase) 15109f002e4aaa2d7ea085cd0a3c66ff0fa533905382Brian Paul *eventBase = ev; 15119f002e4aaa2d7ea085cd0a3c66ff0fa533905382Brian Paul return True; /* we're faking GLX so always return success */ 1512afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1513afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1514afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1515e7b16b74bf5d13331b5a88bbbbb9096560297b63Brian Paulextern void _kw_ungrab_all( Display *dpy ); 1516afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgvoid _kw_ungrab_all( Display *dpy ) 1517afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1518afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XUngrabPointer( dpy, CurrentTime ); 1519afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XUngrabKeyboard( dpy, CurrentTime ); 1520afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1521afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1522afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1523426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1524426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyContext( Display *dpy, GLXContext ctx ) 1525afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 15267cf50e137da497a590ec9001a9918972a6246142Brian Paul struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx; 1527afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 1528afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg MakeCurrent_PrevContext = 0; 1529afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg MakeCurrent_PrevDrawable = 0; 1530086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevReadable = 0; 1531086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevDrawBuffer = 0; 1532086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevReadBuffer = 0; 15337cf50e137da497a590ec9001a9918972a6246142Brian Paul XMesaDestroyContext( glxCtx->xmesaContext ); 153490e227f0791cb585dc4e4e1f71e32c67f5e20436Andy Skinner XMesaGarbageCollect(dpy); 153532f2fd1c5d6088692551c80352b7d6fa35b0cd09Kristian Høgsberg free(glxCtx); 1536afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1537afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1538afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1539426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool 1540426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXIsDirect( Display *dpy, GLXContext ctx ) 1541afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 15427cf50e137da497a590ec9001a9918972a6246142Brian Paul struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx; 1543afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 15447cf50e137da497a590ec9001a9918972a6246142Brian Paul return glxCtx->xmesaContext->direct; 1545afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1546afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1547afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1548afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1549426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1550426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXSwapBuffers( Display *dpy, GLXDrawable drawable ) 1551afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1552afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaBuffer buffer = XMesaFindBuffer( dpy, drawable ); 1553afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1554afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (buffer) { 1555afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaSwapBuffers(buffer); 1556afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1557367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul else if (_mesa_getenv("MESA_DEBUG")) { 1558ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul _mesa_warning(NULL, "glXSwapBuffers: invalid drawable 0x%x\n", 1559ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul (int) drawable); 1560afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1561afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1562afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1563afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 15644c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul 1565b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_MESA_copy_sub_buffer ***/ 1566b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul 1567426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1568426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCopySubBufferMESA( Display *dpy, GLXDrawable drawable, 1569426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul int x, int y, int width, int height ) 1570afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1571afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaBuffer buffer = XMesaFindBuffer( dpy, drawable ); 1572afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (buffer) { 1573afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaCopySubBuffer(buffer, x, y, width, height); 1574afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1575367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul else if (_mesa_getenv("MESA_DEBUG")) { 1576d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul _mesa_warning(NULL, "Mesa: glXCopySubBufferMESA: invalid drawable\n"); 1577afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1578afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1579afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1580afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1581426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool 1582426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryVersion( Display *dpy, int *maj, int *min ) 1583afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1584afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 1585afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Return GLX version, not Mesa version */ 158678fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul assert(CLIENT_MAJOR_VERSION == SERVER_MAJOR_VERSION); 158778fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul *maj = CLIENT_MAJOR_VERSION; 158878fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul *min = MIN2( CLIENT_MINOR_VERSION, SERVER_MINOR_VERSION ); 1589afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return True; 1590afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1591afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1592afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1593afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 1594afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Query the GLX attributes of the given XVisualInfo. 1595afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 1596426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int 1597e4656003caee346d9c4eb23256d73409271291a7Brian Paulget_config( XMesaVisual xmvis, int attrib, int *value, GLboolean fbconfig ) 1598afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1599e4656003caee346d9c4eb23256d73409271291a7Brian Paul ASSERT(xmvis); 1600afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch(attrib) { 1601afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_USE_GL: 16021f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul if (fbconfig) 16031f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul return GLX_BAD_ATTRIBUTE; 1604afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = (int) True; 1605afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1606afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_BUFFER_SIZE: 1607e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->visinfo->depth; 1608afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1609afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_LEVEL: 1610304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick *value = xmvis->mesa_visual.level; 1611afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1612afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_RGBA: 16131f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul if (fbconfig) 16141f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul return GLX_BAD_ATTRIBUTE; 1615e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (xmvis->mesa_visual.rgbMode) { 1616afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = True; 1617afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1618afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 1619afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = False; 1620afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1621afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1622afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_DOUBLEBUFFER: 1623e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = (int) xmvis->mesa_visual.doubleBufferMode; 1624afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1625afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STEREO: 1626e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = (int) xmvis->mesa_visual.stereoMode; 1627afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1628afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_AUX_BUFFERS: 1629894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul *value = xmvis->mesa_visual.numAuxBuffers; 1630afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1631afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_RED_SIZE: 1632e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->mesa_visual.redBits; 1633afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1634afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_GREEN_SIZE: 1635e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->mesa_visual.greenBits; 1636afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1637afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_BLUE_SIZE: 1638e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->mesa_visual.blueBits; 1639afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1640afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ALPHA_SIZE: 1641e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->mesa_visual.alphaBits; 1642afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1643afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_DEPTH_SIZE: 1644e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->mesa_visual.depthBits; 1645afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1646afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STENCIL_SIZE: 1647e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->mesa_visual.stencilBits; 1648afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1649afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_RED_SIZE: 1650e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->mesa_visual.accumRedBits; 1651b2e460018375f699198073a6167e0ee96ba1d267Brian Paul return 0; 1652afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_GREEN_SIZE: 1653e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->mesa_visual.accumGreenBits; 1654b2e460018375f699198073a6167e0ee96ba1d267Brian Paul return 0; 1655afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_BLUE_SIZE: 1656e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->mesa_visual.accumBlueBits; 1657afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1658afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_ALPHA_SIZE: 1659e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->mesa_visual.accumAlphaBits; 1660afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1661afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1662afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* 1663afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * GLX_EXT_visual_info extension 1664afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 1665afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_X_VISUAL_TYPE_EXT: 1666e4656003caee346d9c4eb23256d73409271291a7Brian Paul switch (xmvis->visinfo->CLASS) { 1667afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case StaticGray: *value = GLX_STATIC_GRAY_EXT; return 0; 1668afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GrayScale: *value = GLX_GRAY_SCALE_EXT; return 0; 1669afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case StaticColor: *value = GLX_STATIC_GRAY_EXT; return 0; 1670afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case PseudoColor: *value = GLX_PSEUDO_COLOR_EXT; return 0; 1671afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case TrueColor: *value = GLX_TRUE_COLOR_EXT; return 0; 1672afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case DirectColor: *value = GLX_DIRECT_COLOR_EXT; return 0; 1673afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1674afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1675afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_TYPE_EXT: 1676304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick if (xmvis->mesa_visual.level==0) { 1677afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* normal planes */ 1678afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = GLX_NONE_EXT; 1679afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1680304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick else if (xmvis->mesa_visual.level>0) { 1681afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* overlay */ 1682e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (xmvis->mesa_visual.rgbMode) { 1683afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = GLX_TRANSPARENT_RGB_EXT; 1684afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1685afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 1686afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = GLX_TRANSPARENT_INDEX_EXT; 1687afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1688afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1689304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick else if (xmvis->mesa_visual.level<0) { 1690afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* underlay */ 1691afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = GLX_NONE_EXT; 1692afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1693afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1694afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_INDEX_VALUE_EXT: 1695afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg { 1696e4656003caee346d9c4eb23256d73409271291a7Brian Paul int pixel = transparent_pixel( xmvis ); 1697afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (pixel>=0) { 1698afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = pixel; 1699afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1700afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* else undefined */ 1701afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1702afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1703afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_RED_VALUE_EXT: 1704afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* undefined */ 1705afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1706afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_GREEN_VALUE_EXT: 1707afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* undefined */ 1708afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1709afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_BLUE_VALUE_EXT: 1710afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* undefined */ 1711afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1712afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_ALPHA_VALUE_EXT: 1713afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* undefined */ 1714afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1715afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1716afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* 1717b2e460018375f699198073a6167e0ee96ba1d267Brian Paul * GLX_EXT_visual_info extension 1718b2e460018375f699198073a6167e0ee96ba1d267Brian Paul */ 1719b2e460018375f699198073a6167e0ee96ba1d267Brian Paul case GLX_VISUAL_CAVEAT_EXT: 1720fc68be6b111473a0bf8f991468f973bb9dd275f4Brian Paul /* test for zero, just in case */ 1721304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick if (xmvis->mesa_visual.visualRating > 0) 1722304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick *value = xmvis->mesa_visual.visualRating; 1723962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul else 1724962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul *value = GLX_NONE_EXT; 1725962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul return 0; 1726b2e460018375f699198073a6167e0ee96ba1d267Brian Paul 1727b2e460018375f699198073a6167e0ee96ba1d267Brian Paul /* 172866ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul * GLX_ARB_multisample 1729afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 173066ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul case GLX_SAMPLE_BUFFERS_ARB: 17313265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul *value = 0; 17323265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return 0; 173366ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul case GLX_SAMPLES_ARB: 17343265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul *value = 0; 17353265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return 0; 17363265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul 17373265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul /* 17383265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul * For FBConfigs: 17393265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul */ 17403265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_SCREEN_EXT: 17413265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (!fbconfig) 17423265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return GLX_BAD_ATTRIBUTE; 1743e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->visinfo->screen; 17443265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 17453265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_DRAWABLE_TYPE: /*SGIX too */ 17463265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (!fbconfig) 17473265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return GLX_BAD_ATTRIBUTE; 17483265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul *value = GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT; 17493265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 17503265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_RENDER_TYPE_SGIX: 17513265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (!fbconfig) 17523265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return GLX_BAD_ATTRIBUTE; 1753e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (xmvis->mesa_visual.rgbMode) 17543265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul *value = GLX_RGBA_BIT; 17553265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul else 17563265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul *value = GLX_COLOR_INDEX_BIT; 17573265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 17583265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_X_RENDERABLE_SGIX: 17593265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (!fbconfig) 17603265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return GLX_BAD_ATTRIBUTE; 17613265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul *value = True; /* XXX really? */ 17623265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 17633265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_FBCONFIG_ID_SGIX: 17643265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (!fbconfig) 17653265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return GLX_BAD_ATTRIBUTE; 1766f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul *value = xmvis->visinfo->visualid; 17673265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 17683265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_MAX_PBUFFER_WIDTH: 17693265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (!fbconfig) 17703265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return GLX_BAD_ATTRIBUTE; 17713265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul /* XXX or MAX_WIDTH? */ 1772f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul *value = DisplayWidth(xmvis->display, xmvis->visinfo->screen); 17733265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 17743265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_MAX_PBUFFER_HEIGHT: 17753265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (!fbconfig) 17763265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return GLX_BAD_ATTRIBUTE; 1777f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul *value = DisplayHeight(xmvis->display, xmvis->visinfo->screen); 17783265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 17793265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_MAX_PBUFFER_PIXELS: 17803265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (!fbconfig) 17813265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return GLX_BAD_ATTRIBUTE; 1782f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul *value = DisplayWidth(xmvis->display, xmvis->visinfo->screen) * 1783f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul DisplayHeight(xmvis->display, xmvis->visinfo->screen); 17843265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 17853265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_VISUAL_ID: 17863265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (!fbconfig) 17873265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return GLX_BAD_ATTRIBUTE; 1788f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul *value = xmvis->visinfo->visualid; 17893265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 17903265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul 1791fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian#ifdef GLX_EXT_texture_from_pixmap 1792fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_BIND_TO_TEXTURE_RGB_EXT: 1793fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian *value = True; /*XXX*/ 1794fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 1795fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_BIND_TO_TEXTURE_RGBA_EXT: 1796fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian /* XXX review */ 1797fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian *value = xmvis->mesa_visual.alphaBits > 0 ? True : False; 1798fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 1799fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_BIND_TO_MIPMAP_TEXTURE_EXT: 1800fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian *value = True; /*XXX*/ 1801fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 1802fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_BIND_TO_TEXTURE_TARGETS_EXT: 1803fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian *value = (GLX_TEXTURE_1D_BIT_EXT | 1804fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian GLX_TEXTURE_2D_BIT_EXT | 1805fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian GLX_TEXTURE_RECTANGLE_BIT_EXT); /*XXX*/ 1806fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 1807fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_Y_INVERTED_EXT: 1808a10ba38df7ac80e36db15aaae9f78e7223b2bfaeBrian *value = True; /*XXX*/ 1809fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 1810fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian#endif 1811fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian 1812afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: 1813afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return GLX_BAD_ATTRIBUTE; 1814afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 18153265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return Success; 1816afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1817afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1818afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 18193265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paulstatic int 18203265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian PaulFake_glXGetConfig( Display *dpy, XVisualInfo *visinfo, 18213265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul int attrib, int *value ) 18223265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul{ 1823e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaVisual xmvis; 1824ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul int k; 1825379641956d134b8dc761b6411d7c4dca8f94a092Brian Paul if (!dpy || !visinfo) 1826a9a1c3f20f2d6aad4afc47cf2b29c5393fddb6b6Brian Paul return GLX_BAD_ATTRIBUTE; 1827a9a1c3f20f2d6aad4afc47cf2b29c5393fddb6b6Brian Paul 1828e4656003caee346d9c4eb23256d73409271291a7Brian Paul xmvis = find_glx_visual( dpy, visinfo ); 1829e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (!xmvis) { 18303265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul /* this visual wasn't obtained with glXChooseVisual */ 1831e4656003caee346d9c4eb23256d73409271291a7Brian Paul xmvis = create_glx_visual( dpy, visinfo ); 1832e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (!xmvis) { 18333265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul /* this visual can't be used for GL rendering */ 18343265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (attrib==GLX_USE_GL) { 18353265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul *value = (int) False; 18363265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return 0; 18373265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 18383265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul else { 18393265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return GLX_BAD_VISUAL; 18403265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 18413265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 18423265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 18433265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul 1844ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul k = get_config(xmvis, attrib, value, GL_FALSE); 1845ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul return k; 18463265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul} 18473265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul 1848afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1849426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1850426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXWaitGL( void ) 1851afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1852afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaContext xmesa = XMesaGetCurrentContext(); 1853afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaFlush( xmesa ); 1854afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1855afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1856afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1857afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1858426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1859426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXWaitX( void ) 1860afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1861afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaContext xmesa = XMesaGetCurrentContext(); 1862afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaFlush( xmesa ); 1863afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1864afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1865afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1866e4656003caee346d9c4eb23256d73409271291a7Brian Paulstatic const char * 1867e4656003caee346d9c4eb23256d73409271291a7Brian Paulget_extensions( void ) 186843c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul{ 1869e4656003caee346d9c4eb23256d73409271291a7Brian Paul return EXTENSIONS + 23; /* skip "GLX_MESA_set_3dfx_mode" */ 187043c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul} 1871afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1872afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1873afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1874afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* GLX 1.1 and later */ 1875426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic const char * 1876426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryExtensionsString( Display *dpy, int screen ) 1877afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1878afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 1879afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) screen; 188043c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul return get_extensions(); 1881afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1882afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1883afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1884afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1885afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* GLX 1.1 and later */ 1886426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic const char * 1887426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryServerString( Display *dpy, int screen, int name ) 1888afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 188978fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul static char version[1000]; 1890298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg sprintf(version, "%d.%d %s", 1891298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg SERVER_MAJOR_VERSION, SERVER_MINOR_VERSION, MESA_GLX_VERSION); 1892afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1893afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 1894afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) screen; 1895afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1896afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (name) { 1897afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_EXTENSIONS: 189843c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul return get_extensions(); 1899afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_VENDOR: 190078fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul return VENDOR; 1901afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_VERSION: 1902afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return version; 1903afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: 1904afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 1905afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1906afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1907afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1908afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1909afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1910afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* GLX 1.1 and later */ 1911426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic const char * 1912426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetClientString( Display *dpy, int name ) 1913afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 191478fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul static char version[1000]; 1915298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg sprintf(version, "%d.%d %s", CLIENT_MAJOR_VERSION, 1916298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg CLIENT_MINOR_VERSION, MESA_GLX_VERSION); 1917afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1918afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 1919afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1920afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (name) { 1921afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_EXTENSIONS: 192243c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul return get_extensions(); 1923afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_VENDOR: 192478fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul return VENDOR; 1925afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_VERSION: 1926afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return version; 1927afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: 1928afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 1929afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1930afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1931afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1932afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1933afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1934426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul/* 1935426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul * GLX 1.3 and later 1936426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul */ 1937426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 19387d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 1939426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int 1940426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetFBConfigAttrib( Display *dpy, GLXFBConfig config, 1941426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul int attribute, int *value ) 1942426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 19433265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul XMesaVisual v = (XMesaVisual) config; 1944426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 1945426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) config; 19467d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 19477d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul if (!dpy || !config || !value) 19487d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return -1; 19497d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 19503265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return get_config(v, attribute, value, GL_TRUE); 1951426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1952426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1953426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 19545605798e56ca6e9f968623f33b58ee7ca90594afBrian Paulstatic GLXFBConfig * 19555605798e56ca6e9f968623f33b58ee7ca90594afBrian PaulFake_glXGetFBConfigs( Display *dpy, int screen, int *nelements ) 19565605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul{ 19573265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul XVisualInfo *visuals, visTemplate; 19583265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul const long visMask = VisualScreenMask; 19593265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul int i; 19603265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul 19613265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul /* Get list of all X visuals */ 19623265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul visTemplate.screen = screen; 19633265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul visuals = XGetVisualInfo(dpy, visMask, &visTemplate, nelements); 19643265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (*nelements > 0) { 19653265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul XMesaVisual *results; 196632f2fd1c5d6088692551c80352b7d6fa35b0cd09Kristian Høgsberg results = (XMesaVisual *) malloc(*nelements * sizeof(XMesaVisual)); 19673265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (!results) { 19683265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul *nelements = 0; 19693265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return NULL; 19703265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 19713265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul for (i = 0; i < *nelements; i++) { 19723265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul results[i] = create_glx_visual(dpy, visuals + i); 19733265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 19743265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return (GLXFBConfig *) results; 19753265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 19763265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return NULL; 19775605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul} 19785605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul 19795605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul 1980481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paulstatic GLXFBConfig * 1981481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian PaulFake_glXChooseFBConfig( Display *dpy, int screen, 1982481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul const int *attribList, int *nitems ) 1983481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul{ 1984481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul XMesaVisual xmvis; 1985481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul 1986ecbdb173bbe3e37b4cbc6b08a5ba5a70236a0d1dBrian Paul /* register ourselves as an extension on this display */ 1987ecbdb173bbe3e37b4cbc6b08a5ba5a70236a0d1dBrian Paul register_with_display(dpy); 1988ecbdb173bbe3e37b4cbc6b08a5ba5a70236a0d1dBrian Paul 1989481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul if (!attribList || !attribList[0]) { 1990481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul /* return list of all configs (per GLX_SGIX_fbconfig spec) */ 1991481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul return Fake_glXGetFBConfigs(dpy, screen, nitems); 1992481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul } 1993481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul 1994481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul xmvis = choose_visual(dpy, screen, attribList, GL_TRUE); 1995481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul if (xmvis) { 199632f2fd1c5d6088692551c80352b7d6fa35b0cd09Kristian Høgsberg GLXFBConfig *config = (GLXFBConfig *) malloc(sizeof(XMesaVisual)); 1997481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul if (!config) { 1998481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul *nitems = 0; 1999481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul return NULL; 2000481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul } 2001481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul *nitems = 1; 2002481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul config[0] = (GLXFBConfig) xmvis; 2003481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul return (GLXFBConfig *) config; 2004481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul } 2005481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul else { 2006481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul *nitems = 0; 2007481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul return NULL; 2008481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul } 2009481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul} 2010481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul 2011481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul 2012426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic XVisualInfo * 2013426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetVisualFromFBConfig( Display *dpy, GLXFBConfig config ) 2014426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 20157d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul if (dpy && config) { 2016f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul XMesaVisual xmvis = (XMesaVisual) config; 2017f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul#if 0 2018f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul return xmvis->vishandle; 2019f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul#else 2020f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul /* create a new vishandle - the cached one may be stale */ 202132f2fd1c5d6088692551c80352b7d6fa35b0cd09Kristian Høgsberg xmvis->vishandle = (XVisualInfo *) malloc(sizeof(XVisualInfo)); 2022f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul if (xmvis->vishandle) { 2023c7ac486261ad30ef654f6d0b1608da4e8483cd40Kenneth Graunke memcpy(xmvis->vishandle, xmvis->visinfo, sizeof(XVisualInfo)); 2024f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul } 2025f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul return xmvis->vishandle; 2026f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul#endif 20277d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul } 20287d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul else { 20297d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return NULL; 20307d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul } 2031426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2032426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2033426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2034426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXWindow 2035426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateWindow( Display *dpy, GLXFBConfig config, Window win, 2036426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul const int *attribList ) 2037426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 2038529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul XMesaVisual xmvis = (XMesaVisual) config; 2039529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul XMesaBuffer xmbuf; 2040529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul if (!xmvis) 2041529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul return 0; 2042529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul 20436aa5668871e7f366b33e85fabc72885fc269a7d4George Sapountzis xmbuf = XMesaCreateWindowBuffer(xmvis, win); 2044529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul if (!xmbuf) 2045529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul return 0; 2046529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul 2047426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 20487d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul (void) attribList; /* Ignored in GLX 1.3 */ 20497d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 20507d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return win; /* A hack for now */ 2051426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2052426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2053426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2054426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 2055426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyWindow( Display *dpy, GLXWindow window ) 2056426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 20577d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul XMesaBuffer b = XMesaFindBuffer(dpy, (XMesaDrawable) window); 20587d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul if (b) 20597d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul XMesaDestroyBuffer(b); 20607d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul /* don't destroy X window */ 2061426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2062426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2063426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 20647d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul/* XXX untested */ 2065426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPixmap 2066426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreatePixmap( Display *dpy, GLXFBConfig config, Pixmap pixmap, 2067426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul const int *attribList ) 2068426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 20697d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul XMesaVisual v = (XMesaVisual) config; 20707d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul XMesaBuffer b; 2071fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian const int *attr; 2072fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian int target = 0, format = 0, mipmap = 0; 2073fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian int value; 20747d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 20757d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul if (!dpy || !config || !pixmap) 20767d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return 0; 20777d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 2078d18c57aaeac37cde0cb551191ecd3c3a56a0ffbaBrian Paul for (attr = attribList; attr && *attr; attr++) { 2079fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian switch (*attr) { 2080fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_TEXTURE_FORMAT_EXT: 2081fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian attr++; 2082fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian switch (*attr) { 2083fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_TEXTURE_FORMAT_NONE_EXT: 2084fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_TEXTURE_FORMAT_RGB_EXT: 2085fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_TEXTURE_FORMAT_RGBA_EXT: 2086fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian format = *attr; 2087fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 2088fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian default: 2089fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian /* error */ 2090fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian return 0; 2091fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2092fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 2093fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_TEXTURE_TARGET_EXT: 2094fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian attr++; 2095fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian switch (*attr) { 2096fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_TEXTURE_1D_EXT: 2097fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_TEXTURE_2D_EXT: 2098fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_TEXTURE_RECTANGLE_EXT: 2099fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian target = *attr; 2100fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 2101fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian default: 2102fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian /* error */ 2103fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian return 0; 2104fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2105fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 2106fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_MIPMAP_TEXTURE_EXT: 2107fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian attr++; 2108fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (*attr) 2109fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian mipmap = 1; 2110fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 2111fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian default: 2112fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian /* error */ 2113fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian return 0; 2114fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2115fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2116fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian 2117fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (format == GLX_TEXTURE_FORMAT_RGB_EXT) { 2118fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (get_config(v, GLX_BIND_TO_TEXTURE_RGB_EXT, 2119fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian &value, GL_TRUE) != Success 2120fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian || !value) { 2121fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian return 0; /* error! */ 2122fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2123fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2124fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian else if (format == GLX_TEXTURE_FORMAT_RGBA_EXT) { 2125fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (get_config(v, GLX_BIND_TO_TEXTURE_RGBA_EXT, 2126fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian &value, GL_TRUE) != Success 2127fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian || !value) { 2128fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian return 0; /* error! */ 2129fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2130fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2131fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (mipmap) { 2132fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (get_config(v, GLX_BIND_TO_MIPMAP_TEXTURE_EXT, 2133fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian &value, GL_TRUE) != Success 2134fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian || !value) { 2135fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian return 0; /* error! */ 2136fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2137fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2138fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (target == GLX_TEXTURE_1D_EXT) { 2139fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (get_config(v, GLX_BIND_TO_TEXTURE_TARGETS_EXT, 2140fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian &value, GL_TRUE) != Success 2141fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian || (value & GLX_TEXTURE_1D_BIT_EXT) == 0) { 2142fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian return 0; /* error! */ 2143fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2144fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2145fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian else if (target == GLX_TEXTURE_2D_EXT) { 2146fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (get_config(v, GLX_BIND_TO_TEXTURE_TARGETS_EXT, 2147fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian &value, GL_TRUE) != Success 2148fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian || (value & GLX_TEXTURE_2D_BIT_EXT) == 0) { 2149fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian return 0; /* error! */ 2150fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2151fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2152fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (target == GLX_TEXTURE_RECTANGLE_EXT) { 2153fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (get_config(v, GLX_BIND_TO_TEXTURE_TARGETS_EXT, 2154fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian &value, GL_TRUE) != Success 2155fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian || (value & GLX_TEXTURE_RECTANGLE_BIT_EXT) == 0) { 2156fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian return 0; /* error! */ 2157fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2158fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2159fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian 2160fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (format || target || mipmap) { 2161fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian /* texture from pixmap */ 2162fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian b = XMesaCreatePixmapTextureBuffer(v, pixmap, 0, format, target, mipmap); 2163fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2164fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian else { 2165fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian b = XMesaCreatePixmapBuffer( v, pixmap, 0 ); 2166fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 21677d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul if (!b) { 21687d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return 0; 21697d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul } 21707d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 21717d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return pixmap; 2172426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2173426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2174426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2175426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 2176426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyPixmap( Display *dpy, GLXPixmap pixmap ) 2177426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 21787d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul XMesaBuffer b = XMesaFindBuffer(dpy, (XMesaDrawable)pixmap); 21797d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul if (b) 21807d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul XMesaDestroyBuffer(b); 21817d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul /* don't destroy X pixmap */ 2182426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2183426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2184426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2185426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPbuffer 2186426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreatePbuffer( Display *dpy, GLXFBConfig config, 2187426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul const int *attribList ) 2188426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 21893265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul XMesaVisual xmvis = (XMesaVisual) config; 21903265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul XMesaBuffer xmbuf; 21917d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul const int *attrib; 21927d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul int width = 0, height = 0; 21937d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul GLboolean useLargest = GL_FALSE, preserveContents = GL_FALSE; 21947d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 2195426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 21967d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 21973265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul for (attrib = attribList; *attrib; attrib++) { 21987d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul switch (*attrib) { 21997d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_PBUFFER_WIDTH: 22003265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul attrib++; 22013265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul width = *attrib; 22027d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul break; 22037d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_PBUFFER_HEIGHT: 22043265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul attrib++; 22053265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul height = *attrib; 22067d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul break; 22077d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_PRESERVED_CONTENTS: 22083265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul attrib++; 2209c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul preserveContents = *attrib; 22107d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul break; 22117d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_LARGEST_PBUFFER: 22123265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul attrib++; 2213c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul useLargest = *attrib; 22147d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul break; 22157d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul default: 22167d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return 0; 22177d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul } 22187d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul } 22197d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 22207d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul if (width == 0 || height == 0) 22217d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return 0; 22227d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 22233f8a61ffa256b4fe36e93a0904b8893c805eb313Brian Paul if (width > SWRAST_MAX_WIDTH || height > SWRAST_MAX_HEIGHT) { 2224c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul /* If allocation would have failed and GLX_LARGEST_PBUFFER is set, 2225c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul * allocate the largest possible buffer. 2226c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul */ 2227c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul if (useLargest) { 22283f8a61ffa256b4fe36e93a0904b8893c805eb313Brian Paul width = SWRAST_MAX_WIDTH; 22293f8a61ffa256b4fe36e93a0904b8893c805eb313Brian Paul height = SWRAST_MAX_HEIGHT; 2230c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul } 2231c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul } 2232c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul 22333265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul xmbuf = XMesaCreatePBuffer( xmvis, 0, width, height); 2234e4656003caee346d9c4eb23256d73409271291a7Brian Paul /* A GLXPbuffer handle must be an X Drawable because that's what 2235e4656003caee346d9c4eb23256d73409271291a7Brian Paul * glXMakeCurrent takes. 2236e4656003caee346d9c4eb23256d73409271291a7Brian Paul */ 2237c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul if (xmbuf) { 2238c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul xmbuf->largestPbuffer = useLargest; 2239c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul xmbuf->preservedContents = preserveContents; 2240dd1a9f75dc1d29e3383f27aaa1cf024c83e5c8e2Brian Paul return (GLXPbuffer) xmbuf->frontxrb->pixmap; 2241c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul } 2242c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul else { 2243dd1a9f75dc1d29e3383f27aaa1cf024c83e5c8e2Brian Paul return 0; 2244c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul } 2245426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2246426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2247426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2248426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 2249426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyPbuffer( Display *dpy, GLXPbuffer pbuf ) 2250426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 2251e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaBuffer b = XMesaFindBuffer(dpy, pbuf); 2252e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (b) { 2253e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaDestroyBuffer(b); 2254e4656003caee346d9c4eb23256d73409271291a7Brian Paul } 2255426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2256426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2257426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2258426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 2259426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryDrawable( Display *dpy, GLXDrawable draw, int attribute, 2260426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul unsigned int *value ) 2261426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 2262e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaBuffer xmbuf = XMesaFindBuffer(dpy, draw); 2263e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (!xmbuf) 2264e4656003caee346d9c4eb23256d73409271291a7Brian Paul return; 22657d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 2266c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul /* make sure buffer's dimensions are up to date */ 2267c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul xmesa_check_and_update_buffer_size(NULL, xmbuf); 2268c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul 22697d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul switch (attribute) { 22707d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_WIDTH: 227129926a11b16ec7a235947d95e9a46777605dd30eBrian Paul *value = xmbuf->mesa_buffer.Width; 2272e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 22737d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_HEIGHT: 227429926a11b16ec7a235947d95e9a46777605dd30eBrian Paul *value = xmbuf->mesa_buffer.Height; 2275e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 22767d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_PRESERVED_CONTENTS: 2277c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul *value = xmbuf->preservedContents; 2278e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 22797d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_LARGEST_PBUFFER: 2280c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul *value = xmbuf->largestPbuffer; 2281e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 22827d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_FBCONFIG_ID: 2283f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul *value = xmbuf->xm_visual->visinfo->visualid; 22847d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return; 2285fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian#ifdef GLX_EXT_texture_from_pixmap 2286fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_TEXTURE_FORMAT_EXT: 2287fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian *value = xmbuf->TextureFormat; 2288fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 2289fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_TEXTURE_TARGET_EXT: 2290fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian *value = xmbuf->TextureTarget; 2291fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 2292fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_MIPMAP_TEXTURE_EXT: 2293fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian *value = xmbuf->TextureMipmap; 2294fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 2295fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian#endif 2296fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian 22977d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul default: 2298fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian return; /* raise BadValue error */ 22997d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul } 2300426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2301426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2302426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2303426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXContext 2304426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateNewContext( Display *dpy, GLXFBConfig config, 2305426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul int renderType, GLXContext shareList, Bool direct ) 2306426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 2307f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul struct fake_glx_context *glxCtx; 2308f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul struct fake_glx_context *shareCtx = (struct fake_glx_context *) shareList; 2309f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul XMesaVisual xmvis = (XMesaVisual) config; 23107d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 23117d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul if (!dpy || !config || 23127d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul (renderType != GLX_RGBA_TYPE && renderType != GLX_COLOR_INDEX_TYPE)) 23137d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return 0; 23147d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 2315f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul glxCtx = CALLOC_STRUCT(fake_glx_context); 2316f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul if (!glxCtx) 2317f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul return 0; 2318f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul 2319f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul /* deallocate unused windows/buffers */ 232090e227f0791cb585dc4e4e1f71e32c67f5e20436Andy Skinner XMesaGarbageCollect(dpy); 2321f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul 2322f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul glxCtx->xmesaContext = XMesaCreateContext(xmvis, 2323f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul shareCtx ? shareCtx->xmesaContext : NULL); 2324f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul if (!glxCtx->xmesaContext) { 232532f2fd1c5d6088692551c80352b7d6fa35b0cd09Kristian Høgsberg free(glxCtx); 2326f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul return NULL; 2327f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul } 2328f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul 232949e80bf6b163310f7cd776261872201eea57053aBrian Paul init_glx_context(glxCtx, dpy); 2330f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul 2331f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul return (GLXContext) glxCtx; 2332426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2333426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2334426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2335426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int 2336426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryContext( Display *dpy, GLXContext ctx, int attribute, int *value ) 2337426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 2338e4656003caee346d9c4eb23256d73409271291a7Brian Paul struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx; 2339e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaContext xmctx = glxCtx->xmesaContext; 2340e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2341426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 2342426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) ctx; 23437d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 23447d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul switch (attribute) { 23457d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_FBCONFIG_ID: 2346f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul *value = xmctx->xm_visual->visinfo->visualid; 2347e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 23487d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_RENDER_TYPE: 234981fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick *value = GLX_RGBA_TYPE; 2350e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 23517d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_SCREEN: 23527d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul *value = 0; 23537d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return Success; 23547d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul default: 23557d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return GLX_BAD_ATTRIBUTE; 23567d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul } 2357e4656003caee346d9c4eb23256d73409271291a7Brian Paul return 0; 2358426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2359426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2360426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2361426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 2362426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXSelectEvent( Display *dpy, GLXDrawable drawable, unsigned long mask ) 2363426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 2364e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable); 2365e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (xmbuf) 2366e4656003caee346d9c4eb23256d73409271291a7Brian Paul xmbuf->selectedEvents = mask; 2367426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2368426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2369426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2370426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 2371426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetSelectedEvent( Display *dpy, GLXDrawable drawable, 2372426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul unsigned long *mask ) 2373426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 2374e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable); 2375e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (xmbuf) 2376e4656003caee346d9c4eb23256d73409271291a7Brian Paul *mask = xmbuf->selectedEvents; 2377e4656003caee346d9c4eb23256d73409271291a7Brian Paul else 2378e4656003caee346d9c4eb23256d73409271291a7Brian Paul *mask = 0; 2379426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2380b82d993b03320818f88f792a9e713f7ed491bfcbBrian Paul 2381b82d993b03320818f88f792a9e713f7ed491bfcbBrian Paul 2382b82d993b03320818f88f792a9e713f7ed491bfcbBrian Paul 2383b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGI_swap_control ***/ 2384783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2385783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int 2386783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXSwapIntervalSGI(int interval) 2387783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2388783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) interval; 2389783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2390783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2391783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2392783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2393783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2394b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGI_video_sync ***/ 2395783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2396ee061060826df059f0ddb904a2160ed610423579Brian Paulstatic unsigned int FrameCounter = 0; 2397ee061060826df059f0ddb904a2160ed610423579Brian Paul 2398783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int 2399783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetVideoSyncSGI(unsigned int *count) 2400783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2401ee061060826df059f0ddb904a2160ed610423579Brian Paul /* this is a bogus implementation */ 2402ee061060826df059f0ddb904a2160ed610423579Brian Paul *count = FrameCounter++; 2403783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2404783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2405783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2406783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int 2407783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count) 2408783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2409ee061060826df059f0ddb904a2160ed610423579Brian Paul if (divisor <= 0 || remainder < 0) 2410ee061060826df059f0ddb904a2160ed610423579Brian Paul return GLX_BAD_VALUE; 2411ee061060826df059f0ddb904a2160ed610423579Brian Paul /* this is a bogus implementation */ 2412ee061060826df059f0ddb904a2160ed610423579Brian Paul FrameCounter++; 2413ee061060826df059f0ddb904a2160ed610423579Brian Paul while (FrameCounter % divisor != remainder) 2414ee061060826df059f0ddb904a2160ed610423579Brian Paul FrameCounter++; 2415ee061060826df059f0ddb904a2160ed610423579Brian Paul *count = FrameCounter; 2416783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2417783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2418783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2419783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2420783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2421b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGI_make_current_read ***/ 2422783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2423426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool 2424783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXMakeCurrentReadSGI(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx) 2425afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 2426a078d75a27b99252ede6520e24b145106ab98aa2Brian Paul return Fake_glXMakeContextCurrent( dpy, draw, read, ctx ); 2427afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 2428783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 24297cf50e137da497a590ec9001a9918972a6246142Brian Paul/* not used 2430783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXDrawable 2431b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian PaulFake_glXGetCurrentReadDrawableSGI(void) 2432783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2433783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2434783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 24357cf50e137da497a590ec9001a9918972a6246142Brian Paul*/ 2436afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 2437afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 2438b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_video_source ***/ 2439b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#if defined(_VL_H) 24404c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul 2441783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXVideoSourceSGIX 2442783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXCreateGLXVideoSourceSGIX(Display *dpy, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode) 2443afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 2444783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2445783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) screen; 2446783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) server; 2447783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) path; 2448783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) nodeClass; 2449783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) drainNode; 2450783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2451783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2452783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2453783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void 2454783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXDestroyGLXVideoSourceSGIX(Display *dpy, GLXVideoSourceSGIX src) 2455783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2456783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2457783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) src; 2458afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 2459783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 24604c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul#endif 24614c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul 246289a42b7e736bd9b0ab090906cab0cd047a6ec12eBrian Paul 2463b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_EXT_import_context ***/ 246489a42b7e736bd9b0ab090906cab0cd047a6ec12eBrian Paul 2465783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void 2466783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXFreeContextEXT(Display *dpy, GLXContext context) 2467783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2468783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2469783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) context; 2470783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2471426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2472783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXContextID 2473783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetContextIDEXT(const GLXContext context) 2474783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2475783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) context; 2476783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2477783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2478783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2479783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXContext 2480783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXImportContextEXT(Display *dpy, GLXContextID contextID) 2481783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2482783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2483783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) contextID; 2484783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2485783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2486426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2487426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int 2488783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryContextInfoEXT(Display *dpy, GLXContext context, int attribute, int *value) 2489426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 2490783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2491783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) context; 2492783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) attribute; 2493783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) value; 2494426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul return 0; 2495426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2496426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2497783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2498783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2499b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_fbconfig ***/ 2500426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2501426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int 2502783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetFBConfigAttribSGIX(Display *dpy, GLXFBConfigSGIX config, int attribute, int *value) 2503783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 25043265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return Fake_glXGetFBConfigAttrib(dpy, config, attribute, value); 2505783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2506783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2507783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXFBConfigSGIX * 2508783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXChooseFBConfigSGIX(Display *dpy, int screen, int *attrib_list, int *nelements) 2509783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 25103265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return (GLXFBConfig *) Fake_glXChooseFBConfig(dpy, screen, attrib_list, nelements); 2511783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2512783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2513e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2514783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXPixmap 2515783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXCreateGLXPixmapWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap) 2516783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2517e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaVisual xmvis = (XMesaVisual) config; 2518e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaBuffer xmbuf = XMesaCreatePixmapBuffer(xmvis, pixmap, 0); 2519e4b2356c07d31fbeeabb13b2fb47db703b473080Brian Paul return xmbuf->frontxrb->pixmap; /* need to return an X ID */ 2520783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2521783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2522e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2523783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXContext 2524783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct) 2525783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2526e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaVisual xmvis = (XMesaVisual) config; 2527e4656003caee346d9c4eb23256d73409271291a7Brian Paul struct fake_glx_context *glxCtx; 2528e4656003caee346d9c4eb23256d73409271291a7Brian Paul struct fake_glx_context *shareCtx = (struct fake_glx_context *) share_list; 2529e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2530e4656003caee346d9c4eb23256d73409271291a7Brian Paul glxCtx = CALLOC_STRUCT(fake_glx_context); 2531e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (!glxCtx) 2532e4656003caee346d9c4eb23256d73409271291a7Brian Paul return 0; 2533e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2534e4656003caee346d9c4eb23256d73409271291a7Brian Paul /* deallocate unused windows/buffers */ 253590e227f0791cb585dc4e4e1f71e32c67f5e20436Andy Skinner XMesaGarbageCollect(dpy); 2536e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2537e4656003caee346d9c4eb23256d73409271291a7Brian Paul glxCtx->xmesaContext = XMesaCreateContext(xmvis, 2538e4656003caee346d9c4eb23256d73409271291a7Brian Paul shareCtx ? shareCtx->xmesaContext : NULL); 2539e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (!glxCtx->xmesaContext) { 254032f2fd1c5d6088692551c80352b7d6fa35b0cd09Kristian Høgsberg free(glxCtx); 2541e4656003caee346d9c4eb23256d73409271291a7Brian Paul return NULL; 2542e4656003caee346d9c4eb23256d73409271291a7Brian Paul } 2543e4656003caee346d9c4eb23256d73409271291a7Brian Paul 254449e80bf6b163310f7cd776261872201eea57053aBrian Paul init_glx_context(glxCtx, dpy); 2545e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2546e4656003caee346d9c4eb23256d73409271291a7Brian Paul return (GLXContext) glxCtx; 2547783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2548783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2549e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2550783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic XVisualInfo * 2551783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetVisualFromFBConfigSGIX(Display *dpy, GLXFBConfigSGIX config) 2552783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 25533265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return Fake_glXGetVisualFromFBConfig(dpy, config); 2554783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2555783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2556e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2557783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXFBConfigSGIX 2558783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetFBConfigFromVisualSGIX(Display *dpy, XVisualInfo *vis) 2559426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 2560e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaVisual xmvis = find_glx_visual(dpy, vis); 2561e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (!xmvis) { 2562e4656003caee346d9c4eb23256d73409271291a7Brian Paul /* This visual wasn't found with glXChooseVisual() */ 2563e4656003caee346d9c4eb23256d73409271291a7Brian Paul xmvis = create_glx_visual(dpy, vis); 2564e4656003caee346d9c4eb23256d73409271291a7Brian Paul } 2565e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2566e4656003caee346d9c4eb23256d73409271291a7Brian Paul return (GLXFBConfigSGIX) xmvis; 2567426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2568426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2569426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2570426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2571b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_pbuffer ***/ 2572783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2573783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXPbufferSGIX 25743265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian PaulFake_glXCreateGLXPbufferSGIX(Display *dpy, GLXFBConfigSGIX config, 25753265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul unsigned int width, unsigned int height, 25763265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul int *attribList) 2577783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 25783265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul XMesaVisual xmvis = (XMesaVisual) config; 25793265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul XMesaBuffer xmbuf; 25803265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul const int *attrib; 25813265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul GLboolean useLargest = GL_FALSE, preserveContents = GL_FALSE; 25823265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul 2583783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 25843265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul 258511b3028e7ba2fc3b985ab84d7227c290608f83f6Brian Paul for (attrib = attribList; attrib && *attrib; attrib++) { 25863265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul switch (*attrib) { 25873265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_PRESERVED_CONTENTS_SGIX: 25883265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul attrib++; 25893265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul preserveContents = *attrib; /* ignored */ 25903265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 25913265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_LARGEST_PBUFFER_SGIX: 25923265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul attrib++; 25933265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul useLargest = *attrib; /* ignored */ 25943265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 25953265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul default: 25963265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return 0; 25973265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 25983265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 25993265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul 2600b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul /* not used at this time */ 2601b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul (void) useLargest; 2602b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul (void) preserveContents; 2603b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul 26043265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul xmbuf = XMesaCreatePBuffer( xmvis, 0, width, height); 2605e4656003caee346d9c4eb23256d73409271291a7Brian Paul /* A GLXPbuffer handle must be an X Drawable because that's what 2606e4656003caee346d9c4eb23256d73409271291a7Brian Paul * glXMakeCurrent takes. 2607e4656003caee346d9c4eb23256d73409271291a7Brian Paul */ 2608e4b2356c07d31fbeeabb13b2fb47db703b473080Brian Paul return (GLXPbuffer) xmbuf->frontxrb->pixmap; 2609783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2610783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2611e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2612783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void 2613783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXDestroyGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf) 2614783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2615e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaBuffer xmbuf = XMesaFindBuffer(dpy, pbuf); 2616e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (xmbuf) { 2617e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaDestroyBuffer(xmbuf); 2618e4656003caee346d9c4eb23256d73409271291a7Brian Paul } 2619783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2620783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2621e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2622783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int 2623783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value) 2624783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2625e4656003caee346d9c4eb23256d73409271291a7Brian Paul const XMesaBuffer xmbuf = XMesaFindBuffer(dpy, pbuf); 2626e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2627e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (!xmbuf) { 2628e4656003caee346d9c4eb23256d73409271291a7Brian Paul /* Generate GLXBadPbufferSGIX for bad pbuffer */ 2629e4656003caee346d9c4eb23256d73409271291a7Brian Paul return 0; 2630e4656003caee346d9c4eb23256d73409271291a7Brian Paul } 2631e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2632e4656003caee346d9c4eb23256d73409271291a7Brian Paul switch (attribute) { 2633e4656003caee346d9c4eb23256d73409271291a7Brian Paul case GLX_PRESERVED_CONTENTS_SGIX: 2634c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul *value = xmbuf->preservedContents; 2635e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 2636e4656003caee346d9c4eb23256d73409271291a7Brian Paul case GLX_LARGEST_PBUFFER_SGIX: 2637c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul *value = xmbuf->largestPbuffer; 2638e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 2639e4656003caee346d9c4eb23256d73409271291a7Brian Paul case GLX_WIDTH_SGIX: 264029926a11b16ec7a235947d95e9a46777605dd30eBrian Paul *value = xmbuf->mesa_buffer.Width; 2641e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 2642e4656003caee346d9c4eb23256d73409271291a7Brian Paul case GLX_HEIGHT_SGIX: 264329926a11b16ec7a235947d95e9a46777605dd30eBrian Paul *value = xmbuf->mesa_buffer.Height; 2644e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 2645e4656003caee346d9c4eb23256d73409271291a7Brian Paul case GLX_EVENT_MASK_SGIX: 2646e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = 0; /* XXX might be wrong */ 2647e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 2648e4656003caee346d9c4eb23256d73409271291a7Brian Paul default: 2649e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = 0; 2650e4656003caee346d9c4eb23256d73409271291a7Brian Paul } 2651783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2652783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2653783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2654e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2655783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void 2656783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXSelectEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long mask) 2657783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2658e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable); 2659e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (xmbuf) { 2660e4656003caee346d9c4eb23256d73409271291a7Brian Paul /* Note: we'll never generate clobber events */ 2661e4656003caee346d9c4eb23256d73409271291a7Brian Paul xmbuf->selectedEvents = mask; 2662e4656003caee346d9c4eb23256d73409271291a7Brian Paul } 2663783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2664783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2665e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2666783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void 2667783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetSelectedEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long *mask) 2668783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2669e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable); 2670e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (xmbuf) { 2671e4656003caee346d9c4eb23256d73409271291a7Brian Paul *mask = xmbuf->selectedEvents; 2672e4656003caee346d9c4eb23256d73409271291a7Brian Paul } 2673e4656003caee346d9c4eb23256d73409271291a7Brian Paul else { 2674e4656003caee346d9c4eb23256d73409271291a7Brian Paul *mask = 0; 2675e4656003caee346d9c4eb23256d73409271291a7Brian Paul } 2676783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2677783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2678783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2679783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2680b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGI_cushion ***/ 2681783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2682783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void 2683783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXCushionSGI(Display *dpy, Window win, float cushion) 2684783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2685783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2686783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) win; 2687783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) cushion; 2688783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2689783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2690783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2691783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2692b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_video_resize ***/ 2693783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2694783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int 2695783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXBindChannelToWindowSGIX(Display *dpy, int screen, int channel , Window window) 2696783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2697783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2698783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) screen; 2699783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) channel; 2700783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) window; 2701783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2702783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2703783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2704783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int 2705783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXChannelRectSGIX(Display *dpy, int screen, int channel, int x, int y, int w, int h) 2706783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2707783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2708783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) screen; 2709783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) channel; 2710783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) x; 2711783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) y; 2712783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) w; 2713783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) h; 2714783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2715783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2716783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2717783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int 2718783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryChannelRectSGIX(Display *dpy, int screen, int channel, int *x, int *y, int *w, int *h) 2719783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2720783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2721783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) screen; 2722783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) channel; 2723783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) x; 2724783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) y; 2725783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) w; 2726783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) h; 2727783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2728783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2729783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2730783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int 2731783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryChannelDeltasSGIX(Display *dpy, int screen, int channel, int *dx, int *dy, int *dw, int *dh) 2732783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2733783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2734783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) screen; 2735783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) channel; 2736783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dx; 2737783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dy; 2738783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dw; 2739783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dh; 2740783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2741783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2742783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2743783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int 2744783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXChannelRectSyncSGIX(Display *dpy, int screen, int channel, GLenum synctype) 2745783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2746783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2747783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) screen; 2748783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) channel; 2749783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) synctype; 2750783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2751783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2752783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2753783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2754783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2755b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_dmbuffer **/ 2756783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2757b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#if defined(_DM_BUFFER_H_) 2758783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Bool 2759783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXAssociateDMPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer) 2760783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2761783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2762783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) pbuffer; 2763783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) params; 2764783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dmbuffer; 2765783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return False; 2766783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2767783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul#endif 2768783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2769783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2770b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_swap_group ***/ 2771783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2772783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void 2773783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXJoinSwapGroupSGIX(Display *dpy, GLXDrawable drawable, GLXDrawable member) 2774783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2775783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2776783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) drawable; 2777783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) member; 2778783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2779783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2780783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2781783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2782b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_swap_barrier ***/ 2783783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2784783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void 2785783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXBindSwapBarrierSGIX(Display *dpy, GLXDrawable drawable, int barrier) 2786783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2787783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2788783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) drawable; 2789783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) barrier; 2790783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2791783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2792783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Bool 2793783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryMaxSwapBarriersSGIX(Display *dpy, int screen, int *max) 2794783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2795783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2796783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) screen; 2797783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) max; 2798783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return False; 2799783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2800783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2801783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2802783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2803b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SUN_get_transparent_index ***/ 2804783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2805783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Status 2806783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetTransparentIndexSUN(Display *dpy, Window overlay, Window underlay, long *pTransparent) 2807783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2808783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2809783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) overlay; 2810783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) underlay; 2811783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) pTransparent; 2812783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2813783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2814783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2815783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2816783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2817b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_MESA_release_buffers ***/ 2818b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul 2819783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul/* 2820783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul * Release the depth, stencil, accum buffers attached to a GLXDrawable 2821783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul * (a window or pixmap) prior to destroying the GLXDrawable. 2822783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul */ 2823783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Bool 2824783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXReleaseBuffersMESA( Display *dpy, GLXDrawable d ) 2825783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2826783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul XMesaBuffer b = XMesaFindBuffer(dpy, d); 2827783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul if (b) { 2828783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul XMesaDestroyBuffer(b); 2829783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return True; 2830783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul } 2831783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return False; 2832783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2833783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2834783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2835783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2836b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_MESA_set_3dfx_mode ***/ 2837b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul 2838783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Bool 2839783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXSet3DfxModeMESA( int mode ) 2840783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2841783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return XMesaSetFXmode( mode ); 2842783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2843783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2844783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2845783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 28463c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian Paul/*** GLX_NV_vertex_array range ***/ 28478fefafa2200d3ea44ec46592b190654a10685b46Brian Paulstatic void * 28488fefafa2200d3ea44ec46592b190654a10685b46Brian PaulFake_glXAllocateMemoryNV( GLsizei size, 28498fefafa2200d3ea44ec46592b190654a10685b46Brian Paul GLfloat readFrequency, 28508fefafa2200d3ea44ec46592b190654a10685b46Brian Paul GLfloat writeFrequency, 28518fefafa2200d3ea44ec46592b190654a10685b46Brian Paul GLfloat priority ) 28528fefafa2200d3ea44ec46592b190654a10685b46Brian Paul{ 28538fefafa2200d3ea44ec46592b190654a10685b46Brian Paul (void) size; 28548fefafa2200d3ea44ec46592b190654a10685b46Brian Paul (void) readFrequency; 28558fefafa2200d3ea44ec46592b190654a10685b46Brian Paul (void) writeFrequency; 28568fefafa2200d3ea44ec46592b190654a10685b46Brian Paul (void) priority; 28578fefafa2200d3ea44ec46592b190654a10685b46Brian Paul return NULL; 28588fefafa2200d3ea44ec46592b190654a10685b46Brian Paul} 28598fefafa2200d3ea44ec46592b190654a10685b46Brian Paul 28608fefafa2200d3ea44ec46592b190654a10685b46Brian Paul 28618fefafa2200d3ea44ec46592b190654a10685b46Brian Paulstatic void 28628fefafa2200d3ea44ec46592b190654a10685b46Brian PaulFake_glXFreeMemoryNV( GLvoid *pointer ) 28638fefafa2200d3ea44ec46592b190654a10685b46Brian Paul{ 28648fefafa2200d3ea44ec46592b190654a10685b46Brian Paul (void) pointer; 28658fefafa2200d3ea44ec46592b190654a10685b46Brian Paul} 28668fefafa2200d3ea44ec46592b190654a10685b46Brian Paul 28678fefafa2200d3ea44ec46592b190654a10685b46Brian Paul 28683c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian Paul/*** GLX_MESA_agp_offset ***/ 2869d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul 2870d6113fc20d68f5720740b89c594227d0312bab3eBrian Paulstatic GLuint 2871d6113fc20d68f5720740b89c594227d0312bab3eBrian PaulFake_glXGetAGPOffsetMESA( const GLvoid *pointer ) 2872d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul{ 2873d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul (void) pointer; 2874d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul return ~0; 2875d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul} 2876d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul 2877d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul 2878fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian/*** GLX_EXT_texture_from_pixmap ***/ 2879fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian 2880fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrianstatic void 2881fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrianFake_glXBindTexImageEXT(Display *dpy, GLXDrawable drawable, int buffer, 2882fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian const int *attrib_list) 2883fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian{ 2884fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian XMesaBuffer b = XMesaFindBuffer(dpy, drawable); 2885fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (b) 2886fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian XMesaBindTexImage(dpy, b, buffer, attrib_list); 2887fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian} 2888fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian 2889fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrianstatic void 2890fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrianFake_glXReleaseTexImageEXT(Display *dpy, GLXDrawable drawable, int buffer) 2891fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian{ 2892fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian XMesaBuffer b = XMesaFindBuffer(dpy, drawable); 2893fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (b) 2894fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian XMesaReleaseTexImage(dpy, b, buffer); 2895fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian} 2896fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian 2897fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian 28987287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul/* silence warning */ 2899e7b16b74bf5d13331b5a88bbbbb9096560297b63Brian Paulextern struct _glxapi_table *_mesa_GetGLXDispatchTable(void); 29007287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul 29017287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul 29027287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul/** 29037287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul * Create a new GLX API dispatch table with its function pointers 29047287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul * initialized to point to Mesa's "fake" GLX API functions. 29057287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul * Note: there's a similar function (_real_GetGLXDispatchTable) that 29067287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul * returns a new dispatch table with all pointers initalized to point 29077287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul * to "real" GLX functions (which understand GLX wire protocol, etc). 29087287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul */ 29097287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulstruct _glxapi_table * 29107287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul_mesa_GetGLXDispatchTable(void) 2911426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 2912426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul static struct _glxapi_table glx; 2913426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2914426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul /* be sure our dispatch table size <= libGL's table */ 2915426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul { 291601915e90e6912f06d43d443a09157f7bbc96ddc5Brian Paul GLuint size = sizeof(struct _glxapi_table) / sizeof(void *); 2917426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) size; 2918426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul assert(_glxapi_get_dispatch_table_size() >= size); 2919426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul } 2920426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2921426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul /* initialize the whole table to no-ops */ 2922426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul _glxapi_set_no_op_table(&glx); 2923426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2924426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul /* now initialize the table with the functions I implement */ 2925426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.ChooseVisual = Fake_glXChooseVisual; 2926426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CopyContext = Fake_glXCopyContext; 2927426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CreateContext = Fake_glXCreateContext; 2928426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CreateGLXPixmap = Fake_glXCreateGLXPixmap; 2929426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.DestroyContext = Fake_glXDestroyContext; 2930426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.DestroyGLXPixmap = Fake_glXDestroyGLXPixmap; 2931426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.GetConfig = Fake_glXGetConfig; 2932426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul /*glx.GetCurrentContext = Fake_glXGetCurrentContext;*/ 2933426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul /*glx.GetCurrentDrawable = Fake_glXGetCurrentDrawable;*/ 2934426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.IsDirect = Fake_glXIsDirect; 2935426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.MakeCurrent = Fake_glXMakeCurrent; 2936426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.QueryExtension = Fake_glXQueryExtension; 2937426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.QueryVersion = Fake_glXQueryVersion; 2938426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.SwapBuffers = Fake_glXSwapBuffers; 2939426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.UseXFont = Fake_glXUseXFont; 2940426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.WaitGL = Fake_glXWaitGL; 2941426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.WaitX = Fake_glXWaitX; 2942426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2943b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_VERSION_1_1 ***/ 2944426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.GetClientString = Fake_glXGetClientString; 2945426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.QueryExtensionsString = Fake_glXQueryExtensionsString; 2946426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.QueryServerString = Fake_glXQueryServerString; 2947426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2948b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_VERSION_1_2 ***/ 2949426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul /*glx.GetCurrentDisplay = Fake_glXGetCurrentDisplay;*/ 2950426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2951b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_VERSION_1_3 ***/ 2952426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.ChooseFBConfig = Fake_glXChooseFBConfig; 2953426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CreateNewContext = Fake_glXCreateNewContext; 2954426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CreatePbuffer = Fake_glXCreatePbuffer; 2955426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CreatePixmap = Fake_glXCreatePixmap; 2956426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CreateWindow = Fake_glXCreateWindow; 2957426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.DestroyPbuffer = Fake_glXDestroyPbuffer; 2958426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.DestroyPixmap = Fake_glXDestroyPixmap; 2959426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.DestroyWindow = Fake_glXDestroyWindow; 2960426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul /*glx.GetCurrentReadDrawable = Fake_glXGetCurrentReadDrawable;*/ 2961426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.GetFBConfigAttrib = Fake_glXGetFBConfigAttrib; 296271dea349d2be623b7819389428b0d6a124e8d184Brian Paul glx.GetFBConfigs = Fake_glXGetFBConfigs; 2963426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.GetSelectedEvent = Fake_glXGetSelectedEvent; 2964426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.GetVisualFromFBConfig = Fake_glXGetVisualFromFBConfig; 2965426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.MakeContextCurrent = Fake_glXMakeContextCurrent; 2966426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.QueryContext = Fake_glXQueryContext; 2967426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.QueryDrawable = Fake_glXQueryDrawable; 2968426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.SelectEvent = Fake_glXSelectEvent; 2969426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2970b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SGI_swap_control ***/ 2971783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.SwapIntervalSGI = Fake_glXSwapIntervalSGI; 2972783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2973b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SGI_video_sync ***/ 2974426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.GetVideoSyncSGI = Fake_glXGetVideoSyncSGI; 2975426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.WaitVideoSyncSGI = Fake_glXWaitVideoSyncSGI; 2976426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2977b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SGI_make_current_read ***/ 2978783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.MakeCurrentReadSGI = Fake_glXMakeCurrentReadSGI; 29797cf50e137da497a590ec9001a9918972a6246142Brian Paul /*glx.GetCurrentReadDrawableSGI = Fake_glXGetCurrentReadDrawableSGI;*/ 2980783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2981b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_video_source ***/ 2982b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#if defined(_VL_H) 2983783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.CreateGLXVideoSourceSGIX = Fake_glXCreateGLXVideoSourceSGIX; 2984783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.DestroyGLXVideoSourceSGIX = Fake_glXDestroyGLXVideoSourceSGIX; 2985783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul#endif 2986783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2987b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_EXT_import_context ***/ 2988783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.FreeContextEXT = Fake_glXFreeContextEXT; 2989783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.GetContextIDEXT = Fake_glXGetContextIDEXT; 29907cf50e137da497a590ec9001a9918972a6246142Brian Paul /*glx.GetCurrentDisplayEXT = Fake_glXGetCurrentDisplayEXT;*/ 2991783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.ImportContextEXT = Fake_glXImportContextEXT; 2992783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.QueryContextInfoEXT = Fake_glXQueryContextInfoEXT; 29934536021a62e02fceaa6e8eb889b0f61743109cc4Brian Paul 2994b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SGIX_fbconfig ***/ 2995783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.GetFBConfigAttribSGIX = Fake_glXGetFBConfigAttribSGIX; 2996783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.ChooseFBConfigSGIX = Fake_glXChooseFBConfigSGIX; 2997783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.CreateGLXPixmapWithConfigSGIX = Fake_glXCreateGLXPixmapWithConfigSGIX; 2998783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.CreateContextWithConfigSGIX = Fake_glXCreateContextWithConfigSGIX; 2999783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.GetVisualFromFBConfigSGIX = Fake_glXGetVisualFromFBConfigSGIX; 3000783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.GetFBConfigFromVisualSGIX = Fake_glXGetFBConfigFromVisualSGIX; 3001783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 3002b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SGIX_pbuffer ***/ 3003783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.CreateGLXPbufferSGIX = Fake_glXCreateGLXPbufferSGIX; 3004783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.DestroyGLXPbufferSGIX = Fake_glXDestroyGLXPbufferSGIX; 3005783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.QueryGLXPbufferSGIX = Fake_glXQueryGLXPbufferSGIX; 3006783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.SelectEventSGIX = Fake_glXSelectEventSGIX; 3007783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.GetSelectedEventSGIX = Fake_glXGetSelectedEventSGIX; 3008783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 3009b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SGI_cushion ***/ 3010783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.CushionSGI = Fake_glXCushionSGI; 3011783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 3012b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SGIX_video_resize ***/ 3013783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.BindChannelToWindowSGIX = Fake_glXBindChannelToWindowSGIX; 3014783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.ChannelRectSGIX = Fake_glXChannelRectSGIX; 3015783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.QueryChannelRectSGIX = Fake_glXQueryChannelRectSGIX; 3016783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.QueryChannelDeltasSGIX = Fake_glXQueryChannelDeltasSGIX; 3017783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.ChannelRectSyncSGIX = Fake_glXChannelRectSyncSGIX; 3018783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 3019b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SGIX_dmbuffer **/ 3020b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#if defined(_DM_BUFFER_H_) 3021783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.AssociateDMPbufferSGIX = NULL; 3022783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul#endif 3023783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 3024b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SGIX_swap_group ***/ 3025783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.JoinSwapGroupSGIX = Fake_glXJoinSwapGroupSGIX; 3026783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 3027b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SGIX_swap_barrier ***/ 3028783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.BindSwapBarrierSGIX = Fake_glXBindSwapBarrierSGIX; 3029783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.QueryMaxSwapBarriersSGIX = Fake_glXQueryMaxSwapBarriersSGIX; 3030783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 3031b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SUN_get_transparent_index ***/ 3032783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.GetTransparentIndexSUN = Fake_glXGetTransparentIndexSUN; 30334536021a62e02fceaa6e8eb889b0f61743109cc4Brian Paul 3034b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_MESA_copy_sub_buffer ***/ 3035426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CopySubBufferMESA = Fake_glXCopySubBufferMESA; 3036426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 3037b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_MESA_release_buffers ***/ 3038426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.ReleaseBuffersMESA = Fake_glXReleaseBuffersMESA; 3039426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 3040b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_MESA_pixmap_colormap ***/ 3041426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CreateGLXPixmapMESA = Fake_glXCreateGLXPixmapMESA; 3042426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 3043b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_MESA_set_3dfx_mode ***/ 3044426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.Set3DfxModeMESA = Fake_glXSet3DfxModeMESA; 3045426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 3046d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul /*** GLX_NV_vertex_array_range ***/ 30478fefafa2200d3ea44ec46592b190654a10685b46Brian Paul glx.AllocateMemoryNV = Fake_glXAllocateMemoryNV; 30488fefafa2200d3ea44ec46592b190654a10685b46Brian Paul glx.FreeMemoryNV = Fake_glXFreeMemoryNV; 30498fefafa2200d3ea44ec46592b190654a10685b46Brian Paul 3050d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul /*** GLX_MESA_agp_offset ***/ 3051d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul glx.GetAGPOffsetMESA = Fake_glXGetAGPOffsetMESA; 3052d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul 3053fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian /*** GLX_EXT_texture_from_pixmap ***/ 3054fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian glx.BindTexImageEXT = Fake_glXBindTexImageEXT; 3055fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian glx.ReleaseTexImageEXT = Fake_glXReleaseTexImageEXT; 3056fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian 3057426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul return &glx; 3058426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 3059