[Xquartz-changes] [391] AppleSGLX/trunk

source_changes at macosforge.org source_changes at macosforge.org
Wed Dec 23 17:48:39 PST 2009


Revision: 391
          http://trac.macosforge.org/projects/xquartz/changeset/391
Author:   jeremyhu at freedesktop.org
Date:     2009-12-23 17:48:39 -0800 (Wed, 23 Dec 2009)
Log Message:
-----------
Finish rebase against master

Modified Paths:
--------------
    AppleSGLX/trunk/BASED_ON
    AppleSGLX/trunk/TODO
    AppleSGLX/trunk/glx_query.c
    AppleSGLX/trunk/glxcmds.c
    AppleSGLX/trunk/glxcurrent.c

Removed Paths:
-------------
    AppleSGLX/trunk/NOTES
    AppleSGLX/trunk/TODO2

Modified: AppleSGLX/trunk/BASED_ON
===================================================================
--- AppleSGLX/trunk/BASED_ON	2009-12-21 21:50:23 UTC (rev 390)
+++ AppleSGLX/trunk/BASED_ON	2009-12-24 01:48:39 UTC (rev 391)
@@ -1,8 +1,2 @@
 master as of 2009.12.21 (c020a83fae23f088990b1d5ae2fc4a1ed92f03d9)
-except for a few which still need to be rebased.
 
-Mesa-7.2 (c020a83fae23f088990b1d5ae2fc4a1ed92f03d9) + indent changes:
-  glxcmds.c
-  glxcurrent.c
-
-

Deleted: AppleSGLX/trunk/NOTES
===================================================================
--- AppleSGLX/trunk/NOTES	2009-12-21 21:50:23 UTC (rev 390)
+++ AppleSGLX/trunk/NOTES	2009-12-24 01:48:39 UTC (rev 391)
@@ -1,2 +0,0 @@
-Don't forget to update glxint.h and glxproto.h if needed for xserver 1.5.
-

Modified: AppleSGLX/trunk/TODO
===================================================================
--- AppleSGLX/trunk/TODO	2009-12-21 21:50:23 UTC (rev 390)
+++ AppleSGLX/trunk/TODO	2009-12-24 01:48:39 UTC (rev 391)
@@ -1,123 +1,26 @@
--- Feb 20, 2009
+Test shared contexts!
 
-DONE Fix glXCreateWindow and glXDestroyWindow.
-
-DONE Add API major version testing to the apple_cgl layer.  This way we can avoid
-future API fiascos.  Jordan suggested this a while ago.
-
--- Feb 16, 2009
-
-DONE glXMakeContextCurrent's readable drawable needs to be set as the current 
-surface/pbuffer/pixmap if it's different than the normal drawable in the 
-following routines:
-glReadPixels, glCopyPixels, glCopyColorTable
-
-DONE The old surface/pbuffer/pixmap needs to be restored after that.
-
-DONE glXGetCurrentReadDrawable should also report the read drawable.  It appears correct.
-
-DONE Test glXGetCurrentDisplay().  It appears correct.
---
-
-DONE Improve the glX symbol compatibility with the old libGL.
-
-DONE Work out something for the GLXFBConfig optimal width/height.  These types
-of things aren't really exposed AFAIK by CGL.  We can't do this, so we
-don't enable the extension that enables the optimal pbuffer width/height.
-Specifically don't enable the SGIX_pbuffer:
-#define GLX_OPTIMAL_PBUFFER_WIDTH_SGIX     0x8019
-#define GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX    0x801A
-
+Go over every glxcmd in glxcmds.c and make sure we have them working.
 Verify the XError behavior of GLXPixmap support functions.
 
 Test GLXPixmap support with various pixmap depths.
  
 Test GLXPixmap support with invalid pixmaps (to stress the protocol code).
 
-DONE Make apple_visual_create_pfobj not use OffScreen always.
-I suspect we can add a bool that indicates whether or not to create such
-an object.  We can also recreate the context, or possibly reconfigure it.
-Perhaps we could store the CGL attributes used for the pixel format object, and
-append the OFfScreen attribute when using GLXPixmaps.
-
-DONE Finish glXDestroyGLXPixmap().
-
-DONE Test glXDestroyGLXPixmap().
-
-DONE Add support for the newer glXCreatePixmap (from 1.4).  We have glXCreateGLXPixmap working.
-
 -- Feb 10, 2009
 
 Test glXCopyContext.
 
-DONE (in 1.6) Add the PBUFFER_BIT to the fbconfigs/visualconfigs in the X server.  This is actually unclear.  We should perhaps set that bit in the libGL instead.
-
-DONE Test the pbuffer by using glReadPixels to verify it's being written to.
-
-DONE PLAN Handle GLX_LARGEST_PBUFFER (it's unclear how to handle this so far).
-
-DONE glXQueryDrawable support for Pbuffer drawables.
-
-DONE make glXSelectEvent() a no-op.
-
--- Feb 9, 2009
-
-DONE Add glDrawBuffersARB to the exclusion list, and make it forward to the glDrawBuffers().
-
--- Feb 7, 2009
-
-DONE Extend the GL_aliases for compatibility with the old libGL (wherever possible).
-
-
--- Feb 5, 2009
-
-DONE glXUseXFont needs the xfont.c code imported from Mesa.
-
-DONE Test Chimera with AppleSGLX.
-
-DONE Test Pymol again with AppleSGLX.
-
--- Jan 16, 2009
-
-(from my paper notes)
-
-DONE: glXSwapBuffers should do an implicit glFlush according to the GLX 1.4 spec.
-
-DONE The first time a context is made current we should set the glViewport and glScissor according to the GLX 1.4 spec to the size of the new drawable.
-
-DONE test glXQueryServerString, glXGetClientString, and glXGetProcAddress.
-
-DONE Use CGLGetVersion to assert ABI major version compatibility with the OpenGL framework.
-
-DONE Work out the include/GL/gl.h problems (with the ARB functions).
-
-DONE Install the new headers with the install target.
-
--- Dec 28, 2008
-
-DONE Fix the missing #define for glxinfo IIRC or one of the glx-based programs from Mesa.  We need to define the necessary functions and features for the relevant GL and GLX extensions.  I also need to find a good indication of what extensions to enable on the server side for telling clients what we support.
-
-
 -- Dec 12 2008
  
-Generate include/GL/gl.h as needed.
-
-DONE TEST Shared contexts may work now, test them.
-
-DONE DestroyContext needs some work perhaps for the drawable destruction.
-
 TEST glXCopyContext needs some work and additional code in apple_glx.c.
 
--- OLD:
-
-DONE Add glxext.h support, and support functions.
-
 ----
 
+Make sure we report the proper list of GLX extensions available.  Apple direct may not support some 
+that Mesa does, and vice-versa.
 
-Don't forget to check with otool -L to make sure the right library is being used before release!
+Modify create_destroy_context and create a new test called create_destroy_context_thread_race.  
+Where 2 threads are doing the same sort of path of create and destroy.  The locking should protect 
+us there, but we need to verify nothing goes wrong.
 
-Make sure we report the proper list of GLX extensions available.  Apple direct may not support some that Mesa does, and vice-versa.
-
-Modify create_destroy_context and create a new test called create_destroy_context_thread_race.  Where 2 threads are doing the same sort of path of create and destroy.  The locking should protect us there, but we need to verify nothing goes wrong.
-

Deleted: AppleSGLX/trunk/TODO2
===================================================================
--- AppleSGLX/trunk/TODO2	2009-12-21 21:50:23 UTC (rev 390)
+++ AppleSGLX/trunk/TODO2	2009-12-24 01:48:39 UTC (rev 391)
@@ -1,5 +0,0 @@
-DONE: Make Pymol work better with the new libGL!
-
-Test shared contexts!
-
-Go over every glxcmd in glxcmds.c and make sure we have them working.

Modified: AppleSGLX/trunk/glx_query.c
===================================================================
--- AppleSGLX/trunk/glx_query.c	2009-12-21 21:50:23 UTC (rev 390)
+++ AppleSGLX/trunk/glx_query.c	2009-12-24 01:48:39 UTC (rev 391)
@@ -115,10 +115,7 @@
  * Query the Server GLX string.
  * This routine will allocate the necessay space for the string.
  */
-#ifndef __APPLE__
-static 
-#endif
-char *
+static char *
 __glXGetStringFromServer(Display * dpy, int opcode, CARD32 glxCode,
                          CARD32 for_whom, CARD32 name)
 {

Modified: AppleSGLX/trunk/glxcmds.c
===================================================================
--- AppleSGLX/trunk/glxcmds.c	2009-12-21 21:50:23 UTC (rev 390)
+++ AppleSGLX/trunk/glxcmds.c	2009-12-24 01:48:39 UTC (rev 391)
@@ -1,7 +1,6 @@
 /*
  * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
  * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
- * Copyright (c) 2008, 2009 Apple Inc. All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -35,22 +34,34 @@
  */
 
 #include "glxclient.h"
-#include "glxextensions.h"
-#include "glcontextmodes.h"
-
+#ifdef __APPLE__
 #include "apple_glx_context.h"
 #include "apple_glx.h"
 #include "glx_error.h"
+#else
+#include "glapi.h"
+#endif
+#include "glxextensions.h"
+#include "glcontextmodes.h"
 
-static const char __glXGLXClientVendorName[] = "SGI";
+#ifndef __APPLE__
+#ifdef GLX_DIRECT_RENDERING
+#include <sys/time.h>
+#include <X11/extensions/xf86vmode.h>
+#include "xf86dri.h"
+#endif
+#endif
+
+#if defined(USE_XCB)
+#include <X11/Xlib-xcb.h>
+#include <xcb/xcb.h>
+#include <xcb/glx.h>
+#endif
+
+static const char __glXGLXClientVendorName[] = "Mesa Project and 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
@@ -68,7 +79,7 @@
 /**
  * Find drawables in the local hash that have been destroyed on the
  * server.
- * 
+ *
  * \param dpy    Display to destroy drawables for
  * \param screen Screen number to destroy drawables for
  */
@@ -108,7 +119,7 @@
 
 /**
  * Get the __DRIdrawable for the drawable associated with a GLXContext
- * 
+ *
  * \param dpy       The display associated with \c drawable.
  * \param drawable  GLXDrawable whose __DRIdrawable part is to be retrieved.
  * \param scrn_num  If non-NULL, the drawables screen is stored there
@@ -147,14 +158,14 @@
 
 /**
  * Get the GLX per-screen data structure associated with a GLX context.
- * 
+ *
  * \param dpy   Display for which the GLX per-screen information is to be
  *              retrieved.
  * \param scrn  Screen on \c dpy for which the GLX per-screen information is
  *              to be retrieved.
  * \returns A pointer to the GLX per-screen data if \c dpy and \c scrn
  *          specify a valid GLX screen, or NULL otherwise.
- * 
+ *
  * \todo Should this function validate that \c scrn is within the screen
  *       number range for \c dpy?
  */
@@ -164,7 +175,9 @@
 {
    __GLXdisplayPrivate *const priv = __glXInitialize(dpy);
 
-   return (priv->screenConfigs != NULL) ? &priv->screenConfigs[scrn] : NULL;
+   return (priv
+           && priv->screenConfigs !=
+           NULL) ? &priv->screenConfigs[scrn] : NULL;
 }
 
 
@@ -173,7 +186,7 @@
                        __GLXscreenConfigs ** ppsc)
 {
    /* Initialize the extension, if needed .  This has the added value
-    * of initializing/allocating the display private 
+    * of initializing/allocating the display private
     */
 
    if (dpy == NULL) {
@@ -240,7 +253,7 @@
  * later in the function for direct-rendering contexts.  Direct-rendering
  * contexts don't need to track client state, so they don't need that memory
  * at all.
- * 
+ *
  * \todo Eliminate \c __glXInitVertexArrayState.  Replace it with a new
  * function called \c __glXAllocateClientState that allocates the memory and
  * does all the initialization (including the pixel pack / unpack).
@@ -338,9 +351,11 @@
       bufSize = __GLX_MAX_RENDER_CMD_SIZE;
    }
    gc->maxSmallRenderCommandSize = bufSize;
-
+   
+#ifdef __APPLE__
    gc->apple = NULL;
-   gc->do_destroy = False;
+   gc->do_destroy = False;   
+#endif
 
    return gc;
 }
@@ -349,7 +364,7 @@
 /**
  * Create a new context.  Exactly one of \c vis and \c fbconfig should be
  * non-NULL.
- * 
+ *
  * \param use_glx_1_3  For FBConfigs, should GLX 1.3 protocol or
  *                     SGIX_fbconfig protocol be used?
  * \param renderType   For FBConfigs, what is the rendering type?
@@ -363,11 +378,15 @@
               Bool use_glx_1_3, int renderType)
 {
    GLXContext gc;
+#if defined(GLX_DIRECT_RENDERING) || defined(__APPLE__)
    int screen = (fbconfig == NULL) ? vis->screen : fbconfig->screen;
    __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen);
+#endif
+#ifdef __APPLE__
    const __GLcontextModes *mode;
    int errorcode;
    bool x11error;
+#endif
 
    if (dpy == NULL)
       return NULL;
@@ -380,40 +399,148 @@
       if ((vis == NULL) && (fbconfig == NULL))
          return NULL;
 
+#ifndef __APPLE__
+#ifdef GLX_DIRECT_RENDERING
+      if (allowDirect && psc->driScreen) {
+         const __GLcontextModes *mode;
+
+         if (fbconfig == NULL) {
+            mode = _gl_context_modes_find_visual(psc->visuals, vis->visualid);
+            if (mode == NULL) {
+               xError error;
+
+               error.errorCode = BadValue;
+               error.resourceID = vis->visualid;
+               error.sequenceNumber = dpy->request;
+               error.type = X_Error;
+               error.majorCode = gc->majorOpcode;
+               error.minorCode = X_GLXCreateContext;
+               _XError(dpy, &error);
+               return None;
+            }
+            if (renderType == 0) {
+               /* Initialize renderType now */
+               renderType = mode->rgbMode ? GLX_RGBA_TYPE : GLX_COLOR_INDEX_TYPE;
+            }
+         }
+         else {
+            mode = fbconfig;
+         }
+
+         gc->driContext = psc->driScreen->createContext(psc, mode, gc,
+                                                        shareList,
+                                                        renderType);
+         if (gc->driContext != NULL) {
+            gc->screen = mode->screen;
+            gc->psc = psc;
+            gc->mode = mode;
+            gc->isDirect = GL_TRUE;
+         }
+      }
+#endif
+
+      LockDisplay(dpy);
+      if (fbconfig == NULL) {
+         xGLXCreateContextReq *req;
+
+         /* Send the glXCreateContext request */
+         GetReq(GLXCreateContext, req);
+         req->reqType = gc->majorOpcode;
+         req->glxCode = X_GLXCreateContext;
+         req->context = gc->xid = XAllocID(dpy);
+         req->visual = vis->visualid;
+         req->screen = vis->screen;
+         req->shareList = shareList ? shareList->xid : None;
+#ifdef GLX_DIRECT_RENDERING
+         req->isDirect = gc->driContext != NULL;
+#else
+         req->isDirect = 0;
+#endif
+      }
+      else if (use_glx_1_3) {
+         xGLXCreateNewContextReq *req;
+
+         /* Send the glXCreateNewContext request */
+         GetReq(GLXCreateNewContext, req);
+         req->reqType = gc->majorOpcode;
+         req->glxCode = X_GLXCreateNewContext;
+         req->context = gc->xid = XAllocID(dpy);
+         req->fbconfig = fbconfig->fbconfigID;
+         req->screen = fbconfig->screen;
+         req->renderType = renderType;
+         req->shareList = shareList ? shareList->xid : None;
+#ifdef GLX_DIRECT_RENDERING
+         req->isDirect = gc->driContext != NULL;
+#else
+         req->isDirect = 0;
+#endif
+      }
+      else {
+         xGLXVendorPrivateWithReplyReq *vpreq;
+         xGLXCreateContextWithConfigSGIXReq *req;
+
+         /* Send the glXCreateNewContext request */
+         GetReqExtra(GLXVendorPrivateWithReply,
+                     sz_xGLXCreateContextWithConfigSGIXReq -
+                     sz_xGLXVendorPrivateWithReplyReq, vpreq);
+         req = (xGLXCreateContextWithConfigSGIXReq *) vpreq;
+         req->reqType = gc->majorOpcode;
+         req->glxCode = X_GLXVendorPrivateWithReply;
+         req->vendorCode = X_GLXvop_CreateContextWithConfigSGIX;
+         req->context = gc->xid = XAllocID(dpy);
+         req->fbconfig = fbconfig->fbconfigID;
+         req->screen = fbconfig->screen;
+         req->renderType = renderType;
+         req->shareList = shareList ? shareList->xid : None;
+#ifdef GLX_DIRECT_RENDERING
+         req->isDirect = gc->driContext != NULL;
+#else
+         req->isDirect = 0;
+#endif
+      }
+
+      UnlockDisplay(dpy);
+      SyncHandle();
+      gc->imported = GL_FALSE;
    }
