fakeglx.c revision ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6
1afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 2afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Mesa 3-D graphics library 3be2de8b299c9fc7bdc22372ed799e894a8582c62Brian Paul * Version: 6.3 45e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen * 51f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. 65e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen * 7afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Permission is hereby granted, free of charge, to any person obtaining a 8afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * copy of this software and associated documentation files (the "Software"), 9afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * to deal in the Software without restriction, including without limitation 10afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * and/or sell copies of the Software, and to permit persons to whom the 12afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Software is furnished to do so, subject to the following conditions: 135e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen * 14afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * The above copyright notice and this permission notice shall be included 15afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * in all copies or substantial portions of the Software. 165e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen * 17afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 21afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 24afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 25afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 26afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 2736cfa38760cc2bd91c08b66bb62c4b6cf9eb5454Brian Paul * This is an emulation of the GLX API which allows Mesa/GLX-based programs 2836cfa38760cc2bd91c08b66bb62c4b6cf9eb5454Brian Paul * to run on X servers which do not have the real GLX extension. 29afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * 30afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Thanks to the contributors: 31afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * 32ddf69f247fdb246b99ef6525fcfa6eda7b2e2aa7Brian Paul * Initial version: Philip Brown (phil@bolthole.com) 33afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Better glXGetConfig() support: Armin Liebchen (liebchen@asylum.cs.utah.edu) 34afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Further visual-handling refinements: Wolfram Gloger 35afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * (wmglo@Dent.MED.Uni-Muenchen.DE). 36afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * 37afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Notes: 38afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Don't be fooled, stereo isn't supported yet. 39afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 40afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 41afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 42afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 43fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul#include "glxheader.h" 44426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul#include "glxapi.h" 45afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#include "GL/xmesa.h" 46afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#include "context.h" 47afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#include "config.h" 48afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#include "macros.h" 493c63452e64df7e10aa073c6c3b9492b1d7dabbb8Brian Paul#include "imports.h" 505e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen#include "mtypes.h" 512c5f93784ea1ba28ae15181917ff3e47656a93adBrian Paul#include "version.h" 5271dea349d2be623b7819389428b0d6a124e8d184Brian Paul#include "xfonts.h" 53afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#include "xmesaP.h" 54afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 55afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 5678fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul/* This indicates the client-side GLX API and GLX encoder version. */ 5778fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul#define CLIENT_MAJOR_VERSION 1 58a573803ed3fe9ef6489f45bd4c5455b77cb33a43Brian Paul#define CLIENT_MINOR_VERSION 4 /* but don't have 1.3's pbuffers, etc yet */ 5978fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul 6078fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul/* This indicates the server-side GLX decoder version. 61ba57e5297d60eef37e43dd4d7f10d1e62f5e97ceBrian Paul * GLX 1.4 indicates OpenGL 1.3 support 6278fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul */ 6378fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul#define SERVER_MAJOR_VERSION 1 64ba57e5297d60eef37e43dd4d7f10d1e62f5e97ceBrian Paul#define SERVER_MINOR_VERSION 4 6578fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul 6678fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul/* This is appended onto the glXGetClient/ServerString version strings. */ 672c5f93784ea1ba28ae15181917ff3e47656a93adBrian Paul#define MESA_GLX_VERSION "Mesa " MESA_VERSION_STRING 6878fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul 6978fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul/* Who implemented this GLX? */ 7078fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul#define VENDOR "Brian Paul" 7178fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul 72e4656003caee346d9c4eb23256d73409271291a7Brian Paul#define EXTENSIONS \ 73e4656003caee346d9c4eb23256d73409271291a7Brian Paul "GLX_MESA_set_3dfx_mode " \ 74e4656003caee346d9c4eb23256d73409271291a7Brian Paul "GLX_MESA_copy_sub_buffer " \ 75e4656003caee346d9c4eb23256d73409271291a7Brian Paul "GLX_MESA_pixmap_colormap " \ 76e4656003caee346d9c4eb23256d73409271291a7Brian Paul "GLX_MESA_release_buffers " \ 77e4656003caee346d9c4eb23256d73409271291a7Brian Paul "GLX_ARB_get_proc_address " \ 78e4656003caee346d9c4eb23256d73409271291a7Brian Paul "GLX_EXT_visual_info " \ 79e4656003caee346d9c4eb23256d73409271291a7Brian Paul "GLX_EXT_visual_rating " \ 80e4656003caee346d9c4eb23256d73409271291a7Brian Paul "GLX_SGI_video_sync " \ 81e4656003caee346d9c4eb23256d73409271291a7Brian Paul "GLX_SGIX_fbconfig " \ 826d6efd605f662c1f07e183e58416db804f0a058fBrian Paul "GLX_SGIX_pbuffer " 8343c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul 847cf50e137da497a590ec9001a9918972a6246142Brian Paul/* 857cf50e137da497a590ec9001a9918972a6246142Brian Paul * Our fake GLX context will contain a "real" GLX context and an XMesa context. 867cf50e137da497a590ec9001a9918972a6246142Brian Paul * 877cf50e137da497a590ec9001a9918972a6246142Brian Paul * Note that a pointer to a __GLXcontext is a pointer to a fake_glx_context, 887cf50e137da497a590ec9001a9918972a6246142Brian Paul * and vice versa. 897cf50e137da497a590ec9001a9918972a6246142Brian Paul * 907cf50e137da497a590ec9001a9918972a6246142Brian Paul * We really just need this structure in order to make the libGL functions 917cf50e137da497a590ec9001a9918972a6246142Brian Paul * glXGetCurrentContext(), glXGetCurrentDrawable() and glXGetCurrentDisplay() 927cf50e137da497a590ec9001a9918972a6246142Brian Paul * work correctly. 937cf50e137da497a590ec9001a9918972a6246142Brian Paul */ 947cf50e137da497a590ec9001a9918972a6246142Brian Paulstruct fake_glx_context { 957cf50e137da497a590ec9001a9918972a6246142Brian Paul __GLXcontext glxContext; /* this MUST be first! */ 967cf50e137da497a590ec9001a9918972a6246142Brian Paul XMesaContext xmesaContext; 977cf50e137da497a590ec9001a9918972a6246142Brian Paul}; 9843c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul 99afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 100afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1017cf50e137da497a590ec9001a9918972a6246142Brian Paul/**********************************************************************/ 1027cf50e137da497a590ec9001a9918972a6246142Brian Paul/*** GLX Visual Code ***/ 1037cf50e137da497a590ec9001a9918972a6246142Brian Paul/**********************************************************************/ 1047cf50e137da497a590ec9001a9918972a6246142Brian Paul 1057cf50e137da497a590ec9001a9918972a6246142Brian Paul#define DONT_CARE -1 1067cf50e137da497a590ec9001a9918972a6246142Brian Paul 107afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 108afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#define MAX_VISUALS 100 109afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XMesaVisual VisualTable[MAX_VISUALS]; 110afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic int NumVisuals = 0; 111afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 112afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 113afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 114afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * This struct and some code fragments borrowed 115afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * from Mark Kilgard's GLUT library. 116afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 117afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgtypedef struct _OverlayInfo { 118afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Avoid 64-bit portability problems by being careful to use 119afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg longs due to the way XGetWindowProperty is specified. Note 120afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg that these parameters are passed as CARD32s over X 121afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg protocol. */ 122afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg unsigned long overlay_visual; 123afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg long transparent_type; 124afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg long value; 125afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg long layer; 126afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} OverlayInfo; 127afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 128afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 129afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 130afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* Macro to handle c_class vs class field name in XVisualInfo struct */ 131afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#if defined(__cplusplus) || defined(c_plusplus) 132afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#define CLASS c_class 133afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#else 134afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#define CLASS class 135afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#endif 136afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 137afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 138afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 139afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 140afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Test if the given XVisualInfo is usable for Mesa rendering. 141afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 1427287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulstatic GLboolean 1437287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulis_usable_visual( XVisualInfo *vinfo ) 144afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 145afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (vinfo->CLASS) { 146afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case StaticGray: 147afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GrayScale: 148afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Any StaticGray/GrayScale visual works in RGB or CI mode */ 149afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return GL_TRUE; 150afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case StaticColor: 151afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case PseudoColor: 152afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Any StaticColor/PseudoColor visual of at least 4 bits */ 153afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vinfo->depth>=4) { 154afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return GL_TRUE; 155afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 156afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 157afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return GL_FALSE; 158afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 159afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case TrueColor: 160afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case DirectColor: 161afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Any depth of TrueColor or DirectColor works in RGB mode */ 162afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return GL_TRUE; 163afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: 164afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* This should never happen */ 165afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return GL_FALSE; 166afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 167afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 168afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 169afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 170afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1711d97c277e0cb2b75559d495a58222f2511212a66Brian Paul/** 1721d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * Get an array OverlayInfo records for specified screen. 1731d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * \param dpy the display 1741d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * \param screen screen number 1751d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * \param numOverlays returns numver of OverlayInfo records 1761d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * \return pointer to OverlayInfo array, free with XFree() 177afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 1781d97c277e0cb2b75559d495a58222f2511212a66Brian Paulstatic OverlayInfo * 1791d97c277e0cb2b75559d495a58222f2511212a66Brian PaulGetOverlayInfo(Display *dpy, int screen, int *numOverlays) 180afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 181afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg Atom overlayVisualsAtom; 182afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg Atom actualType; 1831d97c277e0cb2b75559d495a58222f2511212a66Brian Paul Status status; 1841d97c277e0cb2b75559d495a58222f2511212a66Brian Paul unsigned char *ovInfo; 185afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg unsigned long sizeData, bytesLeft; 1861d97c277e0cb2b75559d495a58222f2511212a66Brian Paul int actualFormat; 187afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 188afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* 189afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * The SERVER_OVERLAY_VISUALS property on the root window contains 190afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * a list of overlay visuals. Get that list now. 191afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 192afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg overlayVisualsAtom = XInternAtom(dpy,"SERVER_OVERLAY_VISUALS", True); 193afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (overlayVisualsAtom == None) { 194afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 195afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 196afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1971d97c277e0cb2b75559d495a58222f2511212a66Brian Paul status = XGetWindowProperty(dpy, RootWindow(dpy, screen), 198afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg overlayVisualsAtom, 0L, (long) 10000, False, 199afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg overlayVisualsAtom, &actualType, &actualFormat, 200afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg &sizeData, &bytesLeft, 2011d97c277e0cb2b75559d495a58222f2511212a66Brian Paul &ovInfo); 202afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 203afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (status != Success || actualType != overlayVisualsAtom || 204afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg actualFormat != 32 || sizeData < 4) { 205afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* something went wrong */ 2061d97c277e0cb2b75559d495a58222f2511212a66Brian Paul XFree((void *) ovInfo); 2071d97c277e0cb2b75559d495a58222f2511212a66Brian Paul *numOverlays = 0; 2081d97c277e0cb2b75559d495a58222f2511212a66Brian Paul return NULL; 2091d97c277e0cb2b75559d495a58222f2511212a66Brian Paul } 2101d97c277e0cb2b75559d495a58222f2511212a66Brian Paul 2111d97c277e0cb2b75559d495a58222f2511212a66Brian Paul *numOverlays = sizeData / 4; 2121d97c277e0cb2b75559d495a58222f2511212a66Brian Paul return (OverlayInfo *) ovInfo; 2131d97c277e0cb2b75559d495a58222f2511212a66Brian Paul} 2141d97c277e0cb2b75559d495a58222f2511212a66Brian Paul 2151d97c277e0cb2b75559d495a58222f2511212a66Brian Paul 2161d97c277e0cb2b75559d495a58222f2511212a66Brian Paul 2171d97c277e0cb2b75559d495a58222f2511212a66Brian Paul/** 2181d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * Return the level (overlay, normal, underlay) of a given XVisualInfo. 2191d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * Input: dpy - the X display 2201d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * vinfo - the XVisualInfo to test 2211d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * Return: level of the visual: 2221d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * 0 = normal planes 2231d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * >0 = overlay planes 2241d97c277e0cb2b75559d495a58222f2511212a66Brian Paul * <0 = underlay planes 2251d97c277e0cb2b75559d495a58222f2511212a66Brian Paul */ 2261d97c277e0cb2b75559d495a58222f2511212a66Brian Paulstatic int 2271d97c277e0cb2b75559d495a58222f2511212a66Brian Paullevel_of_visual( Display *dpy, XVisualInfo *vinfo ) 2281d97c277e0cb2b75559d495a58222f2511212a66Brian Paul{ 2291d97c277e0cb2b75559d495a58222f2511212a66Brian Paul OverlayInfo *overlay_info; 2301d97c277e0cb2b75559d495a58222f2511212a66Brian Paul int numOverlaysPerScreen, i; 2311d97c277e0cb2b75559d495a58222f2511212a66Brian Paul 2321d97c277e0cb2b75559d495a58222f2511212a66Brian Paul overlay_info = GetOverlayInfo(dpy, vinfo->screen, &numOverlaysPerScreen); 2331d97c277e0cb2b75559d495a58222f2511212a66Brian Paul if (!overlay_info) { 234afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 235afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 236afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 237afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* search the overlay visual list for the visual ID of interest */ 2381d97c277e0cb2b75559d495a58222f2511212a66Brian Paul for (i = 0; i < numOverlaysPerScreen; i++) { 2391d97c277e0cb2b75559d495a58222f2511212a66Brian Paul const OverlayInfo *ov = overlay_info + i; 2401d97c277e0cb2b75559d495a58222f2511212a66Brian Paul if (ov->overlay_visual == vinfo->visualid) { 241afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* found the visual */ 242afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (/*ov->transparent_type==1 &&*/ ov->layer!=0) { 243afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int level = ov->layer; 244afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XFree((void *) overlay_info); 245afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return level; 246afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 247afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 248afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XFree((void *) overlay_info); 249afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 250afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 251afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 252afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 253afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 254afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* The visual ID was not found in the overlay list. */ 255afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XFree((void *) overlay_info); 256afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 257afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 258afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 259afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 260afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 261afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 262afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 263afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Given an XVisualInfo and RGB, Double, and Depth buffer flags, save the 264afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * configuration in our list of GLX visuals. 265afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 266afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XMesaVisual 267afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgsave_glx_visual( Display *dpy, XVisualInfo *vinfo, 268afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLboolean rgbFlag, GLboolean alphaFlag, GLboolean dbFlag, 269afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLboolean stereoFlag, 270afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLint depth_size, GLint stencil_size, 271b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint accumRedSize, GLint accumGreenSize, 272b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint accumBlueSize, GLint accumAlphaSize, 273894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul GLint level, GLint numAuxBuffers ) 274afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 275afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLboolean ximageFlag = GL_TRUE; 276afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaVisual xmvis; 277afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLint i; 278afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLboolean comparePointers; 279afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 280afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (dbFlag) { 281afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Check if the MESA_BACK_BUFFER env var is set */ 282367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul char *backbuffer = _mesa_getenv("MESA_BACK_BUFFER"); 283afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (backbuffer) { 284afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (backbuffer[0]=='p' || backbuffer[0]=='P') { 285afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg ximageFlag = GL_FALSE; 286afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 287afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else if (backbuffer[0]=='x' || backbuffer[0]=='X') { 288afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg ximageFlag = GL_TRUE; 289afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 290afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 291d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul _mesa_warning(NULL, "Mesa: invalid value for MESA_BACK_BUFFER environment variable, using an XImage."); 292afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 293afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 294afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 295afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 296afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Comparing IDs uses less memory but sometimes fails. */ 297afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* XXX revisit this after 3.0 is finished. */ 298367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul if (_mesa_getenv("MESA_GLX_VISUAL_HACK")) 299afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg comparePointers = GL_TRUE; 300afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else 301afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg comparePointers = GL_FALSE; 302afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 303a13331d59b535aa4a1ddad695420de5d6f814550Brian Paul /* Force the visual to have an alpha channel */ 304a13331d59b535aa4a1ddad695420de5d6f814550Brian Paul if (rgbFlag && _mesa_getenv("MESA_GLX_FORCE_ALPHA")) 305a13331d59b535aa4a1ddad695420de5d6f814550Brian Paul alphaFlag = GL_TRUE; 306a13331d59b535aa4a1ddad695420de5d6f814550Brian Paul 307afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* First check if a matching visual is already in the list */ 308afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (i=0; i<NumVisuals; i++) { 309afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaVisual v = VisualTable[i]; 310afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (v->display == dpy 311304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick && v->mesa_visual.level == level 312894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul && v->mesa_visual.numAuxBuffers == numAuxBuffers 313afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg && v->ximage_flag == ximageFlag 3141832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul && v->mesa_visual.rgbMode == rgbFlag 3151832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul && v->mesa_visual.doubleBufferMode == dbFlag 3161832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul && v->mesa_visual.stereoMode == stereoFlag 3171832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul && (v->mesa_visual.alphaBits > 0) == alphaFlag 3181832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul && (v->mesa_visual.depthBits >= depth_size || depth_size == 0) 3191832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul && (v->mesa_visual.stencilBits >= stencil_size || stencil_size == 0) 3201832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul && (v->mesa_visual.accumRedBits >= accumRedSize || accumRedSize == 0) 3211832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul && (v->mesa_visual.accumGreenBits >= accumGreenSize || accumGreenSize == 0) 3221832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul && (v->mesa_visual.accumBlueBits >= accumBlueSize || accumBlueSize == 0) 3231832f1cc86758fdcbd122edd5bf9e7a29ccade20Brian Paul && (v->mesa_visual.accumAlphaBits >= accumAlphaSize || accumAlphaSize == 0)) { 324afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* now either compare XVisualInfo pointers or visual IDs */ 325d0247f53aea8fa8677aadc8a00f75c8993be9ebcBrian Paul if ((!comparePointers && v->visinfo->visualid == vinfo->visualid) 326afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg || (comparePointers && v->vishandle == vinfo)) { 327afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return v; 328afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 329afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 330afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 331afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 332afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Create a new visual and add it to the list. */ 333afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 334d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul if (NumVisuals >= MAX_VISUALS) { 335d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul _mesa_problem(NULL, "GLX Error: maximum number of visuals exceeded"); 336afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 337afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 338afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 339c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul xmvis = XMesaCreateVisual( dpy, vinfo, rgbFlag, alphaFlag, dbFlag, 340c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul stereoFlag, ximageFlag, 341c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul depth_size, stencil_size, 342c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul accumRedSize, accumBlueSize, 343c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul accumBlueSize, accumAlphaSize, 0, level, 344c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul GLX_NONE_EXT ); 345afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (xmvis) { 346f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul /* Save a copy of the pointer now so we can find this visual again 347f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul * if we need to search for it in find_glx_visual(). 348f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul */ 349f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul xmvis->vishandle = vinfo; 350f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul /* add xmvis to the list */ 351afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg VisualTable[NumVisuals] = xmvis; 352afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg NumVisuals++; 3537287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul /* XXX minor hack, because XMesaCreateVisual doesn't support an 3547287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul * aux buffers parameter. 3557287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul */ 356894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul xmvis->mesa_visual.numAuxBuffers = numAuxBuffers; 357afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 358afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return xmvis; 359afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 360afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 361afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 362dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul/** 363dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul * Return the default number of bits for the Z buffer. 364dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul * If defined, use the MESA_GLX_DEPTH_BITS env var value. 365dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul * Otherwise, use the DEFAULT_SOFTWARE_DEPTH_BITS constant. 366dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul * XXX probably do the same thing for stencil, accum, etc. 367dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul */ 368dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paulstatic GLint 369dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Pauldefault_depth_bits(void) 370dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul{ 371dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul int zBits; 372dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul const char *zEnv = _mesa_getenv("MESA_GLX_DEPTH_BITS"); 373dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul if (zEnv) 374dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul zBits = _mesa_atoi(zEnv); 375dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul else 376dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul zBits = DEFAULT_SOFTWARE_DEPTH_BITS; 377dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul return zBits; 378dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul} 379dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul 380dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul 381afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 382afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 383afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Create a GLX visual from a regular XVisualInfo. 384ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * This is called when Fake GLX is given an XVisualInfo which wasn't 385ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * returned by glXChooseVisual. Since this is the first time we're 386ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * considering this visual we'll take a guess at reasonable values 387ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * for depth buffer size, stencil size, accum size, etc. 388ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * This is the best we can do with a client-side emulation of GLX. 389afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 390afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XMesaVisual 391afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgcreate_glx_visual( Display *dpy, XVisualInfo *visinfo ) 392afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 393afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int vislevel; 394dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul GLint zBits = default_depth_bits(); 395afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 396afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vislevel = level_of_visual( dpy, visinfo ); 397afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vislevel) { 398afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Configure this visual as a CI, single-buffered overlay */ 399afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return save_glx_visual( dpy, visinfo, 400afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GL_FALSE, /* rgb */ 401afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GL_FALSE, /* alpha */ 402afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GL_FALSE, /* double */ 403afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GL_FALSE, /* stereo */ 404afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 0, /* depth bits */ 405afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 0, /* stencil bits */ 406b2e460018375f699198073a6167e0ee96ba1d267Brian Paul 0,0,0,0, /* accum bits */ 407894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul vislevel, /* level */ 408894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul 0 /* numAux */ 409afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg ); 410afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 411afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else if (is_usable_visual( visinfo )) { 412367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul if (_mesa_getenv("MESA_GLX_FORCE_CI")) { 4138f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul /* Configure this visual as a COLOR INDEX visual. */ 4148f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul return save_glx_visual( dpy, visinfo, 4158f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul GL_FALSE, /* rgb */ 4168f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul GL_FALSE, /* alpha */ 4178f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul GL_TRUE, /* double */ 4188f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul GL_FALSE, /* stereo */ 419dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul zBits, 4208f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul 8 * sizeof(GLstencil), 4218f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul 0 * sizeof(GLaccum), /* r */ 4228f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul 0 * sizeof(GLaccum), /* g */ 4238f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul 0 * sizeof(GLaccum), /* b */ 4248f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul 0 * sizeof(GLaccum), /* a */ 425894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul 0, /* level */ 426894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul 0 /* numAux */ 4278f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul ); 4288f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul } 4298f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul else { 4308f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul /* Configure this visual as RGB, double-buffered, depth-buffered. */ 4318f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul /* This is surely wrong for some people's needs but what else */ 4328f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul /* can be done? They should use glXChooseVisual(). */ 4338f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul return save_glx_visual( dpy, visinfo, 4348f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul GL_TRUE, /* rgb */ 4358f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul GL_FALSE, /* alpha */ 4368f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul GL_TRUE, /* double */ 4378f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul GL_FALSE, /* stereo */ 438dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul zBits, 4398f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul 8 * sizeof(GLstencil), 4408f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul 8 * sizeof(GLaccum), /* r */ 4418f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul 8 * sizeof(GLaccum), /* g */ 4428f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul 8 * sizeof(GLaccum), /* b */ 4438f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul 8 * sizeof(GLaccum), /* a */ 444894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul 0, /* level */ 445894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul 0 /* numAux */ 4468f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul ); 4478f9a594ac8116ed5cab7f8eca14c17ec3e250dadBrian Paul } 448afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 449afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 450d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul _mesa_warning(NULL, "Mesa: error in glXCreateContext: bad visual\n"); 451afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 452afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 453afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 454afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 455afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 456afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 457afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 458afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Find the GLX visual associated with an XVisualInfo. 459afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 460afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XMesaVisual 461afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgfind_glx_visual( Display *dpy, XVisualInfo *vinfo ) 462afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 463afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int i; 464afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 465f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul /* try to match visual id */ 466afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (i=0;i<NumVisuals;i++) { 467f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul if (VisualTable[i]->display==dpy 468f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul && VisualTable[i]->visinfo->visualid == vinfo->visualid) { 469afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return VisualTable[i]; 470afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 471afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 472f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul 473f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul /* if that fails, try to match pointers */ 474afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (i=0;i<NumVisuals;i++) { 475f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul if (VisualTable[i]->display==dpy && VisualTable[i]->vishandle==vinfo) { 476afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return VisualTable[i]; 477afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 478afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 479f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul 480afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 481afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 482afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 483afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 484afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 4851d97c277e0cb2b75559d495a58222f2511212a66Brian Paul/** 486afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return the transparent pixel value for a GLX visual. 487afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input: glxvis - the glx_visual 488afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return: a pixel value or -1 if no transparent pixel 489afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 4907287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulstatic int 4917287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paultransparent_pixel( XMesaVisual glxvis ) 492afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 493afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg Display *dpy = glxvis->display; 494afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XVisualInfo *vinfo = glxvis->visinfo; 4951d97c277e0cb2b75559d495a58222f2511212a66Brian Paul OverlayInfo *overlay_info; 4961d97c277e0cb2b75559d495a58222f2511212a66Brian Paul int numOverlaysPerScreen, i; 497afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 4981d97c277e0cb2b75559d495a58222f2511212a66Brian Paul overlay_info = GetOverlayInfo(dpy, vinfo->screen, &numOverlaysPerScreen); 4991d97c277e0cb2b75559d495a58222f2511212a66Brian Paul if (!overlay_info) { 500afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return -1; 501afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 502afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 5031d97c277e0cb2b75559d495a58222f2511212a66Brian Paul for (i = 0; i < numOverlaysPerScreen; i++) { 5041d97c277e0cb2b75559d495a58222f2511212a66Brian Paul const OverlayInfo *ov = overlay_info + i; 5051d97c277e0cb2b75559d495a58222f2511212a66Brian Paul if (ov->overlay_visual == vinfo->visualid) { 506afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* found it! */ 5071d97c277e0cb2b75559d495a58222f2511212a66Brian Paul if (ov->transparent_type == 0) { 508afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* type 0 indicates no transparency */ 509afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XFree((void *) overlay_info); 510afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return -1; 511afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 512afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 513afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* ov->value is the transparent pixel */ 514afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XFree((void *) overlay_info); 515afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return ov->value; 516afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 517afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 518afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 519afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 520afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* The visual ID was not found in the overlay list. */ 521afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XFree((void *) overlay_info); 522afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return -1; 523afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 524afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 525afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 526afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 5271d97c277e0cb2b75559d495a58222f2511212a66Brian Paul/** 528afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Try to get an X visual which matches the given arguments. 529afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 5307287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulstatic XVisualInfo * 5317287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulget_visual( Display *dpy, int scr, unsigned int depth, int xclass ) 532afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 533afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XVisualInfo temp, *vis; 534afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg long mask; 535afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int n; 536afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg unsigned int default_depth; 537afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int default_class; 538afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 539afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg mask = VisualScreenMask | VisualDepthMask | VisualClassMask; 540afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg temp.screen = scr; 541afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg temp.depth = depth; 542afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg temp.CLASS = xclass; 543afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 544afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default_depth = DefaultDepth(dpy,scr); 545afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default_class = DefaultVisual(dpy,scr)->CLASS; 546afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 547afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (depth==default_depth && xclass==default_class) { 548afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* try to get root window's visual */ 549afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg temp.visualid = DefaultVisual(dpy,scr)->visualid; 550afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg mask |= VisualIDMask; 551afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 552afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 553afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = XGetVisualInfo( dpy, mask, &temp, &n ); 554afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 555afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* In case bits/pixel > 24, make sure color channels are still <=8 bits. 556afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * An SGI Infinite Reality system, for example, can have 30bpp pixels: 557afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * 10 bits per color channel. Mesa's limited to a max of 8 bits/channel. 558afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 559afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis && depth > 24 && (xclass==TrueColor || xclass==DirectColor)) { 56071dea349d2be623b7819389428b0d6a124e8d184Brian Paul if (_mesa_bitcount((GLuint) vis->red_mask ) <= 8 && 56171dea349d2be623b7819389428b0d6a124e8d184Brian Paul _mesa_bitcount((GLuint) vis->green_mask) <= 8 && 56271dea349d2be623b7819389428b0d6a124e8d184Brian Paul _mesa_bitcount((GLuint) vis->blue_mask ) <= 8) { 563afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 564afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 565afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 566afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XFree((void *) vis); 567afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 568afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 569afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 570afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 571afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 572afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 573afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 574afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 575afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 576afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 577afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Retrieve the value of the given environment variable and find 578afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * the X visual which matches it. 579afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input: dpy - the display 580afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * screen - the screen number 581afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * varname - the name of the environment variable 582afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return: an XVisualInfo pointer to NULL if error. 583afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 5847287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulstatic XVisualInfo * 5857287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulget_env_visual(Display *dpy, int scr, const char *varname) 586afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 587afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg char value[100], type[100]; 588afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int depth, xclass = -1; 589afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XVisualInfo *vis; 590afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 591367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul if (!_mesa_getenv( varname )) { 592afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 593afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 594afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 595367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul _mesa_strncpy( value, _mesa_getenv(varname), 100 ); 596afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg value[99] = 0; 597afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 598afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg sscanf( value, "%s %d", type, &depth ); 599afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 600367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul if (_mesa_strcmp(type,"TrueColor")==0) xclass = TrueColor; 601367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul else if (_mesa_strcmp(type,"DirectColor")==0) xclass = DirectColor; 602367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul else if (_mesa_strcmp(type,"PseudoColor")==0) xclass = PseudoColor; 603367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul else if (_mesa_strcmp(type,"StaticColor")==0) xclass = StaticColor; 604367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul else if (_mesa_strcmp(type,"GrayScale")==0) xclass = GrayScale; 605367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul else if (_mesa_strcmp(type,"StaticGray")==0) xclass = StaticGray; 606afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 607afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (xclass>-1 && depth>0) { 608afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, scr, depth, xclass ); 609afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 610afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 611afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 612afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 613afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 6142ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul _mesa_warning(NULL, "GLX unable to find visual class=%s, depth=%d.", 6152ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul type, depth); 616d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul 617afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 618afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 619afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 620afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 621afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 622afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 623afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Select an X visual which satisfies the RGBA/CI flag and minimum depth. 624afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input: dpy, screen - X display and screen number 625afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * rgba - GL_TRUE = RGBA mode, GL_FALSE = CI mode 626afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * min_depth - minimum visual depth 627afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * preferred_class - preferred GLX visual class or DONT_CARE 628afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return: pointer to an XVisualInfo or NULL. 629afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 6307287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulstatic XVisualInfo * 6317287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulchoose_x_visual( Display *dpy, int screen, GLboolean rgba, int min_depth, 6327287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul int preferred_class ) 633afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 634afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XVisualInfo *vis; 635db6aa58267cad3f502f03ab80b9deb6b75320a91Brian Paul int xclass, visclass = 0; 636afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int depth; 637afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 638afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (rgba) { 639afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg Atom hp_cr_maps = XInternAtom(dpy, "_HP_RGB_SMOOTH_MAP_LIST", True); 640afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* First see if the MESA_RGB_VISUAL env var is defined */ 641afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_env_visual( dpy, screen, "MESA_RGB_VISUAL" ); 642afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 643afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 644afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 645afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Otherwise, search for a suitable visual */ 646afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (preferred_class==DONT_CARE) { 647afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (xclass=0;xclass<6;xclass++) { 648afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (xclass) { 649afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case 0: visclass = TrueColor; break; 650afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case 1: visclass = DirectColor; break; 651afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case 2: visclass = PseudoColor; break; 652afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case 3: visclass = StaticColor; break; 653afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case 4: visclass = GrayScale; break; 654afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case 5: visclass = StaticGray; break; 655afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 656afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (min_depth==0) { 657afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* start with shallowest */ 658afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (depth=0;depth<=32;depth++) { 659afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (visclass==TrueColor && depth==8 && !hp_cr_maps) { 660afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Special case: try to get 8-bit PseudoColor before */ 661afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* 8-bit TrueColor */ 662afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, screen, 8, PseudoColor ); 663afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 664afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 665afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 666afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 667afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, screen, depth, visclass ); 668afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 669afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 670afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 671afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 672afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 673afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 674afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* start with deepest */ 675afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (depth=32;depth>=min_depth;depth--) { 676afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (visclass==TrueColor && depth==8 && !hp_cr_maps) { 677afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Special case: try to get 8-bit PseudoColor before */ 678afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* 8-bit TrueColor */ 679afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, screen, 8, PseudoColor ); 680afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 681afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 682afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 683afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 684afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, screen, depth, visclass ); 685afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 686afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 687afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 688afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 689afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 690afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 691afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 692afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 693afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* search for a specific visual class */ 694afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (preferred_class) { 695afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRUE_COLOR_EXT: visclass = TrueColor; break; 696afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_DIRECT_COLOR_EXT: visclass = DirectColor; break; 697afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_PSEUDO_COLOR_EXT: visclass = PseudoColor; break; 698afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STATIC_COLOR_EXT: visclass = StaticColor; break; 699afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_GRAY_SCALE_EXT: visclass = GrayScale; break; 700afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STATIC_GRAY_EXT: visclass = StaticGray; break; 701afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: return NULL; 702afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 703afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (min_depth==0) { 704afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* start with shallowest */ 705afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (depth=0;depth<=32;depth++) { 706afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, screen, depth, visclass ); 707afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 708afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 709afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 710afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 711afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 712afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 713afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* start with deepest */ 714afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (depth=32;depth>=min_depth;depth--) { 715afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, screen, depth, visclass ); 716afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 717afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 718afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 719afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 720afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 721afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 722afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 723afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 724afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* First see if the MESA_CI_VISUAL env var is defined */ 725afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_env_visual( dpy, screen, "MESA_CI_VISUAL" ); 726afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 727afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 728afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 729afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Otherwise, search for a suitable visual, starting with shallowest */ 730afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (preferred_class==DONT_CARE) { 731afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (xclass=0;xclass<4;xclass++) { 732afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (xclass) { 733afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case 0: visclass = PseudoColor; break; 734afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case 1: visclass = StaticColor; break; 735afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case 2: visclass = GrayScale; break; 736afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case 3: visclass = StaticGray; break; 737afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 738afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* try 8-bit up through 16-bit */ 739afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (depth=8;depth<=16;depth++) { 740afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, screen, depth, visclass ); 741afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 742afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 743afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 744afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 745afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* try min_depth up to 8-bit */ 746afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (depth=min_depth;depth<8;depth++) { 747afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, screen, depth, visclass ); 748afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 749afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 750afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 751afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 752afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 753afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 754afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 755afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* search for a specific visual class */ 756afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (preferred_class) { 757afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRUE_COLOR_EXT: visclass = TrueColor; break; 758afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_DIRECT_COLOR_EXT: visclass = DirectColor; break; 759afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_PSEUDO_COLOR_EXT: visclass = PseudoColor; break; 760afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STATIC_COLOR_EXT: visclass = StaticColor; break; 761afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_GRAY_SCALE_EXT: visclass = GrayScale; break; 762afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STATIC_GRAY_EXT: visclass = StaticGray; break; 763afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: return NULL; 764afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 765afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* try 8-bit up through 16-bit */ 766afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (depth=8;depth<=16;depth++) { 767afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, screen, depth, visclass ); 768afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 769afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 770afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 771afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 772afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* try min_depth up to 8-bit */ 773afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (depth=min_depth;depth<8;depth++) { 774afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, screen, depth, visclass ); 775afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 776afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 777afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 778afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 779afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 780afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 781afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 782afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* didn't find a visual */ 783afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 784afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 785afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 786afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 787afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 788afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 789afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Find the deepest X over/underlay visual of at least min_depth. 790afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input: dpy, screen - X display and screen number 791afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * level - the over/underlay level 792afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * trans_type - transparent pixel type: GLX_NONE_EXT, 793afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * GLX_TRANSPARENT_RGB_EXT, GLX_TRANSPARENT_INDEX_EXT, 794afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * or DONT_CARE 795afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * trans_value - transparent pixel value or DONT_CARE 796afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * min_depth - minimum visual depth 797afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * preferred_class - preferred GLX visual class or DONT_CARE 798afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return: pointer to an XVisualInfo or NULL. 799afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 8007287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulstatic XVisualInfo * 8017287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulchoose_x_overlay_visual( Display *dpy, int scr, GLboolean rgbFlag, 8027287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul int level, int trans_type, int trans_value, 8037287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul int min_depth, int preferred_class ) 804afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 805afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg OverlayInfo *overlay_info; 806afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int numOverlaysPerScreen; 807afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int i; 808afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XVisualInfo *deepvis; 809afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int deepest; 810afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 811afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /*DEBUG int tt, tv; */ 812afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 813afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (preferred_class) { 814afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRUE_COLOR_EXT: preferred_class = TrueColor; break; 815afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_DIRECT_COLOR_EXT: preferred_class = DirectColor; break; 816afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_PSEUDO_COLOR_EXT: preferred_class = PseudoColor; break; 817afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STATIC_COLOR_EXT: preferred_class = StaticColor; break; 818afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_GRAY_SCALE_EXT: preferred_class = GrayScale; break; 819afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STATIC_GRAY_EXT: preferred_class = StaticGray; break; 820afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: preferred_class = DONT_CARE; 821afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 822afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 8231d97c277e0cb2b75559d495a58222f2511212a66Brian Paul overlay_info = GetOverlayInfo(dpy, scr, &numOverlaysPerScreen); 8241d97c277e0cb2b75559d495a58222f2511212a66Brian Paul if (!overlay_info) { 825afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 826afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 827afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 828afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Search for the deepest overlay which satisifies all criteria. */ 829afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg deepest = min_depth; 830afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg deepvis = NULL; 831afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 8321d97c277e0cb2b75559d495a58222f2511212a66Brian Paul for (i = 0; i < numOverlaysPerScreen; i++) { 8331d97c277e0cb2b75559d495a58222f2511212a66Brian Paul const OverlayInfo *ov = overlay_info + i; 834afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XVisualInfo *vislist, vistemplate; 835afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int count; 836afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 837afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (ov->layer!=level) { 838afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* failed overlay level criteria */ 839afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg continue; 840afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 841afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!(trans_type==DONT_CARE 842afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg || (trans_type==GLX_TRANSPARENT_INDEX_EXT 843afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg && ov->transparent_type>0) 844afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg || (trans_type==GLX_NONE_EXT && ov->transparent_type==0))) { 845afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* failed transparent pixel type criteria */ 846afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg continue; 847afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 848afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (trans_value!=DONT_CARE && trans_value!=ov->value) { 849afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* failed transparent pixel value criteria */ 850afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg continue; 851afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 852afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 853afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* get XVisualInfo and check the depth */ 854afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vistemplate.visualid = ov->overlay_visual; 855afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vistemplate.screen = scr; 856afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vislist = XGetVisualInfo( dpy, VisualIDMask | VisualScreenMask, 857afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg &vistemplate, &count ); 858afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 859afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (count!=1) { 860afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* something went wrong */ 861afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg continue; 862afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 863afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (preferred_class!=DONT_CARE && preferred_class!=vislist->CLASS) { 864afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* wrong visual class */ 865afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg continue; 866afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 867afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 86842f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul /* if RGB was requested, make sure we have True/DirectColor */ 86942f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul if (rgbFlag && vislist->CLASS != TrueColor 87042f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul && vislist->CLASS != DirectColor) 87142f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul continue; 87242f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul 87342f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul /* if CI was requested, make sure we have a color indexed visual */ 87442f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul if (!rgbFlag 87542f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul && (vislist->CLASS == TrueColor || vislist->CLASS == DirectColor)) 87642f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul continue; 87742f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul 878afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (deepvis==NULL || vislist->depth > deepest) { 879afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* YES! found a satisfactory visual */ 880afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (deepvis) { 88180af3614d88c0cac160e787de7f34b37e96cb626Brian Paul XFree( deepvis ); 882afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 883afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg deepest = vislist->depth; 884afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg deepvis = vislist; 885afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* DEBUG tt = ov->transparent_type;*/ 886afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* DEBUG tv = ov->value; */ 887afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 888afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 889afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 890afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*DEBUG 891afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (deepvis) { 892afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg printf("chose 0x%x: layer=%d depth=%d trans_type=%d trans_value=%d\n", 893afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg deepvis->visualid, level, deepvis->depth, tt, tv ); 894afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 895afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg*/ 896afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return deepvis; 897afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 898afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 899afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 9007cf50e137da497a590ec9001a9918972a6246142Brian Paul/**********************************************************************/ 9017cf50e137da497a590ec9001a9918972a6246142Brian Paul/*** Begin Fake GLX API Functions ***/ 9027cf50e137da497a590ec9001a9918972a6246142Brian Paul/**********************************************************************/ 9037cf50e137da497a590ec9001a9918972a6246142Brian Paul 904afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 905ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul/** 906ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul * Helper used by glXChooseVisual and glXChooseFBConfig. 907ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul * The fbConfig parameter must be GL_FALSE for the former and GL_TRUE for 908ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul * the later. 909ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul * In either case, the attribute list is terminated with the value 'None'. 910ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul */ 9117287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulstatic XMesaVisual 9121f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paulchoose_visual( Display *dpy, int screen, const int *list, GLboolean fbConfig ) 913afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 9141f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul const GLboolean rgbModeDefault = fbConfig; 9153265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul const int *parselist; 916afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XVisualInfo *vis; 917afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int min_ci = 0; 918afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int min_red=0, min_green=0, min_blue=0; 919b3063ac398b72e6a4fd2015d4e220495b9779294Brian Paul GLboolean rgb_flag = rgbModeDefault; 920afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLboolean alpha_flag = GL_FALSE; 921afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLboolean double_flag = GL_FALSE; 922afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLboolean stereo_flag = GL_FALSE; 923afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLint depth_size = 0; 924afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLint stencil_size = 0; 925b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint accumRedSize = 0; 926b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint accumGreenSize = 0; 927b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint accumBlueSize = 0; 928b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint accumAlphaSize = 0; 929afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int level = 0; 930afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int visual_type = DONT_CARE; 931afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int trans_type = DONT_CARE; 932afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int trans_value = DONT_CARE; 933e1210b176926349b258c7ec77b7f36716025c82aBrian Paul GLint caveat = DONT_CARE; 9343265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul XMesaVisual xmvis = NULL; 9353a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul int desiredVisualID = -1; 936894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul int numAux = 0; 937afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 938afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist = list; 939afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 940afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg while (*parselist) { 941afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 942afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (*parselist) { 943afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_USE_GL: 9441f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul if (fbConfig) { 9451f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul /* invalid token */ 9461f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul return NULL; 9471f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul } 9481f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul else { 9491f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul /* skip */ 9501f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul parselist++; 9511f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul } 952afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 953afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_BUFFER_SIZE: 954afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 955afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg min_ci = *parselist++; 956afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 957afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_LEVEL: 958afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 959afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg level = *parselist++; 960afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 961afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_RGBA: 9621f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul if (fbConfig) { 9631f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul /* invalid token */ 9641f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul return NULL; 9651f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul } 9661f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul else { 9671f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul rgb_flag = GL_TRUE; 9681f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul parselist++; 9691f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul } 970afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 971afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_DOUBLEBUFFER: 9721f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul parselist++; 9731f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul if (fbConfig) { 9741f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul double_flag = *parselist++; 9751f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul } 9761f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul else { 9771f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul double_flag = GL_TRUE; 9781f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul } 979afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 980afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STEREO: 9811f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul parselist++; 9821f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul if (fbConfig) { 9831f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul stereo_flag = *parselist++; 9841f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul } 9851f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul else { 9861f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul stereo_flag = GL_TRUE; 9871f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul } 9881f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul return NULL; /* stereo not supported */ 989afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_AUX_BUFFERS: 990afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 991894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul numAux = *parselist++; 992894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul if (numAux > MAX_AUX_BUFFERS) 993894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul return NULL; 994afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 995afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_RED_SIZE: 996afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 997afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg min_red = *parselist++; 998afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 999afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_GREEN_SIZE: 1000afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1001afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg min_green = *parselist++; 1002afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 1003afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_BLUE_SIZE: 1004afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1005afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg min_blue = *parselist++; 1006afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 1007afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ALPHA_SIZE: 1008afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1009afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg { 1010afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLint size = *parselist++; 1011afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg alpha_flag = size>0 ? 1 : 0; 1012afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1013afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 1014afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_DEPTH_SIZE: 1015afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1016afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg depth_size = *parselist++; 1017afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 1018afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STENCIL_SIZE: 1019afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1020afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg stencil_size = *parselist++; 1021afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 1022afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_RED_SIZE: 1023b2e460018375f699198073a6167e0ee96ba1d267Brian Paul parselist++; 1024b2e460018375f699198073a6167e0ee96ba1d267Brian Paul { 1025b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint size = *parselist++; 1026b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumRedSize = MAX2( accumRedSize, size ); 1027b2e460018375f699198073a6167e0ee96ba1d267Brian Paul } 1028b2e460018375f699198073a6167e0ee96ba1d267Brian Paul break; 1029afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_GREEN_SIZE: 1030b2e460018375f699198073a6167e0ee96ba1d267Brian Paul parselist++; 1031b2e460018375f699198073a6167e0ee96ba1d267Brian Paul { 1032b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint size = *parselist++; 1033b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumGreenSize = MAX2( accumGreenSize, size ); 1034b2e460018375f699198073a6167e0ee96ba1d267Brian Paul } 1035b2e460018375f699198073a6167e0ee96ba1d267Brian Paul break; 1036afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_BLUE_SIZE: 1037b2e460018375f699198073a6167e0ee96ba1d267Brian Paul parselist++; 1038b2e460018375f699198073a6167e0ee96ba1d267Brian Paul { 1039b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint size = *parselist++; 1040b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumBlueSize = MAX2( accumBlueSize, size ); 1041b2e460018375f699198073a6167e0ee96ba1d267Brian Paul } 1042b2e460018375f699198073a6167e0ee96ba1d267Brian Paul break; 1043afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_ALPHA_SIZE: 1044afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1045afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg { 1046afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLint size = *parselist++; 1047b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumAlphaSize = MAX2( accumAlphaSize, size ); 1048afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1049afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 1050afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1051afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* 1052afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * GLX_EXT_visual_info extension 1053afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 1054afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_X_VISUAL_TYPE_EXT: 1055afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1056afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg visual_type = *parselist++; 1057afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 1058afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_TYPE_EXT: 1059afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1060afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg trans_type = *parselist++; 1061afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 1062afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_INDEX_VALUE_EXT: 1063afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1064afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg trans_value = *parselist++; 1065afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 1066afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_RED_VALUE_EXT: 1067afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_GREEN_VALUE_EXT: 1068afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_BLUE_VALUE_EXT: 1069afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_ALPHA_VALUE_EXT: 1070afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* ignore */ 1071afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1072afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1073afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 10745e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen 1075e1210b176926349b258c7ec77b7f36716025c82aBrian Paul /* 1076e1210b176926349b258c7ec77b7f36716025c82aBrian Paul * GLX_EXT_visual_info extension 1077e1210b176926349b258c7ec77b7f36716025c82aBrian Paul */ 1078e1210b176926349b258c7ec77b7f36716025c82aBrian Paul case GLX_VISUAL_CAVEAT_EXT: 1079e1210b176926349b258c7ec77b7f36716025c82aBrian Paul parselist++; 1080e1210b176926349b258c7ec77b7f36716025c82aBrian Paul caveat = *parselist++; /* ignored for now */ 1081e1210b176926349b258c7ec77b7f36716025c82aBrian Paul break; 1082e1210b176926349b258c7ec77b7f36716025c82aBrian Paul 10833265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul /* 108466ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul * GLX_ARB_multisample 108566ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul */ 108666ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul case GLX_SAMPLE_BUFFERS_ARB: 108766ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul /* ms not supported */ 108866ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul return NULL; 108966ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul case GLX_SAMPLES_ARB: 109066ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul /* ms not supported */ 109166ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul return NULL; 109266ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul 109366ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul /* 10943265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul * FBConfig attribs. 10953265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul */ 10963265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_RENDER_TYPE: 10973265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul parselist++; 10983265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (*parselist == GLX_RGBA_BIT) { 10993265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul rgb_flag = GL_TRUE; 11003265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 11013265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul else if (*parselist == GLX_COLOR_INDEX_BIT) { 11023265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul rgb_flag = GL_FALSE; 11033265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 11043265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul else if (*parselist == 0) { 11053265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul rgb_flag = GL_TRUE; 11063265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 11073265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul parselist++; 11083265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 11093265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_DRAWABLE_TYPE: 11103265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul parselist++; 11113265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (*parselist & ~(GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT)) { 11123265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return NULL; /* bad bit */ 11133265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 11143265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul parselist++; 11153265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 11163a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul case GLX_FBCONFIG_ID: 11173a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul parselist++; 11183a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul desiredVisualID = *parselist; 11193a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul break; 11203265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul 1121afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case None: 11223a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul /* end of list */ 1123afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 11243265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul 1125afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: 1126afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* undefined attribute */ 11272ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul _mesa_warning(NULL, "unexpected attrib 0x%x in choose_visual()", 11282ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul *parselist); 1129afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 1130afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1131afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1132afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1133b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul (void) caveat; 1134b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul 1135afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* 1136afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Since we're only simulating the GLX extension this function will never 1137afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * find any real GL visuals. Instead, all we can do is try to find an RGB 1138afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * or CI visual of appropriate depth. Other requested attributes such as 1139afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * double buffering, depth buffer, etc. will be associated with the X 1140afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * visual and stored in the VisualTable[]. 1141afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 11423a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul if (desiredVisualID != -1) { 11433a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul /* try to get a specific visual, by visualID */ 11443a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul XVisualInfo temp; 11453a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul int n; 11463a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul temp.visualid = desiredVisualID; 11473a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul temp.screen = screen; 11483a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul vis = XGetVisualInfo(dpy, VisualIDMask | VisualScreenMask, &temp, &n); 11493a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul if (vis) { 11503a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul /* give the visual some useful GLX attributes */ 11513a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul double_flag = GL_TRUE; 11523a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul if (vis->depth > 8) 11533a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul rgb_flag = GL_TRUE; 1154dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul depth_size = default_depth_bits(); 11553a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul stencil_size = STENCIL_BITS; 11563a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul /* XXX accum??? */ 11573a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul } 11583a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul } 11593a99674980c1fd76649ac48a95402bedc75a5e46Brian Paul else if (level==0) { 1160afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* normal color planes */ 1161afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (rgb_flag) { 1162afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Get an RGB visual */ 1163afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int min_rgb = min_red + min_green + min_blue; 1164afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (min_rgb>1 && min_rgb<8) { 1165afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* a special case to be sure we can get a monochrome visual */ 1166afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg min_rgb = 1; 1167afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1168afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = choose_x_visual( dpy, screen, rgb_flag, min_rgb, visual_type ); 1169afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1170afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 1171afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Get a color index visual */ 1172afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = choose_x_visual( dpy, screen, rgb_flag, min_ci, visual_type ); 1173b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumRedSize = accumGreenSize = accumBlueSize = accumAlphaSize = 0; 1174afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1175afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1176afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 1177afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* over/underlay planes */ 117842f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul if (rgb_flag) { 117942f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul /* rgba overlay */ 118042f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul int min_rgb = min_red + min_green + min_blue; 118142f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul if (min_rgb>1 && min_rgb<8) { 118242f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul /* a special case to be sure we can get a monochrome visual */ 118342f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul min_rgb = 1; 118442f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul } 118542f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul vis = choose_x_overlay_visual( dpy, screen, rgb_flag, level, 118642f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul trans_type, trans_value, min_rgb, visual_type ); 118742f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul } 118842f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul else { 118942f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul /* color index overlay */ 119042f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul vis = choose_x_overlay_visual( dpy, screen, rgb_flag, level, 119142f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul trans_type, trans_value, min_ci, visual_type ); 119242f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul } 1193afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1194afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1195afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 1196ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul /* Note: we're not exactly obeying the glXChooseVisual rules here. 1197ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * When GLX_DEPTH_SIZE = 1 is specified we're supposed to choose the 11982c7e6334ec81c2fab2cce9e0fe52cd30256e37eaBrian Paul * largest depth buffer size, which is 32bits/value. Instead, we 1199ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * return 16 to maintain performance with earlier versions of Mesa. 1200ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul */ 12012c7e6334ec81c2fab2cce9e0fe52cd30256e37eaBrian Paul if (depth_size > 24) 12022c7e6334ec81c2fab2cce9e0fe52cd30256e37eaBrian Paul depth_size = 31; /* 32 causes int overflow problems */ 1203ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul else if (depth_size > 16) 1204ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul depth_size = 24; 1205dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul else if (depth_size > 0) { 1206dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul depth_size = default_depth_bits(); 1207dfa5c2bfbbba1e24829582863caeafd97f124d5eBrian Paul } 12082c7e6334ec81c2fab2cce9e0fe52cd30256e37eaBrian Paul 1209ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul /* we only support one size of stencil and accum buffers. */ 1210ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul if (stencil_size > 0) 1211ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul stencil_size = STENCIL_BITS; 12126d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul if (accumRedSize > 0 || accumGreenSize > 0 || accumBlueSize > 0 || 12136d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul accumAlphaSize > 0) { 1214b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumRedSize = ACCUM_BITS; 1215b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumGreenSize = ACCUM_BITS; 1216b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumBlueSize = ACCUM_BITS; 12176d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul accumAlphaSize = alpha_flag ? ACCUM_BITS : 0; 12186d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul } 12196d62d7f32189d6a7b053420d16495217dc62f66fBrian Paul 12203265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul xmvis = save_glx_visual( dpy, vis, rgb_flag, alpha_flag, double_flag, 12213265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul stereo_flag, depth_size, stencil_size, 12223265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul accumRedSize, accumGreenSize, 1223894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul accumBlueSize, accumAlphaSize, level, numAux ); 1224afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1225afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 12263265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return xmvis; 1227afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1228afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1229afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 12303265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paulstatic XVisualInfo * 12313265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian PaulFake_glXChooseVisual( Display *dpy, int screen, int *list ) 12323265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul{ 1233b3063ac398b72e6a4fd2015d4e220495b9779294Brian Paul XMesaVisual xmvis = choose_visual(dpy, screen, list, GL_FALSE); 1234f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul if (xmvis) { 1235f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul#if 0 1236f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul return xmvis->vishandle; 1237f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul#else 1238f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul /* create a new vishandle - the cached one may be stale */ 12394039cb8ca82d59451a6de8902fe35e693cdca3baBrian Paul xmvis->vishandle = (XVisualInfo *) _mesa_malloc(sizeof(XVisualInfo)); 1240f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul if (xmvis->vishandle) { 1241f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul _mesa_memcpy(xmvis->vishandle, xmvis->visinfo, sizeof(XVisualInfo)); 1242f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul } 12433265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return xmvis->vishandle; 1244f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul#endif 1245f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul } 12463265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul else 12473265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return NULL; 12483265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul} 1249afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1250afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1251426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXContext 1252426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateContext( Display *dpy, XVisualInfo *visinfo, 1253426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul GLXContext share_list, Bool direct ) 1254afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1255e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaVisual xmvis; 12567cf50e137da497a590ec9001a9918972a6246142Brian Paul struct fake_glx_context *glxCtx; 12575e1680ce1d8296b2182e8909856927bbeddf3b95Brian Paul struct fake_glx_context *shareCtx = (struct fake_glx_context *) share_list; 125899aab341998e84d9fa208c525cae8021b3845812Brian Paul 125999aab341998e84d9fa208c525cae8021b3845812Brian Paul if (!dpy || !visinfo) 126099aab341998e84d9fa208c525cae8021b3845812Brian Paul return 0; 126199aab341998e84d9fa208c525cae8021b3845812Brian Paul 12627cf50e137da497a590ec9001a9918972a6246142Brian Paul glxCtx = CALLOC_STRUCT(fake_glx_context); 12637cf50e137da497a590ec9001a9918972a6246142Brian Paul if (!glxCtx) 12647cf50e137da497a590ec9001a9918972a6246142Brian Paul return 0; 1265afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1266afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* deallocate unused windows/buffers */ 1267afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaGarbageCollect(); 1268afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1269e4656003caee346d9c4eb23256d73409271291a7Brian Paul xmvis = find_glx_visual( dpy, visinfo ); 1270e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (!xmvis) { 1271afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* This visual wasn't found with glXChooseVisual() */ 1272e4656003caee346d9c4eb23256d73409271291a7Brian Paul xmvis = create_glx_visual( dpy, visinfo ); 1273e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (!xmvis) { 1274afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* unusable visual */ 12757cf50e137da497a590ec9001a9918972a6246142Brian Paul FREE(glxCtx); 1276afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 1277afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1278afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1279afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1280e4656003caee346d9c4eb23256d73409271291a7Brian Paul glxCtx->xmesaContext = XMesaCreateContext(xmvis, 12815e1680ce1d8296b2182e8909856927bbeddf3b95Brian Paul shareCtx ? shareCtx->xmesaContext : NULL); 12827cf50e137da497a590ec9001a9918972a6246142Brian Paul if (!glxCtx->xmesaContext) { 12837cf50e137da497a590ec9001a9918972a6246142Brian Paul FREE(glxCtx); 12847cf50e137da497a590ec9001a9918972a6246142Brian Paul return NULL; 1285afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 12867cf50e137da497a590ec9001a9918972a6246142Brian Paul 12877cf50e137da497a590ec9001a9918972a6246142Brian Paul glxCtx->xmesaContext->direct = GL_FALSE; 12887cf50e137da497a590ec9001a9918972a6246142Brian Paul glxCtx->glxContext.isDirect = GL_FALSE; 12897cf50e137da497a590ec9001a9918972a6246142Brian Paul glxCtx->glxContext.currentDpy = dpy; 12907cf50e137da497a590ec9001a9918972a6246142Brian Paul glxCtx->glxContext.xid = (XID) glxCtx; /* self pointer */ 12917cf50e137da497a590ec9001a9918972a6246142Brian Paul 12927cf50e137da497a590ec9001a9918972a6246142Brian Paul assert((void *) glxCtx == (void *) &(glxCtx->glxContext)); 12937cf50e137da497a590ec9001a9918972a6246142Brian Paul 12947cf50e137da497a590ec9001a9918972a6246142Brian Paul return (GLXContext) glxCtx; 1295afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1296afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1297afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 12987cf50e137da497a590ec9001a9918972a6246142Brian Paul/* XXX these may have to be removed due to thread-safety issues. */ 1299afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic GLXContext MakeCurrent_PrevContext = 0; 1300086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic GLXDrawable MakeCurrent_PrevDrawable = 0; 1301086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic GLXDrawable MakeCurrent_PrevReadable = 0; 1302086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic XMesaBuffer MakeCurrent_PrevDrawBuffer = 0; 1303086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic XMesaBuffer MakeCurrent_PrevReadBuffer = 0; 1304afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 13057cf50e137da497a590ec9001a9918972a6246142Brian Paul 1306086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul/* GLX 1.3 and later */ 1307426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool 1308426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXMakeContextCurrent( Display *dpy, GLXDrawable draw, 13097a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell GLXDrawable read, GLXContext ctx ) 1310086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul{ 13117cf50e137da497a590ec9001a9918972a6246142Brian Paul struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx; 13127cf50e137da497a590ec9001a9918972a6246142Brian Paul 13137a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell if (ctx && draw && read) { 1314086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul XMesaBuffer drawBuffer, readBuffer; 13157cf50e137da497a590ec9001a9918972a6246142Brian Paul XMesaContext xmctx = glxCtx->xmesaContext; 1316086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul 1317086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* Find the XMesaBuffer which corresponds to the GLXDrawable 'draw' */ 13187a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell if (ctx == MakeCurrent_PrevContext 13197a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell && draw == MakeCurrent_PrevDrawable) { 1320086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul drawBuffer = MakeCurrent_PrevDrawBuffer; 1321086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1322086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul else { 1323086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul drawBuffer = XMesaFindBuffer( dpy, draw ); 1324086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1325086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul if (!drawBuffer) { 1326086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* drawable must be a new window! */ 13277cf50e137da497a590ec9001a9918972a6246142Brian Paul drawBuffer = XMesaCreateWindowBuffer2( xmctx->xm_visual, draw, xmctx); 1328086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul if (!drawBuffer) { 1329086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* Out of memory, or context/drawable depth mismatch */ 1330086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul return False; 1331086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1332086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1333086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul 1334086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* Find the XMesaBuffer which corresponds to the GLXDrawable 'read' */ 13357a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell if (ctx == MakeCurrent_PrevContext 1336086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul && read == MakeCurrent_PrevReadable) { 1337086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul readBuffer = MakeCurrent_PrevReadBuffer; 1338086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1339086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul else { 1340086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul readBuffer = XMesaFindBuffer( dpy, read ); 1341086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1342086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul if (!readBuffer) { 1343086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* drawable must be a new window! */ 13447cf50e137da497a590ec9001a9918972a6246142Brian Paul readBuffer = XMesaCreateWindowBuffer2(glxCtx->xmesaContext->xm_visual, 13457cf50e137da497a590ec9001a9918972a6246142Brian Paul read, xmctx); 1346086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul if (!readBuffer) { 1347086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* Out of memory, or context/drawable depth mismatch */ 1348086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul return False; 1349086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1350086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1351086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul 13527a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell MakeCurrent_PrevContext = ctx; 1353086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevDrawable = draw; 1354086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevReadable = read; 1355086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevDrawBuffer = drawBuffer; 1356086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevReadBuffer = readBuffer; 1357086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul 1358086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* Now make current! */ 13597cf50e137da497a590ec9001a9918972a6246142Brian Paul if (XMesaMakeCurrent2(xmctx, drawBuffer, readBuffer)) { 136012c1bee87fcc3a0912685bb6e83447972e5de64eBrian Paul ((__GLXcontext *) ctx)->currentDpy = dpy; 136112c1bee87fcc3a0912685bb6e83447972e5de64eBrian Paul ((__GLXcontext *) ctx)->currentDrawable = draw; 13628d687e7e58a148f3f16573636023e54755372010Brian Paul#ifndef GLX_BUILT_IN_XMESA 136312c1bee87fcc3a0912685bb6e83447972e5de64eBrian Paul ((__GLXcontext *) ctx)->currentReadable = read; 13648d687e7e58a148f3f16573636023e54755372010Brian Paul#else 13657cf50e137da497a590ec9001a9918972a6246142Brian Paul __glXSetCurrentContext(ctx); 13667cf50e137da497a590ec9001a9918972a6246142Brian Paul#endif 13677cf50e137da497a590ec9001a9918972a6246142Brian Paul return True; 13687cf50e137da497a590ec9001a9918972a6246142Brian Paul } 13697cf50e137da497a590ec9001a9918972a6246142Brian Paul else { 13707cf50e137da497a590ec9001a9918972a6246142Brian Paul return False; 13717cf50e137da497a590ec9001a9918972a6246142Brian Paul } 1372086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 13737a1f3a37a10b162b067239dafa19fc6865a41f14Keith Whitwell else if (!ctx && !draw && !read) { 1374086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* release current context w/out assigning new one. */ 1375086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul XMesaMakeCurrent( NULL, NULL ); 1376086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevContext = 0; 1377086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevDrawable = 0; 1378086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevReadable = 0; 1379086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevDrawBuffer = 0; 1380086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevReadBuffer = 0; 138184cac8441fcf5f692cd220e9fa86cab398a4c159Brian Paul#ifdef GLX_BUILT_IN_XMESA 1382b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /* XXX bind dummy context with __glXSetCurrentContext(ctx); */ 1383b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#endif 1384086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul return True; 1385086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1386086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul else { 1387086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* The args must either all be non-zero or all zero. 1388086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul * This is an error. 1389086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul */ 1390086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul return False; 1391086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1392086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul} 1393086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul 1394086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul 1395426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool 1396426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXMakeCurrent( Display *dpy, GLXDrawable drawable, GLXContext ctx ) 1397426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 1398426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul return Fake_glXMakeContextCurrent( dpy, drawable, drawable, ctx ); 1399426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1400426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1401426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1402426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPixmap 1403426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateGLXPixmap( Display *dpy, XVisualInfo *visinfo, Pixmap pixmap ) 1404afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1405afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaVisual v; 1406afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaBuffer b; 1407afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1408afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg v = find_glx_visual( dpy, visinfo ); 1409afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!v) { 1410afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg v = create_glx_visual( dpy, visinfo ); 1411afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!v) { 1412afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* unusable visual */ 1413afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1414afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1415afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1416afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1417afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg b = XMesaCreatePixmapBuffer( v, pixmap, 0 ); 1418afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!b) { 1419afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1420afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1421afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return b->frontbuffer; 1422afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1423afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1424afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1425b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_MESA_pixmap_colormap ***/ 1426b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul 1427426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPixmap 1428426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visinfo, 1429426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul Pixmap pixmap, Colormap cmap ) 1430afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1431afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaVisual v; 1432afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaBuffer b; 1433afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1434afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg v = find_glx_visual( dpy, visinfo ); 1435afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!v) { 1436afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg v = create_glx_visual( dpy, visinfo ); 1437afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!v) { 1438afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* unusable visual */ 1439afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1440afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1441afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1442afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1443afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg b = XMesaCreatePixmapBuffer( v, pixmap, cmap ); 1444afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!b) { 1445afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1446afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1447afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return b->frontbuffer; 1448afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1449afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1450afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1451426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1452426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyGLXPixmap( Display *dpy, GLXPixmap pixmap ) 1453afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1454afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaBuffer b = XMesaFindBuffer(dpy, pixmap); 1455afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (b) { 1456afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaDestroyBuffer(b); 1457afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1458367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul else if (_mesa_getenv("MESA_DEBUG")) { 1459d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul _mesa_warning(NULL, "Mesa: glXDestroyGLXPixmap: invalid pixmap\n"); 1460afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1461afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1462afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1463afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1464426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1465426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCopyContext( Display *dpy, GLXContext src, GLXContext dst, 14663994b77bab8c62a4c1a4dffdfba233ef46662b99Brian Paul unsigned long mask ) 1467afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 146883b820aa98931ef30fa73c72b2a96fe23885955eBrian Paul struct fake_glx_context *fakeSrc = (struct fake_glx_context *) src; 146983b820aa98931ef30fa73c72b2a96fe23885955eBrian Paul struct fake_glx_context *fakeDst = (struct fake_glx_context *) dst; 147083b820aa98931ef30fa73c72b2a96fe23885955eBrian Paul XMesaContext xm_src = fakeSrc->xmesaContext; 147183b820aa98931ef30fa73c72b2a96fe23885955eBrian Paul XMesaContext xm_dst = fakeDst->xmesaContext; 1472afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 14731e24d3318df57b36e3b68695ff64b4b8bd822c9eBrian Paul _mesa_copy_context( &(xm_src->mesa), &(xm_dst->mesa), (GLuint) mask ); 1474afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1475afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1476afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1477426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool 1478426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryExtension( Display *dpy, int *errorb, int *event ) 1479afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1480afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Mesa's GLX isn't really an X extension but we try to act like one. */ 1481afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 1482afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) errorb; 1483afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) event; 1484afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return True; 1485afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1486afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1487afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1488e7b16b74bf5d13331b5a88bbbbb9096560297b63Brian Paulextern void _kw_ungrab_all( Display *dpy ); 1489afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgvoid _kw_ungrab_all( Display *dpy ) 1490afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1491afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XUngrabPointer( dpy, CurrentTime ); 1492afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XUngrabKeyboard( dpy, CurrentTime ); 1493afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1494afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1495afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1496426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1497426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyContext( Display *dpy, GLXContext ctx ) 1498afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 14997cf50e137da497a590ec9001a9918972a6246142Brian Paul struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx; 1500afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 1501afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg MakeCurrent_PrevContext = 0; 1502afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg MakeCurrent_PrevDrawable = 0; 1503086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevReadable = 0; 1504086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevDrawBuffer = 0; 1505086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevReadBuffer = 0; 15067cf50e137da497a590ec9001a9918972a6246142Brian Paul XMesaDestroyContext( glxCtx->xmesaContext ); 1507afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaGarbageCollect(); 1508afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1509afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1510afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1511426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool 1512426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXIsDirect( Display *dpy, GLXContext ctx ) 1513afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 15147cf50e137da497a590ec9001a9918972a6246142Brian Paul struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx; 1515afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 15167cf50e137da497a590ec9001a9918972a6246142Brian Paul return glxCtx->xmesaContext->direct; 1517afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1518afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1519afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1520afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1521426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1522426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXSwapBuffers( Display *dpy, GLXDrawable drawable ) 1523afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1524afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaBuffer buffer = XMesaFindBuffer( dpy, drawable ); 1525afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1526afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (buffer) { 1527afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaSwapBuffers(buffer); 1528afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1529367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul else if (_mesa_getenv("MESA_DEBUG")) { 1530ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul _mesa_warning(NULL, "glXSwapBuffers: invalid drawable 0x%x\n", 1531ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul (int) drawable); 1532afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1533afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1534afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1535afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 15364c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul 1537b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_MESA_copy_sub_buffer ***/ 1538b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul 1539426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1540426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCopySubBufferMESA( Display *dpy, GLXDrawable drawable, 1541426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul int x, int y, int width, int height ) 1542afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1543afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaBuffer buffer = XMesaFindBuffer( dpy, drawable ); 1544afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (buffer) { 1545afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaCopySubBuffer(buffer, x, y, width, height); 1546afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1547367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul else if (_mesa_getenv("MESA_DEBUG")) { 1548d09a1d8b29ae5841ae39b5c24c3f4693dd750559Brian Paul _mesa_warning(NULL, "Mesa: glXCopySubBufferMESA: invalid drawable\n"); 1549afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1550afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1551afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1552afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1553426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool 1554426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryVersion( Display *dpy, int *maj, int *min ) 1555afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1556afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 1557afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Return GLX version, not Mesa version */ 155878fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul assert(CLIENT_MAJOR_VERSION == SERVER_MAJOR_VERSION); 155978fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul *maj = CLIENT_MAJOR_VERSION; 156078fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul *min = MIN2( CLIENT_MINOR_VERSION, SERVER_MINOR_VERSION ); 1561afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return True; 1562afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1563afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1564afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1565afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 1566afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Query the GLX attributes of the given XVisualInfo. 1567afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 1568426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int 1569e4656003caee346d9c4eb23256d73409271291a7Brian Paulget_config( XMesaVisual xmvis, int attrib, int *value, GLboolean fbconfig ) 1570afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1571e4656003caee346d9c4eb23256d73409271291a7Brian Paul ASSERT(xmvis); 1572afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch(attrib) { 1573afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_USE_GL: 15741f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul if (fbconfig) 15751f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul return GLX_BAD_ATTRIBUTE; 1576afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = (int) True; 1577afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1578afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_BUFFER_SIZE: 1579e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->visinfo->depth; 1580afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1581afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_LEVEL: 1582304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick *value = xmvis->mesa_visual.level; 1583afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1584afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_RGBA: 15851f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul if (fbconfig) 15861f98ee90228aa56df207cdbd223bb4b8c0bb15d9Brian Paul return GLX_BAD_ATTRIBUTE; 1587e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (xmvis->mesa_visual.rgbMode) { 1588afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = True; 1589afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1590afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 1591afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = False; 1592afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1593afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1594afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_DOUBLEBUFFER: 1595e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = (int) xmvis->mesa_visual.doubleBufferMode; 1596afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1597afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STEREO: 1598e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = (int) xmvis->mesa_visual.stereoMode; 1599afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1600afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_AUX_BUFFERS: 1601894844a8d956a0ee5f95836331dc318f49fdb845Brian Paul *value = xmvis->mesa_visual.numAuxBuffers; 1602afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1603afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_RED_SIZE: 1604e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->mesa_visual.redBits; 1605afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1606afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_GREEN_SIZE: 1607e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->mesa_visual.greenBits; 1608afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1609afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_BLUE_SIZE: 1610e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->mesa_visual.blueBits; 1611afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1612afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ALPHA_SIZE: 1613e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->mesa_visual.alphaBits; 1614afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1615afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_DEPTH_SIZE: 1616e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->mesa_visual.depthBits; 1617afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1618afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STENCIL_SIZE: 1619e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->mesa_visual.stencilBits; 1620afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1621afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_RED_SIZE: 1622e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->mesa_visual.accumRedBits; 1623b2e460018375f699198073a6167e0ee96ba1d267Brian Paul return 0; 1624afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_GREEN_SIZE: 1625e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->mesa_visual.accumGreenBits; 1626b2e460018375f699198073a6167e0ee96ba1d267Brian Paul return 0; 1627afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_BLUE_SIZE: 1628e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->mesa_visual.accumBlueBits; 1629afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1630afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_ALPHA_SIZE: 1631e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->mesa_visual.accumAlphaBits; 1632afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1633afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1634afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* 1635afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * GLX_EXT_visual_info extension 1636afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 1637afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_X_VISUAL_TYPE_EXT: 1638e4656003caee346d9c4eb23256d73409271291a7Brian Paul switch (xmvis->visinfo->CLASS) { 1639afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case StaticGray: *value = GLX_STATIC_GRAY_EXT; return 0; 1640afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GrayScale: *value = GLX_GRAY_SCALE_EXT; return 0; 1641afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case StaticColor: *value = GLX_STATIC_GRAY_EXT; return 0; 1642afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case PseudoColor: *value = GLX_PSEUDO_COLOR_EXT; return 0; 1643afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case TrueColor: *value = GLX_TRUE_COLOR_EXT; return 0; 1644afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case DirectColor: *value = GLX_DIRECT_COLOR_EXT; return 0; 1645afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1646afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1647afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_TYPE_EXT: 1648304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick if (xmvis->mesa_visual.level==0) { 1649afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* normal planes */ 1650afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = GLX_NONE_EXT; 1651afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1652304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick else if (xmvis->mesa_visual.level>0) { 1653afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* overlay */ 1654e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (xmvis->mesa_visual.rgbMode) { 1655afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = GLX_TRANSPARENT_RGB_EXT; 1656afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1657afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 1658afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = GLX_TRANSPARENT_INDEX_EXT; 1659afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1660afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1661304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick else if (xmvis->mesa_visual.level<0) { 1662afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* underlay */ 1663afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = GLX_NONE_EXT; 1664afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1665afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1666afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_INDEX_VALUE_EXT: 1667afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg { 1668e4656003caee346d9c4eb23256d73409271291a7Brian Paul int pixel = transparent_pixel( xmvis ); 1669afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (pixel>=0) { 1670afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = pixel; 1671afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1672afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* else undefined */ 1673afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1674afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1675afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_RED_VALUE_EXT: 1676afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* undefined */ 1677afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1678afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_GREEN_VALUE_EXT: 1679afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* undefined */ 1680afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1681afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_BLUE_VALUE_EXT: 1682afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* undefined */ 1683afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1684afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_ALPHA_VALUE_EXT: 1685afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* undefined */ 1686afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1687afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1688afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* 1689b2e460018375f699198073a6167e0ee96ba1d267Brian Paul * GLX_EXT_visual_info extension 1690b2e460018375f699198073a6167e0ee96ba1d267Brian Paul */ 1691b2e460018375f699198073a6167e0ee96ba1d267Brian Paul case GLX_VISUAL_CAVEAT_EXT: 1692fc68be6b111473a0bf8f991468f973bb9dd275f4Brian Paul /* test for zero, just in case */ 1693304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick if (xmvis->mesa_visual.visualRating > 0) 1694304d3aa9cb727eb4cd4797c33f8e13e5ac4285a9Ian Romanick *value = xmvis->mesa_visual.visualRating; 1695962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul else 1696962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul *value = GLX_NONE_EXT; 1697962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul return 0; 1698b2e460018375f699198073a6167e0ee96ba1d267Brian Paul 1699b2e460018375f699198073a6167e0ee96ba1d267Brian Paul /* 170066ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul * GLX_ARB_multisample 1701afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 170266ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul case GLX_SAMPLE_BUFFERS_ARB: 17033265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul *value = 0; 17043265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return 0; 170566ab7271016615cf485fb0b71832833d2e0f99a7Brian Paul case GLX_SAMPLES_ARB: 17063265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul *value = 0; 17073265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return 0; 17083265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul 17093265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul /* 17103265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul * For FBConfigs: 17113265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul */ 17123265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_SCREEN_EXT: 17133265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (!fbconfig) 17143265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return GLX_BAD_ATTRIBUTE; 1715e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = xmvis->visinfo->screen; 17163265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 17173265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_DRAWABLE_TYPE: /*SGIX too */ 17183265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (!fbconfig) 17193265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return GLX_BAD_ATTRIBUTE; 17203265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul *value = GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT; 17213265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 17223265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_RENDER_TYPE_SGIX: 17233265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (!fbconfig) 17243265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return GLX_BAD_ATTRIBUTE; 1725e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (xmvis->mesa_visual.rgbMode) 17263265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul *value = GLX_RGBA_BIT; 17273265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul else 17283265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul *value = GLX_COLOR_INDEX_BIT; 17293265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 17303265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_X_RENDERABLE_SGIX: 17313265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (!fbconfig) 17323265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return GLX_BAD_ATTRIBUTE; 17333265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul *value = True; /* XXX really? */ 17343265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 17353265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_FBCONFIG_ID_SGIX: 17363265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (!fbconfig) 17373265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return GLX_BAD_ATTRIBUTE; 1738f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul *value = xmvis->visinfo->visualid; 17393265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 17403265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_MAX_PBUFFER_WIDTH: 17413265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (!fbconfig) 17423265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return GLX_BAD_ATTRIBUTE; 17433265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul /* XXX or MAX_WIDTH? */ 1744f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul *value = DisplayWidth(xmvis->display, xmvis->visinfo->screen); 17453265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 17463265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_MAX_PBUFFER_HEIGHT: 17473265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (!fbconfig) 17483265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return GLX_BAD_ATTRIBUTE; 1749f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul *value = DisplayHeight(xmvis->display, xmvis->visinfo->screen); 17503265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 17513265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_MAX_PBUFFER_PIXELS: 17523265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (!fbconfig) 17533265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return GLX_BAD_ATTRIBUTE; 1754f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul *value = DisplayWidth(xmvis->display, xmvis->visinfo->screen) * 1755f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul DisplayHeight(xmvis->display, xmvis->visinfo->screen); 17563265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 17573265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_VISUAL_ID: 17583265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (!fbconfig) 17593265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return GLX_BAD_ATTRIBUTE; 1760f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul *value = xmvis->visinfo->visualid; 17613265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 17623265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul 1763afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: 1764afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return GLX_BAD_ATTRIBUTE; 1765afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 17663265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return Success; 1767afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1768afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1769afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 17703265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paulstatic int 17713265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian PaulFake_glXGetConfig( Display *dpy, XVisualInfo *visinfo, 17723265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul int attrib, int *value ) 17733265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul{ 1774e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaVisual xmvis; 1775ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul int k; 1776379641956d134b8dc761b6411d7c4dca8f94a092Brian Paul if (!dpy || !visinfo) 1777a9a1c3f20f2d6aad4afc47cf2b29c5393fddb6b6Brian Paul return GLX_BAD_ATTRIBUTE; 1778a9a1c3f20f2d6aad4afc47cf2b29c5393fddb6b6Brian Paul 1779e4656003caee346d9c4eb23256d73409271291a7Brian Paul xmvis = find_glx_visual( dpy, visinfo ); 1780e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (!xmvis) { 17813265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul /* this visual wasn't obtained with glXChooseVisual */ 1782e4656003caee346d9c4eb23256d73409271291a7Brian Paul xmvis = create_glx_visual( dpy, visinfo ); 1783e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (!xmvis) { 17843265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul /* this visual can't be used for GL rendering */ 17853265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (attrib==GLX_USE_GL) { 17863265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul *value = (int) False; 17873265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return 0; 17883265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 17893265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul else { 17903265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return GLX_BAD_VISUAL; 17913265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 17923265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 17933265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 17943265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul 1795ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul k = get_config(xmvis, attrib, value, GL_FALSE); 1796ba0fe1832e3573c7ec872ba9bfb1cf1773e384c6Brian Paul return k; 17973265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul} 17983265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul 1799afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1800426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1801426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXWaitGL( void ) 1802afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1803afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaContext xmesa = XMesaGetCurrentContext(); 1804afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaFlush( xmesa ); 1805afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1806afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1807afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1808afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1809426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1810426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXWaitX( void ) 1811afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1812afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaContext xmesa = XMesaGetCurrentContext(); 1813afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaFlush( xmesa ); 1814afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1815afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1816afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1817e4656003caee346d9c4eb23256d73409271291a7Brian Paulstatic const char * 1818e4656003caee346d9c4eb23256d73409271291a7Brian Paulget_extensions( void ) 181943c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul{ 182043c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul#ifdef FX 1821367d308b8267ad86cd7623590b7bfd4737b5fbf5Brian Paul const char *fx = _mesa_getenv("MESA_GLX_FX"); 182243c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul if (fx && fx[0] != 'd') { 1823e4656003caee346d9c4eb23256d73409271291a7Brian Paul return EXTENSIONS; 182443c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul } 182543c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul#endif 1826e4656003caee346d9c4eb23256d73409271291a7Brian Paul return EXTENSIONS + 23; /* skip "GLX_MESA_set_3dfx_mode" */ 182743c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul} 1828afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1829afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1830afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1831afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* GLX 1.1 and later */ 1832426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic const char * 1833426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryExtensionsString( Display *dpy, int screen ) 1834afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1835afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 1836afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) screen; 183743c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul return get_extensions(); 1838afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1839afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1840afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1841afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1842afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* GLX 1.1 and later */ 1843426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic const char * 1844426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryServerString( Display *dpy, int screen, int name ) 1845afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 184678fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul static char version[1000]; 18472ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul _mesa_sprintf(version, "%d.%d %s", 18482ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul SERVER_MAJOR_VERSION, SERVER_MINOR_VERSION, MESA_GLX_VERSION); 1849afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1850afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 1851afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) screen; 1852afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1853afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (name) { 1854afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_EXTENSIONS: 185543c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul return get_extensions(); 1856afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_VENDOR: 185778fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul return VENDOR; 1858afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_VERSION: 1859afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return version; 1860afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: 1861afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 1862afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1863afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1864afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1865afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1866afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1867afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* GLX 1.1 and later */ 1868426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic const char * 1869426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetClientString( Display *dpy, int name ) 1870afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 187178fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul static char version[1000]; 18722ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul _mesa_sprintf(version, "%d.%d %s", CLIENT_MAJOR_VERSION, 18732ad5921cf3c9737796c3485bd5b9f738fb4a3cb9Brian Paul CLIENT_MINOR_VERSION, MESA_GLX_VERSION); 1874afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1875afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 1876afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1877afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (name) { 1878afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_EXTENSIONS: 187943c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul return get_extensions(); 1880afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_VENDOR: 188178fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul return VENDOR; 1882afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_VERSION: 1883afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return version; 1884afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: 1885afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 1886afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1887afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1888afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1889afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1890afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1891426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul/* 1892426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul * GLX 1.3 and later 1893426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul */ 1894426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 18957d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 18965605798e56ca6e9f968623f33b58ee7ca90594afBrian Paulstatic GLXFBConfig * 1897426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXChooseFBConfig( Display *dpy, int screen, 1898426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul const int *attribList, int *nitems ) 1899426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 1900b3063ac398b72e6a4fd2015d4e220495b9779294Brian Paul XMesaVisual xmvis = choose_visual(dpy, screen, attribList, GL_TRUE); 19013265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (xmvis) { 19024039cb8ca82d59451a6de8902fe35e693cdca3baBrian Paul GLXFBConfig *config = (GLXFBConfig *) _mesa_malloc(sizeof(XMesaVisual)); 19033265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (!config) { 19043265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul *nitems = 0; 19053265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return NULL; 19063265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 19073265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul *nitems = 1; 19083265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul config[0] = (GLXFBConfig) xmvis; 19093265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return (GLXFBConfig *) config; 19103265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 19113265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul else { 19123265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul *nitems = 0; 19133265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return NULL; 19143265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 1915426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1916426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1917426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1918426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int 1919426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetFBConfigAttrib( Display *dpy, GLXFBConfig config, 1920426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul int attribute, int *value ) 1921426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 19223265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul XMesaVisual v = (XMesaVisual) config; 1923426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 1924426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) config; 19257d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 19267d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul if (!dpy || !config || !value) 19277d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return -1; 19287d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 19293265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return get_config(v, attribute, value, GL_TRUE); 1930426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1931426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1932426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 19335605798e56ca6e9f968623f33b58ee7ca90594afBrian Paulstatic GLXFBConfig * 19345605798e56ca6e9f968623f33b58ee7ca90594afBrian PaulFake_glXGetFBConfigs( Display *dpy, int screen, int *nelements ) 19355605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul{ 19363265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul XVisualInfo *visuals, visTemplate; 19373265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul const long visMask = VisualScreenMask; 19383265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul int i; 19393265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul 19403265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul /* Get list of all X visuals */ 19413265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul visTemplate.screen = screen; 19423265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul visuals = XGetVisualInfo(dpy, visMask, &visTemplate, nelements); 19433265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (*nelements > 0) { 19443265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul XMesaVisual *results; 19454039cb8ca82d59451a6de8902fe35e693cdca3baBrian Paul results = (XMesaVisual *) _mesa_malloc(*nelements * sizeof(XMesaVisual)); 19463265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul if (!results) { 19473265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul *nelements = 0; 19483265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return NULL; 19493265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 19503265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul for (i = 0; i < *nelements; i++) { 19513265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul results[i] = create_glx_visual(dpy, visuals + i); 19523265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 19533265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return (GLXFBConfig *) results; 19543265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 19553265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return NULL; 19565605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul} 19575605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul 19585605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul 1959426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic XVisualInfo * 1960426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetVisualFromFBConfig( Display *dpy, GLXFBConfig config ) 1961426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 19627d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul if (dpy && config) { 1963f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul XMesaVisual xmvis = (XMesaVisual) config; 1964f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul#if 0 1965f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul return xmvis->vishandle; 1966f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul#else 1967f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul /* create a new vishandle - the cached one may be stale */ 19684039cb8ca82d59451a6de8902fe35e693cdca3baBrian Paul xmvis->vishandle = (XVisualInfo *) _mesa_malloc(sizeof(XVisualInfo)); 1969f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul if (xmvis->vishandle) { 1970f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul _mesa_memcpy(xmvis->vishandle, xmvis->visinfo, sizeof(XVisualInfo)); 1971f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul } 1972f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul return xmvis->vishandle; 1973f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul#endif 19747d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul } 19757d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul else { 19767d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return NULL; 19777d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul } 1978426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1979426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1980426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1981426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXWindow 1982426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateWindow( Display *dpy, GLXFBConfig config, Window win, 1983426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul const int *attribList ) 1984426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 1985529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul XMesaVisual xmvis = (XMesaVisual) config; 1986529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul XMesaBuffer xmbuf; 1987529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul if (!xmvis) 1988529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul return 0; 1989529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul 1990529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul xmbuf = XMesaCreateWindowBuffer2(xmvis, win, NULL); 1991529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul if (!xmbuf) 1992529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul return 0; 1993529614cd1a1e426ca7ad019795a6b72ad51cd9e6Brian Paul 1994426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 19957d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul (void) attribList; /* Ignored in GLX 1.3 */ 19967d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 19977d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return win; /* A hack for now */ 1998426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1999426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2000426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2001426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 2002426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyWindow( Display *dpy, GLXWindow window ) 2003426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 20047d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul XMesaBuffer b = XMesaFindBuffer(dpy, (XMesaDrawable) window); 20057d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul if (b) 20067d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul XMesaDestroyBuffer(b); 20077d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul /* don't destroy X window */ 2008426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2009426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2010426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 20117d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul/* XXX untested */ 2012426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPixmap 2013426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreatePixmap( Display *dpy, GLXFBConfig config, Pixmap pixmap, 2014426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul const int *attribList ) 2015426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 20167d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul XMesaVisual v = (XMesaVisual) config; 20177d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul XMesaBuffer b; 20187d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 2019426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 2020426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) config; 2021426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) pixmap; 20227d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul (void) attribList; /* Ignored in GLX 1.3 */ 20237d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 20247d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul if (!dpy || !config || !pixmap) 20257d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return 0; 20267d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 20277d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul b = XMesaCreatePixmapBuffer( v, pixmap, 0 ); 20287d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul if (!b) { 20297d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return 0; 20307d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul } 20317d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 20327d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return pixmap; 2033426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2034426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2035426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2036426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 2037426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyPixmap( Display *dpy, GLXPixmap pixmap ) 2038426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 20397d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul XMesaBuffer b = XMesaFindBuffer(dpy, (XMesaDrawable)pixmap); 20407d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul if (b) 20417d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul XMesaDestroyBuffer(b); 20427d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul /* don't destroy X pixmap */ 2043426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2044426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2045426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2046426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPbuffer 2047426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreatePbuffer( Display *dpy, GLXFBConfig config, 2048426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul const int *attribList ) 2049426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 20503265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul XMesaVisual xmvis = (XMesaVisual) config; 20513265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul XMesaBuffer xmbuf; 20527d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul const int *attrib; 20537d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul int width = 0, height = 0; 20547d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul GLboolean useLargest = GL_FALSE, preserveContents = GL_FALSE; 20557d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 2056426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 20577d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 20583265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul for (attrib = attribList; *attrib; attrib++) { 20597d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul switch (*attrib) { 20607d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_PBUFFER_WIDTH: 20613265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul attrib++; 20623265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul width = *attrib; 20637d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul break; 20647d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_PBUFFER_HEIGHT: 20653265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul attrib++; 20663265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul height = *attrib; 20677d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul break; 20687d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_PRESERVED_CONTENTS: 20693265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul attrib++; 20703265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul preserveContents = *attrib; /* ignored */ 20717d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul break; 20727d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_LARGEST_PBUFFER: 20733265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul attrib++; 20743265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul useLargest = *attrib; /* ignored */ 20757d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul break; 20767d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul default: 20777d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return 0; 20787d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul } 20797d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul } 20807d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 2081b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul /* not used at this time */ 2082b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul (void) useLargest; 2083b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul (void) preserveContents; 2084b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul 20857d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul if (width == 0 || height == 0) 20867d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return 0; 20877d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 20883265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul xmbuf = XMesaCreatePBuffer( xmvis, 0, width, height); 2089e4656003caee346d9c4eb23256d73409271291a7Brian Paul /* A GLXPbuffer handle must be an X Drawable because that's what 2090e4656003caee346d9c4eb23256d73409271291a7Brian Paul * glXMakeCurrent takes. 2091e4656003caee346d9c4eb23256d73409271291a7Brian Paul */ 2092e4656003caee346d9c4eb23256d73409271291a7Brian Paul return (GLXPbuffer) xmbuf->frontbuffer; 2093426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2094426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2095426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2096426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 2097426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyPbuffer( Display *dpy, GLXPbuffer pbuf ) 2098426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 2099e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaBuffer b = XMesaFindBuffer(dpy, pbuf); 2100e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (b) { 2101e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaDestroyBuffer(b); 2102e4656003caee346d9c4eb23256d73409271291a7Brian Paul } 2103426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2104426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2105426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2106426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 2107426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryDrawable( Display *dpy, GLXDrawable draw, int attribute, 2108426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul unsigned int *value ) 2109426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 2110e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaBuffer xmbuf = XMesaFindBuffer(dpy, draw); 2111e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (!xmbuf) 2112e4656003caee346d9c4eb23256d73409271291a7Brian Paul return; 21137d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 21147d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul switch (attribute) { 21157d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_WIDTH: 211629926a11b16ec7a235947d95e9a46777605dd30eBrian Paul *value = xmbuf->mesa_buffer.Width; 2117e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 21187d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_HEIGHT: 211929926a11b16ec7a235947d95e9a46777605dd30eBrian Paul *value = xmbuf->mesa_buffer.Height; 2120e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 21217d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_PRESERVED_CONTENTS: 2122e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = True; 2123e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 21247d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_LARGEST_PBUFFER: 212529926a11b16ec7a235947d95e9a46777605dd30eBrian Paul *value = xmbuf->mesa_buffer.Width * xmbuf->mesa_buffer.Height; 2126e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 21277d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_FBCONFIG_ID: 2128f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul *value = xmbuf->xm_visual->visinfo->visualid; 21297d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return; 21307d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul default: 21317d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return; /* GLX_BAD_ATTRIBUTE? */ 21327d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul } 2133426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2134426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2135426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2136426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXContext 2137426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateNewContext( Display *dpy, GLXFBConfig config, 2138426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul int renderType, GLXContext shareList, Bool direct ) 2139426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 2140f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul struct fake_glx_context *glxCtx; 2141f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul struct fake_glx_context *shareCtx = (struct fake_glx_context *) shareList; 2142f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul XMesaVisual xmvis = (XMesaVisual) config; 21437d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 21447d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul if (!dpy || !config || 21457d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul (renderType != GLX_RGBA_TYPE && renderType != GLX_COLOR_INDEX_TYPE)) 21467d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return 0; 21477d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 2148f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul glxCtx = CALLOC_STRUCT(fake_glx_context); 2149f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul if (!glxCtx) 2150f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul return 0; 2151f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul 2152f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul /* deallocate unused windows/buffers */ 2153f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul XMesaGarbageCollect(); 2154f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul 2155f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul glxCtx->xmesaContext = XMesaCreateContext(xmvis, 2156f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul shareCtx ? shareCtx->xmesaContext : NULL); 2157f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul if (!glxCtx->xmesaContext) { 2158f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul FREE(glxCtx); 2159f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul return NULL; 2160f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul } 2161f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul 2162f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul glxCtx->xmesaContext->direct = GL_FALSE; 2163f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul glxCtx->glxContext.isDirect = GL_FALSE; 2164f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul glxCtx->glxContext.currentDpy = dpy; 2165f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul glxCtx->glxContext.xid = (XID) glxCtx; /* self pointer */ 2166f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul 2167f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul assert((void *) glxCtx == (void *) &(glxCtx->glxContext)); 2168f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul 2169f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul return (GLXContext) glxCtx; 2170426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2171426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2172426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2173426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int 2174426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryContext( Display *dpy, GLXContext ctx, int attribute, int *value ) 2175426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 2176e4656003caee346d9c4eb23256d73409271291a7Brian Paul struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx; 2177e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaContext xmctx = glxCtx->xmesaContext; 2178e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2179426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 2180426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) ctx; 21817d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul 21827d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul switch (attribute) { 21837d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_FBCONFIG_ID: 2184f104619b8f6ece7a60aa365c859b03fbc1d74592Brian Paul *value = xmctx->xm_visual->visinfo->visualid; 2185e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 21867d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_RENDER_TYPE: 2187e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (xmctx->xm_visual->mesa_visual.rgbMode) 2188e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = GLX_RGBA_BIT; 2189e4656003caee346d9c4eb23256d73409271291a7Brian Paul else 2190e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = GLX_COLOR_INDEX_BIT; 2191e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 21927d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul case GLX_SCREEN: 21937d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul *value = 0; 21947d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return Success; 21957d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul default: 21967d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul return GLX_BAD_ATTRIBUTE; 21977d5656bee7d3e0c4ba54005c7af6f59f4bf8aea0Brian Paul } 2198e4656003caee346d9c4eb23256d73409271291a7Brian Paul return 0; 2199426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2200426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2201426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2202426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 2203426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXSelectEvent( Display *dpy, GLXDrawable drawable, unsigned long mask ) 2204426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 2205e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable); 2206e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (xmbuf) 2207e4656003caee346d9c4eb23256d73409271291a7Brian Paul xmbuf->selectedEvents = mask; 2208426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2209426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2210426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2211426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 2212426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetSelectedEvent( Display *dpy, GLXDrawable drawable, 2213426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul unsigned long *mask ) 2214426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 2215e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable); 2216e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (xmbuf) 2217e4656003caee346d9c4eb23256d73409271291a7Brian Paul *mask = xmbuf->selectedEvents; 2218e4656003caee346d9c4eb23256d73409271291a7Brian Paul else 2219e4656003caee346d9c4eb23256d73409271291a7Brian Paul *mask = 0; 2220426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2221b82d993b03320818f88f792a9e713f7ed491bfcbBrian Paul 2222b82d993b03320818f88f792a9e713f7ed491bfcbBrian Paul 2223b82d993b03320818f88f792a9e713f7ed491bfcbBrian Paul 2224b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGI_swap_control ***/ 2225783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2226783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int 2227783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXSwapIntervalSGI(int interval) 2228783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2229783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) interval; 2230783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2231783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2232783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2233783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2234783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2235b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGI_video_sync ***/ 2236783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2237783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int 2238783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetVideoSyncSGI(unsigned int *count) 2239783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2240783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) count; 2241783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2242783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2243783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2244783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int 2245783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count) 2246783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2247783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) divisor; 2248783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) remainder; 2249783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) count; 2250783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2251783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2252783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2253783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2254783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2255b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGI_make_current_read ***/ 2256783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2257426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool 2258783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXMakeCurrentReadSGI(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx) 2259afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 2260a078d75a27b99252ede6520e24b145106ab98aa2Brian Paul return Fake_glXMakeContextCurrent( dpy, draw, read, ctx ); 2261afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 2262783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 22637cf50e137da497a590ec9001a9918972a6246142Brian Paul/* not used 2264783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXDrawable 2265b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian PaulFake_glXGetCurrentReadDrawableSGI(void) 2266783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2267783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2268783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 22697cf50e137da497a590ec9001a9918972a6246142Brian Paul*/ 2270afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 2271afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 2272b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_video_source ***/ 2273b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#if defined(_VL_H) 22744c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul 2275783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXVideoSourceSGIX 2276783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXCreateGLXVideoSourceSGIX(Display *dpy, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode) 2277afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 2278783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2279783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) screen; 2280783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) server; 2281783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) path; 2282783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) nodeClass; 2283783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) drainNode; 2284783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2285783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2286783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2287783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void 2288783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXDestroyGLXVideoSourceSGIX(Display *dpy, GLXVideoSourceSGIX src) 2289783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2290783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2291783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) src; 2292afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 2293783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 22944c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul#endif 22954c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul 229689a42b7e736bd9b0ab090906cab0cd047a6ec12eBrian Paul 2297b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_EXT_import_context ***/ 229889a42b7e736bd9b0ab090906cab0cd047a6ec12eBrian Paul 2299783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void 2300783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXFreeContextEXT(Display *dpy, GLXContext context) 2301783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2302783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2303783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) context; 2304783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2305426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2306783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXContextID 2307783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetContextIDEXT(const GLXContext context) 2308783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2309783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) context; 2310783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2311783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2312783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2313783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXContext 2314783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXImportContextEXT(Display *dpy, GLXContextID contextID) 2315783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2316783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2317783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) contextID; 2318783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2319783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2320426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2321426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int 2322783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryContextInfoEXT(Display *dpy, GLXContext context, int attribute, int *value) 2323426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 2324783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2325783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) context; 2326783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) attribute; 2327783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) value; 2328426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul return 0; 2329426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2330426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2331783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2332783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2333b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_fbconfig ***/ 2334426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2335426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int 2336783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetFBConfigAttribSGIX(Display *dpy, GLXFBConfigSGIX config, int attribute, int *value) 2337783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 23383265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return Fake_glXGetFBConfigAttrib(dpy, config, attribute, value); 2339783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2340783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2341783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXFBConfigSGIX * 2342783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXChooseFBConfigSGIX(Display *dpy, int screen, int *attrib_list, int *nelements) 2343783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 23443265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return (GLXFBConfig *) Fake_glXChooseFBConfig(dpy, screen, attrib_list, nelements); 2345783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2346783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2347e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2348783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXPixmap 2349783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXCreateGLXPixmapWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap) 2350783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2351e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaVisual xmvis = (XMesaVisual) config; 2352e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaBuffer xmbuf = XMesaCreatePixmapBuffer(xmvis, pixmap, 0); 2353e4656003caee346d9c4eb23256d73409271291a7Brian Paul return xmbuf->frontbuffer; /* need to return an X ID */ 2354783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2355783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2356e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2357783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXContext 2358783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct) 2359783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2360e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaVisual xmvis = (XMesaVisual) config; 2361e4656003caee346d9c4eb23256d73409271291a7Brian Paul struct fake_glx_context *glxCtx; 2362e4656003caee346d9c4eb23256d73409271291a7Brian Paul struct fake_glx_context *shareCtx = (struct fake_glx_context *) share_list; 2363e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2364e4656003caee346d9c4eb23256d73409271291a7Brian Paul glxCtx = CALLOC_STRUCT(fake_glx_context); 2365e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (!glxCtx) 2366e4656003caee346d9c4eb23256d73409271291a7Brian Paul return 0; 2367e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2368e4656003caee346d9c4eb23256d73409271291a7Brian Paul /* deallocate unused windows/buffers */ 2369e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaGarbageCollect(); 2370e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2371e4656003caee346d9c4eb23256d73409271291a7Brian Paul glxCtx->xmesaContext = XMesaCreateContext(xmvis, 2372e4656003caee346d9c4eb23256d73409271291a7Brian Paul shareCtx ? shareCtx->xmesaContext : NULL); 2373e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (!glxCtx->xmesaContext) { 2374e4656003caee346d9c4eb23256d73409271291a7Brian Paul FREE(glxCtx); 2375e4656003caee346d9c4eb23256d73409271291a7Brian Paul return NULL; 2376e4656003caee346d9c4eb23256d73409271291a7Brian Paul } 2377e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2378e4656003caee346d9c4eb23256d73409271291a7Brian Paul glxCtx->xmesaContext->direct = GL_FALSE; 2379e4656003caee346d9c4eb23256d73409271291a7Brian Paul glxCtx->glxContext.isDirect = GL_FALSE; 2380e4656003caee346d9c4eb23256d73409271291a7Brian Paul glxCtx->glxContext.currentDpy = dpy; 2381e4656003caee346d9c4eb23256d73409271291a7Brian Paul glxCtx->glxContext.xid = (XID) glxCtx; /* self pointer */ 2382e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2383e4656003caee346d9c4eb23256d73409271291a7Brian Paul assert((void *) glxCtx == (void *) &(glxCtx->glxContext)); 2384e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2385e4656003caee346d9c4eb23256d73409271291a7Brian Paul return (GLXContext) glxCtx; 2386783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2387783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2388e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2389783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic XVisualInfo * 2390783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetVisualFromFBConfigSGIX(Display *dpy, GLXFBConfigSGIX config) 2391783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 23923265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return Fake_glXGetVisualFromFBConfig(dpy, config); 2393783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2394783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2395e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2396783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXFBConfigSGIX 2397783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetFBConfigFromVisualSGIX(Display *dpy, XVisualInfo *vis) 2398426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 2399e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaVisual xmvis = find_glx_visual(dpy, vis); 2400e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (!xmvis) { 2401e4656003caee346d9c4eb23256d73409271291a7Brian Paul /* This visual wasn't found with glXChooseVisual() */ 2402e4656003caee346d9c4eb23256d73409271291a7Brian Paul xmvis = create_glx_visual(dpy, vis); 2403e4656003caee346d9c4eb23256d73409271291a7Brian Paul } 2404e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2405e4656003caee346d9c4eb23256d73409271291a7Brian Paul return (GLXFBConfigSGIX) xmvis; 2406426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2407426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2408426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2409426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2410b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_pbuffer ***/ 2411783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2412783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic GLXPbufferSGIX 24133265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian PaulFake_glXCreateGLXPbufferSGIX(Display *dpy, GLXFBConfigSGIX config, 24143265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul unsigned int width, unsigned int height, 24153265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul int *attribList) 2416783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 24173265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul XMesaVisual xmvis = (XMesaVisual) config; 24183265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul XMesaBuffer xmbuf; 24193265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul const int *attrib; 24203265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul GLboolean useLargest = GL_FALSE, preserveContents = GL_FALSE; 24213265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul 2422783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 24233265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul 242411b3028e7ba2fc3b985ab84d7227c290608f83f6Brian Paul for (attrib = attribList; attrib && *attrib; attrib++) { 24253265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul switch (*attrib) { 24263265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_PRESERVED_CONTENTS_SGIX: 24273265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul attrib++; 24283265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul preserveContents = *attrib; /* ignored */ 24293265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 24303265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul case GLX_LARGEST_PBUFFER_SGIX: 24313265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul attrib++; 24323265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul useLargest = *attrib; /* ignored */ 24333265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul break; 24343265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul default: 24353265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul return 0; 24363265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 24373265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul } 24383265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul 2439b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul /* not used at this time */ 2440b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul (void) useLargest; 2441b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul (void) preserveContents; 2442b305028464f02947c0cce0476af0e35f4ed1fafaBrian Paul 24433265fe5f8e47bfa42dd9e5e4a0e717816ad058a0Brian Paul xmbuf = XMesaCreatePBuffer( xmvis, 0, width, height); 2444e4656003caee346d9c4eb23256d73409271291a7Brian Paul /* A GLXPbuffer handle must be an X Drawable because that's what 2445e4656003caee346d9c4eb23256d73409271291a7Brian Paul * glXMakeCurrent takes. 2446e4656003caee346d9c4eb23256d73409271291a7Brian Paul */ 2447e4656003caee346d9c4eb23256d73409271291a7Brian Paul return (GLXPbuffer) xmbuf->frontbuffer; 2448783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2449783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2450e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2451783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void 2452783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXDestroyGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf) 2453783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2454e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaBuffer xmbuf = XMesaFindBuffer(dpy, pbuf); 2455e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (xmbuf) { 2456e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaDestroyBuffer(xmbuf); 2457e4656003caee346d9c4eb23256d73409271291a7Brian Paul } 2458783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2459783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2460e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2461783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int 2462783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value) 2463783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2464e4656003caee346d9c4eb23256d73409271291a7Brian Paul const XMesaBuffer xmbuf = XMesaFindBuffer(dpy, pbuf); 2465e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2466e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (!xmbuf) { 2467e4656003caee346d9c4eb23256d73409271291a7Brian Paul /* Generate GLXBadPbufferSGIX for bad pbuffer */ 2468e4656003caee346d9c4eb23256d73409271291a7Brian Paul return 0; 2469e4656003caee346d9c4eb23256d73409271291a7Brian Paul } 2470e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2471e4656003caee346d9c4eb23256d73409271291a7Brian Paul switch (attribute) { 2472e4656003caee346d9c4eb23256d73409271291a7Brian Paul case GLX_PRESERVED_CONTENTS_SGIX: 2473e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = True; 2474e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 2475e4656003caee346d9c4eb23256d73409271291a7Brian Paul case GLX_LARGEST_PBUFFER_SGIX: 247629926a11b16ec7a235947d95e9a46777605dd30eBrian Paul *value = xmbuf->mesa_buffer.Width * xmbuf->mesa_buffer.Height; 2477e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 2478e4656003caee346d9c4eb23256d73409271291a7Brian Paul case GLX_WIDTH_SGIX: 247929926a11b16ec7a235947d95e9a46777605dd30eBrian Paul *value = xmbuf->mesa_buffer.Width; 2480e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 2481e4656003caee346d9c4eb23256d73409271291a7Brian Paul case GLX_HEIGHT_SGIX: 248229926a11b16ec7a235947d95e9a46777605dd30eBrian Paul *value = xmbuf->mesa_buffer.Height; 2483e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 2484e4656003caee346d9c4eb23256d73409271291a7Brian Paul case GLX_EVENT_MASK_SGIX: 2485e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = 0; /* XXX might be wrong */ 2486e4656003caee346d9c4eb23256d73409271291a7Brian Paul break; 2487e4656003caee346d9c4eb23256d73409271291a7Brian Paul default: 2488e4656003caee346d9c4eb23256d73409271291a7Brian Paul *value = 0; 2489e4656003caee346d9c4eb23256d73409271291a7Brian Paul } 2490783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2491783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2492783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2493e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2494783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void 2495783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXSelectEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long mask) 2496783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2497e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable); 2498e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (xmbuf) { 2499e4656003caee346d9c4eb23256d73409271291a7Brian Paul /* Note: we'll never generate clobber events */ 2500e4656003caee346d9c4eb23256d73409271291a7Brian Paul xmbuf->selectedEvents = mask; 2501e4656003caee346d9c4eb23256d73409271291a7Brian Paul } 2502783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2503783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2504e4656003caee346d9c4eb23256d73409271291a7Brian Paul 2505783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void 2506783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetSelectedEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long *mask) 2507783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2508e4656003caee346d9c4eb23256d73409271291a7Brian Paul XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable); 2509e4656003caee346d9c4eb23256d73409271291a7Brian Paul if (xmbuf) { 2510e4656003caee346d9c4eb23256d73409271291a7Brian Paul *mask = xmbuf->selectedEvents; 2511e4656003caee346d9c4eb23256d73409271291a7Brian Paul } 2512e4656003caee346d9c4eb23256d73409271291a7Brian Paul else { 2513e4656003caee346d9c4eb23256d73409271291a7Brian Paul *mask = 0; 2514e4656003caee346d9c4eb23256d73409271291a7Brian Paul } 2515783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2516783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2517783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2518783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2519b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGI_cushion ***/ 2520783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2521783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void 2522783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXCushionSGI(Display *dpy, Window win, float cushion) 2523783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2524783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2525783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) win; 2526783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) cushion; 2527783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2528783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2529783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2530783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2531b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_video_resize ***/ 2532783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2533783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int 2534783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXBindChannelToWindowSGIX(Display *dpy, int screen, int channel , Window window) 2535783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2536783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2537783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) screen; 2538783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) channel; 2539783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) window; 2540783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2541783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2542783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2543783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int 2544783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXChannelRectSGIX(Display *dpy, int screen, int channel, int x, int y, int w, int h) 2545783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2546783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2547783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) screen; 2548783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) channel; 2549783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) x; 2550783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) y; 2551783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) w; 2552783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) h; 2553783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2554783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2555783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2556783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int 2557783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryChannelRectSGIX(Display *dpy, int screen, int channel, int *x, int *y, int *w, int *h) 2558783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2559783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2560783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) screen; 2561783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) channel; 2562783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) x; 2563783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) y; 2564783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) w; 2565783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) h; 2566783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2567783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2568783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2569783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int 2570783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryChannelDeltasSGIX(Display *dpy, int screen, int channel, int *dx, int *dy, int *dw, int *dh) 2571783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2572783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2573783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) screen; 2574783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) channel; 2575783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dx; 2576783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dy; 2577783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dw; 2578783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dh; 2579783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2580783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2581783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2582783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic int 2583783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXChannelRectSyncSGIX(Display *dpy, int screen, int channel, GLenum synctype) 2584783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2585783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2586783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) screen; 2587783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) channel; 2588783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) synctype; 2589783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2590783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2591783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2592783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2593783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2594b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_dmbuffer **/ 2595783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2596b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#if defined(_DM_BUFFER_H_) 2597783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Bool 2598783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXAssociateDMPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer) 2599783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2600783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2601783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) pbuffer; 2602783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) params; 2603783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dmbuffer; 2604783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return False; 2605783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2606783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul#endif 2607783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2608783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2609b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_swap_group ***/ 2610783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2611783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void 2612783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXJoinSwapGroupSGIX(Display *dpy, GLXDrawable drawable, GLXDrawable member) 2613783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2614783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2615783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) drawable; 2616783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) member; 2617783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2618783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2619783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2620783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2621b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_swap_barrier ***/ 2622783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2623783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic void 2624783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXBindSwapBarrierSGIX(Display *dpy, GLXDrawable drawable, int barrier) 2625783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2626783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2627783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) drawable; 2628783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) barrier; 2629783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2630783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2631783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Bool 2632783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXQueryMaxSwapBarriersSGIX(Display *dpy, int screen, int *max) 2633783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2634783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2635783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) screen; 2636783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) max; 2637783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return False; 2638783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2639783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2640783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2641783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2642b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SUN_get_transparent_index ***/ 2643783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2644783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Status 2645783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXGetTransparentIndexSUN(Display *dpy, Window overlay, Window underlay, long *pTransparent) 2646783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2647783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) dpy; 2648783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) overlay; 2649783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) underlay; 2650783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul (void) pTransparent; 2651783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return 0; 2652783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2653783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2654783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2655783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2656b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_MESA_release_buffers ***/ 2657b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul 2658783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul/* 2659783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul * Release the depth, stencil, accum buffers attached to a GLXDrawable 2660783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul * (a window or pixmap) prior to destroying the GLXDrawable. 2661783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul */ 2662783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Bool 2663783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXReleaseBuffersMESA( Display *dpy, GLXDrawable d ) 2664783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2665783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul XMesaBuffer b = XMesaFindBuffer(dpy, d); 2666783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul if (b) { 2667783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul XMesaDestroyBuffer(b); 2668783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return True; 2669783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul } 2670783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return False; 2671783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2672783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2673783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2674783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2675b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_MESA_set_3dfx_mode ***/ 2676b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul 2677783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paulstatic Bool 2678783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian PaulFake_glXSet3DfxModeMESA( int mode ) 2679783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul{ 2680783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul return XMesaSetFXmode( mode ); 2681783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul} 2682783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2683783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2684783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 26853c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian Paul/*** GLX_NV_vertex_array range ***/ 26868fefafa2200d3ea44ec46592b190654a10685b46Brian Paulstatic void * 26878fefafa2200d3ea44ec46592b190654a10685b46Brian PaulFake_glXAllocateMemoryNV( GLsizei size, 26888fefafa2200d3ea44ec46592b190654a10685b46Brian Paul GLfloat readFrequency, 26898fefafa2200d3ea44ec46592b190654a10685b46Brian Paul GLfloat writeFrequency, 26908fefafa2200d3ea44ec46592b190654a10685b46Brian Paul GLfloat priority ) 26918fefafa2200d3ea44ec46592b190654a10685b46Brian Paul{ 26928fefafa2200d3ea44ec46592b190654a10685b46Brian Paul (void) size; 26938fefafa2200d3ea44ec46592b190654a10685b46Brian Paul (void) readFrequency; 26948fefafa2200d3ea44ec46592b190654a10685b46Brian Paul (void) writeFrequency; 26958fefafa2200d3ea44ec46592b190654a10685b46Brian Paul (void) priority; 26968fefafa2200d3ea44ec46592b190654a10685b46Brian Paul return NULL; 26978fefafa2200d3ea44ec46592b190654a10685b46Brian Paul} 26988fefafa2200d3ea44ec46592b190654a10685b46Brian Paul 26998fefafa2200d3ea44ec46592b190654a10685b46Brian Paul 27008fefafa2200d3ea44ec46592b190654a10685b46Brian Paulstatic void 27018fefafa2200d3ea44ec46592b190654a10685b46Brian PaulFake_glXFreeMemoryNV( GLvoid *pointer ) 27028fefafa2200d3ea44ec46592b190654a10685b46Brian Paul{ 27038fefafa2200d3ea44ec46592b190654a10685b46Brian Paul (void) pointer; 27048fefafa2200d3ea44ec46592b190654a10685b46Brian Paul} 27058fefafa2200d3ea44ec46592b190654a10685b46Brian Paul 27068fefafa2200d3ea44ec46592b190654a10685b46Brian Paul 27073c5bfac63bcbc4028c552fe74d904e6a3416ff36Brian Paul/*** GLX_MESA_agp_offset ***/ 2708d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul 2709d6113fc20d68f5720740b89c594227d0312bab3eBrian Paulstatic GLuint 2710d6113fc20d68f5720740b89c594227d0312bab3eBrian PaulFake_glXGetAGPOffsetMESA( const GLvoid *pointer ) 2711d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul{ 2712d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul (void) pointer; 2713d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul return ~0; 2714d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul} 2715d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul 2716d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul 27177287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul/* silence warning */ 2718e7b16b74bf5d13331b5a88bbbbb9096560297b63Brian Paulextern struct _glxapi_table *_mesa_GetGLXDispatchTable(void); 27197287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul 27207287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul 27217287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul/** 27227287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul * Create a new GLX API dispatch table with its function pointers 27237287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul * initialized to point to Mesa's "fake" GLX API functions. 27247287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul * Note: there's a similar function (_real_GetGLXDispatchTable) that 27257287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul * returns a new dispatch table with all pointers initalized to point 27267287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul * to "real" GLX functions (which understand GLX wire protocol, etc). 27277287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul */ 27287287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paulstruct _glxapi_table * 27297287bbf4fc7c52da2aa31cae897ed70deda645bbBrian Paul_mesa_GetGLXDispatchTable(void) 2730426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 2731426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul static struct _glxapi_table glx; 2732426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2733426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul /* be sure our dispatch table size <= libGL's table */ 2734426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul { 273501915e90e6912f06d43d443a09157f7bbc96ddc5Brian Paul GLuint size = sizeof(struct _glxapi_table) / sizeof(void *); 2736426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) size; 2737426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul assert(_glxapi_get_dispatch_table_size() >= size); 2738426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul } 2739426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2740426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul /* initialize the whole table to no-ops */ 2741426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul _glxapi_set_no_op_table(&glx); 2742426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2743426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul /* now initialize the table with the functions I implement */ 2744426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.ChooseVisual = Fake_glXChooseVisual; 2745426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CopyContext = Fake_glXCopyContext; 2746426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CreateContext = Fake_glXCreateContext; 2747426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CreateGLXPixmap = Fake_glXCreateGLXPixmap; 2748426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.DestroyContext = Fake_glXDestroyContext; 2749426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.DestroyGLXPixmap = Fake_glXDestroyGLXPixmap; 2750426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.GetConfig = Fake_glXGetConfig; 2751426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul /*glx.GetCurrentContext = Fake_glXGetCurrentContext;*/ 2752426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul /*glx.GetCurrentDrawable = Fake_glXGetCurrentDrawable;*/ 2753426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.IsDirect = Fake_glXIsDirect; 2754426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.MakeCurrent = Fake_glXMakeCurrent; 2755426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.QueryExtension = Fake_glXQueryExtension; 2756426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.QueryVersion = Fake_glXQueryVersion; 2757426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.SwapBuffers = Fake_glXSwapBuffers; 2758426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.UseXFont = Fake_glXUseXFont; 2759426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.WaitGL = Fake_glXWaitGL; 2760426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.WaitX = Fake_glXWaitX; 2761426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2762b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_VERSION_1_1 ***/ 2763426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.GetClientString = Fake_glXGetClientString; 2764426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.QueryExtensionsString = Fake_glXQueryExtensionsString; 2765426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.QueryServerString = Fake_glXQueryServerString; 2766426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2767b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_VERSION_1_2 ***/ 2768426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul /*glx.GetCurrentDisplay = Fake_glXGetCurrentDisplay;*/ 2769426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2770b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_VERSION_1_3 ***/ 2771426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.ChooseFBConfig = Fake_glXChooseFBConfig; 2772426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CreateNewContext = Fake_glXCreateNewContext; 2773426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CreatePbuffer = Fake_glXCreatePbuffer; 2774426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CreatePixmap = Fake_glXCreatePixmap; 2775426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CreateWindow = Fake_glXCreateWindow; 2776426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.DestroyPbuffer = Fake_glXDestroyPbuffer; 2777426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.DestroyPixmap = Fake_glXDestroyPixmap; 2778426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.DestroyWindow = Fake_glXDestroyWindow; 2779426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul /*glx.GetCurrentReadDrawable = Fake_glXGetCurrentReadDrawable;*/ 2780426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.GetFBConfigAttrib = Fake_glXGetFBConfigAttrib; 278171dea349d2be623b7819389428b0d6a124e8d184Brian Paul glx.GetFBConfigs = Fake_glXGetFBConfigs; 2782426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.GetSelectedEvent = Fake_glXGetSelectedEvent; 2783426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.GetVisualFromFBConfig = Fake_glXGetVisualFromFBConfig; 2784426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.MakeContextCurrent = Fake_glXMakeContextCurrent; 2785426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.QueryContext = Fake_glXQueryContext; 2786426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.QueryDrawable = Fake_glXQueryDrawable; 2787426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.SelectEvent = Fake_glXSelectEvent; 2788426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2789b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SGI_swap_control ***/ 2790783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.SwapIntervalSGI = Fake_glXSwapIntervalSGI; 2791783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2792b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SGI_video_sync ***/ 2793426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.GetVideoSyncSGI = Fake_glXGetVideoSyncSGI; 2794426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.WaitVideoSyncSGI = Fake_glXWaitVideoSyncSGI; 2795426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2796b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SGI_make_current_read ***/ 2797783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.MakeCurrentReadSGI = Fake_glXMakeCurrentReadSGI; 27987cf50e137da497a590ec9001a9918972a6246142Brian Paul /*glx.GetCurrentReadDrawableSGI = Fake_glXGetCurrentReadDrawableSGI;*/ 2799783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2800b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul/*** GLX_SGIX_video_source ***/ 2801b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#if defined(_VL_H) 2802783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.CreateGLXVideoSourceSGIX = Fake_glXCreateGLXVideoSourceSGIX; 2803783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.DestroyGLXVideoSourceSGIX = Fake_glXDestroyGLXVideoSourceSGIX; 2804783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul#endif 2805783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2806b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_EXT_import_context ***/ 2807783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.FreeContextEXT = Fake_glXFreeContextEXT; 2808783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.GetContextIDEXT = Fake_glXGetContextIDEXT; 28097cf50e137da497a590ec9001a9918972a6246142Brian Paul /*glx.GetCurrentDisplayEXT = Fake_glXGetCurrentDisplayEXT;*/ 2810783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.ImportContextEXT = Fake_glXImportContextEXT; 2811783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.QueryContextInfoEXT = Fake_glXQueryContextInfoEXT; 28124536021a62e02fceaa6e8eb889b0f61743109cc4Brian Paul 2813b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SGIX_fbconfig ***/ 2814783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.GetFBConfigAttribSGIX = Fake_glXGetFBConfigAttribSGIX; 2815783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.ChooseFBConfigSGIX = Fake_glXChooseFBConfigSGIX; 2816783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.CreateGLXPixmapWithConfigSGIX = Fake_glXCreateGLXPixmapWithConfigSGIX; 2817783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.CreateContextWithConfigSGIX = Fake_glXCreateContextWithConfigSGIX; 2818783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.GetVisualFromFBConfigSGIX = Fake_glXGetVisualFromFBConfigSGIX; 2819783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.GetFBConfigFromVisualSGIX = Fake_glXGetFBConfigFromVisualSGIX; 2820783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2821b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SGIX_pbuffer ***/ 2822783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.CreateGLXPbufferSGIX = Fake_glXCreateGLXPbufferSGIX; 2823783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.DestroyGLXPbufferSGIX = Fake_glXDestroyGLXPbufferSGIX; 2824783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.QueryGLXPbufferSGIX = Fake_glXQueryGLXPbufferSGIX; 2825783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.SelectEventSGIX = Fake_glXSelectEventSGIX; 2826783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.GetSelectedEventSGIX = Fake_glXGetSelectedEventSGIX; 2827783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2828b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SGI_cushion ***/ 2829783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.CushionSGI = Fake_glXCushionSGI; 2830783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2831b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SGIX_video_resize ***/ 2832783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.BindChannelToWindowSGIX = Fake_glXBindChannelToWindowSGIX; 2833783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.ChannelRectSGIX = Fake_glXChannelRectSGIX; 2834783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.QueryChannelRectSGIX = Fake_glXQueryChannelRectSGIX; 2835783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.QueryChannelDeltasSGIX = Fake_glXQueryChannelDeltasSGIX; 2836783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.ChannelRectSyncSGIX = Fake_glXChannelRectSyncSGIX; 2837783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2838b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SGIX_dmbuffer **/ 2839b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul#if defined(_DM_BUFFER_H_) 2840783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.AssociateDMPbufferSGIX = NULL; 2841783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul#endif 2842783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2843b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SGIX_swap_group ***/ 2844783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.JoinSwapGroupSGIX = Fake_glXJoinSwapGroupSGIX; 2845783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2846b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SGIX_swap_barrier ***/ 2847783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.BindSwapBarrierSGIX = Fake_glXBindSwapBarrierSGIX; 2848783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.QueryMaxSwapBarriersSGIX = Fake_glXQueryMaxSwapBarriersSGIX; 2849783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul 2850b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_SUN_get_transparent_index ***/ 2851783d7dfcbf40f727c85915b3e5ea5ff6682eaa48Brian Paul glx.GetTransparentIndexSUN = Fake_glXGetTransparentIndexSUN; 28524536021a62e02fceaa6e8eb889b0f61743109cc4Brian Paul 2853b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_MESA_copy_sub_buffer ***/ 2854426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CopySubBufferMESA = Fake_glXCopySubBufferMESA; 2855426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2856b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_MESA_release_buffers ***/ 2857426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.ReleaseBuffersMESA = Fake_glXReleaseBuffersMESA; 2858426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2859b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_MESA_pixmap_colormap ***/ 2860426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CreateGLXPixmapMESA = Fake_glXCreateGLXPixmapMESA; 2861426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2862b0bb4f6226a18e0a6eb40046c7f7b5a841c75edaBrian Paul /*** GLX_MESA_set_3dfx_mode ***/ 2863426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.Set3DfxModeMESA = Fake_glXSet3DfxModeMESA; 2864426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 2865d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul /*** GLX_NV_vertex_array_range ***/ 28668fefafa2200d3ea44ec46592b190654a10685b46Brian Paul glx.AllocateMemoryNV = Fake_glXAllocateMemoryNV; 28678fefafa2200d3ea44ec46592b190654a10685b46Brian Paul glx.FreeMemoryNV = Fake_glXFreeMemoryNV; 28688fefafa2200d3ea44ec46592b190654a10685b46Brian Paul 2869d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul /*** GLX_MESA_agp_offset ***/ 2870d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul glx.GetAGPOffsetMESA = Fake_glXGetAGPOffsetMESA; 2871d6113fc20d68f5720740b89c594227d0312bab3eBrian Paul 2872426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul return &glx; 2873426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 2874