+// ----------------------------------------------------------------------------
+// wxGLContext
+// ----------------------------------------------------------------------------
+
+bool wxGLContext::SetCurrent(const wxGLCanvas& win) const
+{
+ if ( !m_glContext )
+ return false;
+
+ AGLDrawable drawable = (AGLDrawable)GetWindowPort(
+ MAC_WXHWND(win.MacGetTopLevelWindowRef()));
+
+ GLint bufnummer = win.GetAglBufferName();
+ aglSetInteger(m_glContext, AGL_BUFFER_NAME, &bufnummer);
+ //win.SetLastContext(m_glContext);
+
+ const_cast<wxGLCanvas&>(win).SetViewport();
+
+ if ( !aglSetDrawable(m_glContext, drawable) )
+ {
+ wxLogAGLError("aglSetDrawable");
+ return false;
+ }
+
+ return WXGLSetCurrentContext(m_glContext);
+}
+
+// ----------------------------------------------------------------------------
+// wxGLCanvas
+// ----------------------------------------------------------------------------
+
+/*
+
+sharing contexts under AGL is not straightforward, to quote from
+
+http://lists.apple.com/archives/mac-opengl/2003/Jan/msg00402.html :
+
+In Carbon OpenGL (AGL) you would use call aglSetInteger to setup a
+buffer name and attached each context to that same name. From AGL
+you can do:
+
+GLint id = 1;
+
+ctx1 = aglCreateContext...
+aglSetInteger(ctx1, AGL_BUFFER_NAME, &id); // create name
+aglAttachDrawable (ctx1,...); // create surface with associated with
+name (first time)
+ctx2 = aglCreateContext...
+aglSetInteger(ctx2, AGL_BUFFER_NAME, &id); // uses previously created name
+aglAttachDrawable (ctx2, ...); // uses existing surface with existing name
+
+AGL Docs say:
+AGL_BUFFER_NAME
+params contains one value: a non-negative integer name of the surface to be
+associated to be with the current context. If this value is non-zero, and a
+surface of this name is not associated to this drawable, a new surface with
+this name is created and associated with the context when
+aglSetDrawable is called subsequently. If this is a previously allocated
+buffer name within the namespace of the current window (e.g., drawable),
+that previously allocated surface is associated with the context (e.g., no
+new surface is created) and the subsequent call to aglSetDrawable will
+attach that surface. This allows multiple contexts to be attached to a single
+surface. Using the default buffer name zero, returns to one surface per
+context behavior.
+*/
+
+/*
+so what I'm doing is to have a dummy aglContext attached to a wxGLCanvas,
+assign it a buffer number
+*/
+
+