+   else {
+      gc->xid = contextID;
+      gc->imported = GL_TRUE;
+#endif
+   }
 
+#ifdef __APPLE__
    gc->xid = contextID;
    gc->imported = GL_FALSE;
 
-   if (vis) {
+   if(vis) {
       mode = _gl_context_modes_find_visual(psc->visuals, vis->visualid);
-   }
-   else {
-      mode = _gl_context_modes_find_fbconfig(psc->configs,
+   } else {
+      mode = _gl_context_modes_find_fbconfig(psc->configs, 
                                              fbconfig->fbconfigID);
    }
-
-   if (NULL == mode) {
-      __glXSendError(dpy, BadValue, vis->visualid, X_GLXCreateContext, true);
+   
+   if(NULL == mode) {
+      __glXSendError(dpy, BadValue, vis->visualid, X_GLXCreateContext,
+                     true);
       __glXFreeContext(gc);
-
       return NULL;
    }
-
-
-   if (apple_glx_create_context(&gc->apple, dpy, screen, mode,
-                                shareList ? shareList->apple : NULL,
-                                &errorcode, &x11error)) {
+   
+   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;
-
+#else
+   gc->renderType = renderType;
+#endif
    return gc;
 }
 
@@ -421,7 +548,6 @@
 glXCreateContext(Display * dpy, XVisualInfo * vis,
                  GLXContext shareList, Bool allowDirect)
 {
-
    return CreateContext(dpy, vis, NULL, shareList, allowDirect, None,
                         False, 0);
 }
@@ -437,8 +563,9 @@
       XFree((char *) gc->version);
    if (gc->extensions)
       XFree((char *) gc->extensions);
-
-   //__glFreeAttributeState(gc);
+#ifndef __APPLE__
+   __glFreeAttributeState(gc);
+#endif
    XFree((char *) gc->buf);
    Xfree((char *) gc->client_state_private);
    XFree((char *) gc);
@@ -451,25 +578,81 @@
 static void
 DestroyContext(Display * dpy, GLXContext gc)
 {
+#ifndef __APPLE__
+   xGLXDestroyContextReq *req;
+   GLXContextID xid;
+   CARD8 opcode;
+   GLboolean imported;
+
+   opcode = __glXSetupForCommand(dpy);
+   if (!opcode || !gc) {
+      return;
+   }
+
    __glXLock();
+   xid = gc->xid;
+   imported = gc->imported;
+   gc->xid = None;
 
    if (gc->currentDpy) {
+      /* This context is bound to some thread.  According to the man page,
+       * we should not actually delete the context until it's unbound.
+       * Note that we set gc->xid = None above.  In MakeContextCurrent()
+       * we check for that and delete the context there.
+       */
+      __glXUnlock();
+      return;
+   }
+
+#ifdef GLX_DIRECT_RENDERING
+   /* Destroy the direct rendering context */
+   if (gc->driContext) {
+      (*gc->driContext->destroyContext) (gc->driContext, gc->psc, dpy);
+      gc->driContext = NULL;
+      GarbageCollectDRIDrawables(dpy, gc->psc);
+   }
+#endif
+
+   __glXFreeVertexArrayState(gc);
+#else
+   __glXLock();
+#endif /* __APPLE__ */   
+
+   if (gc->currentDpy) {
+#ifdef __APPLE__
       /* 
        * Set the Bool that indicates that we should destroy this GLX context
        * when the context is no longer current.
        */
       gc->do_destroy = True;
+#endif
+      /* Have to free later cuz it's in use now */
       __glXUnlock();
    }
    else {
       /* Destroy the handle if not current to anybody */
       __glXUnlock();
-
-      if (gc->apple)
+#ifdef __APPLE__
+      if(gc->apple)
          apple_glx_destroy_context(&gc->apple, dpy);
-
+#endif
       __glXFreeContext(gc);
    }
+#ifndef __APPLE__
+   if (!imported) {
+      /*
+       ** This dpy also created the server side part of the context.
+       ** Send the glXDestroyContext request.
+       */
+      LockDisplay(dpy);
+      GetReq(GLXDestroyContext, req);
+      req->reqType = opcode;
+      req->glxCode = X_GLXDestroyContext;
+      req->context = xid;
+      UnlockDisplay(dpy);
+      SyncHandle();
+   }
+#endif
 }
 
 PUBLIC void
@@ -495,7 +678,6 @@
       *major = priv->majorVersion;
    if (minor)
       *minor = priv->minorVersion;
-
    return GL_TRUE;
 }
 
@@ -525,6 +707,9 @@
 PUBLIC void
 glXWaitGL(void)
 {
+#ifndef __APPLE__
+   xGLXWaitGLReq *req;
+#endif
    GLXContext gc = __glXGetCurrentContext();
    Display *dpy = gc->currentDpy;
 
@@ -533,8 +718,34 @@
 
    /* Flush any pending commands out */
    __glXFlushRenderBuffer(gc, gc->pc);
+#ifdef __APPLE__
+   glFinish();
+#else
+#ifdef GLX_DIRECT_RENDERING
+   if (gc->driContext) {
+      int screen;
+      __GLXDRIdrawable *pdraw =
+         GetGLXDRIDrawable(dpy, gc->currentDrawable, &screen);
 
-   glFinish();
+      if (pdraw != NULL) {
+         __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen);
+         glFlush();
+         if (psc->driScreen->waitGL != NULL)
+            (*psc->driScreen->waitGL) (pdraw);
+      }
+      return;
+   }
+#endif
+
+   /* Send the glXWaitGL request */
+   LockDisplay(dpy);
+   GetReq(GLXWaitGL, req);
+   req->reqType = gc->majorOpcode;
+   req->glxCode = X_GLXWaitGL;
+   req->contextTag = gc->currentContextTag;
+   UnlockDisplay(dpy);
+   SyncHandle();
+#endif /* __APPLE__ */
 }
 
 /*
@@ -544,6 +755,9 @@
 PUBLIC void
 glXWaitX(void)
 {
+#ifndef __APPLE__
+   xGLXWaitXReq *req;
+#endif
    GLXContext gc = __glXGetCurrentContext();
    Display *dpy = gc->currentDpy;
 
@@ -553,14 +767,45 @@
    /* Flush any pending commands out */
    __glXFlushRenderBuffer(gc, gc->pc);
 
+#ifdef __APPLE__
    apple_glx_waitx(dpy, gc->apple);
+#else
+#ifdef GLX_DIRECT_RENDERING
+   if (gc->driContext) {
+      int screen;
+      __GLXDRIdrawable *pdraw =
+         GetGLXDRIDrawable(dpy, gc->currentDrawable, &screen);
 
-   return;
+      if (pdraw != NULL) {
+         __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen);
+         if (psc->driScreen->waitX != NULL)
+            (*psc->driScreen->waitX) (pdraw);
+      }
+      else
+         XSync(dpy, False);
+      return;
+   }
+#endif
+
+   /*
+    ** Send the glXWaitX request.
+    */
+   LockDisplay(dpy);
+   GetReq(GLXWaitX, req);
+   req->reqType = gc->majorOpcode;
+   req->glxCode = X_GLXWaitX;
+   req->contextTag = gc->currentContextTag;
+   UnlockDisplay(dpy);
+   SyncHandle();
+#endif /* __APPLE__ */
 }
 
 PUBLIC void
 glXUseXFont(Font font, int first, int count, int listBase)
 {
+#ifndef __APPLE__
+   xGLXUseXFontReq *req;
+#endif
    GLXContext gc = __glXGetCurrentContext();
    Display *dpy = gc->currentDpy;
 
@@ -569,8 +814,29 @@
 
    /* Flush any pending commands out */
    (void) __glXFlushRenderBuffer(gc, gc->pc);
+#ifdef __APPLE__
+   DRI_glXUseXFont(font, first, count, listBase); 
+#else
+#ifdef GLX_DIRECT_RENDERING
+   if (gc->driContext) {
+      DRI_glXUseXFont(font, first, count, listBase);
+      return;
+   }
+#endif
 
-   DRI_glXUseXFont(font, first, count, listBase);
+   /* Send the glXUseFont request */
+   LockDisplay(dpy);
+   GetReq(GLXUseXFont, req);
+   req->reqType = gc->majorOpcode;
+   req->glxCode = X_GLXUseXFont;
+   req->contextTag = gc->currentContextTag;
+   req->font = font;
+   req->first = first;
+   req->count = count;
+   req->listBase = listBase;
+   UnlockDisplay(dpy);
+   SyncHandle();
+#endif /* __APPLE__ */
 }
 
 /************************************************************************/
