diff options
author | Michael Bien <[email protected]> | 2010-09-01 17:16:46 +0200 |
---|---|---|
committer | Michael Bien <[email protected]> | 2010-09-01 17:16:46 +0200 |
commit | 2388b47f180989abd14a39188b1d4f80f221bdcf (patch) | |
tree | f6a34f7bb7131cc9b642ae35eba9d1113bebd3c3 /src/com/jogamp/opencl | |
parent | 4836f3ab7916c681450d06f118b90c31f0bcdc8c (diff) |
better exception message if libOpenCL could not be loaded.
Diffstat (limited to 'src/com/jogamp/opencl')
-rw-r--r-- | src/com/jogamp/opencl/CLPlatform.java | 18 | ||||
-rw-r--r-- | src/com/jogamp/opencl/JOCLJNILibLoader.java | 5 |
2 files changed, 17 insertions, 6 deletions
diff --git a/src/com/jogamp/opencl/CLPlatform.java b/src/com/jogamp/opencl/CLPlatform.java index c12fbd47..70b27a0a 100644 --- a/src/com/jogamp/opencl/CLPlatform.java +++ b/src/com/jogamp/opencl/CLPlatform.java @@ -76,11 +76,14 @@ public final class CLPlatform { doPrivileged(new PrivilegedAction<Object>() { public Object run() { - NativeLibrary lib = JOCLJNILibLoader.loadJOCL(); + NativeLibrary libOpenCL = JOCLJNILibLoader.loadOpenCL(); + if(libOpenCL == null) { + throw new JogampRuntimeException("OpenCL library not found."); + } - //eagerly init funciton to query extension addresses (used in reset()) - table.initEntry("clGetExtensionFunctionAddressImpl", lib); - table.reset(lib); + //eagerly init function to query extension addresses (used in reset()) + table.initEntry("clGetExtensionFunctionAddressImpl", libOpenCL); + table.reset(libOpenCL); return null; } }); @@ -99,6 +102,13 @@ public final class CLPlatform { } /** + * Eagerly initializes JOCL. Subsequent calls do nothing. + */ + public static void initialize() throws JogampRuntimeException { + //see static initializer + } + + /** * Returns the default OpenCL platform or null when no platform found. */ public static CLPlatform getDefault() { diff --git a/src/com/jogamp/opencl/JOCLJNILibLoader.java b/src/com/jogamp/opencl/JOCLJNILibLoader.java index 61436aa5..5e2eae37 100644 --- a/src/com/jogamp/opencl/JOCLJNILibLoader.java +++ b/src/com/jogamp/opencl/JOCLJNILibLoader.java @@ -12,9 +12,10 @@ class JOCLJNILibLoader extends JNILibLoaderBase { /** * Loads the native binding and returns the OpenCL library for dynamic linking. + * @return Returns libOpenCL represented as NativeLibrary. */ - static NativeLibrary loadJOCL() { - loadLibrary("jocl", null, true); + static NativeLibrary loadOpenCL() { + loadLibrary("jocl", null, false); return NativeLibrary.open("OpenCL", JOCLJNILibLoader.class.getClassLoader()); } } |