From 5d3631b56ed976f155791b4c75dffff0f911e1d7 Mon Sep 17 00:00:00 2001
From: Andreas Kloeckner <inform@tiker.net>
Date: Thu, 24 Feb 2011 22:54:21 -0500
Subject: [PATCH] Revert "Re-fix the fix's fix for GL interop."

This reverts commit 0ce6cb95556090b39fdd33f8bfe8cfbcceb645e1.
---
 pyopencl/tools.py       |  3 +--
 src/wrapper/wrap_cl.hpp | 26 +++++++++++++++++++-------
 2 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/pyopencl/tools.py b/pyopencl/tools.py
index 74f29dbf..0bdfa292 100644
--- a/pyopencl/tools.py
+++ b/pyopencl/tools.py
@@ -271,7 +271,7 @@ def get_gl_sharing_context_properties():
                     WGL.wglGetCurrentDC()))
     elif sys.platform == "darwin":
         props.append(
-            (ctx_props.CGL_SHAREGROUP, cl.get_apple_cgl_share_group()))
+            (ctx_props.CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE, cl.get_apple_cgl_share_group()))
     else:
         raise NotImplementedError("platform '%s' not yet supported" 
                 % sys.platform)
@@ -280,5 +280,4 @@ def get_gl_sharing_context_properties():
 
 
 
-
 # vim: foldmethod=marker
diff --git a/src/wrapper/wrap_cl.hpp b/src/wrapper/wrap_cl.hpp
index cd5a6a91..8df73a23 100644
--- a/src/wrapper/wrap_cl.hpp
+++ b/src/wrapper/wrap_cl.hpp
@@ -6,10 +6,11 @@
 #ifdef __APPLE__
 
 // Mac ------------------------------------------------------------------------
-#include <OpenCL/cl.h>
-#include <OpenCL/cl_ext.h>
-
+#include <OpenCL/opencl.h>
 #ifdef HAVE_GL
+
+#define PYOPENCL_GL_SHARING_VERSION 1
+
 #include <OpenGL/OpenGL.h>
 #include <OpenCL/cl_gl.h>
 #include <OpenCL/cl_gl_ext.h>
@@ -17,6 +18,10 @@
 
 #else
 
+#if defined(cl_khr_gl_sharing) && (cl_khr_gl_sharing >= 1)
+#define PYOPENCL_GL_SHARING_VERSION cl_khr_gl_sharing
+#endif
+
 // elsewhere ------------------------------------------------------------------
 #include <CL/cl.h>
 // TBD: Nvidia used to not install cl_ext.h by default. Grr.
@@ -654,16 +659,20 @@ namespace pyopencl
                       break;
                     }
 
-#if defined(cl_khr_gl_sharing) && (cl_khr_gl_sharing >= 1)
+#if defined(PYOPENCL_GL_SHARING_VERSION) && (PYOPENCL_GL_SHARING_VERSION >= 1)
+#if defined(__APPLE__) && defined(HAVE_GL)
+                  case CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE:
+#else
                   case CL_GL_CONTEXT_KHR:
                   case CL_EGL_DISPLAY_KHR:
                   case CL_GLX_DISPLAY_KHR:
                   case CL_WGL_HDC_KHR:
                   case CL_CGL_SHAREGROUP_KHR:
+#endif
                     value = py::object(result[i+1]);
                     break;
-#endif
 
+#endif
                   case 0:
                     break;
 
@@ -714,7 +723,7 @@ namespace pyopencl
           props.push_back(
               reinterpret_cast<cl_context_properties>(value().data()));
         }
-#if defined(cl_khr_gl_sharing) && (cl_khr_gl_sharing >= 1)
+#if defined(PYOPENCL_GL_SHARING_VERSION) && (PYOPENCL_GL_SHARING_VERSION >= 1)
 #if defined(_WIN32)
        else if (prop == CL_WGL_HDC_KHR)
        {
@@ -727,6 +736,9 @@ namespace pyopencl
             || prop == CL_EGL_DISPLAY_KHR
             || prop == CL_GLX_DISPLAY_KHR
             || prop == CL_CGL_SHAREGROUP_KHR
+#if defined(__APPLE__) && defined(HAVE_GL)
+            || prop == CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE
+#endif
            )
        {
           py::object ctypes = py::import("ctypes");
@@ -2958,7 +2970,7 @@ namespace pyopencl
 
 
 
-#if defined(cl_khr_gl_sharing) && (cl_khr_gl_sharing >= 1)
+#if defined(PYOPENCL_GL_SHARING_VERSION) && (PYOPENCL_GL_SHARING_VERSION >= 1)
   inline
   py::object get_gl_context_info_khr(
       py::object py_properties,
-- 
GitLab