@@ -583,17 +849,110 @@
 glXCopyContext(Display * dpy, GLXContext source,
                GLXContext dest, unsigned long mask)
 {
+#ifdef __APPLE__
    GLXContext gc = __glXGetCurrentContext();
    int errorcode;
    bool x11error;
 
-   if (apple_glx_copy_context(gc->apple, source->apple, dest->apple,
-                              mask, &errorcode, &x11error)) {
+   if(apple_glx_copy_context(gc->apple, source->apple, dest->apple,
+                             mask, &errorcode, &x11error)) {
       __glXSendError(dpy, errorcode, 0, X_GLXCopyContext, x11error);
    }
+   
+#else
+   xGLXCopyContextReq *req;
+   GLXContext gc = __glXGetCurrentContext();
+   GLXContextTag tag;
+   CARD8 opcode;
+
+   opcode = __glXSetupForCommand(dpy);
+   if (!opcode) {
+      return;
+   }
+
+#ifdef GLX_DIRECT_RENDERING
+   if (gc->driContext) {
+      /* NOT_DONE: This does not work yet */
+   }
+#endif
+
+   /*
+    ** If the source is the current context, send its tag so that the context
+    ** can be flushed before the copy.
+    */
+   if (source == gc && dpy == gc->currentDpy) {
+      tag = gc->currentContextTag;
+   }
+   else {
+      tag = 0;
+   }
+
+   /* Send the glXCopyContext request */
+   LockDisplay(dpy);
+   GetReq(GLXCopyContext, req);
+   req->reqType = opcode;
+   req->glxCode = X_GLXCopyContext;
+   req->source = source ? source->xid : None;
+   req->dest = dest ? dest->xid : None;
+   req->mask = mask;
+   req->contextTag = tag;
+   UnlockDisplay(dpy);
+   SyncHandle();
+#endif /* __APPLE__ */
 }
 
+
+#ifndef __APPLE__
 /**
+ * Determine if a context uses direct rendering.
+ *
+ * \param dpy        Display where the context was created.
+ * \param contextID  ID of the context to be tested.
+ *
+ * \returns \c GL_TRUE if the context is direct rendering or not.
+ */
+static Bool
+__glXIsDirect(Display * dpy, GLXContextID contextID)
+{
+#if !defined(USE_XCB)
+   xGLXIsDirectReq *req;
+   xGLXIsDirectReply reply;
+#endif
+   CARD8 opcode;
+
+   opcode = __glXSetupForCommand(dpy);
+   if (!opcode) {
+      return GL_FALSE;
+   }
+
+#ifdef USE_XCB
+   xcb_connection_t *c = XGetXCBConnection(dpy);
+   xcb_glx_is_direct_reply_t *reply = xcb_glx_is_direct_reply(c,
+                                                              xcb_glx_is_direct
+                                                              (c, contextID),
+                                                              NULL);
+
+   const Bool is_direct = reply->is_direct ? True : False;
+   free(reply);
+
+   return is_direct;
+#else
+   /* Send the glXIsDirect request */
+   LockDisplay(dpy);
+   GetReq(GLXIsDirect, req);
+   req->reqType = opcode;
+   req->glxCode = X_GLXIsDirect;
+   req->context = contextID;
+   _XReply(dpy, (xReply *) & reply, 0, False);
+   UnlockDisplay(dpy);
+   SyncHandle();
+
+   return reply.isDirect;
+#endif /* USE_XCB */
+}
+#endif /* __APPLE__ */
+
+/**
  * \todo
  * Shouldn't this function \b always return \c GL_FALSE when
  * \c GLX_DIRECT_RENDERING is not defined?  Do we really need to bother with
@@ -602,31 +961,94 @@
 PUBLIC Bool
 glXIsDirect(Display * dpy, GLXContext gc)
 {
+#ifdef __APPLE__
    /*
     * This isn't an ideal test.  
     * glXIsDirect should probably search a list of contexts.
     */
-   if (NULL == gc) {
+   if(NULL == gc) {
       __glXSendError(dpy, GLXBadContext, 0, X_GLXIsDirect, false);
       return False;
    }
-
    return gc->isDirect;
+#else
+   if (!gc) {
+      return GL_FALSE;
+#ifdef GLX_DIRECT_RENDERING
+   }
+   else if (gc->driContext) {
+      return GL_TRUE;
+#endif
+   }
+   return __glXIsDirect(dpy, gc->xid);
+#endif /* __APPLE__ */
 }
 
 PUBLIC GLXPixmap
 glXCreateGLXPixmap(Display * dpy, XVisualInfo * vis, Pixmap pixmap)
 {
+#ifdef __APPLE__
    int screen = vis->screen;
    __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen);
    const __GLcontextModes *modes;
 
    modes = _gl_context_modes_find_visual(psc->visuals, vis->visualid);
+   
+   if(apple_glx_pixmap_create(dpy, vis->screen, pixmap, modes))
+      return None;
+   
+   return pixmap;
+#else
+   xGLXCreateGLXPixmapReq *req;
+   GLXPixmap xid;
+   CARD8 opcode;
 
-   if (apple_glx_pixmap_create(dpy, vis->screen, pixmap, modes))
+   opcode = __glXSetupForCommand(dpy);
+   if (!opcode) {
       return None;
+   }
 
-   return pixmap;
+   /* Send the glXCreateGLXPixmap request */
+   LockDisplay(dpy);
+   GetReq(GLXCreateGLXPixmap, req);
+   req->reqType = opcode;
+   req->glxCode = X_GLXCreateGLXPixmap;
+   req->screen = vis->screen;
+   req->visual = vis->visualid;
+   req->pixmap = pixmap;
+   req->glxpixmap = xid = XAllocID(dpy);
+   UnlockDisplay(dpy);
+   SyncHandle();
+
+#ifdef GLX_DIRECT_RENDERING
+   do {
+      /* FIXME: Maybe delay __DRIdrawable creation until the drawable
+       * is actually bound to a context... */
+
+      __GLXdisplayPrivate *const priv = __glXInitialize(dpy);
+      __GLXDRIdrawable *pdraw;
+      __GLXscreenConfigs *psc;
+      __GLcontextModes *modes;
+
+      psc = &priv->screenConfigs[vis->screen];
+      if (psc->driScreen == NULL)
+         break;
+      modes = _gl_context_modes_find_visual(psc->visuals, vis->visualid);
+      pdraw = psc->driScreen->createDrawable(psc, pixmap, req->glxpixmap, modes);
+      if (pdraw == NULL) {
+         fprintf(stderr, "failed to create pixmap\n");
+         break;
+      }
+
+      if (__glxHashInsert(psc->drawHash, req->glxpixmap, pdraw)) {
+         (*pdraw->destroyDrawable) (pdraw);
+         return None;           /* FIXME: Check what we're supposed to do here... */
+      }
+   } while (0);
+#endif
+
+   return xid;
+#endif
 }
 
 /*
@@ -635,21 +1057,109 @@
 PUBLIC void
 glXDestroyGLXPixmap(Display * dpy, GLXPixmap glxpixmap)
 {
-   if (apple_glx_pixmap_destroy(dpy, glxpixmap))
+#ifdef __APPLE__
+   if(apple_glx_pixmap_destroy(dpy, glxpixmap))
       __glXSendError(dpy, GLXBadPixmap, glxpixmap, X_GLXDestroyPixmap, false);
+#else
+   xGLXDestroyGLXPixmapReq *req;
+   CARD8 opcode;
+
+   opcode = __glXSetupForCommand(dpy);
+   if (!opcode) {
+      return;
+   }
+
+   /* Send the glXDestroyGLXPixmap request */
+   LockDisplay(dpy);
+   GetReq(GLXDestroyGLXPixmap, req);
+   req->reqType = opcode;
+   req->glxCode = X_GLXDestroyGLXPixmap;
+   req->glxpixmap = glxpixmap;
+   UnlockDisplay(dpy);
+   SyncHandle();
+
+#ifdef GLX_DIRECT_RENDERING
+   {
+      int screen;
+      __GLXdisplayPrivate *const priv = __glXInitialize(dpy);
+      __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, glxpixmap, &screen);
+      __GLXscreenConfigs *psc = &priv->screenConfigs[screen];
+
+      if (pdraw != NULL) {
+         (*pdraw->destroyDrawable) (pdraw);
+         __glxHashDelete(psc->drawHash, glxpixmap);
+      }
+   }
+#endif
+#endif /* __APPLE__ */
 }
 
 PUBLIC void
 glXSwapBuffers(Display * dpy, GLXDrawable drawable)
 {
+#ifdef __APPLE__
    GLXContext gc = glXGetCurrentContext();
-
-   if (gc && apple_glx_is_current_drawable(dpy, gc->apple, drawable)) {
+   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);
    }
