summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2010-04-24 02:41:52 +0200
committerMichael Bien <[email protected]>2010-04-24 02:41:52 +0200
commitb0f4d671bcf799884a3d3f31fbfee47f7fc6e5cb (patch)
treedeca75214756762e5be05fa8e54c0a5413eb0015 /src/com
parent2fc985f0cdc373cb3c78cc198e21dcc1ce5d961f (diff)
dynamic binding for OpenGL specific functionality.
Diffstat (limited to 'src/com')
-rw-r--r--src/com/jogamp/opencl/CLContext.java2
-rw-r--r--src/com/jogamp/opencl/CLPlatform.java21
-rw-r--r--src/com/jogamp/opencl/NativeLibLoader.java18
-rw-r--r--src/com/jogamp/opencl/gl/CLGLContext.java1
4 files changed, 29 insertions, 13 deletions
diff --git a/src/com/jogamp/opencl/CLContext.java b/src/com/jogamp/opencl/CLContext.java
index 07b59d9e..01159a01 100644
--- a/src/com/jogamp/opencl/CLContext.java
+++ b/src/com/jogamp/opencl/CLContext.java
@@ -162,7 +162,7 @@ public class CLContext extends CLObject implements CLResource {
for (int i = 0; i < devices.length; i++) {
CLDevice device = devices[i];
if(device == null) {
- throw new IllegalArgumentException("device at index"+i+" was null.");
+ throw new IllegalArgumentException("device at index "+i+" was null.");
}
pb.put(i, device.ID);
}
diff --git a/src/com/jogamp/opencl/CLPlatform.java b/src/com/jogamp/opencl/CLPlatform.java
index f3c00926..aa162d0c 100644
--- a/src/com/jogamp/opencl/CLPlatform.java
+++ b/src/com/jogamp/opencl/CLPlatform.java
@@ -1,9 +1,14 @@
package com.jogamp.opencl;
+import com.jogamp.common.JogampRuntimeException;
import com.jogamp.common.nio.Int64Buffer;
+import com.jogamp.common.os.NativeLibrary;
+import com.jogamp.common.nio.PointerBuffer;
import com.jogamp.opencl.util.CLUtil;
import com.jogamp.opencl.impl.CLImpl;
-import com.jogamp.common.nio.PointerBuffer;
+import com.jogamp.opencl.impl.CLProcAddressTable;
+import com.jogamp.gluegen.runtime.ProcAddressHelper;
+
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.IntBuffer;
@@ -34,10 +39,16 @@ public final class CLPlatform {
private Set<String> extensions;
static{
- NativeLibLoader.loadJOCL();
-// System.loadLibrary("gluegen-rt");
-// ProcAddressHelper.resetProcAddressTable(table, null);
- cl = new CLImpl();
+ try {
+ NativeLibrary lib = NativeLibLoader.loadJOCL();
+
+ CLProcAddressTable table = new CLProcAddressTable();
+ ProcAddressHelper.resetProcAddressTable(table, lib);
+
+ cl = new CLImpl(table);
+ }catch(Exception ex) {
+ throw new JogampRuntimeException("JOCL initialization error.", ex);
+ }
}
private CLPlatform(long id) {
diff --git a/src/com/jogamp/opencl/NativeLibLoader.java b/src/com/jogamp/opencl/NativeLibLoader.java
index 2761cb3c..5cce1a36 100644
--- a/src/com/jogamp/opencl/NativeLibLoader.java
+++ b/src/com/jogamp/opencl/NativeLibLoader.java
@@ -1,20 +1,26 @@
package com.jogamp.opencl;
-import java.security.AccessController;
import java.security.PrivilegedAction;
import com.jogamp.common.jvm.JNILibLoaderBase;
+import com.jogamp.common.os.NativeLibrary;
+
+import static java.security.AccessController.*;
/**
- *
+ * Responsible for JOCL lib loading.
* @author Michael Bien
*/
class NativeLibLoader extends JNILibLoaderBase {
- public static void loadJOCL() {
- AccessController.doPrivileged(new PrivilegedAction<Object>() {
- public Object run() {
+ /**
+ * Loads the native binding and returns the OpenCL library for dynamic linking.
+ */
+ static NativeLibrary loadJOCL() {
+
+ return doPrivileged(new PrivilegedAction<NativeLibrary>() {
+ public NativeLibrary run() {
loadLibrary("jocl", null, true);
- return null;
+ return NativeLibrary.open("OpenCL", NativeLibLoader.class.getClassLoader());
}
});
}
diff --git a/src/com/jogamp/opencl/gl/CLGLContext.java b/src/com/jogamp/opencl/gl/CLGLContext.java
index 5fd669b8..f8ca92f3 100644
--- a/src/com/jogamp/opencl/gl/CLGLContext.java
+++ b/src/com/jogamp/opencl/gl/CLGLContext.java
@@ -10,7 +10,6 @@ import com.jogamp.opengl.impl.GLContextImpl;
import com.jogamp.opengl.impl.macosx.cgl.MacOSXCGLContext;
import com.jogamp.opengl.impl.windows.wgl.WindowsWGLContext;
import com.jogamp.opengl.impl.x11.glx.X11GLXContext;
-import javax.media.nativewindow.DefaultGraphicsConfiguration;
import javax.media.opengl.GLContext;
import static com.jogamp.opencl.gl.CLGLI.*;