diff options
author | Michael Bien <[email protected]> | 2010-02-22 12:47:41 +0100 |
---|---|---|
committer | Michael Bien <[email protected]> | 2010-02-22 12:47:41 +0100 |
commit | 7c83da1d2e3e8d122e562408a63a13928cc97c83 (patch) | |
tree | 78957152423cc8b3623feae6b7376e047b0d04ae /src/com/mbien/opencl/CLGLContext.java | |
parent | b014104bc4d2c7b05767bf5364b8b972474850d1 (diff) |
several small refactorings, api and javadoc improvements.
added automatically generated specialized CLExceptions for each known OpenCL error.
added get/set Properties to CLCommandQueue.
Diffstat (limited to 'src/com/mbien/opencl/CLGLContext.java')
-rw-r--r-- | src/com/mbien/opencl/CLGLContext.java | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/com/mbien/opencl/CLGLContext.java b/src/com/mbien/opencl/CLGLContext.java index 6fb0251f..46f0dea3 100644 --- a/src/com/mbien/opencl/CLGLContext.java +++ b/src/com/mbien/opencl/CLGLContext.java @@ -20,8 +20,8 @@ public final class CLGLContext extends CLContext { final long glID; - private CLGLContext(long clContextID, long glContextID) { - super(clContextID); + private CLGLContext(CLPlatform platform, long clContextID, long glContextID) { + super(platform, clContextID); this.glID = glContextID; } @@ -61,11 +61,15 @@ public final class CLGLContext extends CLContext { */ public static final CLGLContext create(GLContext glContext, CLPlatform platform, CLDevice.Type... deviceTypes) { + if(platform == null) { + platform = CLPlatform.getDefault(); + } + long[] glID = new long[1]; - PointerBuffer properties = setupContextProperties(glContext, platform, glID); + PointerBuffer properties = setupContextProperties(platform, glContext, glID); long clID = createContextFromType(properties, toDeviceBitmap(deviceTypes)); - return new CLGLContext(clID, glID[0]); + return new CLGLContext(platform, clID, glID[0]); } @@ -75,11 +79,15 @@ public final class CLGLContext extends CLContext { */ public static final CLGLContext create(GLContext glContext, CLPlatform platform, CLDevice... devices) { + if(platform == null) { + platform = CLPlatform.getDefault(); + } + long[] glID = new long[1]; - PointerBuffer properties = setupContextProperties(glContext, platform, glID); + PointerBuffer properties = setupContextProperties(platform, glContext, glID); long clID = createContext(properties, devices); - CLGLContext context = new CLGLContext(clID, glID[0]); + CLGLContext context = new CLGLContext(platform, clID, glID[0]); if(devices != null) { for (int i = 0; i < devices.length; i++) { devices[i].setContext(context); @@ -89,11 +97,7 @@ public final class CLGLContext extends CLContext { } - private static final PointerBuffer setupContextProperties(GLContext glContext, CLPlatform platform, long[] glID) { - - if(platform == null) { - platform = CLPlatform.getDefault(); - } + private static final PointerBuffer setupContextProperties(CLPlatform platform, GLContext glContext, long[] glID) { if(platform == null) { throw new RuntimeException("no OpenCL installation found"); |