+#else
+   GLXContext gc;
+   GLXContextTag tag;
+   CARD8 opcode;
+#ifdef USE_XCB
+   xcb_connection_t *c;
+#else
+   xGLXSwapBuffersReq *req;
+#endif
+
+#ifdef GLX_DIRECT_RENDERING
+   __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, NULL);
+
+   if (pdraw != NULL) {
+      glFlush();
+      (*pdraw->psc->driScreen->swapBuffers) (pdraw);
+      return;
+   }
+#endif
+
+   opcode = __glXSetupForCommand(dpy);
+   if (!opcode) {
+      return;
+   }
+
+   /*
+    ** The calling thread may or may not have a current context.  If it
+    ** does, send the context tag so the server can do a flush.
+    */
+   gc = __glXGetCurrentContext();
+   if ((gc != NULL) && (dpy == gc->currentDpy) &&
+       ((drawable == gc->currentDrawable)
+        || (drawable == gc->currentReadable))) {
+      tag = gc->currentContextTag;
+   }
    else {
-      __glXSendError(dpy, GLXBadCurrentWindow, 0, X_GLXSwapBuffers, false);
+      tag = 0;
    }
+
+#ifdef USE_XCB
+   c = XGetXCBConnection(dpy);
+   xcb_glx_swap_buffers(c, tag, drawable);
+   xcb_flush(c);
+#else
+   /* Send the glXSwapBuffers request */
+   LockDisplay(dpy);
+   GetReq(GLXSwapBuffers, req);
+   req->reqType = opcode;
+   req->glxCode = X_GLXSwapBuffers;
+   req->drawable = drawable;
+   req->contextTag = tag;
+   UnlockDisplay(dpy);
+   SyncHandle();
+   XFlush(dpy);
+#endif /* USE_XCB */
+#endif /* __APPLE__ */
 }
 
 
@@ -725,28 +1235,28 @@
    config->swapMethod = GLX_DONT_CARE;
 }
 
-#define MATCH_DONT_CARE( param ) \
-	do { \
-	    if ( (a-> param != GLX_DONT_CARE) \
-		 && (a-> param != b-> param) ) { \
-		return False; \
-	    } \
-	} while ( 0 )
+#define MATCH_DONT_CARE( param )        \
+  do {                                  \
+    if ( (a-> param != GLX_DONT_CARE)   \
+         && (a-> param != b-> param) ) {        \
+      return False;                             \
+    }                                           \
+  } while ( 0 )
 
-#define MATCH_MINIMUM( param ) \
-	do { \
-	    if ( (a-> param != GLX_DONT_CARE) \
-		 && (a-> param > b-> param) ) { \
-		return False; \
-	    } \
-	} while ( 0 )
+#define MATCH_MINIMUM( param )                  \
+  do {                                          \
+    if ( (a-> param != GLX_DONT_CARE)           \
+         && (a-> param > b-> param) ) {         \
+      return False;                             \
+    }                                           \
+  } while ( 0 )
 
-#define MATCH_EXACT( param ) \
-	do { \
-	    if ( a-> param != b-> param) { \
-		return False; \
-	    } \
-	} while ( 0 )
+#define MATCH_EXACT( param )                    \
+  do {                                          \
+    if ( a-> param != b-> param) {              \
+      return False;                             \
+    }                                           \
+  } while ( 0 )
 
 /**
  * Determine if two GLXFBConfigs are compatible.
@@ -796,7 +1306,7 @@
     * 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 
+    * 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.
@@ -838,39 +1348,39 @@
  * Well, that's really hard to do with the code as-is.  This behavior is
  * closer to correct, but still not technically right.
  */
-#define PREFER_LARGER_OR_ZERO(comp) \
-    do { \
-	if ( ((*a)-> comp) != ((*b)-> comp) ) { \
-	    if ( ((*a)-> comp) == 0 ) { \
-		return -1; \
-	    } \
-	    else if ( ((*b)-> comp) == 0 ) { \
-		return 1; \
-	    } \
-	    else { \
-		return ((*b)-> comp) - ((*a)-> comp) ; \
-	    } \
-	} \
-    } while( 0 )
+#define PREFER_LARGER_OR_ZERO(comp)             \
+  do {                                          \
+    if ( ((*a)-> comp) != ((*b)-> comp) ) {     \
+      if ( ((*a)-> comp) == 0 ) {               \
+        return -1;                              \
+      }                                         \
+      else if ( ((*b)-> comp) == 0 ) {          \
+        return 1;                               \
+      }                                         \
+      else {                                    \
+        return ((*b)-> comp) - ((*a)-> comp) ;  \
+      }                                         \
+    }                                           \
+  } while( 0 )
 
-#define PREFER_LARGER(comp) \
-    do { \
-	if ( ((*a)-> comp) != ((*b)-> comp) ) { \
-	    return ((*b)-> comp) - ((*a)-> comp) ; \
-	} \
-    } while( 0 )
+#define PREFER_LARGER(comp)                     \
+  do {                                          \
+    if ( ((*a)-> comp) != ((*b)-> comp) ) {     \
+      return ((*b)-> comp) - ((*a)-> comp) ;    \
+    }                                           \
+  } while( 0 )
 
-#define PREFER_SMALLER(comp) \
-    do { \
-	if ( ((*a)-> comp) != ((*b)-> comp) ) { \
-	    return ((*a)-> comp) - ((*b)-> comp) ; \
-	} \
-    } while( 0 )
+#define PREFER_SMALLER(comp)                    \
+  do {                                          \
+    if ( ((*a)-> comp) != ((*b)-> comp) ) {     \
+      return ((*a)-> comp) - ((*b)-> comp) ;    \
+    }                                           \
+  } while( 0 )
 
 /**
  * Compare two GLXFBConfigs.  This function is intended to be used as the
  * compare function passed in to qsort.
- * 
+ *
  * \returns If \c a is a "better" config, according to the specification of
  *          SGIX_fbconfig, a number less than zero is returned.  If \c b is
  *          better, then a number greater than zero is return.  If both are
@@ -945,7 +1455,7 @@
  * Selects and sorts a subset of the supplied configs based on the attributes.
  * This function forms to basis of \c glXChooseVisual, \c glXChooseFBConfig,
  * and \c glXChooseFBConfigSGIX.
- * 
+ *
  * \param configs   Array of pointers to possible configs.  The elements of
  *                  this array that do not meet the criteria will be set to
  *                  NULL.  The remaining elements will be sorted according to
@@ -960,7 +1470,7 @@
  *                             \c glXChooseVisual style or
  *                             \c glXChooseFBConfig style.
  * \returns The number of valid elements left in \c configs.
- * 
+ *
  * \sa glXChooseVisual, glXChooseFBConfig, glXChooseFBConfigSGIX
  */
 static int
@@ -1046,6 +1556,9 @@
     ** Eliminate visuals that don't meet minimum requirements
     ** Compute a score for those that do
     ** Remember which visual, if any, got the highest score
+    ** If no visual is acceptable, return None
+    ** Otherwise, create an XVisualInfo list with just the selected X visual
+    ** and return this.
     */
    for (modes = psc->visuals; modes != NULL; modes = modes->next) {
       if (fbconfigs_compatible(&test_config, modes)
@@ -1054,28 +1567,28 @@
               (fbconfig_compare
                ((const __GLcontextModes * const *const) &modes,
                 &best_config) < 0))) {
-         best_config = modes;
-      }
-   }
+         XVisualInfo visualTemplate;
+         XVisualInfo *newList;
+         int i;
 
-   /*
-    ** 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;
+         visualTemplate.screen = screen;
+         visualTemplate.visualid = modes->visualID;
+         newList = XGetVisualInfo(dpy, VisualScreenMask | VisualIDMask,
+                                  &visualTemplate, &i);
 
-      visualTemplate.screen = screen;
-      visualTemplate.visualid = best_config->visualID;
-      visualList = XGetVisualInfo(dpy, VisualScreenMask | VisualIDMask,
-                                  &visualTemplate, &i);
+         if (newList) {
+            Xfree(visualList);
+            visualList = newList;
+            best_config = modes;
+         }
+      }
    }
 
-   if (visualList && getenv("LIBGL_DUMP_VISUALID")) {
+#ifdef __APPLE__
+   if(visualList && getenv("LIBGL_DUMP_VISUALID")) {
       printf("visualid 0x%lx\n", visualList[0].visualid);
    }
+#endif
 
    return visualList;
 }
@@ -1093,10 +1606,9 @@
 
    if (!psc->effectiveGLXexts) {
       if (!psc->serverGLXexts) {
-         psc->serverGLXexts = __glXGetStringFromServer(dpy, priv->majorOpcode,
-                                                       X_GLXQueryServerString,
-                                                       screen,
-                                                       GLX_EXTENSIONS);
+         psc->serverGLXexts =
+            __glXQueryServerString(dpy, priv->majorOpcode, screen,
+                                   GLX_EXTENSIONS);
       }
 
       __glXCalculateUsableExtensions(psc,
@@ -1153,8 +1665,7 @@
    }
 
    if (*str == NULL) {
-      *str = __glXGetStringFromServer(dpy, priv->majorOpcode,
-                                      X_GLXQueryServerString, screen, name);
+      *str = __glXQueryServerString(dpy, priv->majorOpcode, screen, name);
    }
 
    return *str;
@@ -1163,10 +1674,16 @@
 void
 __glXClientInfo(Display * dpy, int opcode)
 {
-   xGLXClientInfoReq *req;
-   int size;
    char *ext_str = __glXGetClientGLExtensionString();
+   int size = strlen(ext_str) + 1;
 
+#ifdef USE_XCB
+   xcb_connection_t *c = XGetXCBConnection(dpy);
+   xcb_glx_client_info(c,
+                       GLX_MAJOR_VERSION, GLX_MINOR_VERSION, size, ext_str);
+#else
+   xGLXClientInfoReq *req;
+
    /* Send the glXClientInfo request */
    LockDisplay(dpy);
    GetReq(GLXClientInfo, req);
@@ -1175,13 +1692,13 @@
    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);
 
    UnlockDisplay(dpy);
    SyncHandle();
+#endif /* USE_XCB */
 
    Xfree(ext_str);
 }
@@ -1203,22 +1720,23 @@
 PUBLIC
 GLX_ALIAS(Display *, glXGetCurrentDisplayEXT, (void), (),
           glXGetCurrentDisplay)
