apple/glx/log: added missing va_end() after va_copy()
[mesa.git] / src / glx / glxcurrent.c
index f2e386597ad657f6e7b7c165b29ec03ce0d51cde..2b9c708c3ee6fc97fd11fa503bbdbbce54a21eb6 100644 (file)
@@ -36,8 +36,8 @@
 #include <pthread.h>
 
 #include "glxclient.h"
-
 #include "glapi.h"
+#include "glx_error.h"
 
 /*
 ** We setup some dummy structures here so that the API can be used
@@ -165,21 +165,6 @@ glXGetCurrentDrawable(void)
    return gc->currentDrawable;
 }
 
-static void
-__glXGenerateError(Display * dpy, XID resource,
-                   BYTE errorCode, CARD16 minorCode)
-{
-   xError error;
-
-   error.errorCode = errorCode;
-   error.resourceID = resource;
-   error.sequenceNumber = dpy->request;
-   error.type = X_Error;
-   error.majorCode = __glXSetupForCommand(dpy);
-   error.minorCode = minorCode;
-   _XError(dpy, &error);
-}
-
 /**
  * Make a particular context current.
  *
@@ -209,6 +194,13 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw,
       return True;
    }
 
+   /* can't have only one be 0 */
+   if (!!draw != !!read) {
+      __glXUnlock();
+      __glXSendError(dpy, BadMatch, None, X_GLXMakeContextCurrent, True);
+      return False;
+   }
+
    if (oldGC != &dummyContext) {
       if (--oldGC->thread_refcount == 0) {
         oldGC->vtable->unbind(oldGC, gc);
@@ -228,7 +220,8 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw,
       if (gc->vtable->bind(gc, oldGC, draw, read) != Success) {
          __glXSetCurrentContextNull();
          __glXUnlock();
-         __glXGenerateError(dpy, None, GLXBadContext, X_GLXMakeContextCurrent);
+         __glXSendError(dpy, GLXBadContext, None, X_GLXMakeContextCurrent,
+                        False);
          return GL_FALSE;
       }
 
@@ -252,6 +245,18 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw,
 
    __glXUnlock();
 
+   /* The indirect vertex array state must to be initialised after we
+    * have setup the context, as it needs to query server attributes.
+    */
+   if (gc && !gc->isDirect) {
+      __GLXattribute *state = gc->client_state_private;
+      if (state && state->array_state == NULL) {
+         glGetString(GL_EXTENSIONS);
+         glGetString(GL_VERSION);
+         __glXInitVertexArrayState(gc);
+      }
+   }
+
    return GL_TRUE;
 }