From c6639611c212710bb501c5b9c65bc23501f17bf3 Mon Sep 17 00:00:00 2001 From: Kazik Pogoda Date: Mon, 26 Aug 2019 10:09:08 +0200 Subject: [PATCH] NativeFreenectCommandsDemo shows how to retrieve a value from native kinect call --- .../src/main/kotlin/NativeFreenectCommandsDemo.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/orx-kinect-v1-demo/src/main/kotlin/NativeFreenectCommandsDemo.kt b/orx-kinect-v1-demo/src/main/kotlin/NativeFreenectCommandsDemo.kt index 720435fc..e185bb6d 100644 --- a/orx-kinect-v1-demo/src/main/kotlin/NativeFreenectCommandsDemo.kt +++ b/orx-kinect-v1-demo/src/main/kotlin/NativeFreenectCommandsDemo.kt @@ -4,6 +4,7 @@ import org.bytedeco.libfreenect.global.freenect import org.bytedeco.libfreenect.global.freenect.* import org.openrndr.application import org.openrndr.extra.kinect.v1.getKinectsV1 +import java.lang.RuntimeException /** * Even though this library is abstracting freenect access, it is still @@ -14,6 +15,9 @@ import org.openrndr.extra.kinect.v1.getKinectsV1 fun main() = application { program { val kinects = getKinectsV1(this) + // the same as calling kinects.countDevices(), here to show that any value might be returned from execute + val num = kinects.execute { ctx -> freenect_num_devices(ctx.fnCtx) } + if (num == 0) { throw RuntimeException("no kinect detected") } kinects.execute { ctx -> freenect_set_log_level(ctx.fnCtx, freenect.FREENECT_LOG_FLOOD) // lots of logs }