-#if 0
+
+#ifndef __APPLE__
 /**
  * Used internally by libGL to send \c xGLXQueryContextinfoExtReq requests
  * to the X-server.
- * 
+ *
  * \param dpy  Display where \c ctx was created.
  * \param ctx  Context to query.
  * \returns  \c Success on success.  \c GLX_BAD_CONTEXT if \c ctx is invalid,
  *           or zero if the request failed due to internal problems (i.e.,
  *           unable to allocate temporary memory, etc.)
- * 
+ *
  * \note
  * 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;
@@ -1313,16 +1831,15 @@
    SyncHandle();
    return retval;
 }
+
 #endif
 
 PUBLIC int
 glXQueryContext(Display * dpy, GLXContext ctx, int attribute, int *value)
 {
+#ifndef __APPLE__
    int retVal;
 
-   (void) retVal;
-
-#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)) {
@@ -1336,8 +1853,8 @@
 #endif
 
    switch (attribute) {
-#if 0
-   case GLX_SHARE_CONTEXT_EXT:
+#ifndef __APPLE__
+      case GLX_SHARE_CONTEXT_EXT:
       *value = (int) (ctx->share_xid);
       break;
    case GLX_VISUAL_ID_EXT:
@@ -1364,7 +1881,7 @@
           (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;
 }
@@ -1372,7 +1889,9 @@
 PUBLIC GLXContext
 glXImportContextEXT(Display * dpy, GLXContextID contextID)
 {
-#if 0
+#ifdef __APPLE__
+   return NULL;
+#else
    GLXContext ctx;
 
    if (contextID == None) {
@@ -1390,7 +1909,6 @@
    }
    return ctx;
 #endif
-   return NULL;
 }
 
 PUBLIC void
@@ -1454,11 +1972,7 @@
    int i;
 
    *nelements = 0;
-
-   if (!priv)
-      return NULL;
-
-   if ((priv->screenConfigs != NULL)
+   if (priv && (priv->screenConfigs != NULL)
        && (screen >= 0) && (screen <= ScreenCount(dpy))
        && (priv->screenConfigs[screen].configs != NULL)
        && (priv->screenConfigs[screen].configs->fbconfigID != GLX_DONT_CARE)) {
@@ -1517,7 +2031,297 @@
    return XGetVisualInfo(dpy, VisualIDMask, &visualTemplate, &count);
 }
 
+#ifndef __APPLE__
 /*
+** GLX_SGI_swap_control
+*/
+static int
+__glXSwapIntervalSGI(int interval)
+{
+   xGLXVendorPrivateReq *req;
+   GLXContext gc = __glXGetCurrentContext();
+   Display *dpy;
+   CARD32 *interval_ptr;
+   CARD8 opcode;
+
+   if (gc == NULL) {
+      return GLX_BAD_CONTEXT;
+   }
+
+   if (interval <= 0) {
+      return GLX_BAD_VALUE;
+   }
+
+#ifdef __DRI_SWAP_CONTROL
+   if (gc->driContext) {
+      __GLXscreenConfigs *const psc = GetGLXScreenConfigs(gc->currentDpy,
+                                                          gc->screen);
+      __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(gc->currentDpy,
+                                                  gc->currentDrawable,
+                                                  NULL);
+      if (psc->swapControl != NULL && pdraw != NULL) {
+         psc->swapControl->setSwapInterval(pdraw->driDrawable, interval);
+         return 0;
+      }
+      else {
+         return GLX_BAD_CONTEXT;
+      }
+   }
+#endif
+   dpy = gc->currentDpy;
+   opcode = __glXSetupForCommand(dpy);
+   if (!opcode) {
+      return 0;
+   }
+
+   /* Send the glXSwapIntervalSGI request */
+   LockDisplay(dpy);
+   GetReqExtra(GLXVendorPrivate, sizeof(CARD32), req);
+   req->reqType = opcode;
+   req->glxCode = X_GLXVendorPrivate;
+   req->vendorCode = X_GLXvop_SwapIntervalSGI;
+   req->contextTag = gc->currentContextTag;
+
+   interval_ptr = (CARD32 *) (req + 1);
+   *interval_ptr = interval;
+
+   UnlockDisplay(dpy);
+   SyncHandle();
+   XFlush(dpy);
+
+   return 0;
+}
+
+
+/*
+** GLX_MESA_swap_control
+*/
+static int
+__glXSwapIntervalMESA(unsigned int interval)
+{
+#ifdef __DRI_SWAP_CONTROL
+   GLXContext gc = __glXGetCurrentContext();
+
+   if (interval < 0) {
+      return GLX_BAD_VALUE;
+   }
+
+   if (gc != NULL && gc->driContext) {
+      __GLXscreenConfigs *const psc = GetGLXScreenConfigs(gc->currentDpy,
+                                                          gc->screen);
+
+      if ((psc != NULL) && (psc->driScreen != NULL)) {
+         __GLXDRIdrawable *pdraw =
+            GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL);
+         if (psc->swapControl != NULL && pdraw != NULL) {
+            psc->swapControl->setSwapInterval(pdraw->driDrawable, interval);
+            return 0;
+         }
+      }
+   }
+#else
+   (void) interval;
+#endif
+
+   return GLX_BAD_CONTEXT;
+}
+
+
+static int
+__glXGetSwapIntervalMESA(void)
+{
+#ifdef __DRI_SWAP_CONTROL
+   GLXContext gc = __glXGetCurrentContext();
+
+   if (gc != NULL && gc->driContext) {
+      __GLXscreenConfigs *const psc = GetGLXScreenConfigs(gc->currentDpy,
+                                                          gc->screen);
+
+      if ((psc != NULL) && (psc->driScreen != NULL)) {
+         __GLXDRIdrawable *pdraw =
+            GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL);
+         if (psc->swapControl != NULL && pdraw != NULL) {
+            return psc->swapControl->getSwapInterval(pdraw->driDrawable);
+         }
+      }
+   }
+#endif
+
+   return 0;
+}
+
+
+/*
+** GLX_MESA_swap_frame_usage
+*/
+
+static GLint
+__glXBeginFrameTrackingMESA(Display * dpy, GLXDrawable drawable)
+{
+   int status = GLX_BAD_CONTEXT;
+#ifdef __DRI_FRAME_TRACKING
+   int screen = 0;
+   __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen);
+   __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen);
+
+   if (pdraw != NULL && psc->frameTracking != NULL)
+      status = psc->frameTracking->frameTracking(pdraw->driDrawable, GL_TRUE);
+#else
+   (void) dpy;
+   (void) drawable;
+#endif
+   return status;
+}
+
+
+static GLint
+__glXEndFrameTrackingMESA(Display * dpy, GLXDrawable drawable)
+{
+   int status = GLX_BAD_CONTEXT;
+#ifdef __DRI_FRAME_TRACKING
+   int screen = 0;
+   __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen);
+   __GLXscreenConfigs *psc = GetGLXScreenConfigs(dpy, screen);
+
+   if (pdraw != NULL && psc->frameTracking != NULL)
+      status = psc->frameTracking->frameTracking(pdraw->driDrawable,
+                                                 GL_FALSE);
+#else
+   (void) dpy;
+   (void) drawable;
+#endif
+   return status;
+}
+
+
+static GLint
+__glXGetFrameUsageMESA(Display * dpy, GLXDrawable drawable, GLfloat * usage)
+{
+   int status = GLX_BAD_CONTEXT;
+#ifdef __DRI_FRAME_TRACKING
+   int screen = 0;
+   __GLXDRIdrawable *const pdraw = GetGLXDRIDrawable(dpy, drawable, &screen);
+   __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen);
+
+   if (pdraw != NULL && psc->frameTracking != NULL) {
+      int64_t sbc, missedFrames;
+      float lastMissedUsage;
+
+      status = psc->frameTracking->queryFrameTracking(pdraw->driDrawable,
+                                                      &sbc,
+                                                      &missedFrames,
+                                                      &lastMissedUsage,
+                                                      usage);
+   }
+#else
+   (void) dpy;
+   (void) drawable;
+   (void) usage;
+#endif
+   return status;
+}
+
+
+static GLint
+__glXQueryFrameTrackingMESA(Display * dpy, GLXDrawable drawable,
+                            int64_t * sbc, int64_t * missedFrames,
+                            GLfloat * lastMissedUsage)
+{
+   int status = GLX_BAD_CONTEXT;
+#ifdef __DRI_FRAME_TRACKING
+   int screen = 0;
+   __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen);
+   __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen);
+
+   if (pdraw != NULL && psc->frameTracking != NULL) {
+      float usage;
+
+      status = psc->frameTracking->queryFrameTracking(pdraw->driDrawable,
+                                                      sbc, missedFrames,
+                                                      lastMissedUsage,
+                                                      &usage);
+   }
+#else
+   (void) dpy;
+   (void) drawable;
+   (void) sbc;
+   (void) missedFrames;
+   (void) lastMissedUsage;
+#endif
+   return status;
+}
+
+
+/*
+** GLX_SGI_video_sync
+*/
+static int
+__glXGetVideoSyncSGI(unsigned int *count)
+{
+   /* FIXME: Looking at the GLX_SGI_video_sync spec in the extension registry,
+    * FIXME: there should be a GLX encoding for this call.  I can find no
+    * FIXME: documentation for the GLX encoding.
+    */
+#ifdef __DRI_MEDIA_STREAM_COUNTER
+   GLXContext gc = __glXGetCurrentContext();
+
+
+   if (gc != NULL && gc->driContext) {
+      __GLXscreenConfigs *const psc = GetGLXScreenConfigs(gc->currentDpy,
+                                                          gc->screen);
+      if (psc->msc && psc->driScreen) {
+         __GLXDRIdrawable *pdraw =
+            GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL);
+         int64_t temp;
+         int ret;
+
+         ret = (*psc->msc->getDrawableMSC) (psc->__driScreen,
+                                            pdraw->driDrawable, &temp);
+         *count = (unsigned) temp;
+
+         return (ret == 0) ? 0 : GLX_BAD_CONTEXT;
+      }
+   }
+#else
+   (void) count;
+#endif
+   return GLX_BAD_CONTEXT;
+}
+
+static int
+__glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count)
+{
+#ifdef __DRI_MEDIA_STREAM_COUNTER
+   GLXContext gc = __glXGetCurrentContext();
+
+   if (divisor <= 0 || remainder < 0)
+      return GLX_BAD_VALUE;
+
+   if (gc != NULL && gc->driContext) {
+      __GLXscreenConfigs *const psc = GetGLXScreenConfigs(gc->currentDpy,
+                                                          gc->screen);
+      if (psc->msc != NULL && psc->driScreen) {
+         __GLXDRIdrawable *pdraw =
+            GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL);
+         int ret;
+         int64_t msc;
+         int64_t sbc;
+
+         ret = (*psc->msc->waitForMSC) (pdraw->driDrawable, 0,
+                                        divisor, remainder, &msc, &sbc);
+         *count = (unsigned) msc;
+         return (ret == 0) ? 0 : GLX_BAD_CONTEXT;
+      }
+   }
+#else
+   (void) count;
+#endif
+   return GLX_BAD_CONTEXT;
+}
+
+#endif /* __APPLE__ */
+
+/*
 ** GLX_SGIX_fbconfig
 ** Many of these functions are aliased to GLX 1.3 entry points in the 
 ** GLX_functions table.
@@ -1528,37 +2332,39 @@
           (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)
 {
+#ifndef __APPLE__
    xGLXVendorPrivateWithReplyReq *vpreq;
    xGLXCreateGLXPixmapWithConfigSGIXReq *req;
    GLXPixmap xid = None;
    CARD8 opcode;
+   __GLXscreenConfigs *psc;
+#endif
    const __GLcontextModes *const fbconfig = (__GLcontextModes *) config;
-   __GLXscreenConfigs *psc;
 
 
    if ((dpy == NULL) || (config == NULL)) {
       return None;
    }
-
-   if (apple_glx_pixmap_create(dpy, fbconfig->screen, pixmap, fbconfig))
+#ifdef __APPLE__
+   if(apple_glx_pixmap_create(dpy, fbconfig->screen, pixmap, fbconfig))
       return None;
-
    return pixmap;
+#else
 
-
    psc = GetGLXScreenConfigs(dpy, fbconfig->screen);
    if ((psc != NULL)
        && __glXExtensionBitIsEnabled(psc, SGIX_fbconfig_bit)) {
@@ -1585,6 +2391,7 @@
    }
 
    return xid;
+#endif
 }
 
 PUBLIC GLXContext
@@ -1616,7 +2423,7 @@
 glXGetFBConfigFromVisualSGIX(Display * dpy, XVisualInfo * vis)
 {
    __GLXdisplayPrivate *priv;
-   __GLXscreenConfigs *psc;
+   __GLXscreenConfigs *psc = NULL;
 
    if ((GetGLXPrivScreenConfig(dpy, vis->screen, &priv, &psc) != Success)
        && __glXExtensionBitIsEnabled(psc, SGIX_fbconfig_bit)
@@ -1628,9 +2435,477 @@
    return NULL;
 }
 
-#if 0                           /* AppleSGLX may someday need to support this for X11 OpenGL
-                                   compositing managers. */
+#ifndef __APPLE__
+/*
+** GLX_SGIX_swap_group
+*/
+static void
+__glXJoinSwapGroupSGIX(Display * dpy, GLXDrawable drawable,
+                       GLXDrawable member)
+{
+   (void) dpy;
+   (void) drawable;
+   (void) member;
+}
+
+
+/*
+** GLX_SGIX_swap_barrier
+*/
+static void
+__glXBindSwapBarrierSGIX(Display * dpy, GLXDrawable drawable, int barrier)
+{
+   (void) dpy;
+   (void) drawable;
+   (void) barrier;
+}
+
+static Bool
+__glXQueryMaxSwapBarriersSGIX(Display * dpy, int screen, int *max)
+{
+   (void) dpy;
+   (void) screen;
+   (void) max;
+   return False;
+}
+
+
+/*
+** GLX_OML_sync_control
+*/
+static Bool
+__glXGetSyncValuesOML(Display * dpy, GLXDrawable drawable,
+                      int64_t * ust, int64_t * msc, int64_t * sbc)
+{
+#if defined(__DRI_SWAP_BUFFER_COUNTER) && defined(__DRI_MEDIA_STREAM_COUNTER)
+   __GLXdisplayPrivate *const priv = __glXInitialize(dpy);
+
+   if (priv != NULL) {
+      int i;
+      __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &i);
+      __GLXscreenConfigs *const psc = &priv->screenConfigs[i];
+
+      assert((pdraw == NULL) || (i != -1));
+      return ((pdraw && psc->sbc && psc->msc)
+              && ((*psc->msc->getMSC) (psc->driScreen, msc) == 0)
+              && ((*psc->sbc->getSBC) (pdraw->driDrawable, sbc) == 0)
+              && (__glXGetUST(ust) == 0));
+   }
+#else
+   (void) dpy;
+   (void) drawable;
+   (void) ust;
+   (void) msc;
+   (void) sbc;
+#endif
+   return False;
+}
+
+#ifdef GLX_DIRECT_RENDERING
+_X_HIDDEN GLboolean
+__driGetMscRateOML(__DRIdrawable * draw,
+                   int32_t * numerator, int32_t * denominator, void *private)
+{
+#ifdef XF86VIDMODE
+   __GLXscreenConfigs *psc;
+   XF86VidModeModeLine mode_line;
+   int dot_clock;
+   int i;
+   __GLXDRIdrawable *glxDraw = private;
+
+   psc = glxDraw->psc;
+   if (XF86VidModeQueryVersion(psc->dpy, &i, &i) &&
+       XF86VidModeGetModeLine(psc->dpy, psc->scr, &dot_clock, &mode_line)) {
+      unsigned n = dot_clock * 1000;
+      unsigned d = mode_line.vtotal * mode_line.htotal;
+
+# define V_INTERLACE 0x010
+# define V_DBLSCAN   0x020
+
+      if (mode_line.flags & V_INTERLACE)
+         n *= 2;
+      else if (mode_line.flags & V_DBLSCAN)
+         d *= 2;
+
+      /* The OML_sync_control spec requires that if the refresh rate is a
+       * whole number, that the returned numerator be equal to the refresh
+       * rate and the denominator be 1.
+       */
+
+      if (n % d == 0) {
+         n /= d;
+         d = 1;
+      }
+      else {
+         static const unsigned f[] = { 13, 11, 7, 5, 3, 2, 0 };
+
+         /* This is a poor man's way to reduce a fraction.  It's far from
+          * perfect, but it will work well enough for this situation.
+          */
+
+         for (i = 0; f[i] != 0; i++) {
+            while (n % f[i] == 0 && d % f[i] == 0) {
+               d /= f[i];
+               n /= f[i];
+            }
+         }
+      }
+
+      *numerator = n;
+      *denominator = d;
+
+      return True;
+   }
+   else
+      return False;
+#else
+   return False;
+#endif
+}
+#endif
+
 /**
+ * Determine the refresh rate of the specified drawable and display.
+ *
+ * \param dpy          Display whose refresh rate is to be determined.
+ * \param drawable     Drawable whose refresh rate is to be determined.
+ * \param numerator    Numerator of the refresh rate.
+ * \param demoninator  Denominator of the refresh rate.
+ * \return  If the refresh rate for the specified display and drawable could
+ *          be calculated, True is returned.  Otherwise False is returned.
+ *
+ * \note This function is implemented entirely client-side.  A lot of other
+ *       functionality is required to export GLX_OML_sync_control, so on
+ *       XFree86 this function can be called for direct-rendering contexts
+ *       when GLX_OML_sync_control appears in the client extension string.
+ */
+
+_X_HIDDEN GLboolean
+__glXGetMscRateOML(Display * dpy, GLXDrawable drawable,
+                   int32_t * numerator, int32_t * denominator)
+{
+#if defined( GLX_DIRECT_RENDERING ) && defined( XF86VIDMODE )
+   __GLXDRIdrawable *draw = GetGLXDRIDrawable(dpy, drawable, NULL);
+
+   if (draw == NULL)
+      return False;
+
+   return __driGetMscRateOML(draw->driDrawable, numerator, denominator, draw);
+#else
+   (void) dpy;
+   (void) drawable;
+   (void) numerator;
+   (void) denominator;
+#endif
+   return False;
+}
+
+
+static int64_t
+__glXSwapBuffersMscOML(Display * dpy, GLXDrawable drawable,
+                       int64_t target_msc, int64_t divisor, int64_t remainder)
+{
+#ifdef __DRI_SWAP_BUFFER_COUNTER
+   int screen;
+   __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen);
+   __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen);
+
+   /* The OML_sync_control spec says these should "generate a GLX_BAD_VALUE
+    * error", but it also says "It [glXSwapBuffersMscOML] will return a value
+    * of -1 if the function failed because of errors detected in the input
+    * parameters"
+    */
+   if (divisor < 0 || remainder < 0 || target_msc < 0)
+      return -1;
+   if (divisor > 0 && remainder >= divisor)
+      return -1;
+
+   if (pdraw != NULL && psc->counters != NULL)
+      return (*psc->sbc->swapBuffersMSC) (pdraw->driDrawable, target_msc,
+                                          divisor, remainder);
+
+#else
+   (void) dpy;
+   (void) drawable;
+   (void) target_msc;
+   (void) divisor;
+   (void) remainder;
+#endif
+   return 0;
+}
+
+
+static 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)
+{
+#ifdef __DRI_MEDIA_STREAM_COUNTER
+   int screen = 0;
+   __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen);
+   __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen);
+   int ret;
+
+   /* The OML_sync_control spec says these should "generate a GLX_BAD_VALUE
+    * error", but the return type in the spec is Bool.
+    */
+   if (divisor < 0 || remainder < 0 || target_msc < 0)
+      return False;
+   if (divisor > 0 && remainder >= divisor)
+      return False;
+
+   if (pdraw != NULL && psc->msc != NULL) {
+      ret = (*psc->msc->waitForMSC) (pdraw->driDrawable, target_msc,
+                                     divisor, remainder, msc, sbc);
+
+      /* __glXGetUST returns zero on success and non-zero on failure.
+       * This function returns True on success and False on failure.
+       */
+      return ((ret == 0) && (__glXGetUST(ust) == 0));
+   }
+#else
+   (void) dpy;
+   (void) drawable;
+   (void) target_msc;
+   (void) divisor;
+   (void) remainder;
+   (void) ust;
+   (void) msc;
+   (void) sbc;
+#endif
+   return False;
+}
+
+
+static Bool
+__glXWaitForSbcOML(Display * dpy, GLXDrawable drawable,
+                   int64_t target_sbc, int64_t * ust,
+                   int64_t * msc, int64_t * sbc)
+{
+#ifdef __DRI_SWAP_BUFFER_COUNTER
+   int screen;
+   __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen);
+   __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen);
+   int ret;
+
+   /* The OML_sync_control spec says this should "generate a GLX_BAD_VALUE
+    * error", but the return type in the spec is Bool.
+    */
+   if (target_sbc < 0)
+      return False;
+
+   if (pdraw != NULL && psc->sbc != NULL) {
+      ret =
+         (*psc->sbc->waitForSBC) (pdraw->driDrawable, target_sbc, msc, sbc);
+
+      /* __glXGetUST returns zero on success and non-zero on failure.
+       * This function returns True on success and False on failure.
+       */
+      return ((ret == 0) && (__glXGetUST(ust) == 0));
+   }
+#else
+   (void) dpy;
+   (void) drawable;
+   (void) target_sbc;
+   (void) ust;
+   (void) msc;
+   (void) sbc;
+#endif
+   return False;
+}
+
+
+/**
+ * GLX_MESA_allocate_memory
+ */
+/*@{*/
+
+PUBLIC void *
+glXAllocateMemoryMESA(Display * dpy, int scrn,
+                      size_t size, float readFreq,
+                      float writeFreq, float priority)
+{
+#ifdef __DRI_ALLOCATE
+   __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, scrn);
+
+   if (psc && psc->allocate)
+      return (*psc->allocate->allocateMemory) (psc->__driScreen, size,
+                                               readFreq, writeFreq, priority);
+
+#else
+   (void) dpy;
+   (void) scrn;
+   (void) size;
+   (void) readFreq;
+   (void) writeFreq;
+   (void) priority;
+#endif /* GLX_DIRECT_RENDERING */
+
+   return NULL;
+}
+
+
+PUBLIC void
+glXFreeMemoryMESA(Display * dpy, int scrn, void *pointer)
+{
+#ifdef __DRI_ALLOCATE
+   __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, scrn);
+
+   if (psc && psc->allocate)
+      (*psc->allocate->freeMemory) (psc->__driScreen, pointer);
+
+#else
+   (void) dpy;
+   (void) scrn;
+   (void) pointer;
+#endif /* GLX_DIRECT_RENDERING */
+}
+
+
+PUBLIC GLuint
+glXGetMemoryOffsetMESA(Display * dpy, int scrn, const void *pointer)
+{
+#ifdef __DRI_ALLOCATE
+   __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, scrn);
+
+   if (psc && psc->allocate)
+      return (*psc->allocate->memoryOffset) (psc->__driScreen, pointer);
+
+#else
+   (void) dpy;
+   (void) scrn;
+   (void) pointer;
+#endif /* GLX_DIRECT_RENDERING */
+
+   return ~0L;
+}
+
+/*@}*/
+
+
+/**
+ * Mesa extension stubs.  These will help reduce portability problems.
+ */
+/*@{*/
+
+/**
+ * Release all buffers associated with the specified GLX drawable.
+ *
+ * \todo
+ * This function was intended for stand-alone Mesa.  The issue there is that
+ * the library doesn't get any notification when a window is closed.  In
+ * DRI there is a similar but slightly different issue.  When GLX 1.3 is
+ * supported, there are 3 different functions to destroy a drawable.  It
+ * should be possible to create GLX protocol (or have it determine which
+ * protocol to use based on the type of the drawable) to have one function
+ * do the work of 3.  For the direct-rendering case, this function could
+ * just call the driver's \c __DRIdrawableRec::destroyDrawable function.
+ * This would reduce the frequency with which \c __driGarbageCollectDrawables
+ * would need to be used.  This really should be done as part of the new DRI
+ * interface work.
+ *
+ * \sa http://oss.sgi.com/projects/ogl-sample/registry/MESA/release_buffers.txt
+ *     __driGarbageCollectDrawables
+ *     glXDestroyGLXPixmap
+ *     glXDestroyPbuffer glXDestroyPixmap glXDestroyWindow
+ *     glXDestroyGLXPbufferSGIX glXDestroyGLXVideoSourceSGIX
+ */
+static Bool
+__glXReleaseBuffersMESA(Display * dpy, GLXDrawable d)
+{
+   (void) dpy;
+   (void) d;
+   return False;
+}
+
+
+PUBLIC GLXPixmap
+glXCreateGLXPixmapMESA(Display * dpy, XVisualInfo * visual,
+                       Pixmap pixmap, Colormap cmap)
+{
+   (void) dpy;
+   (void) visual;
+   (void) pixmap;
+   (void) cmap;
+   return 0;
+}
+
+/*@}*/
+
+
+/**
+ * GLX_MESA_copy_sub_buffer
+ */
+#define X_GLXvop_CopySubBufferMESA 5154 /* temporary */
+static void
+__glXCopySubBufferMESA(Display * dpy, GLXDrawable drawable,
+                       int x, int y, int width, int height)
+{
+   xGLXVendorPrivateReq *req;
+   GLXContext gc;
+   GLXContextTag tag;
+   CARD32 *drawable_ptr;
+   INT32 *x_ptr, *y_ptr, *w_ptr, *h_ptr;
+   CARD8 opcode;
+
+#ifdef __DRI_COPY_SUB_BUFFER
+   int screen;
+   __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen);
+   if (pdraw != NULL) {
+      __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen);
+      if (psc->driScreen->copySubBuffer != NULL) {
+         glFlush();
+         (*psc->driScreen->copySubBuffer) (pdraw, x, y, width, height);
+      }
+
+      return;
+   }
+#endif
+
+   opcode = __glXSetupForCommand(dpy);
+   if (!opcode)
+      return;
+
+   /*
+    ** The calling thread may or may not have a current context.  If it
+    ** does, send the context tag so the server can do a flush.
+    */
+   gc = __glXGetCurrentContext();
+   if ((gc != NULL) && (dpy == gc->currentDpy) &&
+       ((drawable == gc->currentDrawable) ||
+        (drawable == gc->currentReadable))) {
+      tag = gc->currentContextTag;
+   }
+   else {
+      tag = 0;
+   }
+
+   LockDisplay(dpy);
+   GetReqExtra(GLXVendorPrivate, sizeof(CARD32) + sizeof(INT32) * 4, req);
+   req->reqType = opcode;
+   req->glxCode = X_GLXVendorPrivate;
+   req->vendorCode = X_GLXvop_CopySubBufferMESA;
+   req->contextTag = tag;
+
+   drawable_ptr = (CARD32 *) (req + 1);
+   x_ptr = (INT32 *) (drawable_ptr + 1);
+   y_ptr = (INT32 *) (drawable_ptr + 2);
+   w_ptr = (INT32 *) (drawable_ptr + 3);
+   h_ptr = (INT32 *) (drawable_ptr + 4);
+
+   *drawable_ptr = drawable;
+   *x_ptr = x;
+   *y_ptr = y;
+   *w_ptr = width;
+   *h_ptr = height;
+
+   UnlockDisplay(dpy);
+   SyncHandle();
+}
+
+
+/**
  * GLX_EXT_texture_from_pixmap
  */
 /*@{*/
