diff --git a/orx-syphon/build.gradle b/orx-syphon/build.gradle index 86cb81c6..ab404683 100644 --- a/orx-syphon/build.gradle +++ b/orx-syphon/build.gradle @@ -1,6 +1,6 @@ dependencies { - compile "org.openrndr:openrndr-core:$openrndrVersion" - compile "org.openrndr:openrndr-gl3:$openrndrVersion" - compile "org.lwjgl:lwjgl-opengl:3.2.3" - compile "org.openrndr:openrndr-gl3-natives-macos:$openrndrVersion" + implementation "org.openrndr:openrndr-core:$openrndrVersion" + implementation "org.openrndr:openrndr-gl3:$openrndrVersion" + implementation "org.lwjgl:lwjgl-opengl:3.2.3" + implementation "org.openrndr:openrndr-gl3-natives-macos:$openrndrVersion" } \ No newline at end of file diff --git a/orx-syphon/src/main/kotlin/SyphonClient.kt b/orx-syphon/src/main/kotlin/SyphonClient.kt index 133967fb..06d0776a 100644 --- a/orx-syphon/src/main/kotlin/SyphonClient.kt +++ b/orx-syphon/src/main/kotlin/SyphonClient.kt @@ -1,8 +1,12 @@ +package org.openrndr.extra.syphon + + import jsyphon.JSyphonClient import org.lwjgl.opengl.GL33C.GL_TEXTURE_RECTANGLE import org.openrndr.Extension import org.openrndr.Program import org.openrndr.draw.* + import org.openrndr.internal.gl3.ColorBufferGL3 diff --git a/orx-syphon/src/main/kotlin/SyphonServer.kt b/orx-syphon/src/main/kotlin/SyphonServer.kt index bb65cc98..251c709e 100644 --- a/orx-syphon/src/main/kotlin/SyphonServer.kt +++ b/orx-syphon/src/main/kotlin/SyphonServer.kt @@ -1,3 +1,5 @@ +package org.openrndr.extra.syphon + import jsyphon.JSyphonServer import org.openrndr.Extension diff --git a/orx-syphon/src/main/kotlin/jsyphon/JSyphonClient.kt b/orx-syphon/src/main/kotlin/jsyphon/JSyphonClient.kt index 9ddf245e..6ab7630b 100644 --- a/orx-syphon/src/main/kotlin/jsyphon/JSyphonClient.kt +++ b/orx-syphon/src/main/kotlin/jsyphon/JSyphonClient.kt @@ -7,11 +7,7 @@ class JSyphonClient { private var ptr: Long = 0 - companion object { - init { - System.load(File("orx-syphon/src/main/kotlin/jsyphon/libJSyphon.jnilib").absolutePath) - } - } + val native = JSyphonNative.check() fun init() { ptr = init(null) diff --git a/orx-syphon/src/main/kotlin/jsyphon/JSyphonNative.kt b/orx-syphon/src/main/kotlin/jsyphon/JSyphonNative.kt new file mode 100644 index 00000000..7902db60 --- /dev/null +++ b/orx-syphon/src/main/kotlin/jsyphon/JSyphonNative.kt @@ -0,0 +1,36 @@ +package jsyphon + +import org.openrndr.platform.Platform +import org.openrndr.platform.PlatformType +import java.io.File +import java.io.IOException + +object JSyphonNative { + init { + require(Platform.type == PlatformType.MAC) { "orx-syphon only works on macOS, your platform is not supported" } + + val tempBase = Platform.tempDirectory() + val libraries = arrayOf("Syphon", "libJSyphon.jnilib") + val tempDir = File(tempBase, "orx-syphon") + tempDir.mkdirs() + for (library in libraries) { + val stream = JSyphonNative::class.java.getResourceAsStream("/jsyphon-natives/$library") + require(stream != null) + try { + val target = File(tempDir, library) + val bytes = stream.readBytes() + target.writeBytes(bytes) + } catch (e: IOException) { + throw RuntimeException(e) + } finally { + stream.close() + } + } + for (library in libraries) { + System.load(File(tempDir, library).absolutePath) + } + } + fun check() { + // -- do nothing + } +} \ No newline at end of file diff --git a/orx-syphon/src/main/kotlin/jsyphon/JSyphonServer.kt b/orx-syphon/src/main/kotlin/jsyphon/JSyphonServer.kt index 409cbd3e..65a2f7e6 100644 --- a/orx-syphon/src/main/kotlin/jsyphon/JSyphonServer.kt +++ b/orx-syphon/src/main/kotlin/jsyphon/JSyphonServer.kt @@ -1,7 +1,4 @@ package jsyphon - -import java.io.File - /* JSyphonServer.java - Copyright 2011 -Skye Book (sbook) & Anton Marini (vade) @@ -33,11 +30,7 @@ class JSyphonServer // Public API { private var ptr: Long = 0 - companion object { - init { - System.load(File("orx-syphon/src/main/kotlin/jsyphon/libJSyphon.jnilib").absolutePath) - } - } + val native = JSyphonNative.check() fun initWithName(name: String) { ptr = initWithName(name, null) diff --git a/orx-syphon/src/main/kotlin/jsyphon/JSyphonServerList.kt b/orx-syphon/src/main/kotlin/jsyphon/JSyphonServerList.kt index b62b4aa4..0ef8d24c 100644 --- a/orx-syphon/src/main/kotlin/jsyphon/JSyphonServerList.kt +++ b/orx-syphon/src/main/kotlin/jsyphon/JSyphonServerList.kt @@ -1,5 +1,4 @@ package jsyphon - import java.io.File import java.util.ArrayList import java.util.HashMap diff --git a/orx-syphon/src/main/kotlin/jsyphon/Util.kt b/orx-syphon/src/main/kotlin/jsyphon/Util.kt index 68b4681b..69b33d48 100644 --- a/orx-syphon/src/main/kotlin/jsyphon/Util.kt +++ b/orx-syphon/src/main/kotlin/jsyphon/Util.kt @@ -1,5 +1,4 @@ package jsyphon - class NSSize (var x: Int, var y: Int) class NSPoint(var x: Int, var y: Int) diff --git a/orx-syphon/src/main/kotlin/jsyphon/Syphon b/orx-syphon/src/main/resources/jsyphon-natives/Syphon similarity index 100% rename from orx-syphon/src/main/kotlin/jsyphon/Syphon rename to orx-syphon/src/main/resources/jsyphon-natives/Syphon diff --git a/orx-syphon/src/main/kotlin/jsyphon/libJSyphon.jnilib b/orx-syphon/src/main/resources/jsyphon-natives/libJSyphon.jnilib similarity index 100% rename from orx-syphon/src/main/kotlin/jsyphon/libJSyphon.jnilib rename to orx-syphon/src/main/resources/jsyphon-natives/libJSyphon.jnilib