fakeglx.c revision 5605798e56ca6e9f968623f33b58ee7ca90594af
15605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul/* $Id: fakeglx.c,v 1.32 2000/04/10 21:13:19 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" 51afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#include "types.h" 52afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#include "xmesaP.h" 53afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 54afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 5578fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul/* This indicates the client-side GLX API and GLX encoder version. */ 5678fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul#define CLIENT_MAJOR_VERSION 1 5778fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul#define CLIENT_MINOR_VERSION 2 5878fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul 5978fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul/* This indicates the server-side GLX decoder version. 6078fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul * GLX 1.3 indicates OpenGL 1.2 support 6178fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul */ 6278fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul#define SERVER_MAJOR_VERSION 1 6378fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul#define SERVER_MINOR_VERSION 3 6478fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul 6578fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul/* This is appended onto the glXGetClient/ServerString version strings. */ 66262f9e52d6a511fffd1e6746de9d83d89cca9e1aBrian Paul#define MESA_GLX_VERSION "Mesa 3.3" 6778fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul 6878fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul/* Who implemented this GLX? */ 6978fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul#define VENDOR "Brian Paul" 7078fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul 7178fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul 72afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 7343c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul/* Silence compiler warnings */ 74e7b16b74bf5d13331b5a88bbbbb9096560297b63Brian Paulextern void Fake_glXDummyFunc( void ); 7543c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paulvoid Fake_glXDummyFunc( void ) 7643c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul{ 7743c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul (void) kernel8; 7843c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul (void) DitherValues; 7943c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul (void) HPCR_DRGB; 8043c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul (void) kernel1; 8143c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul} 8243c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul 8343c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul 8443c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul 85afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#define DONT_CARE -1 86afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 87afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 88afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 89afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#define MAX_VISUALS 100 90afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XMesaVisual VisualTable[MAX_VISUALS]; 91afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic int NumVisuals = 0; 92afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 93afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 94afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 95afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 96afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * This struct and some code fragments borrowed 97afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * from Mark Kilgard's GLUT library. 98afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 99afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgtypedef struct _OverlayInfo { 100afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Avoid 64-bit portability problems by being careful to use 101afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg longs due to the way XGetWindowProperty is specified. Note 102afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg that these parameters are passed as CARD32s over X 103afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg protocol. */ 104afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg unsigned long overlay_visual; 105afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg long transparent_type; 106afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg long value; 107afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg long layer; 108afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} OverlayInfo; 109afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 110afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 111afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 112afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* Macro to handle c_class vs class field name in XVisualInfo struct */ 113afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#if defined(__cplusplus) || defined(c_plusplus) 114afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#define CLASS c_class 115afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#else 116afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#define CLASS class 117afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#endif 118afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 119afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 120afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 121afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 122afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 123afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Test if the given XVisualInfo is usable for Mesa rendering. 124afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 125afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic GLboolean is_usable_visual( XVisualInfo *vinfo ) 126afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 127afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (vinfo->CLASS) { 128afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case StaticGray: 129afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GrayScale: 130afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Any StaticGray/GrayScale visual works in RGB or CI mode */ 131afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return GL_TRUE; 132afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case StaticColor: 133afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case PseudoColor: 134afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Any StaticColor/PseudoColor visual of at least 4 bits */ 135afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vinfo->depth>=4) { 136afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return GL_TRUE; 137afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 138afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 139afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return GL_FALSE; 140afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 141afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case TrueColor: 142afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case DirectColor: 143afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Any depth of TrueColor or DirectColor works in RGB mode */ 144afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return GL_TRUE; 145afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: 146afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* This should never happen */ 147afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return GL_FALSE; 148afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 149afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 150afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 151afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 152afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 153afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 154afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return the level (overlay, normal, underlay) of a given XVisualInfo. 155afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input: dpy - the X display 156afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * vinfo - the XVisualInfo to test 157afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return: level of the visual: 158afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * 0 = normal planes 159afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * >0 = overlay planes 160afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * <0 = underlay planes 161afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 162afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic int level_of_visual( Display *dpy, XVisualInfo *vinfo ) 163afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 164afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg Atom overlayVisualsAtom; 165afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg OverlayInfo *overlay_info = NULL; 166afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int numOverlaysPerScreen; 167afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg Status status; 168afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg Atom actualType; 169afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int actualFormat; 170afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg unsigned long sizeData, bytesLeft; 171afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int i; 172afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 173afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* 174afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * The SERVER_OVERLAY_VISUALS property on the root window contains 175afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * a list of overlay visuals. Get that list now. 176afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 177afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg overlayVisualsAtom = XInternAtom(dpy,"SERVER_OVERLAY_VISUALS", True); 178afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (overlayVisualsAtom == None) { 179afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 180afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 181afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 182afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg status = XGetWindowProperty(dpy, RootWindow( dpy, vinfo->screen ), 183afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg overlayVisualsAtom, 0L, (long) 10000, False, 184afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg overlayVisualsAtom, &actualType, &actualFormat, 185afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg &sizeData, &bytesLeft, 186afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (unsigned char **) &overlay_info ); 187afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 188afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (status != Success || actualType != overlayVisualsAtom || 189afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg actualFormat != 32 || sizeData < 4) { 190afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* something went wrong */ 191afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XFree((void *) overlay_info); 192afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 193afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 194afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 195afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* search the overlay visual list for the visual ID of interest */ 196afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg numOverlaysPerScreen = (int) (sizeData / 4); 197afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (i=0;i<numOverlaysPerScreen;i++) { 198afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg OverlayInfo *ov; 199afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg ov = overlay_info + i; 200afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (ov->overlay_visual==vinfo->visualid) { 201afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* found the visual */ 202afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (/*ov->transparent_type==1 &&*/ ov->layer!=0) { 203afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int level = ov->layer; 204afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XFree((void *) overlay_info); 205afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return level; 206afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 207afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 208afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XFree((void *) overlay_info); 209afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 210afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 211afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 212afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 213afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 214afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* The visual ID was not found in the overlay list. */ 215afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XFree((void *) overlay_info); 216afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 217afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 218afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 219afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 220afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 221afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 222afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 223afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Given an XVisualInfo and RGB, Double, and Depth buffer flags, save the 224afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * configuration in our list of GLX visuals. 225afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 226afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XMesaVisual 227afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgsave_glx_visual( Display *dpy, XVisualInfo *vinfo, 228afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLboolean rgbFlag, GLboolean alphaFlag, GLboolean dbFlag, 229afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLboolean stereoFlag, 230afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLint depth_size, GLint stencil_size, 231b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint accumRedSize, GLint accumGreenSize, 232b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint accumBlueSize, GLint accumAlphaSize, 233b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint level ) 234afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 235afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLboolean ximageFlag = GL_TRUE; 236afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaVisual xmvis; 237afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLint i; 238afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLboolean comparePointers; 239afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 240afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (dbFlag) { 241afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Check if the MESA_BACK_BUFFER env var is set */ 242afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg char *backbuffer = getenv("MESA_BACK_BUFFER"); 243afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (backbuffer) { 244afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (backbuffer[0]=='p' || backbuffer[0]=='P') { 245afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg ximageFlag = GL_FALSE; 246afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 247afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else if (backbuffer[0]=='x' || backbuffer[0]=='X') { 248afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg ximageFlag = GL_TRUE; 249afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 250afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 251afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg fprintf(stderr, "Mesa: invalid value for MESA_BACK_BUFFER "); 252afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg fprintf(stderr, "environment variable, using an XImage.\n"); 253afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 254afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 255afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 256afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 257afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Comparing IDs uses less memory but sometimes fails. */ 258afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* XXX revisit this after 3.0 is finished. */ 259afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (getenv("MESA_GLX_VISUAL_HACK")) 260afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg comparePointers = GL_TRUE; 261afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else 262afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg comparePointers = GL_FALSE; 263afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 264afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* First check if a matching visual is already in the list */ 265afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (i=0; i<NumVisuals; i++) { 266afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaVisual v = VisualTable[i]; 267afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (v->display == dpy 268afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg && v->level == level 269afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg && v->ximage_flag == ximageFlag 270afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg && v->gl_visual->RGBAflag == rgbFlag 271afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg && v->gl_visual->DBflag == dbFlag 272afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg && v->gl_visual->StereoFlag == stereoFlag 273afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg && (v->gl_visual->AlphaBits > 0) == alphaFlag 274afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg && (v->gl_visual->DepthBits >= depth_size || depth_size == 0) 275afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg && (v->gl_visual->StencilBits >= stencil_size || stencil_size == 0) 276b2e460018375f699198073a6167e0ee96ba1d267Brian Paul && (v->gl_visual->AccumRedBits >= accumRedSize || accumRedSize == 0) 277b2e460018375f699198073a6167e0ee96ba1d267Brian Paul && (v->gl_visual->AccumGreenBits >= accumGreenSize || accumGreenSize == 0) 278b2e460018375f699198073a6167e0ee96ba1d267Brian Paul && (v->gl_visual->AccumBlueBits >= accumBlueSize || accumBlueSize == 0) 279b2e460018375f699198073a6167e0ee96ba1d267Brian Paul && (v->gl_visual->AccumAlphaBits >= accumAlphaSize || accumAlphaSize == 0)) { 280afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* now either compare XVisualInfo pointers or visual IDs */ 281d0247f53aea8fa8677aadc8a00f75c8993be9ebcBrian Paul if ((!comparePointers && v->visinfo->visualid == vinfo->visualid) 282afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg || (comparePointers && v->vishandle == vinfo)) { 283afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return v; 284afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 285afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 286afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 287afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 288afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Create a new visual and add it to the list. */ 289afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 290afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (NumVisuals>=MAX_VISUALS) { 291afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg fprintf( stderr, "GLX Error: maximum number of visuals exceeded\n"); 292afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 293afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 294afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 295c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul xmvis = XMesaCreateVisual( dpy, vinfo, rgbFlag, alphaFlag, dbFlag, 296c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul stereoFlag, ximageFlag, 297c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul depth_size, stencil_size, 298c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul accumRedSize, accumBlueSize, 299c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul accumBlueSize, accumAlphaSize, 0, level, 300c8735e8f8299676e443e6ca0ffd339ab94e013f9Brian Paul GLX_NONE_EXT ); 301afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (xmvis) { 302afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg VisualTable[NumVisuals] = xmvis; 303afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg NumVisuals++; 304afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 305afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return xmvis; 306afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 307afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 308afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 309afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 310afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 311afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Create a GLX visual from a regular XVisualInfo. 312ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * This is called when Fake GLX is given an XVisualInfo which wasn't 313ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * returned by glXChooseVisual. Since this is the first time we're 314ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * considering this visual we'll take a guess at reasonable values 315ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * for depth buffer size, stencil size, accum size, etc. 316ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * This is the best we can do with a client-side emulation of GLX. 317afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 318afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XMesaVisual 319afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgcreate_glx_visual( Display *dpy, XVisualInfo *visinfo ) 320afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 321afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int vislevel; 322afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 323afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vislevel = level_of_visual( dpy, visinfo ); 324afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vislevel) { 325afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Configure this visual as a CI, single-buffered overlay */ 326afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return save_glx_visual( dpy, visinfo, 327afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GL_FALSE, /* rgb */ 328afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GL_FALSE, /* alpha */ 329afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GL_FALSE, /* double */ 330afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GL_FALSE, /* stereo */ 331afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 0, /* depth bits */ 332afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 0, /* stencil bits */ 333b2e460018375f699198073a6167e0ee96ba1d267Brian Paul 0,0,0,0, /* accum bits */ 334afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vislevel /* level */ 335afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg ); 336afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 337afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else if (is_usable_visual( visinfo )) { 338afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Configure this visual as RGB, double-buffered, depth-buffered. */ 339afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* This is surely wrong for some people's needs but what else */ 340afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* can be done? They should use glXChooseVisual(). */ 341afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return save_glx_visual( dpy, visinfo, 342afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GL_TRUE, /* rgb */ 343afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GL_FALSE, /* alpha */ 344afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GL_TRUE, /* double */ 345afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GL_FALSE, /* stereo */ 346ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul DEFAULT_SOFTWARE_DEPTH_BITS, 347ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul 8 * sizeof(GLstencil), 348b2e460018375f699198073a6167e0ee96ba1d267Brian Paul 8 * sizeof(GLaccum), /* r */ 349b2e460018375f699198073a6167e0ee96ba1d267Brian Paul 8 * sizeof(GLaccum), /* g */ 350b2e460018375f699198073a6167e0ee96ba1d267Brian Paul 8 * sizeof(GLaccum), /* b */ 351b2e460018375f699198073a6167e0ee96ba1d267Brian Paul 8 * sizeof(GLaccum), /* a */ 352afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 0 /* level */ 353afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg ); 354afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 355afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 356afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg fprintf(stderr,"Mesa: error in glXCreateContext: bad visual\n"); 357afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 358afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 359afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 360afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 361afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 362afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 363afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 364afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Find the GLX visual associated with an XVisualInfo. 365afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 366afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XMesaVisual 367afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgfind_glx_visual( Display *dpy, XVisualInfo *vinfo ) 368afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 369afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int i; 370afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 371afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* First try to match pointers */ 372afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (i=0;i<NumVisuals;i++) { 373afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (VisualTable[i]->display==dpy && VisualTable[i]->vishandle==vinfo) { 374afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return VisualTable[i]; 375afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 376afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 377afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* try to match visual id */ 378afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (i=0;i<NumVisuals;i++) { 379afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (VisualTable[i]->display==dpy 380afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg && VisualTable[i]->visinfo->visualid == vinfo->visualid) { 381afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return VisualTable[i]; 382afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 383afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 384afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 385afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 386afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 387afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 388afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 389afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 390afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return the transparent pixel value for a GLX visual. 391afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input: glxvis - the glx_visual 392afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return: a pixel value or -1 if no transparent pixel 393afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 394afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic int transparent_pixel( XMesaVisual glxvis ) 395afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 396afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg Display *dpy = glxvis->display; 397afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XVisualInfo *vinfo = glxvis->visinfo; 398afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg Atom overlayVisualsAtom; 399afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg OverlayInfo *overlay_info = NULL; 400afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int numOverlaysPerScreen; 401afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg Status status; 402afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg Atom actualType; 403afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int actualFormat; 404afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg unsigned long sizeData, bytesLeft; 405afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int i; 406afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 407afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* 408afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * The SERVER_OVERLAY_VISUALS property on the root window contains 409afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * a list of overlay visuals. Get that list now. 410afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 411afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg overlayVisualsAtom = XInternAtom(dpy,"SERVER_OVERLAY_VISUALS", True); 412afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (overlayVisualsAtom == None) { 413afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return -1; 414afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 415afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 416afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg status = XGetWindowProperty(dpy, RootWindow( dpy, vinfo->screen ), 417afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg overlayVisualsAtom, 0L, (long) 10000, False, 418afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg overlayVisualsAtom, &actualType, &actualFormat, 419afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg &sizeData, &bytesLeft, 420afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (unsigned char **) &overlay_info ); 421afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 422afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (status != Success || actualType != overlayVisualsAtom || 423afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg actualFormat != 32 || sizeData < 4) { 424afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* something went wrong */ 425afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XFree((void *) overlay_info); 426afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return -1; 427afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 428afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 429afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* search the overlay visual list for the visual ID of interest */ 430afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg numOverlaysPerScreen = (int) (sizeData / 4); 431afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (i=0;i<numOverlaysPerScreen;i++) { 432afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg OverlayInfo *ov; 433afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg ov = overlay_info + i; 434afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (ov->overlay_visual==vinfo->visualid) { 435afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* found it! */ 436afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (ov->transparent_type==0) { 437afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* type 0 indicates no transparency */ 438afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XFree((void *) overlay_info); 439afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return -1; 440afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 441afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 442afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* ov->value is the transparent pixel */ 443afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XFree((void *) overlay_info); 444afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return ov->value; 445afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 446afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 447afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 448afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 449afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* The visual ID was not found in the overlay list. */ 450afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XFree((void *) overlay_info); 451afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return -1; 452afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 453afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 454afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 455afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 456afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 457afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return number of bits set in n. 458afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 459afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic int bitcount( unsigned long n ) 460afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 461afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int bits; 462afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (bits=0; n>0; n=n>>1) { 463afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (n&1) { 464afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg bits++; 465afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 466afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 467afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return bits; 468afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 469afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 470afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 471afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 472afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Try to get an X visual which matches the given arguments. 473afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 474afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XVisualInfo *get_visual( Display *dpy, int scr, 475afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg unsigned int depth, int xclass ) 476afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 477afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XVisualInfo temp, *vis; 478afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg long mask; 479afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int n; 480afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg unsigned int default_depth; 481afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int default_class; 482afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 483afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg mask = VisualScreenMask | VisualDepthMask | VisualClassMask; 484afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg temp.screen = scr; 485afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg temp.depth = depth; 486afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg temp.CLASS = xclass; 487afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 488afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default_depth = DefaultDepth(dpy,scr); 489afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default_class = DefaultVisual(dpy,scr)->CLASS; 490afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 491afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (depth==default_depth && xclass==default_class) { 492afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* try to get root window's visual */ 493afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg temp.visualid = DefaultVisual(dpy,scr)->visualid; 494afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg mask |= VisualIDMask; 495afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 496afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 497afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = XGetVisualInfo( dpy, mask, &temp, &n ); 498afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 499afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* In case bits/pixel > 24, make sure color channels are still <=8 bits. 500afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * An SGI Infinite Reality system, for example, can have 30bpp pixels: 501afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * 10 bits per color channel. Mesa's limited to a max of 8 bits/channel. 502afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 503afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis && depth > 24 && (xclass==TrueColor || xclass==DirectColor)) { 504afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (bitcount(vis->red_mask) <= 8 505afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg && bitcount(vis->green_mask) <= 8 506afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg && bitcount(vis->blue_mask) <= 8) { 507afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 508afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 509afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 510afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XFree((void *) vis); 511afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 512afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 513afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 514afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 515afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 516afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 517afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 518afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 519afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 520afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 521afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Retrieve the value of the given environment variable and find 522afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * the X visual which matches it. 523afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input: dpy - the display 524afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * screen - the screen number 525afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * varname - the name of the environment variable 526afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return: an XVisualInfo pointer to NULL if error. 527afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 528afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XVisualInfo *get_env_visual(Display *dpy, int scr, const char *varname) 529afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 530afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg char value[100], type[100]; 531afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int depth, xclass = -1; 532afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XVisualInfo *vis; 533afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 534afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!getenv( varname )) { 535afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 536afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 537afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 538afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg strncpy( value, getenv(varname), 100 ); 539afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg value[99] = 0; 540afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 541afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg sscanf( value, "%s %d", type, &depth ); 542afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 543afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (strcmp(type,"TrueColor")==0) xclass = TrueColor; 544afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else if (strcmp(type,"DirectColor")==0) xclass = DirectColor; 545afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else if (strcmp(type,"PseudoColor")==0) xclass = PseudoColor; 546afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else if (strcmp(type,"StaticColor")==0) xclass = StaticColor; 547afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else if (strcmp(type,"GrayScale")==0) xclass = GrayScale; 548afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else if (strcmp(type,"StaticGray")==0) xclass = StaticGray; 549afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 550afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (xclass>-1 && depth>0) { 551afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, scr, depth, xclass ); 552afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 553afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 554afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 555afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 556afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 557afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg fprintf( stderr, "Mesa: GLX unable to find visual class=%s, depth=%d.\n", 558afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg type, depth ); 559afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 560afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 561afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 562afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 563afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 564afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 565afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Select an X visual which satisfies the RGBA/CI flag and minimum depth. 566afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input: dpy, screen - X display and screen number 567afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * rgba - GL_TRUE = RGBA mode, GL_FALSE = CI mode 568afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * min_depth - minimum visual depth 569afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * preferred_class - preferred GLX visual class or DONT_CARE 570afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return: pointer to an XVisualInfo or NULL. 571afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 572afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XVisualInfo *choose_x_visual( Display *dpy, int screen, 573afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLboolean rgba, int min_depth, 574afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int preferred_class ) 575afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 576afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XVisualInfo *vis; 577afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int xclass, visclass; 578afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int depth; 579afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 580afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (rgba) { 581afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg Atom hp_cr_maps = XInternAtom(dpy, "_HP_RGB_SMOOTH_MAP_LIST", True); 582afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* First see if the MESA_RGB_VISUAL env var is defined */ 583afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_env_visual( dpy, screen, "MESA_RGB_VISUAL" ); 584afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 585afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 586afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 587afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Otherwise, search for a suitable visual */ 588afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (preferred_class==DONT_CARE) { 589afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (xclass=0;xclass<6;xclass++) { 590afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (xclass) { 591afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case 0: visclass = TrueColor; break; 592afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case 1: visclass = DirectColor; break; 593afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case 2: visclass = PseudoColor; break; 594afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case 3: visclass = StaticColor; break; 595afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case 4: visclass = GrayScale; break; 596afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case 5: visclass = StaticGray; break; 597afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 598afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (min_depth==0) { 599afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* start with shallowest */ 600afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (depth=0;depth<=32;depth++) { 601afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (visclass==TrueColor && depth==8 && !hp_cr_maps) { 602afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Special case: try to get 8-bit PseudoColor before */ 603afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* 8-bit TrueColor */ 604afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, screen, 8, PseudoColor ); 605afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 606afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 607afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 608afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 609afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, screen, depth, visclass ); 610afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 611afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 612afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 613afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 614afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 615afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 616afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* start with deepest */ 617afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (depth=32;depth>=min_depth;depth--) { 618afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (visclass==TrueColor && depth==8 && !hp_cr_maps) { 619afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Special case: try to get 8-bit PseudoColor before */ 620afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* 8-bit TrueColor */ 621afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, screen, 8, PseudoColor ); 622afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 623afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 624afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 625afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 626afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, screen, depth, visclass ); 627afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 628afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 629afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 630afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 631afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 632afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 633afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 634afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 635afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* search for a specific visual class */ 636afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (preferred_class) { 637afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRUE_COLOR_EXT: visclass = TrueColor; break; 638afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_DIRECT_COLOR_EXT: visclass = DirectColor; break; 639afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_PSEUDO_COLOR_EXT: visclass = PseudoColor; break; 640afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STATIC_COLOR_EXT: visclass = StaticColor; break; 641afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_GRAY_SCALE_EXT: visclass = GrayScale; break; 642afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STATIC_GRAY_EXT: visclass = StaticGray; break; 643afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: return NULL; 644afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 645afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (min_depth==0) { 646afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* start with shallowest */ 647afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (depth=0;depth<=32;depth++) { 648afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, screen, depth, visclass ); 649afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 650afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 651afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 652afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 653afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 654afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 655afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* start with deepest */ 656afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (depth=32;depth>=min_depth;depth--) { 657afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, screen, depth, visclass ); 658afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 659afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 660afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 661afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 662afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 663afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 664afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 665afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 666afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* First see if the MESA_CI_VISUAL env var is defined */ 667afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_env_visual( dpy, screen, "MESA_CI_VISUAL" ); 668afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 669afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 670afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 671afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Otherwise, search for a suitable visual, starting with shallowest */ 672afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (preferred_class==DONT_CARE) { 673afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (xclass=0;xclass<4;xclass++) { 674afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (xclass) { 675afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case 0: visclass = PseudoColor; break; 676afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case 1: visclass = StaticColor; break; 677afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case 2: visclass = GrayScale; break; 678afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case 3: visclass = StaticGray; break; 679afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 680afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* try 8-bit up through 16-bit */ 681afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (depth=8;depth<=16;depth++) { 682afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, screen, depth, visclass ); 683afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 684afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 685afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 686afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 687afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* try min_depth up to 8-bit */ 688afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (depth=min_depth;depth<8;depth++) { 689afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, screen, depth, visclass ); 690afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 691afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 692afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 693afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 694afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 695afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 696afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 697afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* search for a specific visual class */ 698afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (preferred_class) { 699afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRUE_COLOR_EXT: visclass = TrueColor; break; 700afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_DIRECT_COLOR_EXT: visclass = DirectColor; break; 701afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_PSEUDO_COLOR_EXT: visclass = PseudoColor; break; 702afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STATIC_COLOR_EXT: visclass = StaticColor; break; 703afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_GRAY_SCALE_EXT: visclass = GrayScale; break; 704afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STATIC_GRAY_EXT: visclass = StaticGray; break; 705afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: return NULL; 706afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 707afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* try 8-bit up through 16-bit */ 708afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (depth=8;depth<=16;depth++) { 709afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, screen, depth, visclass ); 710afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 711afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 712afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 713afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 714afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* try min_depth up to 8-bit */ 715afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (depth=min_depth;depth<8;depth++) { 716afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = get_visual( dpy, screen, depth, visclass ); 717afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 718afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 719afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 720afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 721afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 722afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 723afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 724afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* didn't find a visual */ 725afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 726afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 727afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 728afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 729afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 730afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 731afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Find the deepest X over/underlay visual of at least min_depth. 732afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Input: dpy, screen - X display and screen number 733afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * level - the over/underlay level 734afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * trans_type - transparent pixel type: GLX_NONE_EXT, 735afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * GLX_TRANSPARENT_RGB_EXT, GLX_TRANSPARENT_INDEX_EXT, 736afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * or DONT_CARE 737afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * trans_value - transparent pixel value or DONT_CARE 738afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * min_depth - minimum visual depth 739afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * preferred_class - preferred GLX visual class or DONT_CARE 740afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return: pointer to an XVisualInfo or NULL. 741afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 742afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic XVisualInfo *choose_x_overlay_visual( Display *dpy, int scr, 74342f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul GLboolean rgbFlag, 744afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int level, int trans_type, 745afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int trans_value, 746afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int min_depth, 747afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int preferred_class ) 748afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 749afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg Atom overlayVisualsAtom; 750afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg OverlayInfo *overlay_info; 751afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int numOverlaysPerScreen; 752afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg Status status; 753afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg Atom actualType; 754afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int actualFormat; 755afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg unsigned long sizeData, bytesLeft; 756afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int i; 757afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XVisualInfo *deepvis; 758afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int deepest; 759afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 760afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /*DEBUG int tt, tv; */ 761afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 762afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (preferred_class) { 763afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRUE_COLOR_EXT: preferred_class = TrueColor; break; 764afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_DIRECT_COLOR_EXT: preferred_class = DirectColor; break; 765afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_PSEUDO_COLOR_EXT: preferred_class = PseudoColor; break; 766afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STATIC_COLOR_EXT: preferred_class = StaticColor; break; 767afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_GRAY_SCALE_EXT: preferred_class = GrayScale; break; 768afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STATIC_GRAY_EXT: preferred_class = StaticGray; break; 769afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: preferred_class = DONT_CARE; 770afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 771afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 772afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* 773afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * The SERVER_OVERLAY_VISUALS property on the root window contains 774afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * a list of overlay visuals. Get that list now. 775afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 776afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg overlayVisualsAtom = XInternAtom(dpy,"SERVER_OVERLAY_VISUALS", True); 777afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (overlayVisualsAtom == (Atom) None) { 778afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 779afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 780afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 781afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg status = XGetWindowProperty(dpy, RootWindow( dpy, scr ), 782afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg overlayVisualsAtom, 0L, (long) 10000, False, 783afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg overlayVisualsAtom, &actualType, &actualFormat, 784afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg &sizeData, &bytesLeft, 785afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (unsigned char **) &overlay_info ); 786afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 787afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (status != Success || actualType != overlayVisualsAtom || 788afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg actualFormat != 32 || sizeData < 4) { 789afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* something went wrong */ 790afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 791afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 792afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 793afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Search for the deepest overlay which satisifies all criteria. */ 794afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg deepest = min_depth; 795afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg deepvis = NULL; 796afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 797afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg numOverlaysPerScreen = (int) (sizeData / 4); 798afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg for (i=0;i<numOverlaysPerScreen;i++) { 799afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XVisualInfo *vislist, vistemplate; 800afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int count; 801afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg OverlayInfo *ov; 802afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg ov = overlay_info + i; 803afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 804afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (ov->layer!=level) { 805afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* failed overlay level criteria */ 806afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg continue; 807afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 808afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!(trans_type==DONT_CARE 809afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg || (trans_type==GLX_TRANSPARENT_INDEX_EXT 810afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg && ov->transparent_type>0) 811afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg || (trans_type==GLX_NONE_EXT && ov->transparent_type==0))) { 812afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* failed transparent pixel type criteria */ 813afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg continue; 814afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 815afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (trans_value!=DONT_CARE && trans_value!=ov->value) { 816afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* failed transparent pixel value criteria */ 817afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg continue; 818afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 819afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 820afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* get XVisualInfo and check the depth */ 821afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vistemplate.visualid = ov->overlay_visual; 822afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vistemplate.screen = scr; 823afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vislist = XGetVisualInfo( dpy, VisualIDMask | VisualScreenMask, 824afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg &vistemplate, &count ); 825afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 826afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (count!=1) { 827afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* something went wrong */ 828afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg continue; 829afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 830afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (preferred_class!=DONT_CARE && preferred_class!=vislist->CLASS) { 831afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* wrong visual class */ 832afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg continue; 833afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 834afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 83542f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul /* if RGB was requested, make sure we have True/DirectColor */ 83642f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul if (rgbFlag && vislist->CLASS != TrueColor 83742f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul && vislist->CLASS != DirectColor) 83842f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul continue; 83942f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul 84042f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul /* if CI was requested, make sure we have a color indexed visual */ 84142f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul if (!rgbFlag 84242f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul && (vislist->CLASS == TrueColor || vislist->CLASS == DirectColor)) 84342f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul continue; 84442f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul 845afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (deepvis==NULL || vislist->depth > deepest) { 846afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* YES! found a satisfactory visual */ 847afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (deepvis) { 84880af3614d88c0cac160e787de7f34b37e96cb626Brian Paul XFree( deepvis ); 849afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 850afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg deepest = vislist->depth; 851afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg deepvis = vislist; 852afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* DEBUG tt = ov->transparent_type;*/ 853afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* DEBUG tv = ov->value; */ 854afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 855afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 856afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 857afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*DEBUG 858afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (deepvis) { 859afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg printf("chose 0x%x: layer=%d depth=%d trans_type=%d trans_value=%d\n", 860afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg deepvis->visualid, level, deepvis->depth, tt, tv ); 861afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 862afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg*/ 863afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return deepvis; 864afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 865afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 866afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 867afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 868426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic XVisualInfo * 869426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXChooseVisual( Display *dpy, int screen, int *list ) 870afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 871afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int *parselist; 872afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XVisualInfo *vis; 873afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int min_ci = 0; 874afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int min_red=0, min_green=0, min_blue=0; 875afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLboolean rgb_flag = GL_FALSE; 876afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLboolean alpha_flag = GL_FALSE; 877afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLboolean double_flag = GL_FALSE; 878afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLboolean stereo_flag = GL_FALSE; 879afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLint depth_size = 0; 880afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLint stencil_size = 0; 881b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint accumRedSize = 0; 882b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint accumGreenSize = 0; 883b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint accumBlueSize = 0; 884b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint accumAlphaSize = 0; 885afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int level = 0; 886afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int visual_type = DONT_CARE; 887afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int trans_type = DONT_CARE; 888afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int trans_value = DONT_CARE; 889e1210b176926349b258c7ec77b7f36716025c82aBrian Paul GLint caveat = DONT_CARE; 890afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 891afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist = list; 892afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 893afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg while (*parselist) { 894afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 895afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (*parselist) { 896afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_USE_GL: 897afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* ignore */ 898afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 899afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 900afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_BUFFER_SIZE: 901afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 902afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg min_ci = *parselist++; 903afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 904afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_LEVEL: 905afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 906afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg level = *parselist++; 907afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 908afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_RGBA: 909afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg rgb_flag = GL_TRUE; 910afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 911afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 912afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_DOUBLEBUFFER: 913afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg double_flag = GL_TRUE; 914afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 915afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 916afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STEREO: 917afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg stereo_flag = GL_TRUE; 918afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 919afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_AUX_BUFFERS: 920afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* ignore */ 921afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 922afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 923afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 924afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_RED_SIZE: 925afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 926afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg min_red = *parselist++; 927afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 928afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_GREEN_SIZE: 929afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 930afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg min_green = *parselist++; 931afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 932afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_BLUE_SIZE: 933afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 934afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg min_blue = *parselist++; 935afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 936afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ALPHA_SIZE: 937afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 938afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg { 939afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLint size = *parselist++; 940afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg alpha_flag = size>0 ? 1 : 0; 941afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 942afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 943afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_DEPTH_SIZE: 944afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 945afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg depth_size = *parselist++; 946afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 947afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STENCIL_SIZE: 948afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 949afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg stencil_size = *parselist++; 950afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 951afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_RED_SIZE: 952b2e460018375f699198073a6167e0ee96ba1d267Brian Paul parselist++; 953b2e460018375f699198073a6167e0ee96ba1d267Brian Paul { 954b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint size = *parselist++; 955b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumRedSize = MAX2( accumRedSize, size ); 956b2e460018375f699198073a6167e0ee96ba1d267Brian Paul } 957b2e460018375f699198073a6167e0ee96ba1d267Brian Paul break; 958afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_GREEN_SIZE: 959b2e460018375f699198073a6167e0ee96ba1d267Brian Paul parselist++; 960b2e460018375f699198073a6167e0ee96ba1d267Brian Paul { 961b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint size = *parselist++; 962b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumGreenSize = MAX2( accumGreenSize, size ); 963b2e460018375f699198073a6167e0ee96ba1d267Brian Paul } 964b2e460018375f699198073a6167e0ee96ba1d267Brian Paul break; 965afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_BLUE_SIZE: 966b2e460018375f699198073a6167e0ee96ba1d267Brian Paul parselist++; 967b2e460018375f699198073a6167e0ee96ba1d267Brian Paul { 968b2e460018375f699198073a6167e0ee96ba1d267Brian Paul GLint size = *parselist++; 969b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumBlueSize = MAX2( accumBlueSize, size ); 970b2e460018375f699198073a6167e0ee96ba1d267Brian Paul } 971b2e460018375f699198073a6167e0ee96ba1d267Brian Paul break; 972afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_ALPHA_SIZE: 973afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 974afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg { 975afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg GLint size = *parselist++; 976b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumAlphaSize = MAX2( accumAlphaSize, size ); 977afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 978afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 979afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 980afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* 981afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * GLX_EXT_visual_info extension 982afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 983afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_X_VISUAL_TYPE_EXT: 984afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 985afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg visual_type = *parselist++; 986afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 987afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_TYPE_EXT: 988afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 989afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg trans_type = *parselist++; 990afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 991afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_INDEX_VALUE_EXT: 992afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 993afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg trans_value = *parselist++; 994afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 995afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_RED_VALUE_EXT: 996afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_GREEN_VALUE_EXT: 997afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_BLUE_VALUE_EXT: 998afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_ALPHA_VALUE_EXT: 999afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* ignore */ 1000afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1001afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg parselist++; 1002afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 1003afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1004e1210b176926349b258c7ec77b7f36716025c82aBrian Paul /* 1005e1210b176926349b258c7ec77b7f36716025c82aBrian Paul * GLX_EXT_visual_info extension 1006e1210b176926349b258c7ec77b7f36716025c82aBrian Paul */ 1007e1210b176926349b258c7ec77b7f36716025c82aBrian Paul case GLX_VISUAL_CAVEAT_EXT: 1008e1210b176926349b258c7ec77b7f36716025c82aBrian Paul parselist++; 1009e1210b176926349b258c7ec77b7f36716025c82aBrian Paul caveat = *parselist++; /* ignored for now */ 1010e1210b176926349b258c7ec77b7f36716025c82aBrian Paul break; 1011e1210b176926349b258c7ec77b7f36716025c82aBrian Paul 1012afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case None: 1013afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg break; 1014afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: 1015afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* undefined attribute */ 1016afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 1017afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1018afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1019afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1020afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* 1021afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Since we're only simulating the GLX extension this function will never 1022afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * find any real GL visuals. Instead, all we can do is try to find an RGB 1023afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * or CI visual of appropriate depth. Other requested attributes such as 1024afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * double buffering, depth buffer, etc. will be associated with the X 1025afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * visual and stored in the VisualTable[]. 1026afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 1027afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (level==0) { 1028afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* normal color planes */ 1029afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (rgb_flag) { 1030afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Get an RGB visual */ 1031afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int min_rgb = min_red + min_green + min_blue; 1032afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (min_rgb>1 && min_rgb<8) { 1033afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* a special case to be sure we can get a monochrome visual */ 1034afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg min_rgb = 1; 1035afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1036afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = choose_x_visual( dpy, screen, rgb_flag, min_rgb, visual_type ); 1037afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1038afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 1039afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Get a color index visual */ 1040afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg vis = choose_x_visual( dpy, screen, rgb_flag, min_ci, visual_type ); 1041b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumRedSize = accumGreenSize = accumBlueSize = accumAlphaSize = 0; 1042afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1043afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1044afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 1045afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* over/underlay planes */ 104642f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul if (rgb_flag) { 104742f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul /* rgba overlay */ 104842f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul int min_rgb = min_red + min_green + min_blue; 104942f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul if (min_rgb>1 && min_rgb<8) { 105042f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul /* a special case to be sure we can get a monochrome visual */ 105142f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul min_rgb = 1; 105242f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul } 105342f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul vis = choose_x_overlay_visual( dpy, screen, rgb_flag, level, 105442f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul trans_type, trans_value, min_rgb, visual_type ); 105542f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul } 105642f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul else { 105742f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul /* color index overlay */ 105842f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul vis = choose_x_overlay_visual( dpy, screen, rgb_flag, level, 105942f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul trans_type, trans_value, min_ci, visual_type ); 106042f252fc06e6fd0bb8c95cb9d238c1416b5d50e7Brian Paul } 1061afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1062afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1063afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (vis) { 1064ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul /* Note: we're not exactly obeying the glXChooseVisual rules here. 1065ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * When GLX_DEPTH_SIZE = 1 is specified we're supposed to choose the 1066ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * largest depth buffer size, which is 32bits/value. However, we 1067ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul * return 16 to maintain performance with earlier versions of Mesa. 1068ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul */ 1069ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul if (depth_size == 1) 1070ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul depth_size = DEFAULT_SOFTWARE_DEPTH_BITS; 1071ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul else if (depth_size > 24) 1072ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul depth_size = 31; 1073ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul else if (depth_size > 16) 1074ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul depth_size = 24; 1075ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul /* we only support one size of stencil and accum buffers. */ 1076ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul if (stencil_size > 0) 1077ed30dfa1264ec8875a3162c3c8778bc703bf11d5Brian Paul stencil_size = STENCIL_BITS; 1078b2e460018375f699198073a6167e0ee96ba1d267Brian Paul if (accumRedSize > 0) 1079b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumRedSize = ACCUM_BITS; 1080b2e460018375f699198073a6167e0ee96ba1d267Brian Paul if (accumGreenSize > 0) 1081b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumGreenSize = ACCUM_BITS; 1082b2e460018375f699198073a6167e0ee96ba1d267Brian Paul if (accumBlueSize > 0) 1083b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumBlueSize = ACCUM_BITS; 1084b2e460018375f699198073a6167e0ee96ba1d267Brian Paul if (accumAlphaSize > 0) 1085b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumAlphaSize = ACCUM_BITS; 1086afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!save_glx_visual( dpy, vis, rgb_flag, alpha_flag, double_flag, 1087b2e460018375f699198073a6167e0ee96ba1d267Brian Paul stereo_flag, depth_size, stencil_size, 1088b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumRedSize, accumGreenSize, 1089b2e460018375f699198073a6167e0ee96ba1d267Brian Paul accumBlueSize, accumAlphaSize, 1090b2e460018375f699198073a6167e0ee96ba1d267Brian Paul level )) 1091afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 1092afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1093afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1094afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return vis; 1095afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1096afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1097afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1098afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1099afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1100426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXContext 1101426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateContext( Display *dpy, XVisualInfo *visinfo, 1102426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul GLXContext share_list, Bool direct ) 1103afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1104afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaVisual glxvis; 1105afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaContext xmctx; 1106afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1107afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* deallocate unused windows/buffers */ 1108afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaGarbageCollect(); 1109afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1110afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg glxvis = find_glx_visual( dpy, visinfo ); 1111afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!glxvis) { 1112afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* This visual wasn't found with glXChooseVisual() */ 1113afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg glxvis = create_glx_visual( dpy, visinfo ); 1114afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!glxvis) { 1115afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* unusable visual */ 1116afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 1117afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1118afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1119afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1120afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg xmctx = XMesaCreateContext( glxvis, (XMesaContext) share_list ); 1121afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (xmctx) { 1122afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* set the direct/indirect flag */ 1123afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg xmctx->direct = direct; 1124afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1125afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return (GLXContext) xmctx; 1126afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1127afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1128afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1129afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgstatic GLXContext MakeCurrent_PrevContext = 0; 1130086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic GLXDrawable MakeCurrent_PrevDrawable = 0; 1131086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic GLXDrawable MakeCurrent_PrevReadable = 0; 1132086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic XMesaBuffer MakeCurrent_PrevDrawBuffer = 0; 1133086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paulstatic XMesaBuffer MakeCurrent_PrevReadBuffer = 0; 1134afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1135086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul/* GLX 1.3 and later */ 1136426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool 1137426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXMakeContextCurrent( Display *dpy, GLXDrawable draw, 1138426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul GLXDrawable read, GLXContext ctx ) 1139086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul{ 1140086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul if (ctx && draw && read) { 1141086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul XMesaBuffer drawBuffer, readBuffer; 1142086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul XMesaContext xmctx = (XMesaContext) ctx; 1143086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul 1144086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* Find the XMesaBuffer which corresponds to the GLXDrawable 'draw' */ 1145086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul if (ctx == MakeCurrent_PrevContext 1146086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul && draw == MakeCurrent_PrevDrawable) { 1147086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul drawBuffer = MakeCurrent_PrevDrawBuffer; 1148086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1149086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul else { 1150086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul drawBuffer = XMesaFindBuffer( dpy, draw ); 1151086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1152086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul if (!drawBuffer) { 1153086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* drawable must be a new window! */ 1154086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul drawBuffer = XMesaCreateWindowBuffer2( xmctx->xm_visual, draw, ctx ); 1155086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul if (!drawBuffer) { 1156086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* Out of memory, or context/drawable depth mismatch */ 1157086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul return False; 1158086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1159086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1160086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul 1161086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* Find the XMesaBuffer which corresponds to the GLXDrawable 'read' */ 1162086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul if (ctx == MakeCurrent_PrevContext 1163086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul && read == MakeCurrent_PrevReadable) { 1164086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul readBuffer = MakeCurrent_PrevReadBuffer; 1165086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1166086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul else { 1167086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul readBuffer = XMesaFindBuffer( dpy, read ); 1168086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1169086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul if (!readBuffer) { 1170086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* drawable must be a new window! */ 1171086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul readBuffer = XMesaCreateWindowBuffer2( xmctx->xm_visual, read, ctx ); 1172086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul if (!readBuffer) { 1173086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* Out of memory, or context/drawable depth mismatch */ 1174086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul return False; 1175086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1176086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1177086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul 1178086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevContext = ctx; 1179086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevDrawable = draw; 1180086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevReadable = read; 1181086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevDrawBuffer = drawBuffer; 1182086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevReadBuffer = readBuffer; 1183086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul 1184086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* Now make current! */ 1185086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul return (Bool) XMesaMakeCurrent2((XMesaContext) ctx, drawBuffer, readBuffer); 1186086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1187086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul else if (!ctx && !draw && !read) { 1188086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* release current context w/out assigning new one. */ 1189086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul XMesaMakeCurrent( NULL, NULL ); 1190086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevContext = 0; 1191086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevDrawable = 0; 1192086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevReadable = 0; 1193086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevDrawBuffer = 0; 1194086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevReadBuffer = 0; 1195086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul return True; 1196086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1197086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul else { 1198086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul /* The args must either all be non-zero or all zero. 1199086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul * This is an error. 1200086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul */ 1201086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul return False; 1202086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul } 1203086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul} 1204086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul 1205086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul 1206426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1207426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool 1208426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXMakeCurrent( Display *dpy, GLXDrawable drawable, GLXContext ctx ) 1209426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 1210426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul return Fake_glXMakeContextCurrent( dpy, drawable, drawable, ctx ); 1211426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1212426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1213426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1214426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1215426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPixmap 1216426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateGLXPixmap( Display *dpy, XVisualInfo *visinfo, Pixmap pixmap ) 1217afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1218afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaVisual v; 1219afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaBuffer b; 1220afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1221afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg v = find_glx_visual( dpy, visinfo ); 1222afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!v) { 1223afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg v = create_glx_visual( dpy, visinfo ); 1224afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!v) { 1225afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* unusable visual */ 1226afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1227afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1228afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1229afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1230afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg b = XMesaCreatePixmapBuffer( v, pixmap, 0 ); 1231afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!b) { 1232afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1233afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1234afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return b->frontbuffer; 1235afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1236afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1237afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1238afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#ifdef GLX_MESA_pixmap_colormap 1239afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1240426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPixmap 1241426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visinfo, 1242426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul Pixmap pixmap, Colormap cmap ) 1243afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1244afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaVisual v; 1245afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaBuffer b; 1246afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1247afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg v = find_glx_visual( dpy, visinfo ); 1248afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!v) { 1249afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg v = create_glx_visual( dpy, visinfo ); 1250afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!v) { 1251afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* unusable visual */ 1252afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1253afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1254afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1255afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1256afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg b = XMesaCreatePixmapBuffer( v, pixmap, cmap ); 1257afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!b) { 1258afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1259afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1260afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return b->frontbuffer; 1261afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1262afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1263afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#endif 1264afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1265afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1266426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1267426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyGLXPixmap( Display *dpy, GLXPixmap pixmap ) 1268afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1269afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaBuffer b = XMesaFindBuffer(dpy, pixmap); 1270afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (b) { 1271afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaDestroyBuffer(b); 1272afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1273afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else if (getenv("MESA_DEBUG")) { 1274afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg fprintf( stderr, "Mesa: glXDestroyGLXPixmap: invalid pixmap\n"); 1275afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1276afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1277afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1278afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1279426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1280426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCopyContext( Display *dpy, GLXContext src, GLXContext dst, 12813994b77bab8c62a4c1a4dffdfba233ef46662b99Brian Paul unsigned long mask ) 1282afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1283afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaContext xm_src = (XMesaContext) src; 1284afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaContext xm_dst = (XMesaContext) dst; 1285afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 1286f3232bcaf1f875e6a7198e3b5ede3e286ceb04faBrian Paul gl_copy_context( xm_src->gl_ctx, xm_dst->gl_ctx, (GLuint) mask ); 1287afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1288afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1289afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1290afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1291426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool 1292426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryExtension( Display *dpy, int *errorb, int *event ) 1293afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1294afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Mesa's GLX isn't really an X extension but we try to act like one. */ 1295afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 1296afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) errorb; 1297afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) event; 1298afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return True; 1299afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1300afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1301afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1302e7b16b74bf5d13331b5a88bbbbb9096560297b63Brian Paulextern void _kw_ungrab_all( Display *dpy ); 1303afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgvoid _kw_ungrab_all( Display *dpy ) 1304afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1305afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XUngrabPointer( dpy, CurrentTime ); 1306afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XUngrabKeyboard( dpy, CurrentTime ); 1307afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1308afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1309afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1310426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1311426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyContext( Display *dpy, GLXContext ctx ) 1312afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1313afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 1314afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg MakeCurrent_PrevContext = 0; 1315afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg MakeCurrent_PrevDrawable = 0; 1316086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevReadable = 0; 1317086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevDrawBuffer = 0; 1318086a151f942b2bcd8b9fbc56255e45b8c89b705eBrian Paul MakeCurrent_PrevReadBuffer = 0; 1319afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaDestroyContext( (XMesaContext) ctx ); 1320afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaGarbageCollect(); 1321afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1322afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1323afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1324afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1325426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool 1326426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXIsDirect( Display *dpy, GLXContext ctx ) 1327afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1328afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 1329afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return ((XMesaContext) ctx)->direct; 1330afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1331afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1332afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1333afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1334426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1335426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXSwapBuffers( Display *dpy, GLXDrawable drawable ) 1336afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1337afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaBuffer buffer = XMesaFindBuffer( dpy, drawable ); 1338afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1339afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (buffer) { 1340afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaSwapBuffers(buffer); 1341afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1342afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else if (getenv("MESA_DEBUG")) { 1343afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg fprintf(stderr, "Mesa Warning: glXSwapBuffers: invalid drawable\n"); 1344afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1345afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1346afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1347afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1348426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1349426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCopySubBufferMESA( Display *dpy, GLXDrawable drawable, 1350426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul int x, int y, int width, int height ) 1351afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1352afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaBuffer buffer = XMesaFindBuffer( dpy, drawable ); 1353afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (buffer) { 1354afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaCopySubBuffer(buffer, x, y, width, height); 1355afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1356afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else if (getenv("MESA_DEBUG")) { 1357afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg fprintf(stderr, "Mesa Warning: glXCopySubBufferMESA: invalid drawable\n"); 1358afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1359afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1360afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1361afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1362afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1363426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool 1364426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryVersion( Display *dpy, int *maj, int *min ) 1365afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1366afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 1367afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* Return GLX version, not Mesa version */ 136878fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul assert(CLIENT_MAJOR_VERSION == SERVER_MAJOR_VERSION); 136978fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul *maj = CLIENT_MAJOR_VERSION; 137078fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul *min = MIN2( CLIENT_MINOR_VERSION, SERVER_MINOR_VERSION ); 1371afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return True; 1372afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1373afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1374afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1375afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1376afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 1377afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Query the GLX attributes of the given XVisualInfo. 1378afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 1379426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int 1380426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetConfig( Display *dpy, XVisualInfo *visinfo, 1381426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul int attrib, int *value ) 1382afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1383afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaVisual glxvis; 1384afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1385afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg glxvis = find_glx_visual( dpy, visinfo ); 1386afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!glxvis) { 1387afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* this visual wasn't obtained with glXChooseVisual */ 1388afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg glxvis = create_glx_visual( dpy, visinfo ); 1389afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (!glxvis) { 1390afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* this visual can't be used for GL rendering */ 1391afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (attrib==GLX_USE_GL) { 1392afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = (int) False; 1393afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1394afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1395afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 1396afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /*fprintf( stderr, "Mesa: Error in glXGetConfig: bad visual\n");*/ 1397afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return GLX_BAD_VISUAL; 1398afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1399afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1400afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1401afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1402afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch(attrib) { 1403afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_USE_GL: 1404afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = (int) True; 1405afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1406afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_BUFFER_SIZE: 1407afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = visinfo->depth; 1408afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1409afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_LEVEL: 1410afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = glxvis->level; 1411afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1412afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_RGBA: 1413afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (glxvis->gl_visual->RGBAflag) { 1414afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = True; 1415afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1416afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 1417afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = False; 1418afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1419afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1420afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_DOUBLEBUFFER: 1421afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = (int) glxvis->gl_visual->DBflag; 1422afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1423afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STEREO: 1424afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = (int) glxvis->gl_visual->StereoFlag; 1425afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1426afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_AUX_BUFFERS: 1427afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = (int) False; 1428afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1429afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_RED_SIZE: 1430afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = glxvis->gl_visual->RedBits; 1431afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1432afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_GREEN_SIZE: 1433afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = glxvis->gl_visual->GreenBits; 1434afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1435afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_BLUE_SIZE: 1436afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = glxvis->gl_visual->BlueBits; 1437afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1438afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ALPHA_SIZE: 1439afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = glxvis->gl_visual->AlphaBits; 1440afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1441afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_DEPTH_SIZE: 1442afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = glxvis->gl_visual->DepthBits; 1443afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1444afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_STENCIL_SIZE: 1445afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = glxvis->gl_visual->StencilBits; 1446afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1447afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_RED_SIZE: 1448b2e460018375f699198073a6167e0ee96ba1d267Brian Paul *value = glxvis->gl_visual->AccumRedBits; 1449b2e460018375f699198073a6167e0ee96ba1d267Brian Paul return 0; 1450afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_GREEN_SIZE: 1451b2e460018375f699198073a6167e0ee96ba1d267Brian Paul *value = glxvis->gl_visual->AccumGreenBits; 1452b2e460018375f699198073a6167e0ee96ba1d267Brian Paul return 0; 1453afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_BLUE_SIZE: 1454b2e460018375f699198073a6167e0ee96ba1d267Brian Paul *value = glxvis->gl_visual->AccumBlueBits; 1455afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1456afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_ACCUM_ALPHA_SIZE: 1457b2e460018375f699198073a6167e0ee96ba1d267Brian Paul *value = glxvis->gl_visual->AccumAlphaBits; 1458afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1459afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1460afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* 1461afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * GLX_EXT_visual_info extension 1462afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 1463afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_X_VISUAL_TYPE_EXT: 1464afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (glxvis->visinfo->CLASS) { 1465afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case StaticGray: *value = GLX_STATIC_GRAY_EXT; return 0; 1466afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GrayScale: *value = GLX_GRAY_SCALE_EXT; return 0; 1467afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case StaticColor: *value = GLX_STATIC_GRAY_EXT; return 0; 1468afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case PseudoColor: *value = GLX_PSEUDO_COLOR_EXT; return 0; 1469afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case TrueColor: *value = GLX_TRUE_COLOR_EXT; return 0; 1470afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case DirectColor: *value = GLX_DIRECT_COLOR_EXT; return 0; 1471afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1472afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1473afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_TYPE_EXT: 1474afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (glxvis->level==0) { 1475afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* normal planes */ 1476afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = GLX_NONE_EXT; 1477afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1478afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else if (glxvis->level>0) { 1479afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* overlay */ 1480afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (glxvis->gl_visual->RGBAflag) { 1481afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = GLX_TRANSPARENT_RGB_EXT; 1482afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1483afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else { 1484afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = GLX_TRANSPARENT_INDEX_EXT; 1485afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1486afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1487afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg else if (glxvis->level<0) { 1488afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* underlay */ 1489afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = GLX_NONE_EXT; 1490afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1491afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1492afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_INDEX_VALUE_EXT: 1493afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg { 1494afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg int pixel = transparent_pixel( glxvis ); 1495afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (pixel>=0) { 1496afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *value = pixel; 1497afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1498afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* else undefined */ 1499afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1500afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1501afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_RED_VALUE_EXT: 1502afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* undefined */ 1503afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1504afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_GREEN_VALUE_EXT: 1505afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* undefined */ 1506afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1507afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_BLUE_VALUE_EXT: 1508afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* undefined */ 1509afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1510afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_TRANSPARENT_ALPHA_VALUE_EXT: 1511afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* undefined */ 1512afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return 0; 1513afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1514afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /* 1515b2e460018375f699198073a6167e0ee96ba1d267Brian Paul * GLX_EXT_visual_info extension 1516b2e460018375f699198073a6167e0ee96ba1d267Brian Paul */ 1517b2e460018375f699198073a6167e0ee96ba1d267Brian Paul case GLX_VISUAL_CAVEAT_EXT: 1518fc68be6b111473a0bf8f991468f973bb9dd275f4Brian Paul /* test for zero, just in case */ 1519962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul if (glxvis->VisualCaveat > 0) 1520962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul *value = glxvis->VisualCaveat; 1521962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul else 1522962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul *value = GLX_NONE_EXT; 1523962f4269153ba954e137aab94ff4eaad4a7b02aeBrian Paul return 0; 1524b2e460018375f699198073a6167e0ee96ba1d267Brian Paul 1525b2e460018375f699198073a6167e0ee96ba1d267Brian Paul /* 1526afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Extensions 1527afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 1528afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: 1529afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return GLX_BAD_ATTRIBUTE; 1530afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1531afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1532afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1533afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1534afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1535426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1536426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXWaitGL( void ) 1537afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1538afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaContext xmesa = XMesaGetCurrentContext(); 1539afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaFlush( xmesa ); 1540afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1541afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1542afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1543afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1544426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1545426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXWaitX( void ) 1546afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1547afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaContext xmesa = XMesaGetCurrentContext(); 1548afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaFlush( xmesa ); 1549afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1550afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1551afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 155243c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul/* 155343c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul * Return the extensions string, which is 3Dfx-dependant. 155443c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul */ 155543c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paulstatic const char *get_extensions( void ) 155643c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul{ 155743c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul#ifdef FX 155843c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul const char *fx = getenv("MESA_GLX_FX"); 155943c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul if (fx && fx[0] != 'd') { 1560e1210b176926349b258c7ec77b7f36716025c82aBrian 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"; 156143c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul } 156243c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul#endif 1563e1210b176926349b258c7ec77b7f36716025c82aBrian 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"; 156443c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul} 1565afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1566afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1567afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1568afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* GLX 1.1 and later */ 1569426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic const char * 1570426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryExtensionsString( Display *dpy, int screen ) 1571afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1572afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 1573afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) screen; 157443c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul return get_extensions(); 1575afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1576afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1577afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1578afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1579afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* GLX 1.1 and later */ 1580426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic const char * 1581426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryServerString( Display *dpy, int screen, int name ) 1582afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 158378fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul static char version[1000]; 158478fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul sprintf(version, "%d.%d %s", SERVER_MAJOR_VERSION, SERVER_MINOR_VERSION, 158578fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul MESA_GLX_VERSION); 1586afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1587afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 1588afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) screen; 1589afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1590afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (name) { 1591afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_EXTENSIONS: 159243c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul return get_extensions(); 1593afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_VENDOR: 159478fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul return VENDOR; 1595afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_VERSION: 1596afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return version; 1597afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: 1598afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 1599afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1600afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1601afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1602afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1603afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1604afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* GLX 1.1 and later */ 1605426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic const char * 1606426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetClientString( Display *dpy, int name ) 1607afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 160878fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul static char version[1000]; 160978fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul sprintf(version, "%d.%d %s", CLIENT_MAJOR_VERSION, CLIENT_MINOR_VERSION, 161078fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul MESA_GLX_VERSION); 1611afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1612afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg (void) dpy; 1613afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1614afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg switch (name) { 1615afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_EXTENSIONS: 161643c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul return get_extensions(); 1617afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_VENDOR: 161878fc78e0f68a20ae90f3d4aaf361751a9185a0b9Brian Paul return VENDOR; 1619afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg case GLX_VERSION: 1620afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return version; 1621afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: 1622afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return NULL; 1623afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1624afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1625afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1626afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1627afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1628426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul/* 1629426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul * GLX 1.3 and later 1630426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul */ 1631426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 16325605798e56ca6e9f968623f33b58ee7ca90594afBrian Paulstatic GLXFBConfig * 1633426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXChooseFBConfig( Display *dpy, int screen, 1634426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul const int *attribList, int *nitems ) 1635426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 1636426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 1637426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) screen; 1638426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) attribList; 1639426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) nitems; 1640426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul return 0; 1641426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1642426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1643426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1644426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int 1645426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetFBConfigAttrib( Display *dpy, GLXFBConfig config, 1646426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul int attribute, int *value ) 1647426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 1648426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 1649426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) config; 1650426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) attribute; 1651426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) value; 1652426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul return 0; 1653426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1654426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1655426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 16565605798e56ca6e9f968623f33b58ee7ca90594afBrian Paulstatic GLXFBConfig * 16575605798e56ca6e9f968623f33b58ee7ca90594afBrian PaulFake_glXGetFBConfigs( Display *dpy, int screen, int *nelements ) 16585605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul{ 16595605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul (void) dpy; 16605605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul (void) screen; 16615605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul (void) nelements; 16625605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul return 0; 16635605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul} 16645605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul 16655605798e56ca6e9f968623f33b58ee7ca90594afBrian Paul 1666426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic XVisualInfo * 1667426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetVisualFromFBConfig( Display *dpy, GLXFBConfig config ) 1668426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 1669426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 1670426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) config; 1671426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul return 0; 1672426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1673426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1674426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1675426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXWindow 1676426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateWindow( Display *dpy, GLXFBConfig config, Window win, 1677426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul const int *attribList ) 1678426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 1679426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 1680426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) config; 1681426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) win; 1682426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) attribList; 1683426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul return 0; 1684426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1685426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1686426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1687426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1688426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyWindow( Display *dpy, GLXWindow window ) 1689426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 1690426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 1691426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) window; 1692426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul return; 1693426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1694426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1695426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1696426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPixmap 1697426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreatePixmap( Display *dpy, GLXFBConfig config, Pixmap pixmap, 1698426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul const int *attribList ) 1699426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 1700426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 1701426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) config; 1702426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) pixmap; 1703426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) attribList; 1704426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul return 0; 1705426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1706426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1707426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1708426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1709426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyPixmap( Display *dpy, GLXPixmap pixmap ) 1710426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 1711426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 1712426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) pixmap; 1713426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul return; 1714426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1715426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1716426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1717426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXPbuffer 1718426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreatePbuffer( Display *dpy, GLXFBConfig config, 1719426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul const int *attribList ) 1720426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 1721426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 1722426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) config; 1723426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) attribList; 1724426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul return 0; 1725426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1726426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1727426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1728426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1729426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXDestroyPbuffer( Display *dpy, GLXPbuffer pbuf ) 1730426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 1731426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 1732426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) pbuf; 1733426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1734426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1735426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1736426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1737426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryDrawable( Display *dpy, GLXDrawable draw, int attribute, 1738426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul unsigned int *value ) 1739426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 1740426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 1741426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) draw; 1742426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) attribute; 1743426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) value; 1744426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1745426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1746426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1747426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLXContext 1748426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXCreateNewContext( Display *dpy, GLXFBConfig config, 1749426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul int renderType, GLXContext shareList, Bool direct ) 1750426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 1751426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 1752426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) config; 1753426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) renderType; 1754426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) shareList; 1755426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) direct; 1756426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul return 0; 1757426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1758426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1759426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1760426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int 1761426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXQueryContext( Display *dpy, GLXContext ctx, int attribute, int *value ) 1762426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 1763426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 1764426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) ctx; 1765426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) attribute; 1766426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) value; 1767426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul return 0; 1768426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1769426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1770426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1771426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1772426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXSelectEvent( Display *dpy, GLXDrawable drawable, unsigned long mask ) 1773426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 1774426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 1775426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) drawable; 1776426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) mask; 1777426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1778426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1779426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1780426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic void 1781426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetSelectedEvent( Display *dpy, GLXDrawable drawable, 1782426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul unsigned long *mask ) 1783426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 1784426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) dpy; 1785426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) drawable; 1786426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) mask; 1787426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1788b82d993b03320818f88f792a9e713f7ed491bfcbBrian Paul 1789b82d993b03320818f88f792a9e713f7ed491bfcbBrian Paul 1790b82d993b03320818f88f792a9e713f7ed491bfcbBrian Paul 1791afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/* 1792afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Release the depth, stencil, accum buffers attached to a GLXDrawable 1793afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * (a window or pixmap) prior to destroying the GLXDrawable. 1794afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */ 1795426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic Bool 1796426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXReleaseBuffersMESA( Display *dpy, GLXDrawable d ) 1797afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 1798afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaBuffer b = XMesaFindBuffer(dpy, d); 1799afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg if (b) { 1800afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg XMesaDestroyBuffer(b); 1801afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return True; 1802afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg } 1803afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg return False; 1804afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 1805afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 1806afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 180743c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul/* 180843c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul * GLX_MESA_set_3dfx_mode 180943c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul */ 1810426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic GLboolean 1811426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXSet3DfxModeMESA( GLint mode ) 1812afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{ 181343c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul return XMesaSetFXmode( mode ); 1814afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 181589a42b7e736bd9b0ab090906cab0cd047a6ec12eBrian Paul 181689a42b7e736bd9b0ab090906cab0cd047a6ec12eBrian Paul 1817426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul/* 1818426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul * GLX_SGI_video_sync 1819426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul */ 1820426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1821426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul#ifdef GLX_SGI_video_sync 1822426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1823426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int 1824426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXGetVideoSyncSGI(unsigned int *count) 1825426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 1826426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul return 0; 1827426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1828426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1829426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1830426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstatic int 1831426cb9f58f194a1e30e0908e8fc971bdcae06960Brian PaulFake_glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count) 1832426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 1833426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul return 0; 1834426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1835426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1836426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul#endif 1837426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1838426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 183943c9c2cfae458cf0d7618af5f25d57c0a5ebae08Brian Paul 1840426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulextern void Fake_glXUseXFont( Font font, int first, int count, int listbase ); 1841426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1842426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1843e7b16b74bf5d13331b5a88bbbbb9096560297b63Brian Paulextern struct _glxapi_table *_mesa_GetGLXDispatchTable(void); 1844426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paulstruct _glxapi_table *_mesa_GetGLXDispatchTable(void) 1845426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul{ 1846426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul static struct _glxapi_table glx; 1847426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1848426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul /* be sure our dispatch table size <= libGL's table */ 1849426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul { 1850426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul int size = sizeof(struct _glxapi_table) / sizeof(void *); 1851426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul (void) size; 1852426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul assert(_glxapi_get_dispatch_table_size() >= size); 1853426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul } 1854426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1855426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul /* initialize the whole table to no-ops */ 1856426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul _glxapi_set_no_op_table(&glx); 1857426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1858426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul /* now initialize the table with the functions I implement */ 1859426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.ChooseVisual = Fake_glXChooseVisual; 1860426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CopyContext = Fake_glXCopyContext; 1861426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CreateContext = Fake_glXCreateContext; 1862426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CreateGLXPixmap = Fake_glXCreateGLXPixmap; 1863426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.DestroyContext = Fake_glXDestroyContext; 1864426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.DestroyGLXPixmap = Fake_glXDestroyGLXPixmap; 1865426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.GetConfig = Fake_glXGetConfig; 1866426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul /*glx.GetCurrentContext = Fake_glXGetCurrentContext;*/ 1867426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul /*glx.GetCurrentDrawable = Fake_glXGetCurrentDrawable;*/ 1868426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.IsDirect = Fake_glXIsDirect; 1869426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.MakeCurrent = Fake_glXMakeCurrent; 1870426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.QueryExtension = Fake_glXQueryExtension; 1871426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.QueryVersion = Fake_glXQueryVersion; 1872426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.SwapBuffers = Fake_glXSwapBuffers; 1873426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.UseXFont = Fake_glXUseXFont; 1874426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.WaitGL = Fake_glXWaitGL; 1875426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.WaitX = Fake_glXWaitX; 1876426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1877426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul#ifdef _GLXAPI_VERSION_1_1 1878426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.GetClientString = Fake_glXGetClientString; 1879426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.QueryExtensionsString = Fake_glXQueryExtensionsString; 1880426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.QueryServerString = Fake_glXQueryServerString; 1881426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul#endif 1882426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1883426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul#ifdef _GLXAPI_VERSION_1_2 1884426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul /*glx.GetCurrentDisplay = Fake_glXGetCurrentDisplay;*/ 1885426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul#endif 1886426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1887426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul#ifdef _GLXAPI_VERSION_1_3 1888426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.ChooseFBConfig = Fake_glXChooseFBConfig; 1889426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CreateNewContext = Fake_glXCreateNewContext; 1890426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CreatePbuffer = Fake_glXCreatePbuffer; 1891426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CreatePixmap = Fake_glXCreatePixmap; 1892426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CreateWindow = Fake_glXCreateWindow; 1893426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.DestroyPbuffer = Fake_glXDestroyPbuffer; 1894426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.DestroyPixmap = Fake_glXDestroyPixmap; 1895426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.DestroyWindow = Fake_glXDestroyWindow; 1896426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul /*glx.GetCurrentReadDrawable = Fake_glXGetCurrentReadDrawable;*/ 1897426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.GetFBConfigAttrib = Fake_glXGetFBConfigAttrib; 1898426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.GetSelectedEvent = Fake_glXGetSelectedEvent; 1899426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.GetVisualFromFBConfig = Fake_glXGetVisualFromFBConfig; 1900426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.MakeContextCurrent = Fake_glXMakeContextCurrent; 1901426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.QueryContext = Fake_glXQueryContext; 1902426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.QueryDrawable = Fake_glXQueryDrawable; 1903426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.SelectEvent = Fake_glXSelectEvent; 1904426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul#endif 1905426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1906426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul#ifdef _GLXAPI_SGI_video_sync 1907426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.GetVideoSyncSGI = Fake_glXGetVideoSyncSGI; 1908426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.WaitVideoSyncSGI = Fake_glXWaitVideoSyncSGI; 1909426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul#endif 1910426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1911426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul#ifdef _GLXAPI_MESA_copy_sub_buffer 1912426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CopySubBufferMESA = Fake_glXCopySubBufferMESA; 1913426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul#endif 1914426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1915426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul#ifdef _GLXAPI_MESA_release_buffers 1916426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.ReleaseBuffersMESA = Fake_glXReleaseBuffersMESA; 1917426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul#endif 1918426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1919426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul#ifdef _GLXAPI_MESA_pixmap_colormap 1920426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.CreateGLXPixmapMESA = Fake_glXCreateGLXPixmapMESA; 1921426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul#endif 1922426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1923426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul#ifdef _GLXAPI_MESA_set_3dfx_mode 1924426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul glx.Set3DfxModeMESA = Fake_glXSet3DfxModeMESA; 1925426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul#endif 1926426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul 1927426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul return &glx; 1928426cb9f58f194a1e30e0908e8fc971bdcae06960Brian Paul} 1929