From 9575f39cc204dc31d85233ecf4b09443190c3673 Mon Sep 17 00:00:00 2001 From: Michael Bien Date: Sat, 2 Jan 2010 00:35:04 +0100 Subject: fixed shared context creation code. --- src/com/mbien/opencl/CLGLContext.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/com/mbien/opencl/CLGLContext.java b/src/com/mbien/opencl/CLGLContext.java index 9699c1ba..407c7311 100644 --- a/src/com/mbien/opencl/CLGLContext.java +++ b/src/com/mbien/opencl/CLGLContext.java @@ -26,7 +26,6 @@ public final class CLGLContext extends CLContext { public static CLGLContext create(GLContext glContext) { - long glID = glContext.getContext(); //UNIX //cl_context_properties props[] = { @@ -45,6 +44,8 @@ public final class CLGLContext extends CLContext { // CL_CGL_SHAREGROUP_KHR, (cl_context_properties)TODO 0, // CL_CONTEXT_PLATFORM, (cl_context_properties)cpPlatform, 0}; + long glID = 0; + GLContextImpl ctxImpl = (GLContextImpl)glContext; DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration)ctxImpl.getDrawableImpl() @@ -53,6 +54,7 @@ public final class CLGLContext extends CLContext { LongBuffer properties = LongBuffer.allocate(5); if(glContext instanceof X11GLXContext) { long handle = config.getScreen().getDevice().getHandle(); + glID = ((X11GLXContext)glContext).getContext(); properties.put(CLGLI.CL_GL_CONTEXT_KHR).put(glID) .put(CLGLI.CL_GLX_DISPLAY_KHR).put(handle); }else if(glContext instanceof WindowsWGLContext) { @@ -61,6 +63,8 @@ public final class CLGLContext extends CLContext { }else if(glContext instanceof MacOSXCGLContext) { // TODO test on mac throw new RuntimeException("cl-gl interoperability on mac not yet implemented"); + }else{ + throw new RuntimeException("unsupported GLContext: "+glContext); } properties.put(0).rewind(); // 0 terminated array -- cgit v1.2.3