@@ -1660,11 +2935,20 @@
    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) {
+         if (pdraw->psc->texBuffer->base.version >= 2 &&
+             pdraw->psc->texBuffer->setTexBuffer2 != NULL) {
+            (*pdraw->psc->texBuffer->setTexBuffer2) (gc->__driContext,
+                                                     pdraw->textureTarget,
+                                                     pdraw->textureFormat,
+                                                     pdraw->driDrawable);
+         }
+         else {
+            (*pdraw->psc->texBuffer->setTexBuffer) (gc->__driContext,
+                                                    pdraw->textureTarget,
+                                                    pdraw->driDrawable);
+         }
+      }
       return;
    }
 #endif
@@ -1742,12 +3026,12 @@
 
 /*@}*/
 
-#endif
+#endif /* __APPLE__ */
 
 /**
  * \c strdup is actually not a standard ANSI C or POSIX routine.
  * Irix will not define it if ANSI mode is in effect.
- * 
+ *
  * \sa strdup
  */
 _X_HIDDEN char *
@@ -1821,7 +3105,7 @@
    GLX_FUNCTION(glXQueryDrawable),
    GLX_FUNCTION(glXSelectEvent),
 
-#if 0
+#ifndef __APPLE__
    /*** GLX_SGI_swap_control ***/
    GLX_FUNCTION2(glXSwapIntervalSGI, __glXSwapIntervalSGI),
 
