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, 431074637bf991c1f0fbe7d63df75427975af711d7cBrian Paul 8, /* 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 920938b156d824d2dd34eea9247e0efc4467a3fc804Brian Paul if (fbConfig && 921938b156d824d2dd34eea9247e0efc4467a3fc804Brian Paul parselist[1] == GLX_DONT_CARE && 922938b156d824d2dd34eea9247e0efc4467a3fc804Brian Paul parselist[0] != GLX_LEVEL) { 923938b156d824d2dd34eea9247e0efc4467a3fc804Brian Paul /* For glXChooseFBConfig(), skip attributes whose value is 924938b156d824d2dd34eea9247e0efc4467a3fc804Brian Paul * GLX_DONT_CARE (-1), unless it's GLX_LEVEL (which can legitimately be 925938b156d824d2dd34eea9247e0efc4467a3fc804Brian Paul * a negative value). 926938b156d824d2dd34eea9247e0efc4467a3fc804Brian Paul * 927938b156d824d2dd34eea9247e0efc4467a3fc804Brian Paul * From page 17 (23 of the pdf) of the GLX 1.4 spec: 928938b156d824d2dd34eea9247e0efc4467a3fc804Brian Paul * GLX DONT CARE may be specified for all attributes except GLX LEVEL. 929938b156d824d2dd34eea9247e0efc4467a3fc804Brian Paul */ 930938b156d824d2dd34eea9247e0efc4467a3fc804Brian Paul parselist += 2; 931938b156d824d2dd34eea9247e0efc4467a3fc804Brian Paul continue; 932938b156d824d2dd34eea9247e0efc4467a3fc804Brian Paul } 933938b156d824d2dd34eea9247e0efc4467a3fc804Brian Paul 934afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (*parselist) { 935afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_USE_GL: 9361f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul if (fbConfig) { 9371f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul /* invalid token */ 9381f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul return NULL; 9391f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul } 9401f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul else { 9411f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul /* skip */ 9421f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul parselist++; 9431f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul } 944afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 945afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_BUFFER_SIZE: 946afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 947afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg min_ci = *parselist++; 948afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 949afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_LEVEL: 950afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 951afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg level = *parselist++; 952afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 953afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_RGBA: 9541f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul if (fbConfig) { 9551f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul /* invalid token */ 9561f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul return NULL; 9571f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul } 9581f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul else { 9591f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul rgb_flag = GL_TRUE; 9601f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul parselist++; 9611f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul } 962afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 963afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_DOUBLEBUFFER: 9641f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul parselist++; 9651f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul if (fbConfig) { 9661f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul double_flag = *parselist++; 9671f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul } 9681f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul else { 9691f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul double_flag = GL_TRUE; 9701f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul } 971afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 972afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STEREO: 9731f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul parselist++; 9741f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul if (fbConfig) { 9751f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul stereo_flag = *parselist++; 9761f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul } 9771f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul else { 9781f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul stereo_flag = GL_TRUE; 9791f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul } 980da2f1e88bc63403a95b89706905c070b7c894863Brian break; 981afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_AUX_BUFFERS: 982afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 983894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul numAux = *parselist++; 984894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul if (numAux > MAX_AUX_BUFFERS) 985894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul return NULL; 986afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 987afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_RED_SIZE: 988afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 989afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg min_red = *parselist++; 990afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 991afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_GREEN_SIZE: 992afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 993afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg min_green = *parselist++; 994afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 995afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_BLUE_SIZE: 996afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 997afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg min_blue = *parselist++; 998afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 999afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ALPHA_SIZE: 1000afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1001afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg { 1002afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLint size = *parselist++; 1003c12ee99d119debe1a421a77c1cc6d99d958ae94bBrian Paul alpha_flag = size ? GL_TRUE : GL_FALSE; 1004afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1005afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 1006afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_DEPTH_SIZE: 1007afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1008afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg depth_size = *parselist++; 1009afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 1010afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STENCIL_SIZE: 1011afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1012afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg stencil_size = *parselist++; 1013afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 1014afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_RED_SIZE: 1015b2e460018375f699198073a6167e0ee96ba1d267Brian Paul parselist++; 1016b2e460018375f699198073a6167e0ee96ba1d267Brian Paul { 1017b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint size = *parselist++; 1018b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumRedSize = MAX2( accumRedSize, size ); 1019b2e460018375f699198073a6167e0ee96ba1d267Brian Paul } 1020b2e460018375f699198073a6167e0ee96ba1d267Brian Paul break; 1021afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_GREEN_SIZE: 1022b2e460018375f699198073a6167e0ee96ba1d267Brian Paul parselist++; 1023b2e460018375f699198073a6167e0ee96ba1d267Brian Paul { 1024b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint size = *parselist++; 1025b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumGreenSize = MAX2( accumGreenSize, size ); 1026b2e460018375f699198073a6167e0ee96ba1d267Brian Paul } 1027b2e460018375f699198073a6167e0ee96ba1d267Brian Paul break; 1028afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_BLUE_SIZE: 1029b2e460018375f699198073a6167e0ee96ba1d267Brian Paul parselist++; 1030b2e460018375f699198073a6167e0ee96ba1d267Brian Paul { 1031b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint size = *parselist++; 1032b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumBlueSize = MAX2( accumBlueSize, size ); 1033b2e460018375f699198073a6167e0ee96ba1d267Brian Paul } 1034b2e460018375f699198073a6167e0ee96ba1d267Brian Paul break; 1035afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_ALPHA_SIZE: 1036afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1037afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg { 1038afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLint size = *parselist++; 1039b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumAlphaSize = MAX2( accumAlphaSize, size ); 1040afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1041afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 1042afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1043afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* 1044afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * GLX_EXT_visual_info extension 1045afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 1046afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_X_VISUAL_TYPE_EXT: 1047afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1048afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg visual_type = *parselist++; 1049afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 1050afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_TYPE_EXT: 1051afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1052afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg trans_type = *parselist++; 1053afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 1054afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_INDEX_VALUE_EXT: 1055afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1056afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg trans_value = *parselist++; 1057afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 1058afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_RED_VALUE_EXT: 1059afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_GREEN_VALUE_EXT: 1060afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_BLUE_VALUE_EXT: 1061afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_ALPHA_VALUE_EXT: 1062afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* ignore */ 1063afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1064afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1065afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 10665e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen 1067e1210b176926349b258c7ec77b7f36716025c82aBrian Paul /* 1068e1210b176926349b258c7ec77b7f36716025c82aBrian Paul * GLX_EXT_visual_info extension 1069e1210b176926349b258c7ec77b7f36716025c82aBrian Paul */ 1070e1210b176926349b258c7ec77b7f36716025c82aBrian Paul case GLX_VISUAL_CAVEAT_EXT: 1071e1210b176926349b258c7ec77b7f36716025c82aBrian Paul parselist++; 1072e1210b176926349b258c7ec77b7f36716025c82aBrian Paul caveat = *parselist++; /* ignored for now */ 1073e1210b176926349b258c7ec77b7f36716025c82aBrian Paul break; 1074e1210b176926349b258c7ec77b7f36716025c82aBrian Paul 10753265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul /* 107666ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul * GLX_ARB_multisample 107766ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul */ 107866ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul case GLX_SAMPLE_BUFFERS_ARB: 107966ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul case GLX_SAMPLES_ARB: 1080e903f51bc43fde1f61a779fd8017c96a651781acBrian Paul parselist++; 1081e903f51bc43fde1f61a779fd8017c96a651781acBrian Paul if (*parselist++ != 0) 1082e903f51bc43fde1f61a779fd8017c96a651781acBrian Paul /* ms not supported */ 1083e903f51bc43fde1f61a779fd8017c96a651781acBrian Paul return NULL; 1084e903f51bc43fde1f61a779fd8017c96a651781acBrian Paul break; 108566ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul 108666ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul /* 10873265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul * FBConfig attribs. 10883265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul */ 10893265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_RENDER_TYPE: 1090dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul if (!fbConfig) 1091dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul return NULL; 10923265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul parselist++; 1093584b0879ac2ec2420ea6866e47eb90e1a980e758Brian Paul if (*parselist & GLX_RGBA_BIT) { 10943265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul rgb_flag = GL_TRUE; 10953265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 1096584b0879ac2ec2420ea6866e47eb90e1a980e758Brian Paul else if (*parselist & GLX_COLOR_INDEX_BIT) { 10973265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul rgb_flag = GL_FALSE; 10983265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 10993265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul else if (*parselist == 0) { 11003265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul rgb_flag = GL_TRUE; 11013265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 11023265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul parselist++; 11033265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 11043265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_DRAWABLE_TYPE: 1105dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul if (!fbConfig) 1106dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul return NULL; 11073265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul parselist++; 11083265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (*parselist & ~(GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT)) { 11093265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return NULL; /* bad bit */ 11103265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 11113265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul parselist++; 11123265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 11133a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul case GLX_FBCONFIG_ID: 1114d60880db35fd11d9348ce4b2bfbcc9325d2ebf91Brian Paul case GLX_VISUAL_ID: 1115dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul if (!fbConfig) 1116dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul return NULL; 11173a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul parselist++; 1118dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul desiredVisualID = *parselist++; 1119dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul break; 1120dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul case GLX_X_RENDERABLE: 1121d60880db35fd11d9348ce4b2bfbcc9325d2ebf91Brian Paul case GLX_MAX_PBUFFER_WIDTH: 1122d60880db35fd11d9348ce4b2bfbcc9325d2ebf91Brian Paul case GLX_MAX_PBUFFER_HEIGHT: 1123d60880db35fd11d9348ce4b2bfbcc9325d2ebf91Brian Paul case GLX_MAX_PBUFFER_PIXELS: 1124dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul if (!fbConfig) 1125dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul return NULL; 1126dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul parselist += 2; 1127dfb6c56ed85d7b11b6e7e9b0a5ec7eddb1162510Brian Paul /* ignore */ 11283a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul break; 11293265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul 1130fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian#ifdef GLX_EXT_texture_from_pixmap 1131fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_BIND_TO_TEXTURE_RGB_EXT: 1132fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian parselist++; /*skip*/ 1133fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 1134fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_BIND_TO_TEXTURE_RGBA_EXT: 1135fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian parselist++; /*skip*/ 1136fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 1137fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_BIND_TO_MIPMAP_TEXTURE_EXT: 1138fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian parselist++; /*skip*/ 1139fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 1140fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_BIND_TO_TEXTURE_TARGETS_EXT: 1141fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian parselist++; 1142fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (*parselist & ~(GLX_TEXTURE_1D_BIT_EXT | 1143fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian GLX_TEXTURE_2D_BIT_EXT | 1144fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian GLX_TEXTURE_RECTANGLE_BIT_EXT)) { 1145fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian /* invalid bit */ 1146fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian return NULL; 1147fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 1148fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 1149fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_Y_INVERTED_EXT: 1150fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian parselist++; /*skip*/ 1151fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 1152fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian#endif 1153fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian 1154afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case None: 11553a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul /* end of list */ 1156afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 11573265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul 1158afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: 1159afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* undefined attribute */ 11602ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul _mesa_warning(NULL, "unexpected attrib 0x%x in choose_visual()", 11612ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul *parselist); 1162afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 1163afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1164afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1165afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 116681fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick if (!rgb_flag) 116781fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick return NULL; 116881fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick 1169b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul (void) caveat; 11702aeadabc7ec05e45d4f8f3bf4df531d9c451ad45Brian Paul (void) min_ci; 1171b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul 1172afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* 1173afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Since we're only simulating the GLX extension this function will never 1174afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * find any real GL visuals. Instead, all we can do is try to find an RGB 1175afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * or CI visual of appropriate depth. Other requested attributes such as 1176afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * double buffering, depth buffer, etc. will be associated with the X 1177afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * visual and stored in the VisualTable[]. 1178afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 11793a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul if (desiredVisualID != -1) { 11803a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul /* try to get a specific visual, by visualID */ 11813a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul XVisualInfo temp; 11823a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul int n; 11833a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul temp.visualid = desiredVisualID; 11843a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul temp.screen = screen; 11853a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul vis = XGetVisualInfo(dpy, VisualIDMask | VisualScreenMask, &temp, &n); 11863a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul if (vis) { 11873a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul /* give the visual some useful GLX attributes */ 11883a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul double_flag = GL_TRUE; 118981fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick if (vis->depth <= 8) 119081fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick return NULL; 1191dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul depth_size = default_depth_bits(); 1192074637bf991c1f0fbe7d63df75427975af711d7cBrian Paul stencil_size = 8; 11933a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul /* XXX accum??? */ 11943a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul } 11953a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul } 1196afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 119781fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick /* RGB visual */ 119881fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick int min_rgb = min_red + min_green + min_blue; 119981fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick if (min_rgb>1 && min_rgb<8) { 120081fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick /* a special case to be sure we can get a monochrome visual */ 120181fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick min_rgb = 1; 120281fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick } 120381fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick 120481fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick if (level==0) { 120581fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick vis = choose_x_visual(dpy, screen, min_rgb, visual_type); 120642f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul } 120742f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul else { 120881fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick vis = choose_x_overlay_visual(dpy, screen, level, 120981fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick trans_type, trans_value, min_rgb, visual_type); 121042f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul } 1211afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1212afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1213afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 1214ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul /* Note: we're not exactly obeying the glXChooseVisual rules here. 1215ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * When GLX_DEPTH_SIZE = 1 is specified we're supposed to choose the 12162c7e6334ec81c2fab2cce9e0fe52cd30256e37eaBrian Paul * largest depth buffer size, which is 32bits/value. Instead, we 1217ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * return 16 to maintain performance with earlier versions of Mesa. 1218ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul */ 12192c7e6334ec81c2fab2cce9e0fe52cd30256e37eaBrian Paul if (depth_size > 24) 12209e4e3adcf82a72e9a74f21b492fbf5552ebfd47fBrian Paul depth_size = 32; 1221ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul else if (depth_size > 16) 1222ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul depth_size = 24; 1223dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul else if (depth_size > 0) { 1224dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul depth_size = default_depth_bits(); 1225dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul } 12262c7e6334ec81c2fab2cce9e0fe52cd30256e37eaBrian Paul 1227c12ee99d119debe1a421a77c1cc6d99d958ae94bBrian Paul if (!alpha_flag) { 1228c12ee99d119debe1a421a77c1cc6d99d958ae94bBrian Paul alpha_flag = default_alpha_bits() > 0; 1229c12ee99d119debe1a421a77c1cc6d99d958ae94bBrian Paul } 1230c12ee99d119debe1a421a77c1cc6d99d958ae94bBrian Paul 1231ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul /* we only support one size of stencil and accum buffers. */ 1232ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul if (stencil_size > 0) 1233074637bf991c1f0fbe7d63df75427975af711d7cBrian Paul stencil_size = 8; 12346d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul if (accumRedSize > 0 || accumGreenSize > 0 || accumBlueSize > 0 || 12356d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul accumAlphaSize > 0) { 1236978ef2bb6d9ca4996a24f95820a699e22c84f70bBrian Paul accumRedSize = 1237978ef2bb6d9ca4996a24f95820a699e22c84f70bBrian Paul accumGreenSize = 1238978ef2bb6d9ca4996a24f95820a699e22c84f70bBrian Paul accumBlueSize = default_accum_bits(); 1239978ef2bb6d9ca4996a24f95820a699e22c84f70bBrian Paul accumAlphaSize = alpha_flag ? accumRedSize : 0; 12406d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul } 12416d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul 124281fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick xmvis = save_glx_visual( dpy, vis, alpha_flag, double_flag, 12433265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul stereo_flag, depth_size, stencil_size, 12443265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul accumRedSize, accumGreenSize, 1245894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul accumBlueSize, accumAlphaSize, level, numAux ); 1246afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1247afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 12483265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return xmvis; 1249afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1250afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1251afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 12523265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paulstatic XVisualInfo * 12533265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian PaulFake_glXChooseVisual( Display *dpy, int screen, int *list ) 12543265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul{ 12556c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul XMesaVisual xmvis; 12566c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul 12576c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul /* register ourselves as an extension on this display */ 12586c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul register_with_display(dpy); 12596c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul 12606c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul xmvis = choose_visual(dpy, screen, list, GL_FALSE); 1261f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul if (xmvis) { 1262f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul#if 0 1263f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul return xmvis->vishandle; 1264f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul#else 1265f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul /* create a new vishandle - the cached one may be stale */ 126632f2fd1c5d6088692551c80352b7d6fa35b0cd09Kristian Høgsberg xmvis->vishandle = (XVisualInfo *) malloc(sizeof(XVisualInfo)); 1267f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul if (xmvis->vishandle) { 1268c7ac486261ad30ef654f6d0b1608da4e8483cd40Kenneth Graunke memcpy(xmvis->vishandle, xmvis->visinfo, sizeof(XVisualInfo)); 1269f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul } 12703265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return xmvis->vishandle; 1271f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul#endif 1272f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul } 12733265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul else 12743265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return NULL; 12753265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul} 1276afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1277afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 127849e80bf6b163310f7cd776261872201eea57053aBrian Paul/** 127949e80bf6b163310f7cd776261872201eea57053aBrian Paul * Init basic fields of a new fake_glx_context. 128049e80bf6b163310f7cd776261872201eea57053aBrian Paul */ 128149e80bf6b163310f7cd776261872201eea57053aBrian Paulstatic void 128249e80bf6b163310f7cd776261872201eea57053aBrian Paulinit_glx_context(struct fake_glx_context *glxCtx, Display *dpy) 128349e80bf6b163310f7cd776261872201eea57053aBrian Paul{ 1284c35a5aeb706d33b9c09b5a12bbbeae0f109885c9Brian Paul /* Always return True. See if anyone's confused... */ 1285c35a5aeb706d33b9c09b5a12bbbeae0f109885c9Brian Paul GLboolean direct = GL_TRUE; 1286c35a5aeb706d33b9c09b5a12bbbeae0f109885c9Brian Paul 128749e80bf6b163310f7cd776261872201eea57053aBrian Paul glxCtx->xmesaContext->direct = direct; 128849e80bf6b163310f7cd776261872201eea57053aBrian Paul glxCtx->glxContext.isDirect = direct; 128949e80bf6b163310f7cd776261872201eea57053aBrian Paul glxCtx->glxContext.currentDpy = dpy; 129049e80bf6b163310f7cd776261872201eea57053aBrian Paul glxCtx->glxContext.xid = (XID) glxCtx; /* self pointer */ 129149e80bf6b163310f7cd776261872201eea57053aBrian Paul 129249e80bf6b163310f7cd776261872201eea57053aBrian Paul assert((void *) glxCtx == (void *) &(glxCtx->glxContext)); 129349e80bf6b163310f7cd776261872201eea57053aBrian Paul} 129449e80bf6b163310f7cd776261872201eea57053aBrian Paul 129549e80bf6b163310f7cd776261872201eea57053aBrian Paul 129649e80bf6b163310f7cd776261872201eea57053aBrian Paul 1297426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXContext 1298426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateContext( Display *dpy, XVisualInfo *visinfo, 1299426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul GLXContext share_list, Bool direct ) 1300afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1301e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaVisual xmvis; 13027cf50e137da497a590ec9001a9918972a6246142Brian Paul struct fake_glx_context *glxCtx; 13035e1680ce1d8296b2182e8909856927bbeddf3b95Brian Paul struct fake_glx_context *shareCtx = (struct fake_glx_context *) share_list; 130499aab341998e84d9fa208c525cae8021b3845812Brian Paul 130599aab341998e84d9fa208c525cae8021b3845812Brian Paul if (!dpy || !visinfo) 130699aab341998e84d9fa208c525cae8021b3845812Brian Paul return 0; 130799aab341998e84d9fa208c525cae8021b3845812Brian Paul 13087cf50e137da497a590ec9001a9918972a6246142Brian Paul glxCtx = CALLOC_STRUCT(fake_glx_context); 13097cf50e137da497a590ec9001a9918972a6246142Brian Paul if (!glxCtx) 13107cf50e137da497a590ec9001a9918972a6246142Brian Paul return 0; 1311afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1312afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* deallocate unused windows/buffers */ 13136c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul#if 0 131490e227f0791cb585dc4e4e1f71e32c67f5e20436Andy Skinner XMesaGarbageCollect(dpy); 13156c06ce281aa7a7e20eab1934f573bc5c673d41cbBrian Paul#endif 1316afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1317e4656003caee346d9c4eb23256d73409271291a7Brian Paul xmvis = find_glx_visual( dpy, visinfo ); 1318e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (!xmvis) { 1319afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* This visual wasn't found with glXChooseVisual() */ 1320e4656003caee346d9c4eb23256d73409271291a7Brian Paul xmvis = create_glx_visual( dpy, visinfo ); 1321e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (!xmvis) { 1322afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* unusable visual */ 132332f2fd1c5d6088692551c80352b7d6fa35b0cd09Kristian Høgsberg free(glxCtx); 1324afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 1325afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1326afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1327afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1328e4656003caee346d9c4eb23256d73409271291a7Brian Paul glxCtx->xmesaContext = XMesaCreateContext(xmvis, 13295e1680ce1d8296b2182e8909856927bbeddf3b95Brian Paul shareCtx ? shareCtx->xmesaContext : NULL); 13307cf50e137da497a590ec9001a9918972a6246142Brian Paul if (!glxCtx->xmesaContext) { 133132f2fd1c5d6088692551c80352b7d6fa35b0cd09Kristian Høgsberg free(glxCtx); 13327cf50e137da497a590ec9001a9918972a6246142Brian Paul return NULL; 1333afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 13347cf50e137da497a590ec9001a9918972a6246142Brian Paul 133549e80bf6b163310f7cd776261872201eea57053aBrian Paul init_glx_context(glxCtx, dpy); 13367cf50e137da497a590ec9001a9918972a6246142Brian Paul 13377cf50e137da497a590ec9001a9918972a6246142Brian Paul return (GLXContext) glxCtx; 1338afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1339afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1340afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 13417cf50e137da497a590ec9001a9918972a6246142Brian Paul/* XXX these may have to be removed due to thread-safety issues. */ 1342afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic GLXContext MakeCurrent_PrevContext = 0; 1343086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic GLXDrawable MakeCurrent_PrevDrawable = 0; 1344086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic GLXDrawable MakeCurrent_PrevReadable = 0; 1345086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic XMesaBuffer MakeCurrent_PrevDrawBuffer = 0; 1346086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic XMesaBuffer MakeCurrent_PrevReadBuffer = 0; 1347afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 13487cf50e137da497a590ec9001a9918972a6246142Brian Paul 1349086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul/* GLX 1.3 and later */ 1350426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool 1351426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXMakeContextCurrent( Display *dpy, GLXDrawable draw, 13527a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell GLXDrawable read, GLXContext ctx ) 1353086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul{ 13547cf50e137da497a590ec9001a9918972a6246142Brian Paul struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx; 13557cf50e137da497a590ec9001a9918972a6246142Brian Paul 13567a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell if (ctx && draw && read) { 1357086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul XMesaBuffer drawBuffer, readBuffer; 13587cf50e137da497a590ec9001a9918972a6246142Brian Paul XMesaContext xmctx = glxCtx->xmesaContext; 1359086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul 1360086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* Find the XMesaBuffer which corresponds to the GLXDrawable 'draw' */ 13617a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell if (ctx == MakeCurrent_PrevContext 13627a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell && draw == MakeCurrent_PrevDrawable) { 1363086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul drawBuffer = MakeCurrent_PrevDrawBuffer; 1364086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1365086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul else { 1366086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul drawBuffer = XMesaFindBuffer( dpy, draw ); 1367086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1368086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul if (!drawBuffer) { 1369086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* drawable must be a new window! */ 13706aa5668871e7f366b33e85fabc72885fc269a7d4George Sapountzis drawBuffer = XMesaCreateWindowBuffer( xmctx->xm_visual, draw ); 1371086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul if (!drawBuffer) { 1372086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* Out of memory, or context/drawable depth mismatch */ 1373086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul return False; 1374086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1375086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1376086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul 1377086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* Find the XMesaBuffer which corresponds to the GLXDrawable 'read' */ 13787a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell if (ctx == MakeCurrent_PrevContext 1379086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul && read == MakeCurrent_PrevReadable) { 1380086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul readBuffer = MakeCurrent_PrevReadBuffer; 1381086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1382086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul else { 1383086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul readBuffer = XMesaFindBuffer( dpy, read ); 1384086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1385086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul if (!readBuffer) { 1386086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* drawable must be a new window! */ 13876aa5668871e7f366b33e85fabc72885fc269a7d4George Sapountzis readBuffer = XMesaCreateWindowBuffer( xmctx->xm_visual, read ); 1388086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul if (!readBuffer) { 1389086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* Out of memory, or context/drawable depth mismatch */ 1390086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul return False; 1391086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1392086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1393086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul 13947a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell MakeCurrent_PrevContext = ctx; 1395086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevDrawable = draw; 1396086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevReadable = read; 1397086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevDrawBuffer = drawBuffer; 1398086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevReadBuffer = readBuffer; 1399086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul 1400086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* Now make current! */ 14017cf50e137da497a590ec9001a9918972a6246142Brian Paul if (XMesaMakeCurrent2(xmctx, drawBuffer, readBuffer)) { 140212c1bee87fcc3a0912685bb6e83447972e5de64eBrian Paul ((__GLXcontext *) ctx)->currentDpy = dpy; 140312c1bee87fcc3a0912685bb6e83447972e5de64eBrian Paul ((__GLXcontext *) ctx)->currentDrawable = draw; 140412c1bee87fcc3a0912685bb6e83447972e5de64eBrian Paul ((__GLXcontext *) ctx)->currentReadable = read; 14057cf50e137da497a590ec9001a9918972a6246142Brian Paul return True; 14067cf50e137da497a590ec9001a9918972a6246142Brian Paul } 14077cf50e137da497a590ec9001a9918972a6246142Brian Paul else { 14087cf50e137da497a590ec9001a9918972a6246142Brian Paul return False; 14097cf50e137da497a590ec9001a9918972a6246142Brian Paul } 1410086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 14117a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell else if (!ctx && !draw && !read) { 1412086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* release current context w/out assigning new one. */ 1413086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul XMesaMakeCurrent( NULL, NULL ); 1414086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevContext = 0; 1415086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevDrawable = 0; 1416086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevReadable = 0; 1417086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevDrawBuffer = 0; 1418086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevReadBuffer = 0; 1419086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul return True; 1420086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1421086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul else { 1422086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* The args must either all be non-zero or all zero. 1423086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul * This is an error. 1424086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul */ 1425086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul return False; 1426086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1427086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul} 1428086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul 1429086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul 1430426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool 1431426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXMakeCurrent( Display *dpy, GLXDrawable drawable, GLXContext ctx ) 1432426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 1433426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul return Fake_glXMakeContextCurrent( dpy, drawable, drawable, ctx ); 1434426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1435426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1436426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1437426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPixmap 1438426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateGLXPixmap( Display *dpy, XVisualInfo *visinfo, Pixmap pixmap ) 1439afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1440afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaVisual v; 1441afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaBuffer b; 1442afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1443afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg v = find_glx_visual( dpy, visinfo ); 1444afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!v) { 1445afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg v = create_glx_visual( dpy, visinfo ); 1446afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!v) { 1447afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* unusable visual */ 1448afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1449afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1450afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1451afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1452afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg b = XMesaCreatePixmapBuffer( v, pixmap, 0 ); 1453afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!b) { 1454afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1455afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1456e4b2356c07d31fbeeabb13b2fb47db703b473080Brian Paul return b->frontxrb->pixmap; 1457afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1458afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1459afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1460b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_MESA_pixmap_colormap ***/ 1461b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul 1462426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPixmap 1463426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visinfo, 1464426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul Pixmap pixmap, Colormap cmap ) 1465afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1466afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaVisual v; 1467afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaBuffer b; 1468afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1469afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg v = find_glx_visual( dpy, visinfo ); 1470afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!v) { 1471afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg v = create_glx_visual( dpy, visinfo ); 1472afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!v) { 1473afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* unusable visual */ 1474afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1475afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1476afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1477afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1478afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg b = XMesaCreatePixmapBuffer( v, pixmap, cmap ); 1479afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!b) { 1480afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1481afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1482e4b2356c07d31fbeeabb13b2fb47db703b473080Brian Paul return b->frontxrb->pixmap; 1483afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1484afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1485afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1486426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1487426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyGLXPixmap( Display *dpy, GLXPixmap pixmap ) 1488afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1489afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaBuffer b = XMesaFindBuffer(dpy, pixmap); 1490afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (b) { 1491afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaDestroyBuffer(b); 1492afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1493367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul else if (_mesa_getenv("MESA_DEBUG")) { 1494d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul _mesa_warning(NULL, "Mesa: glXDestroyGLXPixmap: invalid pixmap\n"); 1495afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1496afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1497afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1498afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1499426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1500426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCopyContext( Display *dpy, GLXContext src, GLXContext dst, 15013994b77bab8c62a4c1a4dffdfba233ef46662b99Brian Paul unsigned long mask ) 1502afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 150383b820aa98931ef30fa73c72b2a96fe23885955eBrian Paul struct fake_glx_context *fakeSrc = (struct fake_glx_context *) src; 150483b820aa98931ef30fa73c72b2a96fe23885955eBrian Paul struct fake_glx_context *fakeDst = (struct fake_glx_context *) dst; 150583b820aa98931ef30fa73c72b2a96fe23885955eBrian Paul XMesaContext xm_src = fakeSrc->xmesaContext; 150683b820aa98931ef30fa73c72b2a96fe23885955eBrian Paul XMesaContext xm_dst = fakeDst->xmesaContext; 1507afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 150868edf28df68701ac429e53c0fd6dbb70b39c3fd0Brian Paul if (MakeCurrent_PrevContext == src) { 150968edf28df68701ac429e53c0fd6dbb70b39c3fd0Brian Paul _mesa_Flush(); 151068edf28df68701ac429e53c0fd6dbb70b39c3fd0Brian Paul } 15111e24d3318df57b36e3b68695ff64b4b8bd822c9eBrian Paul _mesa_copy_context( &(xm_src->mesa), &(xm_dst->mesa), (GLuint) mask ); 1512afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1513afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1514afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1515426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool 1516e3fff3daf031a997a1d4316e1a0e5c831573221dBrian PaulFake_glXQueryExtension( Display *dpy, int *errorBase, int *eventBase ) 1517afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 15189f002e4aaa2d7ea085cd0a3c66ff0fa533905382Brian Paul int op, ev, err; 1519afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Mesa's GLX isn't really an X extension but we try to act like one. */ 15209f002e4aaa2d7ea085cd0a3c66ff0fa533905382Brian Paul if (!XQueryExtension(dpy, GLX_EXTENSION_NAME, &op, &ev, &err)) 15219f002e4aaa2d7ea085cd0a3c66ff0fa533905382Brian Paul ev = err = 0; 1522e3fff3daf031a997a1d4316e1a0e5c831573221dBrian Paul if (errorBase) 15239f002e4aaa2d7ea085cd0a3c66ff0fa533905382Brian Paul *errorBase = err; 1524e3fff3daf031a997a1d4316e1a0e5c831573221dBrian Paul if (eventBase) 15259f002e4aaa2d7ea085cd0a3c66ff0fa533905382Brian Paul *eventBase = ev; 15269f002e4aaa2d7ea085cd0a3c66ff0fa533905382Brian Paul return True; /* we're faking GLX so always return success */ 1527afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1528afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1529afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1530e7b16b74bf5d13331b5a88bbbbb9096560297b63Brian Paulextern void _kw_ungrab_all( Display *dpy ); 1531afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgvoid _kw_ungrab_all( Display *dpy ) 1532afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1533afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XUngrabPointer( dpy, CurrentTime ); 1534afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XUngrabKeyboard( dpy, CurrentTime ); 1535afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1536afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1537afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1538426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1539426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyContext( Display *dpy, GLXContext ctx ) 1540afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 15417cf50e137da497a590ec9001a9918972a6246142Brian Paul struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx; 1542afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 1543afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg MakeCurrent_PrevContext = 0; 1544afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg MakeCurrent_PrevDrawable = 0; 1545086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevReadable = 0; 1546086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevDrawBuffer = 0; 1547086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevReadBuffer = 0; 15487cf50e137da497a590ec9001a9918972a6246142Brian Paul XMesaDestroyContext( glxCtx->xmesaContext ); 154990e227f0791cb585dc4e4e1f71e32c67f5e20436Andy Skinner XMesaGarbageCollect(dpy); 155032f2fd1c5d6088692551c80352b7d6fa35b0cd09Kristian Høgsberg free(glxCtx); 1551afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1552afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1553afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1554426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool 1555426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXIsDirect( Display *dpy, GLXContext ctx ) 1556afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 15577cf50e137da497a590ec9001a9918972a6246142Brian Paul struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx; 1558afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 15597cf50e137da497a590ec9001a9918972a6246142Brian Paul return glxCtx->xmesaContext->direct; 1560afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1561afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1562afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1563afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1564426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1565426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXSwapBuffers( Display *dpy, GLXDrawable drawable ) 1566afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1567afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaBuffer buffer = XMesaFindBuffer( dpy, drawable ); 1568afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1569afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (buffer) { 1570afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaSwapBuffers(buffer); 1571afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1572367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul else if (_mesa_getenv("MESA_DEBUG")) { 1573ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul _mesa_warning(NULL, "glXSwapBuffers: invalid drawable 0x%x\n", 1574ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul (int) drawable); 1575afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1576afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1577afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1578afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 15794c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul 1580b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_MESA_copy_sub_buffer ***/ 1581b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul 1582426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1583426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCopySubBufferMESA( Display *dpy, GLXDrawable drawable, 1584426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul int x, int y, int width, int height ) 1585afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1586afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaBuffer buffer = XMesaFindBuffer( dpy, drawable ); 1587afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (buffer) { 1588afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaCopySubBuffer(buffer, x, y, width, height); 1589afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1590367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul else if (_mesa_getenv("MESA_DEBUG")) { 1591d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul _mesa_warning(NULL, "Mesa: glXCopySubBufferMESA: invalid drawable\n"); 1592afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1593afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1594afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1595afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1596426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool 1597426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryVersion( Display *dpy, int *maj, int *min ) 1598afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1599afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 1600afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Return GLX version, not Mesa version */ 160178fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul assert(CLIENT_MAJOR_VERSION == SERVER_MAJOR_VERSION); 160278fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul *maj = CLIENT_MAJOR_VERSION; 160378fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul *min = MIN2( CLIENT_MINOR_VERSION, SERVER_MINOR_VERSION ); 1604afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return True; 1605afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1606afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1607afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1608afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 1609afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Query the GLX attributes of the given XVisualInfo. 1610afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 1611426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int 1612e4656003caee346d9c4eb23256d73409271291a7Brian Paulget_config( XMesaVisual xmvis, int attrib, int *value, GLboolean fbconfig ) 1613afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1614e4656003caee346d9c4eb23256d73409271291a7Brian Paul ASSERT(xmvis); 1615afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch(attrib) { 1616afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_USE_GL: 16171f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul if (fbconfig) 16181f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul return GLX_BAD_ATTRIBUTE; 1619afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = (int) True; 1620afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1621afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_BUFFER_SIZE: 1622e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->visinfo->depth; 1623afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1624afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_LEVEL: 1625304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick *value = xmvis->mesa_visual.level; 1626afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1627afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_RGBA: 16281f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul if (fbconfig) 16291f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul return GLX_BAD_ATTRIBUTE; 1630e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (xmvis->mesa_visual.rgbMode) { 1631afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = True; 1632afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1633afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 1634afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = False; 1635afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1636afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1637afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_DOUBLEBUFFER: 1638e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = (int) xmvis->mesa_visual.doubleBufferMode; 1639afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1640afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STEREO: 1641e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = (int) xmvis->mesa_visual.stereoMode; 1642afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1643afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_AUX_BUFFERS: 1644894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul *value = xmvis->mesa_visual.numAuxBuffers; 1645afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1646afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_RED_SIZE: 1647e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->mesa_visual.redBits; 1648afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1649afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_GREEN_SIZE: 1650e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->mesa_visual.greenBits; 1651afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1652afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_BLUE_SIZE: 1653e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->mesa_visual.blueBits; 1654afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1655afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ALPHA_SIZE: 1656e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->mesa_visual.alphaBits; 1657afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1658afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_DEPTH_SIZE: 1659e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->mesa_visual.depthBits; 1660afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1661afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STENCIL_SIZE: 1662e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->mesa_visual.stencilBits; 1663afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1664afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_RED_SIZE: 1665e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->mesa_visual.accumRedBits; 1666b2e460018375f699198073a6167e0ee96ba1d267Brian Paul return 0; 1667afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_GREEN_SIZE: 1668e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->mesa_visual.accumGreenBits; 1669b2e460018375f699198073a6167e0ee96ba1d267Brian Paul return 0; 1670afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_BLUE_SIZE: 1671e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->mesa_visual.accumBlueBits; 1672afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1673afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_ALPHA_SIZE: 1674e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->mesa_visual.accumAlphaBits; 1675afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1676afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1677afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* 1678afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * GLX_EXT_visual_info extension 1679afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 1680afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_X_VISUAL_TYPE_EXT: 1681e4656003caee346d9c4eb23256d73409271291a7Brian Paul switch (xmvis->visinfo->CLASS) { 1682afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case StaticGray: *value = GLX_STATIC_GRAY_EXT; return 0; 1683afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GrayScale: *value = GLX_GRAY_SCALE_EXT; return 0; 1684afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case StaticColor: *value = GLX_STATIC_GRAY_EXT; return 0; 1685afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case PseudoColor: *value = GLX_PSEUDO_COLOR_EXT; return 0; 1686afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case TrueColor: *value = GLX_TRUE_COLOR_EXT; return 0; 1687afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case DirectColor: *value = GLX_DIRECT_COLOR_EXT; return 0; 1688afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1689afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1690afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_TYPE_EXT: 1691304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick if (xmvis->mesa_visual.level==0) { 1692afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* normal planes */ 1693afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = GLX_NONE_EXT; 1694afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1695304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick else if (xmvis->mesa_visual.level>0) { 1696afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* overlay */ 1697e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (xmvis->mesa_visual.rgbMode) { 1698afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = GLX_TRANSPARENT_RGB_EXT; 1699afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1700afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 1701afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = GLX_TRANSPARENT_INDEX_EXT; 1702afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1703afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1704304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick else if (xmvis->mesa_visual.level<0) { 1705afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* underlay */ 1706afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = GLX_NONE_EXT; 1707afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1708afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1709afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_INDEX_VALUE_EXT: 1710afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg { 1711e4656003caee346d9c4eb23256d73409271291a7Brian Paul int pixel = transparent_pixel( xmvis ); 1712afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (pixel>=0) { 1713afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = pixel; 1714afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1715afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* else undefined */ 1716afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1717afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1718afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_RED_VALUE_EXT: 1719afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* undefined */ 1720afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1721afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_GREEN_VALUE_EXT: 1722afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* undefined */ 1723afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1724afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_BLUE_VALUE_EXT: 1725afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* undefined */ 1726afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1727afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_ALPHA_VALUE_EXT: 1728afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* undefined */ 1729afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1730afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1731afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* 1732b2e460018375f699198073a6167e0ee96ba1d267Brian Paul * GLX_EXT_visual_info extension 1733b2e460018375f699198073a6167e0ee96ba1d267Brian Paul */ 1734b2e460018375f699198073a6167e0ee96ba1d267Brian Paul case GLX_VISUAL_CAVEAT_EXT: 1735fc68be6b111473a0bf8f991468f973bb9dd275f4Brian Paul /* test for zero, just in case */ 1736304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick if (xmvis->mesa_visual.visualRating > 0) 1737304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick *value = xmvis->mesa_visual.visualRating; 1738962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul else 1739962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul *value = GLX_NONE_EXT; 1740962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul return 0; 1741b2e460018375f699198073a6167e0ee96ba1d267Brian Paul 1742b2e460018375f699198073a6167e0ee96ba1d267Brian Paul /* 174366ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul * GLX_ARB_multisample 1744afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 174566ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul case GLX_SAMPLE_BUFFERS_ARB: 17463265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul *value = 0; 17473265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return 0; 174866ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul case GLX_SAMPLES_ARB: 17493265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul *value = 0; 17503265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return 0; 17513265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul 17523265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul /* 17533265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul * For FBConfigs: 17543265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul */ 17553265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_SCREEN_EXT: 17563265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (!fbconfig) 17573265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return GLX_BAD_ATTRIBUTE; 1758e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->visinfo->screen; 17593265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 17603265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_DRAWABLE_TYPE: /*SGIX too */ 17613265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (!fbconfig) 17623265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return GLX_BAD_ATTRIBUTE; 17633265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul *value = GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT; 17643265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 17653265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_RENDER_TYPE_SGIX: 17663265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (!fbconfig) 17673265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return GLX_BAD_ATTRIBUTE; 1768e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (xmvis->mesa_visual.rgbMode) 17693265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul *value = GLX_RGBA_BIT; 17703265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul else 17713265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul *value = GLX_COLOR_INDEX_BIT; 17723265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 17733265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_X_RENDERABLE_SGIX: 17743265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (!fbconfig) 17753265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return GLX_BAD_ATTRIBUTE; 17763265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul *value = True; /* XXX really? */ 17773265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 17783265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_FBCONFIG_ID_SGIX: 17793265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (!fbconfig) 17803265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return GLX_BAD_ATTRIBUTE; 1781f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul *value = xmvis->visinfo->visualid; 17823265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 17833265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_MAX_PBUFFER_WIDTH: 17843265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (!fbconfig) 17853265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return GLX_BAD_ATTRIBUTE; 17863265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul /* XXX or MAX_WIDTH? */ 1787f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul *value = DisplayWidth(xmvis->display, xmvis->visinfo->screen); 17883265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 17893265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_MAX_PBUFFER_HEIGHT: 17903265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (!fbconfig) 17913265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return GLX_BAD_ATTRIBUTE; 1792f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul *value = DisplayHeight(xmvis->display, xmvis->visinfo->screen); 17933265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 17943265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_MAX_PBUFFER_PIXELS: 17953265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (!fbconfig) 17963265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return GLX_BAD_ATTRIBUTE; 1797f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul *value = DisplayWidth(xmvis->display, xmvis->visinfo->screen) * 1798f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul DisplayHeight(xmvis->display, xmvis->visinfo->screen); 17993265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 18003265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_VISUAL_ID: 18013265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (!fbconfig) 18023265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return GLX_BAD_ATTRIBUTE; 1803f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul *value = xmvis->visinfo->visualid; 18043265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 18053265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul 1806fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian#ifdef GLX_EXT_texture_from_pixmap 1807fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_BIND_TO_TEXTURE_RGB_EXT: 1808fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian *value = True; /*XXX*/ 1809fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 1810fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_BIND_TO_TEXTURE_RGBA_EXT: 1811fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian /* XXX review */ 1812fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian *value = xmvis->mesa_visual.alphaBits > 0 ? True : False; 1813fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 1814fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_BIND_TO_MIPMAP_TEXTURE_EXT: 1815fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian *value = True; /*XXX*/ 1816fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 1817fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_BIND_TO_TEXTURE_TARGETS_EXT: 1818fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian *value = (GLX_TEXTURE_1D_BIT_EXT | 1819fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian GLX_TEXTURE_2D_BIT_EXT | 1820fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian GLX_TEXTURE_RECTANGLE_BIT_EXT); /*XXX*/ 1821fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 1822fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_Y_INVERTED_EXT: 1823a10ba38df7ac80e36db15aaae9f78e7223b2bfaeBrian *value = True; /*XXX*/ 1824fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 1825fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian#endif 1826fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian 1827afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: 1828afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return GLX_BAD_ATTRIBUTE; 1829afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 18303265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return Success; 1831afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1832afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1833afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 18343265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paulstatic int 18353265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian PaulFake_glXGetConfig( Display *dpy, XVisualInfo *visinfo, 18363265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul int attrib, int *value ) 18373265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul{ 1838e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaVisual xmvis; 1839ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul int k; 1840379641956d134b8dc761b6411d7c4dca8f94a092Brian Paul if (!dpy || !visinfo) 1841a9a1c3f20f2d6aad4afc47cf2b29c5393fddb6b6Brian Paul return GLX_BAD_ATTRIBUTE; 1842a9a1c3f20f2d6aad4afc47cf2b29c5393fddb6b6Brian Paul 1843e4656003caee346d9c4eb23256d73409271291a7Brian Paul xmvis = find_glx_visual( dpy, visinfo ); 1844e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (!xmvis) { 18453265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul /* this visual wasn't obtained with glXChooseVisual */ 1846e4656003caee346d9c4eb23256d73409271291a7Brian Paul xmvis = create_glx_visual( dpy, visinfo ); 1847e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (!xmvis) { 18483265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul /* this visual can't be used for GL rendering */ 18493265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (attrib==GLX_USE_GL) { 18503265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul *value = (int) False; 18513265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return 0; 18523265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 18533265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul else { 18543265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return GLX_BAD_VISUAL; 18553265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 18563265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 18573265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 18583265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul 1859ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul k = get_config(xmvis, attrib, value, GL_FALSE); 1860ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul return k; 18613265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul} 18623265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul 1863afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1864426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1865426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXWaitGL( void ) 1866afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1867afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaContext xmesa = XMesaGetCurrentContext(); 1868afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaFlush( xmesa ); 1869afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1870afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1871afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1872afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1873426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1874426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXWaitX( void ) 1875afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1876afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaContext xmesa = XMesaGetCurrentContext(); 1877afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaFlush( xmesa ); 1878afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1879afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1880afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1881e4656003caee346d9c4eb23256d73409271291a7Brian Paulstatic const char * 1882e4656003caee346d9c4eb23256d73409271291a7Brian Paulget_extensions( void ) 188343c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul{ 1884e4656003caee346d9c4eb23256d73409271291a7Brian Paul return EXTENSIONS + 23; /* skip "GLX_MESA_set_3dfx_mode" */ 188543c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul} 1886afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1887afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1888afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1889afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* GLX 1.1 and later */ 1890426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic const char * 1891426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryExtensionsString( Display *dpy, int screen ) 1892afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1893afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 1894afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) screen; 189543c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul return get_extensions(); 1896afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1897afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1898afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1899afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1900afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* GLX 1.1 and later */ 1901426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic const char * 1902426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryServerString( Display *dpy, int screen, int name ) 1903afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 190478fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul static char version[1000]; 1905298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg sprintf(version, "%d.%d %s", 1906298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg SERVER_MAJOR_VERSION, SERVER_MINOR_VERSION, MESA_GLX_VERSION); 1907afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1908afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 1909afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) screen; 1910afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1911afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (name) { 1912afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_EXTENSIONS: 191343c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul return get_extensions(); 1914afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_VENDOR: 191578fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul return VENDOR; 1916afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_VERSION: 1917afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return version; 1918afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: 1919afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 1920afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1921afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1922afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1923afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1924afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1925afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* GLX 1.1 and later */ 1926426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic const char * 1927426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetClientString( Display *dpy, int name ) 1928afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 192978fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul static char version[1000]; 1930298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg sprintf(version, "%d.%d %s", CLIENT_MAJOR_VERSION, 1931298be2b028263b2c343a707662c6fbfa18293cb2Kristian Høgsberg CLIENT_MINOR_VERSION, MESA_GLX_VERSION); 1932afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1933afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 1934afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1935afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (name) { 1936afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_EXTENSIONS: 193743c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul return get_extensions(); 1938afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_VENDOR: 193978fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul return VENDOR; 1940afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_VERSION: 1941afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return version; 1942afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: 1943afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 1944afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1945afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1946afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1947afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1948afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1949426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul/* 1950426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul * GLX 1.3 and later 1951426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul */ 1952426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 19537d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 1954426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int 1955426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetFBConfigAttrib( Display *dpy, GLXFBConfig config, 1956426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul int attribute, int *value ) 1957426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 19583265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul XMesaVisual v = (XMesaVisual) config; 1959426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 1960426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) config; 19617d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 19627d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul if (!dpy || !config || !value) 19637d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return -1; 19647d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 19653265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return get_config(v, attribute, value, GL_TRUE); 1966426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1967426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1968426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 19695605798e56ca6e9f968623f33b58ee7ca90594afBrian Paulstatic GLXFBConfig * 19705605798e56ca6e9f968623f33b58ee7ca90594afBrian PaulFake_glXGetFBConfigs( Display *dpy, int screen, int *nelements ) 19715605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul{ 19723265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul XVisualInfo *visuals, visTemplate; 19733265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul const long visMask = VisualScreenMask; 19743265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul int i; 19753265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul 19763265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul /* Get list of all X visuals */ 19773265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul visTemplate.screen = screen; 19783265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul visuals = XGetVisualInfo(dpy, visMask, &visTemplate, nelements); 19793265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (*nelements > 0) { 19803265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul XMesaVisual *results; 198132f2fd1c5d6088692551c80352b7d6fa35b0cd09Kristian Høgsberg results = (XMesaVisual *) malloc(*nelements * sizeof(XMesaVisual)); 19823265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (!results) { 19833265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul *nelements = 0; 19843265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return NULL; 19853265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 19863265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul for (i = 0; i < *nelements; i++) { 19873265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul results[i] = create_glx_visual(dpy, visuals + i); 19883265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 19893265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return (GLXFBConfig *) results; 19903265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 19913265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return NULL; 19925605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul} 19935605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul 19945605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul 1995481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paulstatic GLXFBConfig * 1996481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian PaulFake_glXChooseFBConfig( Display *dpy, int screen, 1997481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul const int *attribList, int *nitems ) 1998481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul{ 1999481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul XMesaVisual xmvis; 2000481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul 2001ecbdb173bbe3e37b4cbc6b08a5ba5a70236a0d1dBrian Paul /* register ourselves as an extension on this display */ 2002ecbdb173bbe3e37b4cbc6b08a5ba5a70236a0d1dBrian Paul register_with_display(dpy); 2003ecbdb173bbe3e37b4cbc6b08a5ba5a70236a0d1dBrian Paul 2004481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul if (!attribList || !attribList[0]) { 2005481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul /* return list of all configs (per GLX_SGIX_fbconfig spec) */ 2006481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul return Fake_glXGetFBConfigs(dpy, screen, nitems); 2007481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul } 2008481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul 2009481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul xmvis = choose_visual(dpy, screen, attribList, GL_TRUE); 2010481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul if (xmvis) { 201132f2fd1c5d6088692551c80352b7d6fa35b0cd09Kristian Høgsberg GLXFBConfig *config = (GLXFBConfig *) malloc(sizeof(XMesaVisual)); 2012481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul if (!config) { 2013481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul *nitems = 0; 2014481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul return NULL; 2015481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul } 2016481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul *nitems = 1; 2017481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul config[0] = (GLXFBConfig) xmvis; 2018481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul return (GLXFBConfig *) config; 2019481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul } 2020481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul else { 2021481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul *nitems = 0; 2022481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul return NULL; 2023481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul } 2024481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul} 2025481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul 2026481bdd383ac309cda8e471215b8fd3d6b5fa8cadBrian Paul 2027426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic XVisualInfo * 2028426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetVisualFromFBConfig( Display *dpy, GLXFBConfig config ) 2029426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 20307d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul if (dpy && config) { 2031f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul XMesaVisual xmvis = (XMesaVisual) config; 2032f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul#if 0 2033f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul return xmvis->vishandle; 2034f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul#else 2035f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul /* create a new vishandle - the cached one may be stale */ 203632f2fd1c5d6088692551c80352b7d6fa35b0cd09Kristian Høgsberg xmvis->vishandle = (XVisualInfo *) malloc(sizeof(XVisualInfo)); 2037f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul if (xmvis->vishandle) { 2038c7ac486261ad30ef654f6d0b1608da4e8483cd40Kenneth Graunke memcpy(xmvis->vishandle, xmvis->visinfo, sizeof(XVisualInfo)); 2039f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul } 2040f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul return xmvis->vishandle; 2041f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul#endif 20427d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul } 20437d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul else { 20447d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return NULL; 20457d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul } 2046426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2047426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2048426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2049426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXWindow 2050426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateWindow( Display *dpy, GLXFBConfig config, Window win, 2051426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul const int *attribList ) 2052426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 2053529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul XMesaVisual xmvis = (XMesaVisual) config; 2054529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul XMesaBuffer xmbuf; 2055529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul if (!xmvis) 2056529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul return 0; 2057529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul 20586aa5668871e7f366b33e85fabc72885fc269a7d4George Sapountzis xmbuf = XMesaCreateWindowBuffer(xmvis, win); 2059529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul if (!xmbuf) 2060529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul return 0; 2061529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul 2062426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 20637d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul (void) attribList; /* Ignored in GLX 1.3 */ 20647d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 20657d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return win; /* A hack for now */ 2066426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2067426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2068426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2069426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 2070426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyWindow( Display *dpy, GLXWindow window ) 2071426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 20727d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul XMesaBuffer b = XMesaFindBuffer(dpy, (XMesaDrawable) window); 20737d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul if (b) 20747d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul XMesaDestroyBuffer(b); 20757d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul /* don't destroy X window */ 2076426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2077426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2078426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 20797d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul/* XXX untested */ 2080426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPixmap 2081426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreatePixmap( Display *dpy, GLXFBConfig config, Pixmap pixmap, 2082426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul const int *attribList ) 2083426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 20847d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul XMesaVisual v = (XMesaVisual) config; 20857d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul XMesaBuffer b; 2086fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian const int *attr; 2087fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian int target = 0, format = 0, mipmap = 0; 2088fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian int value; 20897d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 20907d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul if (!dpy || !config || !pixmap) 20917d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return 0; 20927d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 2093d18c57aaeac37cde0cb551191ecd3c3a56a0ffbaBrian Paul for (attr = attribList; attr && *attr; attr++) { 2094fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian switch (*attr) { 2095fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_TEXTURE_FORMAT_EXT: 2096fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian attr++; 2097fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian switch (*attr) { 2098fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_TEXTURE_FORMAT_NONE_EXT: 2099fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_TEXTURE_FORMAT_RGB_EXT: 2100fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_TEXTURE_FORMAT_RGBA_EXT: 2101fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian format = *attr; 2102fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 2103fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian default: 2104fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian /* error */ 2105fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian return 0; 2106fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2107fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 2108fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_TEXTURE_TARGET_EXT: 2109fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian attr++; 2110fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian switch (*attr) { 2111fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_TEXTURE_1D_EXT: 2112fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_TEXTURE_2D_EXT: 2113fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_TEXTURE_RECTANGLE_EXT: 2114fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian target = *attr; 2115fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 2116fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian default: 2117fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian /* error */ 2118fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian return 0; 2119fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2120fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 2121fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_MIPMAP_TEXTURE_EXT: 2122fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian attr++; 2123fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (*attr) 2124fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian mipmap = 1; 2125fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 2126fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian default: 2127fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian /* error */ 2128fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian return 0; 2129fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2130fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2131fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian 2132fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (format == GLX_TEXTURE_FORMAT_RGB_EXT) { 2133fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (get_config(v, GLX_BIND_TO_TEXTURE_RGB_EXT, 2134fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian &value, GL_TRUE) != Success 2135fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian || !value) { 2136fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian return 0; /* error! */ 2137fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2138fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2139fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian else if (format == GLX_TEXTURE_FORMAT_RGBA_EXT) { 2140fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (get_config(v, GLX_BIND_TO_TEXTURE_RGBA_EXT, 2141fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian &value, GL_TRUE) != Success 2142fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian || !value) { 2143fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian return 0; /* error! */ 2144fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2145fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2146fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (mipmap) { 2147fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (get_config(v, GLX_BIND_TO_MIPMAP_TEXTURE_EXT, 2148fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian &value, GL_TRUE) != Success 2149fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian || !value) { 2150fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian return 0; /* error! */ 2151fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2152fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2153fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (target == GLX_TEXTURE_1D_EXT) { 2154fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (get_config(v, GLX_BIND_TO_TEXTURE_TARGETS_EXT, 2155fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian &value, GL_TRUE) != Success 2156fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian || (value & GLX_TEXTURE_1D_BIT_EXT) == 0) { 2157fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian return 0; /* error! */ 2158fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2159fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2160fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian else if (target == GLX_TEXTURE_2D_EXT) { 2161fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (get_config(v, GLX_BIND_TO_TEXTURE_TARGETS_EXT, 2162fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian &value, GL_TRUE) != Success 2163fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian || (value & GLX_TEXTURE_2D_BIT_EXT) == 0) { 2164fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian return 0; /* error! */ 2165fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2166fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2167fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (target == GLX_TEXTURE_RECTANGLE_EXT) { 2168fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (get_config(v, GLX_BIND_TO_TEXTURE_TARGETS_EXT, 2169fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian &value, GL_TRUE) != Success 2170fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian || (value & GLX_TEXTURE_RECTANGLE_BIT_EXT) == 0) { 2171fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian return 0; /* error! */ 2172fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2173fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2174fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian 2175fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (format || target || mipmap) { 2176fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian /* texture from pixmap */ 2177fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian b = XMesaCreatePixmapTextureBuffer(v, pixmap, 0, format, target, mipmap); 2178fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 2179fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian else { 2180fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian b = XMesaCreatePixmapBuffer( v, pixmap, 0 ); 2181fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian } 21827d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul if (!b) { 21837d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return 0; 21847d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul } 21857d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 21867d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return pixmap; 2187426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2188426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2189426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2190426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 2191426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyPixmap( Display *dpy, GLXPixmap pixmap ) 2192426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 21937d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul XMesaBuffer b = XMesaFindBuffer(dpy, (XMesaDrawable)pixmap); 21947d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul if (b) 21957d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul XMesaDestroyBuffer(b); 21967d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul /* don't destroy X pixmap */ 2197426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2198426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2199426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2200426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPbuffer 2201426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreatePbuffer( Display *dpy, GLXFBConfig config, 2202426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul const int *attribList ) 2203426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 22043265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul XMesaVisual xmvis = (XMesaVisual) config; 22053265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul XMesaBuffer xmbuf; 22067d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul const int *attrib; 22077d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul int width = 0, height = 0; 22087d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul GLboolean useLargest = GL_FALSE, preserveContents = GL_FALSE; 22097d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 2210426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 22117d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 22123265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul for (attrib = attribList; *attrib; attrib++) { 22137d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul switch (*attrib) { 22147d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_PBUFFER_WIDTH: 22153265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul attrib++; 22163265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul width = *attrib; 22177d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul break; 22187d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_PBUFFER_HEIGHT: 22193265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul attrib++; 22203265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul height = *attrib; 22217d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul break; 22227d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_PRESERVED_CONTENTS: 22233265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul attrib++; 2224c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul preserveContents = *attrib; 22257d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul break; 22267d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_LARGEST_PBUFFER: 22273265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul attrib++; 2228c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul useLargest = *attrib; 22297d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul break; 22307d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul default: 22317d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return 0; 22327d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul } 22337d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul } 22347d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 22357d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul if (width == 0 || height == 0) 22367d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return 0; 22377d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 22383f8a61ffa256b4fe36e93a0904b8893c805eb313Brian Paul if (width > SWRAST_MAX_WIDTH || height > SWRAST_MAX_HEIGHT) { 2239c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul /* If allocation would have failed and GLX_LARGEST_PBUFFER is set, 2240c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul * allocate the largest possible buffer. 2241c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul */ 2242c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul if (useLargest) { 22433f8a61ffa256b4fe36e93a0904b8893c805eb313Brian Paul width = SWRAST_MAX_WIDTH; 22443f8a61ffa256b4fe36e93a0904b8893c805eb313Brian Paul height = SWRAST_MAX_HEIGHT; 2245c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul } 2246c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul } 2247c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul 22483265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul xmbuf = XMesaCreatePBuffer( xmvis, 0, width, height); 2249e4656003caee346d9c4eb23256d73409271291a7Brian Paul /* A GLXPbuffer handle must be an X Drawable because that's what 2250e4656003caee346d9c4eb23256d73409271291a7Brian Paul * glXMakeCurrent takes. 2251e4656003caee346d9c4eb23256d73409271291a7Brian Paul */ 2252c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul if (xmbuf) { 2253c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul xmbuf->largestPbuffer = useLargest; 2254c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul xmbuf->preservedContents = preserveContents; 2255dd1a9f75dc1d29e3383f27aaa1cf024c83e5c8e2Brian Paul return (GLXPbuffer) xmbuf->frontxrb->pixmap; 2256c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul } 2257c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul else { 2258dd1a9f75dc1d29e3383f27aaa1cf024c83e5c8e2Brian Paul return 0; 2259c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul } 2260426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2261426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2262426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2263426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 2264426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyPbuffer( Display *dpy, GLXPbuffer pbuf ) 2265426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 2266e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaBuffer b = XMesaFindBuffer(dpy, pbuf); 2267e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (b) { 2268e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaDestroyBuffer(b); 2269e4656003caee346d9c4eb23256d73409271291a7Brian Paul } 2270426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2271426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2272426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2273426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 2274426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryDrawable( Display *dpy, GLXDrawable draw, int attribute, 2275426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul unsigned int *value ) 2276426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 2277e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaBuffer xmbuf = XMesaFindBuffer(dpy, draw); 2278e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (!xmbuf) 2279e4656003caee346d9c4eb23256d73409271291a7Brian Paul return; 22807d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 2281c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul /* make sure buffer's dimensions are up to date */ 2282c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul xmesa_check_and_update_buffer_size(NULL, xmbuf); 2283c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul 22847d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul switch (attribute) { 22857d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_WIDTH: 228629926a11b16ec7a235947d95e9a46777605dd30eBrian Paul *value = xmbuf->mesa_buffer.Width; 2287e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 22887d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_HEIGHT: 228929926a11b16ec7a235947d95e9a46777605dd30eBrian Paul *value = xmbuf->mesa_buffer.Height; 2290e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 22917d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_PRESERVED_CONTENTS: 2292c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul *value = xmbuf->preservedContents; 2293e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 22947d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_LARGEST_PBUFFER: 2295c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul *value = xmbuf->largestPbuffer; 2296e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 22977d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_FBCONFIG_ID: 2298f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul *value = xmbuf->xm_visual->visinfo->visualid; 22997d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return; 2300fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian#ifdef GLX_EXT_texture_from_pixmap 2301fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_TEXTURE_FORMAT_EXT: 2302fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian *value = xmbuf->TextureFormat; 2303fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 2304fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_TEXTURE_TARGET_EXT: 2305fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian *value = xmbuf->TextureTarget; 2306fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 2307fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian case GLX_MIPMAP_TEXTURE_EXT: 2308fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian *value = xmbuf->TextureMipmap; 2309fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian break; 2310fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian#endif 2311fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian 23127d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul default: 2313fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian return; /* raise BadValue error */ 23147d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul } 2315426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2316426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2317426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2318426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXContext 2319426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateNewContext( Display *dpy, GLXFBConfig config, 2320426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul int renderType, GLXContext shareList, Bool direct ) 2321426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 2322f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul struct fake_glx_context *glxCtx; 2323f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul struct fake_glx_context *shareCtx = (struct fake_glx_context *) shareList; 2324f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul XMesaVisual xmvis = (XMesaVisual) config; 23257d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 23267d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul if (!dpy || !config || 23277d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul (renderType != GLX_RGBA_TYPE && renderType != GLX_COLOR_INDEX_TYPE)) 23287d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return 0; 23297d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 2330f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul glxCtx = CALLOC_STRUCT(fake_glx_context); 2331f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul if (!glxCtx) 2332f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul return 0; 2333f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul 2334f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul /* deallocate unused windows/buffers */ 233590e227f0791cb585dc4e4e1f71e32c67f5e20436Andy Skinner XMesaGarbageCollect(dpy); 2336f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul 2337f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul glxCtx->xmesaContext = XMesaCreateContext(xmvis, 2338f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul shareCtx ? shareCtx->xmesaContext : NULL); 2339f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul if (!glxCtx->xmesaContext) { 234032f2fd1c5d6088692551c80352b7d6fa35b0cd09Kristian Høgsberg free(glxCtx); 2341f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul return NULL; 2342f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul } 2343f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul 234449e80bf6b163310f7cd776261872201eea57053aBrian Paul init_glx_context(glxCtx, dpy); 2345f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul 2346f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul return (GLXContext) glxCtx; 2347426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2348426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2349426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2350426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int 2351426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryContext( Display *dpy, GLXContext ctx, int attribute, int *value ) 2352426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 2353e4656003caee346d9c4eb23256d73409271291a7Brian Paul struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx; 2354e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaContext xmctx = glxCtx->xmesaContext; 2355e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2356426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 2357426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) ctx; 23587d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 23597d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul switch (attribute) { 23607d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_FBCONFIG_ID: 2361f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul *value = xmctx->xm_visual->visinfo->visualid; 2362e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 23637d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_RENDER_TYPE: 236481fe9949ef0293f7a6e076bd6e56f6a5340a1dc3Ian Romanick *value = GLX_RGBA_TYPE; 2365e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 23667d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_SCREEN: 23677d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul *value = 0; 23687d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return Success; 23697d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul default: 23707d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return GLX_BAD_ATTRIBUTE; 23717d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul } 2372e4656003caee346d9c4eb23256d73409271291a7Brian Paul return 0; 2373426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2374426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2375426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2376426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 2377426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXSelectEvent( Display *dpy, GLXDrawable drawable, unsigned long mask ) 2378426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 2379e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable); 2380e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (xmbuf) 2381e4656003caee346d9c4eb23256d73409271291a7Brian Paul xmbuf->selectedEvents = mask; 2382426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2383426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2384426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2385426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 2386426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetSelectedEvent( Display *dpy, GLXDrawable drawable, 2387426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul unsigned long *mask ) 2388426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 2389e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable); 2390e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (xmbuf) 2391e4656003caee346d9c4eb23256d73409271291a7Brian Paul *mask = xmbuf->selectedEvents; 2392e4656003caee346d9c4eb23256d73409271291a7Brian Paul else 2393e4656003caee346d9c4eb23256d73409271291a7Brian Paul *mask = 0; 2394426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2395b82d993b03320818f88f792a9e713f7ed491bfcbBrian Paul 2396b82d993b03320818f88f792a9e713f7ed491bfcbBrian Paul 2397b82d993b03320818f88f792a9e713f7ed491bfcbBrian Paul 2398b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGI_swap_control ***/ 2399783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2400783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int 2401783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXSwapIntervalSGI(int interval) 2402783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2403783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) interval; 2404783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2405783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2406783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2407783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2408783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2409b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGI_video_sync ***/ 2410783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2411ee061060826df059f0ddb904a2160ed610423579Brian Paulstatic unsigned int FrameCounter = 0; 2412ee061060826df059f0ddb904a2160ed610423579Brian Paul 2413783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int 2414783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetVideoSyncSGI(unsigned int *count) 2415783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2416ee061060826df059f0ddb904a2160ed610423579Brian Paul /* this is a bogus implementation */ 2417ee061060826df059f0ddb904a2160ed610423579Brian Paul *count = FrameCounter++; 2418783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2419783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2420783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2421783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int 2422783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count) 2423783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2424ee061060826df059f0ddb904a2160ed610423579Brian Paul if (divisor <= 0 || remainder < 0) 2425ee061060826df059f0ddb904a2160ed610423579Brian Paul return GLX_BAD_VALUE; 2426ee061060826df059f0ddb904a2160ed610423579Brian Paul /* this is a bogus implementation */ 2427ee061060826df059f0ddb904a2160ed610423579Brian Paul FrameCounter++; 2428ee061060826df059f0ddb904a2160ed610423579Brian Paul while (FrameCounter % divisor != remainder) 2429ee061060826df059f0ddb904a2160ed610423579Brian Paul FrameCounter++; 2430ee061060826df059f0ddb904a2160ed610423579Brian Paul *count = FrameCounter; 2431783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2432783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2433783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2434783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2435783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2436b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGI_make_current_read ***/ 2437783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2438426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool 2439783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXMakeCurrentReadSGI(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx) 2440afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 2441a078d75a27b99252ede6520e24b145106ab98aa2Brian Paul return Fake_glXMakeContextCurrent( dpy, draw, read, ctx ); 2442afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 2443783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 24447cf50e137da497a590ec9001a9918972a6246142Brian Paul/* not used 2445783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXDrawable 2446b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian PaulFake_glXGetCurrentReadDrawableSGI(void) 2447783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2448783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2449783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 24507cf50e137da497a590ec9001a9918972a6246142Brian Paul*/ 2451afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 2452afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 2453b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_video_source ***/ 2454b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#if defined(_VL_H) 24554c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul 2456783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXVideoSourceSGIX 2457783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXCreateGLXVideoSourceSGIX(Display *dpy, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode) 2458afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 2459783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2460783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) screen; 2461783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) server; 2462783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) path; 2463783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) nodeClass; 2464783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) drainNode; 2465783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2466783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2467783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2468783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void 2469783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXDestroyGLXVideoSourceSGIX(Display *dpy, GLXVideoSourceSGIX src) 2470783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2471783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2472783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) src; 2473afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 2474783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 24754c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul#endif 24764c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul 247789a42b7e736bd9b0ab090906cab0cd047a6ec12eBrian Paul 2478b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_EXT_import_context ***/ 247989a42b7e736bd9b0ab090906cab0cd047a6ec12eBrian Paul 2480783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void 2481783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXFreeContextEXT(Display *dpy, GLXContext context) 2482783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2483783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2484783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) context; 2485783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2486426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2487783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXContextID 2488783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetContextIDEXT(const GLXContext context) 2489783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2490783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) context; 2491783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2492783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2493783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2494783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXContext 2495783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXImportContextEXT(Display *dpy, GLXContextID contextID) 2496783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2497783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2498783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) contextID; 2499783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2500783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2501426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2502426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int 2503783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryContextInfoEXT(Display *dpy, GLXContext context, int attribute, int *value) 2504426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 2505783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2506783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) context; 2507783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) attribute; 2508783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) value; 2509426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul return 0; 2510426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2511426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2512783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2513783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2514b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_fbconfig ***/ 2515426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2516426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int 2517783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetFBConfigAttribSGIX(Display *dpy, GLXFBConfigSGIX config, int attribute, int *value) 2518783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 25193265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return Fake_glXGetFBConfigAttrib(dpy, config, attribute, value); 2520783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2521783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2522783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXFBConfigSGIX * 2523783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXChooseFBConfigSGIX(Display *dpy, int screen, int *attrib_list, int *nelements) 2524783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 25253265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return (GLXFBConfig *) Fake_glXChooseFBConfig(dpy, screen, attrib_list, nelements); 2526783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2527783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2528e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2529783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXPixmap 2530783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXCreateGLXPixmapWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap) 2531783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2532e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaVisual xmvis = (XMesaVisual) config; 2533e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaBuffer xmbuf = XMesaCreatePixmapBuffer(xmvis, pixmap, 0); 2534e4b2356c07d31fbeeabb13b2fb47db703b473080Brian Paul return xmbuf->frontxrb->pixmap; /* need to return an X ID */ 2535783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2536783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2537e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2538783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXContext 2539783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct) 2540783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2541e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaVisual xmvis = (XMesaVisual) config; 2542e4656003caee346d9c4eb23256d73409271291a7Brian Paul struct fake_glx_context *glxCtx; 2543e4656003caee346d9c4eb23256d73409271291a7Brian Paul struct fake_glx_context *shareCtx = (struct fake_glx_context *) share_list; 2544e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2545e4656003caee346d9c4eb23256d73409271291a7Brian Paul glxCtx = CALLOC_STRUCT(fake_glx_context); 2546e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (!glxCtx) 2547e4656003caee346d9c4eb23256d73409271291a7Brian Paul return 0; 2548e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2549e4656003caee346d9c4eb23256d73409271291a7Brian Paul /* deallocate unused windows/buffers */ 255090e227f0791cb585dc4e4e1f71e32c67f5e20436Andy Skinner XMesaGarbageCollect(dpy); 2551e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2552e4656003caee346d9c4eb23256d73409271291a7Brian Paul glxCtx->xmesaContext = XMesaCreateContext(xmvis, 2553e4656003caee346d9c4eb23256d73409271291a7Brian Paul shareCtx ? shareCtx->xmesaContext : NULL); 2554e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (!glxCtx->xmesaContext) { 255532f2fd1c5d6088692551c80352b7d6fa35b0cd09Kristian Høgsberg free(glxCtx); 2556e4656003caee346d9c4eb23256d73409271291a7Brian Paul return NULL; 2557e4656003caee346d9c4eb23256d73409271291a7Brian Paul } 2558e4656003caee346d9c4eb23256d73409271291a7Brian Paul 255949e80bf6b163310f7cd776261872201eea57053aBrian Paul init_glx_context(glxCtx, dpy); 2560e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2561e4656003caee346d9c4eb23256d73409271291a7Brian Paul return (GLXContext) glxCtx; 2562783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2563783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2564e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2565783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic XVisualInfo * 2566783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetVisualFromFBConfigSGIX(Display *dpy, GLXFBConfigSGIX config) 2567783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 25683265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return Fake_glXGetVisualFromFBConfig(dpy, config); 2569783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2570783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2571e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2572783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXFBConfigSGIX 2573783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetFBConfigFromVisualSGIX(Display *dpy, XVisualInfo *vis) 2574426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 2575e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaVisual xmvis = find_glx_visual(dpy, vis); 2576e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (!xmvis) { 2577e4656003caee346d9c4eb23256d73409271291a7Brian Paul /* This visual wasn't found with glXChooseVisual() */ 2578e4656003caee346d9c4eb23256d73409271291a7Brian Paul xmvis = create_glx_visual(dpy, vis); 2579e4656003caee346d9c4eb23256d73409271291a7Brian Paul } 2580e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2581e4656003caee346d9c4eb23256d73409271291a7Brian Paul return (GLXFBConfigSGIX) xmvis; 2582426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2583426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2584426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2585426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2586b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_pbuffer ***/ 2587783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2588783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXPbufferSGIX 25893265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian PaulFake_glXCreateGLXPbufferSGIX(Display *dpy, GLXFBConfigSGIX config, 25903265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul unsigned int width, unsigned int height, 25913265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul int *attribList) 2592783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 25933265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul XMesaVisual xmvis = (XMesaVisual) config; 25943265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul XMesaBuffer xmbuf; 25953265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul const int *attrib; 25963265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul GLboolean useLargest = GL_FALSE, preserveContents = GL_FALSE; 25973265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul 2598783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 25993265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul 260011b3028e7ba2fc3b985ab84d7227c290608f83f6Brian Paul for (attrib = attribList; attrib && *attrib; attrib++) { 26013265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul switch (*attrib) { 26023265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_PRESERVED_CONTENTS_SGIX: 26033265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul attrib++; 26043265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul preserveContents = *attrib; /* ignored */ 26053265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 26063265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_LARGEST_PBUFFER_SGIX: 26073265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul attrib++; 26083265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul useLargest = *attrib; /* ignored */ 26093265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 26103265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul default: 26113265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return 0; 26123265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 26133265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 26143265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul 2615b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul /* not used at this time */ 2616b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul (void) useLargest; 2617b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul (void) preserveContents; 2618b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul 26193265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul xmbuf = XMesaCreatePBuffer( xmvis, 0, width, height); 2620e4656003caee346d9c4eb23256d73409271291a7Brian Paul /* A GLXPbuffer handle must be an X Drawable because that's what 2621e4656003caee346d9c4eb23256d73409271291a7Brian Paul * glXMakeCurrent takes. 2622e4656003caee346d9c4eb23256d73409271291a7Brian Paul */ 2623e4b2356c07d31fbeeabb13b2fb47db703b473080Brian Paul return (GLXPbuffer) xmbuf->frontxrb->pixmap; 2624783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2625783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2626e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2627783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void 2628783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXDestroyGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf) 2629783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2630e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaBuffer xmbuf = XMesaFindBuffer(dpy, pbuf); 2631e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (xmbuf) { 2632e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaDestroyBuffer(xmbuf); 2633e4656003caee346d9c4eb23256d73409271291a7Brian Paul } 2634783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2635783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2636e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2637783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int 2638783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value) 2639783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2640e4656003caee346d9c4eb23256d73409271291a7Brian Paul const XMesaBuffer xmbuf = XMesaFindBuffer(dpy, pbuf); 2641e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2642e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (!xmbuf) { 2643e4656003caee346d9c4eb23256d73409271291a7Brian Paul /* Generate GLXBadPbufferSGIX for bad pbuffer */ 2644e4656003caee346d9c4eb23256d73409271291a7Brian Paul return 0; 2645e4656003caee346d9c4eb23256d73409271291a7Brian Paul } 2646e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2647e4656003caee346d9c4eb23256d73409271291a7Brian Paul switch (attribute) { 2648e4656003caee346d9c4eb23256d73409271291a7Brian Paul case GLX_PRESERVED_CONTENTS_SGIX: 2649c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul *value = xmbuf->preservedContents; 2650e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 2651e4656003caee346d9c4eb23256d73409271291a7Brian Paul case GLX_LARGEST_PBUFFER_SGIX: 2652c3eef6021a06d728aa4c8b882264f554f2d4b801Brian Paul *value = xmbuf->largestPbuffer; 2653e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 2654e4656003caee346d9c4eb23256d73409271291a7Brian Paul case GLX_WIDTH_SGIX: 265529926a11b16ec7a235947d95e9a46777605dd30eBrian Paul *value = xmbuf->mesa_buffer.Width; 2656e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 2657e4656003caee346d9c4eb23256d73409271291a7Brian Paul case GLX_HEIGHT_SGIX: 265829926a11b16ec7a235947d95e9a46777605dd30eBrian Paul *value = xmbuf->mesa_buffer.Height; 2659e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 2660e4656003caee346d9c4eb23256d73409271291a7Brian Paul case GLX_EVENT_MASK_SGIX: 2661e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = 0; /* XXX might be wrong */ 2662e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 2663e4656003caee346d9c4eb23256d73409271291a7Brian Paul default: 2664e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = 0; 2665e4656003caee346d9c4eb23256d73409271291a7Brian Paul } 2666783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2667783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2668783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2669e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2670783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void 2671783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXSelectEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long mask) 2672783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2673e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable); 2674e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (xmbuf) { 2675e4656003caee346d9c4eb23256d73409271291a7Brian Paul /* Note: we'll never generate clobber events */ 2676e4656003caee346d9c4eb23256d73409271291a7Brian Paul xmbuf->selectedEvents = mask; 2677e4656003caee346d9c4eb23256d73409271291a7Brian Paul } 2678783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2679783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2680e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2681783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void 2682783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetSelectedEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long *mask) 2683783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2684e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable); 2685e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (xmbuf) { 2686e4656003caee346d9c4eb23256d73409271291a7Brian Paul *mask = xmbuf->selectedEvents; 2687e4656003caee346d9c4eb23256d73409271291a7Brian Paul } 2688e4656003caee346d9c4eb23256d73409271291a7Brian Paul else { 2689e4656003caee346d9c4eb23256d73409271291a7Brian Paul *mask = 0; 2690e4656003caee346d9c4eb23256d73409271291a7Brian Paul } 2691783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2692783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2693783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2694783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2695b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGI_cushion ***/ 2696783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2697783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void 2698783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXCushionSGI(Display *dpy, Window win, float cushion) 2699783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2700783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2701783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) win; 2702783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) cushion; 2703783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2704783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2705783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2706783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2707b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_video_resize ***/ 2708783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2709783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int 2710783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXBindChannelToWindowSGIX(Display *dpy, int screen, int channel , Window window) 2711783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2712783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2713783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) screen; 2714783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) channel; 2715783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) window; 2716783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2717783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2718783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2719783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int 2720783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXChannelRectSGIX(Display *dpy, int screen, int channel, int x, int y, int w, int h) 2721783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2722783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2723783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) screen; 2724783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) channel; 2725783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) x; 2726783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) y; 2727783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) w; 2728783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) h; 2729783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2730783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2731783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2732783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int 2733783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryChannelRectSGIX(Display *dpy, int screen, int channel, int *x, int *y, int *w, int *h) 2734783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2735783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2736783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) screen; 2737783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) channel; 2738783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) x; 2739783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) y; 2740783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) w; 2741783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) h; 2742783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2743783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2744783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2745783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int 2746783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryChannelDeltasSGIX(Display *dpy, int screen, int channel, int *dx, int *dy, int *dw, int *dh) 2747783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2748783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2749783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) screen; 2750783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) channel; 2751783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dx; 2752783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dy; 2753783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dw; 2754783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dh; 2755783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2756783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2757783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2758783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int 2759783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXChannelRectSyncSGIX(Display *dpy, int screen, int channel, GLenum synctype) 2760783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2761783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2762783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) screen; 2763783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) channel; 2764783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) synctype; 2765783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2766783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2767783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2768783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2769783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2770b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_dmbuffer **/ 2771783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2772b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#if defined(_DM_BUFFER_H_) 2773783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Bool 2774783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXAssociateDMPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer) 2775783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2776783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2777783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) pbuffer; 2778783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) params; 2779783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dmbuffer; 2780783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return False; 2781783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2782783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul#endif 2783783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2784783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2785b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_swap_group ***/ 2786783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2787783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void 2788783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXJoinSwapGroupSGIX(Display *dpy, GLXDrawable drawable, GLXDrawable member) 2789783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2790783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2791783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) drawable; 2792783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) member; 2793783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2794783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2795783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2796783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2797b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_swap_barrier ***/ 2798783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2799783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void 2800783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXBindSwapBarrierSGIX(Display *dpy, GLXDrawable drawable, int barrier) 2801783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2802783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2803783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) drawable; 2804783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) barrier; 2805783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2806783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2807783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Bool 2808783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryMaxSwapBarriersSGIX(Display *dpy, int screen, int *max) 2809783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2810783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2811783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) screen; 2812783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) max; 2813783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return False; 2814783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2815783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2816783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2817783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2818b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SUN_get_transparent_index ***/ 2819783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2820783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Status 2821783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetTransparentIndexSUN(Display *dpy, Window overlay, Window underlay, long *pTransparent) 2822783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2823783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2824783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) overlay; 2825783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) underlay; 2826783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) pTransparent; 2827783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2828783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2829783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2830783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2831783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2832b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_MESA_release_buffers ***/ 2833b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul 2834783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul/* 2835783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul * Release the depth, stencil, accum buffers attached to a GLXDrawable 2836783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul * (a window or pixmap) prior to destroying the GLXDrawable. 2837783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul */ 2838783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Bool 2839783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXReleaseBuffersMESA( Display *dpy, GLXDrawable d ) 2840783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2841783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul XMesaBuffer b = XMesaFindBuffer(dpy, d); 2842783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul if (b) { 2843783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul XMesaDestroyBuffer(b); 2844783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return True; 2845783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul } 2846783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return False; 2847783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2848783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2849783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2850783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2851b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_MESA_set_3dfx_mode ***/ 2852b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul 2853783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Bool 2854783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXSet3DfxModeMESA( int mode ) 2855783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2856783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return XMesaSetFXmode( mode ); 2857783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2858783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2859783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2860783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 28613c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian Paul/*** GLX_NV_vertex_array range ***/ 28628fefafa2200d3ea44ec46592b190654a10685b46Brian Paulstatic void * 28638fefafa2200d3ea44ec46592b190654a10685b46Brian PaulFake_glXAllocateMemoryNV( GLsizei size, 28648fefafa2200d3ea44ec46592b190654a10685b46Brian Paul GLfloat readFrequency, 28658fefafa2200d3ea44ec46592b190654a10685b46Brian Paul GLfloat writeFrequency, 28668fefafa2200d3ea44ec46592b190654a10685b46Brian Paul GLfloat priority ) 28678fefafa2200d3ea44ec46592b190654a10685b46Brian Paul{ 28688fefafa2200d3ea44ec46592b190654a10685b46Brian Paul (void) size; 28698fefafa2200d3ea44ec46592b190654a10685b46Brian Paul (void) readFrequency; 28708fefafa2200d3ea44ec46592b190654a10685b46Brian Paul (void) writeFrequency; 28718fefafa2200d3ea44ec46592b190654a10685b46Brian Paul (void) priority; 28728fefafa2200d3ea44ec46592b190654a10685b46Brian Paul return NULL; 28738fefafa2200d3ea44ec46592b190654a10685b46Brian Paul} 28748fefafa2200d3ea44ec46592b190654a10685b46Brian Paul 28758fefafa2200d3ea44ec46592b190654a10685b46Brian Paul 28768fefafa2200d3ea44ec46592b190654a10685b46Brian Paulstatic void 28778fefafa2200d3ea44ec46592b190654a10685b46Brian PaulFake_glXFreeMemoryNV( GLvoid *pointer ) 28788fefafa2200d3ea44ec46592b190654a10685b46Brian Paul{ 28798fefafa2200d3ea44ec46592b190654a10685b46Brian Paul (void) pointer; 28808fefafa2200d3ea44ec46592b190654a10685b46Brian Paul} 28818fefafa2200d3ea44ec46592b190654a10685b46Brian Paul 28828fefafa2200d3ea44ec46592b190654a10685b46Brian Paul 28833c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian Paul/*** GLX_MESA_agp_offset ***/ 2884d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul 2885d6113fc20d68f5720740b89c594227d0312bab3eBrian Paulstatic GLuint 2886d6113fc20d68f5720740b89c594227d0312bab3eBrian PaulFake_glXGetAGPOffsetMESA( const GLvoid *pointer ) 2887d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul{ 2888d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul (void) pointer; 2889d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul return ~0; 2890d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul} 2891d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul 2892d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul 2893fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian/*** GLX_EXT_texture_from_pixmap ***/ 2894fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian 2895fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrianstatic void 2896fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrianFake_glXBindTexImageEXT(Display *dpy, GLXDrawable drawable, int buffer, 2897fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian const int *attrib_list) 2898fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian{ 2899fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian XMesaBuffer b = XMesaFindBuffer(dpy, drawable); 2900fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (b) 2901fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian XMesaBindTexImage(dpy, b, buffer, attrib_list); 2902fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian} 2903fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian 2904fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrianstatic void 2905fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrianFake_glXReleaseTexImageEXT(Display *dpy, GLXDrawable drawable, int buffer) 2906fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian{ 2907fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian XMesaBuffer b = XMesaFindBuffer(dpy, drawable); 2908fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian if (b) 2909fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian XMesaReleaseTexImage(dpy, b, buffer); 2910fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian} 2911fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian 2912fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian 29137287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul/* silence warning */ 2914e7b16b74bf5d13331b5a88bbbbb9096560297b63Brian Paulextern struct _glxapi_table *_mesa_GetGLXDispatchTable(void); 29157287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul 29167287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul 29177287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul/** 29187287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul * Create a new GLX API dispatch table with its function pointers 29197287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul * initialized to point to Mesa's "fake" GLX API functions. 29207287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul * Note: there's a similar function (_real_GetGLXDispatchTable) that 29217287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul * returns a new dispatch table with all pointers initalized to point 29227287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul * to "real" GLX functions (which understand GLX wire protocol, etc). 29237287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul */ 29247287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulstruct _glxapi_table * 29257287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul_mesa_GetGLXDispatchTable(void) 2926426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 2927426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul static struct _glxapi_table glx; 2928426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2929426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul /* be sure our dispatch table size <= libGL's table */ 2930426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul { 293101915e90e6912f06d43d443a09157f7bbc96ddc5Brian Paul GLuint size = sizeof(struct _glxapi_table) / sizeof(void *); 2932426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) size; 2933426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul assert(_glxapi_get_dispatch_table_size() >= size); 2934426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul } 2935426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2936426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul /* initialize the whole table to no-ops */ 2937426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul _glxapi_set_no_op_table(&glx); 2938426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2939426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul /* now initialize the table with the functions I implement */ 2940426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.ChooseVisual = Fake_glXChooseVisual; 2941426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CopyContext = Fake_glXCopyContext; 2942426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CreateContext = Fake_glXCreateContext; 2943426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CreateGLXPixmap = Fake_glXCreateGLXPixmap; 2944426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.DestroyContext = Fake_glXDestroyContext; 2945426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.DestroyGLXPixmap = Fake_glXDestroyGLXPixmap; 2946426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.GetConfig = Fake_glXGetConfig; 2947426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul /*glx.GetCurrentContext = Fake_glXGetCurrentContext;*/ 2948426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul /*glx.GetCurrentDrawable = Fake_glXGetCurrentDrawable;*/ 2949426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.IsDirect = Fake_glXIsDirect; 2950426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.MakeCurrent = Fake_glXMakeCurrent; 2951426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.QueryExtension = Fake_glXQueryExtension; 2952426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.QueryVersion = Fake_glXQueryVersion; 2953426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.SwapBuffers = Fake_glXSwapBuffers; 2954426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.UseXFont = Fake_glXUseXFont; 2955426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.WaitGL = Fake_glXWaitGL; 2956426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.WaitX = Fake_glXWaitX; 2957426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2958b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_VERSION_1_1 ***/ 2959426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.GetClientString = Fake_glXGetClientString; 2960426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.QueryExtensionsString = Fake_glXQueryExtensionsString; 2961426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.QueryServerString = Fake_glXQueryServerString; 2962426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2963b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_VERSION_1_2 ***/ 2964426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul /*glx.GetCurrentDisplay = Fake_glXGetCurrentDisplay;*/ 2965426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2966b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_VERSION_1_3 ***/ 2967426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.ChooseFBConfig = Fake_glXChooseFBConfig; 2968426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CreateNewContext = Fake_glXCreateNewContext; 2969426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CreatePbuffer = Fake_glXCreatePbuffer; 2970426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CreatePixmap = Fake_glXCreatePixmap; 2971426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CreateWindow = Fake_glXCreateWindow; 2972426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.DestroyPbuffer = Fake_glXDestroyPbuffer; 2973426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.DestroyPixmap = Fake_glXDestroyPixmap; 2974426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.DestroyWindow = Fake_glXDestroyWindow; 2975426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul /*glx.GetCurrentReadDrawable = Fake_glXGetCurrentReadDrawable;*/ 2976426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.GetFBConfigAttrib = Fake_glXGetFBConfigAttrib; 297771dea349d2be623b7819389428b0d6a124e8d184Brian Paul glx.GetFBConfigs = Fake_glXGetFBConfigs; 2978426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.GetSelectedEvent = Fake_glXGetSelectedEvent; 2979426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.GetVisualFromFBConfig = Fake_glXGetVisualFromFBConfig; 2980426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.MakeContextCurrent = Fake_glXMakeContextCurrent; 2981426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.QueryContext = Fake_glXQueryContext; 2982426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.QueryDrawable = Fake_glXQueryDrawable; 2983426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.SelectEvent = Fake_glXSelectEvent; 2984426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2985b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SGI_swap_control ***/ 2986783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.SwapIntervalSGI = Fake_glXSwapIntervalSGI; 2987783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2988b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SGI_video_sync ***/ 2989426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.GetVideoSyncSGI = Fake_glXGetVideoSyncSGI; 2990426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.WaitVideoSyncSGI = Fake_glXWaitVideoSyncSGI; 2991426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2992b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SGI_make_current_read ***/ 2993783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.MakeCurrentReadSGI = Fake_glXMakeCurrentReadSGI; 29947cf50e137da497a590ec9001a9918972a6246142Brian Paul /*glx.GetCurrentReadDrawableSGI = Fake_glXGetCurrentReadDrawableSGI;*/ 2995783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2996b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_video_source ***/ 2997b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#if defined(_VL_H) 2998783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.CreateGLXVideoSourceSGIX = Fake_glXCreateGLXVideoSourceSGIX; 2999783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.DestroyGLXVideoSourceSGIX = Fake_glXDestroyGLXVideoSourceSGIX; 3000783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul#endif 3001783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 3002b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_EXT_import_context ***/ 3003783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.FreeContextEXT = Fake_glXFreeContextEXT; 3004783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.GetContextIDEXT = Fake_glXGetContextIDEXT; 30057cf50e137da497a590ec9001a9918972a6246142Brian Paul /*glx.GetCurrentDisplayEXT = Fake_glXGetCurrentDisplayEXT;*/ 3006783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.ImportContextEXT = Fake_glXImportContextEXT; 3007783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.QueryContextInfoEXT = Fake_glXQueryContextInfoEXT; 30084536021a62e02fceaa6e8eb889b0f61743109cc4Brian Paul 3009b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SGIX_fbconfig ***/ 3010783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.GetFBConfigAttribSGIX = Fake_glXGetFBConfigAttribSGIX; 3011783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.ChooseFBConfigSGIX = Fake_glXChooseFBConfigSGIX; 3012783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.CreateGLXPixmapWithConfigSGIX = Fake_glXCreateGLXPixmapWithConfigSGIX; 3013783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.CreateContextWithConfigSGIX = Fake_glXCreateContextWithConfigSGIX; 3014783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.GetVisualFromFBConfigSGIX = Fake_glXGetVisualFromFBConfigSGIX; 3015783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.GetFBConfigFromVisualSGIX = Fake_glXGetFBConfigFromVisualSGIX; 3016783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 3017b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SGIX_pbuffer ***/ 3018783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.CreateGLXPbufferSGIX = Fake_glXCreateGLXPbufferSGIX; 3019783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.DestroyGLXPbufferSGIX = Fake_glXDestroyGLXPbufferSGIX; 3020783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.QueryGLXPbufferSGIX = Fake_glXQueryGLXPbufferSGIX; 3021783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.SelectEventSGIX = Fake_glXSelectEventSGIX; 3022783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.GetSelectedEventSGIX = Fake_glXGetSelectedEventSGIX; 3023783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 3024b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SGI_cushion ***/ 3025783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.CushionSGI = Fake_glXCushionSGI; 3026783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 3027b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SGIX_video_resize ***/ 3028783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.BindChannelToWindowSGIX = Fake_glXBindChannelToWindowSGIX; 3029783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.ChannelRectSGIX = Fake_glXChannelRectSGIX; 3030783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.QueryChannelRectSGIX = Fake_glXQueryChannelRectSGIX; 3031783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.QueryChannelDeltasSGIX = Fake_glXQueryChannelDeltasSGIX; 3032783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.ChannelRectSyncSGIX = Fake_glXChannelRectSyncSGIX; 3033783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 3034b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SGIX_dmbuffer **/ 3035b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#if defined(_DM_BUFFER_H_) 3036783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.AssociateDMPbufferSGIX = NULL; 3037783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul#endif 3038783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 3039b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SGIX_swap_group ***/ 3040783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.JoinSwapGroupSGIX = Fake_glXJoinSwapGroupSGIX; 3041783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 3042b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SGIX_swap_barrier ***/ 3043783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.BindSwapBarrierSGIX = Fake_glXBindSwapBarrierSGIX; 3044783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.QueryMaxSwapBarriersSGIX = Fake_glXQueryMaxSwapBarriersSGIX; 3045783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 3046b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SUN_get_transparent_index ***/ 3047783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.GetTransparentIndexSUN = Fake_glXGetTransparentIndexSUN; 30484536021a62e02fceaa6e8eb889b0f61743109cc4Brian Paul 3049b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_MESA_copy_sub_buffer ***/ 3050426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CopySubBufferMESA = Fake_glXCopySubBufferMESA; 3051426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 3052b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_MESA_release_buffers ***/ 3053426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.ReleaseBuffersMESA = Fake_glXReleaseBuffersMESA; 3054426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 3055b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_MESA_pixmap_colormap ***/ 3056426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CreateGLXPixmapMESA = Fake_glXCreateGLXPixmapMESA; 3057426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 3058b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_MESA_set_3dfx_mode ***/ 3059426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.Set3DfxModeMESA = Fake_glXSet3DfxModeMESA; 3060426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 3061d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul /*** GLX_NV_vertex_array_range ***/ 30628fefafa2200d3ea44ec46592b190654a10685b46Brian Paul glx.AllocateMemoryNV = Fake_glXAllocateMemoryNV; 30638fefafa2200d3ea44ec46592b190654a10685b46Brian Paul glx.FreeMemoryNV = Fake_glXFreeMemoryNV; 30648fefafa2200d3ea44ec46592b190654a10685b46Brian Paul 3065d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul /*** GLX_MESA_agp_offset ***/ 3066d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul glx.GetAGPOffsetMESA = Fake_glXGetAGPOffsetMESA; 3067d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul 3068fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian /*** GLX_EXT_texture_from_pixmap ***/ 3069fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian glx.BindTexImageEXT = Fake_glXBindTexImageEXT; 3070fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian glx.ReleaseTexImageEXT = Fake_glXReleaseTexImageEXT; 3071fd54564f78d4aeae2c39ada7502ec659c14b3ecaBrian 3072426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul return &glx; 3073426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 3074