[Xquartz-changes] [386] AppleSGLX/trunk

source_changes at macosforge.org source_changes at macosforge.org
Mon Dec 21 12:56:26 PST 2009


Revision: 386
          http://trac.macosforge.org/projects/xquartz/changeset/386
Author:   jeremyhu at freedesktop.org
Date:     2009-12-21 12:56:26 -0800 (Mon, 21 Dec 2009)
Log Message:
-----------
Whitespace fixes to match mesa master and some buildfixes

Modified Paths:
--------------
    AppleSGLX/trunk/Makefile
    AppleSGLX/trunk/apple_cgl.c
    AppleSGLX/trunk/apple_cgl.h
    AppleSGLX/trunk/apple_glx.c
    AppleSGLX/trunk/apple_glx.h
    AppleSGLX/trunk/apple_glx_context.c
    AppleSGLX/trunk/apple_glx_context.h
    AppleSGLX/trunk/apple_glx_drawable.c
    AppleSGLX/trunk/apple_glx_drawable.h
    AppleSGLX/trunk/apple_glx_pbuffer.c
    AppleSGLX/trunk/apple_glx_pixmap.c
    AppleSGLX/trunk/apple_glx_surface.c
    AppleSGLX/trunk/apple_visual.c
    AppleSGLX/trunk/apple_visual.h
    AppleSGLX/trunk/apple_xgl_api_read.c
    AppleSGLX/trunk/apple_xgl_api_read.h
    AppleSGLX/trunk/apple_xgl_api_stereo.c
    AppleSGLX/trunk/apple_xgl_api_stereo.h
    AppleSGLX/trunk/apple_xgl_api_viewport.c
    AppleSGLX/trunk/appledri.c
    AppleSGLX/trunk/appledri.h
    AppleSGLX/trunk/appledristr.h
    AppleSGLX/trunk/glcontextmodes.c
    AppleSGLX/trunk/glcontextmodes.h
    AppleSGLX/trunk/glx_empty.c
    AppleSGLX/trunk/glx_error.c
    AppleSGLX/trunk/glx_error.h
    AppleSGLX/trunk/glx_pbuffer.c
    AppleSGLX/trunk/glx_query.c
    AppleSGLX/trunk/glxclient.h
    AppleSGLX/trunk/glxcmds.c
    AppleSGLX/trunk/glxcurrent.c
    AppleSGLX/trunk/glxext.c
    AppleSGLX/trunk/glxextensions.c
    AppleSGLX/trunk/glxextensions.h
    AppleSGLX/trunk/glxhash.c
    AppleSGLX/trunk/glxhash.h
    AppleSGLX/trunk/glxreply.c
    AppleSGLX/trunk/include/GL/internal/glcore.h
    AppleSGLX/trunk/packrender.h
    AppleSGLX/trunk/packsingle.h
    AppleSGLX/trunk/pixel.c
    AppleSGLX/trunk/xfont.c

Modified: AppleSGLX/trunk/Makefile
===================================================================
--- AppleSGLX/trunk/Makefile	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/Makefile	2009-12-21 20:56:26 UTC (rev 386)
@@ -2,7 +2,7 @@
 X11_DIR = $(INSTALL_DIR)
 
 CC=gcc
-GL_CFLAGS=-Wall -ggdb3 -Os -DPTHREADS -D_REENTRANT -DPUBLIC="" $(RC_CFLAGS) $(CFLAGS)
+GL_CFLAGS=-Wall -ggdb3 -Os -DPTHREADS -D_REENTRANT $(RC_CFLAGS) $(CFLAGS)
 GL_LDFLAGS=-L$(INSTALL_DIR)/lib -L$(X11_DIR)/lib $(LDFLAGS) -Wl,-single_module
 
 TCLSH=tclsh8.5

Modified: AppleSGLX/trunk/apple_cgl.c
===================================================================
--- AppleSGLX/trunk/apple_cgl.c	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/apple_cgl.c	2009-12-21 20:56:26 UTC (rev 386)
@@ -45,78 +45,84 @@
 
 static bool initialized = false;
 
-static void *sym(void *h, const char *name) {
-    void *s;
+static void *
+sym(void *h, const char *name)
+{
+   void *s;
 
-    s = dlsym(h, name);
+   s = dlsym(h, name);
 
-    if(NULL == s) {
-	fprintf(stderr, "error: %s\n", dlerror());
-	abort();
-    }
+   if (NULL == s) {
+      fprintf(stderr, "error: %s\n", dlerror());
+      abort();
+   }
 
-    return s;
+   return s;
 }
 
-void apple_cgl_init(void) {
-    void *h;
-    GLint major = 0, minor = 0;
-    const char *opengl_framework_path;
-    
-    if(initialized)
-	return;
-    
-    opengl_framework_path = getenv("OPENGL_FRAMEWORK_PATH");
-    if(!opengl_framework_path) {
-        opengl_framework_path = OPENGL_FRAMEWORK_PATH;
-    }
+void
+apple_cgl_init(void)
+{
+   void *h;
+   GLint major = 0, minor = 0;
+   const char *opengl_framework_path;
 
-    (void)dlerror(); /*drain dlerror*/
-    h = dlopen(opengl_framework_path, RTLD_NOW);
+   if (initialized)
+      return;
 
-    if(NULL == h) {
-        fprintf(stderr, "error: unable to dlopen %s : %s\n", opengl_framework_path,
-                dlerror());
-        abort();
-    }
+   opengl_framework_path = getenv("OPENGL_FRAMEWORK_PATH");
+   if (!opengl_framework_path) {
+      opengl_framework_path = OPENGL_FRAMEWORK_PATH;
+   }
 
-    dl_handle = h;
+   (void) dlerror();            /*drain dlerror */
+   h = dlopen(opengl_framework_path, RTLD_NOW);
 
-    apple_cgl.get_version = sym(h, "CGLGetVersion");
+   if (NULL == h) {
+      fprintf(stderr, "error: unable to dlopen %s : %s\n",
+              opengl_framework_path, dlerror());
+      abort();
+   }
 
-    apple_cgl.get_version(&major, &minor);
+   dl_handle = h;
 
-    apple_glx_diagnostic("CGL major %d minor %d\n", major, minor);
+   apple_cgl.get_version = sym(h, "CGLGetVersion");
 
-    if(1 != major) {
-	fprintf(stderr, "WARNING: the CGL major version has changed!\n"
-		"libGL may be incompatible!\n");
-    }
+   apple_cgl.get_version(&major, &minor);
 
-    apple_cgl.choose_pixel_format = sym(h, "CGLChoosePixelFormat");
-    apple_cgl.destroy_pixel_format = sym(h, "CGLDestroyPixelFormat");
+   apple_glx_diagnostic("CGL major %d minor %d\n", major, minor);
 
-    apple_cgl.clear_drawable = sym(h, "CGLClearDrawable");
-    apple_cgl.flush_drawable = sym(h, "CGLFlushDrawable");
+   if (1 != major) {
+      fprintf(stderr, "WARNING: the CGL major version has changed!\n"
+              "libGL may be incompatible!\n");
+   }
 
-    apple_cgl.create_context = sym(h, "CGLCreateContext");
-    apple_cgl.destroy_context = sym(h, "CGLDestroyContext");
+   apple_cgl.choose_pixel_format = sym(h, "CGLChoosePixelFormat");
+   apple_cgl.destroy_pixel_format = sym(h, "CGLDestroyPixelFormat");
 
-    apple_cgl.set_current_context = sym(h, "CGLSetCurrentContext");
-    apple_cgl.get_current_context = sym(h, "CGLGetCurrentContext");
-    apple_cgl.error_string = sym(h, "CGLErrorString");
+   apple_cgl.clear_drawable = sym(h, "CGLClearDrawable");
+   apple_cgl.flush_drawable = sym(h, "CGLFlushDrawable");
 
-    apple_cgl.set_off_screen = sym(h, "CGLSetOffScreen");
-    
-    apple_cgl.copy_context = sym(h, "CGLCopyContext");
+   apple_cgl.create_context = sym(h, "CGLCreateContext");
+   apple_cgl.destroy_context = sym(h, "CGLDestroyContext");
 
-    apple_cgl.create_pbuffer = sym(h, "CGLCreatePBuffer");
-    apple_cgl.destroy_pbuffer = sym(h, "CGLDestroyPBuffer");
-    apple_cgl.set_pbuffer = sym(h, "CGLSetPBuffer");
+   apple_cgl.set_current_context = sym(h, "CGLSetCurrentContext");
+   apple_cgl.get_current_context = sym(h, "CGLGetCurrentContext");
+   apple_cgl.error_string = sym(h, "CGLErrorString");
 
-    initialized = true;
+   apple_cgl.set_off_screen = sym(h, "CGLSetOffScreen");
+
+   apple_cgl.copy_context = sym(h, "CGLCopyContext");
+
+   apple_cgl.create_pbuffer = sym(h, "CGLCreatePBuffer");
+   apple_cgl.destroy_pbuffer = sym(h, "CGLDestroyPBuffer");
+   apple_cgl.set_pbuffer = sym(h, "CGLSetPBuffer");
+
+   initialized = true;
 }
 
-void *apple_cgl_get_dl_handle(void) {
-    return dl_handle;
+void *
+apple_cgl_get_dl_handle(void)
+{
+   return dl_handle;
 }

Modified: AppleSGLX/trunk/apple_cgl.h
===================================================================
--- AppleSGLX/trunk/apple_cgl.h	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/apple_cgl.h	2009-12-21 20:56:26 UTC (rev 386)
@@ -38,45 +38,43 @@
 /* For GLint and GLsizei on Tiger */
 #include <OpenGL/gl.h>
 
-struct apple_cgl_api {
-    void (*get_version)(GLint *majorvers, GLint *minorvers);
-    
-    CGLError (*choose_pixel_format)(const CGLPixelFormatAttribute *attribs, 
-				    CGLPixelFormatObj *pix, GLint *npix);
-    CGLError (*destroy_pixel_format)(CGLPixelFormatObj pix);
+struct apple_cgl_api
+{
+   void (*get_version) (GLint * majorvers, GLint * minorvers);
 
-    CGLError (*clear_drawable)(CGLContextObj ctx);
-    CGLError (*flush_drawable)(CGLContextObj ctx);
+     CGLError(*choose_pixel_format) (const CGLPixelFormatAttribute * attribs,
+                                     CGLPixelFormatObj * pix, GLint * npix);
+     CGLError(*destroy_pixel_format) (CGLPixelFormatObj pix);
 
-    CGLError (*create_context)(CGLPixelFormatObj pix, CGLContextObj share, 
-			       CGLContextObj *ctx);
-    CGLError (*destroy_context)(CGLContextObj pix);
+     CGLError(*clear_drawable) (CGLContextObj ctx);
+     CGLError(*flush_drawable) (CGLContextObj ctx);
 
-    CGLError (*set_current_context)(CGLContextObj ctx);
-    CGLContextObj (*get_current_context)(void);
-    const char *(*error_string)(CGLError error);
-    
-    CGLError (*set_off_screen)(CGLContextObj ctx, 
-			       GLsizei width, GLsizei height, GLint rowbytes,
-			       void *baseaddr);
+     CGLError(*create_context) (CGLPixelFormatObj pix, CGLContextObj share,
+                                CGLContextObj * ctx);
+     CGLError(*destroy_context) (CGLContextObj pix);
 
-    CGLError (*copy_context)(CGLContextObj src, CGLContextObj dst,
-			     GLbitfield mask);
+     CGLError(*set_current_context) (CGLContextObj ctx);
+     CGLContextObj(*get_current_context) (void);
+   const char *(*error_string) (CGLError error);
 
-    CGLError (*create_pbuffer)(GLsizei width,
-			       GLsizei height,
-			       GLenum target,
-			       GLenum internalFormat,
-			       GLint max_level,
-			       CGLPBufferObj *pbuffer);
+     CGLError(*set_off_screen) (CGLContextObj ctx,
+                                GLsizei width, GLsizei height, GLint rowbytes,
+                                void *baseaddr);
 
-    CGLError (*destroy_pbuffer)(CGLPBufferObj pbuffer);
+     CGLError(*copy_context) (CGLContextObj src, CGLContextObj dst,
+                              GLbitfield mask);
 
-    CGLError (*set_pbuffer)(CGLContextObj ctx,
-			    CGLPBufferObj pbuffer,
-			    GLenum face,
-			    GLint level,
-			    GLint screen);
+     CGLError(*create_pbuffer) (GLsizei width,
+                                GLsizei height,
+                                GLenum target,
+                                GLenum internalFormat,
+                                GLint max_level, CGLPBufferObj * pbuffer);
+
+     CGLError(*destroy_pbuffer) (CGLPBufferObj pbuffer);
+
+     CGLError(*set_pbuffer) (CGLContextObj ctx,
+                             CGLPBufferObj pbuffer,
+                             GLenum face, GLint level, GLint screen);
 };
 
 extern struct apple_cgl_api apple_cgl;
@@ -86,4 +84,3 @@
 extern void *apple_cgl_get_dl_handle(void);
 
 #endif
-

Modified: AppleSGLX/trunk/apple_glx.c
===================================================================
--- AppleSGLX/trunk/apple_glx.c	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/apple_glx.c	2009-12-21 20:56:26 UTC (rev 386)
@@ -52,146 +52,163 @@
 
 static bool diagnostic = false;
 
-void apple_glx_diagnostic(const char *fmt, ...) {
-    va_list vl;
+void
+apple_glx_diagnostic(const char *fmt, ...)
+{
+   va_list vl;
 
-    if(diagnostic) {
-	fprintf(stderr, "DIAG: ");
+   if (diagnostic) {
+      fprintf(stderr, "DIAG: ");
 
-	va_start(vl, fmt);
-	vfprintf(stderr, fmt, vl);
-	va_end(vl);
-    }
+      va_start(vl, fmt);
+      vfprintf(stderr, fmt, vl);
+      va_end(vl);
+   }
 }
 
-int apple_get_dri_event_base(void) {
-    if(!initialized) {
-	fprintf(stderr, "error: dri_event_base called before apple_init_glx!\n");
-	abort();
-    }
-    return dri_event_base;
+int
+apple_get_dri_event_base(void)
+{
+   if (!initialized) {
+      fprintf(stderr,
+              "error: dri_event_base called before apple_init_glx!\n");
+      abort();
+   }
+   return dri_event_base;
 }
 
-static void surface_notify_handler(Display *dpy, unsigned int uid, int kind) {
-    
-    switch(kind) {
-    case AppleDRISurfaceNotifyDestroyed:
-	apple_glx_diagnostic("%s: surface destroyed %u\n", __func__, uid);
-	apple_glx_surface_destroy(uid);
-	break;
-	
-    case AppleDRISurfaceNotifyChanged: {
-	int updated;
-	
-	updated = apple_glx_context_surface_changed(uid, pthread_self());
+static void
+surface_notify_handler(Display * dpy, unsigned int uid, int kind)
+{
 
-	apple_glx_diagnostic("surface notify updated %d\n", updated);
-    }
-	break;
-	
-    default:
-	fprintf(stderr, "unhandled kind of event: %d in %s\n", kind, __func__);
-    }
+   switch (kind) {
+   case AppleDRISurfaceNotifyDestroyed:
+      apple_glx_diagnostic("%s: surface destroyed %u\n", __func__, uid);
+      apple_glx_surface_destroy(uid);
+      break;
+
+   case AppleDRISurfaceNotifyChanged:{
+         int updated;
+
+         updated = apple_glx_context_surface_changed(uid, pthread_self());
+
+         apple_glx_diagnostic("surface notify updated %d\n", updated);
+      }
+      break;
+
+   default:
+      fprintf(stderr, "unhandled kind of event: %d in %s\n", kind, __func__);
+   }
 }
 
-xp_client_id apple_glx_get_client_id(void) {
-    static xp_client_id id;
+xp_client_id
+apple_glx_get_client_id(void)
+{
+   static xp_client_id id;
 
-    if(0 == id) {
-	if((XP_Success != xp_init(XP_IN_BACKGROUND)) ||
-	   (Success != xp_get_client_id(&id))) {
-	    return 0;
-	}
-    }
+   if (0 == id) {
+      if ((XP_Success != xp_init(XP_IN_BACKGROUND)) ||
+          (Success != xp_get_client_id(&id))) {
+         return 0;
+      }
+   }
 
-    return id;
+   return id;
 }
 
 /* Return true if an error occured. */
-bool apple_init_glx(Display *dpy) {
-    int eventBase, errorBase;
-    int major, minor, patch;
+bool
+apple_init_glx(Display * dpy)
+{
+   int eventBase, errorBase;
+   int major, minor, patch;
 
-    if(!XAppleDRIQueryExtension(dpy, &eventBase, &errorBase))
-	return true;
-    
-    if(!XAppleDRIQueryVersion(dpy, &major, &minor, &patch))
-        return true;
-    
-    if(initialized)
-	return false;
+   if (!XAppleDRIQueryExtension(dpy, &eventBase, &errorBase))
+      return true;
 
-    if(getenv("LIBGL_DIAGNOSTIC")) {
-	printf("initializing libGL in %s\n", __func__);
-	diagnostic = true;
-    }
+   if (!XAppleDRIQueryVersion(dpy, &major, &minor, &patch))
+      return true;
 
-    apple_cgl_init();
-    apple_xgl_init_direct();
-    libgl_handle = dlopen(OPENGL_LIB_PATH, RTLD_LAZY);
-    (void)apple_glx_get_client_id();
+   if (initialized)
+      return false;
 
-    XAppleDRISetSurfaceNotifyHandler(surface_notify_handler);
+   if (getenv("LIBGL_DIAGNOSTIC")) {
+      printf("initializing libGL in %s\n", __func__);
+      diagnostic = true;
+   }
 
-    /* This should really be per display. */
-    dri_event_base = eventBase;
-    initialized = true;
+   apple_cgl_init();
+   apple_xgl_init_direct();
+   libgl_handle = dlopen(OPENGL_LIB_PATH, RTLD_LAZY);
+   (void) apple_glx_get_client_id();
 
-    return false;
+   XAppleDRISetSurfaceNotifyHandler(surface_notify_handler);
+
+   /* This should really be per display. */
+   dri_event_base = eventBase;
+   initialized = true;
+
+   return false;
 }
 
-void apple_glx_swap_buffers(void *ptr) {
-    struct apple_glx_context *ac = ptr;
+void
+apple_glx_swap_buffers(void *ptr)
+{
+   struct apple_glx_context *ac = ptr;
 
-    /* This may not be needed with CGLFlushDrawable: */
-    glFlush();
-    apple_cgl.flush_drawable(ac->context_obj);
+   /* This may not be needed with CGLFlushDrawable: */
+   glFlush();
+   apple_cgl.flush_drawable(ac->context_obj);
 }
 
-void *apple_glx_get_proc_address(const GLubyte *procname) {
-    size_t len;
-    void *h, *s;
-    char *pname = (char *)procname;
+void *
+apple_glx_get_proc_address(const GLubyte * procname)
+{
+   size_t len;
+   void *h, *s;
+   char *pname = (char *) procname;
 
-    assert(NULL != procname);
-    len = strlen(pname);
-   
-    if(len < 3) {
-	return NULL;
-    }
+   assert(NULL != procname);
+   len = strlen(pname);
 
-    if((pname != strstr(pname, "glX")) && 
-       (pname != strstr(pname, "gl"))) {
-	fprintf(stderr, "warning: get proc address request is not for a gl or glX function");
-	return NULL;
-    }
+   if (len < 3) {
+      return NULL;
+   }
 
-    /* Search using the default symbols first. */
-    (void)dlerror(); /*drain dlerror*/
-    h = dlopen(NULL, RTLD_NOW);
-    if(NULL == h) {
-	fprintf(stderr, "warning: get proc address: %s\n", dlerror());
-	return NULL;
-    }
-    
-    s = dlsym(h, pname);
+   if ((pname != strstr(pname, "glX")) && (pname != strstr(pname, "gl"))) {
+      fprintf(stderr,
+              "warning: get proc address request is not for a gl or glX function");
+      return NULL;
+   }
 
-    if(NULL == s) {
-	/* Try the libGL.dylib from the OpenGL.framework. */
-	s = dlsym(libgl_handle, pname);
-    }
-    
-    dlclose(h);
+   /* Search using the default symbols first. */
+   (void) dlerror();            /*drain dlerror */
+   h = dlopen(NULL, RTLD_NOW);
+   if (NULL == h) {
+      fprintf(stderr, "warning: get proc address: %s\n", dlerror());
+      return NULL;
+   }
 
-    return s;
+   s = dlsym(h, pname);
+
+   if (NULL == s) {
+      /* Try the libGL.dylib from the OpenGL.framework. */
+      s = dlsym(libgl_handle, pname);
+   }
+
+   dlclose(h);
+
+   return s;
 }
 
-void apple_glx_waitx(Display *dpy, void *ptr) {
-    struct apple_private_context *ac = ptr;
+void
+apple_glx_waitx(Display * dpy, void *ptr)
+{
+   struct apple_private_context *ac = ptr;
 
-    (void)ac;
+   (void) ac;
 
-    glFlush();
-    glFinish();
-    XSync(dpy, False);
+   glFlush();
+   glFinish();
+   XSync(dpy, False);
 }

Modified: AppleSGLX/trunk/apple_glx.h
===================================================================
--- AppleSGLX/trunk/apple_glx.h	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/apple_glx.h	2009-12-21 20:56:26 UTC (rev 386)
@@ -33,15 +33,16 @@
 #include <stdbool.h>
 #include <OpenGL/CGLTypes.h>
 #include <GL/gl.h>
+#include <GL/glxint.h>
 #include <X11/Xlib.h>
 #define XP_NO_X_HEADERS
 #include <Xplugin.h>
 
 void apple_glx_diagnostic(const char *fmt, ...);
 xp_client_id apple_glx_get_client_id(void);
-bool apple_init_glx(Display *dpy);
+bool apple_init_glx(Display * dpy);
 void apple_glx_swap_buffers(void *ptr);
-void *apple_glx_get_proc_address(const GLubyte *procname);
-void apple_glx_waitx(Display *dpy, void *ptr);
+void *apple_glx_get_proc_address(const GLubyte * procname);
+void apple_glx_waitx(Display * dpy, void *ptr);
 
 #endif

Modified: AppleSGLX/trunk/apple_glx_context.c
===================================================================
--- AppleSGLX/trunk/apple_glx_context.c	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/apple_glx_context.c	2009-12-21 20:56:26 UTC (rev 386)
@@ -63,45 +63,51 @@
 static struct apple_glx_context *context_list = NULL;
 
 /* This guards the context_list above. */
-static void lock_context_list(void) {
-    int err;
+static void
+lock_context_list(void)
+{
+   int err;
 
-    err = pthread_mutex_lock(&context_lock);
+   err = pthread_mutex_lock(&context_lock);
 
-    if(err) {
-	fprintf(stderr, "pthread_mutex_lock failure in %s: %d\n",
-		__func__, err);
-	abort();
-    }
+   if (err) {
+      fprintf(stderr, "pthread_mutex_lock failure in %s: %d\n",
+              __func__, err);
+      abort();
+   }
 }
 
-static void unlock_context_list(void) {
-    int err;
+static void
+unlock_context_list(void)
+{
+   int err;
 
-    err = pthread_mutex_unlock(&context_lock);
+   err = pthread_mutex_unlock(&context_lock);
 
-    if(err) {
-	fprintf(stderr, "pthread_mutex_unlock failure in %s: %d\n",
-		__func__, err);
-	abort();
-    }
+   if (err) {
+      fprintf(stderr, "pthread_mutex_unlock failure in %s: %d\n",
+              __func__, err);
+      abort();
+   }
 }
 
-static bool is_context_valid(struct apple_glx_context *ac) {
-    struct apple_glx_context *i;
+static bool
+is_context_valid(struct apple_glx_context *ac)
+{
+   struct apple_glx_context *i;
 
-    lock_context_list();
-    
-    for(i = context_list; i; i = i->next) {
-	if(ac == i) {
-	    unlock_context_list();
-	    return true;
-	}
-    }
-    
-    unlock_context_list();
-    
-    return false;
+   lock_context_list();
+
+   for (i = context_list; i; i = i->next) {
+      if (ac == i) {
+         unlock_context_list();
+         return true;
+      }
+   }
+
+   unlock_context_list();
+
+   return false;
 }
 
 /* This creates an apple_private_context struct.  
@@ -110,475 +116,497 @@
  *
  * This is also where the CGLContextObj is created, and the CGLPixelFormatObj.
  */
-bool apple_glx_create_context(void **ptr, Display *dpy, int screen, 
-			      const void *mode, void *sharedContext,
-			      int *errorptr, bool *x11errorptr) {
-    struct apple_glx_context *ac;
-    struct apple_glx_context *sharedac = sharedContext;
-    CGLError error;
+bool
+apple_glx_create_context(void **ptr, Display * dpy, int screen,
+                         const void *mode, void *sharedContext,
+                         int *errorptr, bool * x11errorptr)
+{
+   struct apple_glx_context *ac;
+   struct apple_glx_context *sharedac = sharedContext;
+   CGLError error;
 
-    *ptr = NULL;
+   *ptr = NULL;
 
-    ac = malloc(sizeof *ac);
+   ac = malloc(sizeof *ac);
 
-    if(NULL == ac) {
-	*errorptr = BadAlloc;
-	*x11errorptr = true;
-	return true;
-    }
+   if (NULL == ac) {
+      *errorptr = BadAlloc;
+      *x11errorptr = true;
+      return true;
+   }
 
-    if(sharedac && !is_context_valid(sharedac)) {
-	*errorptr = GLXBadContext;
-	*x11errorptr = false;
-	return true;
-    }
-    
-    ac->context_obj = NULL;
-    ac->pixel_format_obj = NULL;
-    ac->drawable = NULL;
-    ac->thread_id = pthread_self();
-    ac->screen = screen;
-    ac->double_buffered = false;
-    ac->uses_stereo = false;
-    ac->need_update = false;
-    ac->is_current = false;
-    ac->made_current = false;
-    ac->last_surface_window = None;
-    
-    apple_visual_create_pfobj(&ac->pixel_format_obj, mode, 
-			      &ac->double_buffered, &ac->uses_stereo,
-			      /*offscreen*/ false);
-    
-    error = apple_cgl.create_context(ac->pixel_format_obj, 
-				     sharedac ? sharedac->context_obj : NULL,
-				     &ac->context_obj);
+   if (sharedac && !is_context_valid(sharedac)) {
+      *errorptr = GLXBadContext;
+      *x11errorptr = false;
+      return true;
+   }
 
-    
-    if(error) {
-	(void)apple_cgl.destroy_pixel_format(ac->pixel_format_obj);		
+   ac->context_obj = NULL;
+   ac->pixel_format_obj = NULL;
+   ac->drawable = NULL;
+   ac->thread_id = pthread_self();
+   ac->screen = screen;
+   ac->double_buffered = false;
+   ac->uses_stereo = false;
+   ac->need_update = false;
+   ac->is_current = false;
+   ac->made_current = false;
+   ac->last_surface_window = None;
 
-	free(ac);
-	
-	if(kCGLBadMatch == error) {
-	    *errorptr = BadMatch;
-	    *x11errorptr = true;
-	} else {
-	    *errorptr = GLXBadContext;
-	    *x11errorptr = false;
-	}
+   apple_visual_create_pfobj(&ac->pixel_format_obj, mode,
+                             &ac->double_buffered, &ac->uses_stereo,
+                             /*offscreen */ false);
 
-	if(getenv("LIBGL_DIAGNOSTIC"))
-	    fprintf(stderr, "error: %s\n", apple_cgl.error_string(error));
-	
-	return true;
-    }
+   error = apple_cgl.create_context(ac->pixel_format_obj,
+                                    sharedac ? sharedac->context_obj : NULL,
+                                    &ac->context_obj);
 
-    /* The context creation succeeded, so we can link in the new context. */
-    lock_context_list();
 
-    if(context_list)
-	context_list->previous = ac;
+   if (error) {
+      (void) apple_cgl.destroy_pixel_format(ac->pixel_format_obj);
 
-    ac->previous = NULL;
-    ac->next = context_list;
-    context_list = ac;
+      free(ac);
 
-    *ptr = ac;
+      if (kCGLBadMatch == error) {
+         *errorptr = BadMatch;
+         *x11errorptr = true;
+      }
+      else {
+         *errorptr = GLXBadContext;
+         *x11errorptr = false;
+      }
 
-    apple_glx_diagnostic("%s: ac %p ac->context_obj %p\n",
-			 __func__, (void *)ac, (void *)ac->context_obj);
+      if (getenv("LIBGL_DIAGNOSTIC"))
+         fprintf(stderr, "error: %s\n", apple_cgl.error_string(error));
 
-    unlock_context_list();
+      return true;
+   }
 
-    return false;
+   /* The context creation succeeded, so we can link in the new context. */
+   lock_context_list();
+
+   if (context_list)
+      context_list->previous = ac;
+
+   ac->previous = NULL;
+   ac->next = context_list;
+   context_list = ac;
+
+   *ptr = ac;
+
+   apple_glx_diagnostic("%s: ac %p ac->context_obj %p\n",
+                        __func__, (void *) ac, (void *) ac->context_obj);
+
+   unlock_context_list();
+
+   return false;
 }
 
-void apple_glx_destroy_context(void **ptr, Display *dpy) {
-    struct apple_glx_context *ac = *ptr;
+void
+apple_glx_destroy_context(void **ptr, Display * dpy)
+{
+   struct apple_glx_context *ac = *ptr;
 
-    if(NULL == ac)
-	return;
+   if (NULL == ac)
+      return;
 
-    apple_glx_diagnostic("%s: ac %p ac->context_obj %p\n",
-			 __func__, (void *)ac, (void *)ac->context_obj);
+   apple_glx_diagnostic("%s: ac %p ac->context_obj %p\n",
+                        __func__, (void *) ac, (void *) ac->context_obj);
 
-    if(apple_cgl.get_current_context() == ac->context_obj) {
-	apple_glx_diagnostic("%s: context ac->context_obj %p "
-			     "is still current!\n", __func__,
-			     (void *)ac->context_obj);
-	if(apple_cgl.set_current_context(NULL)) {
-	    abort();
-	}
-    }
+   if (apple_cgl.get_current_context() == ac->context_obj) {
+      apple_glx_diagnostic("%s: context ac->context_obj %p "
+                           "is still current!\n", __func__,
+                           (void *) ac->context_obj);
+      if (apple_cgl.set_current_context(NULL)) {
+         abort();
+      }
+   }
 
-    /* Remove ac from the context_list as soon as possible. */
-    lock_context_list();
+   /* Remove ac from the context_list as soon as possible. */
+   lock_context_list();
 
-    if(ac->previous) {
-	ac->previous->next = ac->next;
-    } else {
-	context_list = ac->next;
-    }
+   if (ac->previous) {
+      ac->previous->next = ac->next;
+   }
+   else {
+      context_list = ac->next;
+   }
 
-    if (ac->next) {
-	ac->next->previous = ac->previous;
-    }
+   if (ac->next) {
+      ac->next->previous = ac->previous;
+   }
 
-    unlock_context_list();
+   unlock_context_list();
 
 
-    if(apple_cgl.clear_drawable(ac->context_obj)) {
-	fprintf(stderr, "error: while clearing drawable!\n");
-	abort();
-    }
-    
-    /*
-     * This potentially causes surface_notify_handler to be called in
-     * apple_glx.c... 
-     * We can NOT have a lock held at this point.  It would result in 
-     * an abort due to an attempted deadlock.  This is why we earlier
-     * removed the ac pointer from the double-linked list.
-     */
-    if(ac->drawable) {
-	ac->drawable->destroy(ac->drawable);
-    }
+   if (apple_cgl.clear_drawable(ac->context_obj)) {
+      fprintf(stderr, "error: while clearing drawable!\n");
+      abort();
+   }
 
-    if(apple_cgl.destroy_pixel_format(ac->pixel_format_obj)) {
-	fprintf(stderr, "error: destroying pixel format in %s\n", __func__);
-	abort();
-    }
+   /*
+    * This potentially causes surface_notify_handler to be called in
+    * apple_glx.c... 
+    * We can NOT have a lock held at this point.  It would result in 
+    * an abort due to an attempted deadlock.  This is why we earlier
+    * removed the ac pointer from the double-linked list.
+    */
+   if (ac->drawable) {
+      ac->drawable->destroy(ac->drawable);
+   }
 
-    if(apple_cgl.destroy_context(ac->context_obj)) {
-	fprintf(stderr, "error: destroying context_obj in %s\n", __func__);
-	abort();
-    }
-    
-    free(ac);
+   if (apple_cgl.destroy_pixel_format(ac->pixel_format_obj)) {
+      fprintf(stderr, "error: destroying pixel format in %s\n", __func__);
+      abort();
+   }
 
-    *ptr = NULL;
-    
-    apple_glx_garbage_collect_drawables(dpy);
+   if (apple_cgl.destroy_context(ac->context_obj)) {
+      fprintf(stderr, "error: destroying context_obj in %s\n", __func__);
+      abort();
+   }
+
+   free(ac);
+
+   *ptr = NULL;
+
+   apple_glx_garbage_collect_drawables(dpy);
 }
 
 
 /* Return true if an error occured. */
-bool apple_glx_make_current_context(Display *dpy, void *oldptr, void *ptr,
-				    GLXDrawable drawable) {
-    struct apple_glx_context *oldac = oldptr;
-    struct apple_glx_context *ac = ptr;
-    struct apple_glx_drawable *newagd = NULL;
-    CGLError cglerr;
-    bool same_drawable = false;
+bool
+apple_glx_make_current_context(Display * dpy, void *oldptr, void *ptr,
+                               GLXDrawable drawable)
+{
+   struct apple_glx_context *oldac = oldptr;
+   struct apple_glx_context *ac = ptr;
+   struct apple_glx_drawable *newagd = NULL;
+   CGLError cglerr;
+   bool same_drawable = false;
 
 #if 0
-    apple_glx_diagnostic("%s: oldac %p ac %p drawable 0x%lx\n",
-			 __func__, (void *)oldac, (void *)ac,
-			 drawable);
-    
-    apple_glx_diagnostic("%s: oldac->context_obj %p ac->context_obj %p\n",
-			__func__, 
-			(void *)(oldac ? oldac->context_obj : NULL),
-			(void *)(ac ? ac->context_obj : NULL));
+   apple_glx_diagnostic("%s: oldac %p ac %p drawable 0x%lx\n",
+                        __func__, (void *) oldac, (void *) ac, drawable);
+
+   apple_glx_diagnostic("%s: oldac->context_obj %p ac->context_obj %p\n",
+                        __func__,
+                        (void *) (oldac ? oldac->context_obj : NULL),
+                        (void *) (ac ? ac->context_obj : NULL));
 #endif
 
-    /* This a common path for GLUT and other apps, so special case it. */
-    if(ac && ac->drawable && ac->drawable->drawable == drawable) {
-	same_drawable = true;
-	
-	if(ac->is_current)
-	    return false;
-    }
-    
-    /* Reset the is_current state of the old context, if non-NULL. */
-    if(oldac && (ac != oldac))
-	oldac->is_current = false;
+   /* This a common path for GLUT and other apps, so special case it. */
+   if (ac && ac->drawable && ac->drawable->drawable == drawable) {
+      same_drawable = true;
 
-    if(NULL == ac) {
-	/*Clear the current context for this thread.*/
-	apple_cgl.set_current_context(NULL);
+      if (ac->is_current)
+         return false;
+   }
 
-	if(oldac) {
-	    oldac->is_current = false;
-	
-	    if(oldac->drawable) {
-		oldac->drawable->destroy(oldac->drawable);
-		oldac->drawable = NULL;
-	    }
+   /* Reset the is_current state of the old context, if non-NULL. */
+   if (oldac && (ac != oldac))
+      oldac->is_current = false;
 
-	    /* Invalidate this to prevent surface recreation. */
-	    oldac->last_surface_window = None;
-	}
-	
-	return false;
-    }
-    
-    if(None == drawable) {
-	bool error = false;
+   if (NULL == ac) {
+      /*Clear the current context for this thread. */
+      apple_cgl.set_current_context(NULL);
 
-	/* Clear the current drawable for this context_obj. */
+      if (oldac) {
+         oldac->is_current = false;
 
-	if(apple_cgl.set_current_context(ac->context_obj))
-	    error = true;
-	
-	if(apple_cgl.clear_drawable(ac->context_obj))
-	    error = true;
+         if (oldac->drawable) {
+            oldac->drawable->destroy(oldac->drawable);
+            oldac->drawable = NULL;
+         }
 
-	if(ac->drawable) {
-	    ac->drawable->destroy(ac->drawable);
-	    ac->drawable = NULL;
-	}
+         /* Invalidate this to prevent surface recreation. */
+         oldac->last_surface_window = None;
+      }
 
-	/* Invalidate this to prevent surface recreation. */
-	ac->last_surface_window = None;
-	
-	apple_glx_diagnostic("%s: drawable is None, error is: %d\n",
-			     __func__, error);
+      return false;
+   }
 
-	return error;
-    }
+   if (None == drawable) {
+      bool error = false;
 
-    /* This is an optimisation to avoid searching for the current drawable. */
-    if(ac->drawable && ac->drawable->drawable == drawable) {
-	newagd = ac->drawable;
-    } else {
-	/* Find the drawable if possible, and retain a reference to it. */
-	newagd = apple_glx_drawable_find(drawable, APPLE_GLX_DRAWABLE_REFERENCE);
-    }
-    
-    /*
-     * Try to destroy the old drawable, so long as the new one
-     * isn't the old. 
-     */
-    if(ac->drawable && !same_drawable) {
-	ac->drawable->destroy(ac->drawable);
-	ac->drawable = NULL;
-    }
-    
-    if(NULL == newagd) {
-	if(apple_glx_surface_create(dpy, ac->screen, drawable, &newagd))
-	    return true;
-    
-	/* The drawable is referenced once by apple_glx_surface_create. */
+      /* Clear the current drawable for this context_obj. */
 
-	/*
-	 * FIXME: We actually need 2 references to prevent premature surface 
-	 * destruction.  The problem is that the surface gets destroyed in 
-	 * the case of the context being reused for another window, and
-	 * we then lose the surface contents.  Wait for destruction of a
-	 * window to destroy a surface.
-	 *
-	 * Note: this may leave around surfaces we don't want around, if
-	 * say we are using X for raster drawing after OpenGL rendering, 
-	 * but it will be compatible with the old libGL's behavior.
-	 *
-	 * Someday the X11 and OpenGL rendering must be unified at some
-	 * layer.  I suspect we can do that via shared memory and 
-	 * multiple threads in the X server (1 for each context created
-	 * by a client).  This would also allow users to render from 
-	 * multiple clients to the same OpenGL surface.  In fact it could
-	 * all be OpenGL.
-	 *
-	 */
-	newagd->reference(newagd);
-	
-	/* Save the new drawable with the context structure. */
-	ac->drawable = newagd;
-    } else {
-	/* We are reusing an existing drawable structure. */
+      if (apple_cgl.set_current_context(ac->context_obj))
+         error = true;
 
-	if(same_drawable) {
-	    assert(ac->drawable == newagd);
-	    /* The drawable_find above retained a reference for us. */
-	} else {
-	    ac->drawable = newagd;
-	}
-    }
-    
-    /* 
-     * Avoid this costly path if this is the same drawable and the
-     * context is already current. 
-     */
+      if (apple_cgl.clear_drawable(ac->context_obj))
+         error = true;
 
-    if(same_drawable && ac->is_current) {
-	apple_glx_diagnostic("%s: same_drawable and ac->is_current\n");
-	return false;
-    }
+      if (ac->drawable) {
+         ac->drawable->destroy(ac->drawable);
+         ac->drawable = NULL;
+      }
 
-    cglerr = apple_cgl.set_current_context(ac->context_obj);
+      /* Invalidate this to prevent surface recreation. */
+      ac->last_surface_window = None;
 
-    if(kCGLNoError != cglerr) {
-	fprintf(stderr, "set current error: %s\n",
-		apple_cgl.error_string(cglerr));
-	return true;
-    }
+      apple_glx_diagnostic("%s: drawable is None, error is: %d\n",
+                           __func__, error);
 
-    ac->is_current = true;
+      return error;
+   }
 
-    assert(NULL != ac->context_obj);
-    assert(NULL != ac->drawable);
+   /* This is an optimisation to avoid searching for the current drawable. */
+   if (ac->drawable && ac->drawable->drawable == drawable) {
+      newagd = ac->drawable;
+   }
+   else {
+      /* Find the drawable if possible, and retain a reference to it. */
+      newagd =
+         apple_glx_drawable_find(drawable, APPLE_GLX_DRAWABLE_REFERENCE);
+   }
 
-    ac->thread_id = pthread_self();
-     
-    /* This will be set if the pending_destroy code indicates it should be: */
-    ac->last_surface_window = None;
+   /*
+    * Try to destroy the old drawable, so long as the new one
+    * isn't the old. 
+    */
+   if (ac->drawable && !same_drawable) {
+      ac->drawable->destroy(ac->drawable);
+      ac->drawable = NULL;
+   }
 
-    switch(ac->drawable->type) {
-    case APPLE_GLX_DRAWABLE_PBUFFER:
-    case APPLE_GLX_DRAWABLE_SURFACE:
-    case APPLE_GLX_DRAWABLE_PIXMAP:
-	if(ac->drawable->callbacks.make_current) {
-	    if(ac->drawable->callbacks.make_current(ac, ac->drawable))
-		return true;
-	}
-	break;
+   if (NULL == newagd) {
+      if (apple_glx_surface_create(dpy, ac->screen, drawable, &newagd))
+         return true;
 
-    default:
-	fprintf(stderr, "internal error: invalid drawable type: %d\n", 
-		ac->drawable->type);
-	abort();
-    }
-    
-    return false;
+      /* The drawable is referenced once by apple_glx_surface_create. */
+
+      /*
+       * FIXME: We actually need 2 references to prevent premature surface 
+       * destruction.  The problem is that the surface gets destroyed in 
+       * the case of the context being reused for another window, and
+       * we then lose the surface contents.  Wait for destruction of a
+       * window to destroy a surface.
+       *
+       * Note: this may leave around surfaces we don't want around, if
+       * say we are using X for raster drawing after OpenGL rendering, 
+       * but it will be compatible with the old libGL's behavior.
+       *
+       * Someday the X11 and OpenGL rendering must be unified at some
+       * layer.  I suspect we can do that via shared memory and 
+       * multiple threads in the X server (1 for each context created
+       * by a client).  This would also allow users to render from 
+       * multiple clients to the same OpenGL surface.  In fact it could
+       * all be OpenGL.
+       *
+       */
+      newagd->reference(newagd);
+
+      /* Save the new drawable with the context structure. */
+      ac->drawable = newagd;
+   }
+   else {
+      /* We are reusing an existing drawable structure. */
+
+      if (same_drawable) {
+         assert(ac->drawable == newagd);
+         /* The drawable_find above retained a reference for us. */
+      }
+      else {
+         ac->drawable = newagd;
+      }
+   }
+
+   /* 
+    * Avoid this costly path if this is the same drawable and the
+    * context is already current. 
+    */
+
+   if (same_drawable && ac->is_current) {
+      apple_glx_diagnostic("%s: same_drawable and ac->is_current\n");
+      return false;
+   }
+
+   cglerr = apple_cgl.set_current_context(ac->context_obj);
+
+   if (kCGLNoError != cglerr) {
+      fprintf(stderr, "set current error: %s\n",
+              apple_cgl.error_string(cglerr));
+      return true;
+   }
+
+   ac->is_current = true;
+
+   assert(NULL != ac->context_obj);
+   assert(NULL != ac->drawable);
+
+   ac->thread_id = pthread_self();
+
+   /* This will be set if the pending_destroy code indicates it should be: */
+   ac->last_surface_window = None;
+
+   switch (ac->drawable->type) {
+   case APPLE_GLX_DRAWABLE_PBUFFER:
+   case APPLE_GLX_DRAWABLE_SURFACE:
+   case APPLE_GLX_DRAWABLE_PIXMAP:
+      if (ac->drawable->callbacks.make_current) {
+         if (ac->drawable->callbacks.make_current(ac, ac->drawable))
+            return true;
+      }
+      break;
+
+   default:
+      fprintf(stderr, "internal error: invalid drawable type: %d\n",
+              ac->drawable->type);
+      abort();
+   }
+
+   return false;
 }
 
-bool apple_glx_is_current_drawable(Display *dpy, void *ptr, 
-				   GLXDrawable drawable) {
-    struct apple_glx_context *ac = ptr;
-    
-    if(ac->drawable && ac->drawable->drawable == drawable) {
-	return true;
-    } else if(NULL == ac->drawable && None != ac->last_surface_window) {
-	apple_glx_context_update(dpy, ac);
+bool
+apple_glx_is_current_drawable(Display * dpy, void *ptr, GLXDrawable drawable)
+{
+   struct apple_glx_context *ac = ptr;
 
-	return (ac->drawable && ac->drawable->drawable == drawable);
-    }
+   if (ac->drawable && ac->drawable->drawable == drawable) {
+      return true;
+   }
+   else if (NULL == ac->drawable && None != ac->last_surface_window) {
+      apple_glx_context_update(dpy, ac);
 
-    return false;
+      return (ac->drawable && ac->drawable->drawable == drawable);
+   }
+
+   return false;
 }
 
-bool apple_glx_copy_context(void *currentptr, void *srcptr, void *destptr, 
-			    unsigned long mask, int *errorptr,
-			    bool *x11errorptr) {
-    struct apple_glx_context *src, *dest;
-    CGLError err;
+bool
+apple_glx_copy_context(void *currentptr, void *srcptr, void *destptr,
+                       unsigned long mask, int *errorptr, bool * x11errorptr)
+{
+   struct apple_glx_context *src, *dest;
+   CGLError err;
 
-    src = srcptr;
-    dest = destptr;
+   src = srcptr;
+   dest = destptr;
 
-    if(src->screen != dest->screen) {
-	*errorptr = BadMatch;
-	*x11errorptr = true;
-	return true;
-    }
-    
-    if(dest == currentptr || dest->is_current) {
-	*errorptr = BadAccess;
-	*x11errorptr = true;
-	return true;
-    }
+   if (src->screen != dest->screen) {
+      *errorptr = BadMatch;
+      *x11errorptr = true;
+      return true;
+   }
 
-    /* 
-     * If srcptr is the current context then we should do an implicit glFlush.
-     */
-    if(currentptr == srcptr)
-	glFlush();
-    
-    err = apple_cgl.copy_context(src->context_obj, dest->context_obj, 
-				 (GLbitfield)mask);
-    
-    if(kCGLNoError != err) {
-	*errorptr = GLXBadContext;
-	*x11errorptr = false;
-	return true;
-    }
-    
-    return false;
+   if (dest == currentptr || dest->is_current) {
+      *errorptr = BadAccess;
+      *x11errorptr = true;
+      return true;
+   }
+
+   /* 
+    * If srcptr is the current context then we should do an implicit glFlush.
+    */
+   if (currentptr == srcptr)
+      glFlush();
+
+   err = apple_cgl.copy_context(src->context_obj, dest->context_obj,
+                                (GLbitfield) mask);
+
+   if (kCGLNoError != err) {
+      *errorptr = GLXBadContext;
+      *x11errorptr = false;
+      return true;
+   }
+
+   return false;
 }
 
 /* 
  * The value returned is the total number of contexts set to update. 
  * It's meant for debugging/introspection.
  */
-int apple_glx_context_surface_changed(unsigned int uid, pthread_t caller) {
-    struct apple_glx_context *ac;
-    int updated = 0;
+int
+apple_glx_context_surface_changed(unsigned int uid, pthread_t caller)
+{
+   struct apple_glx_context *ac;
+   int updated = 0;
 
-    lock_context_list();
+   lock_context_list();
 
-    for(ac = context_list; ac; ac = ac->next) {
-	if(ac->drawable && APPLE_GLX_DRAWABLE_SURFACE == ac->drawable->type
-	   && ac->drawable->types.surface.uid == uid) {
+   for (ac = context_list; ac; ac = ac->next) {
+      if (ac->drawable && APPLE_GLX_DRAWABLE_SURFACE == ac->drawable->type
+          && ac->drawable->types.surface.uid == uid) {
 
-	    if(caller == ac->thread_id) {
-		apple_glx_diagnostic("caller is the same thread for uid %u\n",
-				     uid);
+         if (caller == ac->thread_id) {
+            apple_glx_diagnostic("caller is the same thread for uid %u\n",
+                                 uid);
 
-		xp_update_gl_context(ac->context_obj);
-	    } else {
-		ac->need_update = true;
-		++updated;
-	    }
-	}
-    }
+            xp_update_gl_context(ac->context_obj);
+         }
+         else {
+            ac->need_update = true;
+            ++updated;
+         }
+      }
+   }
 
-    unlock_context_list();
+   unlock_context_list();
 
-    return updated;
-} 
+   return updated;
+}
 
-void apple_glx_context_update(Display *dpy, void *ptr) {
-    struct apple_glx_context *ac = ptr;
+void
+apple_glx_context_update(Display * dpy, void *ptr)
+{
+   struct apple_glx_context *ac = ptr;
 
-    if(NULL == ac->drawable && None != ac->last_surface_window) {
-	bool failed;
+   if (NULL == ac->drawable && None != ac->last_surface_window) {
+      bool failed;
 
-	/* Attempt to recreate the surface for a destroyed drawable. */
-	failed = apple_glx_make_current_context(dpy, ac, ac, ac->last_surface_window);
+      /* Attempt to recreate the surface for a destroyed drawable. */
+      failed =
+         apple_glx_make_current_context(dpy, ac, ac, ac->last_surface_window);
 
-	apple_glx_diagnostic("%s: surface recreation failed? %s\n", __func__,
-			     failed ? "YES" : "NO");
-    }
+      apple_glx_diagnostic("%s: surface recreation failed? %s\n", __func__,
+                           failed ? "YES" : "NO");
+   }
 
-    if(ac->need_update) {
-	xp_update_gl_context(ac->context_obj);
-	ac->need_update = false;
-	
-	apple_glx_diagnostic("%s: updating context %p\n", __func__, ptr);
-    }
+   if (ac->need_update) {
+      xp_update_gl_context(ac->context_obj);
+      ac->need_update = false;
 
-    if(ac->drawable && APPLE_GLX_DRAWABLE_SURFACE == ac->drawable->type
+      apple_glx_diagnostic("%s: updating context %p\n", __func__, ptr);
+   }
+
+   if (ac->drawable && APPLE_GLX_DRAWABLE_SURFACE == ac->drawable->type
        && ac->drawable->types.surface.pending_destroy) {
-	apple_glx_diagnostic("%s: clearing drawable %p\n", __func__, ptr);
-	apple_cgl.clear_drawable(ac->context_obj);
+      apple_glx_diagnostic("%s: clearing drawable %p\n", __func__, ptr);
+      apple_cgl.clear_drawable(ac->context_obj);
 
-	if(ac->drawable) {
-	    struct apple_glx_drawable *d;
+      if (ac->drawable) {
+         struct apple_glx_drawable *d;
 
-	    apple_glx_diagnostic("%s: attempting to destroy drawable %p\n", 
-				 __func__, ptr);
-	    apple_glx_diagnostic("%s: ac->drawable->drawable is 0x%lx\n",
-				 __func__, ac->drawable->drawable);
+         apple_glx_diagnostic("%s: attempting to destroy drawable %p\n",
+                              __func__, ptr);
+         apple_glx_diagnostic("%s: ac->drawable->drawable is 0x%lx\n",
+                              __func__, ac->drawable->drawable);
 
-	    d = ac->drawable;
+         d = ac->drawable;
 
-	    ac->last_surface_window = d->drawable;
+         ac->last_surface_window = d->drawable;
 
-	    ac->drawable = NULL;
+         ac->drawable = NULL;
 
-	    /* 
-	     * This will destroy the surface drawable if there are 
-	     * no references to it.  
-	     * It also subtracts 1 from the reference_count.
-	     * If there are references to it, then it's probably made
-	     * current in another context.
-	     */
-	    d->destroy(d);	    
- 	}
-    }
+         /* 
+          * This will destroy the surface drawable if there are 
+          * no references to it.  
+          * It also subtracts 1 from the reference_count.
+          * If there are references to it, then it's probably made
+          * current in another context.
+          */
+         d->destroy(d);
+      }
+   }
 }
 
-bool apple_glx_context_uses_stereo(void *ptr) {
-    struct apple_glx_context *ac = ptr;
+bool
+apple_glx_context_uses_stereo(void *ptr)
+{
+   struct apple_glx_context *ac = ptr;
 
-    return ac->uses_stereo;
+   return ac->uses_stereo;
 }

Modified: AppleSGLX/trunk/apple_glx_context.h
===================================================================
--- AppleSGLX/trunk/apple_glx_context.h	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/apple_glx_context.h	2009-12-21 20:56:26 UTC (rev 386)
@@ -40,43 +40,46 @@
 
 #include "apple_glx_drawable.h"
 
-struct apple_glx_context {
-    CGLContextObj context_obj;
-    CGLPixelFormatObj pixel_format_obj;
-    struct apple_glx_drawable *drawable;
-    pthread_t thread_id;
-    int screen;
-    bool double_buffered;
-    bool uses_stereo;
-    bool need_update;
-    bool is_current; /* True if the context is current in some thread. */
-    bool made_current; /* True if the context has ever been made current. */
+struct apple_glx_context
+{
+   CGLContextObj context_obj;
+   CGLPixelFormatObj pixel_format_obj;
+   struct apple_glx_drawable *drawable;
+   pthread_t thread_id;
+   int screen;
+   bool double_buffered;
+   bool uses_stereo;
+   bool need_update;
+   bool is_current;             /* True if the context is current in some thread. */
+   bool made_current;           /* True if the context has ever been made current. */
 
-    /*
-     * last_surface is set by the pending_destroy code handler for a drawable.
-     * Due to a CG difference, we have to recreate a surface if the window
-     * is unmapped and mapped again.
-     */
-    Window last_surface_window;
-    struct apple_glx_context *previous, *next;
+   /*
+    * last_surface is set by the pending_destroy code handler for a drawable.
+    * Due to a CG difference, we have to recreate a surface if the window
+    * is unmapped and mapped again.
+    */
+   Window last_surface_window;
+   struct apple_glx_context *previous, *next;
 };
 
-bool apple_glx_create_context(void **ptr, Display *dpy, int screen, 
-			      const void *mode, void *sharedContext,
-                              int *errorptr, bool *x11errorptr);
-void apple_glx_destroy_context(void **ptr, Display *dpy);
+bool apple_glx_create_context(void **ptr, Display * dpy, int screen,
+                              const void *mode, void *sharedContext,
+                              int *errorptr, bool * x11errorptr);
+void apple_glx_destroy_context(void **ptr, Display * dpy);
 
-bool apple_glx_make_current_context(Display *dpy, void *oldptr, void *ptr, GLXDrawable drawable);
-bool apple_glx_is_current_drawable(Display *dpy, void *ptr, GLXDrawable drawable);
+bool apple_glx_make_current_context(Display * dpy, void *oldptr, void *ptr,
+                                    GLXDrawable drawable);
+bool apple_glx_is_current_drawable(Display * dpy, void *ptr,
+                                   GLXDrawable drawable);
 
-bool apple_glx_copy_context(void *currentptr, void *srcptr, void *destptr, 
-			    unsigned long mask, int *errorptr, 
-			    bool *x11errorptr);
+bool apple_glx_copy_context(void *currentptr, void *srcptr, void *destptr,
+                            unsigned long mask, int *errorptr,
+                            bool * x11errorptr);
 
 int apple_glx_context_surface_changed(unsigned int uid, pthread_t caller);
 
-void apple_glx_context_update(Display *dpy, void *ptr);
+void apple_glx_context_update(Display * dpy, void *ptr);
 
 bool apple_glx_context_uses_stereo(void *ptr);
 
-#endif /*APPLE_GLX_CONTEXT_H*/
+#endif /*APPLE_GLX_CONTEXT_H */

Modified: AppleSGLX/trunk/apple_glx_drawable.c
===================================================================
--- AppleSGLX/trunk/apple_glx_drawable.c	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/apple_glx_drawable.c	2009-12-21 20:56:26 UTC (rev 386)
@@ -40,466 +40,503 @@
 static pthread_mutex_t drawables_lock = PTHREAD_MUTEX_INITIALIZER;
 static struct apple_glx_drawable *drawables_list = NULL;
 
-static void lock_drawables_list(void) {
-    int err;
-    
-    err = pthread_mutex_lock(&drawables_lock);
+static void
+lock_drawables_list(void)
+{
+   int err;
 
-    if(err) {
-	fprintf(stderr, "pthread_mutex_lock failure in %s: %d\n",
-		__func__, err);
-        abort();
-    }
+   err = pthread_mutex_lock(&drawables_lock);
+
+   if (err) {
+      fprintf(stderr, "pthread_mutex_lock failure in %s: %d\n",
+              __func__, err);
+      abort();
+   }
 }
 
-static void unlock_drawables_list(void) {
-    int err;
-    
-    err = pthread_mutex_unlock(&drawables_lock);
+static void
+unlock_drawables_list(void)
+{
+   int err;
 
-    if(err) {
-	fprintf(stderr, "pthread_mutex_unlock failure in %s: %d\n",
-		__func__, err);
-        abort();
-    }
+   err = pthread_mutex_unlock(&drawables_lock);
+
+   if (err) {
+      fprintf(stderr, "pthread_mutex_unlock failure in %s: %d\n",
+              __func__, err);
+      abort();
+   }
 }
 
-struct apple_glx_drawable *apple_glx_find_drawable(Display *dpy,
-						   GLXDrawable drawable) {
-    struct apple_glx_drawable *i, *agd = NULL;
+struct apple_glx_drawable *
+apple_glx_find_drawable(Display * dpy, GLXDrawable drawable)
+{
+   struct apple_glx_drawable *i, *agd = NULL;
 
-    lock_drawables_list();
+   lock_drawables_list();
 
-    for(i = drawables_list; i; i = i->next) {
-	if(i->drawable == drawable) {
-	    agd = i;
-	    break;
-	}
-    }
-    
-    unlock_drawables_list();
+   for (i = drawables_list; i; i = i->next) {
+      if (i->drawable == drawable) {
+         agd = i;
+         break;
+      }
+   }
 
-    return agd;
+   unlock_drawables_list();
+
+   return agd;
 }
 
-static void drawable_lock(struct apple_glx_drawable *agd) {
-    int err;
+static void
+drawable_lock(struct apple_glx_drawable *agd)
+{
+   int err;
 
-    err = pthread_mutex_lock(&agd->mutex);
+   err = pthread_mutex_lock(&agd->mutex);
 
-    if(err) {
-	fprintf(stderr, "pthread_mutex_lock error: %d\n", err);
-	abort();
-    }
+   if (err) {
+      fprintf(stderr, "pthread_mutex_lock error: %d\n", err);
+      abort();
+   }
 }
 
-static void drawable_unlock(struct apple_glx_drawable *d) {
-    int err;
+static void
+drawable_unlock(struct apple_glx_drawable *d)
+{
+   int err;
 
-    err = pthread_mutex_unlock(&d->mutex);
+   err = pthread_mutex_unlock(&d->mutex);
 
-    if(err) {
-	fprintf(stderr, "pthread_mutex_unlock error: %d\n", err);
-	abort();
-    }
+   if (err) {
+      fprintf(stderr, "pthread_mutex_unlock error: %d\n", err);
+      abort();
+   }
 }
 
 
-static void reference_drawable(struct apple_glx_drawable *d) {
-    d->lock(d);
-    d->reference_count++;
-    d->unlock(d);
+static void
+reference_drawable(struct apple_glx_drawable *d)
+{
+   d->lock(d);
+   d->reference_count++;
+   d->unlock(d);
 }
 
-static void release_drawable(struct apple_glx_drawable *d) {
-    d->lock(d);
-    d->reference_count--;
-    d->unlock(d);
+static void
+release_drawable(struct apple_glx_drawable *d)
+{
+   d->lock(d);
+   d->reference_count--;
+   d->unlock(d);
 }
 
 /* The drawables list must be locked prior to calling this. */
 /* Return true if the drawable was destroyed. */
-static bool destroy_drawable(struct apple_glx_drawable *d) {
-    
-    d->lock(d);
-    
-    if(d->reference_count > 0) {
-	d->unlock(d);
-	return false;
-    }
+static bool
+destroy_drawable(struct apple_glx_drawable *d)
+{
 
-    d->unlock(d);
-  
-    if(d->previous) {
-	d->previous->next = d->next;
-    } else {
-	/*
-	 * The item must be at the head of the list, if it
-	 * has no previous pointer. 
-	 */
-	drawables_list = d->next;
-    }
+   d->lock(d);
 
-    if(d->next)
-	d->next->previous = d->previous;
+   if (d->reference_count > 0) {
+      d->unlock(d);
+      return false;
+   }
 
-    unlock_drawables_list();
-    
-    if (d->callbacks.destroy) {
-	/*
-	 * Warning: this causes other routines to be called (potentially)
-	 * from surface_notify_handler.  It's probably best to not have
-	 * any locks at this point locked.
-	 */
-	d->callbacks.destroy(d->display, d);
-    }
-     
-    apple_glx_diagnostic("%s: freeing %p\n", __func__, (void *)d);
-   
-    free(d);
+   d->unlock(d);
 
-    /* So that the locks are balanced and the caller correctly unlocks. */
-    lock_drawables_list();
+   if (d->previous) {
+      d->previous->next = d->next;
+   }
+   else {
+      /*
+       * The item must be at the head of the list, if it
+       * has no previous pointer. 
+       */
+      drawables_list = d->next;
+   }
 
-    return true;
+   if (d->next)
+      d->next->previous = d->previous;
+
+   unlock_drawables_list();
+
+   if (d->callbacks.destroy) {
+      /*
+       * Warning: this causes other routines to be called (potentially)
+       * from surface_notify_handler.  It's probably best to not have
+       * any locks at this point locked.
+       */
+      d->callbacks.destroy(d->display, d);
+   }
+
+   apple_glx_diagnostic("%s: freeing %p\n", __func__, (void *) d);
+
+   free(d);
+
+   /* So that the locks are balanced and the caller correctly unlocks. */
+   lock_drawables_list();
+
+   return true;
 }
 
 /*
  * This is typically called when a context is destroyed or the current
  * drawable is made None.
  */
-static bool destroy_drawable_callback(struct apple_glx_drawable *d) {
-    bool result;
+static bool
+destroy_drawable_callback(struct apple_glx_drawable *d)
+{
+   bool result;
 
-    d->lock(d);
+   d->lock(d);
 
-    apple_glx_diagnostic("%s: %p ->reference_count before -- %d\n", __func__,
-			 (void *)d, d->reference_count);
+   apple_glx_diagnostic("%s: %p ->reference_count before -- %d\n", __func__,
+                        (void *) d, d->reference_count);
 
-    d->reference_count--;
+   d->reference_count--;
 
-    if(d->reference_count > 0) {
-	d->unlock(d);
-	return false;
-    }
+   if (d->reference_count > 0) {
+      d->unlock(d);
+      return false;
+   }
 
-    d->unlock(d);
+   d->unlock(d);
 
-    lock_drawables_list();
+   lock_drawables_list();
 
-    result = destroy_drawable(d);
+   result = destroy_drawable(d);
 
-    unlock_drawables_list();
+   unlock_drawables_list();
 
-    return result;
+   return result;
 }
 
-static bool is_pbuffer(struct apple_glx_drawable *d) {
-    return APPLE_GLX_DRAWABLE_PBUFFER == d->type;
+static bool
+is_pbuffer(struct apple_glx_drawable *d)
+{
+   return APPLE_GLX_DRAWABLE_PBUFFER == d->type;
 }
 
-static bool is_pixmap(struct apple_glx_drawable *d) {
-    return APPLE_GLX_DRAWABLE_PIXMAP == d->type;
+static bool
+is_pixmap(struct apple_glx_drawable *d)
+{
+   return APPLE_GLX_DRAWABLE_PIXMAP == d->type;
 }
 
-static void common_init(Display *dpy, GLXDrawable drawable, 
-			struct apple_glx_drawable *d) {
-    int err;
-    pthread_mutexattr_t attr;
-    
-    d->display = dpy;
-    d->reference_count = 0;
-    d->drawable = drawable;
-    d->type = -1;
+static void
+common_init(Display * dpy, GLXDrawable drawable, struct apple_glx_drawable *d)
+{
+   int err;
+   pthread_mutexattr_t attr;
 
-    err = pthread_mutexattr_init(&attr);
+   d->display = dpy;
+   d->reference_count = 0;
+   d->drawable = drawable;
+   d->type = -1;
 
-    if(err) {
-	fprintf(stderr, "pthread_mutexattr_init error: %d\n", err);
-	abort();
-    }
+   err = pthread_mutexattr_init(&attr);
 
-    /* 
-     * There are some patterns that require a recursive mutex,
-     * when working with locks that protect the apple_glx_drawable,
-     * and reference functions like ->reference, and ->release.
-     */
-    err = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
+   if (err) {
+      fprintf(stderr, "pthread_mutexattr_init error: %d\n", err);
+      abort();
+   }
 
-    if(err) {
-	fprintf(stderr, "error: setting pthread mutex type: %d\n", err);
-	abort();
-    }
+   /* 
+    * There are some patterns that require a recursive mutex,
+    * when working with locks that protect the apple_glx_drawable,
+    * and reference functions like ->reference, and ->release.
+    */
+   err = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
 
-    err = pthread_mutex_init(&d->mutex, &attr);
-    
-    if(err) {
-	fprintf(stderr, "pthread_mutex_init error: %d\n", err);
-	abort();
-    }
+   if (err) {
+      fprintf(stderr, "error: setting pthread mutex type: %d\n", err);
+      abort();
+   }
 
-    (void)pthread_mutexattr_destroy(&attr);
+   err = pthread_mutex_init(&d->mutex, &attr);
 
-    d->lock = drawable_lock;
-    d->unlock = drawable_unlock;
+   if (err) {
+      fprintf(stderr, "pthread_mutex_init error: %d\n", err);
+      abort();
+   }
 
-    d->reference = reference_drawable;
-    d->release = release_drawable;
-    
-    d->destroy = destroy_drawable_callback;
+   (void) pthread_mutexattr_destroy(&attr);
 
-    d->is_pbuffer = is_pbuffer;
-    d->is_pixmap = is_pixmap;
+   d->lock = drawable_lock;
+   d->unlock = drawable_unlock;
 
-    d->width = -1;
-    d->height = -1;
-    d->row_bytes = 0;
-    d->path[0] = '\0';
-    d->fd = -1;
-    d->buffer = NULL;
-    d->buffer_length = 0;
-    
-    d->previous = NULL;
-    d->next = NULL;
+   d->reference = reference_drawable;
+   d->release = release_drawable;
+
+   d->destroy = destroy_drawable_callback;
+
+   d->is_pbuffer = is_pbuffer;
+   d->is_pixmap = is_pixmap;
+
+   d->width = -1;
+   d->height = -1;
+   d->row_bytes = 0;
+   d->path[0] = '\0';
+   d->fd = -1;
+   d->buffer = NULL;
+   d->buffer_length = 0;
+
+   d->previous = NULL;
+   d->next = NULL;
 }
 
-static void link_tail(struct apple_glx_drawable *agd) {
-    lock_drawables_list();
-       
-    /* Link the new drawable into the global list. */
-    agd->next = drawables_list;
+static void
+link_tail(struct apple_glx_drawable *agd)
+{
+   lock_drawables_list();
 
-    if(drawables_list)
-	drawables_list->previous = agd;
+   /* Link the new drawable into the global list. */
+   agd->next = drawables_list;
 
-    drawables_list = agd;
+   if (drawables_list)
+      drawables_list->previous = agd;
 
-    unlock_drawables_list();
+   drawables_list = agd;
+
+   unlock_drawables_list();
 }
 
 /*WARNING: this returns a locked and referenced object. */
-bool apple_glx_drawable_create(Display *dpy,
-			       int screen,
-			       GLXDrawable drawable,
-			       struct apple_glx_drawable **agdResult,
-			       struct apple_glx_drawable_callbacks *callbacks) {
-    struct apple_glx_drawable *d;
-    
-    d = calloc(1, sizeof *d);
+bool
+apple_glx_drawable_create(Display * dpy,
+                          int screen,
+                          GLXDrawable drawable,
+                          struct apple_glx_drawable **agdResult,
+                          struct apple_glx_drawable_callbacks *callbacks)
+{
+   struct apple_glx_drawable *d;
 
-    if(NULL == d) {
-	perror("malloc");
-	return true;	
-    }
+   d = calloc(1, sizeof *d);
 
-    common_init(dpy, drawable, d);
-    d->type = callbacks->type;
-    d->callbacks = *callbacks;
-   
-    d->reference(d);
-    d->lock(d);
+   if (NULL == d) {
+      perror("malloc");
+      return true;
+   }
 
-    link_tail(d);
+   common_init(dpy, drawable, d);
+   d->type = callbacks->type;
+   d->callbacks = *callbacks;
 
-    apple_glx_diagnostic("%s: new drawable %p\n", __func__, (void *)d);
+   d->reference(d);
+   d->lock(d);
 
-    *agdResult = d;
-    
-    return false;
+   link_tail(d);
+
+   apple_glx_diagnostic("%s: new drawable %p\n", __func__, (void *) d);
+
+   *agdResult = d;
+
+   return false;
 }
 
 static int error_count = 0;
 
-static int error_handler(Display *dpy, XErrorEvent *err) {
-    if(err->error_code == BadWindow) {
-	++error_count;
-    }
+static int
+error_handler(Display * dpy, XErrorEvent * err)
+{
+   if (err->error_code == BadWindow) {
+      ++error_count;
+   }
 
-    return 0;
-} 
+   return 0;
+}
 
-void apple_glx_garbage_collect_drawables(Display *dpy) {
-    struct apple_glx_drawable *d, *dnext;
-    Window root;
-    int x, y;
-    unsigned int width, height, bd, depth;
-    int (*old_handler)(Display *, XErrorEvent *);
-    
+void
+apple_glx_garbage_collect_drawables(Display * dpy)
+{
+   struct apple_glx_drawable *d, *dnext;
+   Window root;
+   int x, y;
+   unsigned int width, height, bd, depth;
+   int (*old_handler) (Display *, XErrorEvent *);
 
-    if(NULL == drawables_list)
-	return;
 
-    old_handler = XSetErrorHandler(error_handler);
+   if (NULL == drawables_list)
+      return;
 
-    XSync(dpy, False);
+   old_handler = XSetErrorHandler(error_handler);
 
-    lock_drawables_list();
+   XSync(dpy, False);
 
-    for(d = drawables_list; d;) {
-	dnext = d->next;
+   lock_drawables_list();
 
-	d->lock(d);
+   for (d = drawables_list; d;) {
+      dnext = d->next;
 
-	if(d->reference_count > 0) {
-	    /* 
-	     * Skip this, because some context still retains a reference 
-	     * to the drawable.
-	     */
-	    d->unlock(d);
-	    d = dnext;
-	    continue;
-	}
+      d->lock(d);
 
-	d->unlock(d);
+      if (d->reference_count > 0) {
+         /* 
+          * Skip this, because some context still retains a reference 
+          * to the drawable.
+          */
+         d->unlock(d);
+         d = dnext;
+         continue;
+      }
 
-	error_count = 0;
+      d->unlock(d);
 
-	/* 
-	 * Mesa uses XGetWindowAttributes, but some of these things are 
-	 * most definitely not Windows, and that's against the rules.
-	 * XGetGeometry on the other hand is legal with a Pixmap and Window.
-	 */
-	XGetGeometry(dpy, d->drawable, &root, &x, &y, &width, &height, &bd,
-		     &depth);
-	
-	if(error_count > 0) {
-	    /*
-	     * Note: this may not actually destroy the drawable.
-	     * If another context retains a reference to the drawable
-	     * after the reference count test above. 
-	     */
-	    (void)destroy_drawable(d);
-	    error_count = 0;
-	}
+      error_count = 0;
 
-	d = dnext;
-    }
+      /* 
+       * Mesa uses XGetWindowAttributes, but some of these things are 
+       * most definitely not Windows, and that's against the rules.
+       * XGetGeometry on the other hand is legal with a Pixmap and Window.
+       */
+      XGetGeometry(dpy, d->drawable, &root, &x, &y, &width, &height, &bd,
+                   &depth);
 
-    XSetErrorHandler(old_handler);
+      if (error_count > 0) {
+         /*
+          * Note: this may not actually destroy the drawable.
+          * If another context retains a reference to the drawable
+          * after the reference count test above. 
+          */
+         (void) destroy_drawable(d);
+         error_count = 0;
+      }
 
-    unlock_drawables_list();
+      d = dnext;
+   }
+
+   XSetErrorHandler(old_handler);
+
+   unlock_drawables_list();
 }
 
-unsigned int apple_glx_get_drawable_count(void) {
-    unsigned int result = 0;
-    struct apple_glx_drawable *d;
+unsigned int
+apple_glx_get_drawable_count(void)
+{
+   unsigned int result = 0;
+   struct apple_glx_drawable *d;
 
-    lock_drawables_list();
+   lock_drawables_list();
 
-    for(d = drawables_list; d; d = d->next)
-	++result;
-    
-    unlock_drawables_list();
+   for (d = drawables_list; d; d = d->next)
+      ++result;
 
-    return result;
+   unlock_drawables_list();
+
+   return result;
 }
 
 struct apple_glx_drawable *
-apple_glx_drawable_find_by_type(GLXDrawable drawable, int type,
-				int flags) {
-    struct apple_glx_drawable *d;
-   
-    lock_drawables_list();
+apple_glx_drawable_find_by_type(GLXDrawable drawable, int type, int flags)
+{
+   struct apple_glx_drawable *d;
 
-    for(d = drawables_list; d; d = d->next) {
-	if(d->type == type && d->drawable == drawable) {
-	    if(flags & APPLE_GLX_DRAWABLE_REFERENCE)
-		d->reference(d);
-	    
-	    if(flags & APPLE_GLX_DRAWABLE_LOCK)
-		d->lock(d);
+   lock_drawables_list();
 
-	    unlock_drawables_list();
-	    
-	    return d;
-	}
-    }
+   for (d = drawables_list; d; d = d->next) {
+      if (d->type == type && d->drawable == drawable) {
+         if (flags & APPLE_GLX_DRAWABLE_REFERENCE)
+            d->reference(d);
 
-    unlock_drawables_list();
+         if (flags & APPLE_GLX_DRAWABLE_LOCK)
+            d->lock(d);
 
-    return NULL;
+         unlock_drawables_list();
+
+         return d;
+      }
+   }
+
+   unlock_drawables_list();
+
+   return NULL;
 }
 
 struct apple_glx_drawable *
-apple_glx_drawable_find(GLXDrawable drawable, int flags) {
-    struct apple_glx_drawable *d;
-    
-    lock_drawables_list();
-    
-    for(d = drawables_list; d; d = d->next) {
-	if(d->drawable == drawable) {
-	    if(flags & APPLE_GLX_DRAWABLE_REFERENCE)
-		d->reference(d);
-	    
-	    if(flags & APPLE_GLX_DRAWABLE_LOCK)
-		d->lock(d);
-	    
-	    unlock_drawables_list();
-	    
-	    return d;
-	}
-    }
+apple_glx_drawable_find(GLXDrawable drawable, int flags)
+{
+   struct apple_glx_drawable *d;
 
-    unlock_drawables_list();
+   lock_drawables_list();
 
-    return NULL;
+   for (d = drawables_list; d; d = d->next) {
+      if (d->drawable == drawable) {
+         if (flags & APPLE_GLX_DRAWABLE_REFERENCE)
+            d->reference(d);
+
+         if (flags & APPLE_GLX_DRAWABLE_LOCK)
+            d->lock(d);
+
+         unlock_drawables_list();
+
+         return d;
+      }
+   }
+
+   unlock_drawables_list();
+
+   return NULL;
 }
 
 /* Return true if the type is valid for the drawable. */
-bool apple_glx_drawable_destroy_by_type(Display *dpy, 
-					GLXDrawable drawable, int type) {
-    struct apple_glx_drawable *d;
+bool
+apple_glx_drawable_destroy_by_type(Display * dpy,
+                                   GLXDrawable drawable, int type)
+{
+   struct apple_glx_drawable *d;
 
-    lock_drawables_list();
-    
-    for(d = drawables_list; d; d = d->next) {
-	if(drawable == d->drawable && type == d->type) {
-	    /*
-	     * The user has requested that we destroy this resource.
-	     * However, there may be references in the contexts to it, so
-	     * release it, and call destroy_drawable which doesn't destroy
-	     * if the reference_count is > 0.
-	     */	      
-	    d->release(d);
+   lock_drawables_list();
 
-	    apple_glx_diagnostic("%s d->reference_count %d\n", 
-				 __func__, d->reference_count);
+   for (d = drawables_list; d; d = d->next) {
+      if (drawable == d->drawable && type == d->type) {
+         /*
+          * The user has requested that we destroy this resource.
+          * However, there may be references in the contexts to it, so
+          * release it, and call destroy_drawable which doesn't destroy
+          * if the reference_count is > 0.
+          */
+         d->release(d);
 
-	    destroy_drawable(d);
-	    unlock_drawables_list();
-	    return true;
-	}
-    }
+         apple_glx_diagnostic("%s d->reference_count %d\n",
+                              __func__, d->reference_count);
 
-    unlock_drawables_list();
+         destroy_drawable(d);
+         unlock_drawables_list();
+         return true;
+      }
+   }
 
-    return false;
+   unlock_drawables_list();
+
+   return false;
 }
 
 struct apple_glx_drawable *
-apple_glx_drawable_find_by_uid(unsigned int uid, int flags) {
-    struct apple_glx_drawable *d;
-    
-    lock_drawables_list();
+apple_glx_drawable_find_by_uid(unsigned int uid, int flags)
+{
+   struct apple_glx_drawable *d;
 
-    for(d = drawables_list; d; d = d->next) {
-	/* Only surfaces have a uid. */
-	if(APPLE_GLX_DRAWABLE_SURFACE == d->type) {
-	    if(d->types.surface.uid == uid) {
-		if(flags & APPLE_GLX_DRAWABLE_REFERENCE)
-		    d->reference(d);
+   lock_drawables_list();
 
-		if(flags & APPLE_GLX_DRAWABLE_LOCK)
-		    d->lock(d);
+   for (d = drawables_list; d; d = d->next) {
+      /* Only surfaces have a uid. */
+      if (APPLE_GLX_DRAWABLE_SURFACE == d->type) {
+         if (d->types.surface.uid == uid) {
+            if (flags & APPLE_GLX_DRAWABLE_REFERENCE)
+               d->reference(d);
 
-		unlock_drawables_list();
+            if (flags & APPLE_GLX_DRAWABLE_LOCK)
+               d->lock(d);
 
-		return d;
-	    }
-	}
-    }
+            unlock_drawables_list();
 
-    unlock_drawables_list();
+            return d;
+         }
+      }
+   }
 
-    return NULL;
+   unlock_drawables_list();
+
+   return NULL;
 }

Modified: AppleSGLX/trunk/apple_glx_drawable.h
===================================================================
--- AppleSGLX/trunk/apple_glx_drawable.h	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/apple_glx_drawable.h	2009-12-21 20:56:26 UTC (rev 386)
@@ -38,117 +38,124 @@
 #undef XP_NO_X_HEADERS
 #include "apple_glx_context.h"
 
-enum {
-    APPLE_GLX_DRAWABLE_SURFACE = 1,
-    APPLE_GLX_DRAWABLE_PBUFFER,
-    APPLE_GLX_DRAWABLE_PIXMAP
+enum
+{
+   APPLE_GLX_DRAWABLE_SURFACE = 1,
+   APPLE_GLX_DRAWABLE_PBUFFER,
+   APPLE_GLX_DRAWABLE_PIXMAP
 };
 
 /* The flag for the find routine. */
-enum {
-    APPLE_GLX_DRAWABLE_LOCK = 2,
-    APPLE_GLX_DRAWABLE_REFERENCE = 4
+enum
+{
+   APPLE_GLX_DRAWABLE_LOCK = 2,
+   APPLE_GLX_DRAWABLE_REFERENCE = 4
 };
 
 struct apple_glx_context;
 struct apple_glx_drawable;
 
-struct apple_glx_surface {
-    xp_surface_id surface_id;
-    unsigned int uid;
-    bool pending_destroy;
+struct apple_glx_surface
+{
+   xp_surface_id surface_id;
+   unsigned int uid;
+   bool pending_destroy;
 };
 
-struct apple_glx_pbuffer {
-    GLXPbuffer xid; /* our pixmap */
-    int width, height;
-    GLint fbconfigID;
-    CGLPBufferObj buffer_obj;
-    unsigned long event_mask;    
+struct apple_glx_pbuffer
+{
+   GLXPbuffer xid;              /* our pixmap */
+   int width, height;
+   GLint fbconfigID;
+   CGLPBufferObj buffer_obj;
+   unsigned long event_mask;
 };
 
-struct apple_glx_pixmap {
-    GLXPixmap xpixmap;
-    void *buffer;
-    int width, height, pitch, /*bytes per pixel*/ bpp;
-    size_t size;
-    char path[PATH_MAX];
-    int fd;
-    CGLPixelFormatObj pixel_format_obj;
-    CGLContextObj context_obj;
-    GLint fbconfigID;
+struct apple_glx_pixmap
+{
+   GLXPixmap xpixmap;
+   void *buffer;
+   int width, height, pitch, /*bytes per pixel */ bpp;
+   size_t size;
+   char path[PATH_MAX];
+   int fd;
+   CGLPixelFormatObj pixel_format_obj;
+   CGLContextObj context_obj;
+   GLint fbconfigID;
 };
 
-struct apple_glx_drawable_callbacks {
-    int type;
-    bool (*make_current)(struct apple_glx_context *ac,
-			 struct apple_glx_drawable *d);
-    void (*destroy)(Display *dpy, struct apple_glx_drawable *d);
+struct apple_glx_drawable_callbacks
+{
+   int type;
+     bool(*make_current) (struct apple_glx_context * ac,
+                          struct apple_glx_drawable * d);
+   void (*destroy) (Display * dpy, struct apple_glx_drawable * d);
 };
 
-struct apple_glx_drawable {
-    Display *display;
-    int reference_count;
-    GLXDrawable drawable;
-    int type; /* APPLE_GLX_DRAWABLE_* */
+struct apple_glx_drawable
+{
+   Display *display;
+   int reference_count;
+   GLXDrawable drawable;
+   int type;                    /* APPLE_GLX_DRAWABLE_* */
 
-    union {
-	struct apple_glx_pixmap pixmap;
-	struct apple_glx_pbuffer pbuffer;
-	struct apple_glx_surface surface;
-    } types;
-    
-    struct apple_glx_drawable_callbacks callbacks;
-    
-    /* 
-     * This mutex protects the reference count and any other drawable data.
-     * It's used to prevent an early release of a drawable.
-     */
-    pthread_mutex_t mutex;
-    void (*lock)(struct apple_glx_drawable *agd);
-    void (*unlock)(struct apple_glx_drawable *agd);
+   union
+   {
+      struct apple_glx_pixmap pixmap;
+      struct apple_glx_pbuffer pbuffer;
+      struct apple_glx_surface surface;
+   } types;
 
-    void (*reference)(struct apple_glx_drawable *agd);
-    void (*release)(struct apple_glx_drawable *agd);
-    
-    bool (*destroy)(struct apple_glx_drawable *agd);
+   struct apple_glx_drawable_callbacks callbacks;
 
-    bool (*is_pbuffer)(struct apple_glx_drawable *agd);
+   /* 
+    * This mutex protects the reference count and any other drawable data.
+    * It's used to prevent an early release of a drawable.
+    */
+   pthread_mutex_t mutex;
+   void (*lock) (struct apple_glx_drawable * agd);
+   void (*unlock) (struct apple_glx_drawable * agd);
 
-    bool (*is_pixmap)(struct apple_glx_drawable *agd);
+   void (*reference) (struct apple_glx_drawable * agd);
+   void (*release) (struct apple_glx_drawable * agd);
 
+     bool(*destroy) (struct apple_glx_drawable * agd);
+
+     bool(*is_pbuffer) (struct apple_glx_drawable * agd);
+
+     bool(*is_pixmap) (struct apple_glx_drawable * agd);
+
 /*BEGIN These are used for the mixed mode drawing... */
-    int width, height;
-    int row_bytes;
-    char path[PATH_MAX];
-    int fd; /* The file descriptor for this drawable's shared memory. */
-    void *buffer; /* The memory for the drawable.  Typically shared memory. */
-    size_t buffer_length;
-/*END*/
-
-    struct apple_glx_drawable *previous, *next;
+   int width, height;
+   int row_bytes;
+   char path[PATH_MAX];
+   int fd;                      /* The file descriptor for this drawable's shared memory. */
+   void *buffer;                /* The memory for the drawable.  Typically shared memory. */
+   size_t buffer_length;
+     /*END*/ struct apple_glx_drawable *previous, *next;
 };
 
 struct apple_glx_context;
 
 /* May return NULL if not found */
-struct apple_glx_drawable *apple_glx_find_drawable(Display *dpy, 
-						   GLXDrawable drawable);
+struct apple_glx_drawable *apple_glx_find_drawable(Display * dpy,
+                                                   GLXDrawable drawable);
 
 /* Returns true on error and locks the agd result with a reference. */
-bool apple_glx_drawable_create(Display *dpy,
-			       int screen,
-			       GLXDrawable drawable,
-			       struct apple_glx_drawable **agd,
-			       struct apple_glx_drawable_callbacks *callbacks);
+bool apple_glx_drawable_create(Display * dpy,
+                               int screen,
+                               GLXDrawable drawable,
+                               struct apple_glx_drawable **agd,
+                               struct apple_glx_drawable_callbacks
+                               *callbacks);
 
 /* Returns true on error */
-bool apple_glx_create_drawable(Display *dpy, 
-			       struct apple_glx_context *ac,
-			       GLXDrawable drawable,
-			       struct apple_glx_drawable **agd);
+bool apple_glx_create_drawable(Display * dpy,
+                               struct apple_glx_context *ac,
+                               GLXDrawable drawable,
+                               struct apple_glx_drawable **agd);
 
-void apple_glx_garbage_collect_drawables(Display *dpy);
+void apple_glx_garbage_collect_drawables(Display * dpy);
 
 /* 
  * This returns the total number of drawables. 
@@ -156,39 +163,40 @@
  */
 unsigned int apple_glx_get_drawable_count(void);
 
-struct apple_glx_drawable *apple_glx_drawable_find_by_type(GLXDrawable drawable,
-							   int type, int flags);
+struct apple_glx_drawable *apple_glx_drawable_find_by_type(GLXDrawable
+                                                           drawable, int type,
+                                                           int flags);
 
-struct apple_glx_drawable *
-apple_glx_drawable_find(GLXDrawable drawable, int flags);
+struct apple_glx_drawable *apple_glx_drawable_find(GLXDrawable drawable,
+                                                   int flags);
 
 
-bool apple_glx_drawable_destroy_by_type(Display *dpy, GLXDrawable drawable,
-					int type);
+bool apple_glx_drawable_destroy_by_type(Display * dpy, GLXDrawable drawable,
+                                        int type);
 
-struct apple_glx_drawable *
-apple_glx_drawable_find_by_uid(unsigned int uid, int flags);
+struct apple_glx_drawable *apple_glx_drawable_find_by_uid(unsigned int uid,
+                                                          int flags);
 
 /* Surfaces */
 
-bool apple_glx_surface_create(Display *dpy, int screen, GLXDrawable drawable,
-			      struct apple_glx_drawable **resultptr);
+bool apple_glx_surface_create(Display * dpy, int screen, GLXDrawable drawable,
+                              struct apple_glx_drawable **resultptr);
 
 void apple_glx_surface_destroy(unsigned int uid);
 
 /* Pbuffers */
 
 /* Returns true if an error occurred. */
-bool apple_glx_pbuffer_create(Display *dpy, GLXFBConfig config, 
-			      int width, int height, int *errorcode,
-			      GLXPbuffer *pbuf);
+bool apple_glx_pbuffer_create(Display * dpy, GLXFBConfig config,
+                              int width, int height, int *errorcode,
+                              GLXPbuffer * pbuf);
 
 /* Returns true if the pbuffer was invalid. */
-bool apple_glx_pbuffer_destroy(Display *dpy, GLXPbuffer pbuf);
+bool apple_glx_pbuffer_destroy(Display * dpy, GLXPbuffer pbuf);
 
 /* Returns true if the pbuffer was valid and the attribute. */
-bool apple_glx_pbuffer_query(GLXDrawable d, int attribute, 
-			      unsigned int *value);
+bool apple_glx_pbuffer_query(GLXDrawable d, int attribute,
+                             unsigned int *value);
 
 /* Returns true if the GLXDrawable is a valid GLXPbuffer, and the mask is set. */
 bool apple_glx_pbuffer_set_event_mask(GLXDrawable d, unsigned long mask);
@@ -201,14 +209,14 @@
 
 /* mode is a __GLcontextModes * */
 /* Returns true if an error occurred. */
-bool apple_glx_pixmap_create(Display *dpy, int screen, Pixmap pixmap,
-			     const void *mode);
+bool apple_glx_pixmap_create(Display * dpy, int screen, Pixmap pixmap,
+                             const void *mode);
 
 /* Returns true if an error occurred. */
-bool apple_glx_pixmap_destroy(Display *dpy, Pixmap pixmap);
+bool apple_glx_pixmap_destroy(Display * dpy, Pixmap pixmap);
 
 bool apple_glx_pixmap_query(GLXPixmap pixmap, int attribute,
-			    unsigned int *value);
+                            unsigned int *value);
 
 
 

Modified: AppleSGLX/trunk/apple_glx_pbuffer.c
===================================================================
--- AppleSGLX/trunk/apple_glx_pbuffer.c	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/apple_glx_pbuffer.c	2009-12-21 20:56:26 UTC (rev 386)
@@ -37,283 +37,294 @@
 #include "apple_cgl.h"
 
 static bool pbuffer_make_current(struct apple_glx_context *ac,
-			    struct apple_glx_drawable *d);
+                                 struct apple_glx_drawable *d);
 
-static void pbuffer_destroy(Display *dpy, struct apple_glx_drawable *d);
+static void pbuffer_destroy(Display * dpy, struct apple_glx_drawable *d);
 
 static struct apple_glx_drawable_callbacks callbacks = {
-    .type = APPLE_GLX_DRAWABLE_PBUFFER,
-    .make_current = pbuffer_make_current,
-    .destroy = pbuffer_destroy
+   .type = APPLE_GLX_DRAWABLE_PBUFFER,
+   .make_current = pbuffer_make_current,
+   .destroy = pbuffer_destroy
 };
 
 
 /* Return true if an error occurred. */
-bool pbuffer_make_current(struct apple_glx_context *ac,
-			  struct apple_glx_drawable *d) {
-    struct apple_glx_pbuffer *pbuf = &d->types.pbuffer;
-    CGLError cglerr;
+bool
+pbuffer_make_current(struct apple_glx_context *ac,
+                     struct apple_glx_drawable *d)
+{
+   struct apple_glx_pbuffer *pbuf = &d->types.pbuffer;
+   CGLError cglerr;
 
-    assert(APPLE_GLX_DRAWABLE_PBUFFER == d->type);
+   assert(APPLE_GLX_DRAWABLE_PBUFFER == d->type);
 
-    cglerr = apple_cgl.set_pbuffer(ac->context_obj, 
-				   pbuf->buffer_obj,
-				   0, 0, 0);
-    
-    if(kCGLNoError != cglerr) {
-	fprintf(stderr, "set_pbuffer: %s\n", apple_cgl.error_string(cglerr));
-	return true;
-    }
+   cglerr = apple_cgl.set_pbuffer(ac->context_obj, pbuf->buffer_obj, 0, 0, 0);
 
-    if(!ac->made_current) {
-	glViewport(0, 0, pbuf->width, pbuf->height);
-	glScissor(0, 0, pbuf->width, pbuf->height);
-	ac->made_current = true;
-    }
+   if (kCGLNoError != cglerr) {
+      fprintf(stderr, "set_pbuffer: %s\n", apple_cgl.error_string(cglerr));
+      return true;
+   }
 
-    apple_glx_diagnostic("made pbuffer drawable 0x%lx current\n",
-			 d->drawable);
-    
-    return false;
+   if (!ac->made_current) {
+      glViewport(0, 0, pbuf->width, pbuf->height);
+      glScissor(0, 0, pbuf->width, pbuf->height);
+      ac->made_current = true;
+   }
+
+   apple_glx_diagnostic("made pbuffer drawable 0x%lx current\n", d->drawable);
+
+   return false;
 }
 
-void pbuffer_destroy(Display *dpy, struct apple_glx_drawable *d) {
-    struct apple_glx_pbuffer *pbuf = &d->types.pbuffer;
+void
+pbuffer_destroy(Display * dpy, struct apple_glx_drawable *d)
+{
+   struct apple_glx_pbuffer *pbuf = &d->types.pbuffer;
 
-    assert(APPLE_GLX_DRAWABLE_PBUFFER == d->type);
+   assert(APPLE_GLX_DRAWABLE_PBUFFER == d->type);
 
-    apple_glx_diagnostic("destroying pbuffer for drawable 0x%lx\n",
-			 d->drawable);
+   apple_glx_diagnostic("destroying pbuffer for drawable 0x%lx\n",
+                        d->drawable);
 
-    apple_cgl.destroy_pbuffer(pbuf->buffer_obj);
-    XFreePixmap(dpy, pbuf->xid);
+   apple_cgl.destroy_pbuffer(pbuf->buffer_obj);
+   XFreePixmap(dpy, pbuf->xid);
 }
 
 /* Return true if an error occurred. */
-bool apple_glx_pbuffer_destroy(Display *dpy, GLXPbuffer pbuf) {
-    return !apple_glx_drawable_destroy_by_type(dpy, pbuf,
-					      APPLE_GLX_DRAWABLE_PBUFFER);
+bool
+apple_glx_pbuffer_destroy(Display * dpy, GLXPbuffer pbuf)
+{
+   return !apple_glx_drawable_destroy_by_type(dpy, pbuf,
+                                              APPLE_GLX_DRAWABLE_PBUFFER);
 }
 
 /* Return true if an error occurred. */
-bool apple_glx_pbuffer_create(Display *dpy, GLXFBConfig config, 
-			      int width, int height, int *errorcode,
-			      GLXPbuffer *result) {
-    struct apple_glx_drawable *d;
-    struct apple_glx_pbuffer *pbuf = NULL;
-    CGLError err;
-    Window root;
-    int screen;
-    Pixmap xid;
-    __GLcontextModes *modes = (__GLcontextModes *)config;
+bool
+apple_glx_pbuffer_create(Display * dpy, GLXFBConfig config,
+                         int width, int height, int *errorcode,
+                         GLXPbuffer * result)
+{
+   struct apple_glx_drawable *d;
+   struct apple_glx_pbuffer *pbuf = NULL;
+   CGLError err;
+   Window root;
+   int screen;
+   Pixmap xid;
+   __GLcontextModes *modes = (__GLcontextModes *) config;
 
-    root = DefaultRootWindow(dpy);
-    screen = DefaultScreen(dpy);
+   root = DefaultRootWindow(dpy);
+   screen = DefaultScreen(dpy);
 
-    /*
-     * This pixmap is only used for a persistent XID.
-     * The XC-MISC extension cleans up XIDs and reuses them transparently,
-     * so we need to retain a server-side reference.
-     */
-    xid = XCreatePixmap(dpy, root, (unsigned int)1,
-			      (unsigned int)1,
-			      DefaultDepth(dpy, screen));
+   /*
+    * This pixmap is only used for a persistent XID.
+    * The XC-MISC extension cleans up XIDs and reuses them transparently,
+    * so we need to retain a server-side reference.
+    */
+   xid = XCreatePixmap(dpy, root, (unsigned int) 1,
+                       (unsigned int) 1, DefaultDepth(dpy, screen));
 
-    if(None == xid) {
-	*errorcode = BadAlloc;
-	return true;
-    } 
+   if (None == xid) {
+      *errorcode = BadAlloc;
+      return true;
+   }
 
-    if(apple_glx_drawable_create(dpy, screen, xid, &d, &callbacks)) {
-	*errorcode = BadAlloc;
-	return true;
-    }
-    
-    /* The lock is held in d from create onward. */
-    pbuf = &d->types.pbuffer;
-    
-    pbuf->xid = xid;    
-    pbuf->width = width;
-    pbuf->height = height;
+   if (apple_glx_drawable_create(dpy, screen, xid, &d, &callbacks)) {
+      *errorcode = BadAlloc;
+      return true;
+   }
 
-    err = apple_cgl.create_pbuffer(width, height, GL_TEXTURE_RECTANGLE_EXT,
-				   (modes->alphaBits > 0) ? GL_RGBA : GL_RGB,
-				   0, &pbuf->buffer_obj);
+   /* The lock is held in d from create onward. */
+   pbuf = &d->types.pbuffer;
 
-    if(kCGLNoError != err) {
-	d->unlock(d);
-	d->destroy(d);
-	*errorcode = BadMatch;
-	return true;
-    }
+   pbuf->xid = xid;
+   pbuf->width = width;
+   pbuf->height = height;
 
-    pbuf->fbconfigID = modes->fbconfigID;
+   err = apple_cgl.create_pbuffer(width, height, GL_TEXTURE_RECTANGLE_EXT,
+                                  (modes->alphaBits > 0) ? GL_RGBA : GL_RGB,
+                                  0, &pbuf->buffer_obj);
 
-    pbuf->event_mask = 0;
+   if (kCGLNoError != err) {
+      d->unlock(d);
+      d->destroy(d);
+      *errorcode = BadMatch;
+      return true;
+   }
 
-    *result = pbuf->xid;
+   pbuf->fbconfigID = modes->fbconfigID;
 
-    d->unlock(d);
-        
-    return false;
+   pbuf->event_mask = 0;
+
+   *result = pbuf->xid;
+
+   d->unlock(d);
+
+   return false;
 }
 
 
 
 /* Return true if an error occurred. */
-static bool get_max_size(int *widthresult, int *heightresult) {
-    CGLContextObj oldcontext;
-    GLint ar[2];
-   
-    oldcontext = apple_cgl.get_current_context();
+static bool
+get_max_size(int *widthresult, int *heightresult)
+{
+   CGLContextObj oldcontext;
+   GLint ar[2];
 
-    if(!oldcontext) {
-	/* 
-	 * There is no current context, so we need to make one in order
-	 * to call glGetInteger.
-	 */
-	CGLPixelFormatObj pfobj;
-	CGLError err;
-	CGLPixelFormatAttribute attr[10];
-	int c = 0;
-	GLint vsref = 0;
-	CGLContextObj newcontext;
-       
-	attr[c++] = kCGLPFAColorSize;
-	attr[c++] = 32;
-	attr[c++] = 0;
+   oldcontext = apple_cgl.get_current_context();
 
-	err = apple_cgl.choose_pixel_format(attr, &pfobj, &vsref);
-	if(kCGLNoError != err) {
-	    if(getenv("LIBGL_DIAGNOSTIC")) {
-		printf("choose_pixel_format error in %s: %s\n", __func__,
-		       apple_cgl.error_string(err));
-	    }
+   if (!oldcontext) {
+      /* 
+       * There is no current context, so we need to make one in order
+       * to call glGetInteger.
+       */
+      CGLPixelFormatObj pfobj;
+      CGLError err;
+      CGLPixelFormatAttribute attr[10];
+      int c = 0;
+      GLint vsref = 0;
+      CGLContextObj newcontext;
 
-	    return true;
-	}
-	    
+      attr[c++] = kCGLPFAColorSize;
+      attr[c++] = 32;
+      attr[c++] = 0;
 
-	err = apple_cgl.create_context(pfobj, NULL, &newcontext);
+      err = apple_cgl.choose_pixel_format(attr, &pfobj, &vsref);
+      if (kCGLNoError != err) {
+         if (getenv("LIBGL_DIAGNOSTIC")) {
+            printf("choose_pixel_format error in %s: %s\n", __func__,
+                   apple_cgl.error_string(err));
+         }
 
-	if(kCGLNoError != err) {
-	    if(getenv("LIBGL_DIAGNOSTIC")) {
-		printf("create_context error in %s: %s\n", __func__,
-		       apple_cgl.error_string(err));
-	    }
+         return true;
+      }
 
-	    apple_cgl.destroy_pixel_format(pfobj);
-	   
-	    return true;
-	}
 
-	err = apple_cgl.set_current_context(newcontext);
+      err = apple_cgl.create_context(pfobj, NULL, &newcontext);
 
-	if (kCGLNoError != err) {
-	    printf("set_current_context error in %s: %s\n", __func__,
-		   apple_cgl.error_string(err));
-	    return true;
-	}
+      if (kCGLNoError != err) {
+         if (getenv("LIBGL_DIAGNOSTIC")) {
+            printf("create_context error in %s: %s\n", __func__,
+                   apple_cgl.error_string(err));
+         }
 
-	
-	glGetIntegerv(GL_MAX_VIEWPORT_DIMS, ar);
+         apple_cgl.destroy_pixel_format(pfobj);
 
-	apple_cgl.set_current_context(oldcontext);
-	apple_cgl.destroy_context(newcontext);
-	apple_cgl.destroy_pixel_format(pfobj);	
-    } else {
-	/* We have a valid context. */
+         return true;
+      }
 
-	glGetIntegerv(GL_MAX_VIEWPORT_DIMS, ar);
-    }
+      err = apple_cgl.set_current_context(newcontext);
 
-    *widthresult = ar[0];
-    *heightresult = ar[1];
-        
-    return false;
+      if (kCGLNoError != err) {
+         printf("set_current_context error in %s: %s\n", __func__,
+                apple_cgl.error_string(err));
+         return true;
+      }
+
+
+      glGetIntegerv(GL_MAX_VIEWPORT_DIMS, ar);
+
+      apple_cgl.set_current_context(oldcontext);
+      apple_cgl.destroy_context(newcontext);
+      apple_cgl.destroy_pixel_format(pfobj);
+   }
+   else {
+      /* We have a valid context. */
+
+      glGetIntegerv(GL_MAX_VIEWPORT_DIMS, ar);
+   }
+
+   *widthresult = ar[0];
+   *heightresult = ar[1];
+
+   return false;
 }
 
-bool apple_glx_pbuffer_query(GLXPbuffer p, int attr, unsigned int *value) {
-    bool result = false;
-    struct apple_glx_drawable *d;
-    struct apple_glx_pbuffer *pbuf;
+bool
+apple_glx_pbuffer_query(GLXPbuffer p, int attr, unsigned int *value)
+{
+   bool result = false;
+   struct apple_glx_drawable *d;
+   struct apple_glx_pbuffer *pbuf;
 
-    d = apple_glx_drawable_find_by_type(p, APPLE_GLX_DRAWABLE_PBUFFER,
-					APPLE_GLX_DRAWABLE_LOCK);
-    
-    if(d) {
-	pbuf = &d->types.pbuffer;
+   d = apple_glx_drawable_find_by_type(p, APPLE_GLX_DRAWABLE_PBUFFER,
+                                       APPLE_GLX_DRAWABLE_LOCK);
 
-	switch(attr) {
-	case GLX_WIDTH:
-	    *value = pbuf->width;
-	    result = true;
-	    break;
-	    
-	case GLX_HEIGHT:
-	    *value = pbuf->height;
-	    result = true;
-	    break;
+   if (d) {
+      pbuf = &d->types.pbuffer;
 
-	case GLX_PRESERVED_CONTENTS:
-	    *value = true;
-	    result = true;
-	    break;
-	    
-	case GLX_LARGEST_PBUFFER: {
-	    int width, height;
-	    if(get_max_size(&width, &height)) {
-		fprintf(stderr, "internal error: "
-			"unable to find the largest pbuffer!\n");
-	    } else {
-		*value = width;
-		result = true;
-	    }
-	}
-	    break;
+      switch (attr) {
+      case GLX_WIDTH:
+         *value = pbuf->width;
+         result = true;
+         break;
 
-	case GLX_FBCONFIG_ID:
-	    *value = pbuf->fbconfigID;
-	    result = true;
-	    break;
-	}
+      case GLX_HEIGHT:
+         *value = pbuf->height;
+         result = true;
+         break;
 
-	d->unlock(d);
-    }
+      case GLX_PRESERVED_CONTENTS:
+         *value = true;
+         result = true;
+         break;
 
-    return result;
+      case GLX_LARGEST_PBUFFER:{
+            int width, height;
+            if (get_max_size(&width, &height)) {
+               fprintf(stderr, "internal error: "
+                       "unable to find the largest pbuffer!\n");
+            }
+            else {
+               *value = width;
+               result = true;
+            }
+         }
+         break;
+
+      case GLX_FBCONFIG_ID:
+         *value = pbuf->fbconfigID;
+         result = true;
+         break;
+      }
+
+      d->unlock(d);
+   }
+
+   return result;
 }
 
-bool apple_glx_pbuffer_set_event_mask(GLXDrawable drawable,
-				      unsigned long mask) {
-    struct apple_glx_drawable *d;
-    bool result = false;
+bool
+apple_glx_pbuffer_set_event_mask(GLXDrawable drawable, unsigned long mask)
+{
+   struct apple_glx_drawable *d;
+   bool result = false;
 
-    d = apple_glx_drawable_find_by_type(drawable, APPLE_GLX_DRAWABLE_PBUFFER,
-					APPLE_GLX_DRAWABLE_LOCK);
+   d = apple_glx_drawable_find_by_type(drawable, APPLE_GLX_DRAWABLE_PBUFFER,
+                                       APPLE_GLX_DRAWABLE_LOCK);
 
-    if(d) {
-	d->types.pbuffer.event_mask = mask;
-	result = true;
-	d->unlock(d);
-    }
+   if (d) {
+      d->types.pbuffer.event_mask = mask;
+      result = true;
+      d->unlock(d);
+   }
 
-    return result;
+   return result;
 }
 
-bool apple_glx_pbuffer_get_event_mask(GLXDrawable drawable,
-				      unsigned long *mask) {
-    struct apple_glx_drawable *d;
-    bool result = false;
-    
-    d = apple_glx_drawable_find_by_type(drawable, APPLE_GLX_DRAWABLE_PBUFFER,
-					APPLE_GLX_DRAWABLE_LOCK);
-    if(d) {
-	*mask = d->types.pbuffer.event_mask;
-	result = true;
-	d->unlock(d);
-    }
+bool
+apple_glx_pbuffer_get_event_mask(GLXDrawable drawable, unsigned long *mask)
+{
+   struct apple_glx_drawable *d;
+   bool result = false;
 
-    return result;
+   d = apple_glx_drawable_find_by_type(drawable, APPLE_GLX_DRAWABLE_PBUFFER,
+                                       APPLE_GLX_DRAWABLE_LOCK);
+   if (d) {
+      *mask = d->types.pbuffer.event_mask;
+      result = true;
+      d->unlock(d);
+   }
+
+   return result;
 }
-

Modified: AppleSGLX/trunk/apple_glx_pixmap.c
===================================================================
--- AppleSGLX/trunk/apple_glx_pixmap.c	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/apple_glx_pixmap.c	2009-12-21 20:56:26 UTC (rev 386)
@@ -43,178 +43,188 @@
 #include "glcontextmodes.h"
 
 static bool pixmap_make_current(struct apple_glx_context *ac,
-				struct apple_glx_drawable *d);
+                                struct apple_glx_drawable *d);
 
-static void pixmap_destroy(Display *dpy, struct apple_glx_drawable *d);
+static void pixmap_destroy(Display * dpy, struct apple_glx_drawable *d);
 
 static struct apple_glx_drawable_callbacks callbacks = {
-    .type = APPLE_GLX_DRAWABLE_PIXMAP,
-    .make_current = pixmap_make_current,
-    .destroy = pixmap_destroy
+   .type = APPLE_GLX_DRAWABLE_PIXMAP,
+   .make_current = pixmap_make_current,
+   .destroy = pixmap_destroy
 };
 
-static bool pixmap_make_current(struct apple_glx_context *ac,
-				struct apple_glx_drawable *d) {
-    CGLError cglerr;
-    struct apple_glx_pixmap *p = &d->types.pixmap;
-    
-    assert(APPLE_GLX_DRAWABLE_PIXMAP == d->type);
+static bool
+pixmap_make_current(struct apple_glx_context *ac,
+                    struct apple_glx_drawable *d)
+{
+   CGLError cglerr;
+   struct apple_glx_pixmap *p = &d->types.pixmap;
 
-    cglerr = apple_cgl.set_current_context(p->context_obj);
-    
-    if(kCGLNoError != cglerr) {
-	fprintf(stderr, "set current context: %s\n",
-		apple_cgl.error_string(cglerr));
-	return true;
-    }
+   assert(APPLE_GLX_DRAWABLE_PIXMAP == d->type);
 
-    cglerr = apple_cgl.set_off_screen(p->context_obj, p->width, p->height,
-				      p->pitch, p->buffer);
-    
-    if(kCGLNoError != cglerr) {
-	fprintf(stderr, "set off screen: %s\n", apple_cgl.error_string(cglerr));
-	
-	return true;
-    }
-    
-    if(!ac->made_current) {
-	glViewport(0, 0, p->width, p->height);
-	glScissor(0, 0, p->width, p->height);
-	ac->made_current = true;
-    }
+   cglerr = apple_cgl.set_current_context(p->context_obj);
 
-    return false;
+   if (kCGLNoError != cglerr) {
+      fprintf(stderr, "set current context: %s\n",
+              apple_cgl.error_string(cglerr));
+      return true;
+   }
+
+   cglerr = apple_cgl.set_off_screen(p->context_obj, p->width, p->height,
+                                     p->pitch, p->buffer);
+
+   if (kCGLNoError != cglerr) {
+      fprintf(stderr, "set off screen: %s\n", apple_cgl.error_string(cglerr));
+
+      return true;
+   }
+
+   if (!ac->made_current) {
+      glViewport(0, 0, p->width, p->height);
+      glScissor(0, 0, p->width, p->height);
+      ac->made_current = true;
+   }
+
+   return false;
 }
 
-static void pixmap_destroy(Display *dpy, struct apple_glx_drawable *d) {
-    struct apple_glx_pixmap *p = &d->types.pixmap;
+static void
+pixmap_destroy(Display * dpy, struct apple_glx_drawable *d)
+{
+   struct apple_glx_pixmap *p = &d->types.pixmap;
 
-    if(p->pixel_format_obj)
-	(void)apple_cgl.destroy_pixel_format(p->pixel_format_obj);
+   if (p->pixel_format_obj)
+      (void) apple_cgl.destroy_pixel_format(p->pixel_format_obj);
 
-    if(p->context_obj)
-	(void)apple_cgl.destroy_context(p->context_obj);
-    
-    XAppleDRIDestroyPixmap(dpy, p->xpixmap);
-    
-    if(p->buffer) {
-	if(munmap(p->buffer, p->size))
-	    perror("munmap");
-	
-	if(-1 == close(p->fd))
-	    perror("close");
-	
-	if(shm_unlink(p->path))
-	    perror("shm_unlink");
-    }
+   if (p->context_obj)
+      (void) apple_cgl.destroy_context(p->context_obj);
 
-    apple_glx_diagnostic("destroyed pixmap buffer for: 0x%lx\n", d->drawable);
+   XAppleDRIDestroyPixmap(dpy, p->xpixmap);
+
+   if (p->buffer) {
+      if (munmap(p->buffer, p->size))
+         perror("munmap");
+
+      if (-1 == close(p->fd))
+         perror("close");
+
+      if (shm_unlink(p->path))
+         perror("shm_unlink");
+   }
+
+   apple_glx_diagnostic("destroyed pixmap buffer for: 0x%lx\n", d->drawable);
 }
 
 /* Return true if an error occurred. */
-bool apple_glx_pixmap_create(Display *dpy, int screen, Pixmap pixmap, 
-			     const void *mode) {
-    struct apple_glx_drawable *d;
-    struct apple_glx_pixmap *p;
-    bool double_buffered;
-    bool uses_stereo;
-    CGLError error;
-    const __GLcontextModes *cmodes = mode;
+bool
+apple_glx_pixmap_create(Display * dpy, int screen, Pixmap pixmap,
+                        const void *mode)
+{
+   struct apple_glx_drawable *d;
+   struct apple_glx_pixmap *p;
+   bool double_buffered;
+   bool uses_stereo;
+   CGLError error;
+   const __GLcontextModes *cmodes = mode;
 
-    if(apple_glx_drawable_create(dpy, screen, pixmap, &d, &callbacks))
-	return true;
-    
-    /* d is locked and referenced at this point. */
+   if (apple_glx_drawable_create(dpy, screen, pixmap, &d, &callbacks))
+      return true;
 
-    p = &d->types.pixmap;
+   /* d is locked and referenced at this point. */
 
-    p->xpixmap = pixmap;
-    p->buffer = NULL;
+   p = &d->types.pixmap;
 
-    if(!XAppleDRICreatePixmap(dpy, screen, pixmap,
-			      &p->width, &p->height, &p->pitch, &p->bpp,
-			      &p->size, p->path, PATH_MAX)) {
-	d->unlock(d);
-	d->destroy(d);
-	return true;
-    }
-      
-    p->fd = shm_open(p->path, O_RDWR, 0);
-    
-    if(p->fd < 0) {
-	perror("shm_open");
-	d->unlock(d);
-	d->destroy(d);
-	return true;
-    }
+   p->xpixmap = pixmap;
+   p->buffer = NULL;
 
-    p->buffer = mmap(NULL, p->size, PROT_READ | PROT_WRITE,
-		     MAP_FILE | MAP_SHARED, p->fd, 0);
+   if (!XAppleDRICreatePixmap(dpy, screen, pixmap,
+                              &p->width, &p->height, &p->pitch, &p->bpp,
+                              &p->size, p->path, PATH_MAX)) {
+      d->unlock(d);
+      d->destroy(d);
+      return true;
+   }
 
-    if(MAP_FAILED == p->buffer) {
-	perror("mmap");
-	d->unlock(d);
-	d->destroy(d);
-	return true;
-    }
+   p->fd = shm_open(p->path, O_RDWR, 0);
 
-    apple_visual_create_pfobj(&p->pixel_format_obj, mode, &double_buffered,
-			      &uses_stereo, /*offscreen*/ true);
+   if (p->fd < 0) {
+      perror("shm_open");
+      d->unlock(d);
+      d->destroy(d);
+      return true;
+   }
 
-    error = apple_cgl.create_context(p->pixel_format_obj, NULL,
-				     &p->context_obj);
+   p->buffer = mmap(NULL, p->size, PROT_READ | PROT_WRITE,
+                    MAP_FILE | MAP_SHARED, p->fd, 0);
 
-    if(kCGLNoError != error) {
-	d->unlock(d);
-	d->destroy(d);
-	return true;
-    }
-    
-    p->fbconfigID = cmodes->fbconfigID;
+   if (MAP_FAILED == p->buffer) {
+      perror("mmap");
+      d->unlock(d);
+      d->destroy(d);
+      return true;
+   }
 
-    d->unlock(d);
+   apple_visual_create_pfobj(&p->pixel_format_obj, mode, &double_buffered,
+                             &uses_stereo, /*offscreen */ true);
 
-    apple_glx_diagnostic("created: pixmap buffer for 0x%lx\n", d->drawable);
+   error = apple_cgl.create_context(p->pixel_format_obj, NULL,
+                                    &p->context_obj);
 
-    return false;
+   if (kCGLNoError != error) {
+      d->unlock(d);
+      d->destroy(d);
+      return true;
+   }
+
+   p->fbconfigID = cmodes->fbconfigID;
+
+   d->unlock(d);
+
+   apple_glx_diagnostic("created: pixmap buffer for 0x%lx\n", d->drawable);
+
+   return false;
 }
 
-bool apple_glx_pixmap_query(GLXPixmap pixmap, int attr, unsigned int *value) {
-    struct apple_glx_drawable *d;
-    struct apple_glx_pixmap *p;
-    bool result = false;
- 
-    d = apple_glx_drawable_find_by_type(pixmap, APPLE_GLX_DRAWABLE_PIXMAP,
-					APPLE_GLX_DRAWABLE_LOCK);
+bool
+apple_glx_pixmap_query(GLXPixmap pixmap, int attr, unsigned int *value)
+{
+   struct apple_glx_drawable *d;
+   struct apple_glx_pixmap *p;
+   bool result = false;
 
-    if(d) {
-	p = &d->types.pixmap;
+   d = apple_glx_drawable_find_by_type(pixmap, APPLE_GLX_DRAWABLE_PIXMAP,
+                                       APPLE_GLX_DRAWABLE_LOCK);
 
-	switch(attr) {
-	case GLX_WIDTH:
-	    *value = p->width;
-	    result = true;
-	    break;
+   if (d) {
+      p = &d->types.pixmap;
 
-	case GLX_HEIGHT:
-	    *value = p->height;
-	    result = true;
-	    break;
-	    
-	case GLX_FBCONFIG_ID:
-	    *value = p->fbconfigID;
-	    result = true;
-	    break;
-	}
+      switch (attr) {
+      case GLX_WIDTH:
+         *value = p->width;
+         result = true;
+         break;
 
-	d->unlock(d);
-    }
+      case GLX_HEIGHT:
+         *value = p->height;
+         result = true;
+         break;
 
-    return result;
+      case GLX_FBCONFIG_ID:
+         *value = p->fbconfigID;
+         result = true;
+         break;
+      }
+
+      d->unlock(d);
+   }
+
+   return result;
 }
 
 /* Return true if the type is valid for pixmap. */
-bool apple_glx_pixmap_destroy(Display *dpy, GLXPixmap pixmap) {
-    return !apple_glx_drawable_destroy_by_type(dpy, pixmap,
-					       APPLE_GLX_DRAWABLE_PIXMAP);
+bool
+apple_glx_pixmap_destroy(Display * dpy, GLXPixmap pixmap)
+{
+   return !apple_glx_drawable_destroy_by_type(dpy, pixmap,
+                                              APPLE_GLX_DRAWABLE_PIXMAP);
 }

Modified: AppleSGLX/trunk/apple_glx_surface.c
===================================================================
--- AppleSGLX/trunk/apple_glx_surface.c	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/apple_glx_surface.c	2009-12-21 20:56:26 UTC (rev 386)
@@ -33,152 +33,157 @@
 #include "apple_glx_drawable.h"
 
 static bool surface_make_current(struct apple_glx_context *ac,
-				 struct apple_glx_drawable *d);
+                                 struct apple_glx_drawable *d);
 
-static void surface_destroy(Display *dpy, struct apple_glx_drawable *d);
+static void surface_destroy(Display * dpy, struct apple_glx_drawable *d);
 
 
 static struct apple_glx_drawable_callbacks callbacks = {
-    .type = APPLE_GLX_DRAWABLE_SURFACE,
-    .make_current = surface_make_current,
-    .destroy = surface_destroy
+   .type = APPLE_GLX_DRAWABLE_SURFACE,
+   .make_current = surface_make_current,
+   .destroy = surface_destroy
 };
 
-static void update_viewport_and_scissor(Display *dpy,
-					GLXDrawable drawable) {
-    Window root;
-    int x, y;
-    unsigned int width = 0, height = 0, bd, depth;
-    
-    XGetGeometry(dpy, drawable, &root, &x, &y, &width, &height, &bd, &depth);
-    
-    glViewport(0, 0, width, height);
-    glScissor(0, 0, width, height);
+static void
+update_viewport_and_scissor(Display * dpy, GLXDrawable drawable)
+{
+   Window root;
+   int x, y;
+   unsigned int width = 0, height = 0, bd, depth;
+
+   XGetGeometry(dpy, drawable, &root, &x, &y, &width, &height, &bd, &depth);
+
+   glViewport(0, 0, width, height);
+   glScissor(0, 0, width, height);
 }
 
-static bool surface_make_current(struct apple_glx_context *ac,
-				 struct apple_glx_drawable *d) {
-    struct apple_glx_surface *s = &d->types.surface;
-    xp_error error;
+static bool
+surface_make_current(struct apple_glx_context *ac,
+                     struct apple_glx_drawable *d)
+{
+   struct apple_glx_surface *s = &d->types.surface;
+   xp_error error;
 
-    assert(APPLE_GLX_DRAWABLE_SURFACE == d->type);
-  
-    apple_glx_diagnostic("%s: ac->context_obj %p s->surface_id %u\n",
-			 __func__, (void *)ac->context_obj, s->surface_id);
+   assert(APPLE_GLX_DRAWABLE_SURFACE == d->type);
 
-    error = xp_attach_gl_context(ac->context_obj, s->surface_id);
-    
-    if(error) {
-	fprintf(stderr, "error: xp_attach_gl_context returned: %d\n",
-		error);
-	return true;
-    }
-    
-    
-    if(!ac->made_current) {
-	/* 
-	 * The first time a new context is made current the glViewport
-	 * and glScissor should be updated.
-	 */
-	update_viewport_and_scissor(ac->drawable->display,
-				    ac->drawable->drawable);
-	ac->made_current = true;
-    }
+   apple_glx_diagnostic("%s: ac->context_obj %p s->surface_id %u\n",
+                        __func__, (void *) ac->context_obj, s->surface_id);
 
-    apple_glx_diagnostic("%s: drawable 0x%lx\n", __func__, d->drawable);
+   error = xp_attach_gl_context(ac->context_obj, s->surface_id);
 
-    return false;
+   if (error) {
+      fprintf(stderr, "error: xp_attach_gl_context returned: %d\n", error);
+      return true;
+   }
+
+
+   if (!ac->made_current) {
+      /* 
+       * The first time a new context is made current the glViewport
+       * and glScissor should be updated.
+       */
+      update_viewport_and_scissor(ac->drawable->display,
+                                  ac->drawable->drawable);
+      ac->made_current = true;
+   }
+
+   apple_glx_diagnostic("%s: drawable 0x%lx\n", __func__, d->drawable);
+
+   return false;
 }
 
-static void surface_destroy(Display *dpy, struct apple_glx_drawable *d) {
-    struct apple_glx_surface *s = &d->types.surface;
+static void
+surface_destroy(Display * dpy, struct apple_glx_drawable *d)
+{
+   struct apple_glx_surface *s = &d->types.surface;
 
-    apple_glx_diagnostic("%s: s->surface_id %u\n", __func__, s->surface_id);
+   apple_glx_diagnostic("%s: s->surface_id %u\n", __func__, s->surface_id);
 
-    xp_error error = xp_destroy_surface(s->surface_id);
-        
-    if(error) {
-	fprintf(stderr, "xp_destroy_surface error: %d\n", (int)error);
-    }
+   xp_error error = xp_destroy_surface(s->surface_id);
 
-    /* 
-     * Check if this surface destroy came from the surface being destroyed
-     * on the server.  If s->pending_destroy is true, then it did, and 
-     * we don't want to try to destroy the surface on the server.
-     */
-    if(!s->pending_destroy) {
-	/*
-	 * Warning: this causes other routines to be called (potentially)
-	 * from surface_notify_handler.  It's probably best to not have
-	 * any locks at this point locked.
-	 */
-	XAppleDRIDestroySurface(d->display, DefaultScreen(d->display), 
-				d->drawable);
-	
-	apple_glx_diagnostic("%s: destroyed a surface for drawable 0x%lx uid %u\n", 
-			     __func__, d->drawable, s->uid);
-    }
+   if (error) {
+      fprintf(stderr, "xp_destroy_surface error: %d\n", (int) error);
+   }
+
+   /* 
+    * Check if this surface destroy came from the surface being destroyed
+    * on the server.  If s->pending_destroy is true, then it did, and 
+    * we don't want to try to destroy the surface on the server.
+    */
+   if (!s->pending_destroy) {
+      /*
+       * Warning: this causes other routines to be called (potentially)
+       * from surface_notify_handler.  It's probably best to not have
+       * any locks at this point locked.
+       */
+      XAppleDRIDestroySurface(d->display, DefaultScreen(d->display),
+                              d->drawable);
+
+      apple_glx_diagnostic
+         ("%s: destroyed a surface for drawable 0x%lx uid %u\n", __func__,
+          d->drawable, s->uid);
+   }
 }
 
 /* Return true if an error occured. */
-static bool create_surface(Display *dpy, int screen,
-			   struct apple_glx_drawable *d) {
-    struct apple_glx_surface *s = &d->types.surface;
-    unsigned int key[2];
-    xp_client_id id;
+static bool
+create_surface(Display * dpy, int screen, struct apple_glx_drawable *d)
+{
+   struct apple_glx_surface *s = &d->types.surface;
+   unsigned int key[2];
+   xp_client_id id;
 
-    id = apple_glx_get_client_id();
-    if(0 == id)
-	return true;
+   id = apple_glx_get_client_id();
+   if (0 == id)
+      return true;
 
-    assert(None != d->drawable);
+   assert(None != d->drawable);
 
-    s->pending_destroy = false;
+   s->pending_destroy = false;
 
-    if(XAppleDRICreateSurface(dpy, screen, d->drawable,
-			      id, key, &s->uid)) {
-	xp_error error;
+   if (XAppleDRICreateSurface(dpy, screen, d->drawable, id, key, &s->uid)) {
+      xp_error error;
 
-	error = xp_import_surface(key, &s->surface_id);
+      error = xp_import_surface(key, &s->surface_id);
 
-	if(error) {
-	    fprintf(stderr, "error: xp_import_surface returned: %d\n",
-		    error);
-	    return true;
-	}
-	
-	apple_glx_diagnostic("%s: created a surface for drawable 0x%lx"
-			     " with uid %u\n", 
-			     __func__, d->drawable, s->uid);
-	return false; /*success*/
-    }
+      if (error) {
+         fprintf(stderr, "error: xp_import_surface returned: %d\n", error);
+         return true;
+      }
 
-    return true; /* unable to create a surface. */
+      apple_glx_diagnostic("%s: created a surface for drawable 0x%lx"
+                           " with uid %u\n", __func__, d->drawable, s->uid);
+      return false;             /*success */
+   }
+
+   return true;                 /* unable to create a surface. */
 }
 
 /* Return true if an error occured. */
 /* This returns a referenced object via resultptr. */
-bool apple_glx_surface_create(Display *dpy, int screen,
-			      GLXDrawable drawable,
-			      struct apple_glx_drawable **resultptr) {
-    struct apple_glx_drawable *d;
+bool
+apple_glx_surface_create(Display * dpy, int screen,
+                         GLXDrawable drawable,
+                         struct apple_glx_drawable ** resultptr)
+{
+   struct apple_glx_drawable *d;
 
-    if(apple_glx_drawable_create(dpy, screen, drawable, &d, &callbacks))
-	return true;
-    
-    /* apple_glx_drawable_create creates a locked and referenced object. */
+   if (apple_glx_drawable_create(dpy, screen, drawable, &d, &callbacks))
+      return true;
 
-    if(create_surface(dpy, screen, d)) {
-	d->unlock(d);
-	d->destroy(d);
-	return true;
-    }  
-    
-    *resultptr = d;
+   /* apple_glx_drawable_create creates a locked and referenced object. */
 
-    d->unlock(d);
-    
-    return false;
+   if (create_surface(dpy, screen, d)) {
+      d->unlock(d);
+      d->destroy(d);
+      return true;
+   }
+
+   *resultptr = d;
+
+   d->unlock(d);
+
+   return false;
 }
 
 /*
@@ -191,27 +196,29 @@
  * pending_destroy, which is then checked for in glViewport by
  * apple_glx_context_update.
  */
-void apple_glx_surface_destroy(unsigned int uid) {
-    struct apple_glx_drawable *d;
-    
-    d = apple_glx_drawable_find_by_uid(uid, APPLE_GLX_DRAWABLE_REFERENCE
-				       | APPLE_GLX_DRAWABLE_LOCK);
+void
+apple_glx_surface_destroy(unsigned int uid)
+{
+   struct apple_glx_drawable *d;
 
-    if(d) {
-	d->types.surface.pending_destroy = true;
-	d->release(d);
-	/* 
-	 * We release 2 references to the surface.  One was acquired by
-	 * the find, and the other was leftover from a context, or 
-	 * the surface being displayed, so the destroy() will decrease it
-	 * once more.
-	 *
-	 * If the surface is in a context, it will take one d->destroy(d);
-	 * to actually destroy it when the pending_destroy is processed
-	 * by a glViewport callback (see apple_glx_context_update()).
-	 */
-	d->destroy(d);
-	
-	d->unlock(d);
-    }
+   d = apple_glx_drawable_find_by_uid(uid, APPLE_GLX_DRAWABLE_REFERENCE
+                                      | APPLE_GLX_DRAWABLE_LOCK);
+
+   if (d) {
+      d->types.surface.pending_destroy = true;
+      d->release(d);
+      /* 
+       * We release 2 references to the surface.  One was acquired by
+       * the find, and the other was leftover from a context, or 
+       * the surface being displayed, so the destroy() will decrease it
+       * once more.
+       *
+       * If the surface is in a context, it will take one d->destroy(d);
+       * to actually destroy it when the pending_destroy is processed
+       * by a glViewport callback (see apple_glx_context_update()).
+       */
+      d->destroy(d);
+
+      d->unlock(d);
+   }
 }

Modified: AppleSGLX/trunk/apple_visual.c
===================================================================
--- AppleSGLX/trunk/apple_visual.c	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/apple_visual.c	2009-12-21 20:56:26 UTC (rev 386)
@@ -35,99 +35,110 @@
 #include <OpenGL/OpenGL.h>
 #include <OpenGL/CGLContext.h>
 #include <OpenGL/CGLRenderers.h>
-#include "glcontextmodes.h" 
 #include "apple_cgl.h"
 #include "apple_visual.h"
 #include "apple_glx.h"
+#include "glcontextmodes.h"
 
-enum {
-    MAX_ATTR = 60
+enum
+{
+   MAX_ATTR = 60
 };
 
 /*mode is a __GlcontextModes*/
-void apple_visual_create_pfobj(CGLPixelFormatObj *pfobj, const void *mode,
-                               bool *double_buffered, bool *uses_stereo,
-			       bool offscreen) {
-    CGLPixelFormatAttribute attr[MAX_ATTR];
-    const __GLcontextModes *c = mode;
-    int numattr = 0;
-    GLint vsref = 0;
-    CGLError error = 0;
-    
-    if(offscreen) {
-        apple_glx_diagnostic("offscreen rendering enabled.  Using kCGLPFAOffScreen\n");
+void
+apple_visual_create_pfobj(CGLPixelFormatObj * pfobj, const void *mode,
+                          bool * double_buffered, bool * uses_stereo,
+                          bool offscreen)
+{
+   CGLPixelFormatAttribute attr[MAX_ATTR];
+   const __GLcontextModes *c = mode;
+   int numattr = 0;
+   GLint vsref = 0;
+   CGLError error = 0;
 
-        attr[numattr++] = kCGLPFAOffScreen;
-        attr[numattr++] = kCGLPFAColorSize;
-        attr[numattr++] = 32;
-    } else if(getenv("LIBGL_ALWAYS_SOFTWARE") != NULL) {
-        apple_glx_diagnostic("Software rendering requested.  Using kCGLRendererGenericFloatID.\n");
-        attr[numattr++] = kCGLPFARendererID;
-        attr[numattr++] = kCGLRendererGenericFloatID;
-    } else if(getenv("LIBGL_ALLOW_SOFTWARE") != NULL) {
-        apple_glx_diagnostic("Software rendering is not being excluded.  Not using kCGLPFAAccelerated.\n");
-    } else {
-        attr[numattr++] = kCGLPFAAccelerated;
-    }
-    
-    /* 
-     * The program chose a config based on the fbconfigs or visuals.
-     * Those are based on the attributes from CGL, so we probably
-     * do want the closest match for the color, depth, and accum.
-     */
-    attr[numattr++] = kCGLPFAClosestPolicy;
-    
-    if(c->stereoMode) {
-        attr[numattr++] = kCGLPFAStereo;
-	*uses_stereo = true;
-    } else {
-	*uses_stereo = false;
-    }
+   if (offscreen) {
+      apple_glx_diagnostic
+         ("offscreen rendering enabled.  Using kCGLPFAOffScreen\n");
 
-    if(c->doubleBufferMode) {
-        attr[numattr++] = kCGLPFADoubleBuffer;
-        *double_buffered = true;
-    } else {
-        *double_buffered = false;
-    }
-    
-    attr[numattr++] = kCGLPFAColorSize;
-    attr[numattr++] = c->redBits + c->greenBits + c->blueBits;
-    attr[numattr++] = kCGLPFAAlphaSize;
-    attr[numattr++] = c->alphaBits;
-    
-    if((c->accumRedBits + c->accumGreenBits + c->accumBlueBits) > 0) {
-        attr[numattr++] = kCGLPFAAccumSize;
-        attr[numattr++] = c->accumRedBits + c->accumGreenBits + 
-	    c->accumBlueBits + c->accumAlphaBits;
-    }
-    
-    if(c->depthBits > 0) {
-        attr[numattr++] = kCGLPFADepthSize;
-        attr[numattr++] = c->depthBits;
-    }
-    
-    if(c->stencilBits > 0) {
-        attr[numattr++] = kCGLPFAStencilSize;
-        attr[numattr++] = c->stencilBits;
-    }
-    
-    if(c->sampleBuffers > 0) {
-        attr[numattr++] = kCGLPFAMultisample;
-        attr[numattr++] = kCGLPFASampleBuffers;
-        attr[numattr++] = c->sampleBuffers;
-        attr[numattr++] = kCGLPFASamples;
-        attr[numattr++] = c->samples;
-    }
-    
-    attr[numattr++] = 0;
-    
-    assert(numattr < MAX_ATTR);
-    
-    error = apple_cgl.choose_pixel_format(attr, pfobj, &vsref);
-    
-    if(error) {
-        fprintf(stderr, "error: %s\n", apple_cgl.error_string(error));
-        abort();
-    }
+      attr[numattr++] = kCGLPFAOffScreen;
+      attr[numattr++] = kCGLPFAColorSize;
+      attr[numattr++] = 32;
+   }
+   else if (getenv("LIBGL_ALWAYS_SOFTWARE") != NULL) {
+      apple_glx_diagnostic
+         ("Software rendering requested.  Using kCGLRendererGenericFloatID.\n");
+      attr[numattr++] = kCGLPFARendererID;
+      attr[numattr++] = kCGLRendererGenericFloatID;
+   }
+   else if (getenv("LIBGL_ALLOW_SOFTWARE") != NULL) {
+      apple_glx_diagnostic
+         ("Software rendering is not being excluded.  Not using kCGLPFAAccelerated.\n");
+   }
+   else {
+      attr[numattr++] = kCGLPFAAccelerated;
+   }
+
+   /* 
+    * The program chose a config based on the fbconfigs or visuals.
+    * Those are based on the attributes from CGL, so we probably
+    * do want the closest match for the color, depth, and accum.
+    */
+   attr[numattr++] = kCGLPFAClosestPolicy;
+
+   if (c->stereoMode) {
+      attr[numattr++] = kCGLPFAStereo;
+      *uses_stereo = true;
+   }
+   else {
+      *uses_stereo = false;
+   }
+
+   if (c->doubleBufferMode) {
+      attr[numattr++] = kCGLPFADoubleBuffer;
+      *double_buffered = true;
+   }
+   else {
+      *double_buffered = false;
+   }
+
+   attr[numattr++] = kCGLPFAColorSize;
+   attr[numattr++] = c->redBits + c->greenBits + c->blueBits;
+   attr[numattr++] = kCGLPFAAlphaSize;
+   attr[numattr++] = c->alphaBits;
+
+   if ((c->accumRedBits + c->accumGreenBits + c->accumBlueBits) > 0) {
+      attr[numattr++] = kCGLPFAAccumSize;
+      attr[numattr++] = c->accumRedBits + c->accumGreenBits +
+         c->accumBlueBits + c->accumAlphaBits;
+   }
+
+   if (c->depthBits > 0) {
+      attr[numattr++] = kCGLPFADepthSize;
+      attr[numattr++] = c->depthBits;
+   }
+
+   if (c->stencilBits > 0) {
+      attr[numattr++] = kCGLPFAStencilSize;
+      attr[numattr++] = c->stencilBits;
+   }
+
+   if (c->sampleBuffers > 0) {
+      attr[numattr++] = kCGLPFAMultisample;
+      attr[numattr++] = kCGLPFASampleBuffers;
+      attr[numattr++] = c->sampleBuffers;
+      attr[numattr++] = kCGLPFASamples;
+      attr[numattr++] = c->samples;
+   }
+
+   attr[numattr++] = 0;
+
+   assert(numattr < MAX_ATTR);
+
+   error = apple_cgl.choose_pixel_format(attr, pfobj, &vsref);
+
+   if (error) {
+      fprintf(stderr, "error: %s\n", apple_cgl.error_string(error));
+      abort();
+   }
 }

Modified: AppleSGLX/trunk/apple_visual.h
===================================================================
--- AppleSGLX/trunk/apple_visual.h	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/apple_visual.h	2009-12-21 20:56:26 UTC (rev 386)
@@ -34,8 +34,8 @@
 #include <OpenGL/CGLTypes.h>
 
 /* mode is expected to be of type __GLcontextModes. */
-void apple_visual_create_pfobj(CGLPixelFormatObj *pfobj, const void *mode,
-			       bool *double_buffered, bool *uses_stereo,
-			       bool offscreen);
+void apple_visual_create_pfobj(CGLPixelFormatObj * pfobj, const void *mode,
+                               bool * double_buffered, bool * uses_stereo,
+                               bool offscreen);
 
 #endif

Modified: AppleSGLX/trunk/apple_xgl_api_read.c
===================================================================
--- AppleSGLX/trunk/apple_xgl_api_read.c	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/apple_xgl_api_read.c	2009-12-21 20:56:26 UTC (rev 386)
@@ -41,84 +41,94 @@
 
 extern struct apple_xgl_api __gl_api;
 
-struct apple_xgl_saved_state {
-    bool swapped;
+struct apple_xgl_saved_state
+{
+   bool swapped;
 };
 
-static void SetRead(struct apple_xgl_saved_state *saved) {
-    GLXContext gc = __glXGetCurrentContext();
-   
-    /*
-     * By default indicate that the state was not swapped, so that UnsetRead
-     * functions correctly.
-     */
-    saved->swapped = false;
+static void
+SetRead(struct apple_xgl_saved_state *saved)
+{
+   GLXContext gc = __glXGetCurrentContext();
 
-    /* 
-     * If the readable drawable isn't the same as the drawable then 
-     * the user has requested a readable drawable with glXMakeContextCurrent().
-     * We emulate this behavior by switching the current drawable.
-     */
-    if(None != gc->currentReadable 
+   /*
+    * By default indicate that the state was not swapped, so that UnsetRead
+    * functions correctly.
+    */
+   saved->swapped = false;
+
+   /* 
+    * If the readable drawable isn't the same as the drawable then 
+    * the user has requested a readable drawable with glXMakeContextCurrent().
+    * We emulate this behavior by switching the current drawable.
+    */
+   if (None != gc->currentReadable
        && gc->currentReadable != gc->currentDrawable) {
-	Display *dpy = glXGetCurrentDisplay();
+      Display *dpy = glXGetCurrentDisplay();
 
-	saved->swapped = true;
+      saved->swapped = true;
 
-	if(apple_glx_make_current_context(dpy, gc->apple, gc->apple, 
-					  gc->currentReadable)) {
-	    /* An error occurred, so try to restore the old context state. */
-	    (void)apple_glx_make_current_context(dpy, gc->apple, gc->apple, 
-						 gc->currentDrawable);
-	    saved->swapped = false;
-	}
-    }
+      if (apple_glx_make_current_context(dpy, gc->apple, gc->apple,
+                                         gc->currentReadable)) {
+         /* An error occurred, so try to restore the old context state. */
+         (void) apple_glx_make_current_context(dpy, gc->apple, gc->apple,
+                                               gc->currentDrawable);
+         saved->swapped = false;
+      }
+   }
 }
 
-static void UnsetRead(struct apple_xgl_saved_state *saved) {
-    if(saved->swapped) {
-	GLXContext gc = __glXGetCurrentContext();
-	Display *dpy = glXGetCurrentDisplay();
+static void
+UnsetRead(struct apple_xgl_saved_state *saved)
+{
+   if (saved->swapped) {
+      GLXContext gc = __glXGetCurrentContext();
+      Display *dpy = glXGetCurrentDisplay();
 
-	if(apple_glx_make_current_context(dpy, gc->apple, gc->apple,
-					  gc->currentDrawable)) {
-	    /*
-	     * An error occurred restoring the drawable.
-	     * It's unclear what to do about that. 
-	     */
-	}
-    }
+      if (apple_glx_make_current_context(dpy, gc->apple, gc->apple,
+                                         gc->currentDrawable)) {
+         /*
+          * An error occurred restoring the drawable.
+          * It's unclear what to do about that. 
+          */
+      }
+   }
 }
 
-void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, 
-		  GLenum format, GLenum type, void * pixels) {
-    struct apple_xgl_saved_state saved;
-    
-    SetRead(&saved);
+void
+glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
+             GLenum format, GLenum type, void *pixels)
+{
+   struct apple_xgl_saved_state saved;
 
-    __gl_api.ReadPixels(x, y, width, height, format, type, pixels);
+   SetRead(&saved);
 
-    UnsetRead(&saved);
+   __gl_api.ReadPixels(x, y, width, height, format, type, pixels);
+
+   UnsetRead(&saved);
 }
 
-void glCopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, 
-		  GLenum type) {
-    struct apple_xgl_saved_state saved;
+void
+glCopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type)
+{
+   struct apple_xgl_saved_state saved;
 
-    SetRead(&saved);
+   SetRead(&saved);
 
-    __gl_api.CopyPixels(x, y, width, height, type);
+   __gl_api.CopyPixels(x, y, width, height, type);
 
-    UnsetRead(&saved);
+   UnsetRead(&saved);
 }
 
-void glCopyColorTable(GLenum target, GLenum internalformat, GLint x, GLint y,
-		      GLsizei width) {
-    struct apple_xgl_saved_state saved;
+void
+glCopyColorTable(GLenum target, GLenum internalformat, GLint x, GLint y,
+                 GLsizei width)
+{
+   struct apple_xgl_saved_state saved;
 
-    SetRead(&saved);
+   SetRead(&saved);
 
-    __gl_api.CopyColorTable(target, internalformat, x, y, width);
+   __gl_api.CopyColorTable(target, internalformat, x, y, width);
 
-    UnsetRead(&saved);
+   UnsetRead(&saved);
 }

Modified: AppleSGLX/trunk/apple_xgl_api_read.h
===================================================================
--- AppleSGLX/trunk/apple_xgl_api_read.h	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/apple_xgl_api_read.h	2009-12-21 20:56:26 UTC (rev 386)
@@ -35,12 +35,13 @@
 
 #include "glxclient.h"
 
-extern void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, 
-			 GLenum type, void * pixels);
+extern void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
+                         GLenum format, GLenum type, void *pixels);
 
-extern void glCopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type);
+extern void glCopyPixels(GLint x, GLint y, GLsizei width, GLsizei height,
+                         GLenum type);
 
-extern void glCopyColorTable(GLenum target, GLenum internalformat, GLint x, GLint y, 
-		      GLsizei width);
+extern void glCopyColorTable(GLenum target, GLenum internalformat, GLint x,
+                             GLint y, GLsizei width);
 
 #endif

Modified: AppleSGLX/trunk/apple_xgl_api_stereo.c
===================================================================
--- AppleSGLX/trunk/apple_xgl_api_stereo.c	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/apple_xgl_api_stereo.c	2009-12-21 20:56:26 UTC (rev 386)
@@ -36,74 +36,84 @@
 /* 
  * These are special functions for stereoscopic support 
  * differences in MacOS X.
- */ 
-void glDrawBuffer(GLenum mode) {
-    GLXContext gc = glXGetCurrentContext();
+ */
+void
+glDrawBuffer(GLenum mode)
+{
+   GLXContext gc = glXGetCurrentContext();
 
-    if(gc && apple_glx_context_uses_stereo(gc->apple)) {
-	GLenum buf[2];
-	GLsizei n = 0;
-	
-	switch(mode) {
-	case GL_BACK:
-	    buf[0] = GL_BACK_LEFT;
-	    buf[1] = GL_BACK_RIGHT;
-	    n = 2;
-	    break;
-	case GL_FRONT:
-	    buf[0] = GL_FRONT_LEFT;
-	    buf[1] = GL_FRONT_RIGHT;
-	    n = 2;
-	    break;
-	    
-	default:
-	    buf[0] = mode;
-	    n = 1;
-	    break;
-	}
-	
-	__gl_api.DrawBuffers(n, buf);
-    } else {
-	__gl_api.DrawBuffer(mode);
-    }
+   if (gc && apple_glx_context_uses_stereo(gc->apple)) {
+      GLenum buf[2];
+      GLsizei n = 0;
+
+      switch (mode) {
+      case GL_BACK:
+         buf[0] = GL_BACK_LEFT;
+         buf[1] = GL_BACK_RIGHT;
+         n = 2;
+         break;
+      case GL_FRONT:
+         buf[0] = GL_FRONT_LEFT;
+         buf[1] = GL_FRONT_RIGHT;
+         n = 2;
+         break;
+
+      default:
+         buf[0] = mode;
+         n = 1;
+         break;
+      }
+
+      __gl_api.DrawBuffers(n, buf);
+   }
+   else {
+      __gl_api.DrawBuffer(mode);
+   }
 }
 
-	 
-void glDrawBuffers(GLsizei n, const GLenum *bufs) {
-    GLXContext gc = glXGetCurrentContext();
 
-    if(gc && apple_glx_context_uses_stereo(gc->apple)) {
-	GLenum newbuf[n + 2];
-	GLsizei i, outi = 0;
-	bool have_back = false;
-	bool have_front = false;
-        
-	for(i = 0; i < n; ++i) {
-	    if(GL_BACK == bufs[i]) {
-		have_back = true;
-	    } else if(GL_FRONT == bufs[i]) {
-		have_back = true;
-	    } else {
-		newbuf[outi++] = bufs[i];
-	    }
-	}
-	
-	if(have_back) {
-	    newbuf[outi++] = GL_BACK_LEFT;
-	    newbuf[outi++] = GL_BACK_RIGHT;
-	}
+void
+glDrawBuffers(GLsizei n, const GLenum * bufs)
+{
+   GLXContext gc = glXGetCurrentContext();
 
-	if(have_front) {
-	    newbuf[outi++] = GL_FRONT_LEFT;
-	    newbuf[outi++] = GL_FRONT_RIGHT;
-	}
-	
-	__gl_api.DrawBuffers(outi, newbuf);
-    } else {
-	__gl_api.DrawBuffers(n, bufs);
-    }
+   if (gc && apple_glx_context_uses_stereo(gc->apple)) {
+      GLenum newbuf[n + 2];
+      GLsizei i, outi = 0;
+      bool have_back = false;
+      bool have_front = false;
+
+      for (i = 0; i < n; ++i) {
+         if (GL_BACK == bufs[i]) {
+            have_back = true;
+         }
+         else if (GL_FRONT == bufs[i]) {
+            have_back = true;
+         }
+         else {
+            newbuf[outi++] = bufs[i];
+         }
+      }
+
+      if (have_back) {
+         newbuf[outi++] = GL_BACK_LEFT;
+         newbuf[outi++] = GL_BACK_RIGHT;
+      }
+
+      if (have_front) {
+         newbuf[outi++] = GL_FRONT_LEFT;
+         newbuf[outi++] = GL_FRONT_RIGHT;
+      }
+
+      __gl_api.DrawBuffers(outi, newbuf);
+   }
+   else {
+      __gl_api.DrawBuffers(n, bufs);
+   }
 }
 
-void glDrawBuffersARB(GLsizei n, const GLenum *bufs) {
-    glDrawBuffers(n, bufs);
+void
+glDrawBuffersARB(GLsizei n, const GLenum * bufs)
+{
+   glDrawBuffers(n, bufs);
 }

Modified: AppleSGLX/trunk/apple_xgl_api_stereo.h
===================================================================
--- AppleSGLX/trunk/apple_xgl_api_stereo.h	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/apple_xgl_api_stereo.h	2009-12-21 20:56:26 UTC (rev 386)
@@ -33,7 +33,7 @@
 #define APPLE_XGL_API_STEREO_H
 
 extern void glDrawBuffer(GLenum mode);
-extern void glDrawBuffers(GLsizei n, const GLenum *bufs);
-extern void glDrawBuffersARB(GLsizei n, const GLenum *bufs);
+extern void glDrawBuffers(GLsizei n, const GLenum * bufs);
+extern void glDrawBuffersARB(GLsizei n, const GLenum * bufs);
 
 #endif

Modified: AppleSGLX/trunk/apple_xgl_api_viewport.c
===================================================================
--- AppleSGLX/trunk/apple_xgl_api_viewport.c	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/apple_xgl_api_viewport.c	2009-12-21 20:56:26 UTC (rev 386)
@@ -32,12 +32,14 @@
 
 extern struct apple_xgl_api __gl_api;
 
-void glViewport(GLint x, GLint y, GLsizei width, GLsizei height) {
-    GLXContext gc = __glXGetCurrentContext();
-    Display *dpy = glXGetCurrentDisplay();
+void
+glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
+{
+   GLXContext gc = __glXGetCurrentContext();
+   Display *dpy = glXGetCurrentDisplay();
 
-    if(gc && gc->apple)
-	apple_glx_context_update(dpy, gc->apple);
+   if (gc && gc->apple)
+      apple_glx_context_update(dpy, gc->apple);
 
-    __gl_api.Viewport(x, y, width, height);
+   __gl_api.Viewport(x, y, width, height);
 }

Modified: AppleSGLX/trunk/appledri.c
===================================================================
--- AppleSGLX/trunk/appledri.c	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/appledri.c	2009-12-21 20:56:26 UTC (rev 386)
@@ -59,61 +59,61 @@
  *                                                                           *
  *****************************************************************************/
 
-static int close_display(Display *dpy, XExtCodes *extCodes);
+static int close_display(Display * dpy, XExtCodes * extCodes);
 static Bool wire_to_event();
 
 static /* const */ XExtensionHooks appledri_extension_hooks = {
-    NULL,				/* create_gc */
-    NULL,				/* copy_gc */
-    NULL,				/* flush_gc */
-    NULL,				/* free_gc */
-    NULL,				/* create_font */
-    NULL,				/* free_font */
-    close_display,			/* close_display */
-    wire_to_event,			/* wire_to_event */
-    NULL,				/* event_to_wire */
-    NULL,				/* error */
-    NULL,				/* error_string */
+   NULL,                        /* create_gc */
+   NULL,                        /* copy_gc */
+   NULL,                        /* flush_gc */
+   NULL,                        /* free_gc */
+   NULL,                        /* create_font */
+   NULL,                        /* free_font */
+   close_display,               /* close_display */
+   wire_to_event,               /* wire_to_event */
+   NULL,                        /* event_to_wire */
+   NULL,                        /* error */
+   NULL,                        /* error_string */
 };
 
-static XEXT_GENERATE_FIND_DISPLAY (find_display, appledri_info, 
-				   appledri_extension_name, 
-				   &appledri_extension_hooks, 
-				   AppleDRINumberEvents, NULL)
+static
+XEXT_GENERATE_FIND_DISPLAY(find_display, appledri_info,
+                           appledri_extension_name,
+                           &appledri_extension_hooks,
+                           AppleDRINumberEvents, NULL)
 
-static XEXT_GENERATE_CLOSE_DISPLAY (close_display, appledri_info)
+     static XEXT_GENERATE_CLOSE_DISPLAY(close_display, appledri_info)
 
-static void (*surface_notify_handler) ();
+     static void (*surface_notify_handler) ();
 
-void *
-XAppleDRISetSurfaceNotifyHandler (void (*fun) ())
+     void *XAppleDRISetSurfaceNotifyHandler(void (*fun) ())
 {
-    void *old = surface_notify_handler;
-    surface_notify_handler = fun;
-    return old;
+   void *old = surface_notify_handler;
+   surface_notify_handler = fun;
+   return old;
 }
 
-static Bool wire_to_event (dpy, re, event)
-    Display *dpy;
-    XEvent  *re;
-    xEvent  *event;
+static Bool
+wire_to_event(dpy, re, event)
+     Display *dpy;
+     XEvent *re;
+     xEvent *event;
 {
-    XExtDisplayInfo *info = find_display (dpy);
-    xAppleDRINotifyEvent *sevent;
+   XExtDisplayInfo *info = find_display(dpy);
+   xAppleDRINotifyEvent *sevent;
 
-    AppleDRICheckExtension (dpy, info, False);
+   AppleDRICheckExtension(dpy, info, False);
 
-    switch ((event->u.u.type & 0x7f) - info->codes->first_event) {
-    case AppleDRISurfaceNotify:
-	sevent = (xAppleDRINotifyEvent *) event;
-	if (surface_notify_handler != NULL)
-	{
-	    (*surface_notify_handler) (dpy, (unsigned int) sevent->arg,
-				       (int) sevent->kind);
-	}
-	return False;
-    }
-    return False;
+   switch ((event->u.u.type & 0x7f) - info->codes->first_event) {
+   case AppleDRISurfaceNotify:
+      sevent = (xAppleDRINotifyEvent *) event;
+      if (surface_notify_handler != NULL) {
+         (*surface_notify_handler) (dpy, (unsigned int) sevent->arg,
+                                    (int) sevent->kind);
+      }
+      return False;
+   }
+   return False;
 }
 
 /*****************************************************************************
@@ -130,312 +130,326 @@
 #endif
 
 
-Bool XAppleDRIQueryExtension (dpy, event_basep, error_basep)
-    Display *dpy;
-    int *event_basep, *error_basep;
+Bool
+XAppleDRIQueryExtension(dpy, event_basep, error_basep)
+     Display *dpy;
+     int *event_basep, *error_basep;
 {
-    XExtDisplayInfo *info = find_display (dpy);
+   XExtDisplayInfo *info = find_display(dpy);
 
-    TRACE("QueryExtension...");
-    if (XextHasExtension(info)) {
-	*event_basep = info->codes->first_event;
-	*error_basep = info->codes->first_error;
-        TRACE("QueryExtension... return True");
-	return True;
-    } else {
-        TRACE("QueryExtension... return False");
-	return False;
-    }
+   TRACE("QueryExtension...");
+   if (XextHasExtension(info)) {
+      *event_basep = info->codes->first_event;
+      *error_basep = info->codes->first_error;
+      TRACE("QueryExtension... return True");
+      return True;
+   }
+   else {
+      TRACE("QueryExtension... return False");
+      return False;
+   }
 }
 
-Bool XAppleDRIQueryVersion(dpy, majorVersion, minorVersion, patchVersion)
-    Display* dpy;
-    int* majorVersion; 
-    int* minorVersion;
-    int* patchVersion;
+Bool
+XAppleDRIQueryVersion(dpy, majorVersion, minorVersion, patchVersion)
+     Display *dpy;
+     int *majorVersion;
+     int *minorVersion;
+     int *patchVersion;
 {
-    XExtDisplayInfo *info = find_display (dpy);
-    xAppleDRIQueryVersionReply rep;
-    xAppleDRIQueryVersionReq *req;
+   XExtDisplayInfo *info = find_display(dpy);
+   xAppleDRIQueryVersionReply rep;
+   xAppleDRIQueryVersionReq *req;
 
-    TRACE("QueryVersion...");
-    AppleDRICheckExtension (dpy, info, False);
+   TRACE("QueryVersion...");
+   AppleDRICheckExtension(dpy, info, False);
 
-    LockDisplay(dpy);
-    GetReq(AppleDRIQueryVersion, req);
-    req->reqType = info->codes->major_opcode;
-    req->driReqType = X_AppleDRIQueryVersion;
-    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
-	UnlockDisplay(dpy);
-	SyncHandle();
-        TRACE("QueryVersion... return False");
-	return False;
-    }
-    *majorVersion = rep.majorVersion;
-    *minorVersion = rep.minorVersion;
-    *patchVersion = rep.patchVersion;
-    UnlockDisplay(dpy);
-    SyncHandle();
-    TRACE("QueryVersion... return True");
-    return True;
+   LockDisplay(dpy);
+   GetReq(AppleDRIQueryVersion, req);
+   req->reqType = info->codes->major_opcode;
+   req->driReqType = X_AppleDRIQueryVersion;
+   if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
+      UnlockDisplay(dpy);
+      SyncHandle();
+      TRACE("QueryVersion... return False");
+      return False;
+   }
+   *majorVersion = rep.majorVersion;
+   *minorVersion = rep.minorVersion;
+   *patchVersion = rep.patchVersion;
+   UnlockDisplay(dpy);
+   SyncHandle();
+   TRACE("QueryVersion... return True");
+   return True;
 }
 
-Bool XAppleDRIQueryDirectRenderingCapable(dpy, screen, isCapable)
-    Display* dpy;
-    int screen;
-    Bool* isCapable;
+Bool
+XAppleDRIQueryDirectRenderingCapable(dpy, screen, isCapable)
+     Display *dpy;
+     int screen;
+     Bool *isCapable;
 {
-    XExtDisplayInfo *info = find_display (dpy);
-    xAppleDRIQueryDirectRenderingCapableReply rep;
-    xAppleDRIQueryDirectRenderingCapableReq *req;
+   XExtDisplayInfo *info = find_display(dpy);
+   xAppleDRIQueryDirectRenderingCapableReply rep;
+   xAppleDRIQueryDirectRenderingCapableReq *req;
 
-    TRACE("QueryDirectRenderingCapable...");
-    AppleDRICheckExtension (dpy, info, False);
+   TRACE("QueryDirectRenderingCapable...");
+   AppleDRICheckExtension(dpy, info, False);
 
-    LockDisplay(dpy);
-    GetReq(AppleDRIQueryDirectRenderingCapable, req);
-    req->reqType = info->codes->major_opcode;
-    req->driReqType = X_AppleDRIQueryDirectRenderingCapable;
-    req->screen = screen;
-    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
-	UnlockDisplay(dpy);
-	SyncHandle();
-        TRACE("QueryDirectRenderingCapable... return False");
-	return False;
-    }
-    *isCapable = rep.isCapable;
-    UnlockDisplay(dpy);
-    SyncHandle();
-    TRACE("QueryDirectRenderingCapable... return True");
-    return True;
+   LockDisplay(dpy);
+   GetReq(AppleDRIQueryDirectRenderingCapable, req);
+   req->reqType = info->codes->major_opcode;
+   req->driReqType = X_AppleDRIQueryDirectRenderingCapable;
+   req->screen = screen;
+   if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
+      UnlockDisplay(dpy);
+      SyncHandle();
+      TRACE("QueryDirectRenderingCapable... return False");
+      return False;
+   }
+   *isCapable = rep.isCapable;
+   UnlockDisplay(dpy);
+   SyncHandle();
+   TRACE("QueryDirectRenderingCapable... return True");
+   return True;
 }
 
-Bool XAppleDRIAuthConnection(dpy, screen, magic)
-    Display* dpy;
-    int screen;
-    unsigned int magic;
+Bool
+XAppleDRIAuthConnection(dpy, screen, magic)
+     Display *dpy;
+     int screen;
+     unsigned int magic;
 {
-    XExtDisplayInfo *info = find_display (dpy);
-    xAppleDRIAuthConnectionReq *req;
-    xAppleDRIAuthConnectionReply rep;
+   XExtDisplayInfo *info = find_display(dpy);
+   xAppleDRIAuthConnectionReq *req;
+   xAppleDRIAuthConnectionReply rep;
 
-    TRACE("AuthConnection...");
-    AppleDRICheckExtension (dpy, info, False);
+   TRACE("AuthConnection...");
+   AppleDRICheckExtension(dpy, info, False);
 
-    LockDisplay(dpy);
-    GetReq(AppleDRIAuthConnection, req);
-    req->reqType = info->codes->major_opcode;
-    req->driReqType = X_AppleDRIAuthConnection;
-    req->screen = screen;
-    req->magic = magic;
-    rep.authenticated = 0;
-    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse) || !rep.authenticated) {
-	UnlockDisplay(dpy);
-	SyncHandle();
-        TRACE("AuthConnection... return False");
-	return False;
-    }
-    UnlockDisplay(dpy);
-    SyncHandle();
-    TRACE("AuthConnection... return True");
-    return True;
+   LockDisplay(dpy);
+   GetReq(AppleDRIAuthConnection, req);
+   req->reqType = info->codes->major_opcode;
+   req->driReqType = X_AppleDRIAuthConnection;
+   req->screen = screen;
+   req->magic = magic;
+   rep.authenticated = 0;
+   if (!_XReply(dpy, (xReply *) & rep, 0, xFalse) || !rep.authenticated) {
+      UnlockDisplay(dpy);
+      SyncHandle();
+      TRACE("AuthConnection... return False");
+      return False;
+   }
+   UnlockDisplay(dpy);
+   SyncHandle();
+   TRACE("AuthConnection... return True");
+   return True;
 }
 
-Bool XAppleDRICreateSurface(dpy, screen, drawable, client_id, key, uid)
-    Display* dpy;
-    int screen;
-    Drawable drawable;
-    unsigned int client_id;
-    unsigned int *key;
-    unsigned int *uid;
+Bool
+XAppleDRICreateSurface(dpy, screen, drawable, client_id, key, uid)
+     Display *dpy;
+     int screen;
+     Drawable drawable;
+     unsigned int client_id;
+     unsigned int *key;
+     unsigned int *uid;
 {
-    XExtDisplayInfo *info = find_display (dpy);
-    xAppleDRICreateSurfaceReply rep;
-    xAppleDRICreateSurfaceReq *req;
+   XExtDisplayInfo *info = find_display(dpy);
+   xAppleDRICreateSurfaceReply rep;
+   xAppleDRICreateSurfaceReq *req;
 
-    TRACE("CreateSurface...");
-    AppleDRICheckExtension (dpy, info, False);
+   TRACE("CreateSurface...");
+   AppleDRICheckExtension(dpy, info, False);
 
-    LockDisplay(dpy);
-    GetReq(AppleDRICreateSurface, req);
-    req->reqType = info->codes->major_opcode;
-    req->driReqType = X_AppleDRICreateSurface;
-    req->screen = screen;
-    req->drawable = drawable;
-    req->client_id = client_id;
-    rep.key_0 = rep.key_1 = rep.uid = 0;
-    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse) || !rep.key_0) {
-	UnlockDisplay(dpy);
-	SyncHandle();
-        TRACE("CreateSurface... return False");
-	return False;
-    }
-    key[0] = rep.key_0;
-    key[1] = rep.key_1;
-    *uid = rep.uid;
-    UnlockDisplay(dpy);
-    SyncHandle();
-    TRACE("CreateSurface... return True");
-    return True;
+   LockDisplay(dpy);
+   GetReq(AppleDRICreateSurface, req);
+   req->reqType = info->codes->major_opcode;
+   req->driReqType = X_AppleDRICreateSurface;
+   req->screen = screen;
+   req->drawable = drawable;
+   req->client_id = client_id;
+   rep.key_0 = rep.key_1 = rep.uid = 0;
+   if (!_XReply(dpy, (xReply *) & rep, 0, xFalse) || !rep.key_0) {
+      UnlockDisplay(dpy);
+      SyncHandle();
+      TRACE("CreateSurface... return False");
+      return False;
+   }
+   key[0] = rep.key_0;
+   key[1] = rep.key_1;
+   *uid = rep.uid;
+   UnlockDisplay(dpy);
+   SyncHandle();
+   TRACE("CreateSurface... return True");
+   return True;
 }
 
-Bool XAppleDRIDestroySurface(dpy, screen, drawable)
-    Display* dpy;
-    int screen;
-    Drawable drawable;
+Bool
+XAppleDRIDestroySurface(dpy, screen, drawable)
+     Display *dpy;
+     int screen;
+     Drawable drawable;
 {
-    XExtDisplayInfo *info = find_display (dpy);
-    xAppleDRIDestroySurfaceReq *req;
+   XExtDisplayInfo *info = find_display(dpy);
+   xAppleDRIDestroySurfaceReq *req;
 
-    TRACE("DestroySurface...");
-    AppleDRICheckExtension (dpy, info, False);
+   TRACE("DestroySurface...");
+   AppleDRICheckExtension(dpy, info, False);
 
-    LockDisplay(dpy);
-    GetReq(AppleDRIDestroySurface, req);
-    req->reqType = info->codes->major_opcode;
-    req->driReqType = X_AppleDRIDestroySurface;
-    req->screen = screen;
-    req->drawable = drawable;
-    UnlockDisplay(dpy);
-    SyncHandle();
-    TRACE("DestroySurface... return True");
-    return True;
+   LockDisplay(dpy);
+   GetReq(AppleDRIDestroySurface, req);
+   req->reqType = info->codes->major_opcode;
+   req->driReqType = X_AppleDRIDestroySurface;
+   req->screen = screen;
+   req->drawable = drawable;
+   UnlockDisplay(dpy);
+   SyncHandle();
+   TRACE("DestroySurface... return True");
+   return True;
 }
 
-Bool XAppleDRICreateSharedBuffer(Display *dpy, int screen, Drawable drawable,
-				 Bool doubleSwap, char *path, size_t pathlen,
-				 int *width, int *height)
+Bool
+XAppleDRICreateSharedBuffer(Display * dpy, int screen, Drawable drawable,
+                            Bool doubleSwap, char *path, size_t pathlen,
+                            int *width, int *height)
 {
-    XExtDisplayInfo *info = find_display(dpy);
-    xAppleDRICreateSharedBufferReq *req;
-    xAppleDRICreateSharedBufferReply rep;
+   XExtDisplayInfo *info = find_display(dpy);
+   xAppleDRICreateSharedBufferReq *req;
+   xAppleDRICreateSharedBufferReply rep;
 
-    AppleDRICheckExtension(dpy, info, False);
+   AppleDRICheckExtension(dpy, info, False);
 
-    LockDisplay(dpy);
-    GetReq(AppleDRICreateSharedBuffer, req);
-    req->reqType = info->codes->major_opcode;
-    req->driReqType = X_AppleDRICreateSharedBuffer;
-    req->screen = screen;
-    req->drawable = drawable;
-    req->doubleSwap = doubleSwap;
+   LockDisplay(dpy);
+   GetReq(AppleDRICreateSharedBuffer, req);
+   req->reqType = info->codes->major_opcode;
+   req->driReqType = X_AppleDRICreateSharedBuffer;
+   req->screen = screen;
+   req->drawable = drawable;
+   req->doubleSwap = doubleSwap;
 
-    
-    if(!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
-	puts("REPLY ERROR");
 
-	UnlockDisplay(dpy);
-	SyncHandle();
-	return False;
-    }
+   if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
+      puts("REPLY ERROR");
 
-    printf("rep.stringLength %d\n", (int) rep.stringLength);
+      UnlockDisplay(dpy);
+      SyncHandle();
+      return False;
+   }
 
-    if(rep.stringLength > 0 && rep.stringLength <= pathlen) {
-	_XReadPad(dpy, path, rep.stringLength);
+   printf("rep.stringLength %d\n", (int) rep.stringLength);
 
-	printf("path: %s\n", path);
+   if (rep.stringLength > 0 && rep.stringLength <= pathlen) {
+      _XReadPad(dpy, path, rep.stringLength);
 
-	*width = rep.width;
-	*height = rep.height;
+      printf("path: %s\n", path);
 
-	UnlockDisplay(dpy);
-	SyncHandle();
-	return True;
-    }
+      *width = rep.width;
+      *height = rep.height;
 
-    UnlockDisplay(dpy);
-    SyncHandle();
+      UnlockDisplay(dpy);
+      SyncHandle();
+      return True;
+   }
 
-    return False;
+   UnlockDisplay(dpy);
+   SyncHandle();
+
+   return False;
 }
 
-Bool XAppleDRISwapBuffers(Display *dpy, int screen, Drawable drawable)
+Bool
+XAppleDRISwapBuffers(Display * dpy, int screen, Drawable drawable)
 {
-    XExtDisplayInfo *info = find_display(dpy);
-    xAppleDRISwapBuffersReq *req;
+   XExtDisplayInfo *info = find_display(dpy);
+   xAppleDRISwapBuffersReq *req;
 
-    AppleDRICheckExtension(dpy, info, False);
+   AppleDRICheckExtension(dpy, info, False);
 
-    LockDisplay(dpy);
-    GetReq(AppleDRISwapBuffers, req);
-    req->reqType = info->codes->major_opcode;
-    req->driReqType = X_AppleDRISwapBuffers;
-    req->screen = screen;
-    req->drawable = drawable;
-    UnlockDisplay(dpy);
-    SyncHandle();
+   LockDisplay(dpy);
+   GetReq(AppleDRISwapBuffers, req);
+   req->reqType = info->codes->major_opcode;
+   req->driReqType = X_AppleDRISwapBuffers;
+   req->screen = screen;
+   req->drawable = drawable;
+   UnlockDisplay(dpy);
+   SyncHandle();
 
-    return True;
+   return True;
 }
 
-Bool XAppleDRICreatePixmap(Display *dpy, int screen, Drawable drawable,
-			   int *width, int *height, int *pitch, int *bpp,
-			   size_t *size, char *bufname, size_t bufnamesize) {
-    XExtDisplayInfo *info = find_display(dpy);
-    xAppleDRICreatePixmapReq *req;
-    xAppleDRICreatePixmapReply rep;
-    
-    AppleDRICheckExtension(dpy, info, False);
+Bool
+XAppleDRICreatePixmap(Display * dpy, int screen, Drawable drawable,
+                      int *width, int *height, int *pitch, int *bpp,
+                      size_t * size, char *bufname, size_t bufnamesize)
+{
+   XExtDisplayInfo *info = find_display(dpy);
+   xAppleDRICreatePixmapReq *req;
+   xAppleDRICreatePixmapReply rep;
 
-    LockDisplay(dpy);
-    GetReq(AppleDRICreatePixmap, req);
-    req->reqType = info->codes->major_opcode;
-    req->driReqType = X_AppleDRICreatePixmap;
-    req->screen = screen;
-    req->drawable = drawable;
+   AppleDRICheckExtension(dpy, info, False);
 
-    if(!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
-	UnlockDisplay(dpy);
-	SyncHandle();
-	return False;
-    }
+   LockDisplay(dpy);
+   GetReq(AppleDRICreatePixmap, req);
+   req->reqType = info->codes->major_opcode;
+   req->driReqType = X_AppleDRICreatePixmap;
+   req->screen = screen;
+   req->drawable = drawable;
 
-    /*
-    printf("rep.stringLength %d\n", (int) rep.stringLength);
+   if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
+      UnlockDisplay(dpy);
+      SyncHandle();
+      return False;
+   }
+
+   /*
+      printf("rep.stringLength %d\n", (int) rep.stringLength);
     */
 
-    if(rep.stringLength > 0 && rep.stringLength <= bufnamesize) {
-	_XReadPad(dpy, bufname, rep.stringLength);
+   if (rep.stringLength > 0 && rep.stringLength <= bufnamesize) {
+      _XReadPad(dpy, bufname, rep.stringLength);
 
-	printf("path: %s\n", bufname);
+      printf("path: %s\n", bufname);
 
-	*width = rep.width;
-	*height = rep.height;
-	*pitch = rep.pitch;
-	*bpp = rep.bpp;
-	*size = rep.size;
+      *width = rep.width;
+      *height = rep.height;
+      *pitch = rep.pitch;
+      *bpp = rep.bpp;
+      *size = rep.size;
 
-	UnlockDisplay(dpy);
-	SyncHandle();
-	return True;
-    } else if (rep.stringLength > 0) {
-	_XEatData(dpy, rep.stringLength);
-    }
+      UnlockDisplay(dpy);
+      SyncHandle();
+      return True;
+   }
+   else if (rep.stringLength > 0) {
+      _XEatData(dpy, rep.stringLength);
+   }
 
-    UnlockDisplay(dpy);
-    SyncHandle();
+   UnlockDisplay(dpy);
+   SyncHandle();
 
-    return True;
+   return True;
 }
-		   
+
 /* 
  * Call it a drawable, because we really don't know what it is
  * until it reaches the server, and we should keep that in mind.
  */
-Bool XAppleDRIDestroyPixmap(Display *dpy, Pixmap drawable) {
-    XExtDisplayInfo *info = find_display(dpy);
-    xAppleDRIDestroyPixmapReq *req;
-    
-    AppleDRICheckExtension(dpy, info, False);
+Bool
+XAppleDRIDestroyPixmap(Display * dpy, Pixmap drawable)
+{
+   XExtDisplayInfo *info = find_display(dpy);
+   xAppleDRIDestroyPixmapReq *req;
 
-    LockDisplay(dpy);
-    GetReq(AppleDRIDestroyPixmap, req);
-    req->reqType = info->codes->major_opcode;
-    req->driReqType = X_AppleDRIDestroyPixmap;
-    req->drawable = drawable;
-    UnlockDisplay(dpy);
-    SyncHandle();
+   AppleDRICheckExtension(dpy, info, False);
 
-    return True;
+   LockDisplay(dpy);
+   GetReq(AppleDRIDestroyPixmap, req);
+   req->reqType = info->codes->major_opcode;
+   req->driReqType = X_AppleDRIDestroyPixmap;
+   req->drawable = drawable;
+   UnlockDisplay(dpy);
+   SyncHandle();
+
+   return True;
 }

Modified: AppleSGLX/trunk/appledri.h
===================================================================
--- AppleSGLX/trunk/appledri.h	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/appledri.h	2009-12-21 20:56:26 UTC (rev 386)
@@ -72,53 +72,53 @@
 
 #ifndef _APPLEDRI_SERVER_
 
-typedef struct {
-    int	type;		    /* of event */
-    unsigned long serial;   /* # of last request processed by server */
-    Bool send_event;	    /* true if this came frome a SendEvent request */
-    Display *display;	    /* Display the event was read from */
-    Window window;	    /* window of event */
-    Time time;		    /* server timestamp when event happened */
-    int kind;		    /* subtype of event */
-    int arg;
+typedef struct
+{
+   int type;                    /* of event */
+   unsigned long serial;        /* # of last request processed by server */
+   Bool send_event;             /* true if this came frome a SendEvent request */
+   Display *display;            /* Display the event was read from */
+   Window window;               /* window of event */
+   Time time;                   /* server timestamp when event happened */
+   int kind;                    /* subtype of event */
+   int arg;
 } XAppleDRINotifyEvent;
 
 _XFUNCPROTOBEGIN
+   Bool XAppleDRIQueryExtension(Display * dpy, int *event_base,
+                                int *error_base);
 
-Bool XAppleDRIQueryExtension (Display *dpy, int *event_base, int *error_base);
+Bool XAppleDRIQueryVersion(Display * dpy, int *majorVersion,
+                           int *minorVersion, int *patchVersion);
 
-Bool XAppleDRIQueryVersion (Display *dpy, int *majorVersion,
-			    int *minorVersion, int *patchVersion);
+Bool XAppleDRIQueryDirectRenderingCapable(Display * dpy, int screen,
+                                          Bool * isCapable);
 
-Bool XAppleDRIQueryDirectRenderingCapable (Display *dpy, int screen,
-					   Bool *isCapable);
+void *XAppleDRISetSurfaceNotifyHandler(void (*fun) (Display * dpy,
+                                                    unsigned uid, int kind));
 
-void *XAppleDRISetSurfaceNotifyHandler (void (*fun) (Display *dpy,
-						     unsigned uid, int kind));
+Bool XAppleDRIAuthConnection(Display * dpy, int screen, unsigned int magic);
 
-Bool XAppleDRIAuthConnection (Display *dpy, int screen, unsigned int magic);
+Bool XAppleDRICreateSurface(Display * dpy, int screen, Drawable drawable,
+                            unsigned int client_id, unsigned int key[2],
+                            unsigned int *uid);
 
-Bool XAppleDRICreateSurface (Display *dpy, int screen, Drawable drawable,
-			     unsigned int client_id, unsigned int key[2],
-			     unsigned int* uid);
+Bool XAppleDRIDestroySurface(Display * dpy, int screen, Drawable drawable);
 
-Bool XAppleDRIDestroySurface (Display *dpy, int screen, Drawable drawable);
+Bool XAppleDRISynchronizeSurfaces(Display * dpy);
 
-Bool XAppleDRISynchronizeSurfaces (Display *dpy);
+Bool XAppleDRICreateSharedBuffer(Display * dpy, int screen, Drawable drawable,
+                                 Bool doubleSwap, char *path, size_t pathlen,
+                                 int *width, int *height);
 
-Bool XAppleDRICreateSharedBuffer(Display *dpy, int screen, Drawable drawable,
-				 Bool doubleSwap, char *path, size_t pathlen,
-				 int *width, int *height);
+Bool XAppleDRISwapBuffers(Display * dpy, int screen, Drawable drawable);
 
-Bool XAppleDRISwapBuffers(Display *dpy, int screen, Drawable drawable);
+Bool XAppleDRICreatePixmap(Display * dpy, int screen, Drawable drawable,
+                           int *width, int *height, int *pitch, int *bpp,
+                           size_t * size, char *bufname, size_t bufnamesize);
 
-Bool XAppleDRICreatePixmap(Display *dpy, int screen, Drawable drawable,
-			   int *width, int *height, int *pitch, int *bpp,
-			   size_t *size, char *bufname, size_t bufnamesize);
+Bool XAppleDRIDestroyPixmap(Display * dpy, Pixmap pixmap);
 
-Bool XAppleDRIDestroyPixmap(Display *dpy, Pixmap pixmap);
-
 _XFUNCPROTOEND
-
 #endif /* _APPLEDRI_SERVER_ */
 #endif /* _APPLEDRI_H_ */

Modified: AppleSGLX/trunk/appledristr.h
===================================================================
--- AppleSGLX/trunk/appledristr.h	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/appledristr.h	2009-12-21 20:56:26 UTC (rev 386)
@@ -42,209 +42,225 @@
 
 #define APPLEDRINAME "Apple-DRI"
 
-#define APPLE_DRI_MAJOR_VERSION	1	/* current version numbers */
+#define APPLE_DRI_MAJOR_VERSION	1       /* current version numbers */
 #define APPLE_DRI_MINOR_VERSION	0
 #define APPLE_DRI_PATCH_VERSION	0
 
-typedef struct _AppleDRIQueryVersion {
-    CARD8	reqType;		/* always DRIReqCode */
-    CARD8	driReqType;		/* always X_DRIQueryVersion */
-    CARD16	length B16;
+typedef struct _AppleDRIQueryVersion
+{
+   CARD8 reqType;               /* always DRIReqCode */
+   CARD8 driReqType;            /* always X_DRIQueryVersion */
+   CARD16 length B16;
 } xAppleDRIQueryVersionReq;
 #define sz_xAppleDRIQueryVersionReq	4
 
-typedef struct {
-    BYTE	type;			/* X_Reply */
-    BOOL	pad1;
-    CARD16	sequenceNumber B16;
-    CARD32	length B32;
-    CARD16	majorVersion B16;	/* major version of DRI protocol */
-    CARD16	minorVersion B16;	/* minor version of DRI protocol */
-    CARD32	patchVersion B32;       /* patch version of DRI protocol */
-    CARD32	pad3 B32;
-    CARD32	pad4 B32;
-    CARD32	pad5 B32;
-    CARD32	pad6 B32;
+typedef struct
+{
+   BYTE type;                   /* X_Reply */
+   BOOL pad1;
+   CARD16 sequenceNumber B16;
+   CARD32 length B32;
+   CARD16 majorVersion B16;     /* major version of DRI protocol */
+   CARD16 minorVersion B16;     /* minor version of DRI protocol */
+   CARD32 patchVersion B32;     /* patch version of DRI protocol */
+   CARD32 pad3 B32;
+   CARD32 pad4 B32;
+   CARD32 pad5 B32;
+   CARD32 pad6 B32;
 } xAppleDRIQueryVersionReply;
 #define sz_xAppleDRIQueryVersionReply	32
 
-typedef struct _AppleDRIQueryDirectRenderingCapable {
-    CARD8	reqType;		/* always DRIReqCode */
-    CARD8	driReqType;		/* X_DRIQueryDirectRenderingCapable */
-    CARD16	length B16;
-    CARD32	screen B32;
+typedef struct _AppleDRIQueryDirectRenderingCapable
+{
+   CARD8 reqType;               /* always DRIReqCode */
+   CARD8 driReqType;            /* X_DRIQueryDirectRenderingCapable */
+   CARD16 length B16;
+   CARD32 screen B32;
 } xAppleDRIQueryDirectRenderingCapableReq;
 #define sz_xAppleDRIQueryDirectRenderingCapableReq	8
 
-typedef struct {
-    BYTE	type;			/* X_Reply */
-    BOOL	pad1;
-    CARD16	sequenceNumber B16;
-    CARD32	length B32;
-    BOOL	isCapable;
-    BOOL	pad2;
-    BOOL	pad3;
-    BOOL	pad4;
-    CARD32	pad5 B32;
-    CARD32	pad6 B32;
-    CARD32	pad7 B32;
-    CARD32	pad8 B32;
-    CARD32	pad9 B32;
+typedef struct
+{
+   BYTE type;                   /* X_Reply */
+   BOOL pad1;
+   CARD16 sequenceNumber B16;
+   CARD32 length B32;
+   BOOL isCapable;
+   BOOL pad2;
+   BOOL pad3;
+   BOOL pad4;
+   CARD32 pad5 B32;
+   CARD32 pad6 B32;
+   CARD32 pad7 B32;
+   CARD32 pad8 B32;
+   CARD32 pad9 B32;
 } xAppleDRIQueryDirectRenderingCapableReply;
 #define sz_xAppleDRIQueryDirectRenderingCapableReply	32
 
-typedef struct _AppleDRIAuthConnection {
-    CARD8	reqType;		/* always DRIReqCode */
-    CARD8	driReqType;		/* always X_DRICloseConnection */
-    CARD16	length B16;
-    CARD32	screen B32;
-    CARD32      magic B32;
+typedef struct _AppleDRIAuthConnection
+{
+   CARD8 reqType;               /* always DRIReqCode */
+   CARD8 driReqType;            /* always X_DRICloseConnection */
+   CARD16 length B16;
+   CARD32 screen B32;
+   CARD32 magic B32;
 } xAppleDRIAuthConnectionReq;
 #define sz_xAppleDRIAuthConnectionReq	12
 
-typedef struct {
-    BYTE        type;
-    BOOL        pad1;
-    CARD16      sequenceNumber B16;
-    CARD32      length B32;
-    CARD32      authenticated B32;
-    CARD32      pad2 B32;
-    CARD32      pad3 B32;
-    CARD32      pad4 B32;
-    CARD32      pad5 B32;
-    CARD32      pad6 B32;
+typedef struct
+{
+   BYTE type;
+   BOOL pad1;
+   CARD16 sequenceNumber B16;
+   CARD32 length B32;
+   CARD32 authenticated B32;
+   CARD32 pad2 B32;
+   CARD32 pad3 B32;
+   CARD32 pad4 B32;
+   CARD32 pad5 B32;
+   CARD32 pad6 B32;
 } xAppleDRIAuthConnectionReply;
 #define zx_xAppleDRIAuthConnectionReply  32
 
-typedef struct _AppleDRICreateSurface {
-    CARD8	reqType;		/* always DRIReqCode */
-    CARD8	driReqType;		/* always X_DRICreateSurface */
-    CARD16	length B16;
-    CARD32	screen B32;
-    CARD32	drawable B32;
-    CARD32	client_id B32;
+typedef struct _AppleDRICreateSurface
+{
+   CARD8 reqType;               /* always DRIReqCode */
+   CARD8 driReqType;            /* always X_DRICreateSurface */
+   CARD16 length B16;
+   CARD32 screen B32;
+   CARD32 drawable B32;
+   CARD32 client_id B32;
 } xAppleDRICreateSurfaceReq;
 #define sz_xAppleDRICreateSurfaceReq	16
 
-typedef struct {
-    BYTE	type;			/* X_Reply */
-    BOOL	pad1;
-    CARD16	sequenceNumber B16;
-    CARD32	length B32;
-    CARD32	key_0 B32;
-    CARD32	key_1 B32;
-    CARD32	uid B32;
-    CARD32	pad4 B32;
-    CARD32	pad5 B32;
-    CARD32	pad6 B32;
+typedef struct
+{
+   BYTE type;                   /* X_Reply */
+   BOOL pad1;
+   CARD16 sequenceNumber B16;
+   CARD32 length B32;
+   CARD32 key_0 B32;
+   CARD32 key_1 B32;
+   CARD32 uid B32;
+   CARD32 pad4 B32;
+   CARD32 pad5 B32;
+   CARD32 pad6 B32;
 } xAppleDRICreateSurfaceReply;
 #define sz_xAppleDRICreateSurfaceReply	32
 
-typedef struct _AppleDRIDestroySurface {
-    CARD8	reqType;		/* always DRIReqCode */
-    CARD8	driReqType;		/* always X_DRIDestroySurface */
-    CARD16	length B16;
-    CARD32	screen B32;
-    CARD32	drawable B32;
+typedef struct _AppleDRIDestroySurface
+{
+   CARD8 reqType;               /* always DRIReqCode */
+   CARD8 driReqType;            /* always X_DRIDestroySurface */
+   CARD16 length B16;
+   CARD32 screen B32;
+   CARD32 drawable B32;
 } xAppleDRIDestroySurfaceReq;
 #define sz_xAppleDRIDestroySurfaceReq	12
 
-typedef struct _AppleDRINotify {
-	BYTE	type;		/* always eventBase + event type */
-	BYTE	kind;
-	CARD16	sequenceNumber B16;
-	CARD32	time B32;	/* time of change */
-	CARD32	pad1 B32;
-	CARD32	arg B32;
-	CARD32	pad3 B32;
-	CARD32	pad4 B32;
-	CARD32	pad5 B32;
-	CARD32	pad6 B32;
+typedef struct _AppleDRINotify
+{
+   BYTE type;                   /* always eventBase + event type */
+   BYTE kind;
+   CARD16 sequenceNumber B16;
+   CARD32 time B32;             /* time of change */
+   CARD32 pad1 B32;
+   CARD32 arg B32;
+   CARD32 pad3 B32;
+   CARD32 pad4 B32;
+   CARD32 pad5 B32;
+   CARD32 pad6 B32;
 } xAppleDRINotifyEvent;
 #define sz_xAppleDRINotifyEvent	32
 
 
-typedef struct {
-    CARD8 reqType;
-    CARD8 driReqType;
-    CARD16 length B16;
-    CARD32 screen B32;
-    CARD32 drawable B32;
-    BOOL doubleSwap;
-    CARD8 pad1, pad2, pad3;
+typedef struct
+{
+   CARD8 reqType;
+   CARD8 driReqType;
+   CARD16 length B16;
+   CARD32 screen B32;
+   CARD32 drawable B32;
+   BOOL doubleSwap;
+   CARD8 pad1, pad2, pad3;
 } xAppleDRICreateSharedBufferReq;
 
 #define sz_xAppleDRICreateSharedBufferReq 16
 
-typedef struct {
-    BYTE type;
-    BYTE data1;
-    CARD16 sequenceNumber B16;
-    CARD32 length B32;
-    CARD32 stringLength B32; /* 0 on error */
-    CARD32 width B32;
-    CARD32 height B32;
-    CARD32 pad1 B32;
-    CARD32 pad2 B32;
-    CARD32 pad3 B32;
+typedef struct
+{
+   BYTE type;
+   BYTE data1;
+   CARD16 sequenceNumber B16;
+   CARD32 length B32;
+   CARD32 stringLength B32;     /* 0 on error */
+   CARD32 width B32;
+   CARD32 height B32;
+   CARD32 pad1 B32;
+   CARD32 pad2 B32;
+   CARD32 pad3 B32;
 } xAppleDRICreateSharedBufferReply;
 
 #define sz_xAppleDRICreateSharedBufferReply 32
 
-typedef struct {
-    CARD8 reqType;
-    CARD8 driReqType;
-    CARD16 length B16;
-    CARD32 screen B32;
-    CARD32 drawable B32;
+typedef struct
+{
+   CARD8 reqType;
+   CARD8 driReqType;
+   CARD16 length B16;
+   CARD32 screen B32;
+   CARD32 drawable B32;
 } xAppleDRISwapBuffersReq;
 
 #define sz_xAppleDRISwapBuffersReq 12
 
-typedef struct {
-    CARD8 reqType; /*1*/
-    CARD8 driReqType; /*2*/
-    CARD16 length B16; /*4*/
-    CARD32 screen B32; /*8*/
-    CARD32 drawable B32; /*12*/
+typedef struct
+{
+   CARD8 reqType;               /*1 */
+   CARD8 driReqType;            /*2 */
+   CARD16 length B16;           /*4 */
+   CARD32 screen B32;           /*8 */
+   CARD32 drawable B32;         /*12 */
 } xAppleDRICreatePixmapReq;
 
 #define sz_xAppleDRICreatePixmapReq 12
 
-typedef struct {
-    BYTE type; /*1*/
-    BOOL pad1; /*2*/
-    CARD16 sequenceNumber B16; /*4*/
-    CARD32 length B32; /*8*/
-    CARD32 width B32; /*12*/
-    CARD32 height B32; /*16*/
-    CARD32 pitch B32; /*20*/
-    CARD32 bpp B32; /*24*/
-    CARD32 size B32; /*28*/
-    CARD32 stringLength B32; /*32*/
+typedef struct
+{
+   BYTE type;                   /*1 */
+   BOOL pad1;                   /*2 */
+   CARD16 sequenceNumber B16;   /*4 */
+   CARD32 length B32;           /*8 */
+   CARD32 width B32;            /*12 */
+   CARD32 height B32;           /*16 */
+   CARD32 pitch B32;            /*20 */
+   CARD32 bpp B32;              /*24 */
+   CARD32 size B32;             /*28 */
+   CARD32 stringLength B32;     /*32 */
 } xAppleDRICreatePixmapReply;
 
 #define sz_xAppleDRICreatePixmapReply 32
 
-typedef struct {
-    CARD8 reqType; /*1*/
-    CARD8 driReqType; /*2*/
-    CARD16 length B16; /*4*/
-    CARD32 drawable B32; /*8*/
+typedef struct
+{
+   CARD8 reqType;               /*1 */
+   CARD8 driReqType;            /*2 */
+   CARD16 length B16;           /*4 */
+   CARD32 drawable B32;         /*8 */
 } xAppleDRIDestroyPixmapReq;
 
 #define sz_xAppleDRIDestroyPixmapReq 8
 
 #ifdef _APPLEDRI_SERVER_
 
-void AppleDRISendEvent (
+void AppleDRISendEvent(
 #if NeedFunctionPrototypes
-    int			/* type */,
-    unsigned int	/* mask */,
-    int			/* which */,
-    int			/* arg */
+                         int /* type */ ,
+                         unsigned int /* mask */ ,
+                         int /* which */ ,
+                         int    /* arg */
 #endif
-);
+   );
 
 #endif /* _APPLEDRI_SERVER_ */
 #endif /* _APPLEDRISTR_H_ */

Modified: AppleSGLX/trunk/glcontextmodes.c
===================================================================
--- AppleSGLX/trunk/glcontextmodes.c	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/glcontextmodes.c	2009-12-21 20:56:26 UTC (rev 386)
@@ -266,7 +266,7 @@
    case GLX_LEVEL:
       *value_return = mode->level;
       return 0;
-#ifndef __APPLE__ /* This isn't supported by CGL. */
+#ifndef __APPLE__               /* This isn't supported by CGL. */
    case GLX_TRANSPARENT_TYPE_EXT:
       *value_return = mode->transparentPixel;
       return 0;
@@ -316,7 +316,7 @@
    case GLX_MAX_PBUFFER_PIXELS:
       *value_return = mode->maxPbufferPixels;
       return 0;
-#ifndef __APPLE__ /* These aren't supported by CGL. */
+#ifndef __APPLE__               /* These aren't supported by CGL. */
    case GLX_OPTIMAL_PBUFFER_WIDTH_SGIX:
       *value_return = mode->optimalPbufferWidth;
       return 0;

Modified: AppleSGLX/trunk/glcontextmodes.h
===================================================================
--- AppleSGLX/trunk/glcontextmodes.h	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/glcontextmodes.h	2009-12-21 20:56:26 UTC (rev 386)
@@ -33,22 +33,22 @@
 #include "GL/internal/glcore.h"
 
 #if !defined(IN_MINI_GLX)
-extern GLint _gl_convert_from_x_visual_type( int visualType );
-extern GLint _gl_convert_to_x_visual_type( int visualType );
-extern void _gl_copy_visual_to_context_mode( __GLcontextModes * mode,
-    const __GLXvisualConfig * config );
-extern int _gl_get_context_mode_data( const __GLcontextModes *mode,
-    int attribute, int *value_return );
+extern GLint _gl_convert_from_x_visual_type(int visualType);
+extern GLint _gl_convert_to_x_visual_type(int visualType);
+extern void _gl_copy_visual_to_context_mode(__GLcontextModes * mode,
+                                            const __GLXvisualConfig * config);
+extern int _gl_get_context_mode_data(const __GLcontextModes * mode,
+                                     int attribute, int *value_return);
 #endif /* !defined(IN_MINI_GLX) */
 
-extern __GLcontextModes * _gl_context_modes_create( unsigned count,
-    size_t minimum_size );
-extern void _gl_context_modes_destroy( __GLcontextModes * modes );
-extern  __GLcontextModes *
-    _gl_context_modes_find_visual(__GLcontextModes *modes, int vid);
-extern __GLcontextModes *
-    _gl_context_modes_find_fbconfig(__GLcontextModes *modes, int fbid);
-extern GLboolean _gl_context_modes_are_same( const __GLcontextModes * a,
-    const __GLcontextModes * b );
+extern __GLcontextModes *_gl_context_modes_create(unsigned count,
+                                                  size_t minimum_size);
+extern void _gl_context_modes_destroy(__GLcontextModes * modes);
+extern __GLcontextModes *_gl_context_modes_find_visual(__GLcontextModes *
+                                                       modes, int vid);
+extern __GLcontextModes *_gl_context_modes_find_fbconfig(__GLcontextModes *
+                                                         modes, int fbid);
+extern GLboolean _gl_context_modes_are_same(const __GLcontextModes * a,
+                                            const __GLcontextModes * b);
 
 #endif /* GLCONTEXTMODES_H */

Modified: AppleSGLX/trunk/glx_empty.c
===================================================================
--- AppleSGLX/trunk/glx_empty.c	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/glx_empty.c	2009-12-21 20:56:26 UTC (rev 386)
@@ -5,26 +5,29 @@
 /*
 ** GLX_SGI_swap_control
 */
-int glXSwapIntervalSGI(int interval)
+int
+glXSwapIntervalSGI(int interval)
 {
-    (void)interval;
-    return 0;
+   (void) interval;
+   return 0;
 }
 
 
 /*
 ** GLX_MESA_swap_control
 */
-int glXSwapIntervalMESA(unsigned int interval)
+int
+glXSwapIntervalMESA(unsigned int interval)
 {
    (void) interval;
    return GLX_BAD_CONTEXT;
 }
- 
 
-int glXGetSwapIntervalMESA(void)
+
+int
+glXGetSwapIntervalMESA(void)
 {
-    return 0;
+   return 0;
 }
 
 
@@ -32,16 +35,18 @@
 ** GLX_MESA_swap_frame_usage
 */
 
-GLint glXBeginFrameTrackingMESA(Display *dpy, GLXDrawable drawable)
+GLint
+glXBeginFrameTrackingMESA(Display * dpy, GLXDrawable drawable)
 {
-    int   status = GLX_BAD_CONTEXT;
-    (void) dpy;
-    (void) drawable;
-    return status;
+   int status = GLX_BAD_CONTEXT;
+   (void) dpy;
+   (void) drawable;
+   return status;
 }
 
-    
-GLint glXEndFrameTrackingMESA(Display *dpy, GLXDrawable drawable)
+
+GLint
+glXEndFrameTrackingMESA(Display * dpy, GLXDrawable drawable)
 {
    int status = GLX_BAD_CONTEXT;
    (void) dpy;
@@ -50,8 +55,8 @@
 }
 
 
-GLint glXGetFrameUsageMESA(Display *dpy, GLXDrawable drawable,
-				    GLfloat *usage)
+GLint
+glXGetFrameUsageMESA(Display * dpy, GLXDrawable drawable, GLfloat * usage)
 {
    int status = GLX_BAD_CONTEXT;
    (void) dpy;
@@ -60,9 +65,10 @@
    return status;
 }
 
-GLint glXQueryFrameTrackingMESA(Display *dpy, GLXDrawable drawable,
-					 int64_t *sbc, int64_t *missedFrames,
-					 GLfloat *lastMissedUsage)
+GLint
+glXQueryFrameTrackingMESA(Display * dpy, GLXDrawable drawable,
+                          int64_t * sbc, int64_t * missedFrames,
+                          GLfloat * lastMissedUsage)
 {
    int status = GLX_BAD_CONTEXT;
    (void) dpy;
@@ -76,24 +82,26 @@
 /*
 ** GLX_SGI_video_sync
 */
-int glXGetVideoSyncSGI(unsigned int *count)
+int
+glXGetVideoSyncSGI(unsigned int *count)
 {
-    (void) count;
-    return GLX_BAD_CONTEXT;
+   (void) count;
+   return GLX_BAD_CONTEXT;
 }
 
-int glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count)
+int
+glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count)
 {
-    (void) count;
-    return GLX_BAD_CONTEXT;
+   (void) count;
+   return GLX_BAD_CONTEXT;
 }
 
 
 /*
 ** GLX_SGIX_swap_group
 */
-void glXJoinSwapGroupSGIX(Display *dpy, GLXDrawable drawable,
-				   GLXDrawable member)
+void
+glXJoinSwapGroupSGIX(Display * dpy, GLXDrawable drawable, GLXDrawable member)
 {
    (void) dpy;
    (void) drawable;
@@ -104,15 +112,16 @@
 /*
 ** GLX_SGIX_swap_barrier
 */
-void glXBindSwapBarrierSGIX(Display *dpy, GLXDrawable drawable,
-				     int barrier)
+void
+glXBindSwapBarrierSGIX(Display * dpy, GLXDrawable drawable, int barrier)
 {
    (void) dpy;
    (void) drawable;
    (void) barrier;
 }
 
-Bool glXQueryMaxSwapBarriersSGIX(Display *dpy, int screen, int *max)
+Bool
+glXQueryMaxSwapBarriersSGIX(Display * dpy, int screen, int *max)
 {
    (void) dpy;
    (void) screen;
@@ -124,8 +133,9 @@
 /*
 ** GLX_OML_sync_control
 */
-Bool glXGetSyncValuesOML(Display *dpy, GLXDrawable drawable,
-				  int64_t *ust, int64_t *msc, int64_t *sbc)
+Bool
+glXGetSyncValuesOML(Display * dpy, GLXDrawable drawable,
+                    int64_t * ust, int64_t * msc, int64_t * sbc)
 {
    (void) dpy;
    (void) drawable;
@@ -135,9 +145,9 @@
    return False;
 }
 
-int64_t glXSwapBuffersMscOML(Display *dpy, GLXDrawable drawable,
-				      int64_t target_msc, int64_t divisor,
-				      int64_t remainder)
+int64_t
+glXSwapBuffersMscOML(Display * dpy, GLXDrawable drawable,
+                     int64_t target_msc, int64_t divisor, int64_t remainder)
 {
    (void) dpy;
    (void) drawable;
@@ -148,10 +158,11 @@
 }
 
 
-Bool glXWaitForMscOML(Display * dpy, GLXDrawable drawable,
-			       int64_t target_msc, int64_t divisor,
-			       int64_t remainder, int64_t *ust,
-			       int64_t *msc, int64_t *sbc)
+Bool
+glXWaitForMscOML(Display * dpy, GLXDrawable drawable,
+                 int64_t target_msc, int64_t divisor,
+                 int64_t remainder, int64_t * ust,
+                 int64_t * msc, int64_t * sbc)
 {
    (void) dpy;
    (void) drawable;
@@ -165,17 +176,18 @@
 }
 
 
-Bool glXWaitForSbcOML(Display * dpy, GLXDrawable drawable,
-			       int64_t target_sbc, int64_t *ust,
-			       int64_t *msc, int64_t *sbc )
+Bool
+glXWaitForSbcOML(Display * dpy, GLXDrawable drawable,
+                 int64_t target_sbc, int64_t * ust,
+                 int64_t * msc, int64_t * sbc)
 {
-    (void) dpy;
-    (void) drawable;
-    (void) target_sbc;
-    (void) ust;
-    (void) msc;
-    (void) sbc;
-    return False;
+   (void) dpy;
+   (void) drawable;
+   (void) target_sbc;
+   (void) ust;
+   (void) msc;
+   (void) sbc;
+   return False;
 }
 
 
@@ -184,9 +196,10 @@
  */
 /*@{*/
 
-PUBLIC void *glXAllocateMemoryMESA(Display *dpy, int scrn,
-				   size_t size, float readFreq,
-				   float writeFreq, float priority)
+PUBLIC void *
+glXAllocateMemoryMESA(Display * dpy, int scrn,
+                      size_t size, float readFreq,
+                      float writeFreq, float priority)
 {
    (void) dpy;
    (void) scrn;
@@ -198,13 +211,14 @@
 }
 
 
-PUBLIC void glXFreeMemoryMESA(Display *dpy, int scrn, void *pointer)
+PUBLIC void
+glXFreeMemoryMESA(Display * dpy, int scrn, void *pointer)
 {
 #ifdef __DRI_ALLOCATE
-   __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, scrn );
+   __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, scrn);
 
    if (psc && psc->allocate)
-	 (*psc->allocate->freeMemory)(psc->__driScreen, pointer);
+      (*psc->allocate->freeMemory) (psc->__driScreen, pointer);
 
 #else
    (void) dpy;
@@ -214,8 +228,8 @@
 }
 
 
-PUBLIC GLuint glXGetMemoryOffsetMESA( Display *dpy, int scrn,
-				      const void *pointer )
+PUBLIC GLuint
+glXGetMemoryOffsetMESA(Display * dpy, int scrn, const void *pointer)
 {
    (void) dpy;
    (void) scrn;
@@ -223,7 +237,8 @@
    return ~0L;
 }
 
-Bool glXReleaseBuffersMESA( Display *dpy, GLXDrawable d )
+Bool
+glXReleaseBuffersMESA(Display * dpy, GLXDrawable d)
 {
    (void) dpy;
    (void) d;
@@ -231,8 +246,9 @@
 }
 
 
-PUBLIC GLXPixmap glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visual,
-					 Pixmap pixmap, Colormap cmap )
+PUBLIC GLXPixmap
+glXCreateGLXPixmapMESA(Display * dpy, XVisualInfo * visual,
+                       Pixmap pixmap, Colormap cmap)
 {
    (void) dpy;
    (void) visual;
@@ -245,99 +261,115 @@
 /**
  * GLX_MESA_copy_sub_buffer
  */
-void glXCopySubBufferMESA(Display *dpy, GLXDrawable drawable,
-				   int x, int y, int width, int height)
+void
+glXCopySubBufferMESA(Display * dpy, GLXDrawable drawable,
+                     int x, int y, int width, int height)
 {
-    (void) dpy;
-    (void) drawable;
-    (void) x;
-    (void) y;
-    (void) width;
-    (void) height;
+   (void) dpy;
+   (void) drawable;
+   (void) x;
+   (void) y;
+   (void) width;
+   (void) height;
 }
 
 
-PUBLIC int glXQueryGLXPbufferSGIX(Display *dpy, GLXDrawable drawable,
-		       int attribute, unsigned int *value)
+PUBLIC int
+glXQueryGLXPbufferSGIX(Display * dpy, GLXDrawable drawable,
+                       int attribute, unsigned int *value)
 {
-    (void) dpy;
-    (void) drawable;
-    (void) attribute;
-    (void) value;
-    return 0;
+   (void) dpy;
+   (void) drawable;
+   (void) attribute;
+   (void) value;
+   return 0;
 }
 
-PUBLIC GLXDrawable glXCreateGLXPbufferSGIX(Display *dpy, GLXFBConfig config,
-			unsigned int width, unsigned int height,
-			int *attrib_list) {
-    (void) dpy;
-    (void) config;
-    (void) width;
-    (void) height;
-    (void) attrib_list;
-    return None;
+PUBLIC GLXDrawable
+glXCreateGLXPbufferSGIX(Display * dpy, GLXFBConfig config,
+                        unsigned int width, unsigned int height,
+                        int *attrib_list)
+{
+   (void) dpy;
+   (void) config;
+   (void) width;
+   (void) height;
+   (void) attrib_list;
+   return None;
 }
 
 #if 0
 /* GLX_SGIX_fbconfig */
-PUBLIC int glXGetFBConfigAttribSGIX (Display *dpy, void *config, int a, int *b) {
-     (void)dpy;
-     (void)config;
-     (void)a;
-     (void)b;
-     return 0;
+PUBLIC int
+glXGetFBConfigAttribSGIX(Display * dpy, void *config, int a, int *b)
+{
+   (void) dpy;
+   (void) config;
+   (void) a;
+   (void) b;
+   return 0;
 }
 
-PUBLIC void *glXChooseFBConfigSGIX(Display *dpy, int a, int *b, int *c) {
-    (void)dpy;
-    (void)a;
-    (void)b;
-    (void)c;
-    return NULL;
+PUBLIC void *
+glXChooseFBConfigSGIX(Display * dpy, int a, int *b, int *c)
+{
+   (void) dpy;
+   (void) a;
+   (void) b;
+   (void) c;
+   return NULL;
 }
 
-PUBLIC GLXPixmap glXCreateGLXPixmapWithConfigSGIX (Display *dpy, void *config, Pixmap p) {
-    (void)dpy;
-    (void)config;
-    (void)p;
-    return None;
+PUBLIC GLXPixmap
+glXCreateGLXPixmapWithConfigSGIX(Display * dpy, void *config, Pixmap p)
+{
+   (void) dpy;
+   (void) config;
+   (void) p;
+   return None;
 }
 
-PUBLIC GLXContext glXCreateContextWithConfigSGIX (Display *dpy, void *config, int a, 
-						  GLXContext b, Bool c) {
-    (void)dpy;
-    (void)config;
-    (void)a;
-    (void)b;
-    (void)c;
-    return NULL;
+PUBLIC GLXContext
+glXCreateContextWithConfigSGIX(Display * dpy, void *config, int a,
+                               GLXContext b, Bool c)
+{
+   (void) dpy;
+   (void) config;
+   (void) a;
+   (void) b;
+   (void) c;
+   return NULL;
 }
 
-PUBLIC XVisualInfo * glXGetVisualFromFBConfigSGIX (Display *dpy, void *config) {
-    (void)dpy;
-    (void)config;
-    return NULL;
+PUBLIC XVisualInfo *
+glXGetVisualFromFBConfigSGIX(Display * dpy, void *config)
+{
+   (void) dpy;
+   (void) config;
+   return NULL;
 }
 
-PUBLIC void *glXGetFBConfigFromVisualSGIX (Display *dpy, XVisualInfo *visinfo) {
-    (void)dpy;
-    (void)visinfo;
-    return NULL;
+PUBLIC void *
+glXGetFBConfigFromVisualSGIX(Display * dpy, XVisualInfo * visinfo)
+{
+   (void) dpy;
+   (void) visinfo;
+   return NULL;
 }
 #endif
 
 
-PUBLIC GLX_ALIAS_VOID(glXDestroyGLXPbufferSGIX,
-		      (Display *dpy, GLXDrawable pbuf),
-		      (dpy, pbuf),
-		      glXDestroyPbuffer)
-    
-PUBLIC GLX_ALIAS_VOID(glXSelectEventSGIX,
-		      (Display *dpy, GLXDrawable drawable, unsigned long mask),
-		      (dpy, drawable, mask),
-		      glXSelectEvent)
+PUBLIC
+GLX_ALIAS_VOID(glXDestroyGLXPbufferSGIX,
+               (Display * dpy, GLXDrawable pbuf),
+               (dpy, pbuf), glXDestroyPbuffer)
 
-PUBLIC GLX_ALIAS_VOID(glXGetSelectedEventSGIX,
-		      (Display *dpy, GLXDrawable drawable, unsigned long *mask),
-		      (dpy, drawable, mask),
-		      glXGetSelectedEvent)
+     PUBLIC GLX_ALIAS_VOID(glXSelectEventSGIX,
+                           (Display * dpy, GLXDrawable drawable,
+                            unsigned long mask), (dpy, drawable, mask),
+                           glXSelectEvent)
+
+     PUBLIC GLX_ALIAS_VOID(glXGetSelectedEventSGIX,
+                           (Display * dpy, GLXDrawable drawable,
+                            unsigned long *mask), (dpy, drawable, mask),
+                           glXGetSelectedEvent)

Modified: AppleSGLX/trunk/glx_error.c
===================================================================
--- AppleSGLX/trunk/glx_error.c	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/glx_error.c	2009-12-21 20:56:26 UTC (rev 386)
@@ -33,30 +33,33 @@
 #include "glxclient.h"
 #include "glx_error.h"
 
-extern XExtDisplayInfo *__glXFindDisplay(Display *dpy);
+extern XExtDisplayInfo *__glXFindDisplay(Display * dpy);
 
-void __glXSendError(Display *dpy, int errorCode, unsigned long resourceID,
-		    unsigned long minorCode, bool coreX11error) {
-    XExtDisplayInfo *info = __glXFindDisplay(dpy);
-    GLXContext gc = __glXGetCurrentContext();
-    xError error;
-  
-    LockDisplay(dpy);
+void
+__glXSendError(Display * dpy, int errorCode, unsigned long resourceID,
+               unsigned long minorCode, bool coreX11error)
+{
+   XExtDisplayInfo *info = __glXFindDisplay(dpy);
+   GLXContext gc = __glXGetCurrentContext();
+   xError error;
 
-    error.type = X_Error;
-    
-    if(coreX11error) {
-	error.errorCode = errorCode;
-    } else {
-	error.errorCode = info->codes->first_error + errorCode;
-    }
+   LockDisplay(dpy);
 
-    error.sequenceNumber = dpy->request;
-    error.resourceID = resourceID;
-    error.minorCode = minorCode;
-    error.majorCode = gc ? gc->majorOpcode : 0;
+   error.type = X_Error;
 
-    _XError(dpy, &error);
+   if (coreX11error) {
+      error.errorCode = errorCode;
+   }
+   else {
+      error.errorCode = info->codes->first_error + errorCode;
+   }
 
-    UnlockDisplay(dpy);    
+   error.sequenceNumber = dpy->request;
+   error.resourceID = resourceID;
+   error.minorCode = minorCode;
+   error.majorCode = gc ? gc->majorOpcode : 0;
+
+   _XError(dpy, &error);
+
+   UnlockDisplay(dpy);
 }

Modified: AppleSGLX/trunk/glx_error.h
===================================================================
--- AppleSGLX/trunk/glx_error.h	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/glx_error.h	2009-12-21 20:56:26 UTC (rev 386)
@@ -29,5 +29,5 @@
 #include <stdbool.h>
 #include <X11/Xlib.h>
 
-void __glXSendError(Display *dpy, int errorCode, unsigned long resourceID,
-		    unsigned long minorCode, bool coreX11error);
+void __glXSendError(Display * dpy, int errorCode, unsigned long resourceID,
+                    unsigned long minorCode, bool coreX11error);

Modified: AppleSGLX/trunk/glx_pbuffer.c
===================================================================
--- AppleSGLX/trunk/glx_pbuffer.c	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/glx_pbuffer.c	2009-12-21 20:56:26 UTC (rev 386)
@@ -57,15 +57,15 @@
  * Emit a warning when clients use GLX 1.3 functions on pre-1.3 systems.
  */
 static void
-warn_GLX_1_3(Display *dpy, const char *function_name)
+warn_GLX_1_3(Display * dpy, const char *function_name)
 {
    __GLXdisplayPrivate *priv = __glXInitialize(dpy);
 
    if (priv->minorVersion < 3) {
-      fprintf(stderr, 
-	      "WARNING: Application calling GLX 1.3 function \"%s\" "
-	      "when GLX 1.3 is not supported!  This is an application bug!\n",
-	      function_name);
+      fprintf(stderr,
+              "WARNING: Application calling GLX 1.3 function \"%s\" "
+              "when GLX 1.3 is not supported!  This is an application bug!\n",
+              function_name);
    }
 }
 
@@ -596,44 +596,44 @@
    WARN_ONCE_GLX_1_3(dpy, __func__);
 
 #ifdef __APPLE__
-    for(i = 0; attrib_list[i]; ++i) {
-       switch(attrib_list[i]) {
-       case GLX_PBUFFER_WIDTH:
-           width = attrib_list[i + 1];
-           ++i;
-           break;
-           
-       case GLX_PBUFFER_HEIGHT:
-           height = attrib_list[i + 1];
-           ++i;
-           break;
-           
-       case GLX_LARGEST_PBUFFER:
-           /* This is a hint we should probably handle, but how? */
-           ++i;
-           break;
+   for (i = 0; attrib_list[i]; ++i) {
+      switch (attrib_list[i]) {
+      case GLX_PBUFFER_WIDTH:
+         width = attrib_list[i + 1];
+         ++i;
+         break;
 
-       case GLX_PRESERVED_CONTENTS:
-           /* The contents are always preserved with AppleSGLX with CGL. */
-           ++i;
-           break;
-           
-       default:
-           return None;
-       }
-    }
+      case GLX_PBUFFER_HEIGHT:
+         height = attrib_list[i + 1];
+         ++i;
+         break;
 
-    if(apple_glx_pbuffer_create(dpy, config, width, height, &errorcode, 
-                               &result)) {
-       /* 
-        * apple_glx_pbuffer_create only sets the errorcode to core X11
-        * errors. 
-        */
-       __glXSendError(dpy, errorcode, 0, X_GLXCreatePbuffer, true);
-       
-       return None;
-    }
-    
+      case GLX_LARGEST_PBUFFER:
+         /* This is a hint we should probably handle, but how? */
+         ++i;
+         break;
+
+      case GLX_PRESERVED_CONTENTS:
+         /* The contents are always preserved with AppleSGLX with CGL. */
+         ++i;
+         break;
+
+      default:
+         return None;
+      }
+   }
+
+   if (apple_glx_pbuffer_create(dpy, config, width, height, &errorcode,
+                                &result)) {
+      /* 
+       * apple_glx_pbuffer_create only sets the errorcode to core X11
+       * errors. 
+       */
+      __glXSendError(dpy, errorcode, 0, X_GLXCreatePbuffer, true);
+
+      return None;
+   }
+
    return result;
 #else
    for (i = 0; attrib_list[i * 2]; i++) {
@@ -660,9 +660,9 @@
 glXDestroyPbuffer(Display * dpy, GLXPbuffer pbuf)
 {
 #ifdef __APPLE__
-    if(apple_glx_pbuffer_destroy(dpy, pbuf)) {
-       __glXSendError(dpy, GLXBadPbuffer, pbuf, X_GLXDestroyPbuffer, false);
-    }
+   if (apple_glx_pbuffer_destroy(dpy, pbuf)) {
+      __glXSendError(dpy, GLXBadPbuffer, pbuf, X_GLXDestroyPbuffer, false);
+   }
 #else
    DestroyPbuffer(dpy, pbuf);
 #endif
@@ -678,38 +678,39 @@
 {
    WARN_ONCE_GLX_1_3(dpy, __func__);
 #ifdef __APPLE__
-    Window root;
-    int x, y;
-    unsigned int width, height, bd, depth;
+   Window root;
+   int x, y;
+   unsigned int width, height, bd, depth;
 
-    if(apple_glx_pixmap_query(drawable, attribute, value))
-       return; /*done*/
+   if (apple_glx_pixmap_query(drawable, attribute, value))
+      return;                   /*done */
 
-    if(apple_glx_pbuffer_query(drawable, attribute, value))
-       return; /*done*/
+   if (apple_glx_pbuffer_query(drawable, attribute, value))
+      return;                   /*done */
 
-    /*
-     * The OpenGL spec states that we should report GLXBadDrawable if
-     * the drawable is invalid, however doing so would require that we
-     * use XSetErrorHandler(), which is known to not be thread safe.
-     * If we use a round-trip call to validate the drawable, there could
-     * be a race, so instead we just opt in favor of letting the
-     * XGetGeometry request fail with a GetGeometry request X error 
-     * rather than GLXBadDrawable, in what is hoped to be a rare
-     * case of an invalid drawable.  In practice most and possibly all
-     * X11 apps using GLX shouldn't notice a difference.
-     */
-    if(XGetGeometry(dpy, drawable, &root, &x, &y, &width, &height, &bd, &depth)) {
-       switch(attribute) {
-       case GLX_WIDTH:
-           *value = width;
-           break;
+   /*
+    * The OpenGL spec states that we should report GLXBadDrawable if
+    * the drawable is invalid, however doing so would require that we
+    * use XSetErrorHandler(), which is known to not be thread safe.
+    * If we use a round-trip call to validate the drawable, there could
+    * be a race, so instead we just opt in favor of letting the
+    * XGetGeometry request fail with a GetGeometry request X error 
+    * rather than GLXBadDrawable, in what is hoped to be a rare
+    * case of an invalid drawable.  In practice most and possibly all
+    * X11 apps using GLX shouldn't notice a difference.
+    */
+   if (XGetGeometry
+       (dpy, drawable, &root, &x, &y, &width, &height, &bd, &depth)) {
+      switch (attribute) {
+      case GLX_WIDTH:
+         *value = width;
+         break;
 
-       case GLX_HEIGHT:
-           *value = height;
-           break;
-       }
-    }
+      case GLX_HEIGHT:
+         *value = height;
+         break;
+      }
+   }
 #else
    GetDrawableAttribute(dpy, drawable, attribute, value);
 #endif
@@ -735,20 +736,20 @@
 glXSelectEvent(Display * dpy, GLXDrawable drawable, unsigned long mask)
 {
 #ifdef __APPLE__
-    XWindowAttributes xwattr;
-    
-    if(apple_glx_pbuffer_set_event_mask(drawable, mask))
-       return; /*done*/
+   XWindowAttributes xwattr;
 
-    /* 
-     * The spec allows a window, but currently there are no valid
-     * events for a window, so do nothing.
-     */
-    if(XGetWindowAttributes(dpy, drawable, &xwattr))
-       return; /*done*/
-    /* The drawable seems to be invalid.  Report an error. */
- 
-    __glXSendError(dpy, GLXBadDrawable, drawable, 
+   if (apple_glx_pbuffer_set_event_mask(drawable, mask))
+      return;                   /*done */
+
+   /* 
+    * The spec allows a window, but currently there are no valid
+    * events for a window, so do nothing.
+    */
+   if (XGetWindowAttributes(dpy, drawable, &xwattr))
+      return;                   /*done */
+   /* The drawable seems to be invalid.  Report an error. */
+
+   __glXSendError(dpy, GLXBadDrawable, drawable,
                   X_GLXChangeDrawableAttributes, false);
 #else
    CARD32 attribs[2];
@@ -768,23 +769,23 @@
 glXGetSelectedEvent(Display * dpy, GLXDrawable drawable, unsigned long *mask)
 {
 #ifdef __APPLE__
-    XWindowAttributes xwattr;
-    
-    if(apple_glx_pbuffer_get_event_mask(drawable, mask))
-       return; /*done*/
+   XWindowAttributes xwattr;
 
-    /* 
-     * The spec allows a window, but currently there are no valid
-     * events for a window, so do nothing, but set the mask to 0.
-     */
-    if(XGetWindowAttributes(dpy, drawable, &xwattr)) {
-       /* The window is valid, so set the mask to 0.*/
-       *mask = 0;
-       return; /*done*/
-    }
-    /* The drawable seems to be invalid.  Report an error. */
- 
-    __glXSendError(dpy, GLXBadDrawable, drawable, X_GLXGetDrawableAttributes,
+   if (apple_glx_pbuffer_get_event_mask(drawable, mask))
+      return;                   /*done */
+
+   /* 
+    * The spec allows a window, but currently there are no valid
+    * events for a window, so do nothing, but set the mask to 0.
+    */
+   if (XGetWindowAttributes(dpy, drawable, &xwattr)) {
+      /* The window is valid, so set the mask to 0. */
+      *mask = 0;
+      return;                   /*done */
+   }
+   /* The drawable seems to be invalid.  Report an error. */
+
+   __glXSendError(dpy, GLXBadDrawable, drawable, X_GLXGetDrawableAttributes,
                   true);
 #else
    unsigned int value;
@@ -808,12 +809,12 @@
    WARN_ONCE_GLX_1_3(dpy, __func__);
 
 #ifdef __APPLE__
-    const __GLcontextModes *modes = (const __GLcontextModes *)config;
+   const __GLcontextModes *modes = (const __GLcontextModes *) config;
 
-    if(apple_glx_pixmap_create(dpy, modes->screen, pixmap, modes))
-       return None;
+   if (apple_glx_pixmap_create(dpy, modes->screen, pixmap, modes))
+      return None;
 
-    return pixmap;
+   return pixmap;
 #else
    return CreateDrawable(dpy, (__GLcontextModes *) config,
                          (Drawable) pixmap, attrib_list, X_GLXCreatePixmap);
@@ -827,28 +828,28 @@
 {
    WARN_ONCE_GLX_1_3(dpy, __func__);
 #ifdef __APPLE__
-    XWindowAttributes xwattr;
-    XVisualInfo *visinfo;
+   XWindowAttributes xwattr;
+   XVisualInfo *visinfo;
 
-    (void)attrib_list; /*unused according to GLX 1.4*/
-    
-    XGetWindowAttributes(dpy, win, &xwattr);
-    
-    visinfo = glXGetVisualFromFBConfig(dpy, config);
+   (void) attrib_list;          /*unused according to GLX 1.4 */
 
-    if(NULL == visinfo) {
-       __glXSendError(dpy, GLXBadFBConfig, 0, X_GLXCreateWindow, false);
-       return None;
-    }
+   XGetWindowAttributes(dpy, win, &xwattr);
 
-    if(visinfo->visualid != XVisualIDFromVisual(xwattr.visual)) {
-       __glXSendError(dpy, BadMatch, 0, X_GLXCreateWindow, true);
-       return None;
-    }
+   visinfo = glXGetVisualFromFBConfig(dpy, config);
 
-    XFree(visinfo);
+   if (NULL == visinfo) {
+      __glXSendError(dpy, GLXBadFBConfig, 0, X_GLXCreateWindow, false);
+      return None;
+   }
 
-    return win;
+   if (visinfo->visualid != XVisualIDFromVisual(xwattr.visual)) {
+      __glXSendError(dpy, BadMatch, 0, X_GLXCreateWindow, true);
+      return None;
+   }
+
+   XFree(visinfo);
+
+   return win;
 #else
    return CreateDrawable(dpy, (__GLcontextModes *) config,
                          (Drawable) win, attrib_list, X_GLXCreateWindow);
@@ -861,8 +862,8 @@
 {
    WARN_ONCE_GLX_1_3(dpy, __func__);
 #ifdef __APPLE__
-    if(apple_glx_pixmap_destroy(dpy, pixmap))
-       __glXSendError(dpy, GLXBadPixmap, pixmap, X_GLXDestroyPixmap, false);
+   if (apple_glx_pixmap_destroy(dpy, pixmap))
+      __glXSendError(dpy, GLXBadPixmap, pixmap, X_GLXDestroyPixmap, false);
 #else
    DestroyDrawable(dpy, (GLXDrawable) pixmap, X_GLXDestroyPixmap);
 #endif
@@ -894,5 +895,4 @@
                (Display * dpy, GLXDrawable drawable,
                 unsigned long *mask), (dpy, drawable, mask),
                glXGetSelectedEvent)
-
 #endif

Modified: AppleSGLX/trunk/glx_query.c
===================================================================
--- AppleSGLX/trunk/glx_query.c	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/glx_query.c	2009-12-21 20:56:26 UTC (rev 386)
@@ -115,7 +115,10 @@
  * Query the Server GLX string.
  * This routine will allocate the necessay space for the string.
  */
-static char *
+#ifndef __APPLE__
+static 
+#endif
+char *
 __glXGetStringFromServer(Display * dpy, int opcode, CARD32 glxCode,
                          CARD32 for_whom, CARD32 name)
 {

Modified: AppleSGLX/trunk/glxclient.h
===================================================================
--- AppleSGLX/trunk/glxclient.h	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/glxclient.h	2009-12-21 20:56:26 UTC (rev 386)
@@ -53,19 +53,36 @@
 #include "GL/glxint.h"
 #include "GL/glxproto.h"
 #include "GL/internal/glcore.h"
-//#include "glapitable.h"
+#ifndef __APPLE__
+#include "glapi/glapitable.h"
+#endif
 #include "glxhash.h"
-#if defined( USE_XTHREADS )
-# include <X11/Xthreads.h>
-#elif defined( PTHREADS )
+#if defined( PTHREADS )
 # include <pthread.h>
 #endif
 
 #include "glxextensions.h"
 
-#define GLX_MAJOR_VERSION	1	/* current version numbers */
-#define GLX_MINOR_VERSION	4
 
+/* If we build the library with gcc's -fvisibility=hidden flag, we'll
+ * use the PUBLIC macro to mark functions that are to be exported.
+ *
+ * We also need to define a USED attribute, so the optimizer doesn't
+ * inline a static function that we later use in an alias. - ajax
+ */
+#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303
+#  define PUBLIC __attribute__((visibility("default")))
+#  define USED __attribute__((used))
+#else
+#  define PUBLIC
+#  define USED
+#endif
+
+
+
+#define GLX_MAJOR_VERSION 1       /* current version numbers */
+#define GLX_MINOR_VERSION 4
+
 #define __GLX_MAX_TEXTURE_UNITS 32
 
 typedef struct __GLXscreenConfigsRec __GLXscreenConfigs;
@@ -78,7 +95,7 @@
 
 #ifdef GLX_DIRECT_RENDERING
 
-#define containerOf(ptr, type, member)			\
+#define containerOf(ptr, type, member)              \
     (type *)( (char *)ptr - offsetof(type,member) )
 
 #include <GL/internal/dri_interface.h>
@@ -95,124 +112,140 @@
 
 #include "glxextensions.h"
 
-struct __GLXDRIdisplayRec {
+struct __GLXDRIdisplayRec
+{
     /**
      * Method to destroy the private DRI display data.
      */
-    void (*destroyDisplay)(__GLXDRIdisplay *display);
+   void (*destroyDisplay) (__GLXDRIdisplay * display);
 
-    __GLXDRIscreen *(*createScreen)(__GLXscreenConfigs *psc, int screen,
-				    __GLXdisplayPrivate *priv);
+   __GLXDRIscreen *(*createScreen) (__GLXscreenConfigs * psc, int screen,
+                                    __GLXdisplayPrivate * priv);
 };
 
-struct __GLXDRIscreenRec {
+struct __GLXDRIscreenRec
+{
 
-    void (*destroyScreen)(__GLXscreenConfigs *psc);
+   void (*destroyScreen) (__GLXscreenConfigs * psc);
 
-    __GLXDRIcontext *(*createContext)(__GLXscreenConfigs *psc,
-				      const __GLcontextModes *mode,
-				      GLXContext gc,
-				      GLXContext shareList, int renderType);
-	
-    __GLXDRIdrawable *(*createDrawable)(__GLXscreenConfigs *psc,
-					XID drawable,
-					GLXDrawable glxDrawable,
-					const __GLcontextModes *modes);
+   __GLXDRIcontext *(*createContext) (__GLXscreenConfigs * psc,
+                                      const __GLcontextModes * mode,
+                                      GLXContext gc,
+                                      GLXContext shareList, int renderType);
+
+   __GLXDRIdrawable *(*createDrawable) (__GLXscreenConfigs * psc,
+                                        XID drawable,
+                                        GLXDrawable glxDrawable,
+                                        const __GLcontextModes * modes);
+
+   void (*swapBuffers) (__GLXDRIdrawable * pdraw);
+   void (*copySubBuffer) (__GLXDRIdrawable * pdraw,
+                          int x, int y, int width, int height);
+   void (*waitX) (__GLXDRIdrawable * pdraw);
+   void (*waitGL) (__GLXDRIdrawable * pdraw);
 };
 
-struct __GLXDRIcontextRec {
-    void (*destroyContext)(__GLXDRIcontext *context, __GLXscreenConfigs *psc,
-			   Display *dpy);
-    Bool (*bindContext)(__GLXDRIcontext *context,
-			__GLXDRIdrawable *pdraw,
-			__GLXDRIdrawable *pread);
-    
-    void (*unbindContext)(__GLXDRIcontext *context);
+struct __GLXDRIcontextRec
+{
+   void (*destroyContext) (__GLXDRIcontext * context,
+                           __GLXscreenConfigs * psc, Display * dpy);
+     Bool(*bindContext) (__GLXDRIcontext * context, __GLXDRIdrawable * pdraw,
+                         __GLXDRIdrawable * pread);
+
+   void (*unbindContext) (__GLXDRIcontext * context);
 };
 
-struct __GLXDRIdrawableRec {
-    void (*destroyDrawable)(__GLXDRIdrawable *drawable);
+struct __GLXDRIdrawableRec
+{
+   void (*destroyDrawable) (__GLXDRIdrawable * drawable);
 
-    XID xDrawable;
-    XID drawable;
-    __GLXscreenConfigs *psc;
-    __DRIdrawable *driDrawable;
-    GLenum textureTarget;
+   XID xDrawable;
+   XID drawable;
+   __GLXscreenConfigs *psc;
+   GLenum textureTarget;
+   __DRIdrawable *driDrawable;
+   GLenum textureFormat;        /* EXT_texture_from_pixmap support */
 };
 
 /*
 ** Function to create and DRI display data and initialize the display
 ** dependent methods.
 */
-extern __GLXDRIdisplay *driswCreateDisplay(Display *dpy);
-extern __GLXDRIdisplay *driCreateDisplay(Display *dpy);
+extern __GLXDRIdisplay *driswCreateDisplay(Display * dpy);
+extern __GLXDRIdisplay *driCreateDisplay(Display * dpy);
+extern __GLXDRIdisplay *dri2CreateDisplay(Display * dpy);
 
-extern void DRI_glXUseXFont( Font font, int first, int count, int listbase );
+extern void DRI_glXUseXFont(Font font, int first, int count, int listbase);
 
 /*
 ** Functions to obtain driver configuration information from a direct
 ** rendering client application
 */
-extern const char *glXGetScreenDriver (Display *dpy, int scrNum);
+extern const char *glXGetScreenDriver(Display * dpy, int scrNum);
 
-extern const char *glXGetDriverConfig (const char *driverName);
+extern const char *glXGetDriverConfig(const char *driverName);
 
 #endif
 
-/*Apple*/
+#ifdef __APPLE__
 extern void DRI_glXUseXFont( Font font, int first, int count, int listbase );
+#endif
 
 /************************************************************************/
 
 #define __GL_CLIENT_ATTRIB_STACK_DEPTH 16
 
-typedef struct __GLXpixelStoreModeRec {
-    GLboolean swapEndian;
-    GLboolean lsbFirst;
-    GLuint rowLength;
-    GLuint imageHeight;
-    GLuint imageDepth;
-    GLuint skipRows;
-    GLuint skipPixels;
-    GLuint skipImages;
-    GLuint alignment;
+typedef struct __GLXpixelStoreModeRec
+{
+   GLboolean swapEndian;
+   GLboolean lsbFirst;
+   GLuint rowLength;
+   GLuint imageHeight;
+   GLuint imageDepth;
+   GLuint skipRows;
+   GLuint skipPixels;
+   GLuint skipImages;
+   GLuint alignment;
 } __GLXpixelStoreMode;
 
 
-typedef struct __GLXattributeRec {
-    GLuint mask;
+typedef struct __GLXattributeRec
+{
+   GLuint mask;
 
     /**
      * Pixel storage state.  Most of the pixel store mode state is kept
      * here and used by the client code to manage the packing and
      * unpacking of data sent to/received from the server.
      */
-    __GLXpixelStoreMode storePack, storeUnpack;
+   __GLXpixelStoreMode storePack, storeUnpack;
 
     /**
      * Is EXT_vertex_array / GL 1.1 DrawArrays protocol specifically
      * disabled?
      */
-    GLboolean NoDrawArraysProtocol;
-    
+   GLboolean NoDrawArraysProtocol;
+
     /**
      * Vertex Array storage state.  The vertex array component
      * state is stored here and is used to manage the packing of
      * DrawArrays data sent to the server.
      */
-    struct array_state_vector * array_state;
+   struct array_state_vector *array_state;
 } __GLXattribute;
 
-typedef struct __GLXattributeMachineRec {
-	__GLXattribute *stack[__GL_CLIENT_ATTRIB_STACK_DEPTH];
-	__GLXattribute **stackPointer;
+typedef struct __GLXattributeMachineRec
+{
+   __GLXattribute *stack[__GL_CLIENT_ATTRIB_STACK_DEPTH];
+   __GLXattribute **stackPointer;
 } __GLXattributeMachine;
 
 /**
  * GLX state that needs to be kept on the client.  One of these records
  * exist for each context that has been made current by this client.
  */
-struct __GLXcontextRec {
+struct __GLXcontextRec
+{
     /**
      * \name Drawing command buffer.
      *
@@ -229,13 +262,13 @@
      * These must be the first 6 fields since they are static initialized
      * in the dummy context in glxext.c
      */
-    /*@{*/
-    GLubyte *buf;
-    GLubyte *pc;
-    GLubyte *limit;
-    GLubyte *bufEnd;
-    GLint bufSize;
-    /*@}*/
+   /*@{ */
+   GLubyte *buf;
+   GLubyte *pc;
+   GLubyte *limit;
+   GLubyte *bufEnd;
+   GLint bufSize;
+   /*@} */
 
     /**
      * The XID of this rendering context.  When the context is created a
@@ -243,24 +276,24 @@
      * destroyed but is still current to some thread. In this case the
      * context will be freed on next MakeCurrent.
      */
-    XID xid;
+   XID xid;
 
     /**
      * The XID of the \c shareList context.
      */
-    XID share_xid;
+   XID share_xid;
 
     /**
      * Screen number.
      */
-    GLint screen;
-    __GLXscreenConfigs *psc;
+   GLint screen;
+   __GLXscreenConfigs *psc;
 
     /**
      * \c GL_TRUE if the context was created with ImportContext, which
      * means the server-side context was created by another X client.
      */
-    GLboolean imported;
+   GLboolean imported;
 
     /**
      * The context tag returned by MakeCurrent when this context is made
@@ -270,7 +303,7 @@
      * \c WaitX, \c WaitGL, \c UseXFont, and \c MakeCurrent (for the old
      * context)).
      */
-    GLXContextTag currentContextTag;
+   GLXContextTag currentContextTag;
 
     /**
      * \name Rendering mode
@@ -279,11 +312,11 @@
      * When \c glRenderMode is called, the buffer associated with the
      * previous rendering mode (feedback or select) is filled.
      */
-    /*@{*/
-    GLenum renderMode;
-    GLfloat *feedbackBuf;
-    GLuint *selectBuf;
-    /*@}*/
+   /*@{ */
+   GLenum renderMode;
+   GLfloat *feedbackBuf;
+   GLuint *selectBuf;
+   /*@} */
 
     /**
      * This is \c GL_TRUE if the pixel unpack modes are such that an image
@@ -291,43 +324,43 @@
      * still be true that the server will have to do some work.  This
      * just promises that a straight copy will fetch the correct bytes.
      */
-    GLboolean fastImageUnpack;
+   GLboolean fastImageUnpack;
 
     /**
      * Fill newImage with the unpacked form of \c oldImage getting it
      * ready for transport to the server.
      */
-    void (*fillImage)(__GLXcontext*, GLint, GLint, GLint, GLint, GLenum,
-		      GLenum, const GLvoid*, GLubyte*, GLubyte*);
+   void (*fillImage) (__GLXcontext *, GLint, GLint, GLint, GLint, GLenum,
+                      GLenum, const GLvoid *, GLubyte *, GLubyte *);
 
     /**
      * Client side attribs.
      */
-    __GLXattributeMachine attributes;
+   __GLXattributeMachine attributes;
 
     /**
      * Client side error code.  This is set when client side gl API
      * routines need to set an error because of a bad enumerant or
      * running out of memory, etc.
      */
-    GLenum error;
+   GLenum error;
 
     /**
      * Whether this context does direct rendering.
      */
-    Bool isDirect;
+   Bool isDirect;
 
     /**
      * \c dpy of current display for this context.  Will be \c NULL if not
      * current to any display, or if this is the "dummy context".
      */
-    Display *currentDpy;
+   Display *currentDpy;
 
     /**
      * The current drawable for this context.  Will be None if this
      * context is not current to any drawable.  currentReadable is below.
      */
-    GLXDrawable currentDrawable;
+   GLXDrawable currentDrawable;
 
     /**
      * \name GL Constant Strings
@@ -336,38 +369,38 @@
      * These pertain to GL attributes, not to be confused with
      * GLX versioning attributes.
      */
-    /*@{*/
-    GLubyte *vendor;
-    GLubyte *renderer;
-    GLubyte *version;
-    GLubyte *extensions;
-    /*@}*/
+   /*@{ */
+   GLubyte *vendor;
+   GLubyte *renderer;
+   GLubyte *version;
+   GLubyte *extensions;
+   /*@} */
 
     /**
      * Record the dpy this context was created on for later freeing
      */
-    Display *createDpy;
+   Display *createDpy;
 
     /**
      * Maximum small render command size.  This is the smaller of 64k and
      * the size of the above buffer.
      */
-    GLint maxSmallRenderCommandSize;
+   GLint maxSmallRenderCommandSize;
 
     /**
      * Major opcode for the extension.  Copied here so a lookup isn't
      * needed.
      */
-    GLint majorOpcode;
+   GLint majorOpcode;
 
     /**
      * Pointer to the mode used to create this context.
      */
-    const __GLcontextModes * mode;
+   const __GLcontextModes *mode;
 
 #ifdef GLX_DIRECT_RENDERING
-    __GLXDRIcontext *driContext;
-    __DRIcontext *__driContext;
+   __GLXDRIcontext *driContext;
+   __DRIcontext *__driContext;
 #endif
 
     /**
@@ -376,22 +409,22 @@
      *
      * \since Internal API version 20030606.
      */
-    GLXDrawable currentReadable;
+   GLXDrawable currentReadable;
 
-   /** 
+   /**
     * Pointer to client-state data that is private to libGL.  This is only
     * used for indirect rendering contexts.
     *
     * No internal API version change was made for this change.  Client-side
     * drivers should NEVER use this data or even care that it exists.
     */
-   void * client_state_private;
+   void *client_state_private;
 
    /**
     * Stored value for \c glXQueryContext attribute \c GLX_RENDER_TYPE.
     */
    int renderType;
-    
+
    /**
     * \name Raw server GL version
     *
@@ -399,21 +432,28 @@
     * returned by the server, and it may not reflect what is actually
     * supported (or reported) by the client-side library.
     */
-    /*@{*/
+   /*@{ */
    int server_major;        /**< Major version number. */
    int server_minor;        /**< Minor version number. */
-    /*@}*/
+   /*@} */
 
-   char gl_extension_bits[ __GL_EXT_BYTES ];
+   /**
+    * Thread ID we're currently current in. Zero if none.
+    */
+   unsigned long thread_id;
 
+   char gl_extension_bits[__GL_EXT_BYTES];
+
+#ifdef __APPLE__
    void *apple;
    Bool do_destroy;
+#endif
 };
 
-#define __glXSetError(gc,code) \
-    if (!(gc)->error) {	       \
-	(gc)->error = code;    \
-    }
+#define __glXSetError(gc,code)  \
+   if (!(gc)->error) {          \
+      (gc)->error = code;       \
+   }
 
 extern void __glFreeAttributeState(__GLXcontext *);
 
@@ -424,7 +464,7 @@
  * that will use the GLXRender GLX command.  In this case it is
  * \c glPolygonStipple.
  */
-#define __GLX_MAX_SMALL_RENDER_CMD_SIZE	156
+#define __GLX_MAX_SMALL_RENDER_CMD_SIZE 156
 
 /**
  * To keep the implementation fast, the code uses a "limit" pointer
@@ -436,76 +476,84 @@
  * efficacy of the buffer.  The "+32" is just to keep the code working
  * in case somebody counts wrong.
  */
-#define __GLX_BUFFER_LIMIT_SIZE	(__GLX_MAX_SMALL_RENDER_CMD_SIZE + 32)
+#define __GLX_BUFFER_LIMIT_SIZE (__GLX_MAX_SMALL_RENDER_CMD_SIZE + 32)
 
 /**
  * This implementation uses a smaller threshold for switching
  * to the RenderLarge protocol than the protcol requires so that
  * large copies don't occur.
  */
-#define __GLX_RENDER_CMD_SIZE_LIMIT	4096
+#define __GLX_RENDER_CMD_SIZE_LIMIT 4096
 
 /**
  * One of these records exists per screen of the display.  It contains
  * a pointer to the config data for that screen (if the screen supports GL).
  */
-struct __GLXscreenConfigsRec {
+struct __GLXscreenConfigsRec
+{
     /**
      * GLX extension string reported by the X-server.
      */
-    const char *serverGLXexts;
+   const char *serverGLXexts;
 
     /**
      * GLX extension string to be reported to applications.  This is the
      * set of extensions that the application can actually use.
      */
-    char *effectiveGLXexts;
+   char *effectiveGLXexts;
 
 #ifdef GLX_DIRECT_RENDERING
     /**
      * Per screen direct rendering interface functions and data.
      */
-    __DRIscreen *__driScreen;
-    const __DRIcoreExtension *core;
-    const __DRIlegacyExtension *legacy;
-    const __DRIswrastExtension *swrast;
-    __glxHashTable *drawHash;
-    Display *dpy;
-    int scr, fd;
-    void *driver;
+   __DRIscreen *__driScreen;
+   const __DRIcoreExtension *core;
+   const __DRIlegacyExtension *legacy;
+   const __DRIswrastExtension *swrast;
+   const __DRIdri2Extension *dri2;
+   __glxHashTable *drawHash;
+   Display *dpy;
+   int scr, fd;
+   void *driver;
 
-    __GLXDRIscreen *driScreen;
+   __GLXDRIscreen *driScreen;
 
+   const __DRIconfig **driver_configs;
+
 #ifdef __DRI_COPY_SUB_BUFFER
-    const __DRIcopySubBufferExtension *copySubBuffer;
+   const __DRIcopySubBufferExtension *driCopySubBuffer;
 #endif
 
 #ifdef __DRI_SWAP_CONTROL
-    const __DRIswapControlExtension *swapControl;
+   const __DRIswapControlExtension *swapControl;
 #endif
 
 #ifdef __DRI_ALLOCATE
-    const __DRIallocateExtension *allocate;
+   const __DRIallocateExtension *allocate;
 #endif
 
 #ifdef __DRI_FRAME_TRACKING
-    const __DRIframeTrackingExtension *frameTracking;
+   const __DRIframeTrackingExtension *frameTracking;
 #endif
 
 #ifdef __DRI_MEDIA_STREAM_COUNTER
-    const __DRImediaStreamCounterExtension *msc;
+   const __DRImediaStreamCounterExtension *msc;
 #endif
 
 #ifdef __DRI_TEX_BUFFER
-    const __DRItexBufferExtension *texBuffer;
+   const __DRItexBufferExtension *texBuffer;
 #endif
 
+#ifdef __DRI2_FLUSH
+   const __DRI2flushExtension *f;
 #endif
 
+#endif
+
     /**
      * Linked list of glx visuals and  fbconfigs for this screen.
      */
-    __GLcontextModes *visuals, *configs;
+   __GLcontextModes *visuals, *configs;
 
     /**
      * Per-screen dynamic GLX extension tracking.  The \c direct_support
@@ -514,10 +562,10 @@
      * this field.  The \c __GLXscreenConfigs structure is not used outside
      * libGL.
      */
-    /*@{*/
-    unsigned char direct_support[8];
-    GLboolean ext_list_first_time;
-    /*@}*/
+   /*@{ */
+   unsigned char direct_support[8];
+   GLboolean ext_list_first_time;
+   /*@} */
 
 };
 
@@ -525,76 +573,88 @@
  * Per display private data.  One of these records exists for each display
  * that is using the OpenGL (GLX) extension.
  */
-struct __GLXdisplayPrivateRec {
+struct __GLXdisplayPrivateRec
+{
     /**
      * Back pointer to the display
      */
-    Display *dpy;
+   Display *dpy;
 
     /**
      * The \c majorOpcode is common to all connections to the same server.
      * It is also copied into the context structure.
      */
-    int majorOpcode;
+   int majorOpcode;
 
     /**
      * \name Server Version
      *
      * Major and minor version returned by the server during initialization.
      */
-    /*@{*/
-    int majorVersion, minorVersion;
-    /*@}*/
+   /*@{ */
+   int majorVersion, minorVersion;
+   /*@} */
 
     /**
      * \name Storage for the servers GLX vendor and versions strings.
-     * 
+     *
      * These are the same for all screens on this display. These fields will
      * be filled in on demand.
      */
-    /*@{*/
-    const char *serverGLXvendor;
-    const char *serverGLXversion;
-    /*@}*/
+   /*@{ */
+   const char *serverGLXvendor;
+   const char *serverGLXversion;
+   /*@} */
 
     /**
      * Configurations of visuals for all screens on this display.
      * Also, per screen data which now includes the server \c GLX_EXTENSION
      * string.
      */
-    __GLXscreenConfigs *screenConfigs;
+   __GLXscreenConfigs *screenConfigs;
 
 #ifdef GLX_DIRECT_RENDERING
     /**
      * Per display direct rendering interface functions and data.
      */
-    __GLXDRIdisplay *driswDisplay;
-    __GLXDRIdisplay *driDisplay;
+   __GLXDRIdisplay *driswDisplay;
+   __GLXDRIdisplay *driDisplay;
+   __GLXDRIdisplay *dri2Display;
 #endif
 };
 
 
-extern GLubyte *__glXFlushRenderBuffer(__GLXcontext*, GLubyte*);
+extern GLubyte *__glXFlushRenderBuffer(__GLXcontext *, GLubyte *);
 
+#ifndef __APPLE__
+extern void __glXSendLargeChunk(__GLXcontext * gc, GLint requestNumber,
+                                GLint totalRequests,
+                                const GLvoid * data, GLint dataLen);
 
+extern void __glXSendLargeCommand(__GLXcontext *, const GLvoid *, GLint,
+                                  const GLvoid *, GLint);
+#endif
+
 /* Initialize the GLX extension for dpy */
-extern __GLXdisplayPrivate *__glXInitialize(Display*);
+extern __GLXdisplayPrivate *__glXInitialize(Display *);
 
+extern void __glXPreferEGL(int state);
+
 /************************************************************************/
 
 extern int __glXDebug;
 
 /* This is per-thread storage in an MT environment */
-#if defined( USE_XTHREADS ) || defined( PTHREADS )
+#if defined( PTHREADS )
 
-extern void __glXSetCurrentContext(__GLXcontext *c);
+extern void __glXSetCurrentContext(__GLXcontext * c);
 
 # if defined( GLX_USE_TLS )
 
-extern __thread void * __glX_tls_Context
-    __attribute__((tls_model("initial-exec")));
+extern __thread void *__glX_tls_Context
+   __attribute__ ((tls_model("initial-exec")));
 
-#  define __glXGetCurrentContext()	__glX_tls_Context
+#  define __glXGetCurrentContext() __glX_tls_Context
 
 # else
 
@@ -605,25 +665,21 @@
 #else
 
 extern __GLXcontext *__glXcurrentContext;
-#define __glXGetCurrentContext()	__glXcurrentContext
-#define __glXSetCurrentContext(gc)	__glXcurrentContext = gc
+#define __glXGetCurrentContext() __glXcurrentContext
+#define __glXSetCurrentContext(gc) __glXcurrentContext = gc
 
-#endif /* defined( USE_XTHREADS ) || defined( PTHREADS ) */
+#endif /* defined( PTHREADS ) */
 
 extern void __glXSetCurrentContextNull(void);
 
-extern void __glXFreeContext(__GLXcontext*);
+extern void __glXFreeContext(__GLXcontext *);
 
 
 /*
 ** Global lock for all threads in this address space using the GLX
 ** extension
 */
-#if defined( USE_XTHREADS )
-extern xmutex_rec __glXmutex;
-#define __glXLock()    xmutex_lock(&__glXmutex)
-#define __glXUnlock()  xmutex_unlock(&__glXmutex)
-#elif defined( PTHREADS )
+#if defined( PTHREADS )
 extern pthread_mutex_t __glXmutex;
 #define __glXLock()    pthread_mutex_lock(&__glXmutex)
 #define __glXUnlock()  pthread_mutex_unlock(&__glXmutex)
@@ -635,7 +691,7 @@
 /*
 ** Setup for a command.  Initialize the extension for dpy if necessary.
 */
-extern CARD8 __glXSetupForCommand(Display *dpy);
+extern CARD8 __glXSetupForCommand(Display * dpy);
 
 /************************************************************************/
 
@@ -646,9 +702,11 @@
 extern const GLuint __glXDefaultPixelStore[9];
 
 /* Send an image to the server using RenderLarge. */
-extern void __glXSendLargeImage(__GLXcontext *gc, GLint compsize, GLint dim,
-    GLint width, GLint height, GLint depth, GLenum format, GLenum type,
-    const GLvoid *src, GLubyte *pc, GLubyte *modes);
+extern void __glXSendLargeImage(__GLXcontext * gc, GLint compsize, GLint dim,
+                                GLint width, GLint height, GLint depth,
+                                GLenum format, GLenum type,
+                                const GLvoid * src, GLubyte * pc,
+                                GLubyte * modes);
 
 /* Return the size, in bytes, of some pixel data */
 extern GLint __glImageSize(GLint, GLint, GLint, GLenum, GLenum, GLenum);
@@ -668,23 +726,23 @@
 ** updated to contain the modes needed by the server to decode the
 ** sent data.
 */
-extern void __glFillImage(__GLXcontext*, GLint, GLint, GLint, GLint, GLenum,
-			  GLenum, const GLvoid*, GLubyte*, GLubyte*);
+extern void __glFillImage(__GLXcontext *, GLint, GLint, GLint, GLint, GLenum,
+                          GLenum, const GLvoid *, GLubyte *, GLubyte *);
 
 /* Copy map data with a stride into a packed buffer */
 extern void __glFillMap1f(GLint, GLint, GLint, const GLfloat *, GLubyte *);
 extern void __glFillMap1d(GLint, GLint, GLint, const GLdouble *, GLubyte *);
 extern void __glFillMap2f(GLint, GLint, GLint, GLint, GLint,
-			  const GLfloat *, GLfloat *);
+                          const GLfloat *, GLfloat *);
 extern void __glFillMap2d(GLint, GLint, GLint, GLint, GLint,
-			  const GLdouble *, GLdouble *);
+                          const GLdouble *, GLdouble *);
 
 /*
 ** Empty an image out of the reply buffer into the clients memory applying
 ** the pack modes to pack back into the clients requested format.
 */
-extern void __glEmptyImage(__GLXcontext*, GLint, GLint, GLint, GLint, GLenum,
-		           GLenum, const GLubyte *, GLvoid *);
+extern void __glEmptyImage(__GLXcontext *, GLint, GLint, GLint, GLint, GLenum,
+                           GLenum, const GLubyte *, GLvoid *);
 
 
 /*
@@ -697,7 +755,7 @@
 ** Inform the Server of the major and minor numbers and of the client
 ** libraries extension string.
 */
-extern void __glXClientInfo (  Display *dpy, int opcode );
+extern void __glXClientInfo(Display * dpy, int opcode);
 
 /************************************************************************/
 
@@ -705,18 +763,22 @@
 ** Declarations that should be in Xlib
 */
 #ifdef __GL_USE_OUR_PROTOTYPES
-extern void _XFlush(Display*);
-extern Status _XReply(Display*, xReply*, int, Bool);
-extern void _XRead(Display*, void*, long);
-extern void _XSend(Display*, const void*, long);
+extern void _XFlush(Display *);
+extern Status _XReply(Display *, xReply *, int, Bool);
+extern void _XRead(Display *, void *, long);
+extern void _XSend(Display *, const void *, long);
 #endif
 
 
-extern void __glXInitializeVisualConfigFromTags( __GLcontextModes *config,
-    int count, const INT32 *bp, Bool tagged_only, Bool fbconfig_style_tags );
+extern void __glXInitializeVisualConfigFromTags(__GLcontextModes * config,
+                                                int count, const INT32 * bp,
+                                                Bool tagged_only,
+                                                Bool fbconfig_style_tags);
 
-extern char * __glXGetStringFromServer( Display * dpy, int opcode,
-    CARD32 glxCode, CARD32 for_whom, CARD32 name );
+extern char *__glXQueryServerString(Display * dpy, int opcode,
+                                    CARD32 screen, CARD32 name);
+extern char *__glXGetString(Display * dpy, int opcode,
+                            CARD32 screen, CARD32 name);
 
 extern char *__glXstrdup(const char *str);
 
@@ -725,15 +787,16 @@
 extern const char __glXGLClientExtensions[];
 
 /* Get the unadjusted system time */
-extern int __glXGetUST( int64_t * ust );
+extern int __glXGetUST(int64_t * ust);
 
 extern GLboolean __glXGetMscRateOML(Display * dpy, GLXDrawable drawable,
-				    int32_t * numerator, int32_t * denominator);
+                                    int32_t * numerator,
+                                    int32_t * denominator);
 
 #ifdef GLX_DIRECT_RENDERING
 GLboolean
-__driGetMscRateOML(__DRIdrawable *draw,
-		   int32_t *numerator, int32_t *denominator, void *private);
+__driGetMscRateOML(__DRIdrawable * draw,
+                   int32_t * numerator, int32_t * denominator, void *private);
 #endif
 
 #endif /* !__GLX_client_h__ */

Modified: AppleSGLX/trunk/glxcmds.c
===================================================================
--- AppleSGLX/trunk/glxcmds.c	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/glxcmds.c	2009-12-21 20:56:26 UTC (rev 386)
@@ -45,18 +45,24 @@
 static const char __glXGLXClientVendorName[] = "SGI";
 static const char __glXGLXClientVersion[] = "1.4";
 
+// Nuke when rebase is done
+char *
+__glXGetStringFromServer(Display * dpy, int opcode, CARD32 glxCode,
+                         CARD32 for_whom, CARD32 name);
 
+
 /****************************************************************************/
 
 #ifdef GLX_DIRECT_RENDERING
 
 static Bool windowExistsFlag;
-static int windowExistsErrorHandler(Display *dpy, XErrorEvent *xerr)
+static int
+windowExistsErrorHandler(Display * dpy, XErrorEvent * xerr)
 {
-    if (xerr->error_code == BadWindow) {
-	windowExistsFlag = GL_FALSE;
-    }
-    return 0;
+   if (xerr->error_code == BadWindow) {
+      windowExistsFlag = GL_FALSE;
+   }
+   return 0;
 }
 
 /**
@@ -66,37 +72,39 @@
  * \param dpy    Display to destroy drawables for
  * \param screen Screen number to destroy drawables for
  */
-static void GarbageCollectDRIDrawables(Display *dpy, __GLXscreenConfigs *sc)
+static void
+GarbageCollectDRIDrawables(Display * dpy, __GLXscreenConfigs * sc)
 {
-    XID draw;
-    __GLXDRIdrawable *pdraw;
-    XWindowAttributes xwa;
-    int (*oldXErrorHandler)(Display *, XErrorEvent *);
+   XID draw;
+   __GLXDRIdrawable *pdraw;
+   XWindowAttributes xwa;
+   int (*oldXErrorHandler) (Display *, XErrorEvent *);
 
-    /* Set no-op error handler so Xlib doesn't bail out if the windows
-     * has alreay been destroyed on the server. */
-    XSync(dpy, GL_FALSE);
-    oldXErrorHandler = XSetErrorHandler(windowExistsErrorHandler);
+   /* Set no-op error handler so Xlib doesn't bail out if the windows
+    * has alreay been destroyed on the server. */
+   XSync(dpy, GL_FALSE);
+   oldXErrorHandler = XSetErrorHandler(windowExistsErrorHandler);
 
-    if (__glxHashFirst(sc->drawHash, &draw, (void *)&pdraw) == 1) {
-	do {
-	    windowExistsFlag = GL_TRUE;
-	    XGetWindowAttributes(dpy, draw, &xwa); /* dummy request */
-	    if (!windowExistsFlag) {
-		/* Destroy the local drawable data, if the drawable no
-		   longer exists in the Xserver */
-		(*pdraw->destroyDrawable)(pdraw);
-                __glxHashDelete(sc->drawHash, draw);
-	    }
-	} while (__glxHashNext(sc->drawHash, &draw, (void *)&pdraw) == 1);
-    }
+   if (__glxHashFirst(sc->drawHash, &draw, (void *) &pdraw) == 1) {
+      do {
+         windowExistsFlag = GL_TRUE;
+         XGetWindowAttributes(dpy, draw, &xwa); /* dummy request */
+         if (!windowExistsFlag) {
+            /* Destroy the local drawable data, if the drawable no
+               longer exists in the Xserver */
+            (*pdraw->destroyDrawable) (pdraw);
+            __glxHashDelete(sc->drawHash, draw);
+         }
+      } while (__glxHashNext(sc->drawHash, &draw, (void *) &pdraw) == 1);
+   }
 
-    XSync(dpy, GL_FALSE);
-    XSetErrorHandler(oldXErrorHandler);
+   XSync(dpy, GL_FALSE);
+   XSetErrorHandler(oldXErrorHandler);
 }
 
-extern __GLXDRIdrawable *
-GetGLXDRIDrawable(Display *dpy, GLXDrawable drawable, int * const scrn_num);
+extern __GLXDRIdrawable *GetGLXDRIDrawable(Display * dpy,
+                                           GLXDrawable drawable,
+                                           int *const scrn_num);
 
 /**
  * Get the __DRIdrawable for the drawable associated with a GLXContext
@@ -108,30 +116,30 @@
  *           the drawable is not associated with a direct-rendering context.
  */
 _X_HIDDEN __GLXDRIdrawable *
-GetGLXDRIDrawable(Display *dpy, GLXDrawable drawable, int * const scrn_num)
+GetGLXDRIDrawable(Display * dpy, GLXDrawable drawable, int *const scrn_num)
 {
-    __GLXdisplayPrivate *priv = __glXInitialize(dpy);
-    __GLXDRIdrawable *pdraw;
-    const unsigned  screen_count = ScreenCount(dpy);
-    unsigned   i;
-    __GLXscreenConfigs *psc;
+   __GLXdisplayPrivate *priv = __glXInitialize(dpy);
+   __GLXDRIdrawable *pdraw;
+   const unsigned screen_count = ScreenCount(dpy);
+   unsigned i;
+   __GLXscreenConfigs *psc;
 
-    if (priv == NULL)
-	return NULL;
-    
-    for (i = 0; i < screen_count; i++) {
-	psc = &priv->screenConfigs[i];
-	if (psc->drawHash == NULL)
-	    continue;
+   if (priv == NULL)
+      return NULL;
 
-	if (__glxHashLookup(psc->drawHash, drawable, (void *) &pdraw) == 0) {
-	    if (scrn_num != NULL)
-		*scrn_num = i;
-	    return pdraw;
-	}
-    }
+   for (i = 0; i < screen_count; i++) {
+      psc = &priv->screenConfigs[i];
+      if (psc->drawHash == NULL)
+         continue;
 
-    return NULL;
+      if (__glxHashLookup(psc->drawHash, drawable, (void *) &pdraw) == 0) {
+         if (scrn_num != NULL)
+            *scrn_num = i;
+         return pdraw;
+      }
+   }
+
+   return NULL;
 }
 
 #endif
@@ -152,44 +160,44 @@
  */
 
 static __GLXscreenConfigs *
-GetGLXScreenConfigs(Display *dpy, int scrn)
+GetGLXScreenConfigs(Display * dpy, int scrn)
 {
-    __GLXdisplayPrivate * const priv = __glXInitialize(dpy);
+   __GLXdisplayPrivate *const priv = __glXInitialize(dpy);
 
-    return (priv->screenConfigs != NULL) ? &priv->screenConfigs[scrn] : NULL;
+   return (priv->screenConfigs != NULL) ? &priv->screenConfigs[scrn] : NULL;
 }
 
 
 static int
-GetGLXPrivScreenConfig( Display *dpy, int scrn, __GLXdisplayPrivate ** ppriv,
-			__GLXscreenConfigs ** ppsc )
+GetGLXPrivScreenConfig(Display * dpy, int scrn, __GLXdisplayPrivate ** ppriv,
+                       __GLXscreenConfigs ** ppsc)
 {
-    /* Initialize the extension, if needed .  This has the added value
-     * of initializing/allocating the display private 
-     */
-    
-    if ( dpy == NULL ) {
-	return GLX_NO_EXTENSION;
-    }
+   /* Initialize the extension, if needed .  This has the added value
+    * of initializing/allocating the display private 
+    */
 
-    *ppriv = __glXInitialize(dpy);
-    if ( *ppriv == NULL ) {
-	return GLX_NO_EXTENSION;
-    }
+   if (dpy == NULL) {
+      return GLX_NO_EXTENSION;
+   }
 
-    /* Check screen number to see if its valid */
-    if ((scrn < 0) || (scrn >= ScreenCount(dpy))) {
-	return GLX_BAD_SCREEN;
-    }
+   *ppriv = __glXInitialize(dpy);
+   if (*ppriv == NULL) {
+      return GLX_NO_EXTENSION;
+   }
 
-    /* Check to see if the GL is supported on this screen */
-    *ppsc = &((*ppriv)->screenConfigs[scrn]);
-    if ( (*ppsc)->configs == NULL ) {
-	/* No support for GL on this screen regardless of visual */
-	return GLX_BAD_VISUAL;
-    }
+   /* Check screen number to see if its valid */
+   if ((scrn < 0) || (scrn >= ScreenCount(dpy))) {
+      return GLX_BAD_SCREEN;
+   }
 
-    return Success;
+   /* Check to see if the GL is supported on this screen */
+   *ppsc = &((*ppriv)->screenConfigs[scrn]);
+   if ((*ppsc)->configs == NULL) {
+      /* No support for GL on this screen regardless of visual */
+      return GLX_BAD_VISUAL;
+   }
+
+   return Success;
 }
 
 
@@ -204,27 +212,26 @@
  *          is returned.
  */
 static __GLcontextModes *
-ValidateGLXFBConfig( Display * dpy, GLXFBConfig config )
+ValidateGLXFBConfig(Display * dpy, GLXFBConfig config)
 {
-    __GLXdisplayPrivate * const priv = __glXInitialize(dpy);
-    const unsigned num_screens = ScreenCount(dpy);
-    unsigned   i;
-    const __GLcontextModes * modes;
+   __GLXdisplayPrivate *const priv = __glXInitialize(dpy);
+   const unsigned num_screens = ScreenCount(dpy);
+   unsigned i;
+   const __GLcontextModes *modes;
 
 
-    if ( priv != NULL ) {
-	for ( i = 0 ; i < num_screens ; i++ ) {
-	    for ( modes = priv->screenConfigs[i].configs
-		  ; modes != NULL
-		  ; modes = modes->next ) {
-		if ( modes == (__GLcontextModes *) config ) {
-		    return (__GLcontextModes *) config;
-		}
-	    }
-	}
-    }
+   if (priv != NULL) {
+      for (i = 0; i < num_screens; i++) {
+         for (modes = priv->screenConfigs[i].configs; modes != NULL;
+              modes = modes->next) {
+            if (modes == (__GLcontextModes *) config) {
+               return (__GLcontextModes *) config;
+            }
+         }
+      }
+   }
 
-    return NULL;
+   return NULL;
 }
 
 
@@ -238,103 +245,104 @@
  * function called \c __glXAllocateClientState that allocates the memory and
  * does all the initialization (including the pixel pack / unpack).
  */
-static
-GLXContext AllocateGLXContext( Display *dpy )
+static GLXContext
+AllocateGLXContext(Display * dpy)
 {
-     GLXContext gc;
-     int bufSize;
-     CARD8 opcode;
-    __GLXattribute *state;
+   GLXContext gc;
+   int bufSize;
+   CARD8 opcode;
+   __GLXattribute *state;
 
-    if (!dpy)
-        return NULL;
+   if (!dpy)
+      return NULL;
 
-    opcode = __glXSetupForCommand(dpy);
-    if (!opcode) {
-	return NULL;
-    }
+   opcode = __glXSetupForCommand(dpy);
+   if (!opcode) {
+      return NULL;
+   }
 
-    /* Allocate our context record */
-    gc = (GLXContext) Xmalloc(sizeof(struct __GLXcontextRec));
-    if (!gc) {
-	/* Out of memory */
-	return NULL;
-    }
-    memset(gc, 0, sizeof(struct __GLXcontextRec));
+   /* Allocate our context record */
+   gc = (GLXContext) Xmalloc(sizeof(struct __GLXcontextRec));
+   if (!gc) {
+      /* Out of memory */
+      return NULL;
+   }
+   memset(gc, 0, sizeof(struct __GLXcontextRec));
 
-    state = Xmalloc(sizeof(struct __GLXattributeRec));
-    if (state == NULL) {
-	/* Out of memory */
-	Xfree(gc);
-	return NULL;
-    }
-    gc->client_state_private = state;
-    memset(gc->client_state_private, 0, sizeof(struct __GLXattributeRec));
-    state->NoDrawArraysProtocol = (getenv("LIBGL_NO_DRAWARRAYS") != NULL);
+   state = Xmalloc(sizeof(struct __GLXattributeRec));
+   if (state == NULL) {
+      /* Out of memory */
+      Xfree(gc);
+      return NULL;
+   }
+   gc->client_state_private = state;
+   memset(gc->client_state_private, 0, sizeof(struct __GLXattributeRec));
+   state->NoDrawArraysProtocol = (getenv("LIBGL_NO_DRAWARRAYS") != NULL);
 
-    /*
+   /*
     ** Create a temporary buffer to hold GLX rendering commands.  The size
     ** of the buffer is selected so that the maximum number of GLX rendering
     ** commands can fit in a single X packet and still have room in the X
     ** packet for the GLXRenderReq header.
     */
 
-    bufSize = (XMaxRequestSize(dpy) * 4) - sz_xGLXRenderReq;
-    gc->buf = (GLubyte *) Xmalloc(bufSize);
-    if (!gc->buf) {
-	Xfree(gc->client_state_private);
-	Xfree(gc);
-	return NULL;
-    }
-    gc->bufSize = bufSize;
+   bufSize = (XMaxRequestSize(dpy) * 4) - sz_xGLXRenderReq;
+   gc->buf = (GLubyte *) Xmalloc(bufSize);
+   if (!gc->buf) {
+      Xfree(gc->client_state_private);
+      Xfree(gc);
+      return NULL;
+   }
+   gc->bufSize = bufSize;
 
-    /* Fill in the new context */
-    gc->renderMode = GL_RENDER;
+   /* Fill in the new context */
+   gc->renderMode = GL_RENDER;
 
-    state->storePack.alignment = 4;
-    state->storeUnpack.alignment = 4;
+   state->storePack.alignment = 4;
+   state->storeUnpack.alignment = 4;
 
-    gc->attributes.stackPointer = &gc->attributes.stack[0];
+   gc->attributes.stackPointer = &gc->attributes.stack[0];
 
-    /*
+   /*
     ** PERFORMANCE NOTE: A mode dependent fill image can speed things up.
     ** Other code uses the fastImageUnpack bit, but it is never set
     ** to GL_TRUE.
     */
-    gc->fastImageUnpack = GL_FALSE;
-    gc->fillImage = __glFillImage;
-    gc->pc = gc->buf;
-    gc->bufEnd = gc->buf + bufSize;
-    gc->isDirect = GL_FALSE;
-    if (__glXDebug) {
-	/*
-	** Set limit register so that there will be one command per packet
-	*/
-	gc->limit = gc->buf;
-    } else {
-	gc->limit = gc->buf + bufSize - __GLX_BUFFER_LIMIT_SIZE;
-    }
-    gc->createDpy = dpy;
-    gc->majorOpcode = opcode;
+   gc->fastImageUnpack = GL_FALSE;
+   gc->fillImage = __glFillImage;
+   gc->pc = gc->buf;
+   gc->bufEnd = gc->buf + bufSize;
+   gc->isDirect = GL_FALSE;
+   if (__glXDebug) {
+      /*
+       ** Set limit register so that there will be one command per packet
+       */
+      gc->limit = gc->buf;
+   }
+   else {
+      gc->limit = gc->buf + bufSize - __GLX_BUFFER_LIMIT_SIZE;
+   }
+   gc->createDpy = dpy;
+   gc->majorOpcode = opcode;
 
-    /*
+   /*
     ** Constrain the maximum drawing command size allowed to be
     ** transfered using the X_GLXRender protocol request.  First
     ** constrain by a software limit, then constrain by the protocl
     ** limit.
     */
-    if (bufSize > __GLX_RENDER_CMD_SIZE_LIMIT) {
-        bufSize = __GLX_RENDER_CMD_SIZE_LIMIT;
-    }
-    if (bufSize > __GLX_MAX_RENDER_CMD_SIZE) {
-        bufSize = __GLX_MAX_RENDER_CMD_SIZE;
-    }
-    gc->maxSmallRenderCommandSize = bufSize;
+   if (bufSize > __GLX_RENDER_CMD_SIZE_LIMIT) {
+      bufSize = __GLX_RENDER_CMD_SIZE_LIMIT;
+   }
+   if (bufSize > __GLX_MAX_RENDER_CMD_SIZE) {
+      bufSize = __GLX_MAX_RENDER_CMD_SIZE;
+   }
+   gc->maxSmallRenderCommandSize = bufSize;
 
-    gc->apple = NULL;
-    gc->do_destroy = False;
+   gc->apple = NULL;
+   gc->do_destroy = False;
 
-    return gc;
+   return gc;
 }
 
 
@@ -348,200 +356,221 @@
  */
 
 static GLXContext
-CreateContext(Display *dpy, XVisualInfo *vis,
-	      const __GLcontextModes * const fbconfig,
-	      GLXContext shareList,
-	      Bool allowDirect, GLXContextID contextID,
-	      Bool use_glx_1_3, int renderType)
+CreateContext(Display * dpy, XVisualInfo * vis,
+              const __GLcontextModes * const fbconfig,
+              GLXContext shareList,
+              Bool allowDirect, GLXContextID contextID,
+              Bool use_glx_1_3, int renderType)
 {
-    GLXContext gc;
-    int screen = (fbconfig == NULL) ? vis->screen : fbconfig->screen;
-    __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen);
-    const __GLcontextModes *mode;
-    int errorcode;
-    bool x11error;
+   GLXContext gc;
+   int screen = (fbconfig == NULL) ? vis->screen : fbconfig->screen;
+   __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen);
+   const __GLcontextModes *mode;
+   int errorcode;
+   bool x11error;
 
-    if ( dpy == NULL )
-       return NULL;
+   if (dpy == NULL)
+      return NULL;
 
-    gc = AllocateGLXContext(dpy);
-    if (!gc)
-	return NULL;
+   gc = AllocateGLXContext(dpy);
+   if (!gc)
+      return NULL;
 
-    if (None == contextID) {
-	if ( (vis == NULL) && (fbconfig == NULL) )
-	    return NULL;
+   if (None == contextID) {
+      if ((vis == NULL) && (fbconfig == NULL))
+         return NULL;
 
-    }
-    
-    gc->xid = contextID;
-    gc->imported = GL_FALSE;
+   }
 
-    if(vis) {
-	mode = _gl_context_modes_find_visual(psc->visuals, vis->visualid);
-    } else {
-	mode = _gl_context_modes_find_fbconfig(psc->configs, 
-					       fbconfig->fbconfigID);
-    }
+   gc->xid = contextID;
+   gc->imported = GL_FALSE;
 
-    if(NULL == mode) {
-	__glXSendError(dpy, BadValue, vis->visualid, X_GLXCreateContext,
-		       true);
-	__glXFreeContext(gc);
+   if (vis) {
+      mode = _gl_context_modes_find_visual(psc->visuals, vis->visualid);
+   }
+   else {
+      mode = _gl_context_modes_find_fbconfig(psc->configs,
+                                             fbconfig->fbconfigID);
+   }
 
-	return NULL;
-    }
-    
-    
-    if(apple_glx_create_context(&gc->apple, dpy, screen, mode, 
-				shareList ? shareList->apple : NULL,
-				&errorcode, &x11error)) {
-	__glXSendError(dpy, errorcode, 0, X_GLXCreateContext, x11error);
-	__glXFreeContext(gc);
+   if (NULL == mode) {
+      __glXSendError(dpy, BadValue, vis->visualid, X_GLXCreateContext, true);
+      __glXFreeContext(gc);
 
-	return NULL;
-    }
-    
-    gc->currentContextTag = -1;
-    gc->mode = mode;
-    gc->isDirect = allowDirect;
+      return NULL;
+   }
 
-    return gc;
+
+   if (apple_glx_create_context(&gc->apple, dpy, screen, mode,
+                                shareList ? shareList->apple : NULL,
+                                &errorcode, &x11error)) {
+      __glXSendError(dpy, errorcode, 0, X_GLXCreateContext, x11error);
+      __glXFreeContext(gc);
+
+      return NULL;
+   }
+
+   gc->currentContextTag = -1;
+   gc->mode = mode;
+   gc->isDirect = allowDirect;
+
+   return gc;
 }
 
-PUBLIC GLXContext glXCreateContext(Display *dpy, XVisualInfo *vis,
-				   GLXContext shareList, Bool allowDirect)
+PUBLIC GLXContext
+glXCreateContext(Display * dpy, XVisualInfo * vis,
+                 GLXContext shareList, Bool allowDirect)
 {
 
    return CreateContext(dpy, vis, NULL, shareList, allowDirect, None,
-			False, 0);
+                        False, 0);
 }
 
-_X_HIDDEN void __glXFreeContext(__GLXcontext *gc)
+_X_HIDDEN void
+__glXFreeContext(__GLXcontext * gc)
 {
-    if (gc->vendor) XFree((char *) gc->vendor);
-    if (gc->renderer) XFree((char *) gc->renderer);
-    if (gc->version) XFree((char *) gc->version);
-    if (gc->extensions) XFree((char *) gc->extensions);
-    
-    //__glFreeAttributeState(gc);
-    XFree((char *) gc->buf);
-    Xfree((char *) gc->client_state_private);
-    XFree((char *) gc);
-    
+   if (gc->vendor)
+      XFree((char *) gc->vendor);
+   if (gc->renderer)
+      XFree((char *) gc->renderer);
+   if (gc->version)
+      XFree((char *) gc->version);
+   if (gc->extensions)
+      XFree((char *) gc->extensions);
+
+   //__glFreeAttributeState(gc);
+   XFree((char *) gc->buf);
+   Xfree((char *) gc->client_state_private);
+   XFree((char *) gc);
+
 }
 
 /*
 ** Destroy the named context
 */
-static void 
-DestroyContext(Display *dpy, GLXContext gc)
+static void
+DestroyContext(Display * dpy, GLXContext gc)
 {
-    __glXLock();
+   __glXLock();
 
-    if (gc->currentDpy) {
-	/* 
-	 * Set the Bool that indicates that we should destroy this GLX context
-	 * when the context is no longer current.
-	 */
-	gc->do_destroy = True;
-	__glXUnlock();
-    } else {
-	/* Destroy the handle if not current to anybody */
-	__glXUnlock();
+   if (gc->currentDpy) {
+      /* 
+       * Set the Bool that indicates that we should destroy this GLX context
+       * when the context is no longer current.
+       */
+      gc->do_destroy = True;
+      __glXUnlock();
+   }
+   else {
+      /* Destroy the handle if not current to anybody */
+      __glXUnlock();
 
-	if(gc->apple)
-	    apple_glx_destroy_context(&gc->apple, dpy);
+      if (gc->apple)
+         apple_glx_destroy_context(&gc->apple, dpy);
 
-	__glXFreeContext(gc);
-    }
+      __glXFreeContext(gc);
+   }
 }
 
-PUBLIC void glXDestroyContext(Display *dpy, GLXContext gc)
+PUBLIC void
+glXDestroyContext(Display * dpy, GLXContext gc)
 {
-    DestroyContext(dpy, gc);
+   DestroyContext(dpy, gc);
 }
 
 /*
 ** Return the major and minor version #s for the GLX extension
 */
-PUBLIC Bool glXQueryVersion(Display *dpy, int *major, int *minor)
+PUBLIC Bool
+glXQueryVersion(Display * dpy, int *major, int *minor)
 {
-    __GLXdisplayPrivate *priv;
+   __GLXdisplayPrivate *priv;
 
-    /* Init the extension.  This fetches the major and minor version. */
-    priv = __glXInitialize(dpy);
-    if (!priv) return GL_FALSE;
+   /* Init the extension.  This fetches the major and minor version. */
+   priv = __glXInitialize(dpy);
+   if (!priv)
+      return GL_FALSE;
 
-    if (major) *major = priv->majorVersion;
-    if (minor) *minor = priv->minorVersion;
+   if (major)
+      *major = priv->majorVersion;
+   if (minor)
+      *minor = priv->minorVersion;
 
-    return GL_TRUE;
+   return GL_TRUE;
 }
 
 /*
 ** Query the existance of the GLX extension
 */
-PUBLIC Bool glXQueryExtension(Display *dpy, int *errorBase, int *eventBase)
+PUBLIC Bool
+glXQueryExtension(Display * dpy, int *errorBase, int *eventBase)
 {
-    int major_op, erb, evb;
-    Bool rv;
+   int major_op, erb, evb;
+   Bool rv;
 
-    rv = XQueryExtension(dpy, GLX_EXTENSION_NAME, &major_op, &evb, &erb);
-    if (rv) {
-	if (errorBase) *errorBase = erb;
-	if (eventBase) *eventBase = evb;
-    }
-    return rv;
+   rv = XQueryExtension(dpy, GLX_EXTENSION_NAME, &major_op, &evb, &erb);
+   if (rv) {
+      if (errorBase)
+         *errorBase = erb;
+      if (eventBase)
+         *eventBase = evb;
+   }
+   return rv;
 }
 
 /*
 ** Put a barrier in the token stream that forces the GL to finish its
 ** work before X can proceed.
 */
-PUBLIC void glXWaitGL(void)
+PUBLIC void
+glXWaitGL(void)
 {
-    GLXContext gc = __glXGetCurrentContext();
-    Display *dpy = gc->currentDpy;
+   GLXContext gc = __glXGetCurrentContext();
+   Display *dpy = gc->currentDpy;
 
-    if (!dpy) return;
+   if (!dpy)
+      return;
 
-    /* Flush any pending commands out */
-    __glXFlushRenderBuffer(gc, gc->pc);
+   /* Flush any pending commands out */
+   __glXFlushRenderBuffer(gc, gc->pc);
 
-    glFinish();
+   glFinish();
 }
 
 /*
 ** Put a barrier in the token stream that forces X to finish its
 ** work before GL can proceed.
 */
-PUBLIC void glXWaitX(void)
+PUBLIC void
+glXWaitX(void)
 {
-    GLXContext gc = __glXGetCurrentContext();
-    Display *dpy = gc->currentDpy;
+   GLXContext gc = __glXGetCurrentContext();
+   Display *dpy = gc->currentDpy;
 
-    if (!dpy) return;
+   if (!dpy)
+      return;
 
-    /* Flush any pending commands out */
-    __glXFlushRenderBuffer(gc, gc->pc);
+   /* Flush any pending commands out */
+   __glXFlushRenderBuffer(gc, gc->pc);
 
-    apple_glx_waitx(dpy, gc->apple);
+   apple_glx_waitx(dpy, gc->apple);
 
-    return;
+   return;
 }
 
-PUBLIC void glXUseXFont(Font font, int first, int count, int listBase)
+PUBLIC void
+glXUseXFont(Font font, int first, int count, int listBase)
 {
-    GLXContext gc = __glXGetCurrentContext();
-    Display *dpy = gc->currentDpy;
+   GLXContext gc = __glXGetCurrentContext();
+   Display *dpy = gc->currentDpy;
 
-    if (!dpy) return;
+   if (!dpy)
+      return;
 
-    /* Flush any pending commands out */
-    (void) __glXFlushRenderBuffer(gc, gc->pc);
-    
-    DRI_glXUseXFont(font, first, count, listBase);    
+   /* Flush any pending commands out */
+   (void) __glXFlushRenderBuffer(gc, gc->pc);
+
+   DRI_glXUseXFont(font, first, count, listBase);
 }
 
 /************************************************************************/
@@ -550,17 +579,18 @@
 ** Copy the source context to the destination context using the
 ** attribute "mask".
 */
-PUBLIC void glXCopyContext(Display *dpy, GLXContext source,
-			   GLXContext dest, unsigned long mask)
+PUBLIC void
+glXCopyContext(Display * dpy, GLXContext source,
+               GLXContext dest, unsigned long mask)
 {
-    GLXContext gc = __glXGetCurrentContext();
-    int errorcode;
-    bool x11error;
+   GLXContext gc = __glXGetCurrentContext();
+   int errorcode;
+   bool x11error;
 
-    if(apple_glx_copy_context(gc->apple, source->apple, dest->apple,
-			      mask, &errorcode, &x11error)) {
-	__glXSendError(dpy, errorcode, 0, X_GLXCopyContext, x11error);
-    }
+   if (apple_glx_copy_context(gc->apple, source->apple, dest->apple,
+                              mask, &errorcode, &x11error)) {
+      __glXSendError(dpy, errorcode, 0, X_GLXCopyContext, x11error);
+   }
 }
 
 /**
@@ -569,52 +599,57 @@
  * \c GLX_DIRECT_RENDERING is not defined?  Do we really need to bother with
  * the GLX protocol here at all?
  */
-PUBLIC Bool glXIsDirect(Display *dpy, GLXContext gc)
+PUBLIC Bool
+glXIsDirect(Display * dpy, GLXContext gc)
 {
-    /*
-     * This isn't an ideal test.  
-     * glXIsDirect should probably search a list of contexts.
-     */
-    if(NULL == gc) {
-	__glXSendError(dpy, GLXBadContext, 0, X_GLXIsDirect, false);
-	return False;
-    }
+   /*
+    * This isn't an ideal test.  
+    * glXIsDirect should probably search a list of contexts.
+    */
+   if (NULL == gc) {
+      __glXSendError(dpy, GLXBadContext, 0, X_GLXIsDirect, false);
+      return False;
+   }
 
-    return gc->isDirect;
+   return gc->isDirect;
 }
 
-PUBLIC GLXPixmap glXCreateGLXPixmap(Display *dpy, XVisualInfo *vis, 
-				    Pixmap pixmap)
+PUBLIC GLXPixmap
+glXCreateGLXPixmap(Display * dpy, XVisualInfo * vis, Pixmap pixmap)
 {
-    int screen = vis->screen;
-    __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen);
-    const __GLcontextModes *modes;
-    
-    modes = _gl_context_modes_find_visual(psc->visuals, vis->visualid);
+   int screen = vis->screen;
+   __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen);
+   const __GLcontextModes *modes;
 
-    if(apple_glx_pixmap_create(dpy, vis->screen, pixmap, modes))
-	return None;
+   modes = _gl_context_modes_find_visual(psc->visuals, vis->visualid);
 
-    return pixmap;
+   if (apple_glx_pixmap_create(dpy, vis->screen, pixmap, modes))
+      return None;
+
+   return pixmap;
 }
 
 /*
 ** Destroy the named pixmap
 */
-PUBLIC void glXDestroyGLXPixmap(Display *dpy, GLXPixmap glxpixmap)
+PUBLIC void
+glXDestroyGLXPixmap(Display * dpy, GLXPixmap glxpixmap)
 {
-    if(apple_glx_pixmap_destroy(dpy, glxpixmap))
-	__glXSendError(dpy, GLXBadPixmap, glxpixmap, X_GLXDestroyPixmap, false);
+   if (apple_glx_pixmap_destroy(dpy, glxpixmap))
+      __glXSendError(dpy, GLXBadPixmap, glxpixmap, X_GLXDestroyPixmap, false);
 }
 
-PUBLIC void glXSwapBuffers(Display *dpy, GLXDrawable drawable) {
-    GLXContext gc = glXGetCurrentContext();
-    
-    if(gc && apple_glx_is_current_drawable(dpy, gc->apple, drawable)) {
-	apple_glx_swap_buffers(gc->apple);
-    } else {
-	__glXSendError(dpy, GLXBadCurrentWindow, 0, X_GLXSwapBuffers, false);
-    }
+PUBLIC void
+glXSwapBuffers(Display * dpy, GLXDrawable drawable)
+{
+   GLXContext gc = glXGetCurrentContext();
+
+   if (gc && apple_glx_is_current_drawable(dpy, gc->apple, drawable)) {
+      apple_glx_swap_buffers(gc->apple);
+   }
+   else {
+      __glXSendError(dpy, GLXBadCurrentWindow, 0, X_GLXSwapBuffers, false);
+   }
 }
 
 
@@ -622,70 +657,72 @@
 ** Return configuration information for the given display, screen and
 ** visual combination.
 */
-PUBLIC int glXGetConfig(Display *dpy, XVisualInfo *vis, int attribute,
-			int *value_return)
+PUBLIC int
+glXGetConfig(Display * dpy, XVisualInfo * vis, int attribute,
+             int *value_return)
 {
-    __GLXdisplayPrivate *priv;
-    __GLXscreenConfigs *psc;
-    __GLcontextModes *modes;
-    int   status;
+   __GLXdisplayPrivate *priv;
+   __GLXscreenConfigs *psc;
+   __GLcontextModes *modes;
+   int status;
 
-    status = GetGLXPrivScreenConfig( dpy, vis->screen, & priv, & psc );
-    if ( status == Success ) {
-	modes = _gl_context_modes_find_visual(psc->visuals, vis->visualid);
+   status = GetGLXPrivScreenConfig(dpy, vis->screen, &priv, &psc);
+   if (status == Success) {
+      modes = _gl_context_modes_find_visual(psc->visuals, vis->visualid);
 
-	/* Lookup attribute after first finding a match on the visual */
-	if ( modes != NULL ) {
-	    return _gl_get_context_mode_data( modes, attribute, value_return );
-	}
-	
-	status = GLX_BAD_VISUAL;
-    }
+      /* Lookup attribute after first finding a match on the visual */
+      if (modes != NULL) {
+         return _gl_get_context_mode_data(modes, attribute, value_return);
+      }
 
-    /*
+      status = GLX_BAD_VISUAL;
+   }
+
+   /*
     ** If we can't find the config for this visual, this visual is not
     ** supported by the OpenGL implementation on the server.
     */
-    if ( (status == GLX_BAD_VISUAL) && (attribute == GLX_USE_GL) ) {
-	*value_return = GL_FALSE;
-	status = Success;
-    }
+   if ((status == GLX_BAD_VISUAL) && (attribute == GLX_USE_GL)) {
+      *value_return = GL_FALSE;
+      status = Success;
+   }
 
-    return status;
+   return status;
 }
 
 /************************************************************************/
 
 static void
-init_fbconfig_for_chooser( __GLcontextModes * config,
-			   GLboolean fbconfig_style_tags )
+init_fbconfig_for_chooser(__GLcontextModes * config,
+                          GLboolean fbconfig_style_tags)
 {
-    memset( config, 0, sizeof( __GLcontextModes ) );
-    config->visualID = (XID) GLX_DONT_CARE;
-    config->visualType = GLX_DONT_CARE;
+   memset(config, 0, sizeof(__GLcontextModes));
+   config->visualID = (XID) GLX_DONT_CARE;
+   config->visualType = GLX_DONT_CARE;
 
-    /* glXChooseFBConfig specifies different defaults for these two than
-     * glXChooseVisual.
-     */
-    if ( fbconfig_style_tags ) {
-	config->rgbMode = GL_TRUE;
-	config->doubleBufferMode = GLX_DONT_CARE;
-    }
+   /* glXChooseFBConfig specifies different defaults for these two than
+    * glXChooseVisual.
+    */
+   if (fbconfig_style_tags) {
+      config->rgbMode = GL_TRUE;
+      config->doubleBufferMode = GLX_DONT_CARE;
+   }
 
-    config->visualRating = GLX_DONT_CARE;
-    config->transparentPixel = GLX_NONE;
-    config->transparentRed = GLX_DONT_CARE;
-    config->transparentGreen = GLX_DONT_CARE;
-    config->transparentBlue = GLX_DONT_CARE;
-    config->transparentAlpha = GLX_DONT_CARE;
-    config->transparentIndex = GLX_DONT_CARE;
+   config->visualRating = GLX_DONT_CARE;
+   config->transparentPixel = GLX_NONE;
+   config->transparentRed = GLX_DONT_CARE;
+   config->transparentGreen = GLX_DONT_CARE;
+   config->transparentBlue = GLX_DONT_CARE;
+   config->transparentAlpha = GLX_DONT_CARE;
+   config->transparentIndex = GLX_DONT_CARE;
 
-    config->drawableType = GLX_WINDOW_BIT;
-    config->renderType = (config->rgbMode) ? GLX_RGBA_BIT : GLX_COLOR_INDEX_BIT;
-    config->xRenderable = GLX_DONT_CARE;
-    config->fbconfigID = (GLXFBConfigID)(GLX_DONT_CARE);
+   config->drawableType = GLX_WINDOW_BIT;
+   config->renderType =
+      (config->rgbMode) ? GLX_RGBA_BIT : GLX_COLOR_INDEX_BIT;
+   config->xRenderable = GLX_DONT_CARE;
+   config->fbconfigID = (GLXFBConfigID) (GLX_DONT_CARE);
 
-    config->swapMethod = GLX_DONT_CARE;
+   config->swapMethod = GLX_DONT_CARE;
 }
 
 #define MATCH_DONT_CARE( param ) \
@@ -718,80 +755,80 @@
  * \param b  Server specified config to test against \c a.
  */
 static Bool
-fbconfigs_compatible( const __GLcontextModes * const a,
-		      const __GLcontextModes * const b )
+fbconfigs_compatible(const __GLcontextModes * const a,
+                     const __GLcontextModes * const b)
 {
-    MATCH_DONT_CARE( doubleBufferMode );
-    MATCH_DONT_CARE( visualType );
-    MATCH_DONT_CARE( visualRating );
-    MATCH_DONT_CARE( xRenderable );
-    MATCH_DONT_CARE( fbconfigID );
-    MATCH_DONT_CARE( swapMethod );
+   MATCH_DONT_CARE(doubleBufferMode);
+   MATCH_DONT_CARE(visualType);
+   MATCH_DONT_CARE(visualRating);
+   MATCH_DONT_CARE(xRenderable);
+   MATCH_DONT_CARE(fbconfigID);
+   MATCH_DONT_CARE(swapMethod);
 
-    MATCH_MINIMUM( rgbBits );
-    MATCH_MINIMUM( numAuxBuffers );
-    MATCH_MINIMUM( redBits );
-    MATCH_MINIMUM( greenBits );
-    MATCH_MINIMUM( blueBits );
-    MATCH_MINIMUM( alphaBits );
-    MATCH_MINIMUM( depthBits );
-    MATCH_MINIMUM( stencilBits );
-    MATCH_MINIMUM( accumRedBits );
-    MATCH_MINIMUM( accumGreenBits );
-    MATCH_MINIMUM( accumBlueBits );
-    MATCH_MINIMUM( accumAlphaBits );
-    MATCH_MINIMUM( sampleBuffers );
-    MATCH_MINIMUM( maxPbufferWidth );
-    MATCH_MINIMUM( maxPbufferHeight );
-    MATCH_MINIMUM( maxPbufferPixels );
-    MATCH_MINIMUM( samples );
+   MATCH_MINIMUM(rgbBits);
+   MATCH_MINIMUM(numAuxBuffers);
+   MATCH_MINIMUM(redBits);
+   MATCH_MINIMUM(greenBits);
+   MATCH_MINIMUM(blueBits);
+   MATCH_MINIMUM(alphaBits);
+   MATCH_MINIMUM(depthBits);
+   MATCH_MINIMUM(stencilBits);
+   MATCH_MINIMUM(accumRedBits);
+   MATCH_MINIMUM(accumGreenBits);
+   MATCH_MINIMUM(accumBlueBits);
+   MATCH_MINIMUM(accumAlphaBits);
+   MATCH_MINIMUM(sampleBuffers);
+   MATCH_MINIMUM(maxPbufferWidth);
+   MATCH_MINIMUM(maxPbufferHeight);
+   MATCH_MINIMUM(maxPbufferPixels);
+   MATCH_MINIMUM(samples);
 
-    MATCH_DONT_CARE( stereoMode );
-    MATCH_EXACT( level );
+   MATCH_DONT_CARE(stereoMode);
+   MATCH_EXACT(level);
 
-    if ( ((a->drawableType & b->drawableType) == 0)
-	 || ((a->renderType & b->renderType) == 0) ) {
-	return False;
-    }
+   if (((a->drawableType & b->drawableType) == 0)
+       || ((a->renderType & b->renderType) == 0)) {
+      return False;
+   }
 
 
-    /* There is a bug in a few of the XFree86 DDX drivers.  They contain
-     * visuals with a "transparent type" of 0 when they really mean GLX_NONE.
-     * Technically speaking, it is a bug in the DDX driver, but there is
-     * enough of an installed base to work around the problem here.  In any
-     * case, 0 is not a valid value of the transparent type, so we'll treat 0 
-     * from the app as GLX_DONT_CARE. We'll consider GLX_NONE from the app and
-     * 0 from the server to be a match to maintain backward compatibility with
-     * the (broken) drivers.
-     */
+   /* There is a bug in a few of the XFree86 DDX drivers.  They contain
+    * visuals with a "transparent type" of 0 when they really mean GLX_NONE.
+    * Technically speaking, it is a bug in the DDX driver, but there is
+    * enough of an installed base to work around the problem here.  In any
+    * case, 0 is not a valid value of the transparent type, so we'll treat 0 
+    * from the app as GLX_DONT_CARE. We'll consider GLX_NONE from the app and
+    * 0 from the server to be a match to maintain backward compatibility with
+    * the (broken) drivers.
+    */
 
-    if ( a->transparentPixel != GLX_DONT_CARE
-         && a->transparentPixel != 0 ) {
-        if ( a->transparentPixel == GLX_NONE ) {
-            if ( b->transparentPixel != GLX_NONE && b->transparentPixel != 0 )
-                return False;
-        } else {
-            MATCH_EXACT( transparentPixel );
-        }
+   if (a->transparentPixel != GLX_DONT_CARE && a->transparentPixel != 0) {
+      if (a->transparentPixel == GLX_NONE) {
+         if (b->transparentPixel != GLX_NONE && b->transparentPixel != 0)
+            return False;
+      }
+      else {
+         MATCH_EXACT(transparentPixel);
+      }
 
-	switch ( a->transparentPixel ) {
-	  case GLX_TRANSPARENT_RGB:
-	    MATCH_DONT_CARE( transparentRed );
-	    MATCH_DONT_CARE( transparentGreen );
-	    MATCH_DONT_CARE( transparentBlue );
-	    MATCH_DONT_CARE( transparentAlpha );
-	    break;
+      switch (a->transparentPixel) {
+      case GLX_TRANSPARENT_RGB:
+         MATCH_DONT_CARE(transparentRed);
+         MATCH_DONT_CARE(transparentGreen);
+         MATCH_DONT_CARE(transparentBlue);
+         MATCH_DONT_CARE(transparentAlpha);
+         break;
 
-	  case GLX_TRANSPARENT_INDEX:
-	    MATCH_DONT_CARE( transparentIndex );
-	    break;
+      case GLX_TRANSPARENT_INDEX:
+         MATCH_DONT_CARE(transparentIndex);
+         break;
 
-	  default:
-	    break;
-	}
-    }
+      default:
+         break;
+      }
+   }
 
-    return True;
+   return True;
 }
 
 
@@ -841,66 +878,66 @@
  * \sa qsort, glXChooseVisual, glXChooseFBConfig, glXChooseFBConfigSGIX
  */
 static int
-fbconfig_compare( const __GLcontextModes * const * const a,
-		  const __GLcontextModes * const * const b )
+fbconfig_compare(const __GLcontextModes * const *const a,
+                 const __GLcontextModes * const *const b)
 {
-    /* The order of these comparisons must NOT change.  It is defined by
-     * the GLX 1.3 spec and ARB_multisample.
-     */
+   /* The order of these comparisons must NOT change.  It is defined by
+    * the GLX 1.3 spec and ARB_multisample.
+    */
 
-    PREFER_SMALLER( visualSelectGroup );
+   PREFER_SMALLER(visualSelectGroup);
 
-    /* The sort order for the visualRating is GLX_NONE, GLX_SLOW, and
-     * GLX_NON_CONFORMANT_CONFIG.  It just so happens that this is the
-     * numerical sort order of the enums (0x8000, 0x8001, and 0x800D).
-     */
-    PREFER_SMALLER( visualRating );
+   /* The sort order for the visualRating is GLX_NONE, GLX_SLOW, and
+    * GLX_NON_CONFORMANT_CONFIG.  It just so happens that this is the
+    * numerical sort order of the enums (0x8000, 0x8001, and 0x800D).
+    */
+   PREFER_SMALLER(visualRating);
 
-    /* This isn't quite right.  It is supposed to compare the sum of the
-     * components the user specifically set minimums for.
-     */
-    PREFER_LARGER_OR_ZERO( redBits );
-    PREFER_LARGER_OR_ZERO( greenBits );
-    PREFER_LARGER_OR_ZERO( blueBits );
-    PREFER_LARGER_OR_ZERO( alphaBits );
+   /* This isn't quite right.  It is supposed to compare the sum of the
+    * components the user specifically set minimums for.
+    */
+   PREFER_LARGER_OR_ZERO(redBits);
+   PREFER_LARGER_OR_ZERO(greenBits);
+   PREFER_LARGER_OR_ZERO(blueBits);
+   PREFER_LARGER_OR_ZERO(alphaBits);
 
-    PREFER_SMALLER( rgbBits );
+   PREFER_SMALLER(rgbBits);
 
-    if ( ((*a)->doubleBufferMode != (*b)->doubleBufferMode) ) {
-	/* Prefer single-buffer.
-	 */
-	return ( !(*a)->doubleBufferMode ) ? -1 : 1;
-    }
+   if (((*a)->doubleBufferMode != (*b)->doubleBufferMode)) {
+      /* Prefer single-buffer.
+       */
+      return (!(*a)->doubleBufferMode) ? -1 : 1;
+   }
 
-    PREFER_SMALLER( numAuxBuffers );
+   PREFER_SMALLER(numAuxBuffers);
 
-    PREFER_LARGER_OR_ZERO( depthBits );
-    PREFER_SMALLER( stencilBits );
+   PREFER_LARGER_OR_ZERO(depthBits);
+   PREFER_SMALLER(stencilBits);
 
-    /* This isn't quite right.  It is supposed to compare the sum of the
-     * components the user specifically set minimums for.
-     */
-    PREFER_LARGER_OR_ZERO( accumRedBits );
-    PREFER_LARGER_OR_ZERO( accumGreenBits );
-    PREFER_LARGER_OR_ZERO( accumBlueBits );
-    PREFER_LARGER_OR_ZERO( accumAlphaBits );
+   /* This isn't quite right.  It is supposed to compare the sum of the
+    * components the user specifically set minimums for.
+    */
+   PREFER_LARGER_OR_ZERO(accumRedBits);
+   PREFER_LARGER_OR_ZERO(accumGreenBits);
+   PREFER_LARGER_OR_ZERO(accumBlueBits);
+   PREFER_LARGER_OR_ZERO(accumAlphaBits);
 
-    PREFER_SMALLER( visualType );
+   PREFER_SMALLER(visualType);
 
-    /* None of the multisample specs say where this comparison should happen,
-     * so I put it near the end.
-     */
-    PREFER_SMALLER( sampleBuffers );
-    PREFER_SMALLER( samples );
+   /* None of the multisample specs say where this comparison should happen,
+    * so I put it near the end.
+    */
+   PREFER_SMALLER(sampleBuffers);
+   PREFER_SMALLER(samples);
 
-    /* None of the pbuffer or fbconfig specs say that this comparison needs
-     * to happen at all, but it seems like it should.
-     */
-    PREFER_LARGER( maxPbufferWidth );
-    PREFER_LARGER( maxPbufferHeight );
-    PREFER_LARGER( maxPbufferPixels );
+   /* None of the pbuffer or fbconfig specs say that this comparison needs
+    * to happen at all, but it seems like it should.
+    */
+   PREFER_LARGER(maxPbufferWidth);
+   PREFER_LARGER(maxPbufferHeight);
+   PREFER_LARGER(maxPbufferPixels);
 
-    return 0;
+   return 0;
 }
 
 
@@ -927,49 +964,48 @@
  * \sa glXChooseVisual, glXChooseFBConfig, glXChooseFBConfigSGIX
  */
 static int
-choose_visual( __GLcontextModes ** configs, int num_configs,
-	       const int *attribList, GLboolean fbconfig_style_tags )
+choose_visual(__GLcontextModes ** configs, int num_configs,
+              const int *attribList, GLboolean fbconfig_style_tags)
 {
-    __GLcontextModes    test_config;
-    int   base;
-    int   i;
+   __GLcontextModes test_config;
+   int base;
+   int i;
 
-    /* This is a fairly direct implementation of the selection method
-     * described by GLX_SGIX_fbconfig.  Start by culling out all the
-     * configs that are not compatible with the selected parameter
-     * list.
-     */
+   /* This is a fairly direct implementation of the selection method
+    * described by GLX_SGIX_fbconfig.  Start by culling out all the
+    * configs that are not compatible with the selected parameter
+    * list.
+    */
 
-    init_fbconfig_for_chooser( & test_config, fbconfig_style_tags );
-    __glXInitializeVisualConfigFromTags( & test_config, 512,
-					 (const INT32 *) attribList,
-					 GL_TRUE, fbconfig_style_tags );
+   init_fbconfig_for_chooser(&test_config, fbconfig_style_tags);
+   __glXInitializeVisualConfigFromTags(&test_config, 512,
+                                       (const INT32 *) attribList,
+                                       GL_TRUE, fbconfig_style_tags);
 
-    base = 0;
-    for ( i = 0 ; i < num_configs ; i++ ) {
-	if ( fbconfigs_compatible( & test_config, configs[i] ) ) {
-	    configs[ base ] = configs[ i ];
-	    base++;
-	}
-    }
+   base = 0;
+   for (i = 0; i < num_configs; i++) {
+      if (fbconfigs_compatible(&test_config, configs[i])) {
+         configs[base] = configs[i];
+         base++;
+      }
+   }
 
-    if ( base == 0 ) {
-	return 0;
-    }
- 
-    if ( base < num_configs ) {
-	(void) memset( & configs[ base ], 0, 
-		       sizeof( void * ) * (num_configs - base) );
-    }
+   if (base == 0) {
+      return 0;
+   }
 
-    /* After the incompatible configs are removed, the resulting
-     * list is sorted according to the rules set out in the various
-     * specifications.
-     */
-    
-    qsort( configs, base, sizeof( __GLcontextModes * ),
-	   (int (*)(const void*, const void*)) fbconfig_compare );
-    return base;
+   if (base < num_configs) {
+      (void) memset(&configs[base], 0, sizeof(void *) * (num_configs - base));
+   }
+
+   /* After the incompatible configs are removed, the resulting
+    * list is sorted according to the rules set out in the various
+    * specifications.
+    */
+
+   qsort(configs, base, sizeof(__GLcontextModes *),
+         (int (*)(const void *, const void *)) fbconfig_compare);
+   return base;
 }
 
 
@@ -979,166 +1015,175 @@
 ** Return the visual that best matches the template.  Return None if no
 ** visual matches the template.
 */
-PUBLIC XVisualInfo *glXChooseVisual(Display *dpy, int screen, int *attribList)
+PUBLIC XVisualInfo *
+glXChooseVisual(Display * dpy, int screen, int *attribList)
 {
-    XVisualInfo *visualList = NULL;
-    __GLXdisplayPrivate *priv;
-    __GLXscreenConfigs *psc;
-    __GLcontextModes  test_config;
-    __GLcontextModes *modes;
-    const __GLcontextModes *best_config = NULL;
+   XVisualInfo *visualList = NULL;
+   __GLXdisplayPrivate *priv;
+   __GLXscreenConfigs *psc;
+   __GLcontextModes test_config;
+   __GLcontextModes *modes;
+   const __GLcontextModes *best_config = NULL;
 
-    /*
+   /*
     ** Get a list of all visuals, return if list is empty
     */
-    if ( GetGLXPrivScreenConfig( dpy, screen, & priv, & psc ) != Success ) {
-	return None;
-    }
-   
+   if (GetGLXPrivScreenConfig(dpy, screen, &priv, &psc) != Success) {
+      return None;
+   }
 
-    /*
+
+   /*
     ** Build a template from the defaults and the attribute list
     ** Free visual list and return if an unexpected token is encountered
     */
-    init_fbconfig_for_chooser( & test_config, GL_FALSE );
-    __glXInitializeVisualConfigFromTags( & test_config, 512, 
-					 (const INT32 *) attribList,
-					 GL_TRUE, GL_FALSE );
+   init_fbconfig_for_chooser(&test_config, GL_FALSE);
+   __glXInitializeVisualConfigFromTags(&test_config, 512,
+                                       (const INT32 *) attribList,
+                                       GL_TRUE, GL_FALSE);
 
-    /*
+   /*
     ** Eliminate visuals that don't meet minimum requirements
     ** Compute a score for those that do
     ** Remember which visual, if any, got the highest score
     */
-    for ( modes = psc->visuals ; modes != NULL ; modes = modes->next ) {
-	if ( fbconfigs_compatible( & test_config, modes )
-	     && ((best_config == NULL)
-		 || (fbconfig_compare( (const __GLcontextModes * const * const)&modes, &best_config ) < 0)) ) {
-	    best_config = modes;
-	}
-    }
+   for (modes = psc->visuals; modes != NULL; modes = modes->next) {
+      if (fbconfigs_compatible(&test_config, modes)
+          && ((best_config == NULL)
+              ||
+              (fbconfig_compare
+               ((const __GLcontextModes * const *const) &modes,
+                &best_config) < 0))) {
+         best_config = modes;
+      }
+   }
 
-    /*
+   /*
     ** If no visual is acceptable, return None
     ** Otherwise, create an XVisualInfo list with just the selected X visual
     ** and return this.
     */
-    if (best_config != NULL) {
-	XVisualInfo visualTemplate;
-	int  i;
+   if (best_config != NULL) {
+      XVisualInfo visualTemplate;
+      int i;
 
-	visualTemplate.screen = screen;
-	visualTemplate.visualid = best_config->visualID;
-	visualList = XGetVisualInfo( dpy, VisualScreenMask|VisualIDMask,
-				     &visualTemplate, &i );
-    }
+      visualTemplate.screen = screen;
+      visualTemplate.visualid = best_config->visualID;
+      visualList = XGetVisualInfo(dpy, VisualScreenMask | VisualIDMask,
+                                  &visualTemplate, &i);
+   }
 
-    if(visualList && getenv("LIBGL_DUMP_VISUALID")) {
-	printf("visualid 0x%lx\n", visualList[0].visualid);
-    }
+   if (visualList && getenv("LIBGL_DUMP_VISUALID")) {
+      printf("visualid 0x%lx\n", visualList[0].visualid);
+   }
 
-    return visualList;
+   return visualList;
 }
 
 
-PUBLIC const char *glXQueryExtensionsString( Display *dpy, int screen )
+PUBLIC const char *
+glXQueryExtensionsString(Display * dpy, int screen)
 {
-    __GLXscreenConfigs *psc;
-    __GLXdisplayPrivate *priv;
+   __GLXscreenConfigs *psc;
+   __GLXdisplayPrivate *priv;
 
-    if ( GetGLXPrivScreenConfig( dpy, screen, & priv, & psc ) != Success ) {
-	return NULL;
-    }
+   if (GetGLXPrivScreenConfig(dpy, screen, &priv, &psc) != Success) {
+      return NULL;
+   }
 
-    if (!psc->effectiveGLXexts) {
-        if (!psc->serverGLXexts) {
-	    psc->serverGLXexts = __glXGetStringFromServer(dpy, priv->majorOpcode,
-					  	   X_GLXQueryServerString,
-					  	   screen, GLX_EXTENSIONS);
-	}
+   if (!psc->effectiveGLXexts) {
+      if (!psc->serverGLXexts) {
+         psc->serverGLXexts = __glXGetStringFromServer(dpy, priv->majorOpcode,
+                                                       X_GLXQueryServerString,
+                                                       screen,
+                                                       GLX_EXTENSIONS);
+      }
 
-	__glXCalculateUsableExtensions(psc,
+      __glXCalculateUsableExtensions(psc,
 #ifdef GLX_DIRECT_RENDERING
-				       (psc->driScreen != NULL),
+                                     (psc->driScreen != NULL),
 #else
-				       GL_FALSE,
+                                     GL_FALSE,
 #endif
-				       priv->minorVersion);
-    }
+                                     priv->minorVersion);
+   }
 
-    return psc->effectiveGLXexts;
+   return psc->effectiveGLXexts;
 }
 
-PUBLIC const char *glXGetClientString( Display *dpy, int name )
+PUBLIC const char *
+glXGetClientString(Display * dpy, int name)
 {
-    switch(name) {
-	case GLX_VENDOR:
-	    return (__glXGLXClientVendorName);
-	case GLX_VERSION:
-	    return (__glXGLXClientVersion);
-	case GLX_EXTENSIONS:
-	    return (__glXGetClientExtensions());
-	default:
-	    return NULL;
-    }
+   switch (name) {
+   case GLX_VENDOR:
+      return (__glXGLXClientVendorName);
+   case GLX_VERSION:
+      return (__glXGLXClientVersion);
+   case GLX_EXTENSIONS:
+      return (__glXGetClientExtensions());
+   default:
+      return NULL;
+   }
 }
 
-PUBLIC const char *glXQueryServerString( Display *dpy, int screen, int name )
+PUBLIC const char *
+glXQueryServerString(Display * dpy, int screen, int name)
 {
-    __GLXscreenConfigs *psc;
-    __GLXdisplayPrivate *priv;
-    const char ** str;
+   __GLXscreenConfigs *psc;
+   __GLXdisplayPrivate *priv;
+   const char **str;
 
 
-    if ( GetGLXPrivScreenConfig( dpy, screen, & priv, & psc ) != Success ) {
-	return NULL;
-    }
+   if (GetGLXPrivScreenConfig(dpy, screen, &priv, &psc) != Success) {
+      return NULL;
+   }
 
-    switch(name) {
-	case GLX_VENDOR:
-	    str = & priv->serverGLXvendor;
-	    break;
-	case GLX_VERSION:
-	    str = & priv->serverGLXversion;
-	    break;
-	case GLX_EXTENSIONS:
-	    str = & psc->serverGLXexts;
-	    break;
-	default:
-	    return NULL;
-    }
+   switch (name) {
+   case GLX_VENDOR:
+      str = &priv->serverGLXvendor;
+      break;
+   case GLX_VERSION:
+      str = &priv->serverGLXversion;
+      break;
+   case GLX_EXTENSIONS:
+      str = &psc->serverGLXexts;
+      break;
+   default:
+      return NULL;
+   }
 
-    if ( *str == NULL ) {
-	*str = __glXGetStringFromServer(dpy, priv->majorOpcode,
-					X_GLXQueryServerString, screen, name);
-    }
-    
-    return *str;
+   if (*str == NULL) {
+      *str = __glXGetStringFromServer(dpy, priv->majorOpcode,
+                                      X_GLXQueryServerString, screen, name);
+   }
+
+   return *str;
 }
 
-void __glXClientInfo (  Display *dpy, int opcode  )
+void
+__glXClientInfo(Display * dpy, int opcode)
 {
-    xGLXClientInfoReq *req;
-    int size;
-    char * ext_str = __glXGetClientGLExtensionString();
+   xGLXClientInfoReq *req;
+   int size;
+   char *ext_str = __glXGetClientGLExtensionString();
 
-    /* Send the glXClientInfo request */
-    LockDisplay(dpy);
-    GetReq(GLXClientInfo,req);
-    req->reqType = opcode;
-    req->glxCode = X_GLXClientInfo;
-    req->major = GLX_MAJOR_VERSION;
-    req->minor = GLX_MINOR_VERSION;
+   /* Send the glXClientInfo request */
+   LockDisplay(dpy);
+   GetReq(GLXClientInfo, req);
+   req->reqType = opcode;
+   req->glxCode = X_GLXClientInfo;
+   req->major = GLX_MAJOR_VERSION;
+   req->minor = GLX_MINOR_VERSION;
 
-    size = strlen( ext_str ) + 1;
-    req->length += (size + 3) >> 2;
-    req->numbytes = size;
-    Data(dpy, ext_str, size);
+   size = strlen(ext_str) + 1;
+   req->length += (size + 3) >> 2;
+   req->numbytes = size;
+   Data(dpy, ext_str, size);
 
-    UnlockDisplay(dpy);
-    SyncHandle();
-    
-    Xfree( ext_str );
+   UnlockDisplay(dpy);
+   SyncHandle();
+
+   Xfree(ext_str);
 }
 
 
@@ -1146,16 +1191,18 @@
 ** EXT_import_context
 */
 
-PUBLIC Display *glXGetCurrentDisplay(void)
+PUBLIC Display *
+glXGetCurrentDisplay(void)
 {
-    GLXContext gc = __glXGetCurrentContext();
-    if (NULL == gc) return NULL;
-    return gc->currentDpy;
+   GLXContext gc = __glXGetCurrentContext();
+   if (NULL == gc)
+      return NULL;
+   return gc->currentDpy;
 }
 
-PUBLIC GLX_ALIAS(Display *, glXGetCurrentDisplayEXT, (void), (),
-	  glXGetCurrentDisplay)
-
+PUBLIC
+GLX_ALIAS(Display *, glXGetCurrentDisplayEXT, (void), (),
+          glXGetCurrentDisplay)
 #if 0
 /**
  * Used internally by libGL to send \c xGLXQueryContextinfoExtReq requests
@@ -1171,181 +1218,185 @@
  * This function dynamically determines whether to use the EXT_import_context
  * version of the protocol or the GLX 1.3 version of the protocol.
  */
-static int __glXQueryContextInfo(Display *dpy, GLXContext ctx)
+     static int __glXQueryContextInfo(Display * dpy, GLXContext ctx)
 {
-    __GLXdisplayPrivate *priv = __glXInitialize(dpy);
-    xGLXQueryContextReply reply;
-    CARD8 opcode;
-    GLuint numValues;
-    int retval;
+   __GLXdisplayPrivate *priv = __glXInitialize(dpy);
+   xGLXQueryContextReply reply;
+   CARD8 opcode;
+   GLuint numValues;
+   int retval;
 
-    if (ctx == NULL) {
-	return GLX_BAD_CONTEXT;
-    }
-    opcode = __glXSetupForCommand(dpy);
-    if (!opcode) {
-	return 0;
-    }
+   if (ctx == NULL) {
+      return GLX_BAD_CONTEXT;
+   }
+   opcode = __glXSetupForCommand(dpy);
+   if (!opcode) {
+      return 0;
+   }
 
-    /* Send the glXQueryContextInfoEXT request */
-    LockDisplay(dpy);
+   /* Send the glXQueryContextInfoEXT request */
+   LockDisplay(dpy);
 
-    if ( (priv->majorVersion > 1) || (priv->minorVersion >= 3) ) {
-	xGLXQueryContextReq *req;
+   if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) {
+      xGLXQueryContextReq *req;
 
-	GetReq(GLXQueryContext, req);
+      GetReq(GLXQueryContext, req);
 
-	req->reqType = opcode;
-	req->glxCode = X_GLXQueryContext;
-	req->context = (unsigned int)(ctx->xid);
-    }
-    else {
-	xGLXVendorPrivateReq *vpreq;
-	xGLXQueryContextInfoEXTReq *req;
+      req->reqType = opcode;
+      req->glxCode = X_GLXQueryContext;
+      req->context = (unsigned int) (ctx->xid);
+   }
+   else {
+      xGLXVendorPrivateReq *vpreq;
+      xGLXQueryContextInfoEXTReq *req;
 
-	GetReqExtra( GLXVendorPrivate,
-		     sz_xGLXQueryContextInfoEXTReq - sz_xGLXVendorPrivateReq,
-		     vpreq );
-	req = (xGLXQueryContextInfoEXTReq *)vpreq;
-	req->reqType = opcode;
-	req->glxCode = X_GLXVendorPrivateWithReply;
-	req->vendorCode = X_GLXvop_QueryContextInfoEXT;
-	req->context = (unsigned int)(ctx->xid);
-    }
+      GetReqExtra(GLXVendorPrivate,
+                  sz_xGLXQueryContextInfoEXTReq - sz_xGLXVendorPrivateReq,
+                  vpreq);
+      req = (xGLXQueryContextInfoEXTReq *) vpreq;
+      req->reqType = opcode;
+      req->glxCode = X_GLXVendorPrivateWithReply;
+      req->vendorCode = X_GLXvop_QueryContextInfoEXT;
+      req->context = (unsigned int) (ctx->xid);
+   }
 
-    _XReply(dpy, (xReply*) &reply, 0, False);
+   _XReply(dpy, (xReply *) & reply, 0, False);
 
-    numValues = reply.n;
-    if (numValues == 0)
-	retval = Success;
-    else if (numValues > __GLX_MAX_CONTEXT_PROPS)
-	retval = 0;
-    else
-    {
-	int *propList, *pProp;
-	int nPropListBytes;
-	int i;
+   numValues = reply.n;
+   if (numValues == 0)
+      retval = Success;
+   else if (numValues > __GLX_MAX_CONTEXT_PROPS)
+      retval = 0;
+   else {
+      int *propList, *pProp;
+      int nPropListBytes;
+      int i;
 
-	nPropListBytes = numValues << 3;
-	propList = (int *) Xmalloc(nPropListBytes);
-	if (NULL == propList) {
-	    retval = 0;
-	} else {
-	    _XRead(dpy, (char *)propList, nPropListBytes);
-	    pProp = propList;
-	    for (i=0; i < numValues; i++) {
-		switch (*pProp++) {
-		case GLX_SHARE_CONTEXT_EXT:
-		    ctx->share_xid = *pProp++;
-		    break;
-		case GLX_VISUAL_ID_EXT:
-		    ctx->mode =
-			_gl_context_modes_find_visual(ctx->psc->visuals, *pProp++);
-		    break;
-		case GLX_SCREEN:
-		    ctx->screen = *pProp++;
-		    break;
-		case GLX_FBCONFIG_ID:
-		    ctx->mode =
-			_gl_context_modes_find_fbconfig(ctx->psc->configs, *pProp++);
-		    break;
-		case GLX_RENDER_TYPE:
-		    ctx->renderType = *pProp++;
-		    break;
-		default:
-		    pProp++;
-		    continue;
-		}
-	    }
-	    Xfree((char *)propList);
-	    retval = Success;
-	}
-    }
-    UnlockDisplay(dpy);
-    SyncHandle();
-    return retval;
+      nPropListBytes = numValues << 3;
+      propList = (int *) Xmalloc(nPropListBytes);
+      if (NULL == propList) {
+         retval = 0;
+      }
+      else {
+         _XRead(dpy, (char *) propList, nPropListBytes);
+         pProp = propList;
+         for (i = 0; i < numValues; i++) {
+            switch (*pProp++) {
+            case GLX_SHARE_CONTEXT_EXT:
+               ctx->share_xid = *pProp++;
+               break;
+            case GLX_VISUAL_ID_EXT:
+               ctx->mode =
+                  _gl_context_modes_find_visual(ctx->psc->visuals, *pProp++);
+               break;
+            case GLX_SCREEN:
+               ctx->screen = *pProp++;
+               break;
+            case GLX_FBCONFIG_ID:
+               ctx->mode =
+                  _gl_context_modes_find_fbconfig(ctx->psc->configs,
+                                                  *pProp++);
+               break;
+            case GLX_RENDER_TYPE:
+               ctx->renderType = *pProp++;
+               break;
+            default:
+               pProp++;
+               continue;
+            }
+         }
+         Xfree((char *) propList);
+         retval = Success;
+      }
+   }
+   UnlockDisplay(dpy);
+   SyncHandle();
+   return retval;
 }
 #endif
 
 PUBLIC int
-glXQueryContext(Display *dpy, GLXContext ctx, int attribute, int *value)
+glXQueryContext(Display * dpy, GLXContext ctx, int attribute, int *value)
 {
-    int retVal;
+   int retVal;
 
-    (void)retVal;
+   (void) retVal;
 
-#if 0 /*AppleSGLX*/
-    /* get the information from the server if we don't have it already */
+#if 0                           /*AppleSGLX */
+   /* get the information from the server if we don't have it already */
 #ifdef GLX_DIRECT_RENDERING
-    if (!ctx->driContext && (ctx->mode == NULL)) {
+   if (!ctx->driContext && (ctx->mode == NULL)) {
 #else
-    if (ctx->mode == NULL) {
+   if (ctx->mode == NULL) {
 #endif
-	retVal = __glXQueryContextInfo(dpy, ctx);
-	if (Success != retVal) return retVal;
-    }
+      retVal = __glXQueryContextInfo(dpy, ctx);
+      if (Success != retVal)
+         return retVal;
+   }
 #endif
 
-    switch (attribute) {
+   switch (attribute) {
 #if 0
-    case GLX_SHARE_CONTEXT_EXT:
-	*value = (int)(ctx->share_xid);
-	break;
-    case GLX_VISUAL_ID_EXT:
-	*value = ctx->mode ? ctx->mode->visualID : None;
-	break;
+   case GLX_SHARE_CONTEXT_EXT:
+      *value = (int) (ctx->share_xid);
+      break;
+   case GLX_VISUAL_ID_EXT:
+      *value = ctx->mode ? ctx->mode->visualID : None;
+      break;
 #endif
-    case GLX_SCREEN:
-	*value = (int)(ctx->screen);
-	break;
-    case GLX_FBCONFIG_ID:
-	*value = ctx->mode ? ctx->mode->fbconfigID : None;
-	break;
-    case GLX_RENDER_TYPE:
-	*value = (int)(ctx->renderType);
-	break;
-    default:
-	return GLX_BAD_ATTRIBUTE;
-    }
-    return Success;
+   case GLX_SCREEN:
+      *value = (int) (ctx->screen);
+      break;
+   case GLX_FBCONFIG_ID:
+      *value = ctx->mode ? ctx->mode->fbconfigID : None;
+      break;
+   case GLX_RENDER_TYPE:
+      *value = (int) (ctx->renderType);
+      break;
+   default:
+      return GLX_BAD_ATTRIBUTE;
+   }
+   return Success;
 }
 
-PUBLIC GLX_ALIAS( int, glXQueryContextInfoEXT,
-	   (Display *dpy, GLXContext ctx, int attribute, int *value),
-	   (dpy, ctx, attribute, value),
-	   glXQueryContext )
+PUBLIC
+GLX_ALIAS(int, glXQueryContextInfoEXT,
+          (Display * dpy, GLXContext ctx, int attribute, int *value),
+          (dpy, ctx, attribute, value), glXQueryContext)
 
-PUBLIC GLXContextID glXGetContextIDEXT(const GLXContext ctx)
+     PUBLIC GLXContextID glXGetContextIDEXT(const GLXContext ctx)
 {
-    return ctx->xid;
+   return ctx->xid;
 }
 
-PUBLIC GLXContext glXImportContextEXT(Display *dpy, GLXContextID contextID)
+PUBLIC GLXContext
+glXImportContextEXT(Display * dpy, GLXContextID contextID)
 {
 #if 0
-    GLXContext ctx;
+   GLXContext ctx;
 
-    if (contextID == None) {
-	return NULL;
-    }
-    if (__glXIsDirect(dpy, contextID)) {
-	return NULL;
-    }
+   if (contextID == None) {
+      return NULL;
+   }
+   if (__glXIsDirect(dpy, contextID)) {
+      return NULL;
+   }
 
-    ctx = CreateContext(dpy, NULL, NULL, NULL, False, contextID, False, 0);
-    if (NULL != ctx) {
-	if (Success != __glXQueryContextInfo(dpy, ctx)) {
-	   return NULL;
-	}
-    }
-    return ctx;
+   ctx = CreateContext(dpy, NULL, NULL, NULL, False, contextID, False, 0);
+   if (NULL != ctx) {
+      if (Success != __glXQueryContextInfo(dpy, ctx)) {
+         return NULL;
+      }
+   }
+   return ctx;
 #endif
-    return NULL;
+   return NULL;
 }
 
-PUBLIC void glXFreeContextEXT(Display *dpy, GLXContext ctx)
+PUBLIC void
+glXFreeContextEXT(Display * dpy, GLXContext ctx)
 {
-    DestroyContext(dpy, ctx);
+   DestroyContext(dpy, ctx);
 }
 
 
@@ -1354,114 +1405,116 @@
  * GLX 1.3 functions - these are just stubs for now!
  */
 
-PUBLIC GLXFBConfig *glXChooseFBConfig(Display *dpy, int screen,
-				      const int *attribList, int *nitems)
+PUBLIC GLXFBConfig *
+glXChooseFBConfig(Display * dpy, int screen,
+                  const int *attribList, int *nitems)
 {
-    __GLcontextModes ** config_list;
-    int   list_size;
+   __GLcontextModes **config_list;
+   int list_size;
 
 
-    config_list = (__GLcontextModes **) 
-	glXGetFBConfigs( dpy, screen, & list_size );
+   config_list = (__GLcontextModes **)
+      glXGetFBConfigs(dpy, screen, &list_size);
 
-    if ( (config_list != NULL) && (list_size > 0) && (attribList != NULL) ) {
-	list_size = choose_visual( config_list, list_size, attribList,
-				   GL_TRUE );
-	if ( list_size == 0 ) {
-	    XFree( config_list );
-	    config_list = NULL;
-	}
-    }
+   if ((config_list != NULL) && (list_size > 0) && (attribList != NULL)) {
+      list_size = choose_visual(config_list, list_size, attribList, GL_TRUE);
+      if (list_size == 0) {
+         XFree(config_list);
+         config_list = NULL;
+      }
+   }
 
-    *nitems = list_size;
-    return (GLXFBConfig *) config_list;
+   *nitems = list_size;
+   return (GLXFBConfig *) config_list;
 }
 
 
-PUBLIC GLXContext glXCreateNewContext(Display *dpy, GLXFBConfig config,
-				      int renderType, GLXContext shareList,
-				      Bool allowDirect)
+PUBLIC GLXContext
+glXCreateNewContext(Display * dpy, GLXFBConfig config,
+                    int renderType, GLXContext shareList, Bool allowDirect)
 {
-    return CreateContext( dpy, NULL, (__GLcontextModes *) config, shareList,
-			  allowDirect, None, True, renderType );
+   return CreateContext(dpy, NULL, (__GLcontextModes *) config, shareList,
+                        allowDirect, None, True, renderType);
 }
 
 
-PUBLIC GLXDrawable glXGetCurrentReadDrawable(void)
+PUBLIC GLXDrawable
+glXGetCurrentReadDrawable(void)
 {
-    GLXContext gc = __glXGetCurrentContext();
-    return gc->currentReadable;
+   GLXContext gc = __glXGetCurrentContext();
+   return gc->currentReadable;
 }
 
 
-PUBLIC GLXFBConfig *glXGetFBConfigs(Display *dpy, int screen, int *nelements)
+PUBLIC GLXFBConfig *
+glXGetFBConfigs(Display * dpy, int screen, int *nelements)
 {
-    __GLXdisplayPrivate *priv = __glXInitialize(dpy);
-    __GLcontextModes ** config = NULL;
-    int   i;
+   __GLXdisplayPrivate *priv = __glXInitialize(dpy);
+   __GLcontextModes **config = NULL;
+   int i;
 
-    *nelements = 0;
+   *nelements = 0;
 
-    if(!priv)
-        return NULL;
+   if (!priv)
+      return NULL;
 
-    if ( (priv->screenConfigs != NULL)
-	 && (screen >= 0) && (screen <= ScreenCount(dpy))
-	 && (priv->screenConfigs[screen].configs != NULL)
-	 && (priv->screenConfigs[screen].configs->fbconfigID != GLX_DONT_CARE) ) {
-	unsigned num_configs = 0;
-	__GLcontextModes * modes;
+   if ((priv->screenConfigs != NULL)
+       && (screen >= 0) && (screen <= ScreenCount(dpy))
+       && (priv->screenConfigs[screen].configs != NULL)
+       && (priv->screenConfigs[screen].configs->fbconfigID != GLX_DONT_CARE)) {
+      unsigned num_configs = 0;
+      __GLcontextModes *modes;
 
 
-	for ( modes = priv->screenConfigs[screen].configs
-	      ; modes != NULL
-	      ; modes = modes->next ) {
-	    if ( modes->fbconfigID != GLX_DONT_CARE ) {
-		num_configs++;
-	    }
-	}
+      for (modes = priv->screenConfigs[screen].configs; modes != NULL;
+           modes = modes->next) {
+         if (modes->fbconfigID != GLX_DONT_CARE) {
+            num_configs++;
+         }
+      }
 
-	config = (__GLcontextModes **) Xmalloc( sizeof(__GLcontextModes *)
-						* num_configs );
-	if ( config != NULL ) {
-	    *nelements = num_configs;
-	    i = 0;
-	    for ( modes = priv->screenConfigs[screen].configs
-		  ; modes != NULL
-		  ; modes = modes->next ) {
-		if ( modes->fbconfigID != GLX_DONT_CARE ) {
-		    config[i] = modes;
-		    i++;
-		}
-	    }
-	}
-    }
-    return (GLXFBConfig *) config;
+      config = (__GLcontextModes **) Xmalloc(sizeof(__GLcontextModes *)
+                                             * num_configs);
+      if (config != NULL) {
+         *nelements = num_configs;
+         i = 0;
+         for (modes = priv->screenConfigs[screen].configs; modes != NULL;
+              modes = modes->next) {
+            if (modes->fbconfigID != GLX_DONT_CARE) {
+               config[i] = modes;
+               i++;
+            }
+         }
+      }
+   }
+   return (GLXFBConfig *) config;
 }
 
 
-PUBLIC int glXGetFBConfigAttrib(Display *dpy, GLXFBConfig config,
-				int attribute, int *value)
+PUBLIC int
+glXGetFBConfigAttrib(Display * dpy, GLXFBConfig config,
+                     int attribute, int *value)
 {
-    __GLcontextModes * const modes = ValidateGLXFBConfig( dpy, config );
+   __GLcontextModes *const modes = ValidateGLXFBConfig(dpy, config);
 
-    return (modes != NULL)
-	? _gl_get_context_mode_data( modes, attribute, value )
-	: GLXBadFBConfig;
+   return (modes != NULL)
+      ? _gl_get_context_mode_data(modes, attribute, value)
+      : GLXBadFBConfig;
 }
 
 
-PUBLIC XVisualInfo *glXGetVisualFromFBConfig(Display *dpy, GLXFBConfig config)
+PUBLIC XVisualInfo *
+glXGetVisualFromFBConfig(Display * dpy, GLXFBConfig config)
 {
-    XVisualInfo visualTemplate;
-    __GLcontextModes * fbconfig = (__GLcontextModes *) config;
-    int  count;
+   XVisualInfo visualTemplate;
+   __GLcontextModes *fbconfig = (__GLcontextModes *) config;
+   int count;
 
-    /*
+   /*
     ** Get a list of all visuals, return if list is empty
     */
-    visualTemplate.visualid = fbconfig->visualID;
-    return XGetVisualInfo(dpy,VisualIDMask,&visualTemplate,&count);
+   visualTemplate.visualid = fbconfig->visualID;
+   return XGetVisualInfo(dpy, VisualIDMask, &visualTemplate, &count);
 }
 
 /*
@@ -1470,223 +1523,223 @@
 ** GLX_functions table.
 */
 
-PUBLIC GLX_ALIAS(int, glXGetFBConfigAttribSGIX,
-	  (Display *dpy, GLXFBConfigSGIX config, int attribute, int *value),
-	  (dpy, config, attribute, value),
-	  glXGetFBConfigAttrib)
+PUBLIC
+GLX_ALIAS(int, glXGetFBConfigAttribSGIX,
+          (Display * dpy, GLXFBConfigSGIX config, int attribute, int *value),
+          (dpy, config, attribute, value), glXGetFBConfigAttrib)
 
-PUBLIC GLX_ALIAS(GLXFBConfigSGIX *, glXChooseFBConfigSGIX,
-	  (Display *dpy, int screen, int *attrib_list, int *nelements),
-	  (dpy, screen, attrib_list, nelements),
-	  glXChooseFBConfig)
+     PUBLIC GLX_ALIAS(GLXFBConfigSGIX *, glXChooseFBConfigSGIX,
+                      (Display * dpy, int screen, int *attrib_list,
+                       int *nelements), (dpy, screen, attrib_list, nelements),
+                      glXChooseFBConfig)
 
-PUBLIC GLX_ALIAS(XVisualInfo *, glXGetVisualFromFBConfigSGIX,
-	  (Display * dpy, GLXFBConfigSGIX config),
-	  (dpy, config),
-	  glXGetVisualFromFBConfig)
+     PUBLIC GLX_ALIAS(XVisualInfo *, glXGetVisualFromFBConfigSGIX,
+                      (Display * dpy, GLXFBConfigSGIX config),
+                      (dpy, config), glXGetVisualFromFBConfig)
 
-PUBLIC GLXPixmap glXCreateGLXPixmapWithConfigSGIX(Display *dpy,
-                            GLXFBConfigSGIX config, Pixmap pixmap)
+     PUBLIC GLXPixmap glXCreateGLXPixmapWithConfigSGIX(Display * dpy,
+                                                       GLXFBConfigSGIX config,
+                                                       Pixmap pixmap)
 {
-    xGLXVendorPrivateWithReplyReq *vpreq;
-    xGLXCreateGLXPixmapWithConfigSGIXReq *req;
-    GLXPixmap xid = None;
-    CARD8 opcode;
-    const __GLcontextModes * const fbconfig = (__GLcontextModes *) config;
-    __GLXscreenConfigs * psc;
+   xGLXVendorPrivateWithReplyReq *vpreq;
+   xGLXCreateGLXPixmapWithConfigSGIXReq *req;
+   GLXPixmap xid = None;
+   CARD8 opcode;
+   const __GLcontextModes *const fbconfig = (__GLcontextModes *) config;
+   __GLXscreenConfigs *psc;
 
 
-    if ( (dpy == NULL) || (config == NULL) ) {
-	return None;
-    }
+   if ((dpy == NULL) || (config == NULL)) {
+      return None;
+   }
 
-    if(apple_glx_pixmap_create(dpy, fbconfig->screen, pixmap, fbconfig))
-	return None;
+   if (apple_glx_pixmap_create(dpy, fbconfig->screen, pixmap, fbconfig))
+      return None;
 
-    return pixmap;
+   return pixmap;
 
 
-    psc = GetGLXScreenConfigs( dpy, fbconfig->screen );
-    if ( (psc != NULL) 
-	 && __glXExtensionBitIsEnabled( psc, SGIX_fbconfig_bit ) ) {
-	opcode = __glXSetupForCommand(dpy);
-	if (!opcode) {
-	    return None;
-	}
+   psc = GetGLXScreenConfigs(dpy, fbconfig->screen);
+   if ((psc != NULL)
+       && __glXExtensionBitIsEnabled(psc, SGIX_fbconfig_bit)) {
+      opcode = __glXSetupForCommand(dpy);
+      if (!opcode) {
+         return None;
+      }
 
-	/* Send the glXCreateGLXPixmapWithConfigSGIX request */
-	LockDisplay(dpy);
-	GetReqExtra(GLXVendorPrivateWithReply,
-		    sz_xGLXCreateGLXPixmapWithConfigSGIXReq-sz_xGLXVendorPrivateWithReplyReq,vpreq);
-	req = (xGLXCreateGLXPixmapWithConfigSGIXReq *)vpreq;
-	req->reqType = opcode;
-	req->glxCode = X_GLXVendorPrivateWithReply;
-	req->vendorCode = X_GLXvop_CreateGLXPixmapWithConfigSGIX;
-	req->screen = fbconfig->screen;
-	req->fbconfig = fbconfig->fbconfigID;
-	req->pixmap = pixmap;
-	req->glxpixmap = xid = XAllocID(dpy);
-	UnlockDisplay(dpy);
-	SyncHandle();
-    }
+      /* Send the glXCreateGLXPixmapWithConfigSGIX request */
+      LockDisplay(dpy);
+      GetReqExtra(GLXVendorPrivateWithReply,
+                  sz_xGLXCreateGLXPixmapWithConfigSGIXReq -
+                  sz_xGLXVendorPrivateWithReplyReq, vpreq);
+      req = (xGLXCreateGLXPixmapWithConfigSGIXReq *) vpreq;
+      req->reqType = opcode;
+      req->glxCode = X_GLXVendorPrivateWithReply;
+      req->vendorCode = X_GLXvop_CreateGLXPixmapWithConfigSGIX;
+      req->screen = fbconfig->screen;
+      req->fbconfig = fbconfig->fbconfigID;
+      req->pixmap = pixmap;
+      req->glxpixmap = xid = XAllocID(dpy);
+      UnlockDisplay(dpy);
+      SyncHandle();
+   }
 
-    return xid;
+   return xid;
 }
 
-PUBLIC GLXContext glXCreateContextWithConfigSGIX(Display *dpy,
-                             GLXFBConfigSGIX config, int renderType,
-                             GLXContext shareList, Bool allowDirect)
+PUBLIC GLXContext
+glXCreateContextWithConfigSGIX(Display * dpy,
+                               GLXFBConfigSGIX config, int renderType,
+                               GLXContext shareList, Bool allowDirect)
 {
-    GLXContext gc = NULL;
-    const __GLcontextModes * const fbconfig = (__GLcontextModes *) config;
-    __GLXscreenConfigs * psc;
+   GLXContext gc = NULL;
+   const __GLcontextModes *const fbconfig = (__GLcontextModes *) config;
+   __GLXscreenConfigs *psc;
 
 
-    if ( (dpy == NULL) || (config == NULL) ) {
-	return None;
-    }
+   if ((dpy == NULL) || (config == NULL)) {
+      return None;
+   }
 
-    psc = GetGLXScreenConfigs( dpy, fbconfig->screen );
-    if ( (psc != NULL) 
-	 && __glXExtensionBitIsEnabled( psc, SGIX_fbconfig_bit ) ) {
-	gc = CreateContext( dpy, NULL, (__GLcontextModes *) config, shareList,
-			    allowDirect, None, False, renderType );
-    }
+   psc = GetGLXScreenConfigs(dpy, fbconfig->screen);
+   if ((psc != NULL)
+       && __glXExtensionBitIsEnabled(psc, SGIX_fbconfig_bit)) {
+      gc = CreateContext(dpy, NULL, (__GLcontextModes *) config, shareList,
+                         allowDirect, None, False, renderType);
+   }
 
-    return gc;
+   return gc;
 }
 
 
-PUBLIC GLXFBConfigSGIX glXGetFBConfigFromVisualSGIX(Display *dpy,
-						    XVisualInfo *vis)
+PUBLIC GLXFBConfigSGIX
+glXGetFBConfigFromVisualSGIX(Display * dpy, XVisualInfo * vis)
 {
-    __GLXdisplayPrivate *priv;
-    __GLXscreenConfigs *psc;
+   __GLXdisplayPrivate *priv;
+   __GLXscreenConfigs *psc;
 
-    if ( (GetGLXPrivScreenConfig( dpy, vis->screen, & priv, & psc ) != Success)
-	 && __glXExtensionBitIsEnabled( psc, SGIX_fbconfig_bit )
-	 && (psc->configs->fbconfigID != GLX_DONT_CARE) ) {
-	return (GLXFBConfigSGIX) _gl_context_modes_find_visual( psc->configs,
-								vis->visualid );
-    }
+   if ((GetGLXPrivScreenConfig(dpy, vis->screen, &priv, &psc) != Success)
+       && __glXExtensionBitIsEnabled(psc, SGIX_fbconfig_bit)
+       && (psc->configs->fbconfigID != GLX_DONT_CARE)) {
+      return (GLXFBConfigSGIX) _gl_context_modes_find_visual(psc->configs,
+                                                             vis->visualid);
+   }
 
-    return NULL;
+   return NULL;
 }
 
-#if 0 /* AppleSGLX may someday need to support this for X11 OpenGL
-	 compositing managers. */
+#if 0                           /* AppleSGLX may someday need to support this for X11 OpenGL
+                                   compositing managers. */
 /**
  * GLX_EXT_texture_from_pixmap
  */
 /*@{*/
-static void __glXBindTexImageEXT(Display *dpy,
-				 GLXDrawable drawable,
-				 int buffer,
-				 const int *attrib_list)
+static void
+__glXBindTexImageEXT(Display * dpy,
+                     GLXDrawable drawable, int buffer, const int *attrib_list)
 {
-    xGLXVendorPrivateReq *req;
-    GLXContext gc = __glXGetCurrentContext();
-    CARD32 *drawable_ptr;
-    INT32 *buffer_ptr;
-    CARD32 *num_attrib_ptr;
-    CARD32 *attrib_ptr;
-    CARD8 opcode;
-    unsigned int i;
+   xGLXVendorPrivateReq *req;
+   GLXContext gc = __glXGetCurrentContext();
+   CARD32 *drawable_ptr;
+   INT32 *buffer_ptr;
+   CARD32 *num_attrib_ptr;
+   CARD32 *attrib_ptr;
+   CARD8 opcode;
+   unsigned int i;
 
-    if (gc == NULL)
-	return;
+   if (gc == NULL)
+      return;
 
-    i = 0;
-    if (attrib_list) {
- 	while (attrib_list[i * 2] != None)
- 	    i++;
-    }
- 
+   i = 0;
+   if (attrib_list) {
+      while (attrib_list[i * 2] != None)
+         i++;
+   }
+
 #ifdef GLX_DIRECT_RENDERING
-    if (gc->driContext) {
-	__GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, NULL);
+   if (gc->driContext) {
+      __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, NULL);
 
-	if (pdraw != NULL)
-	    (*pdraw->psc->texBuffer->setTexBuffer)(gc->__driContext,
-						   pdraw->textureTarget,
-						   pdraw->driDrawable);
+      if (pdraw != NULL)
+         (*pdraw->psc->texBuffer->setTexBuffer) (gc->__driContext,
+                                                 pdraw->textureTarget,
+                                                 pdraw->driDrawable);
 
-	return;
-    }
+      return;
+   }
 #endif
 
-    opcode = __glXSetupForCommand(dpy);
-    if (!opcode)
-	return;
+   opcode = __glXSetupForCommand(dpy);
+   if (!opcode)
+      return;
 
-    LockDisplay(dpy);
-    GetReqExtra(GLXVendorPrivate, 12 + 8 * i,req);
-    req->reqType = opcode;
-    req->glxCode = X_GLXVendorPrivate;
-    req->vendorCode = X_GLXvop_BindTexImageEXT;
-    req->contextTag = gc->currentContextTag;
+   LockDisplay(dpy);
+   GetReqExtra(GLXVendorPrivate, 12 + 8 * i, req);
+   req->reqType = opcode;
+   req->glxCode = X_GLXVendorPrivate;
+   req->vendorCode = X_GLXvop_BindTexImageEXT;
+   req->contextTag = gc->currentContextTag;
 
-    drawable_ptr = (CARD32 *) (req + 1);
-    buffer_ptr = (INT32 *) (drawable_ptr + 1);
-    num_attrib_ptr = (CARD32 *) (buffer_ptr + 1);
-    attrib_ptr = (CARD32 *) (num_attrib_ptr + 1);
+   drawable_ptr = (CARD32 *) (req + 1);
+   buffer_ptr = (INT32 *) (drawable_ptr + 1);
+   num_attrib_ptr = (CARD32 *) (buffer_ptr + 1);
+   attrib_ptr = (CARD32 *) (num_attrib_ptr + 1);
 
-    *drawable_ptr = drawable;
-    *buffer_ptr = buffer;
-    *num_attrib_ptr = (CARD32) i;
+   *drawable_ptr = drawable;
+   *buffer_ptr = buffer;
+   *num_attrib_ptr = (CARD32) i;
 
-    i = 0;
-    if (attrib_list) {
- 	while (attrib_list[i * 2] != None)
- 	{
- 	    *attrib_ptr++ = (CARD32) attrib_list[i * 2 + 0];
- 	    *attrib_ptr++ = (CARD32) attrib_list[i * 2 + 1];
- 	    i++;
- 	}
-    }
+   i = 0;
+   if (attrib_list) {
+      while (attrib_list[i * 2] != None) {
+         *attrib_ptr++ = (CARD32) attrib_list[i * 2 + 0];
+         *attrib_ptr++ = (CARD32) attrib_list[i * 2 + 1];
+         i++;
+      }
+   }
 
-    UnlockDisplay(dpy);
-    SyncHandle();
+   UnlockDisplay(dpy);
+   SyncHandle();
 }
 
-static void __glXReleaseTexImageEXT(Display *dpy,
-				    GLXDrawable drawable,
-				    int buffer)
+static void
+__glXReleaseTexImageEXT(Display * dpy, GLXDrawable drawable, int buffer)
 {
-    xGLXVendorPrivateReq *req;
-    GLXContext gc = __glXGetCurrentContext();
-    CARD32 *drawable_ptr;
-    INT32 *buffer_ptr;
-    CARD8 opcode;
+   xGLXVendorPrivateReq *req;
+   GLXContext gc = __glXGetCurrentContext();
+   CARD32 *drawable_ptr;
+   INT32 *buffer_ptr;
+   CARD8 opcode;
 
-    if (gc == NULL)
-	return;
+   if (gc == NULL)
+      return;
 
 #ifdef GLX_DIRECT_RENDERING
-    if (gc->driContext)
-	return;
+   if (gc->driContext)
+      return;
 #endif
 
-    opcode = __glXSetupForCommand(dpy);
-    if (!opcode)
-	return;
+   opcode = __glXSetupForCommand(dpy);
+   if (!opcode)
+      return;
 
-    LockDisplay(dpy);
-    GetReqExtra(GLXVendorPrivate, sizeof(CARD32)+sizeof(INT32),req);
-    req->reqType = opcode;
-    req->glxCode = X_GLXVendorPrivate;
-    req->vendorCode = X_GLXvop_ReleaseTexImageEXT;
-    req->contextTag = gc->currentContextTag;
+   LockDisplay(dpy);
+   GetReqExtra(GLXVendorPrivate, sizeof(CARD32) + sizeof(INT32), req);
+   req->reqType = opcode;
+   req->glxCode = X_GLXVendorPrivate;
+   req->vendorCode = X_GLXvop_ReleaseTexImageEXT;
+   req->contextTag = gc->currentContextTag;
 
-    drawable_ptr = (CARD32 *) (req + 1);
-    buffer_ptr = (INT32 *) (drawable_ptr + 1);
+   drawable_ptr = (CARD32 *) (req + 1);
+   buffer_ptr = (INT32 *) (drawable_ptr + 1);
 
-    *drawable_ptr = drawable;
-    *buffer_ptr = buffer;
+   *drawable_ptr = drawable;
+   *buffer_ptr = buffer;
 
-    UnlockDisplay(dpy);
-    SyncHandle();
+   UnlockDisplay(dpy);
+   SyncHandle();
 }
+
 /*@}*/
 
 #endif
@@ -1712,7 +1765,8 @@
 ** glXGetProcAddress support
 */
 
-struct name_address_pair {
+struct name_address_pair
+{
    const char *Name;
    GLvoid *Address;
 };
@@ -1722,145 +1776,145 @@
 
 static const struct name_address_pair GLX_functions[] = {
    /*** GLX_VERSION_1_0 ***/
-   GLX_FUNCTION( glXChooseVisual ),
-   GLX_FUNCTION( glXCopyContext ),
-   GLX_FUNCTION( glXCreateContext ),
-   GLX_FUNCTION( glXCreateGLXPixmap ),
-   GLX_FUNCTION( glXDestroyContext ),
-   GLX_FUNCTION( glXDestroyGLXPixmap ),
-   GLX_FUNCTION( glXGetConfig ),
-   GLX_FUNCTION( glXGetCurrentContext ),
-   GLX_FUNCTION( glXGetCurrentDrawable ),
-   GLX_FUNCTION( glXIsDirect ),
-   GLX_FUNCTION( glXMakeCurrent ),
-   GLX_FUNCTION( glXQueryExtension ),
-   GLX_FUNCTION( glXQueryVersion ),
-   GLX_FUNCTION( glXSwapBuffers ),
-   GLX_FUNCTION( glXUseXFont ),
-   GLX_FUNCTION( glXWaitGL ),
-   GLX_FUNCTION( glXWaitX ),
+   GLX_FUNCTION(glXChooseVisual),
+   GLX_FUNCTION(glXCopyContext),
+   GLX_FUNCTION(glXCreateContext),
+   GLX_FUNCTION(glXCreateGLXPixmap),
+   GLX_FUNCTION(glXDestroyContext),
+   GLX_FUNCTION(glXDestroyGLXPixmap),
+   GLX_FUNCTION(glXGetConfig),
+   GLX_FUNCTION(glXGetCurrentContext),
+   GLX_FUNCTION(glXGetCurrentDrawable),
+   GLX_FUNCTION(glXIsDirect),
+   GLX_FUNCTION(glXMakeCurrent),
+   GLX_FUNCTION(glXQueryExtension),
+   GLX_FUNCTION(glXQueryVersion),
+   GLX_FUNCTION(glXSwapBuffers),
+   GLX_FUNCTION(glXUseXFont),
+   GLX_FUNCTION(glXWaitGL),
+   GLX_FUNCTION(glXWaitX),
 
    /*** GLX_VERSION_1_1 ***/
-   GLX_FUNCTION( glXGetClientString ),
-   GLX_FUNCTION( glXQueryExtensionsString ),
-   GLX_FUNCTION( glXQueryServerString ),
+   GLX_FUNCTION(glXGetClientString),
+   GLX_FUNCTION(glXQueryExtensionsString),
+   GLX_FUNCTION(glXQueryServerString),
 
    /*** GLX_VERSION_1_2 ***/
-   GLX_FUNCTION( glXGetCurrentDisplay ),
+   GLX_FUNCTION(glXGetCurrentDisplay),
 
    /*** GLX_VERSION_1_3 ***/
-   GLX_FUNCTION( glXChooseFBConfig ),
-   GLX_FUNCTION( glXCreateNewContext ),
-   GLX_FUNCTION( glXCreatePbuffer ),
-   GLX_FUNCTION( glXCreatePixmap ),
-   GLX_FUNCTION( glXCreateWindow ),
-   GLX_FUNCTION( glXDestroyPbuffer ),
-   GLX_FUNCTION( glXDestroyPixmap ),
-   GLX_FUNCTION( glXDestroyWindow ),
-   GLX_FUNCTION( glXGetCurrentReadDrawable ),
-   GLX_FUNCTION( glXGetFBConfigAttrib ),
-   GLX_FUNCTION( glXGetFBConfigs ),
-   GLX_FUNCTION( glXGetSelectedEvent ),
-   GLX_FUNCTION( glXGetVisualFromFBConfig ),
-   GLX_FUNCTION( glXMakeContextCurrent ),
-   GLX_FUNCTION( glXQueryContext ),
-   GLX_FUNCTION( glXQueryDrawable ),
-   GLX_FUNCTION( glXSelectEvent ),
+   GLX_FUNCTION(glXChooseFBConfig),
+   GLX_FUNCTION(glXCreateNewContext),
+   GLX_FUNCTION(glXCreatePbuffer),
+   GLX_FUNCTION(glXCreatePixmap),
+   GLX_FUNCTION(glXCreateWindow),
+   GLX_FUNCTION(glXDestroyPbuffer),
+   GLX_FUNCTION(glXDestroyPixmap),
+   GLX_FUNCTION(glXDestroyWindow),
+   GLX_FUNCTION(glXGetCurrentReadDrawable),
+   GLX_FUNCTION(glXGetFBConfigAttrib),
+   GLX_FUNCTION(glXGetFBConfigs),
+   GLX_FUNCTION(glXGetSelectedEvent),
+   GLX_FUNCTION(glXGetVisualFromFBConfig),
+   GLX_FUNCTION(glXMakeContextCurrent),
+   GLX_FUNCTION(glXQueryContext),
+   GLX_FUNCTION(glXQueryDrawable),
+   GLX_FUNCTION(glXSelectEvent),
 
 #if 0
    /*** GLX_SGI_swap_control ***/
-   GLX_FUNCTION2( glXSwapIntervalSGI, __glXSwapIntervalSGI ),
+   GLX_FUNCTION2(glXSwapIntervalSGI, __glXSwapIntervalSGI),
 
    /*** GLX_SGI_video_sync ***/
-   GLX_FUNCTION2( glXGetVideoSyncSGI, __glXGetVideoSyncSGI ),
-   GLX_FUNCTION2( glXWaitVideoSyncSGI, __glXWaitVideoSyncSGI ),
+   GLX_FUNCTION2(glXGetVideoSyncSGI, __glXGetVideoSyncSGI),
+   GLX_FUNCTION2(glXWaitVideoSyncSGI, __glXWaitVideoSyncSGI),
 
    /*** GLX_SGI_make_current_read ***/
-   GLX_FUNCTION2( glXMakeCurrentReadSGI, glXMakeContextCurrent ),
-   GLX_FUNCTION2( glXGetCurrentReadDrawableSGI, glXGetCurrentReadDrawable ),
+   GLX_FUNCTION2(glXMakeCurrentReadSGI, glXMakeContextCurrent),
+   GLX_FUNCTION2(glXGetCurrentReadDrawableSGI, glXGetCurrentReadDrawable),
 
    /*** GLX_EXT_import_context ***/
-   GLX_FUNCTION( glXFreeContextEXT ),
-   GLX_FUNCTION( glXGetContextIDEXT ),
-   GLX_FUNCTION2( glXGetCurrentDisplayEXT, glXGetCurrentDisplay ),
-   GLX_FUNCTION( glXImportContextEXT ),
-   GLX_FUNCTION2( glXQueryContextInfoEXT, glXQueryContext ),
+   GLX_FUNCTION(glXFreeContextEXT),
+   GLX_FUNCTION(glXGetContextIDEXT),
+   GLX_FUNCTION2(glXGetCurrentDisplayEXT, glXGetCurrentDisplay),
+   GLX_FUNCTION(glXImportContextEXT),
+   GLX_FUNCTION2(glXQueryContextInfoEXT, glXQueryContext),
 #endif
 
    /*** GLX_SGIX_fbconfig ***/
-   GLX_FUNCTION2( glXGetFBConfigAttribSGIX, glXGetFBConfigAttrib ),
-   GLX_FUNCTION2( glXChooseFBConfigSGIX, glXChooseFBConfig ),
-   GLX_FUNCTION( glXCreateGLXPixmapWithConfigSGIX ),
-   GLX_FUNCTION( glXCreateContextWithConfigSGIX ),
-   GLX_FUNCTION2( glXGetVisualFromFBConfigSGIX, glXGetVisualFromFBConfig ),
-   GLX_FUNCTION( glXGetFBConfigFromVisualSGIX ),
+   GLX_FUNCTION2(glXGetFBConfigAttribSGIX, glXGetFBConfigAttrib),
+   GLX_FUNCTION2(glXChooseFBConfigSGIX, glXChooseFBConfig),
+   GLX_FUNCTION(glXCreateGLXPixmapWithConfigSGIX),
+   GLX_FUNCTION(glXCreateContextWithConfigSGIX),
+   GLX_FUNCTION2(glXGetVisualFromFBConfigSGIX, glXGetVisualFromFBConfig),
+   GLX_FUNCTION(glXGetFBConfigFromVisualSGIX),
 
 #if 0
    /*** GLX_SGIX_pbuffer ***/
-   GLX_FUNCTION( glXCreateGLXPbufferSGIX ),
-   GLX_FUNCTION( glXDestroyGLXPbufferSGIX ),
-   GLX_FUNCTION( glXQueryGLXPbufferSGIX ),
-   GLX_FUNCTION( glXSelectEventSGIX ),
-   GLX_FUNCTION( glXGetSelectedEventSGIX ),
+   GLX_FUNCTION(glXCreateGLXPbufferSGIX),
+   GLX_FUNCTION(glXDestroyGLXPbufferSGIX),
+   GLX_FUNCTION(glXQueryGLXPbufferSGIX),
+   GLX_FUNCTION(glXSelectEventSGIX),
+   GLX_FUNCTION(glXGetSelectedEventSGIX),
 
    /*** GLX_SGIX_swap_group ***/
-   GLX_FUNCTION2( glXJoinSwapGroupSGIX, __glXJoinSwapGroupSGIX ),
+   GLX_FUNCTION2(glXJoinSwapGroupSGIX, __glXJoinSwapGroupSGIX),
 
    /*** GLX_SGIX_swap_barrier ***/
-   GLX_FUNCTION2( glXBindSwapBarrierSGIX, __glXBindSwapBarrierSGIX ),
-   GLX_FUNCTION2( glXQueryMaxSwapBarriersSGIX, __glXQueryMaxSwapBarriersSGIX ),
+   GLX_FUNCTION2(glXBindSwapBarrierSGIX, __glXBindSwapBarrierSGIX),
+   GLX_FUNCTION2(glXQueryMaxSwapBarriersSGIX, __glXQueryMaxSwapBarriersSGIX),
 
    /*** GLX_MESA_allocate_memory ***/
-   GLX_FUNCTION( glXAllocateMemoryMESA ),
-   GLX_FUNCTION( glXFreeMemoryMESA ),
-   GLX_FUNCTION( glXGetMemoryOffsetMESA ),
+   GLX_FUNCTION(glXAllocateMemoryMESA),
+   GLX_FUNCTION(glXFreeMemoryMESA),
+   GLX_FUNCTION(glXGetMemoryOffsetMESA),
 
    /*** GLX_MESA_copy_sub_buffer ***/
-   GLX_FUNCTION2( glXCopySubBufferMESA, __glXCopySubBufferMESA ),
+   GLX_FUNCTION2(glXCopySubBufferMESA, __glXCopySubBufferMESA),
 
    /*** GLX_MESA_pixmap_colormap ***/
-   GLX_FUNCTION( glXCreateGLXPixmapMESA ),
+   GLX_FUNCTION(glXCreateGLXPixmapMESA),
 
    /*** GLX_MESA_release_buffers ***/
-   GLX_FUNCTION2( glXReleaseBuffersMESA, __glXReleaseBuffersMESA ),
+   GLX_FUNCTION2(glXReleaseBuffersMESA, __glXReleaseBuffersMESA),
 
    /*** GLX_MESA_swap_control ***/
-   GLX_FUNCTION2( glXSwapIntervalMESA, __glXSwapIntervalMESA ),
-   GLX_FUNCTION2( glXGetSwapIntervalMESA, __glXGetSwapIntervalMESA ),
+   GLX_FUNCTION2(glXSwapIntervalMESA, __glXSwapIntervalMESA),
+   GLX_FUNCTION2(glXGetSwapIntervalMESA, __glXGetSwapIntervalMESA),
 
    /*** GLX_MESA_swap_frame_usage ***/
-   GLX_FUNCTION2( glXBeginFrameTrackingMESA, __glXBeginFrameTrackingMESA ),
-   GLX_FUNCTION2( glXEndFrameTrackingMESA, __glXEndFrameTrackingMESA ),
-   GLX_FUNCTION2( glXGetFrameUsageMESA, __glXGetFrameUsageMESA ),
-   GLX_FUNCTION2( glXQueryFrameTrackingMESA, __glXQueryFrameTrackingMESA ),
+   GLX_FUNCTION2(glXBeginFrameTrackingMESA, __glXBeginFrameTrackingMESA),
+   GLX_FUNCTION2(glXEndFrameTrackingMESA, __glXEndFrameTrackingMESA),
+   GLX_FUNCTION2(glXGetFrameUsageMESA, __glXGetFrameUsageMESA),
+   GLX_FUNCTION2(glXQueryFrameTrackingMESA, __glXQueryFrameTrackingMESA),
 #endif
 
    /*** GLX_ARB_get_proc_address ***/
-   GLX_FUNCTION( glXGetProcAddressARB ),
+   GLX_FUNCTION(glXGetProcAddressARB),
 
    /*** GLX 1.4 ***/
-   GLX_FUNCTION2( glXGetProcAddress, glXGetProcAddressARB ),
+   GLX_FUNCTION2(glXGetProcAddress, glXGetProcAddressARB),
 
 #if 0
    /*** GLX_OML_sync_control ***/
-   GLX_FUNCTION2( glXWaitForSbcOML, __glXWaitForSbcOML ),
-   GLX_FUNCTION2( glXWaitForMscOML, __glXWaitForMscOML ),
-   GLX_FUNCTION2( glXSwapBuffersMscOML, __glXSwapBuffersMscOML ),
-   GLX_FUNCTION2( glXGetMscRateOML, __glXGetMscRateOML ),
-   GLX_FUNCTION2( glXGetSyncValuesOML, __glXGetSyncValuesOML ),
+   GLX_FUNCTION2(glXWaitForSbcOML, __glXWaitForSbcOML),
+   GLX_FUNCTION2(glXWaitForMscOML, __glXWaitForMscOML),
+   GLX_FUNCTION2(glXSwapBuffersMscOML, __glXSwapBuffersMscOML),
+   GLX_FUNCTION2(glXGetMscRateOML, __glXGetMscRateOML),
+   GLX_FUNCTION2(glXGetSyncValuesOML, __glXGetSyncValuesOML),
 
    /*** GLX_EXT_texture_from_pixmap ***/
-   GLX_FUNCTION2( glXBindTexImageEXT, __glXBindTexImageEXT ),
-   GLX_FUNCTION2( glXReleaseTexImageEXT, __glXReleaseTexImageEXT ),
+   GLX_FUNCTION2(glXBindTexImageEXT, __glXBindTexImageEXT),
+   GLX_FUNCTION2(glXReleaseTexImageEXT, __glXReleaseTexImageEXT),
 #endif
 
 #ifdef GLX_DIRECT_RENDERING
    /*** DRI configuration ***/
-   GLX_FUNCTION( glXGetScreenDriver ),
-   GLX_FUNCTION( glXGetDriverConfig ),
+   GLX_FUNCTION(glXGetScreenDriver),
+   GLX_FUNCTION(glXGetDriverConfig),
 #endif
 
-   { NULL, NULL }   /* end of list */
+   {NULL, NULL}                 /* end of list */
 };
 
 
@@ -1873,9 +1927,9 @@
  *
  * \sa glXGetProcAddress
  */
-PUBLIC void (*glXGetProcAddressARB(const GLubyte *procName))( void )
+PUBLIC void (*glXGetProcAddressARB(const GLubyte * procName)) (void)
 {
-   typedef void (*gl_function)( void );
+   typedef void (*gl_function) (void);
    gl_function f;
 
    /* Search the table of GLX and internal functions first.  If that
@@ -1884,7 +1938,7 @@
     * DRI based drivers from searching the core GL function table for
     * internal API functions.
     */
-   
+
    f = (gl_function) apple_glx_get_proc_address(procName);
 
    return f;
@@ -1899,9 +1953,9 @@
  *
  * \sa glXGetProcAddressARB
  */
-PUBLIC void (*glXGetProcAddress(const GLubyte *procName))( void )
+PUBLIC void (*glXGetProcAddress(const GLubyte * procName)) (void)
 #if defined(__GNUC__) && !defined(GLX_ALIAS_UNSUPPORTED)
-    __attribute__ ((alias ("glXGetProcAddressARB")));
+   __attribute__ ((alias("glXGetProcAddressARB")));
 #else
 {
    return glXGetProcAddressARB(procName);
@@ -1924,19 +1978,21 @@
  *
  * \since Internal API version 20030317.
  */
-_X_HIDDEN int __glXGetUST( int64_t * ust )
+_X_HIDDEN int
+__glXGetUST(int64_t * ust)
 {
-    struct timeval  tv;
-    
-    if ( ust == NULL ) {
-	return -EFAULT;
-    }
+   struct timeval tv;
 
-    if ( gettimeofday( & tv, NULL ) == 0 ) {
-	ust[0] = (tv.tv_sec * 1000000) + tv.tv_usec;
-	return 0;
-    } else {
-	return -errno;
-    }
+   if (ust == NULL) {
+      return -EFAULT;
+   }
+
+   if (gettimeofday(&tv, NULL) == 0) {
+      ust[0] = (tv.tv_sec * 1000000) + tv.tv_usec;
+      return 0;
+   }
+   else {
+      return -errno;
+   }
 }
 #endif /* GLX_DIRECT_RENDERING */

Modified: AppleSGLX/trunk/glxcurrent.c
===================================================================
--- AppleSGLX/trunk/glxcurrent.c	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/glxcurrent.c	2009-12-21 20:56:26 UTC (rev 386)
@@ -53,11 +53,11 @@
 ** the dummy context structure.
 */
 static __GLXcontext dummyContext = {
-    &dummyBuffer[0],
-    &dummyBuffer[0],
-    &dummyBuffer[0],
-    &dummyBuffer[__GLX_BUFFER_LIMIT_SIZE],
-    sizeof(dummyBuffer),
+   &dummyBuffer[0],
+   &dummyBuffer[0],
+   &dummyBuffer[0],
+   &dummyBuffer[__GLX_BUFFER_LIMIT_SIZE],
+   sizeof(dummyBuffer),
 };
 
 /*
@@ -83,130 +83,143 @@
  * initialize the per-thread data key.  This is ideally done using the
  * \c pthread_once mechanism.
  */
-static void init_thread_data( void )
+static void
+init_thread_data(void)
 {
-    if (pthread_key_create(&ContextTSD, NULL) != 0) {
-	perror("pthread_key_create");
-	exit(EXIT_FAILURE);
-    }
+   if (pthread_key_create(&ContextTSD, NULL) != 0) {
+      perror("pthread_key_create");
+      exit(EXIT_FAILURE);
+   }
 }
 
-_X_HIDDEN void __glXSetCurrentContext( __GLXcontext * c ) {
-    pthread_once(&once_control, init_thread_data);
-    pthread_setspecific(ContextTSD, c);
+_X_HIDDEN void
+__glXSetCurrentContext(__GLXcontext * c)
+{
+   pthread_once(&once_control, init_thread_data);
+   pthread_setspecific(ContextTSD, c);
 }
 
-_X_HIDDEN __GLXcontext * __glXGetCurrentContext( void )
+_X_HIDDEN __GLXcontext *
+__glXGetCurrentContext(void)
 {
-    void * v;
+   void *v;
 
-    pthread_once(& once_control, init_thread_data);
+   pthread_once(&once_control, init_thread_data);
 
-    v = pthread_getspecific( ContextTSD );
-    return (v == NULL) ? & dummyContext : (__GLXcontext *) v;
+   v = pthread_getspecific(ContextTSD);
+   return (v == NULL) ? &dummyContext : (__GLXcontext *) v;
 }
 
 
-_X_HIDDEN void __glXSetCurrentContextNull(void) {
-    __glXSetCurrentContext(&dummyContext);
+_X_HIDDEN void
+__glXSetCurrentContextNull(void)
+{
+   __glXSetCurrentContext(&dummyContext);
 }
 
 
 /************************************************************************/
 
-PUBLIC GLXContext glXGetCurrentContext(void)
+PUBLIC GLXContext
+glXGetCurrentContext(void)
 {
-    GLXContext cx = __glXGetCurrentContext();
-    
-    if (cx == &dummyContext) {
-	return NULL;
-    } else {
-	return cx;
-    }
+   GLXContext cx = __glXGetCurrentContext();
+
+   if (cx == &dummyContext) {
+      return NULL;
+   }
+   else {
+      return cx;
+   }
 }
 
-PUBLIC GLXDrawable glXGetCurrentDrawable(void)
+PUBLIC GLXDrawable
+glXGetCurrentDrawable(void)
 {
-    GLXContext gc = __glXGetCurrentContext();
-    return gc->currentDrawable;
+   GLXContext gc = __glXGetCurrentContext();
+   return gc->currentDrawable;
 }
 
-static Bool MakeContextCurrent(Display *dpy, GLXDrawable draw,
-			       GLXDrawable read, GLXContext gc,
-			       Bool pre13)
+static Bool
+MakeContextCurrent(Display * dpy, GLXDrawable draw,
+                   GLXDrawable read, GLXContext gc, Bool pre13)
 {
-    const GLXContext oldGC = __glXGetCurrentContext();
-    bool error;
-    
-    error = apple_glx_make_current_context(dpy, 
-					   (oldGC && oldGC != &dummyContext) ?
-					   oldGC->apple : NULL, 
-					   gc ? gc->apple : NULL,
-					   draw);
+   const GLXContext oldGC = __glXGetCurrentContext();
+   bool error;
 
-    apple_glx_diagnostic("%s: error %s\n", __func__, error ? "YES" : "NO");
+   error = apple_glx_make_current_context(dpy,
+                                          (oldGC && oldGC != &dummyContext) ?
+                                          oldGC->apple : NULL,
+                                          gc ? gc->apple : NULL, draw);
 
-    if(error)
-	return GL_FALSE;
-    
-    __glXLock();
-   
-    if (gc == oldGC) {
-	/* Even though the contexts are the same the drawable might have
-	 * changed.  Note that gc cannot be the dummy, and that oldGC
-	 * cannot be NULL, therefore if they are the same, gc is not
-	 * NULL and not the dummy.
-	 */
-	if(gc) {
-	    gc->currentDrawable = draw;
-	    gc->currentReadable = read;
-	}
-    } else {
-	
-	if (oldGC != &dummyContext) {
-	    /* Old current context is no longer current to anybody */
-	    oldGC->currentDpy = 0;
-	    oldGC->currentDrawable = None;
-	    oldGC->currentReadable = None;
-	    oldGC->currentContextTag = 0;
-	    
-	    /*
-	     * At this point we should check if the context has been
-	     * through glXDestroyContext, and redestroy it if so.
-	     */
-	    if(oldGC->do_destroy) {
-		__glXUnlock();
-		/* glXDestroyContext uses the same global lock. */
-		glXDestroyContext(dpy, oldGC);
-		__glXLock();
-	    }
-	}
-	
-	if (gc) {
-	    __glXSetCurrentContext(gc);
+   apple_glx_diagnostic("%s: error %s\n", __func__, error ? "YES" : "NO");
 
-	    gc->currentDpy = dpy;
-	    gc->currentDrawable = draw;
-	    gc->currentReadable = read;
-	} else {
-	    __glXSetCurrentContextNull();
-	}
-    }
-    __glXUnlock();
+   if (error)
+      return GL_FALSE;
 
-    return GL_TRUE;
+   __glXLock();
+
+   if (gc == oldGC) {
+      /* Even though the contexts are the same the drawable might have
+       * changed.  Note that gc cannot be the dummy, and that oldGC
+       * cannot be NULL, therefore if they are the same, gc is not
+       * NULL and not the dummy.
+       */
+      if (gc) {
+         gc->currentDrawable = draw;
+         gc->currentReadable = read;
+      }
+   }
+   else {
+
+      if (oldGC != &dummyContext) {
+         /* Old current context is no longer current to anybody */
+         oldGC->currentDpy = 0;
+         oldGC->currentDrawable = None;
+         oldGC->currentReadable = None;
+         oldGC->currentContextTag = 0;
+
+         /*
+          * At this point we should check if the context has been
+          * through glXDestroyContext, and redestroy it if so.
+          */
+         if (oldGC->do_destroy) {
+            __glXUnlock();
+            /* glXDestroyContext uses the same global lock. */
+            glXDestroyContext(dpy, oldGC);
+            __glXLock();
+         }
+      }
+
+      if (gc) {
+         __glXSetCurrentContext(gc);
+
+         gc->currentDpy = dpy;
+         gc->currentDrawable = draw;
+         gc->currentReadable = read;
+      }
+      else {
+         __glXSetCurrentContextNull();
+      }
+   }
+   __glXUnlock();
+
+   return GL_TRUE;
 }
 
 
-PUBLIC Bool glXMakeCurrent(Display *dpy, GLXDrawable draw, GLXContext gc)
+PUBLIC Bool
+glXMakeCurrent(Display * dpy, GLXDrawable draw, GLXContext gc)
 {
-    return MakeContextCurrent(dpy, draw, draw, gc, True);
+   return MakeContextCurrent(dpy, draw, draw, gc, True);
 }
 
-PUBLIC GLX_ALIAS(Bool, glXMakeCurrentReadSGI,
-	  (Display *dpy, GLXDrawable d, GLXDrawable r, GLXContext ctx),
-	  (dpy, d, r, ctx, False), MakeContextCurrent)
+PUBLIC
+GLX_ALIAS(Bool, glXMakeCurrentReadSGI,
+          (Display * dpy, GLXDrawable d, GLXDrawable r, GLXContext ctx),
+          (dpy, d, r, ctx, False), MakeContextCurrent)
 
-PUBLIC GLX_ALIAS(Bool, glXMakeContextCurrent,
-	  (Display *dpy, GLXDrawable d, GLXDrawable r, GLXContext ctx),
-	  (dpy, d, r, ctx, False), MakeContextCurrent)
+     PUBLIC GLX_ALIAS(Bool, glXMakeContextCurrent,
+                      (Display * dpy, GLXDrawable d, GLXDrawable r,
+                       GLXContext ctx), (dpy, d, r, ctx, False),
+                      MakeContextCurrent)

Modified: AppleSGLX/trunk/glxext.c
===================================================================
--- AppleSGLX/trunk/glxext.c	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/glxext.c	2009-12-21 20:56:26 UTC (rev 386)
@@ -36,7 +36,7 @@
  * Direct rendering support added by Precision Insight, Inc.
  *
  * \author Kevin E. Martin <kevin at precisioninsight.com>
- */     
+ */
 
 #include <assert.h>
 #include "glxclient.h"
@@ -56,9 +56,14 @@
 #include <xcb/glx.h>
 #endif
 
+// Nuke when rebase is done
+char *
+__glXGetStringFromServer(Display * dpy, int opcode, CARD32 glxCode,
+                         CARD32 for_whom, CARD32 name);
 
+
 #ifdef DEBUG
-void __glXDumpDrawBuffer(__GLXcontext *ctx);
+void __glXDumpDrawBuffer(__GLXcontext * ctx);
 #endif
 
 #ifdef USE_SPARC_ASM
@@ -88,134 +93,135 @@
 static XExtensionInfo *glXExtensionInfo = &glxext_info_data;
 
 static /* const */ char *error_list[] = {
-    "GLXBadContext",
-    "GLXBadContextState",
-    "GLXBadDrawable",
-    "GLXBadPixmap",
-    "GLXBadContextTag",
-    "GLXBadCurrentWindow",
-    "GLXBadRenderRequest",
-    "GLXBadLargeRequest",
-    "GLXUnsupportedPrivateRequest",
-    "GLXBadFBConfig",
-    "GLXBadPbuffer",
-    "GLXBadCurrentDrawable",
-    "GLXBadWindow",
+   "GLXBadContext",
+   "GLXBadContextState",
+   "GLXBadDrawable",
+   "GLXBadPixmap",
+   "GLXBadContextTag",
+   "GLXBadCurrentWindow",
+   "GLXBadRenderRequest",
+   "GLXBadLargeRequest",
+   "GLXUnsupportedPrivateRequest",
+   "GLXBadFBConfig",
+   "GLXBadPbuffer",
+   "GLXBadCurrentDrawable",
+   "GLXBadWindow",
 };
 
-static int __glXCloseDisplay(Display *dpy, XExtCodes *codes)
+static int
+__glXCloseDisplay(Display * dpy, XExtCodes * codes)
 {
-  GLXContext gc;
+   GLXContext gc;
 
-  gc = __glXGetCurrentContext();
-  if (dpy == gc->currentDpy) {
-    __glXSetCurrentContextNull();
-    __glXFreeContext(gc);
-  }
+   gc = __glXGetCurrentContext();
+   if (dpy == gc->currentDpy) {
+      __glXSetCurrentContextNull();
+      __glXFreeContext(gc);
+   }
 
-  return XextRemoveDisplay(glXExtensionInfo, dpy);
+   return XextRemoveDisplay(glXExtensionInfo, dpy);
 }
 
-static char *__glXErrorString(Display *dpy, int code, XExtCodes *codes, 
-			  char *buf, int n);
+static char *__glXErrorString(Display * dpy, int code, XExtCodes * codes,
+                              char *buf, int n);
 
 static /* const */ XExtensionHooks __glXExtensionHooks = {
-    NULL,				/* create_gc */
-    NULL,				/* copy_gc */
-    NULL,				/* flush_gc */
-    NULL,				/* free_gc */
-    NULL,				/* create_font */
-    NULL,				/* free_font */
-    __glXCloseDisplay,			/* close_display */
-    NULL,				/* wire_to_event */
-    NULL,				/* event_to_wire */
-    NULL,				/* error */
-    __glXErrorString,			/* error_string */
+   NULL,                        /* create_gc */
+   NULL,                        /* copy_gc */
+   NULL,                        /* flush_gc */
+   NULL,                        /* free_gc */
+   NULL,                        /* create_font */
+   NULL,                        /* free_font */
+   __glXCloseDisplay,           /* close_display */
+   NULL,                        /* wire_to_event */
+   NULL,                        /* event_to_wire */
+   NULL,                        /* error */
+   __glXErrorString,            /* error_string */
 };
 
 
 XEXT_GENERATE_FIND_DISPLAY(__glXFindDisplay, glXExtensionInfo,
-			   __glXExtensionName, &__glXExtensionHooks,
-			   __GLX_NUMBER_EVENTS, NULL)
+                           __glXExtensionName, &__glXExtensionHooks,
+                           __GLX_NUMBER_EVENTS, NULL)
 
-static XEXT_GENERATE_ERROR_STRING(__glXErrorString, __glXExtensionName,
-				  __GLX_NUMBER_ERRORS, error_list)
+     static XEXT_GENERATE_ERROR_STRING(__glXErrorString, __glXExtensionName,
+                                       __GLX_NUMBER_ERRORS, error_list)
 
 
 
 
 /************************************************************************/
-
 /*
 ** Free the per screen configs data as well as the array of
 ** __glXScreenConfigs.
 */
-static void FreeScreenConfigs(__GLXdisplayPrivate *priv)
+     static void FreeScreenConfigs(__GLXdisplayPrivate * priv)
 {
-    __GLXscreenConfigs *psc;
-    GLint i, screens;
+   __GLXscreenConfigs *psc;
+   GLint i, screens;
 
-    /* Free screen configuration information */
-    psc = priv->screenConfigs;
-    screens = ScreenCount(priv->dpy);
-    for (i = 0; i < screens; i++, psc++) {
-	if (psc->configs) {
-	    _gl_context_modes_destroy( psc->configs );
-	    if (psc->effectiveGLXexts)
-		Xfree(psc->effectiveGLXexts);
-	    psc->configs = NULL;	/* NOTE: just for paranoia */
-	}
-        if (psc->visuals) {
-            _gl_context_modes_destroy( psc->visuals );
-            psc->visuals = NULL;  /* NOTE: just for paranoia */
-        }
- 	Xfree((char*) psc->serverGLXexts);
+   /* Free screen configuration information */
+   psc = priv->screenConfigs;
+   screens = ScreenCount(priv->dpy);
+   for (i = 0; i < screens; i++, psc++) {
+      if (psc->configs) {
+         _gl_context_modes_destroy(psc->configs);
+         if (psc->effectiveGLXexts)
+            Xfree(psc->effectiveGLXexts);
+         psc->configs = NULL;   /* NOTE: just for paranoia */
+      }
+      if (psc->visuals) {
+         _gl_context_modes_destroy(psc->visuals);
+         psc->visuals = NULL;   /* NOTE: just for paranoia */
+      }
+      Xfree((char *) psc->serverGLXexts);
 
 #ifdef GLX_DIRECT_RENDERING
-	if (psc->driScreen) {
-	    psc->driScreen->destroyScreen(psc);
-	    __glxHashDestroy(psc->drawHash);
-            XFree(psc->driScreen);
-            psc->driScreen = NULL;
-	}
+      if (psc->driScreen) {
+         psc->driScreen->destroyScreen(psc);
+         __glxHashDestroy(psc->drawHash);
+         XFree(psc->driScreen);
+         psc->driScreen = NULL;
+      }
 #endif
-    }
-    XFree((char*) priv->screenConfigs);
-    priv->screenConfigs = NULL;
+   }
+   XFree((char *) priv->screenConfigs);
+   priv->screenConfigs = NULL;
 }
 
 /*
 ** Release the private memory referred to in a display private
 ** structure.  The caller will free the extension structure.
 */
-static int __glXFreeDisplayPrivate(XExtData *extension)
+static int
+__glXFreeDisplayPrivate(XExtData * extension)
 {
-    __GLXdisplayPrivate *priv;
+   __GLXdisplayPrivate *priv;
 
-    priv = (__GLXdisplayPrivate*) extension->private_data;
-    FreeScreenConfigs(priv);
-    if(priv->serverGLXvendor) {
-	Xfree((char*)priv->serverGLXvendor);
-	priv->serverGLXvendor = 0x0; /* to protect against double free's */
-    }
-    if(priv->serverGLXversion) {
-	Xfree((char*)priv->serverGLXversion);
-	priv->serverGLXversion = 0x0; /* to protect against double free's */
-    }
+   priv = (__GLXdisplayPrivate *) extension->private_data;
+   FreeScreenConfigs(priv);
+   if (priv->serverGLXvendor) {
+      Xfree((char *) priv->serverGLXvendor);
+      priv->serverGLXvendor = 0x0;      /* to protect against double free's */
+   }
+   if (priv->serverGLXversion) {
+      Xfree((char *) priv->serverGLXversion);
+      priv->serverGLXversion = 0x0;     /* to protect against double free's */
+   }
 
 #ifdef GLX_DIRECT_RENDERING
-    /* Free the direct rendering per display data */
-    if (priv->driswDisplay)
-	(*priv->driswDisplay->destroyDisplay)(priv->driswDisplay);
-    priv->driswDisplay = NULL;
+   /* Free the direct rendering per display data */
+   if (priv->driswDisplay)
+      (*priv->driswDisplay->destroyDisplay) (priv->driswDisplay);
+   priv->driswDisplay = NULL;
 
-    if (priv->driDisplay)
-	(*priv->driDisplay->destroyDisplay)(priv->driDisplay);
-    priv->driDisplay = NULL;
+   if (priv->driDisplay)
+      (*priv->driDisplay->destroyDisplay) (priv->driDisplay);
+   priv->driDisplay = NULL;
 #endif
 
-    Xfree((char*) priv);
-    return 0;
+   Xfree((char *) priv);
+   return 0;
 }
 
 /************************************************************************/
@@ -224,33 +230,34 @@
 ** Query the version of the GLX extension.  This procedure works even if
 ** the client extension is not completely set up.
 */
-static Bool QueryVersion(Display *dpy, int opcode, int *major, int *minor)
+static Bool
+QueryVersion(Display * dpy, int opcode, int *major, int *minor)
 {
-    xGLXQueryVersionReq *req;
-    xGLXQueryVersionReply reply;
+   xGLXQueryVersionReq *req;
+   xGLXQueryVersionReply reply;
 
-    /* Send the glXQueryVersion request */
-    LockDisplay(dpy);
-    GetReq(GLXQueryVersion,req);
-    req->reqType = opcode;
-    req->glxCode = X_GLXQueryVersion;
-    req->majorVersion = GLX_MAJOR_VERSION;
-    req->minorVersion = GLX_MINOR_VERSION;
-    _XReply(dpy, (xReply*) &reply, 0, False);
-    UnlockDisplay(dpy);
-    SyncHandle();
+   /* Send the glXQueryVersion request */
+   LockDisplay(dpy);
+   GetReq(GLXQueryVersion, req);
+   req->reqType = opcode;
+   req->glxCode = X_GLXQueryVersion;
+   req->majorVersion = GLX_MAJOR_VERSION;
+   req->minorVersion = GLX_MINOR_VERSION;
+   _XReply(dpy, (xReply *) & reply, 0, False);
+   UnlockDisplay(dpy);
+   SyncHandle();
 
-    if (reply.majorVersion != GLX_MAJOR_VERSION) {
-	/*
-	** The server does not support the same major release as this
-	** client.
-	*/
-	return GL_FALSE;
-    }
-    *major = reply.majorVersion;
-    *minor = GLX_MINOR_VERSION;
-    // *minor = min(reply.minorVersion, GLX_MINOR_VERSION);
-    return GL_TRUE;
+   if (reply.majorVersion != GLX_MAJOR_VERSION) {
+      /*
+       ** The server does not support the same major release as this
+       ** client.
+       */
+      return GL_FALSE;
+   }
+   *major = reply.majorVersion;
+   *minor = GLX_MINOR_VERSION;
+   // *minor = min(reply.minorVersion, GLX_MINOR_VERSION);
+   return GL_TRUE;
 }
 
 
@@ -259,8 +266,9 @@
  * because we can't support it.  The X server writes it out though,
  * so we should handle it somehow, to avoid false warnings.
  */
-enum {
-    IGNORE_GLX_SWAP_METHOD_OML = 0x8060
+enum
+{
+   IGNORE_GLX_SWAP_METHOD_OML = 0x8060
 };
 
 
@@ -268,50 +276,51 @@
  * getVisualConfigs uses the !tagged_only path.
  * getFBConfigs uses the tagged_only path.
  */
-_X_HIDDEN void 
-__glXInitializeVisualConfigFromTags( __GLcontextModes *config, int count, 
-				     const INT32 *bp, Bool tagged_only,
-				     Bool fbconfig_style_tags )
+_X_HIDDEN void
+__glXInitializeVisualConfigFromTags(__GLcontextModes * config, int count,
+                                    const INT32 * bp, Bool tagged_only,
+                                    Bool fbconfig_style_tags)
 {
-    int i;
-    long int tag, tagvalue;
-    
-    if (!tagged_only) {
-	/*
-	 * Copy in the first set of properties.
-	 * There should only be 18 initial properties.
-	 */
-	config->visualID = *bp++;
+   int i;
+   long int tag, tagvalue;
 
-	config->visualType = _gl_convert_from_x_visual_type( *bp++ );
+   if (!tagged_only) {
+      /*
+       * Copy in the first set of properties.
+       * There should only be 18 initial properties.
+       */
+      config->visualID = *bp++;
 
-	config->rgbMode = *bp++;
+      config->visualType = _gl_convert_from_x_visual_type(*bp++);
 
-	config->redBits = *bp++;
-	config->greenBits = *bp++;
-	config->blueBits = *bp++;
-	config->alphaBits = *bp++;
-	config->accumRedBits = *bp++;
-	config->accumGreenBits = *bp++;
-	config->accumBlueBits = *bp++;
-	config->accumAlphaBits = *bp++;
+      config->rgbMode = *bp++;
 
-	config->doubleBufferMode = *bp++;
-	config->stereoMode = *bp++;
+      config->redBits = *bp++;
+      config->greenBits = *bp++;
+      config->blueBits = *bp++;
+      config->alphaBits = *bp++;
+      config->accumRedBits = *bp++;
+      config->accumGreenBits = *bp++;
+      config->accumBlueBits = *bp++;
+      config->accumAlphaBits = *bp++;
 
-	config->rgbBits = *bp++;
-	config->depthBits = *bp++;
-	config->stencilBits = *bp++;
-	config->numAuxBuffers = *bp++;
-	config->level = *bp++;
+      config->doubleBufferMode = *bp++;
+      config->stereoMode = *bp++;
 
-	/* AppleSGLX supports pixmap and pbuffers with all config. */
-	config->drawableType = GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT;
-	/* Unfortunately this can create an ABI compatibility problem. */
-	count -= 18;
-    }
+      config->rgbBits = *bp++;
+      config->depthBits = *bp++;
+      config->stencilBits = *bp++;
+      config->numAuxBuffers = *bp++;
+      config->level = *bp++;
 
-    /*
+      /* AppleSGLX supports pixmap and pbuffers with all config. */
+      config->drawableType =
+         GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT;
+      /* Unfortunately this can create an ABI compatibility problem. */
+      count -= 18;
+   }
+
+   /*
     ** Additional properties may be in a list at the end
     ** of the reply.  They are in pairs of property type
     ** and property value.
@@ -320,504 +329,509 @@
 #define FETCH_OR_SET(tag) \
     config-> tag = ( fbconfig_style_tags ) ? *bp++ : 1
 
-    for (i = 0; i < count; i += 2 ) {
-	tag = *bp++;
+   for (i = 0; i < count; i += 2) {
+      tag = *bp++;
 
-	switch(tag) {
-	  case GLX_RGBA:
-	    FETCH_OR_SET( rgbMode );
-	    break;
-	  case GLX_BUFFER_SIZE:
-	    config->rgbBits = *bp++;
-	    break;
-	  case GLX_LEVEL:
-	    config->level = *bp++;
-	    break;
-	  case GLX_DOUBLEBUFFER:
-	    FETCH_OR_SET( doubleBufferMode );
-	    break;
-	  case GLX_STEREO:
-	    FETCH_OR_SET( stereoMode );
-	    break;
-	  case GLX_AUX_BUFFERS:
-	    config->numAuxBuffers = *bp++;
-	    break;
-	  case GLX_RED_SIZE:
-	    config->redBits = *bp++;
-	    break;
-	  case GLX_GREEN_SIZE:
-	    config->greenBits = *bp++;
-	    break;
-	  case GLX_BLUE_SIZE:
-	    config->blueBits = *bp++;
-	    break;
-	  case GLX_ALPHA_SIZE:
-	    config->alphaBits = *bp++;
-	    break;
-	  case GLX_DEPTH_SIZE:
-	    config->depthBits = *bp++;
-	    break;
-	  case GLX_STENCIL_SIZE:
-	    config->stencilBits = *bp++;
-	    break;
-	  case GLX_ACCUM_RED_SIZE:
-	    config->accumRedBits = *bp++;
-	    break;
-	  case GLX_ACCUM_GREEN_SIZE:
-	    config->accumGreenBits = *bp++;
-	    break;
-	  case GLX_ACCUM_BLUE_SIZE:
-	    config->accumBlueBits = *bp++;
-	    break;
-	  case GLX_ACCUM_ALPHA_SIZE:
-	    config->accumAlphaBits = *bp++;
-	    break;
-	  case GLX_VISUAL_CAVEAT_EXT:
-	    config->visualRating = *bp++;    
-	    break;
-	  case GLX_X_VISUAL_TYPE:
-	    config->visualType = *bp++;
-	    break;
-	  case GLX_TRANSPARENT_TYPE:
-	    config->transparentPixel = *bp++;    
-	    break;
-	  case GLX_TRANSPARENT_INDEX_VALUE:
-	    config->transparentIndex = *bp++;    
-	    break;
-	  case GLX_TRANSPARENT_RED_VALUE:
-	    config->transparentRed = *bp++;    
-	    break;
-	  case GLX_TRANSPARENT_GREEN_VALUE:
-	    config->transparentGreen = *bp++;    
-	    break;
-	  case GLX_TRANSPARENT_BLUE_VALUE:
-	    config->transparentBlue = *bp++;    
-	    break;
-	  case GLX_TRANSPARENT_ALPHA_VALUE:
-	    config->transparentAlpha = *bp++;    
-	    break;
-	  case GLX_VISUAL_ID:
-	    config->visualID = *bp++;
-	    break;
-	  case GLX_DRAWABLE_TYPE:
-	    config->drawableType = *bp++;
+      switch (tag) {
+      case GLX_RGBA:
+         FETCH_OR_SET(rgbMode);
+         break;
+      case GLX_BUFFER_SIZE:
+         config->rgbBits = *bp++;
+         break;
+      case GLX_LEVEL:
+         config->level = *bp++;
+         break;
+      case GLX_DOUBLEBUFFER:
+         FETCH_OR_SET(doubleBufferMode);
+         break;
+      case GLX_STEREO:
+         FETCH_OR_SET(stereoMode);
+         break;
+      case GLX_AUX_BUFFERS:
+         config->numAuxBuffers = *bp++;
+         break;
+      case GLX_RED_SIZE:
+         config->redBits = *bp++;
+         break;
+      case GLX_GREEN_SIZE:
+         config->greenBits = *bp++;
+         break;
+      case GLX_BLUE_SIZE:
+         config->blueBits = *bp++;
+         break;
+      case GLX_ALPHA_SIZE:
+         config->alphaBits = *bp++;
+         break;
+      case GLX_DEPTH_SIZE:
+         config->depthBits = *bp++;
+         break;
+      case GLX_STENCIL_SIZE:
+         config->stencilBits = *bp++;
+         break;
+      case GLX_ACCUM_RED_SIZE:
+         config->accumRedBits = *bp++;
+         break;
+      case GLX_ACCUM_GREEN_SIZE:
+         config->accumGreenBits = *bp++;
+         break;
+      case GLX_ACCUM_BLUE_SIZE:
+         config->accumBlueBits = *bp++;
+         break;
+      case GLX_ACCUM_ALPHA_SIZE:
+         config->accumAlphaBits = *bp++;
+         break;
+      case GLX_VISUAL_CAVEAT_EXT:
+         config->visualRating = *bp++;
+         break;
+      case GLX_X_VISUAL_TYPE:
+         config->visualType = *bp++;
+         break;
+      case GLX_TRANSPARENT_TYPE:
+         config->transparentPixel = *bp++;
+         break;
+      case GLX_TRANSPARENT_INDEX_VALUE:
+         config->transparentIndex = *bp++;
+         break;
+      case GLX_TRANSPARENT_RED_VALUE:
+         config->transparentRed = *bp++;
+         break;
+      case GLX_TRANSPARENT_GREEN_VALUE:
+         config->transparentGreen = *bp++;
+         break;
+      case GLX_TRANSPARENT_BLUE_VALUE:
+         config->transparentBlue = *bp++;
+         break;
+      case GLX_TRANSPARENT_ALPHA_VALUE:
+         config->transparentAlpha = *bp++;
+         break;
+      case GLX_VISUAL_ID:
+         config->visualID = *bp++;
+         break;
+      case GLX_DRAWABLE_TYPE:
+         config->drawableType = *bp++;
 
-	    /* AppleSGLX supports pixmap and pbuffers with all config. */
-	    config->drawableType |= GLX_WINDOW_BIT | GLX_PIXMAP_BIT 
-		| GLX_PBUFFER_BIT;
-	    break;
-	  case GLX_RENDER_TYPE:
-	    config->renderType = *bp++;
-	    break;
-	  case GLX_X_RENDERABLE:
-	    config->xRenderable = *bp++;
-	    break;
-	  case GLX_FBCONFIG_ID:
-	    config->fbconfigID = *bp++;
-	    break;
-	  case GLX_MAX_PBUFFER_WIDTH:
-	    config->maxPbufferWidth = *bp++;
-	    break;
-	  case GLX_MAX_PBUFFER_HEIGHT:
-	    config->maxPbufferHeight = *bp++;
-	    break;
-	  case GLX_MAX_PBUFFER_PIXELS:
-	    config->maxPbufferPixels = *bp++;
-	    break;
+         /* AppleSGLX supports pixmap and pbuffers with all config. */
+         config->drawableType |= GLX_WINDOW_BIT | GLX_PIXMAP_BIT
+            | GLX_PBUFFER_BIT;
+         break;
+      case GLX_RENDER_TYPE:
+         config->renderType = *bp++;
+         break;
+      case GLX_X_RENDERABLE:
+         config->xRenderable = *bp++;
+         break;
+      case GLX_FBCONFIG_ID:
+         config->fbconfigID = *bp++;
+         break;
+      case GLX_MAX_PBUFFER_WIDTH:
+         config->maxPbufferWidth = *bp++;
+         break;
+      case GLX_MAX_PBUFFER_HEIGHT:
+         config->maxPbufferHeight = *bp++;
+         break;
+      case GLX_MAX_PBUFFER_PIXELS:
+         config->maxPbufferPixels = *bp++;
+         break;
 #if 0
-	    /* We can't currently support these with CGL. */
-	  case GLX_OPTIMAL_PBUFFER_WIDTH_SGIX:
-	    config->optimalPbufferWidth = *bp++;
-	    break;
-	  case GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX:
-	    config->optimalPbufferHeight = *bp++;
-	    break;
+         /* We can't currently support these with CGL. */
+      case GLX_OPTIMAL_PBUFFER_WIDTH_SGIX:
+         config->optimalPbufferWidth = *bp++;
+         break;
+      case GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX:
+         config->optimalPbufferHeight = *bp++;
+         break;
 #endif
-#if 0 
-	    /* Not supported. */
-          case GLX_VISUAL_SELECT_GROUP_SGIX:
-	    config->visualSelectGroup = *bp++;
-	    break;
+#if 0
+         /* Not supported. */
+      case GLX_VISUAL_SELECT_GROUP_SGIX:
+         config->visualSelectGroup = *bp++;
+         break;
 #endif
 #if 0
-	    /* Changing the swap method is not supported by Xplugin. */
-	  case GLX_SWAP_METHOD_OML:
-	    config->swapMethod = *bp++;
-	    break;
+         /* Changing the swap method is not supported by Xplugin. */
+      case GLX_SWAP_METHOD_OML:
+         config->swapMethod = *bp++;
+         break;
 #endif
-	    /* These 2 have the same values as the SGIS versions, and ARB. */
-	  case GLX_SAMPLE_BUFFERS:
-	    config->sampleBuffers = *bp++;
-	    break;
-	  case GLX_SAMPLES:
-	    config->samples = *bp++;
-	    break;
+         /* These 2 have the same values as the SGIS versions, and ARB. */
+      case GLX_SAMPLE_BUFFERS:
+         config->sampleBuffers = *bp++;
+         break;
+      case GLX_SAMPLES:
+         config->samples = *bp++;
+         break;
 #if 0
-	    /*These are part of GLX_EXT_texture_from_pixmap */
-	  case GLX_BIND_TO_TEXTURE_RGB_EXT:
-	    config->bindToTextureRgb = *bp++;
-	    break;
-	  case GLX_BIND_TO_TEXTURE_RGBA_EXT:
-	    config->bindToTextureRgba = *bp++;
-	    break;
-	  case GLX_BIND_TO_MIPMAP_TEXTURE_EXT:
-	    config->bindToMipmapTexture = *bp++;
-	    break;
-	  case GLX_BIND_TO_TEXTURE_TARGETS_EXT:
-	    config->bindToTextureTargets = *bp++;
-	    break;
-	  case GLX_Y_INVERTED_EXT:
-	    config->yInverted = *bp++;
-	    break;
+         /*These are part of GLX_EXT_texture_from_pixmap */
+      case GLX_BIND_TO_TEXTURE_RGB_EXT:
+         config->bindToTextureRgb = *bp++;
+         break;
+      case GLX_BIND_TO_TEXTURE_RGBA_EXT:
+         config->bindToTextureRgba = *bp++;
+         break;
+      case GLX_BIND_TO_MIPMAP_TEXTURE_EXT:
+         config->bindToMipmapTexture = *bp++;
+         break;
+      case GLX_BIND_TO_TEXTURE_TARGETS_EXT:
+         config->bindToTextureTargets = *bp++;
+         break;
+      case GLX_Y_INVERTED_EXT:
+         config->yInverted = *bp++;
+         break;
 #endif
-	case IGNORE_GLX_SWAP_METHOD_OML:
-	    /* We ignore this tag.  See the comment above this function. */
-	    ++bp;
-	    break;
-		
-	  case None:
-	    i = count;
-	    break;
-	  default:
-	    if(getenv("LIBGL_DIAGNOSTIC")) {
-		tagvalue = *bp++;
-		fprintf(stderr, "WARNING: unknown GLX tag from server: "
-			"tag 0x%lx value 0x%lx\n",
-			tag, tagvalue);
-	    }
-	    break;
-	}
-    }
+      case IGNORE_GLX_SWAP_METHOD_OML:
+         /* We ignore this tag.  See the comment above this function. */
+         ++bp;
+         break;
 
-    config->renderType = (config->rgbMode) ? GLX_RGBA_BIT : GLX_COLOR_INDEX_BIT;
+      case None:
+         i = count;
+         break;
+      default:
+         if (getenv("LIBGL_DIAGNOSTIC")) {
+            tagvalue = *bp++;
+            fprintf(stderr, "WARNING: unknown GLX tag from server: "
+                    "tag 0x%lx value 0x%lx\n", tag, tagvalue);
+         }
+         break;
+      }
+   }
 
-    config->haveAccumBuffer = ((config->accumRedBits +
-			       config->accumGreenBits +
-			       config->accumBlueBits +
-			       config->accumAlphaBits) > 0);
-    config->haveDepthBuffer = (config->depthBits > 0);
-    config->haveStencilBuffer = (config->stencilBits > 0);
+   config->renderType =
+      (config->rgbMode) ? GLX_RGBA_BIT : GLX_COLOR_INDEX_BIT;
+
+   config->haveAccumBuffer = ((config->accumRedBits +
+                               config->accumGreenBits +
+                               config->accumBlueBits +
+                               config->accumAlphaBits) > 0);
+   config->haveDepthBuffer = (config->depthBits > 0);
+   config->haveStencilBuffer = (config->stencilBits > 0);
 }
 
 static __GLcontextModes *
-createConfigsFromProperties(Display *dpy, int nvisuals, int nprops,
-			    int screen, GLboolean tagged_only)
+createConfigsFromProperties(Display * dpy, int nvisuals, int nprops,
+                            int screen, GLboolean tagged_only)
 {
-    INT32 buf[__GLX_TOTAL_CONFIG], *props;
-    unsigned prop_size;
-    __GLcontextModes *modes, *m;
-    int i;
+   INT32 buf[__GLX_TOTAL_CONFIG], *props;
+   unsigned prop_size;
+   __GLcontextModes *modes, *m;
+   int i;
 
-    if (nprops == 0)
-	return NULL;
+   if (nprops == 0)
+      return NULL;
 
-    /* Check number of properties */
-    if (nprops < __GLX_MIN_CONFIG_PROPS || nprops > __GLX_MAX_CONFIG_PROPS)
-	return NULL;
+   /* Check number of properties */
+   if (nprops < __GLX_MIN_CONFIG_PROPS || nprops > __GLX_MAX_CONFIG_PROPS)
+      return NULL;
 
-    /* Allocate memory for our config structure */
-    modes = _gl_context_modes_create(nvisuals, sizeof(__GLcontextModes));
-    if (!modes)
-	return NULL;
+   /* Allocate memory for our config structure */
+   modes = _gl_context_modes_create(nvisuals, sizeof(__GLcontextModes));
+   if (!modes)
+      return NULL;
 
-    prop_size = nprops * __GLX_SIZE_INT32;
-    if (prop_size <= sizeof(buf))
-	props = buf;
-    else
-	props = Xmalloc(prop_size);
+   prop_size = nprops * __GLX_SIZE_INT32;
+   if (prop_size <= sizeof(buf))
+      props = buf;
+   else
+      props = Xmalloc(prop_size);
 
-    /* Read each config structure and convert it into our format */
-    m = modes;
-    for (i = 0; i < nvisuals; i++) {
-	_XRead(dpy, (char *)props, prop_size);
-	
-	/* 
-	 * The XQuartz 2.3.2.1 X server doesn't set this properly, so
-	 * set the proper bits here.
-	 * AppleSGLX supports windows, pixmaps, and pbuffers with all config.
-	 */
-	m->drawableType = GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT;
+   /* Read each config structure and convert it into our format */
+   m = modes;
+   for (i = 0; i < nvisuals; i++) {
+      _XRead(dpy, (char *) props, prop_size);
 
-	__glXInitializeVisualConfigFromTags(m, nprops, props,
-					    tagged_only, GL_TRUE);
-	m->screen = screen;
-	m = m->next;
-    }
+      /* 
+       * The XQuartz 2.3.2.1 X server doesn't set this properly, so
+       * set the proper bits here.
+       * AppleSGLX supports windows, pixmaps, and pbuffers with all config.
+       */
+      m->drawableType = GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT;
 
-    if (props != buf)
-	Xfree(props);
+      __glXInitializeVisualConfigFromTags(m, nprops, props,
+                                          tagged_only, GL_TRUE);
+      m->screen = screen;
+      m = m->next;
+   }
 
-    return modes;
+   if (props != buf)
+      Xfree(props);
+
+   return modes;
 }
 
 static GLboolean
-getVisualConfigs(Display *dpy, __GLXdisplayPrivate *priv, int screen)
+getVisualConfigs(Display * dpy, __GLXdisplayPrivate * priv, int screen)
 {
-    xGLXGetVisualConfigsReq *req;
-    __GLXscreenConfigs *psc;
-    xGLXGetVisualConfigsReply reply;
-    
-    LockDisplay(dpy);
+   xGLXGetVisualConfigsReq *req;
+   __GLXscreenConfigs *psc;
+   xGLXGetVisualConfigsReply reply;
 
-    psc = priv->screenConfigs + screen;
-    psc->visuals = NULL;
-    GetReq(GLXGetVisualConfigs, req);
-    req->reqType = priv->majorOpcode;
-    req->glxCode = X_GLXGetVisualConfigs;
-    req->screen = screen;
+   LockDisplay(dpy);
 
-    if (!_XReply(dpy, (xReply*) &reply, 0, False))
-	goto out;
+   psc = priv->screenConfigs + screen;
+   psc->visuals = NULL;
+   GetReq(GLXGetVisualConfigs, req);
+   req->reqType = priv->majorOpcode;
+   req->glxCode = X_GLXGetVisualConfigs;
+   req->screen = screen;
 
-    psc->visuals = createConfigsFromProperties(dpy,
-					       reply.numVisuals,
-					       reply.numProps,
-					       screen, GL_FALSE);
+   if (!_XReply(dpy, (xReply *) & reply, 0, False))
+      goto out;
 
+   psc->visuals = createConfigsFromProperties(dpy,
+                                              reply.numVisuals,
+                                              reply.numProps,
+                                              screen, GL_FALSE);
+
  out:
-    UnlockDisplay(dpy);
-    return psc->visuals != NULL;
+   UnlockDisplay(dpy);
+   return psc->visuals != NULL;
 }
 
 static GLboolean
-getFBConfigs(Display *dpy, __GLXdisplayPrivate *priv, int screen)
+getFBConfigs(Display * dpy, __GLXdisplayPrivate * priv, int screen)
 {
-    xGLXGetFBConfigsReq *fb_req;
-    xGLXGetFBConfigsSGIXReq *sgi_req;
-    xGLXVendorPrivateWithReplyReq *vpreq;
-    xGLXGetFBConfigsReply reply;
-    __GLXscreenConfigs *psc;
+   xGLXGetFBConfigsReq *fb_req;
+   xGLXGetFBConfigsSGIXReq *sgi_req;
+   xGLXVendorPrivateWithReplyReq *vpreq;
+   xGLXGetFBConfigsReply reply;
+   __GLXscreenConfigs *psc;
 
-    psc = priv->screenConfigs + screen;
-    psc->serverGLXexts = __glXGetStringFromServer(dpy, priv->majorOpcode,
-						  X_GLXQueryServerString,
-						  screen, GLX_EXTENSIONS);
+   psc = priv->screenConfigs + screen;
+   psc->serverGLXexts = __glXGetStringFromServer(dpy, priv->majorOpcode,
+                                                 X_GLXQueryServerString,
+                                                 screen, GLX_EXTENSIONS);
 
-    LockDisplay(dpy);
+   LockDisplay(dpy);
 
-    psc->configs = NULL;
-    if (atof(priv->serverGLXversion) >= 1.3) {
-	GetReq(GLXGetFBConfigs, fb_req);
-	fb_req->reqType = priv->majorOpcode;
-	fb_req->glxCode = X_GLXGetFBConfigs;
-	fb_req->screen = screen;
-    } else if (strstr(psc->serverGLXexts, "GLX_SGIX_fbconfig") != NULL) {
-	GetReqExtra(GLXVendorPrivateWithReply,
-		    sz_xGLXGetFBConfigsSGIXReq +
-		    sz_xGLXVendorPrivateWithReplyReq, vpreq);
-	sgi_req = (xGLXGetFBConfigsSGIXReq *) vpreq;
-	sgi_req->reqType = priv->majorOpcode;
-	sgi_req->glxCode = X_GLXVendorPrivateWithReply;
-	sgi_req->vendorCode = X_GLXvop_GetFBConfigsSGIX;
-	sgi_req->screen = screen;
-    } else
-	goto out;
+   psc->configs = NULL;
+   if (atof(priv->serverGLXversion) >= 1.3) {
+      GetReq(GLXGetFBConfigs, fb_req);
+      fb_req->reqType = priv->majorOpcode;
+      fb_req->glxCode = X_GLXGetFBConfigs;
+      fb_req->screen = screen;
+   }
+   else if (strstr(psc->serverGLXexts, "GLX_SGIX_fbconfig") != NULL) {
+      GetReqExtra(GLXVendorPrivateWithReply,
+                  sz_xGLXGetFBConfigsSGIXReq +
+                  sz_xGLXVendorPrivateWithReplyReq, vpreq);
+      sgi_req = (xGLXGetFBConfigsSGIXReq *) vpreq;
+      sgi_req->reqType = priv->majorOpcode;
+      sgi_req->glxCode = X_GLXVendorPrivateWithReply;
+      sgi_req->vendorCode = X_GLXvop_GetFBConfigsSGIX;
+      sgi_req->screen = screen;
+   }
+   else
+      goto out;
 
-    if (!_XReply(dpy, (xReply*) &reply, 0, False))
-	goto out;
+   if (!_XReply(dpy, (xReply *) & reply, 0, False))
+      goto out;
 
-    psc->configs = createConfigsFromProperties(dpy,
-					       reply.numFBConfigs,
-					       reply.numAttribs * 2,
-					       screen, GL_TRUE);
+   psc->configs = createConfigsFromProperties(dpy,
+                                              reply.numFBConfigs,
+                                              reply.numAttribs * 2,
+                                              screen, GL_TRUE);
 
  out:
-    UnlockDisplay(dpy);
-    return psc->configs != NULL;
+   UnlockDisplay(dpy);
+   return psc->configs != NULL;
 }
 
 /*
 ** Allocate the memory for the per screen configs for each screen.
 ** If that works then fetch the per screen configs data.
 */
-static Bool AllocAndFetchScreenConfigs(Display *dpy, __GLXdisplayPrivate *priv)
+static Bool
+AllocAndFetchScreenConfigs(Display * dpy, __GLXdisplayPrivate * priv)
 {
-    __GLXscreenConfigs *psc;
-    GLint i, screens;
+   __GLXscreenConfigs *psc;
+   GLint i, screens;
 
-    /*
+   /*
     ** First allocate memory for the array of per screen configs.
     */
-    screens = ScreenCount(dpy);
-    psc = (__GLXscreenConfigs*) Xmalloc(screens * sizeof(__GLXscreenConfigs));
-    if (!psc) {
-	return GL_FALSE;
-    }
-    memset(psc, 0, screens * sizeof(__GLXscreenConfigs));
-    priv->screenConfigs = psc;
-    
-    priv->serverGLXversion = __glXGetStringFromServer(dpy, priv->majorOpcode,
-						      X_GLXQueryServerString,
-						      0, GLX_VERSION);
-    if ( priv->serverGLXversion == NULL ) {
-	FreeScreenConfigs(priv);
-	return GL_FALSE;
-    }
+   screens = ScreenCount(dpy);
+   psc = (__GLXscreenConfigs *) Xmalloc(screens * sizeof(__GLXscreenConfigs));
+   if (!psc) {
+      return GL_FALSE;
+   }
+   memset(psc, 0, screens * sizeof(__GLXscreenConfigs));
+   priv->screenConfigs = psc;
 
-    for (i = 0; i < screens; i++, psc++) {
-	getVisualConfigs(dpy, priv, i);
-	getFBConfigs(dpy, priv, i);
-    }
+   priv->serverGLXversion = __glXGetStringFromServer(dpy, priv->majorOpcode,
+                                                     X_GLXQueryServerString,
+                                                     0, GLX_VERSION);
+   if (priv->serverGLXversion == NULL) {
+      FreeScreenConfigs(priv);
+      return GL_FALSE;
+   }
 
-    SyncHandle();
-    return GL_TRUE;
+   for (i = 0; i < screens; i++, psc++) {
+      getVisualConfigs(dpy, priv, i);
+      getFBConfigs(dpy, priv, i);
+   }
+
+   SyncHandle();
+   return GL_TRUE;
 }
 
 /*
 ** Initialize the client side extension code.
 */
-_X_HIDDEN __GLXdisplayPrivate *__glXInitialize(Display* dpy)
+_X_HIDDEN __GLXdisplayPrivate *
+__glXInitialize(Display * dpy)
 {
-    XExtDisplayInfo *info = __glXFindDisplay(dpy);
-    XExtData **privList, *private, *found;
-    __GLXdisplayPrivate *dpyPriv;
-    XEDataObject dataObj;
-    int major, minor;
+   XExtDisplayInfo *info = __glXFindDisplay(dpy);
+   XExtData **privList, *private, *found;
+   __GLXdisplayPrivate *dpyPriv;
+   XEDataObject dataObj;
+   int major, minor;
 #ifdef GLX_DIRECT_RENDERING
-    Bool glx_direct, glx_accel;
+   Bool glx_direct, glx_accel;
 #endif
- 
-    
+
+
 #if defined(USE_XTHREADS)
-    {
-        static int firstCall = 1;
-        if (firstCall) {
-            /* initialize the GLX mutexes */
-            xmutex_init(&__glXmutex);
-            firstCall = 0;
-        }
-    }
+   {
+      static int firstCall = 1;
+      if (firstCall) {
+         /* initialize the GLX mutexes */
+         xmutex_init(&__glXmutex);
+         firstCall = 0;
+      }
+   }
 #endif
 
-    INIT_MESA_SPARC
-    /* The one and only long long lock */
-    __glXLock();
+   INIT_MESA_SPARC
+      /* The one and only long long lock */
+      __glXLock();
 
-    if (!XextHasExtension(info)) {
-	/* No GLX extension supported by this server. Oh well. */
-	__glXUnlock();
-	XMissingExtension(dpy, __glXExtensionName);
-	return 0;
-    }
+   if (!XextHasExtension(info)) {
+      /* No GLX extension supported by this server. Oh well. */
+      __glXUnlock();
+      XMissingExtension(dpy, __glXExtensionName);
+      return 0;
+   }
 
-    /* See if a display private already exists.  If so, return it */
-    dataObj.display = dpy;
-    privList = XEHeadOfExtensionList(dataObj);
-    found = XFindOnExtensionList(privList, info->codes->extension);
-    if (found) {
-	__glXUnlock();
-	return (__GLXdisplayPrivate *) found->private_data;
-    }
+   /* See if a display private already exists.  If so, return it */
+   dataObj.display = dpy;
+   privList = XEHeadOfExtensionList(dataObj);
+   found = XFindOnExtensionList(privList, info->codes->extension);
+   if (found) {
+      __glXUnlock();
+      return (__GLXdisplayPrivate *) found->private_data;
+   }
 
-    /* See if the versions are compatible */
-    if (!QueryVersion(dpy, info->codes->major_opcode, &major, &minor)) {
-	/* The client and server do not agree on versions.  Punt. */
-	__glXUnlock();
-	return 0;
-    }
+   /* See if the versions are compatible */
+   if (!QueryVersion(dpy, info->codes->major_opcode, &major, &minor)) {
+      /* The client and server do not agree on versions.  Punt. */
+      __glXUnlock();
+      return 0;
+   }
 
-    /*
+   /*
     ** Allocate memory for all the pieces needed for this buffer.
     */
-    private = (XExtData *) Xmalloc(sizeof(XExtData));
-    if (!private) {
-	__glXUnlock();
-	return 0;
-    }
-    dpyPriv = (__GLXdisplayPrivate *) Xcalloc(1, sizeof(__GLXdisplayPrivate));
-    if (!dpyPriv) {
-	__glXUnlock();
-	Xfree((char*) private);
-	return 0;
-    }
+   private = (XExtData *) Xmalloc(sizeof(XExtData));
+   if (!private) {
+      __glXUnlock();
+      return 0;
+   }
+   dpyPriv = (__GLXdisplayPrivate *) Xcalloc(1, sizeof(__GLXdisplayPrivate));
+   if (!dpyPriv) {
+      __glXUnlock();
+      Xfree((char *) private);
+      return 0;
+   }
 
-    /*
+   /*
     ** Init the display private and then read in the screen config
     ** structures from the server.
     */
-    dpyPriv->majorOpcode = info->codes->major_opcode;
-    dpyPriv->majorVersion = major;
-    dpyPriv->minorVersion = minor;
-    dpyPriv->dpy = dpy;
+   dpyPriv->majorOpcode = info->codes->major_opcode;
+   dpyPriv->majorVersion = major;
+   dpyPriv->minorVersion = minor;
+   dpyPriv->dpy = dpy;
 
-    dpyPriv->serverGLXvendor = 0x0; 
-    dpyPriv->serverGLXversion = 0x0;
+   dpyPriv->serverGLXvendor = 0x0;
+   dpyPriv->serverGLXversion = 0x0;
 
 #ifdef GLX_DIRECT_RENDERING
-    glx_direct = (getenv("LIBGL_ALWAYS_INDIRECT") == NULL);
-    glx_accel = (getenv("LIBGL_ALWAYS_SOFTWARE") == NULL);
+   glx_direct = (getenv("LIBGL_ALWAYS_INDIRECT") == NULL);
+   glx_accel = (getenv("LIBGL_ALWAYS_SOFTWARE") == NULL);
 
-    /*
+   /*
     ** Initialize the direct rendering per display data and functions.
     ** Note: This _must_ be done before calling any other DRI routines
     ** (e.g., those called in AllocAndFetchScreenConfigs).
     */
-    if (glx_direct && glx_accel) {
-	dpyPriv->driDisplay = driCreateDisplay(dpy);
-    }
-    if (glx_direct)
-	dpyPriv->driswDisplay = driswCreateDisplay(dpy);
+   if (glx_direct && glx_accel) {
+      dpyPriv->driDisplay = driCreateDisplay(dpy);
+   }
+   if (glx_direct)
+      dpyPriv->driswDisplay = driswCreateDisplay(dpy);
 #endif
 
-    if (apple_init_glx(dpy) || !AllocAndFetchScreenConfigs(dpy, dpyPriv)) {
-	__glXUnlock();
-	Xfree((char*) dpyPriv);
-	Xfree((char*) private);
-	return 0;
-    }
+   if (apple_init_glx(dpy) || !AllocAndFetchScreenConfigs(dpy, dpyPriv)) {
+      __glXUnlock();
+      Xfree((char *) dpyPriv);
+      Xfree((char *) private);
+      return 0;
+   }
 
-    /*
+   /*
     ** Fill in the private structure.  This is the actual structure that
     ** hangs off of the Display structure.  Our private structure is
     ** referred to by this structure.  Got that?
     */
-    private->number = info->codes->extension;
-    private->next = 0;
-    private->free_private = __glXFreeDisplayPrivate;
-    private->private_data = (char *) dpyPriv;
-    XAddToExtensionList(privList, private);
+   private->number = info->codes->extension;
+   private->next = 0;
+   private->free_private = __glXFreeDisplayPrivate;
+   private->private_data = (char *) dpyPriv;
+   XAddToExtensionList(privList, private);
 
-    if (dpyPriv->majorVersion == 1 && dpyPriv->minorVersion >= 1) {
-        __glXClientInfo(dpy, dpyPriv->majorOpcode);
-    }
-    __glXUnlock();
+   if (dpyPriv->majorVersion == 1 && dpyPriv->minorVersion >= 1) {
+      __glXClientInfo(dpy, dpyPriv->majorOpcode);
+   }
+   __glXUnlock();
 
-    return dpyPriv;
+   return dpyPriv;
 }
 
 /*
 ** Setup for sending a GLX command on dpy.  Make sure the extension is
 ** initialized.  Try to avoid calling __glXInitialize as its kinda slow.
 */
-_X_HIDDEN CARD8 __glXSetupForCommand(Display *dpy)
+_X_HIDDEN CARD8
+__glXSetupForCommand(Display * dpy)
 {
-    GLXContext gc;
-    __GLXdisplayPrivate *priv;
+   GLXContext gc;
+   __GLXdisplayPrivate *priv;
 
-    /* If this thread has a current context, flush its rendering commands */
-    gc = __glXGetCurrentContext();
-    if (gc->currentDpy) {
-	/* Flush rendering buffer of the current context, if any */
-	(void) __glXFlushRenderBuffer(gc, gc->pc);
+   /* If this thread has a current context, flush its rendering commands */
+   gc = __glXGetCurrentContext();
+   if (gc->currentDpy) {
+      /* Flush rendering buffer of the current context, if any */
+      (void) __glXFlushRenderBuffer(gc, gc->pc);
 
-	if (gc->currentDpy == dpy) {
-	    /* Use opcode from gc because its right */
-	    INIT_MESA_SPARC
-	    return gc->majorOpcode;
-	} else {
-	    /*
-	    ** Have to get info about argument dpy because it might be to
-	    ** a different server
-	    */
-	}
-    }
+      if (gc->currentDpy == dpy) {
+         /* Use opcode from gc because its right */
+         INIT_MESA_SPARC return gc->majorOpcode;
+      }
+      else {
+         /*
+          ** Have to get info about argument dpy because it might be to
+          ** a different server
+          */
+      }
+   }
 
-    /* Forced to lookup extension via the slow initialize route */
-    priv = __glXInitialize(dpy);
-    if (!priv) {
-	return 0;
-    }
-    return priv->majorOpcode;
+   /* Forced to lookup extension via the slow initialize route */
+   priv = __glXInitialize(dpy);
+   if (!priv) {
+      return 0;
+   }
+   return priv->majorOpcode;
 }
 
 /**
@@ -830,37 +844,38 @@
  * Modify this function to use \c ctx->pc instead of the explicit
  * \c pc parameter.
  */
-_X_HIDDEN GLubyte *__glXFlushRenderBuffer(__GLXcontext *ctx, GLubyte *pc)
+_X_HIDDEN GLubyte *
+__glXFlushRenderBuffer(__GLXcontext * ctx, GLubyte * pc)
 {
-    Display * const dpy = ctx->currentDpy;
+   Display *const dpy = ctx->currentDpy;
 #ifdef USE_XCB
-    xcb_connection_t *c = XGetXCBConnection(dpy);
+   xcb_connection_t *c = XGetXCBConnection(dpy);
 #else
-    xGLXRenderReq *req;
+   xGLXRenderReq *req;
 #endif /* USE_XCB */
-    const GLint size = pc - ctx->buf;
+   const GLint size = pc - ctx->buf;
 
-    if ( (dpy != NULL) && (size > 0) ) {
+   if ((dpy != NULL) && (size > 0)) {
 #ifdef USE_XCB
-	xcb_glx_render(c, ctx->currentContextTag, size,
-		       (const uint8_t *)ctx->buf);
+      xcb_glx_render(c, ctx->currentContextTag, size,
+                     (const uint8_t *) ctx->buf);
 #else
-	/* Send the entire buffer as an X request */
-	LockDisplay(dpy);
-	GetReq(GLXRender,req); 
-	req->reqType = ctx->majorOpcode;
-	req->glxCode = X_GLXRender; 
-	req->contextTag = ctx->currentContextTag;
-	req->length += (size + 3) >> 2;
-	_XSend(dpy, (char *)ctx->buf, size);
-	UnlockDisplay(dpy);
-	SyncHandle();
+      /* Send the entire buffer as an X request */
+      LockDisplay(dpy);
+      GetReq(GLXRender, req);
+      req->reqType = ctx->majorOpcode;
+      req->glxCode = X_GLXRender;
+      req->contextTag = ctx->currentContextTag;
+      req->length += (size + 3) >> 2;
+      _XSend(dpy, (char *) ctx->buf, size);
+      UnlockDisplay(dpy);
+      SyncHandle();
 #endif
-    }
+   }
 
-    /* Reset pointer and return it */
-    ctx->pc = ctx->buf;
-    return ctx->pc;
+   /* Reset pointer and return it */
+   ctx->pc = ctx->buf;
+   return ctx->pc;
 }
 
 
@@ -880,35 +895,36 @@
  * \param data           Command data.
  * \param dataLen        Size, in bytes, of the command data.
  */
-_X_HIDDEN void __glXSendLargeChunk(__GLXcontext *gc, GLint requestNumber, 
-				   GLint totalRequests,
-				   const GLvoid * data, GLint dataLen)
+_X_HIDDEN void
+__glXSendLargeChunk(__GLXcontext * gc, GLint requestNumber,
+                    GLint totalRequests, const GLvoid * data, GLint dataLen)
 {
-    Display *dpy = gc->currentDpy;
+   Display *dpy = gc->currentDpy;
 #ifdef USE_XCB
-    xcb_connection_t *c = XGetXCBConnection(dpy);
-    xcb_glx_render_large(c, gc->currentContextTag, requestNumber, totalRequests, dataLen, data);
+   xcb_connection_t *c = XGetXCBConnection(dpy);
+   xcb_glx_render_large(c, gc->currentContextTag, requestNumber,
+                        totalRequests, dataLen, data);
 #else
-    xGLXRenderLargeReq *req;
-    
-    if ( requestNumber == 1 ) {
-	LockDisplay(dpy);
-    }
+   xGLXRenderLargeReq *req;
 
-    GetReq(GLXRenderLarge,req); 
-    req->reqType = gc->majorOpcode;
-    req->glxCode = X_GLXRenderLarge; 
-    req->contextTag = gc->currentContextTag;
-    req->length += (dataLen + 3) >> 2;
-    req->requestNumber = requestNumber;
-    req->requestTotal = totalRequests;
-    req->dataBytes = dataLen;
-    Data(dpy, data, dataLen);
+   if (requestNumber == 1) {
+      LockDisplay(dpy);
+   }
 
-    if ( requestNumber == totalRequests ) {
-	UnlockDisplay(dpy);
-	SyncHandle();
-    }
+   GetReq(GLXRenderLarge, req);
+   req->reqType = gc->majorOpcode;
+   req->glxCode = X_GLXRenderLarge;
+   req->contextTag = gc->currentContextTag;
+   req->length += (dataLen + 3) >> 2;
+   req->requestNumber = requestNumber;
+   req->requestTotal = totalRequests;
+   req->dataBytes = dataLen;
+   Data(dpy, data, dataLen);
+
+   if (requestNumber == totalRequests) {
+      UnlockDisplay(dpy);
+      SyncHandle();
+   }
 #endif /* USE_XCB */
 }
 
@@ -928,65 +944,69 @@
  * \param data       Command data.
  * \param dataLen    Size, in bytes, of the command data.
  */
-_X_HIDDEN void __glXSendLargeCommand(__GLXcontext *ctx,
-				     const GLvoid *header, GLint headerLen,
-				     const GLvoid *data, GLint dataLen)
+_X_HIDDEN void
+__glXSendLargeCommand(__GLXcontext * ctx,
+                      const GLvoid * header, GLint headerLen,
+                      const GLvoid * data, GLint dataLen)
 {
-    GLint maxSize;
-    GLint totalRequests, requestNumber;
+   GLint maxSize;
+   GLint totalRequests, requestNumber;
 
-    /*
+   /*
     ** Calculate the maximum amount of data can be stuffed into a single
     ** packet.  sz_xGLXRenderReq is added because bufSize is the maximum
     ** packet size minus sz_xGLXRenderReq.
     */
-    maxSize = (ctx->bufSize + sz_xGLXRenderReq) - sz_xGLXRenderLargeReq;
-    totalRequests = 1 + (dataLen / maxSize);
-    if (dataLen % maxSize) totalRequests++;
+   maxSize = (ctx->bufSize + sz_xGLXRenderReq) - sz_xGLXRenderLargeReq;
+   totalRequests = 1 + (dataLen / maxSize);
+   if (dataLen % maxSize)
+      totalRequests++;
 
-    /*
+   /*
     ** Send all of the command, except the large array, as one request.
     */
-    assert( headerLen <= maxSize );
-    __glXSendLargeChunk(ctx, 1, totalRequests, header, headerLen);
+   assert(headerLen <= maxSize);
+   __glXSendLargeChunk(ctx, 1, totalRequests, header, headerLen);
 
-    /*
+   /*
     ** Send enough requests until the whole array is sent.
     */
-    for ( requestNumber = 2 ; requestNumber <= (totalRequests - 1) ; requestNumber++ ) {
-	__glXSendLargeChunk(ctx, requestNumber, totalRequests, data, maxSize);
-	data = (const GLvoid *) (((const GLubyte *) data) + maxSize);
-	dataLen -= maxSize;
-	assert( dataLen > 0 );
-    }
+   for (requestNumber = 2; requestNumber <= (totalRequests - 1);
+        requestNumber++) {
+      __glXSendLargeChunk(ctx, requestNumber, totalRequests, data, maxSize);
+      data = (const GLvoid *) (((const GLubyte *) data) + maxSize);
+      dataLen -= maxSize;
+      assert(dataLen > 0);
+   }
 
-    assert( dataLen <= maxSize );
-    __glXSendLargeChunk(ctx, requestNumber, totalRequests, data, dataLen);
+   assert(dataLen <= maxSize);
+   __glXSendLargeChunk(ctx, requestNumber, totalRequests, data, dataLen);
 }
 
 /************************************************************************/
 
 #ifdef DEBUG
-_X_HIDDEN void __glXDumpDrawBuffer(__GLXcontext *ctx)
+_X_HIDDEN void
+__glXDumpDrawBuffer(__GLXcontext * ctx)
 {
-    GLubyte *p = ctx->buf;
-    GLubyte *end = ctx->pc;
-    GLushort opcode, length;
+   GLubyte *p = ctx->buf;
+   GLubyte *end = ctx->pc;
+   GLushort opcode, length;
 
-    while (p < end) {
-	/* Fetch opcode */
-	opcode = *((GLushort*) p);
-	length = *((GLushort*) (p + 2));
-	printf("%2x: %5d: ", opcode, length);
-	length -= 4;
-	p += 4;
-	while (length > 0) {
-	    printf("%08x ", *((unsigned *) p));
-	    p += 4;
-	    length -= 4;
-	}
-	printf("\n");
-    }	    
+   while (p < end) {
+      /* Fetch opcode */
+      opcode = *((GLushort *) p);
+      length = *((GLushort *) (p + 2));
+      printf("%2x: %5d: ", opcode, length);
+      length -= 4;
+      p += 4;
+      while (length > 0) {
+         printf("%08x ", *((unsigned *) p));
+         p += 4;
+         length -= 4;
+      }
+      printf("\n");
+   }
 }
 #endif
 
@@ -1013,29 +1033,29 @@
 static void
 _glx_mesa_init_sparc_glapi_relocs(void)
 {
-	unsigned int *insn_ptr, *end_ptr;
-	unsigned long disp_addr;
+   unsigned int *insn_ptr, *end_ptr;
+   unsigned long disp_addr;
 
-	insn_ptr = &_mesa_sparc_glapi_begin;
-	end_ptr = &_mesa_sparc_glapi_end;
-	disp_addr = (unsigned long) &_glapi_Dispatch;
+   insn_ptr = &_mesa_sparc_glapi_begin;
+   end_ptr = &_mesa_sparc_glapi_end;
+   disp_addr = (unsigned long) &_glapi_Dispatch;
 
-	/*
-         * Verbatim from Mesa sparc.c.  It's needed because there doesn't
-         * seem to be a better way to do this:
-         *
-         * UNCONDITIONAL_JUMP ( (*_glapi_Dispatch) + entry_offset )
-         *
-         * This code is patching in the ADDRESS of the pointer to the
-         * dispatch table.  Hence, it must be called exactly once, because
-         * that address is not going to change.
-         *
-         * What it points to can change, but Mesa (and hence, we) assume
-         * that there is only one pointer.
-         *
-	 */
-	while (insn_ptr < end_ptr) {
-#if ( defined(__sparc_v9__) && ( !defined(__linux__) || defined(__linux_64__) ) )	
+   /*
+    * Verbatim from Mesa sparc.c.  It's needed because there doesn't
+    * seem to be a better way to do this:
+    *
+    * UNCONDITIONAL_JUMP ( (*_glapi_Dispatch) + entry_offset )
+    *
+    * This code is patching in the ADDRESS of the pointer to the
+    * dispatch table.  Hence, it must be called exactly once, because
+    * that address is not going to change.
+    *
+    * What it points to can change, but Mesa (and hence, we) assume
+    * that there is only one pointer.
+    *
+    */
+   while (insn_ptr < end_ptr) {
+#if ( defined(__sparc_v9__) && ( !defined(__linux__) || defined(__linux_64__) ) )
 /*
 	This code patches for 64-bit addresses.  This had better
 	not happen for Sparc/Linux, no matter what architecture we
@@ -1044,20 +1064,19 @@
         The 'defined(__linux_64__)' is used here as a placeholder for
         when we do do 64-bit usermode on sparc linux.
 	*/
-		insn_ptr[0] |= (disp_addr >> (32 + 10));
-		insn_ptr[1] |= ((disp_addr & 0xffffffff) >> 10);
-		__glapi_sparc_icache_flush(&insn_ptr[0]);
-		insn_ptr[2] |= ((disp_addr >> 32) & ((1 << 10) - 1));
-		insn_ptr[3] |= (disp_addr & ((1 << 10) - 1));
-		__glapi_sparc_icache_flush(&insn_ptr[2]);
-		insn_ptr += 11;
+      insn_ptr[0] |= (disp_addr >> (32 + 10));
+      insn_ptr[1] |= ((disp_addr & 0xffffffff) >> 10);
+      __glapi_sparc_icache_flush(&insn_ptr[0]);
+      insn_ptr[2] |= ((disp_addr >> 32) & ((1 << 10) - 1));
+      insn_ptr[3] |= (disp_addr & ((1 << 10) - 1));
+      __glapi_sparc_icache_flush(&insn_ptr[2]);
+      insn_ptr += 11;
 #else
-		insn_ptr[0] |= (disp_addr >> 10);
-		insn_ptr[1] |= (disp_addr & ((1 << 10) - 1));
-		__glapi_sparc_icache_flush(&insn_ptr[0]);
-		insn_ptr += 5;
+      insn_ptr[0] |= (disp_addr >> 10);
+      insn_ptr[1] |= (disp_addr & ((1 << 10) - 1));
+      __glapi_sparc_icache_flush(&insn_ptr[0]);
+      insn_ptr += 5;
 #endif
-	}
+   }
 }
-#endif  /* sparc ASM in use */
-
+#endif /* sparc ASM in use */

Modified: AppleSGLX/trunk/glxextensions.c
===================================================================
--- AppleSGLX/trunk/glxextensions.c	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/glxextensions.c	2009-12-21 20:56:26 UTC (rev 386)
@@ -32,10 +32,12 @@
 #include <X11/extensions/extutil.h>
 #include <X11/extensions/Xext.h>
 #include <string.h>
-//#include "glapi.h"
+#ifndef __APPLE__
+#include "glapi.h"
+#endif
 #include "glxextensions.h"
-#include "simple_list.h"
 
+
 #define SET_BIT(m,b)   (m[ (b) / 8 ] |=  (1U << ((b) % 8)))
 #define CLR_BIT(m,b)   (m[ (b) / 8 ] &= ~(1U << ((b) % 8)))
 #define IS_SET(m,b)    ((m[ (b) / 8 ] & (1U << ((b) % 8))) != 0)
@@ -48,60 +50,100 @@
 #define EXT_ENABLED(bit,supported) (IS_SET( supported, bit ))
 
 
-struct extension_info {
-   const char * const name;
-   unsigned   name_len;
+struct extension_info
+{
+   const char *const name;
+   unsigned name_len;
 
-   unsigned char  bit;
+   unsigned char bit;
 
    /* This is the lowest version of GLX that "requires" this extension.
     * For example, GLX 1.3 requires SGIX_fbconfig, SGIX_pbuffer, and
     * SGI_make_current_read.  If the extension is not required by any known
     * version of GLX, use 0, 0.
     */
-   unsigned char  version_major;
-   unsigned char  version_minor;
-   unsigned char  client_support;
-   unsigned char  direct_support;
-   unsigned char  client_only;       /** Is the extension client-side only? */
-   unsigned char  direct_only;       /** Is the extension for direct
+   unsigned char version_major;
+   unsigned char version_minor;
+   unsigned char client_support;
+   unsigned char direct_support;
+   unsigned char client_only;        /** Is the extension client-side only? */
+   unsigned char direct_only;        /** Is the extension for direct
 				      * contexts only?
 				      */
 };
 
+/* *INDENT-OFF* */
 static const struct extension_info known_glx_extensions[] = {
    { GLX(ARB_get_proc_address),        VER(1,4), Y, N, Y, N },
    { GLX(ARB_multisample),             VER(1,4), Y, Y, N, N },
    { GLX(ARB_render_texture),          VER(0,0), N, N, N, N },
    { GLX(ATI_pixel_format_float),      VER(0,0), N, N, N, N },
+#ifdef __APPLE__
    { GLX(EXT_import_context),          VER(0,0), N, N, N, N },
    { GLX(EXT_visual_info),             VER(0,0), N, N, N, N },
+#else
+   { GLX(EXT_import_context),          VER(0,0), Y, Y, N, N },
+   { GLX(EXT_visual_info),             VER(0,0), Y, Y, N, N },
+#endif
    { GLX(EXT_visual_rating),           VER(0,0), Y, Y, N, N },
+#ifdef __APPLE__
    { GLX(MESA_agp_offset),             VER(0,0), N, N, N, N }, /* Deprecated */
    { GLX(MESA_allocate_memory),        VER(0,0), N, N, N, N },
    { GLX(MESA_copy_sub_buffer),        VER(0,0), N, N, N, N },
+#else
+   { GLX(MESA_agp_offset),             VER(0,0), N, N, N, Y }, /* Deprecated */
+   { GLX(MESA_allocate_memory),        VER(0,0), Y, N, N, Y },
+   { GLX(MESA_copy_sub_buffer),        VER(0,0), Y, N, N, N },
+#endif
    { GLX(MESA_pixmap_colormap),        VER(0,0), N, N, N, N }, /* Deprecated */
    { GLX(MESA_release_buffers),        VER(0,0), N, N, N, N }, /* Deprecated */
+#ifdef __APPLE__
    { GLX(MESA_swap_control),           VER(0,0), N, N, N, N },
    { GLX(MESA_swap_frame_usage),       VER(0,0), N, N, N, N },
+#else
+   { GLX(MESA_swap_control),           VER(0,0), Y, N, N, Y },
+   { GLX(MESA_swap_frame_usage),       VER(0,0), Y, N, N, Y },
+#endif
    { GLX(NV_float_buffer),             VER(0,0), N, N, N, N },
    { GLX(NV_render_depth_texture),     VER(0,0), N, N, N, N },
    { GLX(NV_render_texture_rectangle), VER(0,0), N, N, N, N },
+#ifdef __APPLE__
    { GLX(NV_vertex_array_range),       VER(0,0), N, N, N, N }, /* Deprecated */
    { GLX(OML_swap_method),             VER(0,0), N, N, N, N },
    { GLX(OML_sync_control),            VER(0,0), N, N, N, N },
    { GLX(SGI_make_current_read),       VER(1,3), N, N, N, N },
    { GLX(SGI_swap_control),            VER(0,0), N, N, N, N },
    { GLX(SGI_video_sync),              VER(0,0), N, N, N, N },
+#else
+   { GLX(NV_vertex_array_range),       VER(0,0), N, N, N, Y }, /* Deprecated */
+   { GLX(OML_swap_method),             VER(0,0), Y, Y, N, N },
+   { GLX(OML_sync_control),            VER(0,0), Y, N, N, Y },
+   { GLX(SGI_make_current_read),       VER(1,3), Y, N, N, N },
+   { GLX(SGI_swap_control),            VER(0,0), Y, N, N, N },
+   { GLX(SGI_video_sync),              VER(0,0), Y, N, N, Y },
+#endif
    { GLX(SGIS_blended_overlay),        VER(0,0), N, N, N, N },
    { GLX(SGIS_color_range),            VER(0,0), N, N, N, N },
+#ifdef __APPLE__
    { GLX(SGIS_multisample),            VER(0,0), N, N, N, N },
+#else
+   { GLX(SGIS_multisample),            VER(0,0), Y, Y, N, N },
+#endif
    { GLX(SGIX_fbconfig),               VER(1,3), Y, Y, N, N },
+#ifdef __APPLE__
    { GLX(SGIX_pbuffer),                VER(1,3), N, N, N, N },
+#else
+   { GLX(SGIX_pbuffer),                VER(1,3), Y, Y, N, N },
+#endif
    { GLX(SGIX_swap_barrier),           VER(0,0), N, N, N, N },
    { GLX(SGIX_swap_group),             VER(0,0), N, N, N, N },
-   { GLX(SGIX_visual_select_group),    VER(0,0), N, N, N, N },
-   { GLX(EXT_texture_from_pixmap),     VER(0,0), N, N, N, N },
+#ifdef __APPLE__
+   { GLX(SGIX_visual_select_group),    VER(0,0), Y, Y, N, N },
+   { GLX(EXT_texture_from_pixmap),     VER(0,0), Y, N, N, N },
+#else
+   { GLX(SGIX_visual_select_group),    VER(0,0), Y, Y, N, N },
+   { GLX(EXT_texture_from_pixmap),     VER(0,0), Y, N, N, N },
+#endif
    { NULL }
 };
 
@@ -110,6 +152,7 @@
    { GL(ARB_draw_buffers),               VER(0,0), Y, N, N, N },
    { GL(ARB_fragment_program),           VER(0,0), Y, N, N, N },
    { GL(ARB_fragment_program_shadow),    VER(0,0), Y, N, N, N },
+   { GL(ARB_framebuffer_object),         VER(0,0), Y, N, N, N },
    { GL(ARB_imaging),                    VER(0,0), Y, N, N, N },
    { GL(ARB_multisample),                VER(1,3), Y, N, N, N },
    { GL(ARB_multitexture),               VER(1,3), Y, N, N, N },
@@ -148,8 +191,11 @@
    { GL(EXT_depth_bounds_test),          VER(0,0), N, N, N, N },
    { GL(EXT_draw_range_elements),        VER(1,2), Y, N, Y, N },
    { GL(EXT_fog_coord),                  VER(1,4), Y, N, N, N },
+   { GL(EXT_framebuffer_blit),           VER(0,0), Y, N, N, N },
+   { GL(EXT_framebuffer_multisample),    VER(0,0), Y, N, N, N },
    { GL(EXT_framebuffer_object),         VER(0,0), Y, N, N, N },
    { GL(EXT_multi_draw_arrays),          VER(1,4), Y, N, Y, N },
+   { GL(EXT_packed_depth_stencil),       VER(0,0), Y, N, N, N },
    { GL(EXT_packed_pixels),              VER(1,2), Y, N, N, N },
    { GL(EXT_paletted_texture),           VER(0,0), Y, N, N, N },
    { GL(EXT_pixel_buffer_object),        VER(0,0), N, N, N, N },
@@ -207,6 +253,7 @@
    { GL(NV_fragment_program2),           VER(0,0), Y, N, N, N },
    { GL(NV_light_max_exponent),          VER(0,0), Y, N, N, N },
    { GL(NV_multisample_filter_hint),     VER(0,0), Y, N, N, N },
+   { GL(NV_packed_depth_stencil),        VER(0,0), Y, N, N, N },
    { GL(NV_point_sprite),                VER(0,0), Y, N, N, N },
    { GL(NV_texgen_reflection),           VER(0,0), Y, N, N, N },
    { GL(NV_texture_compression_vtc),     VER(0,0), Y, N, N, N },
@@ -245,14 +292,15 @@
    { GL(SUN_slice_accum),                VER(0,0), Y, N, N, N },
    { NULL }
 };
+/* *INDENT-ON* */
 
 
 /* global bit-fields of available extensions and their characteristics */
 static unsigned char client_glx_support[8];
 static unsigned char client_glx_only[8];
 static unsigned char direct_glx_only[8];
-static unsigned char client_gl_support[ __GL_EXT_BYTES ];
-static unsigned char client_gl_only[ __GL_EXT_BYTES ];
+static unsigned char client_gl_support[__GL_EXT_BYTES];
+static unsigned char client_gl_only[__GL_EXT_BYTES];
 
 /**
  * Bits representing the set of extensions that are enabled by default in all
@@ -267,12 +315,13 @@
 static const unsigned gl_minor = 4;
 
 /* client extensions string */
-static const char * __glXGLXClientExtensions = NULL;
+static const char *__glXGLXClientExtensions = NULL;
 
-static void __glXExtensionsCtr( void );
-static void __glXExtensionsCtrScreen( __GLXscreenConfigs *psc );
-static void __glXProcessServerString( const struct extension_info * ext,
-    const char * server_string, unsigned char * server_support );
+static void __glXExtensionsCtr(void);
+static void __glXExtensionsCtrScreen(__GLXscreenConfigs * psc);
+static void __glXProcessServerString(const struct extension_info *ext,
+                                     const char *server_string,
+                                     unsigned char *server_support);
 
 /**
  * Set the state of a GLX extension.
@@ -283,24 +332,24 @@
  * \param supported Table in which the state of the extension is to be set.
  */
 static void
-set_glx_extension( const struct extension_info * ext,
-		   const char * name, unsigned name_len, GLboolean state,
-		   unsigned char * supported )
+set_glx_extension(const struct extension_info *ext,
+                  const char *name, unsigned name_len, GLboolean state,
+                  unsigned char *supported)
 {
-   unsigned   i;
+   unsigned i;
 
 
-   for ( i = 0 ; ext[i].name != NULL ; i++ ) {
-      if ( (name_len == ext[i].name_len)
-	   && (strncmp( ext[i].name, name, name_len ) == 0) ) {
-	 if ( state ) {
-	    SET_BIT( supported, ext[i].bit );
-	 }
-	 else {
-	    CLR_BIT( supported, ext[i].bit );
-	 }
+   for (i = 0; ext[i].name != NULL; i++) {
+      if ((name_len == ext[i].name_len)
+          && (strncmp(ext[i].name, name, name_len) == 0)) {
+         if (state) {
+            SET_BIT(supported, ext[i].bit);
+         }
+         else {
+            CLR_BIT(supported, ext[i].bit);
+         }
 
-	 return;
+         return;
       }
    }
 }
@@ -311,59 +360,55 @@
 
 /**
  * Convert the server's extension string to a bit-field.
- * 
+ *
  * \param server_string   GLX extension string from the server.
  * \param server_support  Bit-field of supported extensions.
- * 
+ *
  * \note
  * This function is used to process both GLX and GL extension strings.  The
  * bit-fields used to track each of these have different sizes.  Therefore,
  * the data pointed by \c server_support must be preinitialized to zero.
  */
 static void
-__glXProcessServerString( const struct extension_info * ext,
-			  const char * server_string,
-			  unsigned char * server_support )
+__glXProcessServerString(const struct extension_info *ext,
+                         const char *server_string,
+                         unsigned char *server_support)
 {
-   unsigned  base;
-   unsigned  len;
+   unsigned base;
+   unsigned len;
 
-   for ( base = 0 ; server_string[ base ] != NUL ; /* empty */ ) {
+   for (base = 0; server_string[base] != NUL; /* empty */ ) {
       /* Determine the length of the next extension name.
        */
-      for ( len = 0
-	    ; (server_string[ base + len ] != SEPARATOR)
-	    && (server_string[ base + len ] != NUL)
-	    ; len++ ) {
-	 /* empty */
+      for (len = 0; (server_string[base + len] != SEPARATOR)
+           && (server_string[base + len] != NUL); len++) {
+         /* empty */
       }
 
       /* Set the bit for the extension in the server_support table.
        */
-      set_glx_extension( ext, & server_string[ base ], len, GL_TRUE,
-			 server_support );
+      set_glx_extension(ext, &server_string[base], len, GL_TRUE,
+                        server_support);
 
- 
+
       /* Advance to the next extension string.  This means that we skip
        * over the previous string and any trialing white-space.
        */
-      for ( base += len ;
-	    (server_string[ base ] == SEPARATOR)
-	    && (server_string[ base ] != NUL)
-	    ; base++ ) {
-	 /* empty */
+      for (base += len; (server_string[base] == SEPARATOR)
+           && (server_string[base] != NUL); base++) {
+         /* empty */
       }
    }
 }
 
 void
-__glXEnableDirectExtension(__GLXscreenConfigs *psc, const char *name)
+__glXEnableDirectExtension(__GLXscreenConfigs * psc, const char *name)
 {
-    __glXExtensionsCtr();
-    __glXExtensionsCtrScreen(psc);
+   __glXExtensionsCtr();
+   __glXExtensionsCtrScreen(psc);
 
-    set_glx_extension(known_glx_extensions,
-		      name, strlen(name), GL_TRUE, psc->direct_support);
+   set_glx_extension(known_glx_extensions,
+                     name, strlen(name), GL_TRUE, psc->direct_support);
 }
 
 /**
@@ -371,58 +416,58 @@
  */
 
 static void
-__glXExtensionsCtr( void )
+__glXExtensionsCtr(void)
 {
-   unsigned   i;
+   unsigned i;
    static GLboolean ext_list_first_time = GL_TRUE;
 
 
-   if ( ext_list_first_time ) {
+   if (ext_list_first_time) {
       ext_list_first_time = GL_FALSE;
 
-      (void) memset( client_glx_support, 0, sizeof( client_glx_support ) );
-      (void) memset( direct_glx_support, 0, sizeof( direct_glx_support ) );
-      (void) memset( client_glx_only,    0, sizeof( client_glx_only ) );
-      (void) memset( direct_glx_only,    0, sizeof( direct_glx_only ) );
+      (void) memset(client_glx_support, 0, sizeof(client_glx_support));
+      (void) memset(direct_glx_support, 0, sizeof(direct_glx_support));
+      (void) memset(client_glx_only, 0, sizeof(client_glx_only));
+      (void) memset(direct_glx_only, 0, sizeof(direct_glx_only));
 
-      (void) memset( client_gl_support,  0, sizeof( client_gl_support ) );
-      (void) memset( client_gl_only,     0, sizeof( client_gl_only ) );
+      (void) memset(client_gl_support, 0, sizeof(client_gl_support));
+      (void) memset(client_gl_only, 0, sizeof(client_gl_only));
 
-      for ( i = 0 ; known_glx_extensions[i].name != NULL ; i++ ) {
-	 const unsigned  bit = known_glx_extensions[i].bit;
+      for (i = 0; known_glx_extensions[i].name != NULL; i++) {
+         const unsigned bit = known_glx_extensions[i].bit;
 
-	 if ( known_glx_extensions[i].client_support ) {
-	    SET_BIT( client_glx_support, bit );
-	 }
+         if (known_glx_extensions[i].client_support) {
+            SET_BIT(client_glx_support, bit);
+         }
 
-	 if ( known_glx_extensions[i].direct_support ) {
-	    SET_BIT( direct_glx_support, bit );
-	 }
+         if (known_glx_extensions[i].direct_support) {
+            SET_BIT(direct_glx_support, bit);
+         }
 
-	 if ( known_glx_extensions[i].client_only ) {
-	    SET_BIT( client_glx_only, bit );
-	 }
+         if (known_glx_extensions[i].client_only) {
+            SET_BIT(client_glx_only, bit);
+         }
 
-	 if ( known_glx_extensions[i].direct_only ) {
-	    SET_BIT( direct_glx_only, bit );
-	 }
+         if (known_glx_extensions[i].direct_only) {
+            SET_BIT(direct_glx_only, bit);
+         }
       }
 
-      for ( i = 0 ; known_gl_extensions[i].name != NULL ; i++ ) {
-	 const unsigned  bit = known_gl_extensions[i].bit;
+      for (i = 0; known_gl_extensions[i].name != NULL; i++) {
+         const unsigned bit = known_gl_extensions[i].bit;
 
-	 if ( known_gl_extensions[i].client_support ) {
-	    SET_BIT( client_gl_support, bit );
-	 }
+         if (known_gl_extensions[i].client_support) {
+            SET_BIT(client_gl_support, bit);
+         }
 
-	 if ( known_gl_extensions[i].client_only ) {
-	    SET_BIT( client_gl_only, bit );
-	 }
+         if (known_gl_extensions[i].client_only) {
+            SET_BIT(client_gl_only, bit);
+         }
       }
-      
+
 #if 0
-      fprintf( stderr, "[%s:%u] Maximum client library version: %u.%u\n",
-	       __func__, __LINE__, gl_major, gl_minor );
+      fprintf(stderr, "[%s:%u] Maximum client library version: %u.%u\n",
+              __func__, __LINE__, gl_major, gl_minor);
 #endif
    }
 }
@@ -435,13 +480,13 @@
  */
 
 static void
-__glXExtensionsCtrScreen( __GLXscreenConfigs *psc )
+__glXExtensionsCtrScreen(__GLXscreenConfigs * psc)
 {
-    if (psc->ext_list_first_time) {
-	psc->ext_list_first_time = GL_FALSE;
-	(void) memcpy( psc->direct_support, direct_glx_support,
-		       sizeof( direct_glx_support ) );
-    }
+   if (psc->ext_list_first_time) {
+      psc->ext_list_first_time = GL_FALSE;
+      (void) memcpy(psc->direct_support, direct_glx_support,
+                    sizeof(direct_glx_support));
+   }
 }
 
 
@@ -455,14 +500,14 @@
  *          \c NULL, then \c GL_FALSE is returned.
  */
 GLboolean
-__glXExtensionBitIsEnabled( __GLXscreenConfigs *psc, unsigned bit )
+__glXExtensionBitIsEnabled(__GLXscreenConfigs * psc, unsigned bit)
 {
    GLboolean enabled = GL_FALSE;
 
-   if ( psc != NULL ) {
+   if (psc != NULL) {
       __glXExtensionsCtr();
-      __glXExtensionsCtrScreen( psc );
-      enabled = EXT_ENABLED( bit, psc->direct_support );
+      __glXExtensionsCtrScreen(psc);
+      enabled = EXT_ENABLED(bit, psc->direct_support);
    }
 
    return enabled;
@@ -474,12 +519,12 @@
  *
  */
 GLboolean
-__glExtensionBitIsEnabled( const __GLXcontext * gc, unsigned bit )
+__glExtensionBitIsEnabled(const __GLXcontext * gc, unsigned bit)
 {
    GLboolean enabled = GL_FALSE;
 
-   if ( gc != NULL ) {
-      enabled = EXT_ENABLED( bit, gc->gl_extension_bits );
+   if (gc != NULL) {
+      enabled = EXT_ENABLED(bit, gc->gl_extension_bits);
    }
 
    return enabled;
@@ -491,34 +536,34 @@
  * Convert a bit-field to a string of supported extensions.
  */
 static char *
-__glXGetStringFromTable( const struct extension_info * ext,
-			 const unsigned char * supported )
+__glXGetStringFromTable(const struct extension_info *ext,
+                        const unsigned char *supported)
 {
-   unsigned   i;
-   unsigned   ext_str_len;
-   char * ext_str;
-   char * point;
+   unsigned i;
+   unsigned ext_str_len;
+   char *ext_str;
+   char *point;
 
 
    ext_str_len = 0;
-   for ( i = 0 ; ext[i].name != NULL ; i++ ) {
-      if ( EXT_ENABLED( ext[i].bit, supported ) ) {
-	 ext_str_len += ext[i].name_len + 1;
+   for (i = 0; ext[i].name != NULL; i++) {
+      if (EXT_ENABLED(ext[i].bit, supported)) {
+         ext_str_len += ext[i].name_len + 1;
       }
    }
 
-   ext_str = Xmalloc( ext_str_len + 1 );
-   if ( ext_str != NULL ) {
+   ext_str = Xmalloc(ext_str_len + 1);
+   if (ext_str != NULL) {
       point = ext_str;
 
-      for ( i = 0 ; ext[i].name != NULL ; i++ ) {
-	 if ( EXT_ENABLED( ext[i].bit, supported ) ) {
-	    (void) memcpy( point, ext[i].name, ext[i].name_len );
-	    point += ext[i].name_len;
+      for (i = 0; ext[i].name != NULL; i++) {
+         if (EXT_ENABLED(ext[i].bit, supported)) {
+            (void) memcpy(point, ext[i].name, ext[i].name_len);
+            point += ext[i].name_len;
 
-	    *point = ' ';
-	    point++;
-	 }
+            *point = ' ';
+            point++;
+         }
       }
 
       *point = '\0';
@@ -532,12 +577,12 @@
  * Get the string of client library supported extensions.
  */
 const char *
-__glXGetClientExtensions( void )
+__glXGetClientExtensions(void)
 {
-   if ( __glXGLXClientExtensions == NULL ) {
+   if (__glXGLXClientExtensions == NULL) {
       __glXExtensionsCtr();
-      __glXGLXClientExtensions = __glXGetStringFromTable( known_glx_extensions,
-							  client_glx_support );
+      __glXGLXClientExtensions = __glXGetStringFromTable(known_glx_extensions,
+                                                         client_glx_support);
    }
 
    return __glXGLXClientExtensions;
@@ -547,7 +592,7 @@
 /**
  * Calculate the list of application usable extensions.  The resulting
  * string is stored in \c psc->effectiveGLXexts.
- * 
+ *
  * \param psc                        Pointer to GLX per-screen record.
  * \param display_is_direct_capable  True if the display is capable of
  *                                   direct rendering.
@@ -555,20 +600,20 @@
  */
 
 void
-__glXCalculateUsableExtensions( __GLXscreenConfigs *psc,
-				GLboolean display_is_direct_capable,
-				int minor_version )
+__glXCalculateUsableExtensions(__GLXscreenConfigs * psc,
+                               GLboolean display_is_direct_capable,
+                               int minor_version)
 {
    unsigned char server_support[8];
    unsigned char usable[8];
-   unsigned      i;
+   unsigned i;
 
    __glXExtensionsCtr();
-   __glXExtensionsCtrScreen( psc );
+   __glXExtensionsCtrScreen(psc);
 
-   (void) memset( server_support, 0, sizeof( server_support ) );
-   __glXProcessServerString( known_glx_extensions,
-			     psc->serverGLXexts, server_support );
+   (void) memset(server_support, 0, sizeof(server_support));
+   __glXProcessServerString(known_glx_extensions,
+                            psc->serverGLXexts, server_support);
 
 
    /* This is a hack.  Some servers support GLX 1.3 but don't export
@@ -577,20 +622,20 @@
     * "emulated" as well.
     */
 
-   if ( minor_version >= 3 ) {
-      SET_BIT( server_support, EXT_visual_info_bit );
-      SET_BIT( server_support, EXT_visual_rating_bit );
-      SET_BIT( server_support, SGI_make_current_read_bit );
-      SET_BIT( server_support, SGIX_fbconfig_bit );
-      SET_BIT( server_support, SGIX_pbuffer_bit );
-       
+   if (minor_version >= 3) {
+      SET_BIT(server_support, EXT_visual_info_bit);
+      SET_BIT(server_support, EXT_visual_rating_bit);
+      SET_BIT(server_support, SGI_make_current_read_bit);
+      SET_BIT(server_support, SGIX_fbconfig_bit);
+      SET_BIT(server_support, SGIX_pbuffer_bit);
+
       /* This one is a little iffy.  GLX 1.3 doesn't incorporate all of this
        * extension.  However, the only part that is not strictly client-side
        * is shared.  That's the glXQueryContext / glXQueryContextInfoEXT
        * function.
        */
 
-      SET_BIT( server_support, EXT_import_context_bit );
+      SET_BIT(server_support, EXT_import_context_bit);
    }
 
 
@@ -598,35 +643,37 @@
     * it and the "server" supports it.  In this case that means that either
     * the true server supports it or it is only for direct-rendering and
     * the direct rendering driver supports it.
-    * 
+    *
     * If the display is not capable of direct rendering, then the extension
     * is enabled if and only if the client-side library and the server
     * support it.
     */
 
-   if ( display_is_direct_capable ) {
-      for ( i = 0 ; i < 8 ; i++ ) {
-	 usable[i] = (client_glx_support[i] & client_glx_only[i])
-	     | (client_glx_support[i] & psc->direct_support[i] & server_support[i])
-	     | (client_glx_support[i] & psc->direct_support[i] & direct_glx_only[i]);
+   if (display_is_direct_capable) {
+      for (i = 0; i < 8; i++) {
+         usable[i] = (client_glx_support[i] & client_glx_only[i])
+            | (client_glx_support[i] & psc->direct_support[i] &
+               server_support[i])
+            | (client_glx_support[i] & psc->direct_support[i] &
+               direct_glx_only[i]);
       }
    }
    else {
-      for ( i = 0 ; i < 8 ; i++ ) {
-	 usable[i] = (client_glx_support[i] & client_glx_only[i])
-	     | (client_glx_support[i] & server_support[i]);
+      for (i = 0; i < 8; i++) {
+         usable[i] = (client_glx_support[i] & client_glx_only[i])
+            | (client_glx_support[i] & server_support[i]);
       }
    }
 
-   psc->effectiveGLXexts = __glXGetStringFromTable( known_glx_extensions,
-						    usable );
+   psc->effectiveGLXexts = __glXGetStringFromTable(known_glx_extensions,
+                                                   usable);
 }
 
 
 /**
  * Calculate the list of application usable extensions.  The resulting
  * string is stored in \c gc->extensions.
- * 
+ *
  * \param gc             Pointer to GLX context.
  * \param server_string  Extension string from the server.
  * \param major_version  GL major version from the server.
@@ -634,32 +681,33 @@
  */
 
 void
-__glXCalculateUsableGLExtensions( __GLXcontext * gc,
-				  const char * server_string,
-				  int major_version, int minor_version )
+__glXCalculateUsableGLExtensions(__GLXcontext * gc,
+                                 const char *server_string,
+                                 int major_version, int minor_version)
 {
-   unsigned char server_support[ __GL_EXT_BYTES ];
-   unsigned char usable[ __GL_EXT_BYTES ];
-   unsigned      i;
+   unsigned char server_support[__GL_EXT_BYTES];
+   unsigned char usable[__GL_EXT_BYTES];
+   unsigned i;
 
 
    __glXExtensionsCtr();
 
-   (void) memset( server_support, 0, sizeof( server_support ) );
-   __glXProcessServerString( known_gl_extensions, server_string,
-			     server_support );
+   (void) memset(server_support, 0, sizeof(server_support));
+   __glXProcessServerString(known_gl_extensions, server_string,
+                            server_support);
 
 
    /* Handle lazy servers that don't export all the extensions strings that
     * are part of the GL core version that they support.
     */
 
-   for ( i = 0 ; i < __GL_EXT_BYTES ; i++ ) {
-      if ( (known_gl_extensions[i].version_major != 0)
-	   && ((major_version > known_gl_extensions[i].version_major)
-	       || ((major_version == known_gl_extensions[i].version_major)
-		   && (minor_version >= known_gl_extensions[i].version_minor))) ) {
-	 SET_BIT( server_support, known_gl_extensions[i].bit );
+   for (i = 0; i < __GL_EXT_BYTES; i++) {
+      if ((known_gl_extensions[i].version_major != 0)
+          && ((major_version > known_gl_extensions[i].version_major)
+              || ((major_version == known_gl_extensions[i].version_major)
+                  && (minor_version >=
+                      known_gl_extensions[i].version_minor)))) {
+         SET_BIT(server_support, known_gl_extensions[i].bit);
       }
    }
 
@@ -669,14 +717,14 @@
     * and it only needs client-side support.
     */
 
-   for ( i = 0 ; i < __GL_EXT_BYTES ; i++ ) {
+   for (i = 0; i < __GL_EXT_BYTES; i++) {
       usable[i] = (client_gl_support[i] & client_gl_only[i])
-	| (client_gl_support[i] & server_support[i]);
+         | (client_gl_support[i] & server_support[i]);
    }
 
-   gc->extensions = (unsigned char *) 
-     __glXGetStringFromTable( known_gl_extensions, usable );
-   (void) memcpy( gc->gl_extension_bits, usable, sizeof( usable ) );
+   gc->extensions = (unsigned char *)
+      __glXGetStringFromTable(known_gl_extensions, usable);
+   (void) memcpy(gc->gl_extension_bits, usable, sizeof(usable));
 }
 
 
@@ -685,11 +733,11 @@
  * rendering.
  */
 void
-__glXGetGLVersion( int * major_version, int * minor_version )
-{		   
-    __glXExtensionsCtr();
-    *major_version = gl_major;
-    *minor_version = gl_minor;
+__glXGetGLVersion(int *major_version, int *minor_version)
+{
+   __glXExtensionsCtr();
+   *major_version = gl_major;
+   *minor_version = gl_minor;
 }
 
 
@@ -699,8 +747,8 @@
  * supported by the client to the server.
  */
 char *
-__glXGetClientGLExtensionString( void )
+__glXGetClientGLExtensionString(void)
 {
-    __glXExtensionsCtr();
-    return __glXGetStringFromTable( known_gl_extensions, client_gl_support );
+   __glXExtensionsCtr();
+   return __glXGetStringFromTable(known_gl_extensions, client_gl_support);
 }

Modified: AppleSGLX/trunk/glxextensions.h
===================================================================
--- AppleSGLX/trunk/glxextensions.h	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/glxextensions.h	2009-12-21 20:56:26 UTC (rev 386)
@@ -31,7 +31,8 @@
 #ifndef GLX_GLXEXTENSIONS_H
 #define GLX_GLXEXTENSIONS_H
 
-enum {
+enum
+{
    ARB_get_proc_address_bit = 0,
    ARB_multisample_bit,
    ARB_render_texture_bit,
@@ -40,7 +41,7 @@
    EXT_visual_rating_bit,
    EXT_import_context_bit,
    MESA_agp_offset_bit,
-   MESA_allocate_memory_bit, /* Replaces MESA_agp_offset & NV_vertex_array_range */
+   MESA_allocate_memory_bit,    /* Replaces MESA_agp_offset & NV_vertex_array_range */
    MESA_copy_sub_buffer_bit,
    MESA_depth_float_bit,
    MESA_pixmap_colormap_bit,
@@ -67,11 +68,13 @@
    EXT_texture_from_pixmap_bit
 };
 
-enum {
+enum
+{
    GL_ARB_depth_texture_bit = 0,
    GL_ARB_draw_buffers_bit,
    GL_ARB_fragment_program_bit,
    GL_ARB_fragment_program_shadow_bit,
+   GL_ARB_framebuffer_object_bit,
    GL_ARB_imaging_bit,
    GL_ARB_multisample_bit,
    GL_ARB_multitexture_bit,
@@ -110,8 +113,11 @@
    GL_EXT_depth_bounds_test_bit,
    GL_EXT_draw_range_elements_bit,
    GL_EXT_fog_coord_bit,
+   GL_EXT_framebuffer_blit_bit,
+   GL_EXT_framebuffer_multisample_bit,
    GL_EXT_framebuffer_object_bit,
    GL_EXT_multi_draw_arrays_bit,
+   GL_EXT_packed_depth_stencil_bit,
    GL_EXT_packed_pixels_bit,
    GL_EXT_paletted_texture_bit,
    GL_EXT_pixel_buffer_object_bit,
@@ -162,6 +168,7 @@
    GL_NV_fragment_program2_bit,
    GL_NV_light_max_exponent_bit,
    GL_NV_multisample_filter_hint_bit,
+   GL_NV_packed_depth_stencil_bit,
    GL_NV_point_sprite_bit,
    GL_NV_texgen_reflection_bit,
    GL_NV_texture_compression_vtc_bit,
@@ -230,28 +237,34 @@
 struct __GLXscreenConfigsRec;
 struct __GLXcontextRec;
 
-extern GLboolean __glXExtensionBitIsEnabled( struct __GLXscreenConfigsRec *psc, unsigned bit );
-extern const char * __glXGetClientExtensions( void );
-extern void __glXCalculateUsableExtensions( struct __GLXscreenConfigsRec *psc,
-    GLboolean display_is_direct_capable, int server_minor_version );
+extern GLboolean __glXExtensionBitIsEnabled(struct __GLXscreenConfigsRec *psc,
+                                            unsigned bit);
+extern const char *__glXGetClientExtensions(void);
+extern void __glXCalculateUsableExtensions(struct __GLXscreenConfigsRec *psc,
+                                           GLboolean
+                                           display_is_direct_capable,
+                                           int server_minor_version);
 
-extern void __glXCalculateUsableGLExtensions( struct __GLXcontextRec * gc,
-    const char * server_string, int major_version, int minor_version );
-extern void __glXGetGLVersion( int * major_version, int * minor_version );
-extern char * __glXGetClientGLExtensionString( void );
+extern void __glXCalculateUsableGLExtensions(struct __GLXcontextRec *gc,
+                                             const char *server_string,
+                                             int major_version,
+                                             int minor_version);
+extern void __glXGetGLVersion(int *major_version, int *minor_version);
+extern char *__glXGetClientGLExtensionString(void);
 
-extern GLboolean __glExtensionBitIsEnabled( const struct __GLXcontextRec * gc, 
-    unsigned bit );
+extern GLboolean __glExtensionBitIsEnabled(const struct __GLXcontextRec *gc,
+                                           unsigned bit);
 
 extern void
-__glXEnableDirectExtension(struct __GLXscreenConfigsRec *psc, const char *name);
+__glXEnableDirectExtension(struct __GLXscreenConfigsRec *psc,
+                           const char *name);
 
 /* Source-level backwards compatibility with old drivers. They won't
  * find the respective functions, though. 
  */
-typedef void (* PFNGLXENABLEEXTENSIONPROC) ( const char * name,
-    GLboolean force_client );
-typedef void (* PFNGLXDISABLEEXTENSIONPROC) ( const char * name );
+typedef void (*PFNGLXENABLEEXTENSIONPROC) (const char *name,
+                                           GLboolean force_client);
+typedef void (*PFNGLXDISABLEEXTENSIONPROC) (const char *name);
 
 /* GLX_ALIAS should be used for functions with a non-void return type.
    GLX_ALIAS_VOID is for functions with a void return type. */
@@ -261,17 +274,17 @@
 #else
 # if defined(__GNUC__) && !defined(GLX_ALIAS_UNSUPPORTED)
 #  define GLX_ALIAS(return_type, real_func, proto_args, args, aliased_func) \
-	return_type  real_func  proto_args \
-	__attribute__ ((alias( # aliased_func ) ));
+   return_type  real_func  proto_args                                   \
+   __attribute__ ((alias( # aliased_func ) ));
 #  define GLX_ALIAS_VOID(real_func, proto_args, args, aliased_func) \
-	GLX_ALIAS(void, real_func, proto_args, args, aliased_func)
+   GLX_ALIAS(void, real_func, proto_args, args, aliased_func)
 # else
 #  define GLX_ALIAS(return_type, real_func, proto_args, args, aliased_func) \
-	return_type  real_func  proto_args \
-	{ return aliased_func args ; }
+   return_type  real_func  proto_args                                   \
+   { return aliased_func args ; }
 #  define GLX_ALIAS_VOID(real_func, proto_args, args, aliased_func) \
-	void  real_func  proto_args \
-	{ aliased_func args ; }
+   void  real_func  proto_args                                      \
+   { aliased_func args ; }
 # endif /* __GNUC__ */
 #endif /* GLX_NO_STATIC_EXTENSION_FUNCTIONS */
 

Modified: AppleSGLX/trunk/glxhash.c
===================================================================
--- AppleSGLX/trunk/glxhash.c	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/glxhash.c	2009-12-21 20:56:26 UTC (rev 386)
@@ -80,8 +80,8 @@
 
 #define HASH_MAGIC 0xdeadbeef
 #define HASH_DEBUG 0
-#define HASH_SIZE  512		/* Good for about 100 entries */
-				/* If you change this value, you probably
+#define HASH_SIZE  512          /* Good for about 100 entries */
+                                /* If you change this value, you probably
                                    have to change the HashHash hashing
                                    function! */
 
@@ -92,323 +92,370 @@
 #define HASH_RANDOM             random()
 #define HASH_RANDOM_DESTROY
 
-typedef struct __glxHashBucket {
-    unsigned long     key;
-    void              *value;
-    struct __glxHashBucket *next;
+typedef struct __glxHashBucket
+{
+   unsigned long key;
+   void *value;
+   struct __glxHashBucket *next;
 } __glxHashBucket, *__glxHashBucketPtr;
 
 typedef struct __glxHashTable *__glxHashTablePtr;
-struct __glxHashTable {
-    unsigned long    magic;
-    unsigned long    hits;	/* At top of linked list */
-    unsigned long    partials;	/* Not at top of linked list */
-    unsigned long    misses;	/* Not in table */
-    __glxHashBucketPtr    buckets[HASH_SIZE];
-    int              p0;
-    __glxHashBucketPtr    p1;
+struct __glxHashTable
+{
+   unsigned long magic;
+   unsigned long hits;          /* At top of linked list */
+   unsigned long partials;      /* Not at top of linked list */
+   unsigned long misses;        /* Not in table */
+   __glxHashBucketPtr buckets[HASH_SIZE];
+   int p0;
+   __glxHashBucketPtr p1;
 };
 
-static unsigned long HashHash(unsigned long key)
+static unsigned long
+HashHash(unsigned long key)
 {
-    unsigned long        hash = 0;
-    unsigned long        tmp  = key;
-    static int           init = 0;
-    static unsigned long scatter[256];
-    int                  i;
+   unsigned long hash = 0;
+   unsigned long tmp = key;
+   static int init = 0;
+   static unsigned long scatter[256];
+   int i;
 
-    if (!init) {
-	HASH_RANDOM_DECL;
-	HASH_RANDOM_INIT(37);
-	for (i = 0; i < 256; i++) scatter[i] = HASH_RANDOM;
-	HASH_RANDOM_DESTROY;
-	++init;
-    }
+   if (!init) {
+      HASH_RANDOM_DECL;
+      HASH_RANDOM_INIT(37);
+      for (i = 0; i < 256; i++)
+         scatter[i] = HASH_RANDOM;
+      HASH_RANDOM_DESTROY;
+      ++init;
+   }
 
-    while (tmp) {
-	hash = (hash << 1) + scatter[tmp & 0xff];
-	tmp >>= 8;
-    }
+   while (tmp) {
+      hash = (hash << 1) + scatter[tmp & 0xff];
+      tmp >>= 8;
+   }
 
-    hash %= HASH_SIZE;
+   hash %= HASH_SIZE;
 #if HASH_DEBUG
-    printf( "Hash(%d) = %d\n", key, hash);
+   printf("Hash(%d) = %d\n", key, hash);
 #endif
-    return hash;
+   return hash;
 }
 
-_X_HIDDEN __glxHashTable *__glxHashCreate(void)
+_X_HIDDEN __glxHashTable *
+__glxHashCreate(void)
 {
-    __glxHashTablePtr table;
-    int          i;
+   __glxHashTablePtr table;
+   int i;
 
-    table           = HASH_ALLOC(sizeof(*table));
-    if (!table) return NULL;
-    table->magic    = HASH_MAGIC;
-    table->hits     = 0;
-    table->partials = 0;
-    table->misses   = 0;
+   table = HASH_ALLOC(sizeof(*table));
+   if (!table)
+      return NULL;
+   table->magic = HASH_MAGIC;
+   table->hits = 0;
+   table->partials = 0;
+   table->misses = 0;
 
-    for (i = 0; i < HASH_SIZE; i++) table->buckets[i] = NULL;
-    return table;
+   for (i = 0; i < HASH_SIZE; i++)
+      table->buckets[i] = NULL;
+   return table;
 }
 
-_X_HIDDEN int __glxHashDestroy(__glxHashTable *t)
+_X_HIDDEN int
+__glxHashDestroy(__glxHashTable * t)
 {
-    __glxHashTablePtr  table = (__glxHashTablePtr)t;
-    __glxHashBucketPtr bucket;
-    __glxHashBucketPtr next;
-    int           i;
+   __glxHashTablePtr table = (__glxHashTablePtr) t;
+   __glxHashBucketPtr bucket;
+   __glxHashBucketPtr next;
+   int i;
 
-    if (table->magic != HASH_MAGIC) return -1; /* Bad magic */
+   if (table->magic != HASH_MAGIC)
+      return -1;                /* Bad magic */
 
-    for (i = 0; i < HASH_SIZE; i++) {
-	for (bucket = table->buckets[i]; bucket;) {
-	    next = bucket->next;
-	    HASH_FREE(bucket);
-	    bucket = next;
-	}
-    }
-    HASH_FREE(table);
-    return 0;
+   for (i = 0; i < HASH_SIZE; i++) {
+      for (bucket = table->buckets[i]; bucket;) {
+         next = bucket->next;
+         HASH_FREE(bucket);
+         bucket = next;
+      }
+   }
+   HASH_FREE(table);
+   return 0;
 }
 
 /* Find the bucket and organize the list so that this bucket is at the
    top. */
 
-static __glxHashBucketPtr HashFind(__glxHashTablePtr table,
-			      unsigned long key, unsigned long *h)
+static __glxHashBucketPtr
+HashFind(__glxHashTablePtr table, unsigned long key, unsigned long *h)
 {
-    unsigned long hash = HashHash(key);
-    __glxHashBucketPtr prev = NULL;
-    __glxHashBucketPtr bucket;
+   unsigned long hash = HashHash(key);
+   __glxHashBucketPtr prev = NULL;
+   __glxHashBucketPtr bucket;
 
-    if (h) *h = hash;
+   if (h)
+      *h = hash;
 
-    for (bucket = table->buckets[hash]; bucket; bucket = bucket->next) {
-	if (bucket->key == key) {
-	    if (prev) {
-				/* Organize */
-		prev->next           = bucket->next;
-		bucket->next         = table->buckets[hash];
-		table->buckets[hash] = bucket;
-		++table->partials;
-	    } else {
-		++table->hits;
-	    }
-	    return bucket;
-	}
-	prev = bucket;
-    }
-    ++table->misses;
-    return NULL;
+   for (bucket = table->buckets[hash]; bucket; bucket = bucket->next) {
+      if (bucket->key == key) {
+         if (prev) {
+            /* Organize */
+            prev->next = bucket->next;
+            bucket->next = table->buckets[hash];
+            table->buckets[hash] = bucket;
+            ++table->partials;
+         }
+         else {
+            ++table->hits;
+         }
+         return bucket;
+      }
+      prev = bucket;
+   }
+   ++table->misses;
+   return NULL;
 }
 
-_X_HIDDEN int __glxHashLookup(__glxHashTable *t,
-			      unsigned long key, void **value)
+_X_HIDDEN int
+__glxHashLookup(__glxHashTable * t, unsigned long key, void **value)
 {
-    __glxHashTablePtr  table = (__glxHashTablePtr)t;
-    __glxHashBucketPtr bucket;
+   __glxHashTablePtr table = (__glxHashTablePtr) t;
+   __glxHashBucketPtr bucket;
 
-    if (!table || table->magic != HASH_MAGIC) return -1; /* Bad magic */
+   if (!table || table->magic != HASH_MAGIC)
+      return -1;                /* Bad magic */
 
-    bucket = HashFind(table, key, NULL);
-    if (!bucket) return 1;	/* Not found */
-    *value = bucket->value;
-    return 0;			/* Found */
+   bucket = HashFind(table, key, NULL);
+   if (!bucket)
+      return 1;                 /* Not found */
+   *value = bucket->value;
+   return 0;                    /* Found */
 }
 
-_X_HIDDEN int __glxHashInsert(__glxHashTable *t,
-			      unsigned long key, void *value)
+_X_HIDDEN int
+__glxHashInsert(__glxHashTable * t, unsigned long key, void *value)
 {
-    __glxHashTablePtr  table = (__glxHashTablePtr)t;
-    __glxHashBucketPtr bucket;
-    unsigned long hash;
+   __glxHashTablePtr table = (__glxHashTablePtr) t;
+   __glxHashBucketPtr bucket;
+   unsigned long hash;
 
-    if (table->magic != HASH_MAGIC) return -1; /* Bad magic */
+   if (table->magic != HASH_MAGIC)
+      return -1;                /* Bad magic */
 
-    if (HashFind(table, key, &hash)) return 1; /* Already in table */
+   if (HashFind(table, key, &hash))
+      return 1;                 /* Already in table */
 
-    bucket               = HASH_ALLOC(sizeof(*bucket));
-    if (!bucket) return -1;	/* Error */
-    bucket->key          = key;
-    bucket->value        = value;
-    bucket->next         = table->buckets[hash];
-    table->buckets[hash] = bucket;
+   bucket = HASH_ALLOC(sizeof(*bucket));
+   if (!bucket)
+      return -1;                /* Error */
+   bucket->key = key;
+   bucket->value = value;
+   bucket->next = table->buckets[hash];
+   table->buckets[hash] = bucket;
 #if HASH_DEBUG
-    printf("Inserted %d at %d/%p\n", key, hash, bucket);
+   printf("Inserted %d at %d/%p\n", key, hash, bucket);
 #endif
-    return 0;			/* Added to table */
+   return 0;                    /* Added to table */
 }
 
-_X_HIDDEN int __glxHashDelete(__glxHashTable *t, unsigned long key)
+_X_HIDDEN int
+__glxHashDelete(__glxHashTable * t, unsigned long key)
 {
-    __glxHashTablePtr  table = (__glxHashTablePtr)t;
-    unsigned long hash;
-    __glxHashBucketPtr bucket;
+   __glxHashTablePtr table = (__glxHashTablePtr) t;
+   unsigned long hash;
+   __glxHashBucketPtr bucket;
 
-    if (table->magic != HASH_MAGIC) return -1; /* Bad magic */
+   if (table->magic != HASH_MAGIC)
+      return -1;                /* Bad magic */
 
-    bucket = HashFind(table, key, &hash);
+   bucket = HashFind(table, key, &hash);
 
-    if (!bucket) return 1;	/* Not found */
+   if (!bucket)
+      return 1;                 /* Not found */
 
-    table->buckets[hash] = bucket->next;
-    HASH_FREE(bucket);
-    return 0;
+   table->buckets[hash] = bucket->next;
+   HASH_FREE(bucket);
+   return 0;
 }
 
-_X_HIDDEN int __glxHashNext(__glxHashTable *t,
-			    unsigned long *key, void **value)
+_X_HIDDEN int
+__glxHashNext(__glxHashTable * t, unsigned long *key, void **value)
 {
-    __glxHashTablePtr  table = (__glxHashTablePtr)t;
+   __glxHashTablePtr table = (__glxHashTablePtr) t;
 
-    while (table->p0 < HASH_SIZE) {
-	if (table->p1) {
-	    *key       = table->p1->key;
-	    *value     = table->p1->value;
-	    table->p1  = table->p1->next;
-	    return 1;
-	}
-	table->p1 = table->buckets[table->p0];
-	++table->p0;
-    }
-    return 0;
+   while (table->p0 < HASH_SIZE) {
+      if (table->p1) {
+         *key = table->p1->key;
+         *value = table->p1->value;
+         table->p1 = table->p1->next;
+         return 1;
+      }
+      table->p1 = table->buckets[table->p0];
+      ++table->p0;
+   }
+   return 0;
 }
 
-_X_HIDDEN int __glxHashFirst(__glxHashTable *t,
-			     unsigned long *key, void **value)
+_X_HIDDEN int
+__glxHashFirst(__glxHashTable * t, unsigned long *key, void **value)
 {
-    __glxHashTablePtr  table = (__glxHashTablePtr)t;
+   __glxHashTablePtr table = (__glxHashTablePtr) t;
 
-    if (table->magic != HASH_MAGIC) return -1; /* Bad magic */
+   if (table->magic != HASH_MAGIC)
+      return -1;                /* Bad magic */
 
-    table->p0 = 0;
-    table->p1 = table->buckets[0];
-    return __glxHashNext(table, key, value);
+   table->p0 = 0;
+   table->p1 = table->buckets[0];
+   return __glxHashNext(table, key, value);
 }
 
 #if HASH_MAIN
 #define DIST_LIMIT 10
 static int dist[DIST_LIMIT];
 
-static void clear_dist(void) {
-    int i;
+static void
+clear_dist(void)
+{
+   int i;
 
-    for (i = 0; i < DIST_LIMIT; i++) dist[i] = 0;
+   for (i = 0; i < DIST_LIMIT; i++)
+      dist[i] = 0;
 }
 
-static int count_entries(__glxHashBucketPtr bucket)
+static int
+count_entries(__glxHashBucketPtr bucket)
 {
-    int count = 0;
+   int count = 0;
 
-    for (; bucket; bucket = bucket->next) ++count;
-    return count;
+   for (; bucket; bucket = bucket->next)
+      ++count;
+   return count;
 }
 
-static void update_dist(int count)
+static void
+update_dist(int count)
 {
-    if (count >= DIST_LIMIT) ++dist[DIST_LIMIT-1];
-    else                     ++dist[count];
+   if (count >= DIST_LIMIT)
+      ++dist[DIST_LIMIT - 1];
+   else
+      ++dist[count];
 }
 
-static void compute_dist(__glxHashTablePtr table)
+static void
+compute_dist(__glxHashTablePtr table)
 {
-    int           i;
-    __glxHashBucketPtr bucket;
+   int i;
+   __glxHashBucketPtr bucket;
 
-    printf("Hits = %ld, partials = %ld, misses = %ld\n",
-	   table->hits, table->partials, table->misses);
-    clear_dist();
-    for (i = 0; i < HASH_SIZE; i++) {
-	bucket = table->buckets[i];
-	update_dist(count_entries(bucket));
-    }
-    for (i = 0; i < DIST_LIMIT; i++) {
-	if (i != DIST_LIMIT-1) printf("%5d %10d\n", i, dist[i]);
-	else                   printf("other %10d\n", dist[i]);
-    }
+   printf("Hits = %ld, partials = %ld, misses = %ld\n",
+          table->hits, table->partials, table->misses);
+   clear_dist();
+   for (i = 0; i < HASH_SIZE; i++) {
+      bucket = table->buckets[i];
+      update_dist(count_entries(bucket));
+   }
+   for (i = 0; i < DIST_LIMIT; i++) {
+      if (i != DIST_LIMIT - 1)
+         printf("%5d %10d\n", i, dist[i]);
+      else
+         printf("other %10d\n", dist[i]);
+   }
 }
 
-static void check_table(__glxHashTablePtr table,
-			unsigned long key, unsigned long value)
+static void
+check_table(__glxHashTablePtr table, unsigned long key, unsigned long value)
 {
-    unsigned long retval  = 0;
-    int           retcode = __glxHashLookup(table, key, &retval);
+   unsigned long retval = 0;
+   int retcode = __glxHashLookup(table, key, &retval);
 
-    switch (retcode) {
-    case -1:
-	printf("Bad magic = 0x%08lx:"
-	       " key = %lu, expected = %lu, returned = %lu\n",
-	       table->magic, key, value, retval);
-	break;
-    case 1:
-	printf("Not found: key = %lu, expected = %lu returned = %lu\n",
-	       key, value, retval);
-	break;
-    case 0:
-	if (value != retval)
-	    printf("Bad value: key = %lu, expected = %lu, returned = %lu\n",
-		   key, value, retval);
-	break;
-    default:
-	printf("Bad retcode = %d: key = %lu, expected = %lu, returned = %lu\n",
-	       retcode, key, value, retval);
-	break;
-    }
+   switch (retcode) {
+   case -1:
+      printf("Bad magic = 0x%08lx:"
+             " key = %lu, expected = %lu, returned = %lu\n",
+             table->magic, key, value, retval);
+      break;
+   case 1:
+      printf("Not found: key = %lu, expected = %lu returned = %lu\n",
+             key, value, retval);
+      break;
+   case 0:
+      if (value != retval)
+         printf("Bad value: key = %lu, expected = %lu, returned = %lu\n",
+                key, value, retval);
+      break;
+   default:
+      printf("Bad retcode = %d: key = %lu, expected = %lu, returned = %lu\n",
+             retcode, key, value, retval);
+      break;
+   }
 }
 
-int main(void)
+int
+main(void)
 {
-    __glxHashTablePtr table;
-    int          i;
+   __glxHashTablePtr table;
+   int i;
 
-    printf("\n***** 256 consecutive integers ****\n");
-    table = __glxHashCreate();
-    for (i = 0; i < 256; i++) __glxHashInsert(table, i, i);
-    for (i = 0; i < 256; i++) check_table(table, i, i);
-    for (i = 256; i >= 0; i--) check_table(table, i, i);
-    compute_dist(table);
-    __glxHashDestroy(table);
+   printf("\n***** 256 consecutive integers ****\n");
+   table = __glxHashCreate();
+   for (i = 0; i < 256; i++)
+      __glxHashInsert(table, i, i);
+   for (i = 0; i < 256; i++)
+      check_table(table, i, i);
+   for (i = 256; i >= 0; i--)
+      check_table(table, i, i);
+   compute_dist(table);
+   __glxHashDestroy(table);
 
-    printf("\n***** 1024 consecutive integers ****\n");
-    table = __glxHashCreate();
-    for (i = 0; i < 1024; i++) __glxHashInsert(table, i, i);
-    for (i = 0; i < 1024; i++) check_table(table, i, i);
-    for (i = 1024; i >= 0; i--) check_table(table, i, i);
-    compute_dist(table);
-    __glxHashDestroy(table);
+   printf("\n***** 1024 consecutive integers ****\n");
+   table = __glxHashCreate();
+   for (i = 0; i < 1024; i++)
+      __glxHashInsert(table, i, i);
+   for (i = 0; i < 1024; i++)
+      check_table(table, i, i);
+   for (i = 1024; i >= 0; i--)
+      check_table(table, i, i);
+   compute_dist(table);
+   __glxHashDestroy(table);
 
-    printf("\n***** 1024 consecutive page addresses (4k pages) ****\n");
-    table = __glxHashCreate();
-    for (i = 0; i < 1024; i++) __glxHashInsert(table, i*4096, i);
-    for (i = 0; i < 1024; i++) check_table(table, i*4096, i);
-    for (i = 1024; i >= 0; i--) check_table(table, i*4096, i);
-    compute_dist(table);
-    __glxHashDestroy(table);
+   printf("\n***** 1024 consecutive page addresses (4k pages) ****\n");
+   table = __glxHashCreate();
+   for (i = 0; i < 1024; i++)
+      __glxHashInsert(table, i * 4096, i);
+   for (i = 0; i < 1024; i++)
+      check_table(table, i * 4096, i);
+   for (i = 1024; i >= 0; i--)
+      check_table(table, i * 4096, i);
+   compute_dist(table);
+   __glxHashDestroy(table);
 
-    printf("\n***** 1024 random integers ****\n");
-    table = __glxHashCreate();
-    srandom(0xbeefbeef);
-    for (i = 0; i < 1024; i++) __glxHashInsert(table, random(), i);
-    srandom(0xbeefbeef);
-    for (i = 0; i < 1024; i++) check_table(table, random(), i);
-    srandom(0xbeefbeef);
-    for (i = 0; i < 1024; i++) check_table(table, random(), i);
-    compute_dist(table);
-    __glxHashDestroy(table);
+   printf("\n***** 1024 random integers ****\n");
+   table = __glxHashCreate();
+   srandom(0xbeefbeef);
+   for (i = 0; i < 1024; i++)
+      __glxHashInsert(table, random(), i);
+   srandom(0xbeefbeef);
+   for (i = 0; i < 1024; i++)
+      check_table(table, random(), i);
+   srandom(0xbeefbeef);
+   for (i = 0; i < 1024; i++)
+      check_table(table, random(), i);
+   compute_dist(table);
+   __glxHashDestroy(table);
 
-    printf("\n***** 5000 random integers ****\n");
-    table = __glxHashCreate();
-    srandom(0xbeefbeef);
-    for (i = 0; i < 5000; i++) __glxHashInsert(table, random(), i);
-    srandom(0xbeefbeef);
-    for (i = 0; i < 5000; i++) check_table(table, random(), i);
-    srandom(0xbeefbeef);
-    for (i = 0; i < 5000; i++) check_table(table, random(), i);
-    compute_dist(table);
-    __glxHashDestroy(table);
+   printf("\n***** 5000 random integers ****\n");
+   table = __glxHashCreate();
+   srandom(0xbeefbeef);
+   for (i = 0; i < 5000; i++)
+      __glxHashInsert(table, random(), i);
+   srandom(0xbeefbeef);
+   for (i = 0; i < 5000; i++)
+      check_table(table, random(), i);
+   srandom(0xbeefbeef);
+   for (i = 0; i < 5000; i++)
+      check_table(table, random(), i);
+   compute_dist(table);
+   __glxHashDestroy(table);
 
-    return 0;
+   return 0;
 }
 #endif

Modified: AppleSGLX/trunk/glxhash.h
===================================================================
--- AppleSGLX/trunk/glxhash.h	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/glxhash.h	2009-12-21 20:56:26 UTC (rev 386)
@@ -6,11 +6,15 @@
 
 /* Hash table routines */
 extern __glxHashTable *__glxHashCreate(void);
-extern int  __glxHashDestroy(__glxHashTable *t);
-extern int  __glxHashLookup(__glxHashTable *t, unsigned long key, void **value);
-extern int  __glxHashInsert(__glxHashTable *t, unsigned long key, void *value);
-extern int  __glxHashDelete(__glxHashTable *t, unsigned long key);
-extern int  __glxHashFirst(__glxHashTable *t, unsigned long *key, void **value);
-extern int  __glxHashNext(__glxHashTable *t, unsigned long *key, void **value);
+extern int __glxHashDestroy(__glxHashTable * t);
+extern int __glxHashLookup(__glxHashTable * t, unsigned long key,
+                           void **value);
+extern int __glxHashInsert(__glxHashTable * t, unsigned long key,
+                           void *value);
+extern int __glxHashDelete(__glxHashTable * t, unsigned long key);
+extern int __glxHashFirst(__glxHashTable * t, unsigned long *key,
+                          void **value);
+extern int __glxHashNext(__glxHashTable * t, unsigned long *key,
+                         void **value);
 
 #endif /* _GLX_HASH_H_ */

Modified: AppleSGLX/trunk/glxreply.c
===================================================================
--- AppleSGLX/trunk/glxreply.c	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/glxreply.c	2009-12-21 20:56:26 UTC (rev 386)
@@ -28,98 +28,107 @@
 #include "glxclient.h"
 #include <GL/glxproto.h>
 
-CARD32 __glXReadReply(Display * dpy, size_t size, void *dest,
-		      GLboolean reply_is_always_array) {
-    xGLXSingleReply reply;
-    
-    (void) _XReply(dpy, (xReply *) & reply, 0, False);
-    if (size != 0) {
-        if ((reply.length > 0) || reply_is_always_array) {
-            const GLint bytes = (reply_is_always_array)
-                ? (4 * reply.length) : (reply.size * size);
-            const GLint extra = 4 - (bytes & 3);
+CARD32
+__glXReadReply(Display * dpy, size_t size, void *dest,
+               GLboolean reply_is_always_array)
+{
+   xGLXSingleReply reply;
 
-            _XRead(dpy, dest, bytes);
-            if (extra < 4) {
-                _XEatData(dpy, extra);
-            }
-        } else {
-            (void) memcpy(dest, &(reply.pad3), size);
-        }
-    }
+   (void) _XReply(dpy, (xReply *) & reply, 0, False);
+   if (size != 0) {
+      if ((reply.length > 0) || reply_is_always_array) {
+         const GLint bytes = (reply_is_always_array)
+            ? (4 * reply.length) : (reply.size * size);
+         const GLint extra = 4 - (bytes & 3);
 
-    return reply.retval;
+         _XRead(dpy, dest, bytes);
+         if (extra < 4) {
+            _XEatData(dpy, extra);
+         }
+      }
+      else {
+         (void) memcpy(dest, &(reply.pad3), size);
+      }
+   }
+
+   return reply.retval;
 }
 
-void __glXReadPixelReply(Display * dpy, __GLXcontext * gc, unsigned max_dim,
+void
+__glXReadPixelReply(Display * dpy, __GLXcontext * gc, unsigned max_dim,
                     GLint width, GLint height, GLint depth, GLenum format,
-                    GLenum type, void *dest, GLboolean dimensions_in_reply) {
-    xGLXSingleReply reply;
-    GLint size;
+                    GLenum type, void *dest, GLboolean dimensions_in_reply)
+{
+   xGLXSingleReply reply;
+   GLint size;
 
-    (void) _XReply(dpy, (xReply *) & reply, 0, False);
+   (void) _XReply(dpy, (xReply *) & reply, 0, False);
 
-    if (dimensions_in_reply) {
-        width = reply.pad3;
-        height = reply.pad4;
-        depth = reply.pad5;
+   if (dimensions_in_reply) {
+      width = reply.pad3;
+      height = reply.pad4;
+      depth = reply.pad5;
 
-        if ((height == 0) || (max_dim < 2)) {
-            height = 1;
-        }
-        if ((depth == 0) || (max_dim < 3)) {
-            depth = 1;
-        }
-    }
+      if ((height == 0) || (max_dim < 2)) {
+         height = 1;
+      }
+      if ((depth == 0) || (max_dim < 3)) {
+         depth = 1;
+      }
+   }
 
-    size = reply.length * 4;
-    if (size != 0) {
-        void *buf = Xmalloc(size);
+   size = reply.length * 4;
+   if (size != 0) {
+      void *buf = Xmalloc(size);
 
-        if (buf == NULL) {
-            _XEatData(dpy, size);
-            __glXSetError(gc, GL_OUT_OF_MEMORY);
-        } else {
-            const GLint extra = 4 - (size & 3);
+      if (buf == NULL) {
+         _XEatData(dpy, size);
+         __glXSetError(gc, GL_OUT_OF_MEMORY);
+      }
+      else {
+         const GLint extra = 4 - (size & 3);
 
-            _XRead(dpy, buf, size);
-            if (extra < 4) {
-                _XEatData(dpy, extra);
-            }
+         _XRead(dpy, buf, size);
+         if (extra < 4) {
+            _XEatData(dpy, extra);
+         }
 
-            __glEmptyImage(gc, 3, width, height, depth, format, type,
-                           buf, dest);
-            Xfree(buf);
-        }
-    }
+         __glEmptyImage(gc, 3, width, height, depth, format, type, buf, dest);
+         Xfree(buf);
+      }
+   }
 }
 
 #if 0
-GLubyte * __glXSetupSingleRequest(__GLXcontext * gc, GLint sop, GLint cmdlen) {
-    xGLXSingleReq *req;
-    Display *const dpy = gc->currentDpy;
+GLubyte *
+__glXSetupSingleRequest(__GLXcontext * gc, GLint sop, GLint cmdlen)
+{
+   xGLXSingleReq *req;
+   Display *const dpy = gc->currentDpy;
 
-    (void) __glXFlushRenderBuffer(gc, gc->pc);
-    LockDisplay(dpy);
-    GetReqExtra(GLXSingle, cmdlen, req);
-    req->reqType = gc->majorOpcode;
-    req->contextTag = gc->currentContextTag;
-    req->glxCode = sop;
-    return (GLubyte *) (req) + sz_xGLXSingleReq;
+   (void) __glXFlushRenderBuffer(gc, gc->pc);
+   LockDisplay(dpy);
+   GetReqExtra(GLXSingle, cmdlen, req);
+   req->reqType = gc->majorOpcode;
+   req->contextTag = gc->currentContextTag;
+   req->glxCode = sop;
+   return (GLubyte *) (req) + sz_xGLXSingleReq;
 }
 #endif
 
-GLubyte *__glXSetupVendorRequest(__GLXcontext * gc, GLint code, GLint vop,
-                        GLint cmdlen) {
-    xGLXVendorPrivateReq *req;
-    Display *const dpy = gc->currentDpy;
+GLubyte *
+__glXSetupVendorRequest(__GLXcontext * gc, GLint code, GLint vop,
+                        GLint cmdlen)
+{
+   xGLXVendorPrivateReq *req;
+   Display *const dpy = gc->currentDpy;
 
-    (void) __glXFlushRenderBuffer(gc, gc->pc);
-    LockDisplay(dpy);
-    GetReqExtra(GLXVendorPrivate, cmdlen, req);
-    req->reqType = gc->majorOpcode;
-    req->glxCode = code;
-    req->vendorCode = vop;
-    req->contextTag = gc->currentContextTag;
-    return (GLubyte *) (req) + sz_xGLXVendorPrivateReq;
+   (void) __glXFlushRenderBuffer(gc, gc->pc);
+   LockDisplay(dpy);
+   GetReqExtra(GLXVendorPrivate, cmdlen, req);
+   req->reqType = gc->majorOpcode;
+   req->glxCode = code;
+   req->vendorCode = vop;
+   req->contextTag = gc->currentContextTag;
+   return (GLubyte *) (req) + sz_xGLXVendorPrivateReq;
 }

Modified: AppleSGLX/trunk/include/GL/internal/glcore.h
===================================================================
--- AppleSGLX/trunk/include/GL/internal/glcore.h	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/include/GL/internal/glcore.h	2009-12-21 20:56:26 UTC (rev 386)
@@ -139,6 +139,10 @@
     GLint bindToMipmapTexture;
     GLint bindToTextureTargets;
     GLint yInverted;
+
+#ifdef __APPLE__
+    void *apple;
+#endif
 } __GLcontextModes;
 
 /* Several fields of __GLcontextModes can take these as values.  Since

Modified: AppleSGLX/trunk/packrender.h
===================================================================
--- AppleSGLX/trunk/packrender.h	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/packrender.h	2009-12-21 20:56:26 UTC (rev 386)
@@ -184,8 +184,8 @@
 #define __GLX_PUT_DOUBLE(offset,a) \
     gl_put_double(pc + offset, a)
 
-extern void gl_put_float(/*GLubyte *, struct cray_single*/);
-extern void gl_put_double(/*GLubyte *, struct cray_double*/);
+extern void gl_put_float( /*GLubyte *, struct cray_single */ );
+extern void gl_put_double( /*GLubyte *, struct cray_double */ );
 #endif
 
 #ifndef _CRAY
@@ -233,10 +233,10 @@
 #define __GLX_PUT_DOUBLE_ARRAY(offset,a,alen) \
     gl_put_double_array((GLubyte *)(pc + offset), (double *)a, alen * __GLX_SIZE_FLOAT64)
 
-extern gl_put_short_array (GLubyte *, short *, int);
-extern gl_put_long_array (GLubyte *, long *, int);
-extern gl_put_float_array (GLubyte *, float *, int);
-extern gl_put_double_array (GLubyte *, double *, int);
+extern gl_put_short_array(GLubyte *, short *, int);
+extern gl_put_long_array(GLubyte *, long *, int);
+extern gl_put_float_array(GLubyte *, float *, int);
+extern gl_put_double_array(GLubyte *, double *, int);
 
 #endif /* _CRAY */
 

Modified: AppleSGLX/trunk/packsingle.h
===================================================================
--- AppleSGLX/trunk/packsingle.h	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/packsingle.h	2009-12-21 20:56:26 UTC (rev 386)
@@ -165,7 +165,7 @@
 #endif
 
 #endif
-	  
+
 /* Get an array of typed data */
 #define __GLX_SINGLE_GET_VOID_ARRAY(a,alen)	\
 {						\
@@ -180,8 +180,8 @@
     _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT8);	\
     if (slop) _XEatData(dpy,4-slop);		\
 }
-					
 
+
 #define __GLX_SINGLE_GET_SHORT_ARRAY(a,alen)	\
 {						\
     GLint slop = (alen*__GLX_SIZE_INT16) & 3;	\
@@ -190,14 +190,14 @@
 }
 
 #define __GLX_SINGLE_GET_LONG_ARRAY(a,alen) \
-    _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT32);  	
+    _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT32);
 
 #ifndef _CRAY
 #define __GLX_SINGLE_GET_FLOAT_ARRAY(a,alen) \
-    _XRead(dpy,(char *)a,alen*__GLX_SIZE_FLOAT32);  	
+    _XRead(dpy,(char *)a,alen*__GLX_SIZE_FLOAT32);
 
 #define __GLX_SINGLE_GET_DOUBLE_ARRAY(a,alen) \
-    _XRead(dpy,(char *)a,alen*__GLX_SIZE_FLOAT64);  	
+    _XRead(dpy,(char *)a,alen*__GLX_SIZE_FLOAT64);
 
 #else
 #define __GLX_SINGLE_GET_FLOAT_ARRAY(a,alen) \
@@ -206,8 +206,8 @@
 #define __GLX_SINGLE_GET_DOUBLE_ARRAY(a,alen) \
     gl_get_double_array(dpy, a, alen);
 
-extern void gl_get_float_array(Display *dpy, float *a, int alen);
-extern void gl_get_double_array(Display *dpy, double *a, int alen);
+extern void gl_get_float_array(Display * dpy, float *a, int alen);
+extern void gl_get_double_array(Display * dpy, double *a, int alen);
 #endif
 
 #endif /* !__GLX_packsingle_h__ */

Modified: AppleSGLX/trunk/pixel.c
===================================================================
--- AppleSGLX/trunk/pixel.c	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/pixel.c	2009-12-21 20:56:26 UTC (rev 386)
@@ -31,46 +31,46 @@
 #include "packrender.h"
 
 static const GLubyte MsbToLsbTable[256] = {
-    0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
-    0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
-    0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
-    0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
-    0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
-    0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
-    0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
-    0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
-    0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
-    0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
-    0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
-    0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
-    0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
-    0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
-    0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
-    0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
-    0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
-    0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
-    0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
-    0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
-    0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
-    0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
-    0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
-    0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
-    0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
-    0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
-    0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
-    0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
-    0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
-    0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
-    0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
-    0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff,
+   0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
+   0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
+   0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
+   0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
+   0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
+   0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
+   0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
+   0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
+   0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
+   0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
+   0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
+   0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
+   0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
+   0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
+   0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
+   0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
+   0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
+   0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
+   0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
+   0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
+   0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
+   0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
+   0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
+   0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
+   0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
+   0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
+   0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
+   0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
+   0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
+   0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
+   0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
+   0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff,
 };
 
 static const GLubyte LowBitsMask[9] = {
-    0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff,
+   0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff,
 };
 
 static const GLubyte HighBitsMask[9] = {
-    0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff,
+   0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff,
 };
 
 
@@ -79,76 +79,80 @@
 ** data is transfered into the destImage buffer.  Return in modes the
 ** set of pixel modes that are to be done by the server.
 */
-static void FillBitmap(__GLXcontext *gc, GLint width, GLint height,
-		       GLenum format, const GLvoid *userdata,
-		       GLubyte *destImage)
+static void
+FillBitmap(__GLXcontext * gc, GLint width, GLint height,
+           GLenum format, const GLvoid * userdata, GLubyte * destImage)
 {
-    const __GLXattribute * state = gc->client_state_private;
-    GLint rowLength = state->storeUnpack.rowLength;
-    GLint alignment = state->storeUnpack.alignment;
-    GLint skipPixels = state->storeUnpack.skipPixels;
-    GLint skipRows = state->storeUnpack.skipRows;
-    GLint lsbFirst = state->storeUnpack.lsbFirst;
-    GLint elementsLeft, bitOffset, currentByte, nextByte, highBitMask;
-    GLint lowBitMask, i;
-    GLint components, groupsPerRow, rowSize, padding, elementsPerRow;
-    const GLubyte *start, *iter;
+   const __GLXattribute *state = gc->client_state_private;
+   GLint rowLength = state->storeUnpack.rowLength;
+   GLint alignment = state->storeUnpack.alignment;
+   GLint skipPixels = state->storeUnpack.skipPixels;
+   GLint skipRows = state->storeUnpack.skipRows;
+   GLint lsbFirst = state->storeUnpack.lsbFirst;
+   GLint elementsLeft, bitOffset, currentByte, nextByte, highBitMask;
+   GLint lowBitMask, i;
+   GLint components, groupsPerRow, rowSize, padding, elementsPerRow;
+   const GLubyte *start, *iter;
 
-    if (rowLength > 0) {
-	groupsPerRow = rowLength;
-    } else {
-	groupsPerRow = width;
-    }
-    components = __glElementsPerGroup(format,GL_BITMAP);
-    rowSize = (groupsPerRow * components + 7) >> 3;
-    padding = (rowSize % alignment);
-    if (padding) {
-	rowSize += alignment - padding;
-    }
-    start = ((const GLubyte*) userdata) + skipRows * rowSize + 
-	((skipPixels * components) >> 3);
-    bitOffset = (skipPixels * components) & 7;
-    highBitMask = LowBitsMask[8-bitOffset];
-    lowBitMask = HighBitsMask[bitOffset];
-    elementsPerRow = width * components;
-    for (i = 0; i < height; i++) {
-	elementsLeft = elementsPerRow;
-	iter = start;
-	while (elementsLeft) {
-	    /* First retrieve low bits from current byte */
-	    if (lsbFirst) {
-		currentByte = MsbToLsbTable[iter[0]];
-	    } else {
-		currentByte = iter[0];
-	    }
-	    if (bitOffset) {
-		/* Need to read next byte to finish current byte */
-		if (elementsLeft > (8 - bitOffset)) {
-		    if (lsbFirst) {
-			nextByte = MsbToLsbTable[iter[1]];
-		    } else {
-			nextByte = iter[1];
-		    }
-		    currentByte = 
-			((currentByte & highBitMask) << bitOffset) |
-			    ((nextByte & lowBitMask) >> (8 - bitOffset));
-		} else {
-		    currentByte = 
-			((currentByte & highBitMask) << bitOffset);
-		}
-	    } 
-	    if (elementsLeft >= 8) {
-		*destImage = currentByte;
-		elementsLeft -= 8;
-	    } else {
-		*destImage = currentByte & HighBitsMask[elementsLeft];
-		elementsLeft = 0;
-	    }
-	    destImage++;
-	    iter++;
-	}
-	start += rowSize;
-    }
+   if (rowLength > 0) {
+      groupsPerRow = rowLength;
+   }
+   else {
+      groupsPerRow = width;
+   }
+   components = __glElementsPerGroup(format, GL_BITMAP);
+   rowSize = (groupsPerRow * components + 7) >> 3;
+   padding = (rowSize % alignment);
+   if (padding) {
+      rowSize += alignment - padding;
+   }
+   start = ((const GLubyte *) userdata) + skipRows * rowSize +
+      ((skipPixels * components) >> 3);
+   bitOffset = (skipPixels * components) & 7;
+   highBitMask = LowBitsMask[8 - bitOffset];
+   lowBitMask = HighBitsMask[bitOffset];
+   elementsPerRow = width * components;
+   for (i = 0; i < height; i++) {
+      elementsLeft = elementsPerRow;
+      iter = start;
+      while (elementsLeft) {
+         /* First retrieve low bits from current byte */
+         if (lsbFirst) {
+            currentByte = MsbToLsbTable[iter[0]];
+         }
+         else {
+            currentByte = iter[0];
+         }
+         if (bitOffset) {
+            /* Need to read next byte to finish current byte */
+            if (elementsLeft > (8 - bitOffset)) {
+               if (lsbFirst) {
+                  nextByte = MsbToLsbTable[iter[1]];
+               }
+               else {
+                  nextByte = iter[1];
+               }
+               currentByte =
+                  ((currentByte & highBitMask) << bitOffset) |
+                  ((nextByte & lowBitMask) >> (8 - bitOffset));
+            }
+            else {
+               currentByte = ((currentByte & highBitMask) << bitOffset);
+            }
+         }
+         if (elementsLeft >= 8) {
+            *destImage = currentByte;
+            elementsLeft -= 8;
+         }
+         else {
+            *destImage = currentByte & HighBitsMask[elementsLeft];
+            elementsLeft = 0;
+         }
+         destImage++;
+         iter++;
+      }
+      start += rowSize;
+   }
 }
 
 /*
@@ -156,209 +160,224 @@
 ** The internal packed array format used has LSB_FIRST = FALSE and 
 ** ALIGNMENT = 1.
 */
-void __glFillImage(__GLXcontext *gc, GLint dim, GLint width, GLint height,
-		   GLint depth, GLenum format, GLenum type,
-		   const GLvoid *userdata, GLubyte *newimage, GLubyte *modes)
+void
+__glFillImage(__GLXcontext * gc, GLint dim, GLint width, GLint height,
+              GLint depth, GLenum format, GLenum type,
+              const GLvoid * userdata, GLubyte * newimage, GLubyte * modes)
 {
-    const __GLXattribute * state = gc->client_state_private;
-    GLint rowLength = state->storeUnpack.rowLength;
-    GLint imageHeight = state->storeUnpack.imageHeight;
-    GLint alignment = state->storeUnpack.alignment;
-    GLint skipPixels = state->storeUnpack.skipPixels;
-    GLint skipRows = state->storeUnpack.skipRows;
-    GLint skipImages = state->storeUnpack.skipImages;
-    GLint swapBytes = state->storeUnpack.swapEndian;
-    GLint components, elementSize, rowSize, padding, groupsPerRow, groupSize;
-    GLint elementsPerRow, imageSize, rowsPerImage, h, i, j, k;
-    const GLubyte *start, *iter, *itera, *iterb, *iterc;
-    GLubyte *iter2;
+   const __GLXattribute *state = gc->client_state_private;
+   GLint rowLength = state->storeUnpack.rowLength;
+   GLint imageHeight = state->storeUnpack.imageHeight;
+   GLint alignment = state->storeUnpack.alignment;
+   GLint skipPixels = state->storeUnpack.skipPixels;
+   GLint skipRows = state->storeUnpack.skipRows;
+   GLint skipImages = state->storeUnpack.skipImages;
+   GLint swapBytes = state->storeUnpack.swapEndian;
+   GLint components, elementSize, rowSize, padding, groupsPerRow, groupSize;
+   GLint elementsPerRow, imageSize, rowsPerImage, h, i, j, k;
+   const GLubyte *start, *iter, *itera, *iterb, *iterc;
+   GLubyte *iter2;
 
-    if (type == GL_BITMAP) {
-	FillBitmap(gc, width, height, format, userdata, newimage);
-    } else {
-	components = __glElementsPerGroup(format,type);
-	if (rowLength > 0) {
-	    groupsPerRow = rowLength;
-	} else {
-	    groupsPerRow = width;
-	}
-	if (imageHeight > 0) {
-	    rowsPerImage = imageHeight;
-	} else {
-	    rowsPerImage = height;
-	}
+   if (type == GL_BITMAP) {
+      FillBitmap(gc, width, height, format, userdata, newimage);
+   }
+   else {
+      components = __glElementsPerGroup(format, type);
+      if (rowLength > 0) {
+         groupsPerRow = rowLength;
+      }
+      else {
+         groupsPerRow = width;
+      }
+      if (imageHeight > 0) {
+         rowsPerImage = imageHeight;
+      }
+      else {
+         rowsPerImage = height;
+      }
 
-	elementSize = __glBytesPerElement(type);
-	groupSize = elementSize * components;
-	if (elementSize == 1) swapBytes = 0;
+      elementSize = __glBytesPerElement(type);
+      groupSize = elementSize * components;
+      if (elementSize == 1)
+         swapBytes = 0;
 
-	rowSize = groupsPerRow * groupSize;
-	padding = (rowSize % alignment);
-	if (padding) {
-	    rowSize += alignment - padding;
-	}
-	imageSize = rowSize * rowsPerImage;
-	start = ((const GLubyte*) userdata) + skipImages * imageSize +
-		skipRows * rowSize + skipPixels * groupSize;
-	iter2 = newimage;
-	elementsPerRow = width * components;
+      rowSize = groupsPerRow * groupSize;
+      padding = (rowSize % alignment);
+      if (padding) {
+         rowSize += alignment - padding;
+      }
+      imageSize = rowSize * rowsPerImage;
+      start = ((const GLubyte *) userdata) + skipImages * imageSize +
+         skipRows * rowSize + skipPixels * groupSize;
+      iter2 = newimage;
+      elementsPerRow = width * components;
 
-	if (swapBytes) {
-	    itera = start;
-	    for (h = 0; h < depth; h++) {
-		iterb = itera;
-		for (i = 0; i < height; i++) {
-		    iterc = iterb;
-		    for (j = 0; j < elementsPerRow; j++) {
-			for (k = 1; k <= elementSize; k++) {
-			    iter2[k-1] = iterc[elementSize - k];
-			}
-			iter2 += elementSize;
-			iterc += elementSize;
-		    }
-		    iterb += rowSize;
-		}
-		itera += imageSize;
-	    }
-	} else {
-	    itera = start;
-	    for (h = 0; h < depth; h++) {
-		if (rowSize == elementsPerRow * elementSize) {
-		    /* Ha!  This is mondo easy! */
-		    __GLX_MEM_COPY(iter2, itera,
-				   elementsPerRow * elementSize * height);
-		    iter2 += elementsPerRow * elementSize * height;
-		} else {
-		    iter = itera;
-		    for (i = 0; i < height; i++) {
-			__GLX_MEM_COPY(iter2, iter, elementsPerRow*elementSize);
-			iter2 += elementsPerRow * elementSize;
-			iter += rowSize;
-		    }
-		}
-		itera += imageSize;
-	    }    
-	}
-    }
+      if (swapBytes) {
+         itera = start;
+         for (h = 0; h < depth; h++) {
+            iterb = itera;
+            for (i = 0; i < height; i++) {
+               iterc = iterb;
+               for (j = 0; j < elementsPerRow; j++) {
+                  for (k = 1; k <= elementSize; k++) {
+                     iter2[k - 1] = iterc[elementSize - k];
+                  }
+                  iter2 += elementSize;
+                  iterc += elementSize;
+               }
+               iterb += rowSize;
+            }
+            itera += imageSize;
+         }
+      }
+      else {
+         itera = start;
+         for (h = 0; h < depth; h++) {
+            if (rowSize == elementsPerRow * elementSize) {
+               /* Ha!  This is mondo easy! */
+               __GLX_MEM_COPY(iter2, itera,
+                              elementsPerRow * elementSize * height);
+               iter2 += elementsPerRow * elementSize * height;
+            }
+            else {
+               iter = itera;
+               for (i = 0; i < height; i++) {
+                  __GLX_MEM_COPY(iter2, iter, elementsPerRow * elementSize);
+                  iter2 += elementsPerRow * elementSize;
+                  iter += rowSize;
+               }
+            }
+            itera += imageSize;
+         }
+      }
+   }
 
-    /* Setup store modes that describe what we just did */
-    if (modes) {
-       if ( dim < 3 ) {
-	  (void) memcpy( modes, __glXDefaultPixelStore + 4, 20 );
-       }
-       else {
-	  (void) memcpy( modes, __glXDefaultPixelStore + 0, 36 );
-       }
-    }
+   /* Setup store modes that describe what we just did */
+   if (modes) {
+      if (dim < 3) {
+         (void) memcpy(modes, __glXDefaultPixelStore + 4, 20);
+      }
+      else {
+         (void) memcpy(modes, __glXDefaultPixelStore + 0, 36);
+      }
+   }
 }
 
 /*
 ** Empty a bitmap in LSB_FIRST=GL_FALSE and ALIGNMENT=4 format packing it
 ** into the clients memory using the pixel store PACK modes.
 */
-static void EmptyBitmap(__GLXcontext *gc, GLint width, GLint height,
-			GLenum format, const GLubyte *sourceImage,
-			GLvoid *userdata)
+static void
+EmptyBitmap(__GLXcontext * gc, GLint width, GLint height,
+            GLenum format, const GLubyte * sourceImage, GLvoid * userdata)
 {
-    const __GLXattribute * state = gc->client_state_private;
-    GLint rowLength = state->storePack.rowLength;
-    GLint alignment = state->storePack.alignment;
-    GLint skipPixels = state->storePack.skipPixels;
-    GLint skipRows = state->storePack.skipRows;
-    GLint lsbFirst = state->storePack.lsbFirst;
-    GLint components, groupsPerRow, rowSize, padding, elementsPerRow;
-    GLint sourceRowSize, sourcePadding, sourceSkip;
-    GLubyte *start, *iter;
-    GLint elementsLeft, bitOffset, currentByte, highBitMask, lowBitMask;
-    GLint writeMask, i;
-    GLubyte writeByte;
+   const __GLXattribute *state = gc->client_state_private;
+   GLint rowLength = state->storePack.rowLength;
+   GLint alignment = state->storePack.alignment;
+   GLint skipPixels = state->storePack.skipPixels;
+   GLint skipRows = state->storePack.skipRows;
+   GLint lsbFirst = state->storePack.lsbFirst;
+   GLint components, groupsPerRow, rowSize, padding, elementsPerRow;
+   GLint sourceRowSize, sourcePadding, sourceSkip;
+   GLubyte *start, *iter;
+   GLint elementsLeft, bitOffset, currentByte, highBitMask, lowBitMask;
+   GLint writeMask, i;
+   GLubyte writeByte;
 
-    components = __glElementsPerGroup(format,GL_BITMAP);
-    if (rowLength > 0) {
-	groupsPerRow = rowLength;
-    } else {
-	groupsPerRow = width;
-    }
+   components = __glElementsPerGroup(format, GL_BITMAP);
+   if (rowLength > 0) {
+      groupsPerRow = rowLength;
+   }
+   else {
+      groupsPerRow = width;
+   }
 
-    rowSize = (groupsPerRow * components + 7) >> 3;
-    padding = (rowSize % alignment);
-    if (padding) {
-	rowSize += alignment - padding;
-    }
-    sourceRowSize = (width * components + 7) >> 3;
-    sourcePadding = (sourceRowSize % 4);
-    if (sourcePadding) {
-	sourceSkip = 4 - sourcePadding;
-    } else {
-	sourceSkip = 0;
-    }
-    start = ((GLubyte*) userdata) + skipRows * rowSize + 
-	((skipPixels * components) >> 3);
-    bitOffset = (skipPixels * components) & 7;
-    highBitMask = LowBitsMask[8-bitOffset];
-    lowBitMask = HighBitsMask[bitOffset];
-    elementsPerRow = width * components;
-    for (i = 0; i < height; i++) {
-	elementsLeft = elementsPerRow;
-	iter = start;
-	writeMask = highBitMask;
-	writeByte = 0;
-	while (elementsLeft) {
-	    /* Set up writeMask (to write to current byte) */
-	    if (elementsLeft + bitOffset < 8) {
-		/* Need to trim writeMask */
-		writeMask &= HighBitsMask[bitOffset+elementsLeft];
-	    }
+   rowSize = (groupsPerRow * components + 7) >> 3;
+   padding = (rowSize % alignment);
+   if (padding) {
+      rowSize += alignment - padding;
+   }
+   sourceRowSize = (width * components + 7) >> 3;
+   sourcePadding = (sourceRowSize % 4);
+   if (sourcePadding) {
+      sourceSkip = 4 - sourcePadding;
+   }
+   else {
+      sourceSkip = 0;
+   }
+   start = ((GLubyte *) userdata) + skipRows * rowSize +
+      ((skipPixels * components) >> 3);
+   bitOffset = (skipPixels * components) & 7;
+   highBitMask = LowBitsMask[8 - bitOffset];
+   lowBitMask = HighBitsMask[bitOffset];
+   elementsPerRow = width * components;
+   for (i = 0; i < height; i++) {
+      elementsLeft = elementsPerRow;
+      iter = start;
+      writeMask = highBitMask;
+      writeByte = 0;
+      while (elementsLeft) {
+         /* Set up writeMask (to write to current byte) */
+         if (elementsLeft + bitOffset < 8) {
+            /* Need to trim writeMask */
+            writeMask &= HighBitsMask[bitOffset + elementsLeft];
+         }
 
-	    if (lsbFirst) {
-		currentByte = MsbToLsbTable[iter[0]];
-	    } else {
-		currentByte = iter[0];
-	    }
+         if (lsbFirst) {
+            currentByte = MsbToLsbTable[iter[0]];
+         }
+         else {
+            currentByte = iter[0];
+         }
 
-	    if (bitOffset) {
-		writeByte |= (sourceImage[0] >> bitOffset);
-		currentByte = (currentByte & ~writeMask) | 
-		    (writeByte & writeMask);
-		writeByte = (sourceImage[0] << (8 - bitOffset));
-	    } else {
-		currentByte = (currentByte & ~writeMask) |
-		    (sourceImage[0] & writeMask);
-	    }
+         if (bitOffset) {
+            writeByte |= (sourceImage[0] >> bitOffset);
+            currentByte = (currentByte & ~writeMask) |
+               (writeByte & writeMask);
+            writeByte = (sourceImage[0] << (8 - bitOffset));
+         }
+         else {
+            currentByte = (currentByte & ~writeMask) |
+               (sourceImage[0] & writeMask);
+         }
 
-	    if (lsbFirst) {
-		iter[0] = MsbToLsbTable[currentByte];
-	    } else {
-		iter[0] = currentByte;
-	    }
+         if (lsbFirst) {
+            iter[0] = MsbToLsbTable[currentByte];
+         }
+         else {
+            iter[0] = currentByte;
+         }
 
-	    if (elementsLeft >= 8) {
-		elementsLeft -= 8;
-	    } else {
-		elementsLeft = 0;
-	    }
-	    sourceImage++;
-	    iter++;
-	    writeMask = 0xff;
-	}
-	if (writeByte) {
-	    /* Some data left over that still needs writing */
-	    writeMask &= lowBitMask;
-	    if (lsbFirst) {
-		currentByte = MsbToLsbTable[iter[0]];
-	    } else {
-		currentByte = iter[0];
-	    }
-	    currentByte = (currentByte & ~writeMask) | (writeByte & writeMask);
-	    if (lsbFirst) {
-		iter[0] = MsbToLsbTable[currentByte];
-	    } else {
-		iter[0] = currentByte;
-	    }
-	}
-	start += rowSize;
-	sourceImage += sourceSkip;
-    }
+         if (elementsLeft >= 8) {
+            elementsLeft -= 8;
+         }
+         else {
+            elementsLeft = 0;
+         }
+         sourceImage++;
+         iter++;
+         writeMask = 0xff;
+      }
+      if (writeByte) {
+         /* Some data left over that still needs writing */
+         writeMask &= lowBitMask;
+         if (lsbFirst) {
+            currentByte = MsbToLsbTable[iter[0]];
+         }
+         else {
+            currentByte = iter[0];
+         }
+         currentByte = (currentByte & ~writeMask) | (writeByte & writeMask);
+         if (lsbFirst) {
+            iter[0] = MsbToLsbTable[currentByte];
+         }
+         else {
+            iter[0] = currentByte;
+         }
+      }
+      start += rowSize;
+      sourceImage += sourceSkip;
+   }
 }
 
 /*
@@ -368,70 +387,75 @@
 ** Named __glEmptyImage() because it is the opposite of __glFillImage().
 */
 /* ARGSUSED */
-void __glEmptyImage(__GLXcontext *gc, GLint dim, GLint width, GLint height, 
-		    GLint depth, GLenum format, GLenum type,
-		    const GLubyte *sourceImage, GLvoid *userdata)
+void
+__glEmptyImage(__GLXcontext * gc, GLint dim, GLint width, GLint height,
+               GLint depth, GLenum format, GLenum type,
+               const GLubyte * sourceImage, GLvoid * userdata)
 {
-    const __GLXattribute * state = gc->client_state_private;
-    GLint rowLength = state->storePack.rowLength;
-    GLint imageHeight = state->storePack.imageHeight;
-    GLint alignment = state->storePack.alignment;
-    GLint skipPixels = state->storePack.skipPixels;
-    GLint skipRows = state->storePack.skipRows;
-    GLint skipImages = state->storePack.skipImages;
-    GLint components, elementSize, rowSize, padding, groupsPerRow, groupSize;
-    GLint elementsPerRow, sourceRowSize, sourcePadding, h, i;
-    GLint imageSize, rowsPerImage;
-    GLubyte *start, *iter, *itera;
+   const __GLXattribute *state = gc->client_state_private;
+   GLint rowLength = state->storePack.rowLength;
+   GLint imageHeight = state->storePack.imageHeight;
+   GLint alignment = state->storePack.alignment;
+   GLint skipPixels = state->storePack.skipPixels;
+   GLint skipRows = state->storePack.skipRows;
+   GLint skipImages = state->storePack.skipImages;
+   GLint components, elementSize, rowSize, padding, groupsPerRow, groupSize;
+   GLint elementsPerRow, sourceRowSize, sourcePadding, h, i;
+   GLint imageSize, rowsPerImage;
+   GLubyte *start, *iter, *itera;
 
-    if (type == GL_BITMAP) {
-	EmptyBitmap(gc, width, height, format, sourceImage, userdata);
-    } else {
-	components = __glElementsPerGroup(format,type);
-	if (rowLength > 0) {
-	    groupsPerRow = rowLength;
-	} else {
-	    groupsPerRow = width;
-	}
-	if (imageHeight > 0) {
-	    rowsPerImage = imageHeight;
-	} else {
-	    rowsPerImage = height;
-	}
-	elementSize = __glBytesPerElement(type);
-	groupSize = elementSize * components;
-	rowSize = groupsPerRow * groupSize;
-	padding = (rowSize % alignment);
-	if (padding) {
-	    rowSize += alignment - padding;
-	}
-	sourceRowSize = width * groupSize;
-	sourcePadding = (sourceRowSize % 4);
-	if (sourcePadding) {
-	    sourceRowSize += 4 - sourcePadding;
-	}
-	imageSize = sourceRowSize * rowsPerImage;
-	start = ((GLubyte*) userdata) + skipImages * imageSize +
-		skipRows * rowSize + skipPixels * groupSize;
-	elementsPerRow = width * components;
+   if (type == GL_BITMAP) {
+      EmptyBitmap(gc, width, height, format, sourceImage, userdata);
+   }
+   else {
+      components = __glElementsPerGroup(format, type);
+      if (rowLength > 0) {
+         groupsPerRow = rowLength;
+      }
+      else {
+         groupsPerRow = width;
+      }
+      if (imageHeight > 0) {
+         rowsPerImage = imageHeight;
+      }
+      else {
+         rowsPerImage = height;
+      }
+      elementSize = __glBytesPerElement(type);
+      groupSize = elementSize * components;
+      rowSize = groupsPerRow * groupSize;
+      padding = (rowSize % alignment);
+      if (padding) {
+         rowSize += alignment - padding;
+      }
+      sourceRowSize = width * groupSize;
+      sourcePadding = (sourceRowSize % 4);
+      if (sourcePadding) {
+         sourceRowSize += 4 - sourcePadding;
+      }
+      imageSize = sourceRowSize * rowsPerImage;
+      start = ((GLubyte *) userdata) + skipImages * imageSize +
+         skipRows * rowSize + skipPixels * groupSize;
+      elementsPerRow = width * components;
 
-	itera = start;
-	for (h = 0; h < depth; h++) {
-	    if ((rowSize == sourceRowSize) && (sourcePadding == 0)) {
-		/* Ha!  This is mondo easy! */
-		__GLX_MEM_COPY(itera, sourceImage,
-			       elementsPerRow * elementSize * height);
-		sourceImage += elementsPerRow * elementSize * height;
-	    } else {
-		iter = itera;
-		for (i = 0; i < height; i++) {
-		    __GLX_MEM_COPY(iter, sourceImage,
-				   elementsPerRow * elementSize);
-		    sourceImage += sourceRowSize;
-		    iter += rowSize;
-		}
-	    }
-	    itera += imageSize;
-	}
-    }
+      itera = start;
+      for (h = 0; h < depth; h++) {
+         if ((rowSize == sourceRowSize) && (sourcePadding == 0)) {
+            /* Ha!  This is mondo easy! */
+            __GLX_MEM_COPY(itera, sourceImage,
+                           elementsPerRow * elementSize * height);
+            sourceImage += elementsPerRow * elementSize * height;
+         }
+         else {
+            iter = itera;
+            for (i = 0; i < height; i++) {
+               __GLX_MEM_COPY(iter, sourceImage,
+                              elementsPerRow * elementSize);
+               sourceImage += sourceRowSize;
+               iter += rowSize;
+            }
+         }
+         itera += imageSize;
+      }
+   }
 }

Modified: AppleSGLX/trunk/xfont.c
===================================================================
--- AppleSGLX/trunk/xfont.c	2009-12-21 20:27:02 UTC (rev 385)
+++ AppleSGLX/trunk/xfont.c	2009-12-21 20:56:26 UTC (rev 386)
@@ -47,59 +47,56 @@
 int debug_xfonts = 0;
 
 static void
-dump_char_struct (XCharStruct *ch, char *prefix)
+dump_char_struct(XCharStruct * ch, char *prefix)
 {
-  printf ("%slbearing = %d, rbearing = %d, width = %d\n",
+   printf("%slbearing = %d, rbearing = %d, width = %d\n",
           prefix, ch->lbearing, ch->rbearing, ch->width);
-  printf ("%sascent = %d, descent = %d, attributes = %u\n",
+   printf("%sascent = %d, descent = %d, attributes = %u\n",
           prefix, ch->ascent, ch->descent, (unsigned int) ch->attributes);
 }
 
 static void
-dump_font_struct (XFontStruct *font)
+dump_font_struct(XFontStruct * font)
 {
-  printf ("ascent = %d, descent = %d\n", font->ascent, font->descent);
-  printf ("char_or_byte2 = (%u,%u)\n",
+   printf("ascent = %d, descent = %d\n", font->ascent, font->descent);
+   printf("char_or_byte2 = (%u,%u)\n",
           font->min_char_or_byte2, font->max_char_or_byte2);
-  printf ("byte1 = (%u,%u)\n", font->min_byte1, font->max_byte1);
-  printf ("all_chars_exist = %s\n", font->all_chars_exist ? "True" : 
-"False");
-  printf ("default_char = %c (\\%03o)\n",
-          (char) (isprint (font->default_char) ? font->default_char : ' '),
+   printf("byte1 = (%u,%u)\n", font->min_byte1, font->max_byte1);
+   printf("all_chars_exist = %s\n", font->all_chars_exist ? "True" : "False");
+   printf("default_char = %c (\\%03o)\n",
+          (char) (isprint(font->default_char) ? font->default_char : ' '),
           font->default_char);
-  dump_char_struct (&font->min_bounds, "min> ");
-  dump_char_struct (&font->max_bounds, "max> ");
+   dump_char_struct(&font->min_bounds, "min> ");
+   dump_char_struct(&font->max_bounds, "max> ");
 #if 0
-  for (c = font->min_char_or_byte2; c <= font->max_char_or_byte2; c++)
-    {
+   for (c = font->min_char_or_byte2; c <= font->max_char_or_byte2; c++) {
       char prefix[8];
-      sprintf (prefix, "%d> ", c);
-      dump_char_struct (&font->per_char[c], prefix);
-    }
+      sprintf(prefix, "%d> ", c);
+      dump_char_struct(&font->per_char[c], prefix);
+   }
 #endif
 }
 
 static void
-dump_bitmap (unsigned int width, unsigned int height, GLubyte *bitmap)
+dump_bitmap(unsigned int width, unsigned int height, GLubyte * bitmap)
 {
-  unsigned int x, y;
+   unsigned int x, y;
 
-  printf ("    ");
-  for (x = 0; x < 8*width; x++)
-    printf ("%o", 7 - (x % 8));
-  putchar ('\n');
-  for (y = 0; y < height; y++)
-    {
-      printf ("%3o:", y);
-      for (x = 0; x < 8*width; x++)
-        putchar ((bitmap[width*(height - y - 1) + x/8] & (1 << (7 - (x % 
-8))))
+   printf("    ");
+   for (x = 0; x < 8 * width; x++)
+      printf("%o", 7 - (x % 8));
+   putchar('\n');
+   for (y = 0; y < height; y++) {
+      printf("%3o:", y);
+      for (x = 0; x < 8 * width; x++)
+         putchar((bitmap[width * (height - y - 1) + x / 8] & (1 << (7 - (x %
+                                                                         8))))
                  ? '*' : '.');
-      printf ("   ");
+      printf("   ");
       for (x = 0; x < width; x++)
-        printf ("0x%02x, ", bitmap[width*(height - y - 1) + x]);
-      putchar ('\n');
-    }
+         printf("0x%02x, ", bitmap[width * (height - y - 1) + x]);
+      putchar('\n');
+   }
 }
 #endif /* DEBUG */
 
@@ -131,169 +128,172 @@
  * Generate OpenGL-compatible bitmap.
  */
 static void
-fill_bitmap (Display *dpy, Window win, GC gc,
-             unsigned int width, unsigned int height,
-             int x0, int y0, unsigned int c, GLubyte *bitmap)
+fill_bitmap(Display * dpy, Window win, GC gc,
+            unsigned int width, unsigned int height,
+            int x0, int y0, unsigned int c, GLubyte * bitmap)
 {
-  XImage *image;
-  unsigned int x, y;
-  Pixmap pixmap;
-  XChar2b char2b;
+   XImage *image;
+   unsigned int x, y;
+   Pixmap pixmap;
+   XChar2b char2b;
 
-  pixmap = XCreatePixmap (dpy, win, 8*width, height, 1);
-  XSetForeground(dpy, gc, 0);
-  XFillRectangle (dpy, pixmap, gc, 0, 0, 8*width, height);
-  XSetForeground(dpy, gc, 1);
+   pixmap = XCreatePixmap(dpy, win, 8 * width, height, 1);
+   XSetForeground(dpy, gc, 0);
+   XFillRectangle(dpy, pixmap, gc, 0, 0, 8 * width, height);
+   XSetForeground(dpy, gc, 1);
 
-  char2b.byte1 = (c >> 8) & 0xff;
-  char2b.byte2 = (c & 0xff);
+   char2b.byte1 = (c >> 8) & 0xff;
+   char2b.byte2 = (c & 0xff);
 
-  XDrawString16 (dpy, pixmap, gc, x0, y0, &char2b, 1);
+   XDrawString16(dpy, pixmap, gc, x0, y0, &char2b, 1);
 
-  image = XGetImage (dpy, pixmap, 0, 0, 8*width, height, 1, XYPixmap);
-  if (image) {
-    /* Fill the bitmap (X11 and OpenGL are upside down wrt each other).  */
-    for (y = 0; y < height; y++)
-      for (x = 0; x < 8*width; x++)
-        if (XGetPixel (image, x, y))
-          bitmap[width*(height - y - 1) + x/8] |= (1 << (7 - (x % 8)));
-    XDestroyImage (image);
-  }
+   image = XGetImage(dpy, pixmap, 0, 0, 8 * width, height, 1, XYPixmap);
+   if (image) {
+      /* Fill the bitmap (X11 and OpenGL are upside down wrt each other).  */
+      for (y = 0; y < height; y++)
+         for (x = 0; x < 8 * width; x++)
+            if (XGetPixel(image, x, y))
+               bitmap[width * (height - y - 1) + x / 8] |=
+                  (1 << (7 - (x % 8)));
+      XDestroyImage(image);
+   }
 
-  XFreePixmap (dpy, pixmap);
+   XFreePixmap(dpy, pixmap);
 }
 
 /*
  * determine if a given glyph is valid and return the
  * corresponding XCharStruct.
  */
-static XCharStruct *isvalid(XFontStruct *fs, int which)
+static XCharStruct *
+isvalid(XFontStruct * fs, int which)
 {
-  unsigned int  rows,pages;
-  int           byte1 = 0, byte2 = 0;
-  int           i,valid = 1;
+   unsigned int rows, pages;
+   int byte1 = 0, byte2 = 0;
+   int i, valid = 1;
 
-  rows = fs->max_byte1 - fs->min_byte1 + 1;
-  pages = fs->max_char_or_byte2 - fs->min_char_or_byte2 + 1;
+   rows = fs->max_byte1 - fs->min_byte1 + 1;
+   pages = fs->max_char_or_byte2 - fs->min_char_or_byte2 + 1;
 
-  if (rows == 1) {
-    /* "linear" fonts */
-    if ((fs->min_char_or_byte2 > which) ||
-        (fs->max_char_or_byte2 < which)) valid = 0;
-  } else {
-    /* "matrix" fonts */
-    byte2 = which & 0xff;
-    byte1 = which >> 8;
-    if ((fs->min_char_or_byte2 > byte2) ||
-        (fs->max_char_or_byte2 < byte2) ||
-        (fs->min_byte1 > byte1) ||
-        (fs->max_byte1 < byte1)) valid = 0;
-  }
+   if (rows == 1) {
+      /* "linear" fonts */
+      if ((fs->min_char_or_byte2 > which) || (fs->max_char_or_byte2 < which))
+         valid = 0;
+   }
+   else {
+      /* "matrix" fonts */
+      byte2 = which & 0xff;
+      byte1 = which >> 8;
+      if ((fs->min_char_or_byte2 > byte2) ||
+          (fs->max_char_or_byte2 < byte2) ||
+          (fs->min_byte1 > byte1) || (fs->max_byte1 < byte1))
+         valid = 0;
+   }
 
-  if (valid) {
-    if (fs->per_char) {
-      if (rows == 1) {
-        /* "linear" fonts */
-        return(fs->per_char + (which-fs->min_char_or_byte2) );
-      } else {
-        /* "matrix" fonts */
-        i = ((byte1 - fs->min_byte1) * pages) +
-             (byte2 - fs->min_char_or_byte2);
-        return(fs->per_char + i);
+   if (valid) {
+      if (fs->per_char) {
+         if (rows == 1) {
+            /* "linear" fonts */
+            return (fs->per_char + (which - fs->min_char_or_byte2));
+         }
+         else {
+            /* "matrix" fonts */
+            i = ((byte1 - fs->min_byte1) * pages) +
+               (byte2 - fs->min_char_or_byte2);
+            return (fs->per_char + i);
+         }
       }
-    } else {
-        return(&fs->min_bounds);
-    }
-  }
-  return(NULL);
+      else {
+         return (&fs->min_bounds);
+      }
+   }
+   return (NULL);
 }
 
-_X_HIDDEN void DRI_glXUseXFont( Font font, int first, int count, int listbase )
+_X_HIDDEN void
+DRI_glXUseXFont(Font font, int first, int count, int listbase)
 {
-  GLXContext CC;
-  Display *dpy;
-  Window win;
-  Pixmap pixmap;
-  GC gc;
-  XGCValues values;
-  unsigned long valuemask;
-  XFontStruct *fs;
+   GLXContext CC;
+   Display *dpy;
+   Window win;
+   Pixmap pixmap;
+   GC gc;
+   XGCValues values;
+   unsigned long valuemask;
+   XFontStruct *fs;
 
-  GLint swapbytes, lsbfirst, rowlength;
-  GLint skiprows, skippixels, alignment;
+   GLint swapbytes, lsbfirst, rowlength;
+   GLint skiprows, skippixels, alignment;
 
-  unsigned int max_width, max_height, max_bm_width, max_bm_height;
-  GLubyte *bm;
+   unsigned int max_width, max_height, max_bm_width, max_bm_height;
+   GLubyte *bm;
 
-  int i;
+   int i;
 
-  CC = __glXGetCurrentContext();
-  dpy = CC->currentDpy;
-  win = CC->currentDrawable;
+   CC = __glXGetCurrentContext();
+   dpy = CC->currentDpy;
+   win = CC->currentDrawable;
 
-  fs = XQueryFont (dpy, font);
-  if (!fs)
-    {
+   fs = XQueryFont(dpy, font);
+   if (!fs) {
       __glXSetError(CC, GL_INVALID_VALUE);
       return;
-    }
+   }
 
-  /* Allocate a bitmap that can fit all characters.  */
-  max_width = fs->max_bounds.rbearing - fs->min_bounds.lbearing;
-  max_height = fs->max_bounds.ascent + fs->max_bounds.descent;
-  max_bm_width = (max_width + 7) / 8;
-  max_bm_height = max_height;
+   /* Allocate a bitmap that can fit all characters.  */
+   max_width = fs->max_bounds.rbearing - fs->min_bounds.lbearing;
+   max_height = fs->max_bounds.ascent + fs->max_bounds.descent;
+   max_bm_width = (max_width + 7) / 8;
+   max_bm_height = max_height;
 
-  bm = (GLubyte *) Xmalloc((max_bm_width * max_bm_height) * sizeof 
-(GLubyte));
-  if (!bm) {
-      XFreeFontInfo( NULL, fs, 1 );
+   bm = (GLubyte *) Xmalloc((max_bm_width * max_bm_height) * sizeof(GLubyte));
+   if (!bm) {
+      XFreeFontInfo(NULL, fs, 1);
       __glXSetError(CC, GL_OUT_OF_MEMORY);
       return;
-    }
+   }
 
 #if 0
-  /* get the page info */
-  pages = fs->max_char_or_byte2 - fs->min_char_or_byte2 + 1;
-  firstchar = (fs->min_byte1 << 8) + fs->min_char_or_byte2;
-  lastchar = (fs->max_byte1 << 8) + fs->max_char_or_byte2;
-  rows = fs->max_byte1 - fs->min_byte1 + 1;
-  unsigned int first_char, last_char, pages, rows;
+   /* get the page info */
+   pages = fs->max_char_or_byte2 - fs->min_char_or_byte2 + 1;
+   firstchar = (fs->min_byte1 << 8) + fs->min_char_or_byte2;
+   lastchar = (fs->max_byte1 << 8) + fs->max_char_or_byte2;
+   rows = fs->max_byte1 - fs->min_byte1 + 1;
+   unsigned int first_char, last_char, pages, rows;
 #endif
 
-  /* Save the current packing mode for bitmaps.  */
-  glGetIntegerv (GL_UNPACK_SWAP_BYTES, &swapbytes);
-  glGetIntegerv (GL_UNPACK_LSB_FIRST, &lsbfirst);
-  glGetIntegerv (GL_UNPACK_ROW_LENGTH, &rowlength);
-  glGetIntegerv (GL_UNPACK_SKIP_ROWS, &skiprows);
-  glGetIntegerv (GL_UNPACK_SKIP_PIXELS, &skippixels);
-  glGetIntegerv (GL_UNPACK_ALIGNMENT, &alignment);
+   /* Save the current packing mode for bitmaps.  */
+   glGetIntegerv(GL_UNPACK_SWAP_BYTES, &swapbytes);
+   glGetIntegerv(GL_UNPACK_LSB_FIRST, &lsbfirst);
+   glGetIntegerv(GL_UNPACK_ROW_LENGTH, &rowlength);
+   glGetIntegerv(GL_UNPACK_SKIP_ROWS, &skiprows);
+   glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &skippixels);
+   glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
 
-  /* Enforce a standard packing mode which is compatible with
-     fill_bitmap() from above.  This is actually the default mode,
-     except for the (non)alignment.  */
-  glPixelStorei (GL_UNPACK_SWAP_BYTES, GL_FALSE);
-  glPixelStorei (GL_UNPACK_LSB_FIRST, GL_FALSE);
-  glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
-  glPixelStorei (GL_UNPACK_SKIP_ROWS, 0);
-  glPixelStorei (GL_UNPACK_SKIP_PIXELS, 0);
-  glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
+   /* Enforce a standard packing mode which is compatible with
+      fill_bitmap() from above.  This is actually the default mode,
+      except for the (non)alignment.  */
+   glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE);
+   glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE);
+   glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+   glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
+   glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
+   glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
 
-  pixmap = XCreatePixmap (dpy, win, 10, 10, 1);
-  values.foreground = BlackPixel (dpy, DefaultScreen (dpy));
-  values.background = WhitePixel (dpy, DefaultScreen (dpy));
-  values.font = fs->fid;
-  valuemask = GCForeground | GCBackground | GCFont;
-  gc = XCreateGC (dpy, pixmap, valuemask, &values);
-  XFreePixmap (dpy, pixmap);
+   pixmap = XCreatePixmap(dpy, win, 10, 10, 1);
+   values.foreground = BlackPixel(dpy, DefaultScreen(dpy));
+   values.background = WhitePixel(dpy, DefaultScreen(dpy));
+   values.font = fs->fid;
+   valuemask = GCForeground | GCBackground | GCFont;
+   gc = XCreateGC(dpy, pixmap, valuemask, &values);
+   XFreePixmap(dpy, pixmap);
 
 #ifdef DEBUG
-  if (debug_xfonts)
-    dump_font_struct (fs);
+   if (debug_xfonts)
+      dump_font_struct(fs);
 #endif
 
-  for (i = 0; i < count; i++)
-    {
+   for (i = 0; i < count; i++) {
       unsigned int width, height, bm_width, bm_height;
       GLfloat x0, y0, dx, dy;
       XCharStruct *ch;
@@ -305,17 +305,18 @@
       /* check on index validity and get the bounds */
       ch = isvalid(fs, c);
       if (!ch) {
-        ch = &fs->max_bounds;
-        valid = 0;
-      } else {
-        valid = 1;
+         ch = &fs->max_bounds;
+         valid = 0;
       }
+      else {
+         valid = 1;
+      }
 
 #ifdef DEBUG
       if (debug_xfonts) {
-          char s[7];
-          sprintf (s, isprint (c) ? "%c> " : "\\%03o> ", c);
-          dump_char_struct (ch, s);
+         char s[7];
+         sprintf(s, isprint(c) ? "%c> " : "\\%03o> ", c);
+         dump_char_struct(ch, s);
       }
 #endif
 
@@ -323,13 +324,13 @@
          straight from the glXUseXFont(3) manpage.  */
       width = ch->rbearing - ch->lbearing;
       height = ch->ascent + ch->descent;
-      x0 = - ch->lbearing;
+      x0 = -ch->lbearing;
       y0 = ch->descent - 1;
       dx = ch->width;
       dy = 0;
 
       /* X11's starting point.  */
-      x = - ch->lbearing;
+      x = -ch->lbearing;
       y = ch->ascent;
 
       /* Round the width to a multiple of eight.  We will use this also
@@ -338,37 +339,36 @@
       bm_width = (width + 7) / 8;
       bm_height = height;
 
-      glNewList (list, GL_COMPILE);
-        if (valid && (bm_width > 0) && (bm_height > 0)) {
+      glNewList(list, GL_COMPILE);
+      if (valid && (bm_width > 0) && (bm_height > 0)) {
 
-            memset (bm, '\0', bm_width * bm_height);
-            fill_bitmap (dpy, win, gc, bm_width, bm_height, x, y, c, bm);
+         memset(bm, '\0', bm_width * bm_height);
+         fill_bitmap(dpy, win, gc, bm_width, bm_height, x, y, c, bm);
 
-            glBitmap (width, height, x0, y0, dx, dy, bm);
+         glBitmap(width, height, x0, y0, dx, dy, bm);
 #ifdef DEBUG
-            if (debug_xfonts) {
-                printf ("width/height = %u/%u\n", width, height);
-                printf ("bm_width/bm_height = %u/%u\n", bm_width, 
-bm_height);
-                dump_bitmap (bm_width, bm_height, bm);
-              }
+         if (debug_xfonts) {
+            printf("width/height = %u/%u\n", width, height);
+            printf("bm_width/bm_height = %u/%u\n", bm_width, bm_height);
+            dump_bitmap(bm_width, bm_height, bm);
+         }
 #endif
-          } else {
-            glBitmap (0, 0, 0.0, 0.0, dx, dy, NULL);
-          }
-      glEndList ();
-    }
+      }
+      else {
+         glBitmap(0, 0, 0.0, 0.0, dx, dy, NULL);
+      }
+      glEndList();
+   }
 
-  Xfree(bm);
-  XFreeFontInfo( NULL, fs, 1 );
-  XFreeGC (dpy, gc);
+   Xfree(bm);
+   XFreeFontInfo(NULL, fs, 1);
+   XFreeGC(dpy, gc);
 
-  /* Restore saved packing modes.  */
-  glPixelStorei(GL_UNPACK_SWAP_BYTES, swapbytes);
-  glPixelStorei(GL_UNPACK_LSB_FIRST, lsbfirst);
-  glPixelStorei(GL_UNPACK_ROW_LENGTH, rowlength);
-  glPixelStorei(GL_UNPACK_SKIP_ROWS, skiprows);
-  glPixelStorei(GL_UNPACK_SKIP_PIXELS, skippixels);
-  glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
+   /* Restore saved packing modes.  */
+   glPixelStorei(GL_UNPACK_SWAP_BYTES, swapbytes);
+   glPixelStorei(GL_UNPACK_LSB_FIRST, lsbfirst);
+   glPixelStorei(GL_UNPACK_ROW_LENGTH, rowlength);
+   glPixelStorei(GL_UNPACK_SKIP_ROWS, skiprows);
+   glPixelStorei(GL_UNPACK_SKIP_PIXELS, skippixels);
+   glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
 }
-
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/xquartz-changes/attachments/20091221/7b0eae56/attachment-0001.html>


More information about the Xquartz-changes mailing list