@@ -1849,7 +3133,7 @@
    GLX_FUNCTION2(glXGetVisualFromFBConfigSGIX, glXGetVisualFromFBConfig),
    GLX_FUNCTION(glXGetFBConfigFromVisualSGIX),
 
-#if 0
+#ifndef __APPLE__
    /*** GLX_SGIX_pbuffer ***/
    GLX_FUNCTION(glXCreateGLXPbufferSGIX),
    GLX_FUNCTION(glXDestroyGLXPbufferSGIX),
@@ -1895,7 +3179,7 @@
    /*** GLX 1.4 ***/
    GLX_FUNCTION2(glXGetProcAddress, glXGetProcAddressARB),
 
-#if 0
+#ifndef __APPLE__
    /*** GLX_OML_sync_control ***/
    GLX_FUNCTION2(glXWaitForSbcOML, __glXWaitForSbcOML),
    GLX_FUNCTION2(glXWaitForMscOML, __glXWaitForMscOML),
@@ -1917,7 +3201,22 @@
    {NULL, NULL}                 /* end of list */
 };
 
+#ifndef __APPLE__
+static const GLvoid *
+get_glx_proc_address(const char *funcName)
+{
+   GLuint i;
 
+   /* try static functions */
+   for (i = 0; GLX_functions[i].Name; i++) {
+      if (strcmp(GLX_functions[i].Name, funcName) == 0)
+         return GLX_functions[i].Address;
+   }
+
+   return NULL;
+}
+#endif
+
 /**
  * Get the address of a named GL function.  This is the pre-GLX 1.4 name for
  * \c glXGetProcAddress.
@@ -1932,15 +3231,22 @@
    typedef void (*gl_function) (void);
    gl_function f;
 
+
    /* Search the table of GLX and internal functions first.  If that
     * fails and the supplied name could be a valid core GL name, try
     * searching the core GL function table.  This check is done to prevent
     * DRI based drivers from searching the core GL function table for
     * internal API functions.
     */
-
+#ifdef __APPLE__
    f = (gl_function) apple_glx_get_proc_address(procName);
-
+#else
+   f = (gl_function) get_glx_proc_address((const char *) procName);
+   if ((f == NULL) && (procName[0] == 'g') && (procName[1] == 'l')
+       && (procName[2] != 'X')) {
+      f = (gl_function) _glapi_get_proc_address((const char *) procName);
+   }
+#endif
    return f;
 }
 
@@ -1973,7 +3279,7 @@
  *
  * \param ust Location to store the 64-bit UST
  * \returns Zero on success or a negative errno value on failure.
- * 
+ *
  * \sa glXGetProcAddress, PFNGLXGETUSTPROC
  *
  * \since Internal API version 20030317.

Modified: AppleSGLX/trunk/glxcurrent.c
===================================================================
--- AppleSGLX/trunk/glxcurrent.c	2009-12-21 21:50:23 UTC (rev 390)
+++ AppleSGLX/trunk/glxcurrent.c	2009-12-24 01:48:39 UTC (rev 391)
@@ -33,12 +33,25 @@
  * Client-side GLX interface for current context management.
  */
 
-#include <stdlib.h>
+#ifdef PTHREADS
 #include <pthread.h>
+#endif
+
 #include "glxclient.h"
+#ifdef __APPLE__
+#include <stdlib.h>
+
 #include "apple_glx.h"
 #include "apple_glx_context.h"
+#else
+#include "glapi.h"
+#include "indirect_init.h"
 
+#ifdef GLX_DIRECT_RENDERING
+#include "xf86dri.h"
+#endif
+#endif
+
 /*
 ** We setup some dummy structures here so that the API can be used
 ** even if no context is current.
@@ -60,16 +73,47 @@
    sizeof(dummyBuffer),
 };
 
+
+#ifndef __APPLE__
 /*
+** All indirect rendering contexts will share the same indirect dispatch table.
+*/
+static __GLapi *IndirectAPI = NULL;
+#endif
+
+/*
  * Current context management and locking
  */
-static pthread_once_t once_control = PTHREAD_ONCE_INIT;
 
+#if defined( PTHREADS )
+
 _X_HIDDEN pthread_mutex_t __glXmutex = PTHREAD_MUTEX_INITIALIZER;
 
+# if defined( GLX_USE_TLS )
+
 /**
+ * Per-thread GLX context pointer.
+ *
+ * \c __glXSetCurrentContext is written is such a way that this pointer can
+ * \b never be \c NULL.  This is important!  Because of this
+ * \c __glXGetCurrentContext can be implemented as trivial macro.
+ */
+__thread void *__glX_tls_Context __attribute__ ((tls_model("initial-exec")))
+   = &dummyContext;
+
+_X_HIDDEN void
+__glXSetCurrentContext(__GLXcontext * c)
+{
+   __glX_tls_Context = (c != NULL) ? c : &dummyContext;
+}
+
+# else
+
+static pthread_once_t once_control = PTHREAD_ONCE_INIT;
+
+/**
  * Per-thread data key.
- * 
+ *
  * Once \c init_thread_data has been called, the per-thread data key will
  * take a value of \c NULL.  As each new thread is created the default
  * value, in that thread, will be \c NULL.
@@ -78,7 +122,7 @@
 
 /**
  * Initialize the per-thread data key.
- * 
+ *
  * This function is called \b exactly once per-process (not per-thread!) to
  * initialize the per-thread data key.  This is ideally done using the
  * \c pthread_once mechanism.
@@ -88,7 +132,7 @@
 {
    if (pthread_key_create(&ContextTSD, NULL) != 0) {
       perror("pthread_key_create");
-      exit(EXIT_FAILURE);
+      exit(-1);
    }
 }
 
@@ -110,11 +154,29 @@
    return (v == NULL) ? &dummyContext : (__GLXcontext *) v;
 }
 
+# endif /* defined( GLX_USE_TLS ) */
 
+#elif defined( THREADS )
+
+#error Unknown threading method specified.
+
+#else
+
+/* not thread safe */
+_X_HIDDEN __GLXcontext *__glXcurrentContext = &dummyContext;
+
+#endif
+
+
 _X_HIDDEN void
 __glXSetCurrentContextNull(void)
 {
    __glXSetCurrentContext(&dummyContext);
+#ifndef __APPLE__
+#ifdef GLX_DIRECT_RENDERING
+   _glapi_set_dispatch(NULL);   /* no-op functions */
+#endif
+#endif
 }
 
 
@@ -140,70 +202,349 @@
    return gc->currentDrawable;
 }
 
+
+#ifndef __APPLE__
+/************************************************************************/
+
+/**
+ * Sends a GLX protocol message to the specified display to make the context
+ * and the drawables current.
+ *
+ * \param dpy     Display to send the message to.
+ * \param opcode  Major opcode value for the display.
+ * \param gc_id   Context tag for the context to be made current.
+ * \param draw    Drawable ID for the "draw" drawable.
+ * \param read    Drawable ID for the "read" drawable.
+ * \param reply   Space to store the X-server's reply.
+ *
+ * \warning
+ * This function assumes that \c dpy is locked with \c LockDisplay on entry.
+ */
 static Bool
