aboutsummaryrefslogtreecommitdiffstats
path: root/src/oculusvr
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-06-19 23:21:19 +0200
committerSven Gothel <[email protected]>2014-06-19 23:21:19 +0200
commit40d7d0d18ed11b8dbb0f16137f82eef828b822a4 (patch)
tree954cb10ac50d0eea506c4b4b9dc5b5bac39d99e0 /src/oculusvr
parent20bf51f2ccbecf1ab21ef3dbd2ff06e04ebd40cc (diff)
Bug 1021: Add OculusSDK binding / Basic OVR support
Bring-up test only initializes the ovrHmdHandle data structure by OVR native code. See com.jogamp.oculusvr.OVRVersion Current evaluation build compiles all OVR-SDK source files itself w/o using provided libovr.a. We also skip the GL dependent renderer of the SDK, i.e. we prefer to utilize our JOGL 'barrel distortion' renderer. This eases the 'chicken-egg' problem of OVR SDK dependencies, i.e. libGL, libGLESv2 .. etc Since the OVR source code is C++, we may still have to figure out how to / and whether we shall link libstdc++ statically to remove platform dependencies. Right now we link libstdc++ statically if using GCC, see make/build-oculusvr.xml (hackish .. TODO: better way to include all symbols). Same consideration applies to GNU/Linux and libudev.so dependency, since there are: - libudev.so.0 and (Older distri's) - libudev.so.1 (Debian8, ..) ... Produced JAR artifacts are - jar/atomic/oculusvr.jar - jar/atomic/oculusvr-natives-<os.and.arch>.jar i.e. only in 'atomic' variants to not bloat the default 'all' JAR files. .... make/build-oculusvr.xml Notes: - Currently native build only enabled on GNU/Linux (isLinux) - Force disable native build via property 'c.build.oculusvr.skip'
Diffstat (limited to 'src/oculusvr')
-rw-r--r--src/oculusvr/classes/com/jogamp/oculusvr/OVRDynamicLibraryBundleInfo.java113
-rw-r--r--src/oculusvr/classes/com/jogamp/oculusvr/OVRException.java50
-rw-r--r--src/oculusvr/classes/com/jogamp/oculusvr/OVRVersion.java107
-rw-r--r--src/oculusvr/native/OVRImplMisc.cpp30
4 files changed, 300 insertions, 0 deletions
diff --git a/src/oculusvr/classes/com/jogamp/oculusvr/OVRDynamicLibraryBundleInfo.java b/src/oculusvr/classes/com/jogamp/oculusvr/OVRDynamicLibraryBundleInfo.java
new file mode 100644
index 000000000..6bd9d1a64
--- /dev/null
+++ b/src/oculusvr/classes/com/jogamp/oculusvr/OVRDynamicLibraryBundleInfo.java
@@ -0,0 +1,113 @@
+/**
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.oculusvr;
+
+import com.jogamp.common.jvm.JNILibLoaderBase;
+import com.jogamp.common.os.DynamicLibraryBundle;
+import com.jogamp.common.os.DynamicLibraryBundleInfo;
+import com.jogamp.common.os.Platform;
+import com.jogamp.common.util.RunnableExecutor;
+import com.jogamp.common.util.cache.TempJarCache;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.*;
+
+/* pp */ final class OVRDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo {
+ private static final List<String> glueLibNames;
+ static {
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ Platform.initSingleton();
+
+ if(TempJarCache.isInitialized()) {
+ // only: joal.jar -> joal-natives-<os.and.arch>.jar
+ JNILibLoaderBase.addNativeJarLibs(new Class<?>[] { OVRDynamicLibraryBundleInfo.class }, null, null );
+ }
+ return null;
+ }
+ });
+
+ glueLibNames = new ArrayList<String>();
+ glueLibNames.add("oculusvr");
+ }
+
+ /* pp */ OVRDynamicLibraryBundleInfo() {
+ }
+
+ /**
+ * <p>
+ * Returns <code>true</code>,
+ * since we might load the library and allow symbol access to subsequent libs.
+ * </p>
+ */
+ @Override
+ public final boolean shallLinkGlobal() { return true; }
+
+ /**
+ * {@inheritDoc}
+ * <p>
+ * Returns <code>false</code>.
+ * </p>
+ */
+ @Override
+ public final boolean shallLookupGlobal() { return true; }
+
+ @Override
+ public final List<String> getGlueLibNames() {
+ return glueLibNames;
+ }
+
+ @Override
+ public final List<List<String>> getToolLibNames() {
+ return new ArrayList<List<String>>(); // None
+ }
+
+ @Override
+ public final List<String> getToolGetProcAddressFuncNameList() {
+ return null;
+ }
+
+ @Override
+ public final long toolGetProcAddress(long toolGetProcAddressHandle, String funcName) {
+ return 0;
+ }
+
+ @Override
+ public final boolean useToolGetProcAdressFirst(String funcName) {
+ return false;
+ }
+
+ @Override
+ public final RunnableExecutor getLibLoaderExecutor() {
+ return DynamicLibraryBundle.getDefaultRunnableExecutor();
+ }
+}
+
+
diff --git a/src/oculusvr/classes/com/jogamp/oculusvr/OVRException.java b/src/oculusvr/classes/com/jogamp/oculusvr/OVRException.java
new file mode 100644
index 000000000..e65338025
--- /dev/null
+++ b/src/oculusvr/classes/com/jogamp/oculusvr/OVRException.java
@@ -0,0 +1,50 @@
+/**
+ * Copyright (C) 2014 JogAmp Community. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+package com.jogamp.oculusvr;
+
+/** A generic exception for OculusVR errors used throughout the binding
+ as a substitute for {@link RuntimeException}. */
+@SuppressWarnings("serial")
+public class OVRException extends RuntimeException {
+ /** Constructs an ALException object. */
+ public OVRException() {
+ super();
+ }
+
+ /** Constructs an ALException object with the specified detail
+ message. */
+ public OVRException(String message) {
+ super(message);
+ }
+
+ /** Constructs an ALException object with the specified detail
+ message and root cause. */
+ public OVRException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /** Constructs an ALException object with the specified root
+ cause. */
+ public OVRException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/src/oculusvr/classes/com/jogamp/oculusvr/OVRVersion.java b/src/oculusvr/classes/com/jogamp/oculusvr/OVRVersion.java
new file mode 100644
index 000000000..a7c64940f
--- /dev/null
+++ b/src/oculusvr/classes/com/jogamp/oculusvr/OVRVersion.java
@@ -0,0 +1,107 @@
+/**
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.oculusvr;
+
+import com.jogamp.common.GlueGenVersion;
+
+import com.jogamp.common.os.Platform;
+import com.jogamp.common.util.VersionUtil;
+import com.jogamp.common.util.JogampVersion;
+
+import java.util.jar.Manifest;
+
+public class OVRVersion extends JogampVersion {
+
+ protected static volatile OVRVersion jogampCommonVersionInfo;
+
+ protected OVRVersion(String packageName, Manifest mf) {
+ super(packageName, mf);
+ }
+
+ public static OVRVersion getInstance() {
+ if(null == jogampCommonVersionInfo) { // volatile: ok
+ synchronized(OVRVersion.class) {
+ if( null == jogampCommonVersionInfo ) {
+ final String packageName = "com.jogamp.oculusvr";
+ final Manifest mf = VersionUtil.getManifest(OVRVersion.class.getClassLoader(), packageName);
+ jogampCommonVersionInfo = new OVRVersion(packageName, mf);
+ }
+ }
+ }
+ return jogampCommonVersionInfo;
+ }
+
+ public static StringBuilder getAvailableCapabilitiesInfo(final int ovrHmdIndex, StringBuilder sb) {
+ if(null==sb) {
+ sb = new StringBuilder();
+ }
+ if( !OVR.ovr_Initialize() ) { // recursive ..
+ sb.append("\tOVR not available").append(Platform.getNewline());
+ } else {
+ final long ovrHmdHandle = OVR.ovrHmd_Create(ovrHmdIndex);
+ if( 0 != ovrHmdHandle ) {
+ ovrHmdDesc hmdDesc = ovrHmdDesc.create();
+ OVR.ovrHmd_GetDesc(ovrHmdHandle, hmdDesc);
+ sb.append("\thmd."+ovrHmdIndex+".type:\t"+hmdDesc.getType()).append(Platform.getNewline());
+ sb.append("\thmd."+ovrHmdIndex+".hmdCaps:\t"+hmdDesc.getHmdCaps()).append(Platform.getNewline());
+ sb.append("\thmd."+ovrHmdIndex+".distorCaps:\t"+hmdDesc.getDistortionCaps()).append(Platform.getNewline());
+ sb.append("\thmd."+ovrHmdIndex+".sensorCaps:\t"+hmdDesc.getSensorCaps()).append(Platform.getNewline());
+ final ovrSizei resolution = hmdDesc.getResolution();
+ sb.append("\thmd."+ovrHmdIndex+".resolution:\t"+resolution.getW()+"x"+resolution.getH()).append(Platform.getNewline());
+ ovrVector2i winPos = hmdDesc.getWindowsPos();
+ sb.append("\thmd."+ovrHmdIndex+".winPos:\t"+winPos.getX()+" / "+winPos.getY()).append(Platform.getNewline());
+ OVR.ovrHmd_Destroy(ovrHmdHandle);
+ } else {
+ sb.append("\thmd."+ovrHmdIndex+" not available").append(Platform.getNewline());
+ }
+ }
+ // Nope .. ovr.ovr_Shutdown();
+ sb.append(Platform.getNewline());
+ return sb;
+ }
+
+ public static StringBuilder getAllAvailableCapabilitiesInfo(StringBuilder sb) {
+ if(null==sb) {
+ sb = new StringBuilder();
+ }
+ sb.append(Platform.getNewline()).append(Platform.getNewline());
+ sb.append("HMD.0 Capabilities: ").append(Platform.getNewline());
+ getAvailableCapabilitiesInfo(0, sb);
+ return sb;
+ }
+
+ public static void main(String args[]) {
+ System.err.println(VersionUtil.getPlatformInfo());
+ System.err.println(GlueGenVersion.getInstance());
+ // System.err.println(NativeWindowVersion.getInstance());
+ System.err.println(OVRVersion.getInstance());
+ System.err.println(OVRVersion.getAllAvailableCapabilitiesInfo(null).toString());
+ }
+}
+
diff --git a/src/oculusvr/native/OVRImplMisc.cpp b/src/oculusvr/native/OVRImplMisc.cpp
new file mode 100644
index 000000000..08ebddf62
--- /dev/null
+++ b/src/oculusvr/native/OVRImplMisc.cpp
@@ -0,0 +1,30 @@
+#include "OVR_CAPI.h"
+
+#include "CAPI_DistortionRenderer.h"
+
+namespace OVR { namespace CAPI {
+
+ /**
+ * Index is: apiConfig->Header.API, with
+ * ovrRenderAPIConfig * apiConfig
+ * ovrRenderAPIConfigHeader Header
+ * ovrRenderAPIType Header.API
+ */
+ DistortionRenderer::CreateFunc DistortionRenderer::APICreateRegistry[ovrRenderAPI_Count] =
+ {
+ 0, // None
+ 0, // None for GL - &GL::DistortionRenderer::Create,
+ 0, // Android_GLES
+ 0, // D3D9
+ 0, // D3D10
+ 0 // D3D11
+ };
+
+}} // namespace OVR::CAPI
+
+//
+// TBD: Replace stdc++ for compatibility !
+//
+// This is not enough:
+// extern "C" void __cxa_pure_virtual() { while (1); }
+