Fix loading of native libraries and package names
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
dependencies {
|
dependencies {
|
||||||
compile "org.openrndr:openrndr-core:$openrndrVersion"
|
implementation "org.openrndr:openrndr-core:$openrndrVersion"
|
||||||
compile "org.openrndr:openrndr-gl3:$openrndrVersion"
|
implementation "org.openrndr:openrndr-gl3:$openrndrVersion"
|
||||||
compile "org.lwjgl:lwjgl-opengl:3.2.3"
|
implementation "org.lwjgl:lwjgl-opengl:3.2.3"
|
||||||
compile "org.openrndr:openrndr-gl3-natives-macos:$openrndrVersion"
|
implementation "org.openrndr:openrndr-gl3-natives-macos:$openrndrVersion"
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,12 @@
|
|||||||
|
package org.openrndr.extra.syphon
|
||||||
|
|
||||||
|
|
||||||
import jsyphon.JSyphonClient
|
import jsyphon.JSyphonClient
|
||||||
import org.lwjgl.opengl.GL33C.GL_TEXTURE_RECTANGLE
|
import org.lwjgl.opengl.GL33C.GL_TEXTURE_RECTANGLE
|
||||||
import org.openrndr.Extension
|
import org.openrndr.Extension
|
||||||
import org.openrndr.Program
|
import org.openrndr.Program
|
||||||
import org.openrndr.draw.*
|
import org.openrndr.draw.*
|
||||||
|
|
||||||
import org.openrndr.internal.gl3.ColorBufferGL3
|
import org.openrndr.internal.gl3.ColorBufferGL3
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
package org.openrndr.extra.syphon
|
||||||
|
|
||||||
|
|
||||||
import jsyphon.JSyphonServer
|
import jsyphon.JSyphonServer
|
||||||
import org.openrndr.Extension
|
import org.openrndr.Extension
|
||||||
|
|||||||
@@ -7,11 +7,7 @@ class JSyphonClient
|
|||||||
{
|
{
|
||||||
private var ptr: Long = 0
|
private var ptr: Long = 0
|
||||||
|
|
||||||
companion object {
|
val native = JSyphonNative.check()
|
||||||
init {
|
|
||||||
System.load(File("orx-syphon/src/main/kotlin/jsyphon/libJSyphon.jnilib").absolutePath)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun init() {
|
fun init() {
|
||||||
ptr = init(null)
|
ptr = init(null)
|
||||||
|
|||||||
36
orx-syphon/src/main/kotlin/jsyphon/JSyphonNative.kt
Normal file
36
orx-syphon/src/main/kotlin/jsyphon/JSyphonNative.kt
Normal file
@@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,4 @@
|
|||||||
package jsyphon
|
package jsyphon
|
||||||
|
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
JSyphonServer.java -
|
JSyphonServer.java -
|
||||||
Copyright 2011 -Skye Book (sbook) & Anton Marini (vade)
|
Copyright 2011 -Skye Book (sbook) & Anton Marini (vade)
|
||||||
@@ -33,11 +30,7 @@ class JSyphonServer // Public API
|
|||||||
{
|
{
|
||||||
private var ptr: Long = 0
|
private var ptr: Long = 0
|
||||||
|
|
||||||
companion object {
|
val native = JSyphonNative.check()
|
||||||
init {
|
|
||||||
System.load(File("orx-syphon/src/main/kotlin/jsyphon/libJSyphon.jnilib").absolutePath)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun initWithName(name: String) {
|
fun initWithName(name: String) {
|
||||||
ptr = initWithName(name, null)
|
ptr = initWithName(name, null)
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
package jsyphon
|
package jsyphon
|
||||||
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.ArrayList
|
import java.util.ArrayList
|
||||||
import java.util.HashMap
|
import java.util.HashMap
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
package jsyphon
|
package jsyphon
|
||||||
|
|
||||||
class NSSize (var x: Int, var y: Int)
|
class NSSize (var x: Int, var y: Int)
|
||||||
class NSPoint(var x: Int, var y: Int)
|
class NSPoint(var x: Int, var y: Int)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user