+SendMakeCurrentRequest(Display * dpy, CARD8 opcode,
+                       GLXContextID gc_id, GLXContextTag gc_tag,
+                       GLXDrawable draw, GLXDrawable read,
+                       xGLXMakeCurrentReply * reply)
+{
+   Bool ret;
+
+
+   LockDisplay(dpy);
+
+   if (draw == read) {
+      xGLXMakeCurrentReq *req;
+
+      GetReq(GLXMakeCurrent, req);
+      req->reqType = opcode;
+      req->glxCode = X_GLXMakeCurrent;
+      req->drawable = draw;
+      req->context = gc_id;
+      req->oldContextTag = gc_tag;
+   }
+   else {
+      __GLXdisplayPrivate *priv = __glXInitialize(dpy);
+
+      /* If the server can support the GLX 1.3 version, we should
+       * perfer that.  Not only that, some servers support GLX 1.3 but
+       * not the SGI extension.
+       */
+
+      if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) {
+         xGLXMakeContextCurrentReq *req;
+
+         GetReq(GLXMakeContextCurrent, req);
+         req->reqType = opcode;
+         req->glxCode = X_GLXMakeContextCurrent;
+         req->drawable = draw;
+         req->readdrawable = read;
+         req->context = gc_id;
+         req->oldContextTag = gc_tag;
+      }
+      else {
+         xGLXVendorPrivateWithReplyReq *vpreq;
+         xGLXMakeCurrentReadSGIReq *req;
+
+         GetReqExtra(GLXVendorPrivateWithReply,
+                     sz_xGLXMakeCurrentReadSGIReq -
+                     sz_xGLXVendorPrivateWithReplyReq, vpreq);
+         req = (xGLXMakeCurrentReadSGIReq *) vpreq;
+         req->reqType = opcode;
+         req->glxCode = X_GLXVendorPrivateWithReply;
+         req->vendorCode = X_GLXvop_MakeCurrentReadSGI;
+         req->drawable = draw;
+         req->readable = read;
+         req->context = gc_id;
+         req->oldContextTag = gc_tag;
+      }
+   }
+
+   ret = _XReply(dpy, (xReply *) reply, 0, False);
+
+   UnlockDisplay(dpy);
+   SyncHandle();
+
+   return ret;
+}
+
+
+#ifdef GLX_DIRECT_RENDERING
+static __GLXDRIdrawable *
+FetchDRIDrawable(Display * dpy, GLXDrawable glxDrawable, GLXContext gc)
+{
+   __GLXdisplayPrivate *const priv = __glXInitialize(dpy);
+   __GLXDRIdrawable *pdraw;
+   __GLXscreenConfigs *psc;
+
+   if (priv == NULL)
+      return NULL;
+
+   psc = &priv->screenConfigs[gc->screen];
+   if (psc->drawHash == NULL)
+      return NULL;
+
+   if (__glxHashLookup(psc->drawHash, glxDrawable, (void *) &pdraw) == 0)
+      return pdraw;
+
+   pdraw = psc->driScreen->createDrawable(psc, glxDrawable,
+                                          glxDrawable, gc->mode);
+   if (__glxHashInsert(psc->drawHash, glxDrawable, pdraw)) {
+      (*pdraw->destroyDrawable) (pdraw);
+      return NULL;
+   }
+
+   return pdraw;
+}
+#endif /* GLX_DIRECT_RENDERING */
+
+static void
+__glXGenerateError(Display * dpy, GLXContext gc, XID resource,
+                   BYTE errorCode, CARD16 minorCode)
+{
+   xError error;
+
+   error.errorCode = errorCode;
+   error.resourceID = resource;
+   error.sequenceNumber = dpy->request;
+   error.type = X_Error;
+   error.majorCode = gc->majorOpcode;
+   error.minorCode = minorCode;
+   _XError(dpy, &error);
+}
+
+#endif /* __APPLE__ */
+
+/**
+ * Make a particular context current.
+ *
+ * \note This is in this file so that it can access dummyContext.
+ */
+static Bool
 MakeContextCurrent(Display * dpy, GLXDrawable draw,
-                   GLXDrawable read, GLXContext gc, Bool pre13)
+                   GLXDrawable read, GLXContext gc)
 {
    const GLXContext oldGC = __glXGetCurrentContext();
-   bool error;
-
-   error = apple_glx_make_current_context(dpy,
-                                          (oldGC && oldGC != &dummyContext) ?
-                                          oldGC->apple : NULL,
-                                          gc ? gc->apple : NULL, draw);
-
+#ifdef __APPLE__
+   bool error = apple_glx_make_current_context(dpy, 
+                   (oldGC && oldGC != &dummyContext) ? oldGC->apple : NULL, 
+                   gc ? gc->apple : NULL, draw);
+   
    apple_glx_diagnostic("%s: error %s\n", __func__, error ? "YES" : "NO");
+   if(error)
+      return GL_FALSE;
+#else
+   xGLXMakeCurrentReply reply;
+   const CARD8 opcode = __glXSetupForCommand(dpy);
+   const CARD8 oldOpcode = ((gc == oldGC) || (oldGC == &dummyContext))
+      ? opcode : __glXSetupForCommand(oldGC->currentDpy);
+   Bool bindReturnValue;
+   __GLXattribute *state;
 
-   if (error)
+   if (!opcode || !oldOpcode) {
       return GL_FALSE;
+   }
 
+   /* Make sure that the new context has a nonzero ID.  In the request,
+    * a zero context ID is used only to mean that we bind to no current
+    * context.
+    */
+   if ((gc != NULL) && (gc->xid == None)) {
+      return GL_FALSE;
+   }
+
+   if (gc == NULL && (draw != None || read != None)) {
+      __glXGenerateError(dpy, gc, (draw != None) ? draw : read,
+                         BadMatch, X_GLXMakeContextCurrent);
+      return False;
+   }
+   if (gc != NULL && (draw == None || read == None)) {
+      __glXGenerateError(dpy, gc, None, BadMatch, X_GLXMakeContextCurrent);
+      return False;
+   }
+
+   _glapi_check_multithread();
+
+   if (gc != NULL && gc->thread_id != 0 && gc->thread_id != _glthread_GetID()) {
+      __glXGenerateError(dpy, gc, gc->xid,
+                         BadAccess, X_GLXMakeContextCurrent);
+      return False;
+   }
+
+#ifdef GLX_DIRECT_RENDERING
+   /* Bind the direct rendering context to the drawable */
+   if (gc && gc->driContext) {
+      __GLXDRIdrawable *pdraw = FetchDRIDrawable(dpy, draw, gc);
+      __GLXDRIdrawable *pread = FetchDRIDrawable(dpy, read, gc);
+
+      if ((pdraw == NULL) || (pread == NULL)) {
+         __glXGenerateError(dpy, gc, (pdraw == NULL) ? draw : read,
+                            GLXBadDrawable, X_GLXMakeContextCurrent);
+         return False;
+      }
+
+      bindReturnValue =
+         (gc->driContext->bindContext) (gc->driContext, pdraw, pread);
+   }
+   else if (!gc && oldGC && oldGC->driContext) {
+      bindReturnValue = True;
+   }
+   else
+#endif
+   {
+      /* Send a glXMakeCurrent request to bind the new context. */
+      bindReturnValue =
+         SendMakeCurrentRequest(dpy, opcode, gc ? gc->xid : None,
+                                ((dpy != oldGC->currentDpy)
+                                 || oldGC->isDirect)
+                                ? None : oldGC->currentContextTag, draw, read,
+                                &reply);
+   }
+
+
+   if (!bindReturnValue) {
+      return False;
+   }
+
+#ifdef GLX_DIRECT_RENDERING
+   if ((dpy != oldGC->currentDpy || (gc && gc->driContext)) &&
+       !oldGC->isDirect && oldGC != &dummyContext) {
+#else
+   if ((dpy != oldGC->currentDpy) && oldGC != &dummyContext) {
+#endif
+      xGLXMakeCurrentReply dummy_reply;
+
+      /* We are either switching from one dpy to another and have to
+       * send a request to the previous dpy to unbind the previous
+       * context, or we are switching away from a indirect context to
+       * a direct context and have to send a request to the dpy to
+       * unbind the previous context.
+       */
+      (void) SendMakeCurrentRequest(oldGC->currentDpy, oldOpcode, None,
+                                    oldGC->currentContextTag, None, None,
+                                    &dummy_reply);
+   }
+#ifdef GLX_DIRECT_RENDERING
+   else if (oldGC->driContext && oldGC != gc) {
+      oldGC->driContext->unbindContext(oldGC->driContext);
+   }
+#endif
+
+#endif /* __APPLE__ */
+
+   /* Update our notion of what is current */
    __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;
+      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;
-
+         oldGC->thread_id = 0;
+#ifdef __APPLE__
+         
          /*
           * At this point we should check if the context has been
           * through glXDestroyContext, and redestroy it if so.
           */
-         if (oldGC->do_destroy) {
+         if(oldGC->do_destroy) {
             __glXUnlock();
             /* glXDestroyContext uses the same global lock. */
             glXDestroyContext(dpy, oldGC);
             __glXLock();
+#else
+         if (oldGC->xid == None) {
+            /* We are switching away from a context that was
+             * previously destroyed, so we need to free the memory
+             * for the old handle.
+             */
+#ifdef GLX_DIRECT_RENDERING
+            /* Destroy the old direct rendering context */
+            if (oldGC->driContext) {
+               oldGC->driContext->destroyContext(oldGC->driContext,
+                                                 oldGC->psc,
+                                                 oldGC->createDpy);
+               oldGC->driContext = NULL;
+            }
+#endif
+            __glXFreeContext(oldGC);
+#endif /* __APPLE__ */
          }
       }
-
       if (gc) {
          __glXSetCurrentContext(gc);
 
          gc->currentDpy = dpy;
          gc->currentDrawable = draw;
          gc->currentReadable = read;
+#ifndef __APPLE__
+         gc->thread_id = _glthread_GetID();
+
+#ifdef GLX_DIRECT_RENDERING
+         if (!gc->driContext) {
+#endif
+            if (!IndirectAPI)
+               IndirectAPI = __glXNewIndirectAPI();
+            _glapi_set_dispatch(IndirectAPI);
+
+#ifdef GLX_USE_APPLEGL
+            do {
+               extern void XAppleDRIUseIndirectDispatch(void);
+               XAppleDRIUseIndirectDispatch();
+            } while (0);
+#endif
+
+            state = (__GLXattribute *) (gc->client_state_private);
+
+            gc->currentContextTag = reply.contextTag;
+            if (state->array_state == NULL) {
+               (void) glGetString(GL_EXTENSIONS);
+               (void) glGetString(GL_VERSION);
+               __glXInitVertexArrayState(gc);
+            }
+#ifdef GLX_DIRECT_RENDERING
+         }
+         else {
+            gc->currentContextTag = -1;
+         }
+#endif
+#endif /* __APPLE__ */
       }
       else {
          __glXSetCurrentContextNull();
       }
    }
    __glXUnlock();
-
    return GL_TRUE;
 }
 
@@ -211,15 +552,15 @@
 PUBLIC Bool
 glXMakeCurrent(Display * dpy, GLXDrawable draw, GLXContext gc)
 {
-   return MakeContextCurrent(dpy, draw, draw, gc, True);
+   return MakeContextCurrent(dpy, draw, draw, gc);
 }
 
 PUBLIC
 GLX_ALIAS(Bool, glXMakeCurrentReadSGI,
           (Display * dpy, GLXDrawable d, GLXDrawable r, GLXContext ctx),
-          (dpy, d, r, ctx, False), MakeContextCurrent)
+          (dpy, d, r, ctx), 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), MakeContextCurrent)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/xquartz-changes/attachments/20091223/4d3e6fb8/attachment-0001.html>


More information about the Xquartz-changes mailing list