fakeglx.c revision 4c07bd5709830bd11cb29d4d8b8a56e757dc0365
14c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul/* $Id: fakeglx.c,v 1.34 2000/06/08 22:50:28 brianp Exp $ */ 2afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 3afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 4afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Mesa 3-D graphics library 5d0247f53aea8fa8677aadc8a00f75c8993be9ebcBrian Paul * Version: 3.3 6afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * 7262f9e52d6a511fffd1e6746de9d83d89cca9e1aBrian Paul * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. 8afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * 9afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Permission is hereby granted, free of charge, to any person obtaining a 10afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * copy of this software and associated documentation files (the "Software"), 11afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * to deal in the Software without restriction, including without limitation 12afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 13afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * and/or sell copies of the Software, and to permit persons to whom the 14afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Software is furnished to do so, subject to the following conditions: 15afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * 16afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * The above copyright notice and this permission notice shall be included 17afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * in all copies or substantial portions of the Software. 18afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * 19afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 20afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 22afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 23afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 24afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 26afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 27afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 28afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 2936cfa38760cc2bd91c08b66bb62c4b6cf9eb5454Brian Paul * This is an emulation of the GLX API which allows Mesa/GLX-based programs 3036cfa38760cc2bd91c08b66bb62c4b6cf9eb5454Brian Paul * to run on X servers which do not have the real GLX extension. 31afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * 32afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Thanks to the contributors: 33afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * 34afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Initial version: Philip Brown (philb@CSUA.Berkeley.EDU) 35afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Better glXGetConfig() support: Armin Liebchen (liebchen@asylum.cs.utah.edu) 36afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Further visual-handling refinements: Wolfram Gloger 37afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * (wmglo@Dent.MED.Uni-Muenchen.DE). 38afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * 39afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Notes: 40afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Don't be fooled, stereo isn't supported yet. 41afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 42afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 43afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 44afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 45fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul#include "glxheader.h" 46426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul#include "glxapi.h" 47afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#include "GL/xmesa.h" 48afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#include "context.h" 49afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#include "config.h" 50afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#include "macros.h" 5171dea349d2be623b7819389428b0d6a124e8d184Brian Paul#include "mmath.h" 52afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#include "types.h" 5371dea349d2be623b7819389428b0d6a124e8d184Brian Paul#include "xfonts.h" 54afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#include "xmesaP.h" 55afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 56afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 5778fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul/* This indicates the client-side GLX API and GLX encoder version. */ 5878fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul#define CLIENT_MAJOR_VERSION 1 5978fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul#define CLIENT_MINOR_VERSION 2 6078fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul 6178fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul/* This indicates the server-side GLX decoder version. 6278fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul * GLX 1.3 indicates OpenGL 1.2 support 6378fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul */ 6478fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul#define SERVER_MAJOR_VERSION 1 6578fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul#define SERVER_MINOR_VERSION 3 6678fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul 6778fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul/* This is appended onto the glXGetClient/ServerString version strings. */ 68262f9e52d6a511fffd1e6746de9d83d89cca9e1aBrian Paul#define MESA_GLX_VERSION "Mesa 3.3" 6978fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul 7078fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul/* Who implemented this GLX? */ 7178fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul#define VENDOR "Brian Paul" 7278fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul 7378fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul 74afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 7543c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul/* Silence compiler warnings */ 76e7b16b74bf5d13331b5a88bbbbb9096560297b63Brian Paulextern void Fake_glXDummyFunc( void ); 7743c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paulvoid Fake_glXDummyFunc( void ) 7843c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul{ 7943c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul (void) kernel8; 8043c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul (void) DitherValues; 8143c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul (void) HPCR_DRGB; 8243c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul (void) kernel1; 8343c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul} 8443c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul 8543c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul 8643c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul 87afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#define DONT_CARE -1 88afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 89afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 90afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 91afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#define MAX_VISUALS 100 92afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XMesaVisual VisualTable[MAX_VISUALS]; 93afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic int NumVisuals = 0; 94afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 95afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 96afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 97afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 98afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * This struct and some code fragments borrowed 99afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * from Mark Kilgard's GLUT library. 100afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 101afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgtypedef struct _OverlayInfo { 102afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Avoid 64-bit portability problems by being careful to use 103afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg longs due to the way XGetWindowProperty is specified. Note 104afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg that these parameters are passed as CARD32s over X 105afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg protocol. */ 106afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg unsigned long overlay_visual; 107afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg long transparent_type; 108afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg long value; 109afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg long layer; 110afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} OverlayInfo; 111afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 112afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 113afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 114afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* Macro to handle c_class vs class field name in XVisualInfo struct */ 115afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#if defined(__cplusplus) || defined(c_plusplus) 116afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#define CLASS c_class 117afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#else 118afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#define CLASS class 119afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#endif 120afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 121afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 122afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 123afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 124afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 125afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Test if the given XVisualInfo is usable for Mesa rendering. 126afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 127afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic GLboolean is_usable_visual( XVisualInfo *vinfo ) 128afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 129afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (vinfo->CLASS) { 130afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case StaticGray: 131afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GrayScale: 132afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Any StaticGray/GrayScale visual works in RGB or CI mode */ 133afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return GL_TRUE; 134afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case StaticColor: 135afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case PseudoColor: 136afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Any StaticColor/PseudoColor visual of at least 4 bits */ 137afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vinfo->depth>=4) { 138afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return GL_TRUE; 139afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 140afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 141afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return GL_FALSE; 142afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 143afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case TrueColor: 144afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case DirectColor: 145afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Any depth of TrueColor or DirectColor works in RGB mode */ 146afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return GL_TRUE; 147afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: 148afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* This should never happen */ 149afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return GL_FALSE; 150afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 151afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 152afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 153afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 154afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 155afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 156afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return the level (overlay, normal, underlay) of a given XVisualInfo. 157afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input: dpy - the X display 158afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * vinfo - the XVisualInfo to test 159afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return: level of the visual: 160afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * 0 = normal planes 161afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * >0 = overlay planes 162afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * <0 = underlay planes 163afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 164afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic int level_of_visual( Display *dpy, XVisualInfo *vinfo ) 165afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 166afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg Atom overlayVisualsAtom; 167afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg OverlayInfo *overlay_info = NULL; 168afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int numOverlaysPerScreen; 169afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg Status status; 170afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg Atom actualType; 171afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int actualFormat; 172afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg unsigned long sizeData, bytesLeft; 173afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int i; 174afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 175afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* 176afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * The SERVER_OVERLAY_VISUALS property on the root window contains 177afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * a list of overlay visuals. Get that list now. 178afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 179afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg overlayVisualsAtom = XInternAtom(dpy,"SERVER_OVERLAY_VISUALS", True); 180afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (overlayVisualsAtom == None) { 181afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 182afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 183afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 184afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg status = XGetWindowProperty(dpy, RootWindow( dpy, vinfo->screen ), 185afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg overlayVisualsAtom, 0L, (long) 10000, False, 186afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg overlayVisualsAtom, &actualType, &actualFormat, 187afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg &sizeData, &bytesLeft, 188afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (unsigned char **) &overlay_info ); 189afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 190afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (status != Success || actualType != overlayVisualsAtom || 191afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg actualFormat != 32 || sizeData < 4) { 192afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* something went wrong */ 193afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XFree((void *) overlay_info); 194afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 195afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 196afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 197afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* search the overlay visual list for the visual ID of interest */ 198afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg numOverlaysPerScreen = (int) (sizeData / 4); 199afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (i=0;i<numOverlaysPerScreen;i++) { 200afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg OverlayInfo *ov; 201afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg ov = overlay_info + i; 202afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (ov->overlay_visual==vinfo->visualid) { 203afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* found the visual */ 204afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (/*ov->transparent_type==1 &&*/ ov->layer!=0) { 205afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int level = ov->layer; 206afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XFree((void *) overlay_info); 207afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return level; 208afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 209afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 210afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XFree((void *) overlay_info); 211afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 212afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 213afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 214afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 215afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 216afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* The visual ID was not found in the overlay list. */ 217afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XFree((void *) overlay_info); 218afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 219afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 220afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 221afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 222afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 223afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 224afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 225afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Given an XVisualInfo and RGB, Double, and Depth buffer flags, save the 226afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * configuration in our list of GLX visuals. 227afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 228afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XMesaVisual 229afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgsave_glx_visual( Display *dpy, XVisualInfo *vinfo, 230afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLboolean rgbFlag, GLboolean alphaFlag, GLboolean dbFlag, 231afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLboolean stereoFlag, 232afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLint depth_size, GLint stencil_size, 233b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint accumRedSize, GLint accumGreenSize, 234b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint accumBlueSize, GLint accumAlphaSize, 235b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint level ) 236afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 237afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLboolean ximageFlag = GL_TRUE; 238afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaVisual xmvis; 239afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLint i; 240afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLboolean comparePointers; 241afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 242afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (dbFlag) { 243afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Check if the MESA_BACK_BUFFER env var is set */ 244afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg char *backbuffer = getenv("MESA_BACK_BUFFER"); 245afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (backbuffer) { 246afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (backbuffer[0]=='p' || backbuffer[0]=='P') { 247afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg ximageFlag = GL_FALSE; 248afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 249afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else if (backbuffer[0]=='x' || backbuffer[0]=='X') { 250afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg ximageFlag = GL_TRUE; 251afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 252afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 253afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg fprintf(stderr, "Mesa: invalid value for MESA_BACK_BUFFER "); 254afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg fprintf(stderr, "environment variable, using an XImage.\n"); 255afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 256afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 257afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 258afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 259afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Comparing IDs uses less memory but sometimes fails. */ 260afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* XXX revisit this after 3.0 is finished. */ 261afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (getenv("MESA_GLX_VISUAL_HACK")) 262afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg comparePointers = GL_TRUE; 263afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else 264afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg comparePointers = GL_FALSE; 265afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 266afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* First check if a matching visual is already in the list */ 267afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (i=0; i<NumVisuals; i++) { 268afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaVisual v = VisualTable[i]; 269afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (v->display == dpy 270afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg && v->level == level 271afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg && v->ximage_flag == ximageFlag 272afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg && v->gl_visual->RGBAflag == rgbFlag 273afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg && v->gl_visual->DBflag == dbFlag 274afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg && v->gl_visual->StereoFlag == stereoFlag 275afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg && (v->gl_visual->AlphaBits > 0) == alphaFlag 276afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg && (v->gl_visual->DepthBits >= depth_size || depth_size == 0) 277afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg && (v->gl_visual->StencilBits >= stencil_size || stencil_size == 0) 278b2e460018375f699198073a6167e0ee96ba1d267Brian Paul && (v->gl_visual->AccumRedBits >= accumRedSize || accumRedSize == 0) 279b2e460018375f699198073a6167e0ee96ba1d267Brian Paul && (v->gl_visual->AccumGreenBits >= accumGreenSize || accumGreenSize == 0) 280b2e460018375f699198073a6167e0ee96ba1d267Brian Paul && (v->gl_visual->AccumBlueBits >= accumBlueSize || accumBlueSize == 0) 281b2e460018375f699198073a6167e0ee96ba1d267Brian Paul && (v->gl_visual->AccumAlphaBits >= accumAlphaSize || accumAlphaSize == 0)) { 282afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* now either compare XVisualInfo pointers or visual IDs */ 283d0247f53aea8fa8677aadc8a00f75c8993be9ebcBrian Paul if ((!comparePointers && v->visinfo->visualid == vinfo->visualid) 284afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg || (comparePointers && v->vishandle == vinfo)) { 285afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return v; 286afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 287afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 288afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 289afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 290afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Create a new visual and add it to the list. */ 291afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 292afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (NumVisuals>=MAX_VISUALS) { 293afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg fprintf( stderr, "GLX Error: maximum number of visuals exceeded\n"); 294afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 295afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 296afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 297c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul xmvis = XMesaCreateVisual( dpy, vinfo, rgbFlag, alphaFlag, dbFlag, 298c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul stereoFlag, ximageFlag, 299c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul depth_size, stencil_size, 300c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul accumRedSize, accumBlueSize, 301c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul accumBlueSize, accumAlphaSize, 0, level, 302c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul GLX_NONE_EXT ); 303afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (xmvis) { 304afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg VisualTable[NumVisuals] = xmvis; 305afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg NumVisuals++; 306afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 307afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return xmvis; 308afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 309afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 310afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 311afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 312afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 313afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Create a GLX visual from a regular XVisualInfo. 314ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * This is called when Fake GLX is given an XVisualInfo which wasn't 315ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * returned by glXChooseVisual. Since this is the first time we're 316ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * considering this visual we'll take a guess at reasonable values 317ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * for depth buffer size, stencil size, accum size, etc. 318ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * This is the best we can do with a client-side emulation of GLX. 319afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 320afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XMesaVisual 321afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgcreate_glx_visual( Display *dpy, XVisualInfo *visinfo ) 322afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 323afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int vislevel; 324afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 325afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vislevel = level_of_visual( dpy, visinfo ); 326afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vislevel) { 327afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Configure this visual as a CI, single-buffered overlay */ 328afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return save_glx_visual( dpy, visinfo, 329afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GL_FALSE, /* rgb */ 330afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GL_FALSE, /* alpha */ 331afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GL_FALSE, /* double */ 332afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GL_FALSE, /* stereo */ 333afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 0, /* depth bits */ 334afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 0, /* stencil bits */ 335b2e460018375f699198073a6167e0ee96ba1d267Brian Paul 0,0,0,0, /* accum bits */ 336afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vislevel /* level */ 337afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg ); 338afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 339afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else if (is_usable_visual( visinfo )) { 340afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Configure this visual as RGB, double-buffered, depth-buffered. */ 341afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* This is surely wrong for some people's needs but what else */ 342afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* can be done? They should use glXChooseVisual(). */ 343afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return save_glx_visual( dpy, visinfo, 344afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GL_TRUE, /* rgb */ 345afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GL_FALSE, /* alpha */ 346afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GL_TRUE, /* double */ 347afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GL_FALSE, /* stereo */ 348ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul DEFAULT_SOFTWARE_DEPTH_BITS, 349ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul 8 * sizeof(GLstencil), 350b2e460018375f699198073a6167e0ee96ba1d267Brian Paul 8 * sizeof(GLaccum), /* r */ 351b2e460018375f699198073a6167e0ee96ba1d267Brian Paul 8 * sizeof(GLaccum), /* g */ 352b2e460018375f699198073a6167e0ee96ba1d267Brian Paul 8 * sizeof(GLaccum), /* b */ 353b2e460018375f699198073a6167e0ee96ba1d267Brian Paul 8 * sizeof(GLaccum), /* a */ 354afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 0 /* level */ 355afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg ); 356afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 357afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 358afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg fprintf(stderr,"Mesa: error in glXCreateContext: bad visual\n"); 359afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 360afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 361afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 362afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 363afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 364afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 365afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 366afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Find the GLX visual associated with an XVisualInfo. 367afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 368afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XMesaVisual 369afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgfind_glx_visual( Display *dpy, XVisualInfo *vinfo ) 370afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 371afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int i; 372afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 373afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* First try to match pointers */ 374afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (i=0;i<NumVisuals;i++) { 375afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (VisualTable[i]->display==dpy && VisualTable[i]->vishandle==vinfo) { 376afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return VisualTable[i]; 377afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 378afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 379afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* try to match visual id */ 380afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (i=0;i<NumVisuals;i++) { 381afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (VisualTable[i]->display==dpy 382afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg && VisualTable[i]->visinfo->visualid == vinfo->visualid) { 383afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return VisualTable[i]; 384afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 385afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 386afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 387afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 388afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 389afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 390afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 391afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 392afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return the transparent pixel value for a GLX visual. 393afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input: glxvis - the glx_visual 394afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return: a pixel value or -1 if no transparent pixel 395afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 396afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic int transparent_pixel( XMesaVisual glxvis ) 397afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 398afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg Display *dpy = glxvis->display; 399afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XVisualInfo *vinfo = glxvis->visinfo; 400afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg Atom overlayVisualsAtom; 401afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg OverlayInfo *overlay_info = NULL; 402afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int numOverlaysPerScreen; 403afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg Status status; 404afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg Atom actualType; 405afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int actualFormat; 406afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg unsigned long sizeData, bytesLeft; 407afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int i; 408afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 409afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* 410afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * The SERVER_OVERLAY_VISUALS property on the root window contains 411afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * a list of overlay visuals. Get that list now. 412afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 413afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg overlayVisualsAtom = XInternAtom(dpy,"SERVER_OVERLAY_VISUALS", True); 414afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (overlayVisualsAtom == None) { 415afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return -1; 416afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 417afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 418afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg status = XGetWindowProperty(dpy, RootWindow( dpy, vinfo->screen ), 419afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg overlayVisualsAtom, 0L, (long) 10000, False, 420afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg overlayVisualsAtom, &actualType, &actualFormat, 421afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg &sizeData, &bytesLeft, 422afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (unsigned char **) &overlay_info ); 423afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 424afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (status != Success || actualType != overlayVisualsAtom || 425afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg actualFormat != 32 || sizeData < 4) { 426afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* something went wrong */ 427afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XFree((void *) overlay_info); 428afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return -1; 429afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 430afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 431afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* search the overlay visual list for the visual ID of interest */ 432afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg numOverlaysPerScreen = (int) (sizeData / 4); 433afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (i=0;i<numOverlaysPerScreen;i++) { 434afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg OverlayInfo *ov; 435afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg ov = overlay_info + i; 436afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (ov->overlay_visual==vinfo->visualid) { 437afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* found it! */ 438afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (ov->transparent_type==0) { 439afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* type 0 indicates no transparency */ 440afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XFree((void *) overlay_info); 441afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return -1; 442afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 443afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 444afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* ov->value is the transparent pixel */ 445afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XFree((void *) overlay_info); 446afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return ov->value; 447afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 448afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 449afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 450afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 451afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* The visual ID was not found in the overlay list. */ 452afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XFree((void *) overlay_info); 453afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return -1; 454afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 455afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 456afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 457afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 458afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 459afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Try to get an X visual which matches the given arguments. 460afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 461afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XVisualInfo *get_visual( Display *dpy, int scr, 462afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg unsigned int depth, int xclass ) 463afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 464afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XVisualInfo temp, *vis; 465afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg long mask; 466afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int n; 467afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg unsigned int default_depth; 468afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int default_class; 469afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 470afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg mask = VisualScreenMask | VisualDepthMask | VisualClassMask; 471afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg temp.screen = scr; 472afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg temp.depth = depth; 473afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg temp.CLASS = xclass; 474afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 475afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default_depth = DefaultDepth(dpy,scr); 476afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default_class = DefaultVisual(dpy,scr)->CLASS; 477afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 478afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (depth==default_depth && xclass==default_class) { 479afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* try to get root window's visual */ 480afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg temp.visualid = DefaultVisual(dpy,scr)->visualid; 481afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg mask |= VisualIDMask; 482afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 483afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 484afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = XGetVisualInfo( dpy, mask, &temp, &n ); 485afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 486afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* In case bits/pixel > 24, make sure color channels are still <=8 bits. 487afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * An SGI Infinite Reality system, for example, can have 30bpp pixels: 488afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * 10 bits per color channel. Mesa's limited to a max of 8 bits/channel. 489afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 490afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis && depth > 24 && (xclass==TrueColor || xclass==DirectColor)) { 49171dea349d2be623b7819389428b0d6a124e8d184Brian Paul if (_mesa_bitcount((GLuint) vis->red_mask ) <= 8 && 49271dea349d2be623b7819389428b0d6a124e8d184Brian Paul _mesa_bitcount((GLuint) vis->green_mask) <= 8 && 49371dea349d2be623b7819389428b0d6a124e8d184Brian Paul _mesa_bitcount((GLuint) vis->blue_mask ) <= 8) { 494afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 495afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 496afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 497afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XFree((void *) vis); 498afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 499afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 500afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 501afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 502afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 503afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 504afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 505afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 506afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 507afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 508afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Retrieve the value of the given environment variable and find 509afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * the X visual which matches it. 510afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input: dpy - the display 511afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * screen - the screen number 512afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * varname - the name of the environment variable 513afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return: an XVisualInfo pointer to NULL if error. 514afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 515afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XVisualInfo *get_env_visual(Display *dpy, int scr, const char *varname) 516afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 517afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg char value[100], type[100]; 518afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int depth, xclass = -1; 519afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XVisualInfo *vis; 520afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 521afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!getenv( varname )) { 522afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 523afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 524afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 525afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg strncpy( value, getenv(varname), 100 ); 526afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg value[99] = 0; 527afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 528afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg sscanf( value, "%s %d", type, &depth ); 529afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 530afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (strcmp(type,"TrueColor")==0) xclass = TrueColor; 531afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else if (strcmp(type,"DirectColor")==0) xclass = DirectColor; 532afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else if (strcmp(type,"PseudoColor")==0) xclass = PseudoColor; 533afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else if (strcmp(type,"StaticColor")==0) xclass = StaticColor; 534afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else if (strcmp(type,"GrayScale")==0) xclass = GrayScale; 535afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else if (strcmp(type,"StaticGray")==0) xclass = StaticGray; 536afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 537afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (xclass>-1 && depth>0) { 538afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, scr, depth, xclass ); 539afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 540afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 541afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 542afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 543afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 544afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg fprintf( stderr, "Mesa: GLX unable to find visual class=%s, depth=%d.\n", 545afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg type, depth ); 546afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 547afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 548afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 549afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 550afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 551afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 552afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Select an X visual which satisfies the RGBA/CI flag and minimum depth. 553afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input: dpy, screen - X display and screen number 554afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * rgba - GL_TRUE = RGBA mode, GL_FALSE = CI mode 555afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * min_depth - minimum visual depth 556afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * preferred_class - preferred GLX visual class or DONT_CARE 557afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return: pointer to an XVisualInfo or NULL. 558afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 559afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XVisualInfo *choose_x_visual( Display *dpy, int screen, 560afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLboolean rgba, int min_depth, 561afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int preferred_class ) 562afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 563afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XVisualInfo *vis; 564afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int xclass, visclass; 565afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int depth; 566afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 567afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (rgba) { 568afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg Atom hp_cr_maps = XInternAtom(dpy, "_HP_RGB_SMOOTH_MAP_LIST", True); 569afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* First see if the MESA_RGB_VISUAL env var is defined */ 570afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_env_visual( dpy, screen, "MESA_RGB_VISUAL" ); 571afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 572afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 573afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 574afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Otherwise, search for a suitable visual */ 575afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (preferred_class==DONT_CARE) { 576afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (xclass=0;xclass<6;xclass++) { 577afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (xclass) { 578afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case 0: visclass = TrueColor; break; 579afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case 1: visclass = DirectColor; break; 580afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case 2: visclass = PseudoColor; break; 581afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case 3: visclass = StaticColor; break; 582afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case 4: visclass = GrayScale; break; 583afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case 5: visclass = StaticGray; break; 584afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 585afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (min_depth==0) { 586afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* start with shallowest */ 587afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (depth=0;depth<=32;depth++) { 588afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (visclass==TrueColor && depth==8 && !hp_cr_maps) { 589afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Special case: try to get 8-bit PseudoColor before */ 590afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* 8-bit TrueColor */ 591afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, screen, 8, PseudoColor ); 592afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 593afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 594afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 595afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 596afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, screen, depth, visclass ); 597afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 598afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 599afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 600afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 601afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 602afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 603afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* start with deepest */ 604afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (depth=32;depth>=min_depth;depth--) { 605afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (visclass==TrueColor && depth==8 && !hp_cr_maps) { 606afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Special case: try to get 8-bit PseudoColor before */ 607afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* 8-bit TrueColor */ 608afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, screen, 8, PseudoColor ); 609afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 610afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 611afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 612afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 613afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, screen, depth, visclass ); 614afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 615afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 616afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 617afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 618afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 619afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 620afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 621afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 622afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* search for a specific visual class */ 623afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (preferred_class) { 624afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRUE_COLOR_EXT: visclass = TrueColor; break; 625afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_DIRECT_COLOR_EXT: visclass = DirectColor; break; 626afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_PSEUDO_COLOR_EXT: visclass = PseudoColor; break; 627afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STATIC_COLOR_EXT: visclass = StaticColor; break; 628afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_GRAY_SCALE_EXT: visclass = GrayScale; break; 629afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STATIC_GRAY_EXT: visclass = StaticGray; break; 630afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: return NULL; 631afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 632afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (min_depth==0) { 633afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* start with shallowest */ 634afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (depth=0;depth<=32;depth++) { 635afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, screen, depth, visclass ); 636afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 637afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 638afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 639afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 640afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 641afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 642afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* start with deepest */ 643afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (depth=32;depth>=min_depth;depth--) { 644afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, screen, depth, visclass ); 645afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 646afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 647afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 648afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 649afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 650afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 651afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 652afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 653afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* First see if the MESA_CI_VISUAL env var is defined */ 654afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_env_visual( dpy, screen, "MESA_CI_VISUAL" ); 655afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 656afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 657afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 658afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Otherwise, search for a suitable visual, starting with shallowest */ 659afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (preferred_class==DONT_CARE) { 660afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (xclass=0;xclass<4;xclass++) { 661afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (xclass) { 662afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case 0: visclass = PseudoColor; break; 663afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case 1: visclass = StaticColor; break; 664afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case 2: visclass = GrayScale; break; 665afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case 3: visclass = StaticGray; break; 666afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 667afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* try 8-bit up through 16-bit */ 668afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (depth=8;depth<=16;depth++) { 669afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, screen, depth, visclass ); 670afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 671afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 672afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 673afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 674afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* try min_depth up to 8-bit */ 675afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (depth=min_depth;depth<8;depth++) { 676afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, screen, depth, visclass ); 677afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 678afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 679afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 680afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 681afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 682afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 683afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 684afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* search for a specific visual class */ 685afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (preferred_class) { 686afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRUE_COLOR_EXT: visclass = TrueColor; break; 687afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_DIRECT_COLOR_EXT: visclass = DirectColor; break; 688afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_PSEUDO_COLOR_EXT: visclass = PseudoColor; break; 689afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STATIC_COLOR_EXT: visclass = StaticColor; break; 690afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_GRAY_SCALE_EXT: visclass = GrayScale; break; 691afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STATIC_GRAY_EXT: visclass = StaticGray; break; 692afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: return NULL; 693afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 694afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* try 8-bit up through 16-bit */ 695afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (depth=8;depth<=16;depth++) { 696afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, screen, depth, visclass ); 697afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 698afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 699afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 700afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 701afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* try min_depth up to 8-bit */ 702afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (depth=min_depth;depth<8;depth++) { 703afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, screen, depth, visclass ); 704afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 705afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 706afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 707afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 708afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 709afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 710afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 711afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* didn't find a visual */ 712afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 713afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 714afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 715afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 716afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 717afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 718afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Find the deepest X over/underlay visual of at least min_depth. 719afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input: dpy, screen - X display and screen number 720afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * level - the over/underlay level 721afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * trans_type - transparent pixel type: GLX_NONE_EXT, 722afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * GLX_TRANSPARENT_RGB_EXT, GLX_TRANSPARENT_INDEX_EXT, 723afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * or DONT_CARE 724afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * trans_value - transparent pixel value or DONT_CARE 725afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * min_depth - minimum visual depth 726afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * preferred_class - preferred GLX visual class or DONT_CARE 727afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return: pointer to an XVisualInfo or NULL. 728afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 729afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XVisualInfo *choose_x_overlay_visual( Display *dpy, int scr, 73042f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul GLboolean rgbFlag, 731afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int level, int trans_type, 732afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int trans_value, 733afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int min_depth, 734afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int preferred_class ) 735afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 736afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg Atom overlayVisualsAtom; 737afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg OverlayInfo *overlay_info; 738afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int numOverlaysPerScreen; 739afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg Status status; 740afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg Atom actualType; 741afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int actualFormat; 742afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg unsigned long sizeData, bytesLeft; 743afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int i; 744afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XVisualInfo *deepvis; 745afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int deepest; 746afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 747afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /*DEBUG int tt, tv; */ 748afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 749afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (preferred_class) { 750afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRUE_COLOR_EXT: preferred_class = TrueColor; break; 751afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_DIRECT_COLOR_EXT: preferred_class = DirectColor; break; 752afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_PSEUDO_COLOR_EXT: preferred_class = PseudoColor; break; 753afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STATIC_COLOR_EXT: preferred_class = StaticColor; break; 754afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_GRAY_SCALE_EXT: preferred_class = GrayScale; break; 755afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STATIC_GRAY_EXT: preferred_class = StaticGray; break; 756afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: preferred_class = DONT_CARE; 757afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 758afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 759afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* 760afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * The SERVER_OVERLAY_VISUALS property on the root window contains 761afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * a list of overlay visuals. Get that list now. 762afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 763afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg overlayVisualsAtom = XInternAtom(dpy,"SERVER_OVERLAY_VISUALS", True); 764afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (overlayVisualsAtom == (Atom) None) { 765afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 766afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 767afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 768afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg status = XGetWindowProperty(dpy, RootWindow( dpy, scr ), 769afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg overlayVisualsAtom, 0L, (long) 10000, False, 770afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg overlayVisualsAtom, &actualType, &actualFormat, 771afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg &sizeData, &bytesLeft, 772afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (unsigned char **) &overlay_info ); 773afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 774afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (status != Success || actualType != overlayVisualsAtom || 775afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg actualFormat != 32 || sizeData < 4) { 776afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* something went wrong */ 777afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 778afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 779afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 780afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Search for the deepest overlay which satisifies all criteria. */ 781afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg deepest = min_depth; 782afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg deepvis = NULL; 783afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 784afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg numOverlaysPerScreen = (int) (sizeData / 4); 785afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (i=0;i<numOverlaysPerScreen;i++) { 786afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XVisualInfo *vislist, vistemplate; 787afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int count; 788afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg OverlayInfo *ov; 789afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg ov = overlay_info + i; 790afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 791afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (ov->layer!=level) { 792afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* failed overlay level criteria */ 793afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg continue; 794afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 795afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!(trans_type==DONT_CARE 796afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg || (trans_type==GLX_TRANSPARENT_INDEX_EXT 797afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg && ov->transparent_type>0) 798afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg || (trans_type==GLX_NONE_EXT && ov->transparent_type==0))) { 799afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* failed transparent pixel type criteria */ 800afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg continue; 801afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 802afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (trans_value!=DONT_CARE && trans_value!=ov->value) { 803afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* failed transparent pixel value criteria */ 804afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg continue; 805afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 806afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 807afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* get XVisualInfo and check the depth */ 808afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vistemplate.visualid = ov->overlay_visual; 809afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vistemplate.screen = scr; 810afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vislist = XGetVisualInfo( dpy, VisualIDMask | VisualScreenMask, 811afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg &vistemplate, &count ); 812afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 813afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (count!=1) { 814afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* something went wrong */ 815afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg continue; 816afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 817afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (preferred_class!=DONT_CARE && preferred_class!=vislist->CLASS) { 818afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* wrong visual class */ 819afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg continue; 820afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 821afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 82242f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul /* if RGB was requested, make sure we have True/DirectColor */ 82342f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul if (rgbFlag && vislist->CLASS != TrueColor 82442f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul && vislist->CLASS != DirectColor) 82542f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul continue; 82642f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul 82742f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul /* if CI was requested, make sure we have a color indexed visual */ 82842f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul if (!rgbFlag 82942f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul && (vislist->CLASS == TrueColor || vislist->CLASS == DirectColor)) 83042f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul continue; 83142f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul 832afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (deepvis==NULL || vislist->depth > deepest) { 833afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* YES! found a satisfactory visual */ 834afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (deepvis) { 83580af3614d88c0cac160e787de7f34b37e96cb626Brian Paul XFree( deepvis ); 836afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 837afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg deepest = vislist->depth; 838afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg deepvis = vislist; 839afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* DEBUG tt = ov->transparent_type;*/ 840afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* DEBUG tv = ov->value; */ 841afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 842afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 843afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 844afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*DEBUG 845afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (deepvis) { 846afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg printf("chose 0x%x: layer=%d depth=%d trans_type=%d trans_value=%d\n", 847afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg deepvis->visualid, level, deepvis->depth, tt, tv ); 848afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 849afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg*/ 850afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return deepvis; 851afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 852afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 853afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 854afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 855426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic XVisualInfo * 856426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXChooseVisual( Display *dpy, int screen, int *list ) 857afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 858afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int *parselist; 859afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XVisualInfo *vis; 860afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int min_ci = 0; 861afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int min_red=0, min_green=0, min_blue=0; 862afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLboolean rgb_flag = GL_FALSE; 863afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLboolean alpha_flag = GL_FALSE; 864afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLboolean double_flag = GL_FALSE; 865afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLboolean stereo_flag = GL_FALSE; 866afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLint depth_size = 0; 867afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLint stencil_size = 0; 868b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint accumRedSize = 0; 869b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint accumGreenSize = 0; 870b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint accumBlueSize = 0; 871b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint accumAlphaSize = 0; 872afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int level = 0; 873afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int visual_type = DONT_CARE; 874afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int trans_type = DONT_CARE; 875afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int trans_value = DONT_CARE; 876e1210b176926349b258c7ec77b7f36716025c82aBrian Paul GLint caveat = DONT_CARE; 877afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 878afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist = list; 879afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 880afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg while (*parselist) { 881afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 882afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (*parselist) { 883afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_USE_GL: 884afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* ignore */ 885afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 886afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 887afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_BUFFER_SIZE: 888afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 889afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg min_ci = *parselist++; 890afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 891afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_LEVEL: 892afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 893afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg level = *parselist++; 894afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 895afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_RGBA: 896afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg rgb_flag = GL_TRUE; 897afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 898afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 899afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_DOUBLEBUFFER: 900afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg double_flag = GL_TRUE; 901afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 902afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 903afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STEREO: 904afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg stereo_flag = GL_TRUE; 905afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 906afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_AUX_BUFFERS: 907afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* ignore */ 908afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 909afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 910afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 911afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_RED_SIZE: 912afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 913afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg min_red = *parselist++; 914afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 915afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_GREEN_SIZE: 916afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 917afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg min_green = *parselist++; 918afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 919afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_BLUE_SIZE: 920afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 921afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg min_blue = *parselist++; 922afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 923afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ALPHA_SIZE: 924afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 925afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg { 926afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLint size = *parselist++; 927afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg alpha_flag = size>0 ? 1 : 0; 928afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 929afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 930afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_DEPTH_SIZE: 931afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 932afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg depth_size = *parselist++; 933afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 934afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STENCIL_SIZE: 935afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 936afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg stencil_size = *parselist++; 937afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 938afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_RED_SIZE: 939b2e460018375f699198073a6167e0ee96ba1d267Brian Paul parselist++; 940b2e460018375f699198073a6167e0ee96ba1d267Brian Paul { 941b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint size = *parselist++; 942b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumRedSize = MAX2( accumRedSize, size ); 943b2e460018375f699198073a6167e0ee96ba1d267Brian Paul } 944b2e460018375f699198073a6167e0ee96ba1d267Brian Paul break; 945afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_GREEN_SIZE: 946b2e460018375f699198073a6167e0ee96ba1d267Brian Paul parselist++; 947b2e460018375f699198073a6167e0ee96ba1d267Brian Paul { 948b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint size = *parselist++; 949b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumGreenSize = MAX2( accumGreenSize, size ); 950b2e460018375f699198073a6167e0ee96ba1d267Brian Paul } 951b2e460018375f699198073a6167e0ee96ba1d267Brian Paul break; 952afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_BLUE_SIZE: 953b2e460018375f699198073a6167e0ee96ba1d267Brian Paul parselist++; 954b2e460018375f699198073a6167e0ee96ba1d267Brian Paul { 955b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint size = *parselist++; 956b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumBlueSize = MAX2( accumBlueSize, size ); 957b2e460018375f699198073a6167e0ee96ba1d267Brian Paul } 958b2e460018375f699198073a6167e0ee96ba1d267Brian Paul break; 959afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_ALPHA_SIZE: 960afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 961afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg { 962afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLint size = *parselist++; 963b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumAlphaSize = MAX2( accumAlphaSize, size ); 964afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 965afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 966afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 967afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* 968afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * GLX_EXT_visual_info extension 969afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 970afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_X_VISUAL_TYPE_EXT: 971afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 972afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg visual_type = *parselist++; 973afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 974afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_TYPE_EXT: 975afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 976afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg trans_type = *parselist++; 977afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 978afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_INDEX_VALUE_EXT: 979afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 980afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg trans_value = *parselist++; 981afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 982afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_RED_VALUE_EXT: 983afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_GREEN_VALUE_EXT: 984afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_BLUE_VALUE_EXT: 985afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_ALPHA_VALUE_EXT: 986afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* ignore */ 987afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 988afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 989afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 990afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 991e1210b176926349b258c7ec77b7f36716025c82aBrian Paul /* 992e1210b176926349b258c7ec77b7f36716025c82aBrian Paul * GLX_EXT_visual_info extension 993e1210b176926349b258c7ec77b7f36716025c82aBrian Paul */ 994e1210b176926349b258c7ec77b7f36716025c82aBrian Paul case GLX_VISUAL_CAVEAT_EXT: 995e1210b176926349b258c7ec77b7f36716025c82aBrian Paul parselist++; 996e1210b176926349b258c7ec77b7f36716025c82aBrian Paul caveat = *parselist++; /* ignored for now */ 997e1210b176926349b258c7ec77b7f36716025c82aBrian Paul break; 998e1210b176926349b258c7ec77b7f36716025c82aBrian Paul 999afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case None: 1000afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 1001afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: 1002afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* undefined attribute */ 1003afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 1004afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1005afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1006afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1007afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* 1008afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Since we're only simulating the GLX extension this function will never 1009afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * find any real GL visuals. Instead, all we can do is try to find an RGB 1010afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * or CI visual of appropriate depth. Other requested attributes such as 1011afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * double buffering, depth buffer, etc. will be associated with the X 1012afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * visual and stored in the VisualTable[]. 1013afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 1014afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (level==0) { 1015afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* normal color planes */ 1016afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (rgb_flag) { 1017afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Get an RGB visual */ 1018afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int min_rgb = min_red + min_green + min_blue; 1019afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (min_rgb>1 && min_rgb<8) { 1020afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* a special case to be sure we can get a monochrome visual */ 1021afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg min_rgb = 1; 1022afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1023afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = choose_x_visual( dpy, screen, rgb_flag, min_rgb, visual_type ); 1024afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1025afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 1026afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Get a color index visual */ 1027afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = choose_x_visual( dpy, screen, rgb_flag, min_ci, visual_type ); 1028b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumRedSize = accumGreenSize = accumBlueSize = accumAlphaSize = 0; 1029afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1030afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1031afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 1032afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* over/underlay planes */ 103342f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul if (rgb_flag) { 103442f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul /* rgba overlay */ 103542f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul int min_rgb = min_red + min_green + min_blue; 103642f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul if (min_rgb>1 && min_rgb<8) { 103742f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul /* a special case to be sure we can get a monochrome visual */ 103842f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul min_rgb = 1; 103942f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul } 104042f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul vis = choose_x_overlay_visual( dpy, screen, rgb_flag, level, 104142f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul trans_type, trans_value, min_rgb, visual_type ); 104242f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul } 104342f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul else { 104442f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul /* color index overlay */ 104542f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul vis = choose_x_overlay_visual( dpy, screen, rgb_flag, level, 104642f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul trans_type, trans_value, min_ci, visual_type ); 104742f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul } 1048afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1049afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1050afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 1051ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul /* Note: we're not exactly obeying the glXChooseVisual rules here. 1052ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * When GLX_DEPTH_SIZE = 1 is specified we're supposed to choose the 1053ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * largest depth buffer size, which is 32bits/value. However, we 1054ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * return 16 to maintain performance with earlier versions of Mesa. 1055ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul */ 1056ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul if (depth_size == 1) 1057ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul depth_size = DEFAULT_SOFTWARE_DEPTH_BITS; 1058ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul else if (depth_size > 24) 1059ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul depth_size = 31; 1060ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul else if (depth_size > 16) 1061ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul depth_size = 24; 1062ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul /* we only support one size of stencil and accum buffers. */ 1063ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul if (stencil_size > 0) 1064ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul stencil_size = STENCIL_BITS; 1065b2e460018375f699198073a6167e0ee96ba1d267Brian Paul if (accumRedSize > 0) 1066b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumRedSize = ACCUM_BITS; 1067b2e460018375f699198073a6167e0ee96ba1d267Brian Paul if (accumGreenSize > 0) 1068b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumGreenSize = ACCUM_BITS; 1069b2e460018375f699198073a6167e0ee96ba1d267Brian Paul if (accumBlueSize > 0) 1070b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumBlueSize = ACCUM_BITS; 1071b2e460018375f699198073a6167e0ee96ba1d267Brian Paul if (accumAlphaSize > 0) 1072b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumAlphaSize = ACCUM_BITS; 1073afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!save_glx_visual( dpy, vis, rgb_flag, alpha_flag, double_flag, 1074b2e460018375f699198073a6167e0ee96ba1d267Brian Paul stereo_flag, depth_size, stencil_size, 1075b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumRedSize, accumGreenSize, 1076b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumBlueSize, accumAlphaSize, 1077b2e460018375f699198073a6167e0ee96ba1d267Brian Paul level )) 1078afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 1079afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1080afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1081afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 1082afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1083afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1084afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1085afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1086afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1087426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXContext 1088426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateContext( Display *dpy, XVisualInfo *visinfo, 1089426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul GLXContext share_list, Bool direct ) 1090afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1091afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaVisual glxvis; 1092afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaContext xmctx; 1093afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1094afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* deallocate unused windows/buffers */ 1095afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaGarbageCollect(); 1096afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1097afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg glxvis = find_glx_visual( dpy, visinfo ); 1098afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!glxvis) { 1099afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* This visual wasn't found with glXChooseVisual() */ 1100afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg glxvis = create_glx_visual( dpy, visinfo ); 1101afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!glxvis) { 1102afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* unusable visual */ 1103afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 1104afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1105afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1106afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1107afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg xmctx = XMesaCreateContext( glxvis, (XMesaContext) share_list ); 1108afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (xmctx) { 1109afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* set the direct/indirect flag */ 1110afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg xmctx->direct = direct; 1111afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1112afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return (GLXContext) xmctx; 1113afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1114afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1115afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1116afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic GLXContext MakeCurrent_PrevContext = 0; 1117086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic GLXDrawable MakeCurrent_PrevDrawable = 0; 1118086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic GLXDrawable MakeCurrent_PrevReadable = 0; 1119086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic XMesaBuffer MakeCurrent_PrevDrawBuffer = 0; 1120086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic XMesaBuffer MakeCurrent_PrevReadBuffer = 0; 1121afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1122086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul/* GLX 1.3 and later */ 1123426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool 1124426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXMakeContextCurrent( Display *dpy, GLXDrawable draw, 1125426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul GLXDrawable read, GLXContext ctx ) 1126086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul{ 1127086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul if (ctx && draw && read) { 1128086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul XMesaBuffer drawBuffer, readBuffer; 1129086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul XMesaContext xmctx = (XMesaContext) ctx; 1130086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul 1131086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* Find the XMesaBuffer which corresponds to the GLXDrawable 'draw' */ 1132086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul if (ctx == MakeCurrent_PrevContext 1133086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul && draw == MakeCurrent_PrevDrawable) { 1134086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul drawBuffer = MakeCurrent_PrevDrawBuffer; 1135086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1136086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul else { 1137086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul drawBuffer = XMesaFindBuffer( dpy, draw ); 1138086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1139086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul if (!drawBuffer) { 1140086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* drawable must be a new window! */ 11414c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul drawBuffer = XMesaCreateWindowBuffer2( xmctx->xm_visual, draw, (XMesaContext) ctx ); 1142086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul if (!drawBuffer) { 1143086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* Out of memory, or context/drawable depth mismatch */ 1144086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul return False; 1145086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1146086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1147086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul 1148086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* Find the XMesaBuffer which corresponds to the GLXDrawable 'read' */ 1149086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul if (ctx == MakeCurrent_PrevContext 1150086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul && read == MakeCurrent_PrevReadable) { 1151086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul readBuffer = MakeCurrent_PrevReadBuffer; 1152086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1153086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul else { 1154086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul readBuffer = XMesaFindBuffer( dpy, read ); 1155086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1156086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul if (!readBuffer) { 1157086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* drawable must be a new window! */ 11584c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul readBuffer = XMesaCreateWindowBuffer2( xmctx->xm_visual, read, (XMesaContext) ctx ); 1159086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul if (!readBuffer) { 1160086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* Out of memory, or context/drawable depth mismatch */ 1161086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul return False; 1162086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1163086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1164086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul 1165086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevContext = ctx; 1166086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevDrawable = draw; 1167086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevReadable = read; 1168086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevDrawBuffer = drawBuffer; 1169086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevReadBuffer = readBuffer; 1170086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul 1171086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* Now make current! */ 1172086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul return (Bool) XMesaMakeCurrent2((XMesaContext) ctx, drawBuffer, readBuffer); 1173086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1174086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul else if (!ctx && !draw && !read) { 1175086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* release current context w/out assigning new one. */ 1176086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul XMesaMakeCurrent( NULL, NULL ); 1177086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevContext = 0; 1178086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevDrawable = 0; 1179086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevReadable = 0; 1180086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevDrawBuffer = 0; 1181086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevReadBuffer = 0; 1182086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul return True; 1183086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1184086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul else { 1185086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* The args must either all be non-zero or all zero. 1186086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul * This is an error. 1187086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul */ 1188086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul return False; 1189086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1190086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul} 1191086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul 1192086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul 1193426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1194426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool 1195426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXMakeCurrent( Display *dpy, GLXDrawable drawable, GLXContext ctx ) 1196426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 1197426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul return Fake_glXMakeContextCurrent( dpy, drawable, drawable, ctx ); 1198426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1199426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1200426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1201426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1202426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPixmap 1203426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateGLXPixmap( Display *dpy, XVisualInfo *visinfo, Pixmap pixmap ) 1204afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1205afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaVisual v; 1206afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaBuffer b; 1207afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1208afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg v = find_glx_visual( dpy, visinfo ); 1209afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!v) { 1210afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg v = create_glx_visual( dpy, visinfo ); 1211afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!v) { 1212afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* unusable visual */ 1213afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1214afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1215afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1216afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1217afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg b = XMesaCreatePixmapBuffer( v, pixmap, 0 ); 1218afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!b) { 1219afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1220afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1221afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return b->frontbuffer; 1222afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1223afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1224afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1225afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#ifdef GLX_MESA_pixmap_colormap 1226426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPixmap 1227426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visinfo, 1228426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul Pixmap pixmap, Colormap cmap ) 1229afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1230afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaVisual v; 1231afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaBuffer b; 1232afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1233afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg v = find_glx_visual( dpy, visinfo ); 1234afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!v) { 1235afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg v = create_glx_visual( dpy, visinfo ); 1236afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!v) { 1237afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* unusable visual */ 1238afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1239afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1240afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1241afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1242afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg b = XMesaCreatePixmapBuffer( v, pixmap, cmap ); 1243afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!b) { 1244afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1245afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1246afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return b->frontbuffer; 1247afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1248afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#endif 1249afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1250afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1251426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1252426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyGLXPixmap( Display *dpy, GLXPixmap pixmap ) 1253afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1254afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaBuffer b = XMesaFindBuffer(dpy, pixmap); 1255afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (b) { 1256afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaDestroyBuffer(b); 1257afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1258afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else if (getenv("MESA_DEBUG")) { 1259afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg fprintf( stderr, "Mesa: glXDestroyGLXPixmap: invalid pixmap\n"); 1260afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1261afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1262afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1263afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 12644c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul 1265426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1266426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCopyContext( Display *dpy, GLXContext src, GLXContext dst, 12673994b77bab8c62a4c1a4dffdfba233ef46662b99Brian Paul unsigned long mask ) 1268afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1269afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaContext xm_src = (XMesaContext) src; 1270afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaContext xm_dst = (XMesaContext) dst; 1271afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 1272f3232bcaf1f875e6a7198e3b5ede3e286ceb04faBrian Paul gl_copy_context( xm_src->gl_ctx, xm_dst->gl_ctx, (GLuint) mask ); 1273afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1274afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1275afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1276afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1277426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool 1278426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryExtension( Display *dpy, int *errorb, int *event ) 1279afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1280afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Mesa's GLX isn't really an X extension but we try to act like one. */ 1281afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 1282afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) errorb; 1283afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) event; 1284afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return True; 1285afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1286afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1287afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1288e7b16b74bf5d13331b5a88bbbbb9096560297b63Brian Paulextern void _kw_ungrab_all( Display *dpy ); 1289afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgvoid _kw_ungrab_all( Display *dpy ) 1290afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1291afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XUngrabPointer( dpy, CurrentTime ); 1292afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XUngrabKeyboard( dpy, CurrentTime ); 1293afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1294afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1295afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1296426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1297426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyContext( Display *dpy, GLXContext ctx ) 1298afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1299afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 1300afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg MakeCurrent_PrevContext = 0; 1301afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg MakeCurrent_PrevDrawable = 0; 1302086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevReadable = 0; 1303086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevDrawBuffer = 0; 1304086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevReadBuffer = 0; 1305afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaDestroyContext( (XMesaContext) ctx ); 1306afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaGarbageCollect(); 1307afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1308afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1309afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1310afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1311426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool 1312426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXIsDirect( Display *dpy, GLXContext ctx ) 1313afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1314afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 1315afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return ((XMesaContext) ctx)->direct; 1316afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1317afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1318afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1319afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1320426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1321426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXSwapBuffers( Display *dpy, GLXDrawable drawable ) 1322afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1323afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaBuffer buffer = XMesaFindBuffer( dpy, drawable ); 1324afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1325afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (buffer) { 1326afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaSwapBuffers(buffer); 1327afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1328afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else if (getenv("MESA_DEBUG")) { 1329afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg fprintf(stderr, "Mesa Warning: glXSwapBuffers: invalid drawable\n"); 1330afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1331afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1332afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1333afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 13344c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul 13354c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul#ifdef GLX_MESA_copy_sub_buffer 1336426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1337426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCopySubBufferMESA( Display *dpy, GLXDrawable drawable, 1338426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul int x, int y, int width, int height ) 1339afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1340afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaBuffer buffer = XMesaFindBuffer( dpy, drawable ); 1341afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (buffer) { 1342afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaCopySubBuffer(buffer, x, y, width, height); 1343afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1344afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else if (getenv("MESA_DEBUG")) { 1345afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg fprintf(stderr, "Mesa Warning: glXCopySubBufferMESA: invalid drawable\n"); 1346afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1347afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 13484c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul#endif 1349afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1350afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1351afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1352426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool 1353426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryVersion( Display *dpy, int *maj, int *min ) 1354afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1355afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 1356afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Return GLX version, not Mesa version */ 135778fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul assert(CLIENT_MAJOR_VERSION == SERVER_MAJOR_VERSION); 135878fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul *maj = CLIENT_MAJOR_VERSION; 135978fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul *min = MIN2( CLIENT_MINOR_VERSION, SERVER_MINOR_VERSION ); 1360afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return True; 1361afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1362afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1363afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1364afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1365afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 1366afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Query the GLX attributes of the given XVisualInfo. 1367afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 1368426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int 1369426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetConfig( Display *dpy, XVisualInfo *visinfo, 1370426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul int attrib, int *value ) 1371afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1372afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaVisual glxvis; 1373afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1374afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg glxvis = find_glx_visual( dpy, visinfo ); 1375afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!glxvis) { 1376afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* this visual wasn't obtained with glXChooseVisual */ 1377afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg glxvis = create_glx_visual( dpy, visinfo ); 1378afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!glxvis) { 1379afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* this visual can't be used for GL rendering */ 1380afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (attrib==GLX_USE_GL) { 1381afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = (int) False; 1382afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1383afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1384afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 1385afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /*fprintf( stderr, "Mesa: Error in glXGetConfig: bad visual\n");*/ 1386afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return GLX_BAD_VISUAL; 1387afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1388afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1389afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1390afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1391afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch(attrib) { 1392afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_USE_GL: 1393afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = (int) True; 1394afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1395afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_BUFFER_SIZE: 1396afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = visinfo->depth; 1397afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1398afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_LEVEL: 1399afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = glxvis->level; 1400afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1401afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_RGBA: 1402afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (glxvis->gl_visual->RGBAflag) { 1403afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = True; 1404afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1405afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 1406afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = False; 1407afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1408afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1409afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_DOUBLEBUFFER: 1410afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = (int) glxvis->gl_visual->DBflag; 1411afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1412afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STEREO: 1413afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = (int) glxvis->gl_visual->StereoFlag; 1414afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1415afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_AUX_BUFFERS: 1416afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = (int) False; 1417afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1418afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_RED_SIZE: 1419afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = glxvis->gl_visual->RedBits; 1420afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1421afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_GREEN_SIZE: 1422afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = glxvis->gl_visual->GreenBits; 1423afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1424afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_BLUE_SIZE: 1425afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = glxvis->gl_visual->BlueBits; 1426afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1427afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ALPHA_SIZE: 1428afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = glxvis->gl_visual->AlphaBits; 1429afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1430afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_DEPTH_SIZE: 1431afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = glxvis->gl_visual->DepthBits; 1432afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1433afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STENCIL_SIZE: 1434afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = glxvis->gl_visual->StencilBits; 1435afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1436afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_RED_SIZE: 1437b2e460018375f699198073a6167e0ee96ba1d267Brian Paul *value = glxvis->gl_visual->AccumRedBits; 1438b2e460018375f699198073a6167e0ee96ba1d267Brian Paul return 0; 1439afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_GREEN_SIZE: 1440b2e460018375f699198073a6167e0ee96ba1d267Brian Paul *value = glxvis->gl_visual->AccumGreenBits; 1441b2e460018375f699198073a6167e0ee96ba1d267Brian Paul return 0; 1442afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_BLUE_SIZE: 1443b2e460018375f699198073a6167e0ee96ba1d267Brian Paul *value = glxvis->gl_visual->AccumBlueBits; 1444afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1445afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_ALPHA_SIZE: 1446b2e460018375f699198073a6167e0ee96ba1d267Brian Paul *value = glxvis->gl_visual->AccumAlphaBits; 1447afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1448afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1449afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* 1450afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * GLX_EXT_visual_info extension 1451afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 1452afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_X_VISUAL_TYPE_EXT: 1453afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (glxvis->visinfo->CLASS) { 1454afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case StaticGray: *value = GLX_STATIC_GRAY_EXT; return 0; 1455afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GrayScale: *value = GLX_GRAY_SCALE_EXT; return 0; 1456afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case StaticColor: *value = GLX_STATIC_GRAY_EXT; return 0; 1457afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case PseudoColor: *value = GLX_PSEUDO_COLOR_EXT; return 0; 1458afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case TrueColor: *value = GLX_TRUE_COLOR_EXT; return 0; 1459afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case DirectColor: *value = GLX_DIRECT_COLOR_EXT; return 0; 1460afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1461afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1462afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_TYPE_EXT: 1463afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (glxvis->level==0) { 1464afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* normal planes */ 1465afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = GLX_NONE_EXT; 1466afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1467afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else if (glxvis->level>0) { 1468afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* overlay */ 1469afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (glxvis->gl_visual->RGBAflag) { 1470afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = GLX_TRANSPARENT_RGB_EXT; 1471afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1472afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 1473afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = GLX_TRANSPARENT_INDEX_EXT; 1474afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1475afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1476afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else if (glxvis->level<0) { 1477afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* underlay */ 1478afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = GLX_NONE_EXT; 1479afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1480afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1481afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_INDEX_VALUE_EXT: 1482afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg { 1483afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int pixel = transparent_pixel( glxvis ); 1484afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (pixel>=0) { 1485afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = pixel; 1486afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1487afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* else undefined */ 1488afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1489afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1490afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_RED_VALUE_EXT: 1491afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* undefined */ 1492afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1493afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_GREEN_VALUE_EXT: 1494afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* undefined */ 1495afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1496afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_BLUE_VALUE_EXT: 1497afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* undefined */ 1498afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1499afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_ALPHA_VALUE_EXT: 1500afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* undefined */ 1501afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1502afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1503afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* 1504b2e460018375f699198073a6167e0ee96ba1d267Brian Paul * GLX_EXT_visual_info extension 1505b2e460018375f699198073a6167e0ee96ba1d267Brian Paul */ 1506b2e460018375f699198073a6167e0ee96ba1d267Brian Paul case GLX_VISUAL_CAVEAT_EXT: 1507fc68be6b111473a0bf8f991468f973bb9dd275f4Brian Paul /* test for zero, just in case */ 1508962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul if (glxvis->VisualCaveat > 0) 1509962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul *value = glxvis->VisualCaveat; 1510962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul else 1511962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul *value = GLX_NONE_EXT; 1512962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul return 0; 1513b2e460018375f699198073a6167e0ee96ba1d267Brian Paul 1514b2e460018375f699198073a6167e0ee96ba1d267Brian Paul /* 1515afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Extensions 1516afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 1517afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: 1518afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return GLX_BAD_ATTRIBUTE; 1519afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1520afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1521afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1522afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1523afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1524426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1525426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXWaitGL( void ) 1526afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1527afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaContext xmesa = XMesaGetCurrentContext(); 1528afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaFlush( xmesa ); 1529afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1530afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1531afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1532afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1533426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1534426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXWaitX( void ) 1535afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1536afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaContext xmesa = XMesaGetCurrentContext(); 1537afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaFlush( xmesa ); 1538afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1539afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1540afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 154143c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul/* 154243c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul * Return the extensions string, which is 3Dfx-dependant. 154343c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul */ 154443c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paulstatic const char *get_extensions( void ) 154543c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul{ 154643c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul#ifdef FX 154743c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul const char *fx = getenv("MESA_GLX_FX"); 154843c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul if (fx && fx[0] != 'd') { 1549e1210b176926349b258c7ec77b7f36716025c82aBrian Paul return "GLX_MESA_pixmap_colormap GLX_EXT_visual_info GLX_EXT_visual_rating GLX_MESA_release_buffers GLX_MESA_copy_sub_buffer GLX_SGI_video_sync GLX_MESA_set_3dfx_mode GLX_ARB_get_proc_address"; 155043c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul } 155143c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul#endif 1552e1210b176926349b258c7ec77b7f36716025c82aBrian Paul return "GLX_MESA_pixmap_colormap GLX_EXT_visual_info GLX_EXT_visual_rating GLX_MESA_release_buffers GLX_MESA_copy_sub_buffer GLX_SGI_video_sync GLX_ARB_get_proc_address"; 155343c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul} 1554afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1555afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1556afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1557afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* GLX 1.1 and later */ 1558426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic const char * 1559426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryExtensionsString( Display *dpy, int screen ) 1560afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1561afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 1562afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) screen; 156343c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul return get_extensions(); 1564afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1565afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1566afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1567afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1568afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* GLX 1.1 and later */ 1569426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic const char * 1570426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryServerString( Display *dpy, int screen, int name ) 1571afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 157278fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul static char version[1000]; 157378fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul sprintf(version, "%d.%d %s", SERVER_MAJOR_VERSION, SERVER_MINOR_VERSION, 157478fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul MESA_GLX_VERSION); 1575afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1576afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 1577afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) screen; 1578afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1579afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (name) { 1580afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_EXTENSIONS: 158143c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul return get_extensions(); 1582afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_VENDOR: 158378fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul return VENDOR; 1584afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_VERSION: 1585afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return version; 1586afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: 1587afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 1588afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1589afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1590afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1591afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1592afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1593afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* GLX 1.1 and later */ 1594426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic const char * 1595426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetClientString( Display *dpy, int name ) 1596afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 159778fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul static char version[1000]; 159878fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul sprintf(version, "%d.%d %s", CLIENT_MAJOR_VERSION, CLIENT_MINOR_VERSION, 159978fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul MESA_GLX_VERSION); 1600afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1601afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 1602afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1603afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (name) { 1604afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_EXTENSIONS: 160543c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul return get_extensions(); 1606afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_VENDOR: 160778fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul return VENDOR; 1608afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_VERSION: 1609afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return version; 1610afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: 1611afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 1612afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1613afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1614afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1615afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1616afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1617426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul/* 1618426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul * GLX 1.3 and later 1619426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul */ 1620426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 16215605798e56ca6e9f968623f33b58ee7ca90594afBrian Paulstatic GLXFBConfig * 1622426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXChooseFBConfig( Display *dpy, int screen, 1623426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul const int *attribList, int *nitems ) 1624426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 1625426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 1626426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) screen; 1627426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) attribList; 1628426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) nitems; 1629426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul return 0; 1630426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1631426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1632426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1633426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int 1634426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetFBConfigAttrib( Display *dpy, GLXFBConfig config, 1635426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul int attribute, int *value ) 1636426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 1637426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 1638426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) config; 1639426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) attribute; 1640426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) value; 1641426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul return 0; 1642426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1643426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1644426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 16455605798e56ca6e9f968623f33b58ee7ca90594afBrian Paulstatic GLXFBConfig * 16465605798e56ca6e9f968623f33b58ee7ca90594afBrian PaulFake_glXGetFBConfigs( Display *dpy, int screen, int *nelements ) 16475605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul{ 16485605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul (void) dpy; 16495605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul (void) screen; 16505605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul (void) nelements; 16515605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul return 0; 16525605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul} 16535605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul 16545605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul 1655426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic XVisualInfo * 1656426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetVisualFromFBConfig( Display *dpy, GLXFBConfig config ) 1657426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 1658426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 1659426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) config; 1660426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul return 0; 1661426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1662426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1663426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1664426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXWindow 1665426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateWindow( Display *dpy, GLXFBConfig config, Window win, 1666426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul const int *attribList ) 1667426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 1668426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 1669426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) config; 1670426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) win; 1671426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) attribList; 1672426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul return 0; 1673426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1674426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1675426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1676426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1677426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyWindow( Display *dpy, GLXWindow window ) 1678426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 1679426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 1680426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) window; 1681426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul return; 1682426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1683426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1684426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1685426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPixmap 1686426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreatePixmap( Display *dpy, GLXFBConfig config, Pixmap pixmap, 1687426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul const int *attribList ) 1688426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 1689426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 1690426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) config; 1691426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) pixmap; 1692426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) attribList; 1693426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul return 0; 1694426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1695426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1696426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1697426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1698426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyPixmap( Display *dpy, GLXPixmap pixmap ) 1699426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 1700426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 1701426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) pixmap; 1702426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul return; 1703426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1704426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1705426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1706426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPbuffer 1707426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreatePbuffer( Display *dpy, GLXFBConfig config, 1708426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul const int *attribList ) 1709426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 1710426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 1711426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) config; 1712426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) attribList; 1713426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul return 0; 1714426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1715426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1716426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1717426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1718426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyPbuffer( Display *dpy, GLXPbuffer pbuf ) 1719426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 1720426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 1721426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) pbuf; 1722426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1723426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1724426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1725426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1726426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryDrawable( Display *dpy, GLXDrawable draw, int attribute, 1727426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul unsigned int *value ) 1728426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 1729426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 1730426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) draw; 1731426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) attribute; 1732426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) value; 1733426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1734426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1735426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1736426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXContext 1737426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateNewContext( Display *dpy, GLXFBConfig config, 1738426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul int renderType, GLXContext shareList, Bool direct ) 1739426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 1740426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 1741426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) config; 1742426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) renderType; 1743426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) shareList; 1744426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) direct; 1745426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul return 0; 1746426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1747426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1748426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1749426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int 1750426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryContext( Display *dpy, GLXContext ctx, int attribute, int *value ) 1751426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 1752426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 1753426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) ctx; 1754426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) attribute; 1755426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) value; 1756426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul return 0; 1757426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1758426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1759426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1760426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1761426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXSelectEvent( Display *dpy, GLXDrawable drawable, unsigned long mask ) 1762426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 1763426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 1764426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) drawable; 1765426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) mask; 1766426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1767426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1768426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1769426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1770426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetSelectedEvent( Display *dpy, GLXDrawable drawable, 1771426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul unsigned long *mask ) 1772426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 1773426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 1774426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) drawable; 1775426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) mask; 1776426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1777b82d993b03320818f88f792a9e713f7ed491bfcbBrian Paul 1778b82d993b03320818f88f792a9e713f7ed491bfcbBrian Paul 1779b82d993b03320818f88f792a9e713f7ed491bfcbBrian Paul 17804c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul#ifdef GLX_MESA_release_buffers 1781afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 1782afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Release the depth, stencil, accum buffers attached to a GLXDrawable 1783afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * (a window or pixmap) prior to destroying the GLXDrawable. 1784afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 1785426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool 1786426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXReleaseBuffersMESA( Display *dpy, GLXDrawable d ) 1787afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1788afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaBuffer b = XMesaFindBuffer(dpy, d); 1789afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (b) { 1790afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaDestroyBuffer(b); 1791afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return True; 1792afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1793afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return False; 1794afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 17954c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul#endif 1796afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1797afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 17984c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul 17994c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul#ifdef GLX_MESA_set_3dfx_mode 1800426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLboolean 1801426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXSet3DfxModeMESA( GLint mode ) 1802afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 180343c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul return XMesaSetFXmode( mode ); 1804afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 18054c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul#endif 18064c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul 180789a42b7e736bd9b0ab090906cab0cd047a6ec12eBrian Paul 180889a42b7e736bd9b0ab090906cab0cd047a6ec12eBrian Paul 1809426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul/* 1810426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul * GLX_SGI_video_sync 1811426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul */ 1812426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1813426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul#ifdef GLX_SGI_video_sync 1814426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1815426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int 1816426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetVideoSyncSGI(unsigned int *count) 1817426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 1818426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul return 0; 1819426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1820426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1821426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1822426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int 1823426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count) 1824426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 1825426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul return 0; 1826426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1827426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1828426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul#endif 1829426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1830426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 183143c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul 1832e7b16b74bf5d13331b5a88bbbbb9096560297b63Brian Paulextern struct _glxapi_table *_mesa_GetGLXDispatchTable(void); 1833426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstruct _glxapi_table *_mesa_GetGLXDispatchTable(void) 1834426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 1835426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul static struct _glxapi_table glx; 1836426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1837426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul /* be sure our dispatch table size <= libGL's table */ 1838426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul { 1839426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul int size = sizeof(struct _glxapi_table) / sizeof(void *); 1840426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) size; 1841426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul assert(_glxapi_get_dispatch_table_size() >= size); 1842426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul } 1843426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1844426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul /* initialize the whole table to no-ops */ 1845426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul _glxapi_set_no_op_table(&glx); 1846426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1847426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul /* now initialize the table with the functions I implement */ 1848426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.ChooseVisual = Fake_glXChooseVisual; 1849426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CopyContext = Fake_glXCopyContext; 1850426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CreateContext = Fake_glXCreateContext; 1851426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CreateGLXPixmap = Fake_glXCreateGLXPixmap; 1852426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.DestroyContext = Fake_glXDestroyContext; 1853426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.DestroyGLXPixmap = Fake_glXDestroyGLXPixmap; 1854426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.GetConfig = Fake_glXGetConfig; 1855426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul /*glx.GetCurrentContext = Fake_glXGetCurrentContext;*/ 1856426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul /*glx.GetCurrentDrawable = Fake_glXGetCurrentDrawable;*/ 1857426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.IsDirect = Fake_glXIsDirect; 1858426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.MakeCurrent = Fake_glXMakeCurrent; 1859426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.QueryExtension = Fake_glXQueryExtension; 1860426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.QueryVersion = Fake_glXQueryVersion; 1861426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.SwapBuffers = Fake_glXSwapBuffers; 1862426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.UseXFont = Fake_glXUseXFont; 1863426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.WaitGL = Fake_glXWaitGL; 1864426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.WaitX = Fake_glXWaitX; 1865426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 18664c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul#ifdef GLX_VERSION_1_1 1867426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.GetClientString = Fake_glXGetClientString; 1868426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.QueryExtensionsString = Fake_glXQueryExtensionsString; 1869426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.QueryServerString = Fake_glXQueryServerString; 1870426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul#endif 1871426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 18724c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul#ifdef GLX_VERSION_1_2 1873426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul /*glx.GetCurrentDisplay = Fake_glXGetCurrentDisplay;*/ 1874426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul#endif 1875426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 18764c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul#ifdef GLX_VERSION_1_3 1877426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.ChooseFBConfig = Fake_glXChooseFBConfig; 1878426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CreateNewContext = Fake_glXCreateNewContext; 1879426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CreatePbuffer = Fake_glXCreatePbuffer; 1880426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CreatePixmap = Fake_glXCreatePixmap; 1881426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CreateWindow = Fake_glXCreateWindow; 1882426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.DestroyPbuffer = Fake_glXDestroyPbuffer; 1883426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.DestroyPixmap = Fake_glXDestroyPixmap; 1884426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.DestroyWindow = Fake_glXDestroyWindow; 1885426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul /*glx.GetCurrentReadDrawable = Fake_glXGetCurrentReadDrawable;*/ 1886426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.GetFBConfigAttrib = Fake_glXGetFBConfigAttrib; 188771dea349d2be623b7819389428b0d6a124e8d184Brian Paul glx.GetFBConfigs = Fake_glXGetFBConfigs; 1888426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.GetSelectedEvent = Fake_glXGetSelectedEvent; 1889426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.GetVisualFromFBConfig = Fake_glXGetVisualFromFBConfig; 1890426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.MakeContextCurrent = Fake_glXMakeContextCurrent; 1891426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.QueryContext = Fake_glXQueryContext; 1892426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.QueryDrawable = Fake_glXQueryDrawable; 1893426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.SelectEvent = Fake_glXSelectEvent; 1894426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul#endif 1895426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 18964c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul#ifdef GLX_SGI_video_sync 1897426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.GetVideoSyncSGI = Fake_glXGetVideoSyncSGI; 1898426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.WaitVideoSyncSGI = Fake_glXWaitVideoSyncSGI; 1899426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul#endif 1900426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 19014c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul#ifdef GLX_MESA_copy_sub_buffer 1902426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CopySubBufferMESA = Fake_glXCopySubBufferMESA; 1903426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul#endif 1904426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 19054c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul#ifdef GLX_MESA_release_buffers 1906426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.ReleaseBuffersMESA = Fake_glXReleaseBuffersMESA; 1907426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul#endif 1908426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 19094c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul#ifdef GLX_MESA_pixmap_colormap 1910426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CreateGLXPixmapMESA = Fake_glXCreateGLXPixmapMESA; 1911426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul#endif 1912426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 19134c07bd5709830bd11cb29d4d8b8a56e757dc0365Brian Paul#ifdef GLX_MESA_set_3dfx_mode 1914426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.Set3DfxModeMESA = Fake_glXSet3DfxModeMESA; 1915426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul#endif 1916426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1917426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul return &glx; 1918426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1919