From e626312c79f49b2244b5fdae8dbbf1ee22520817 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 27 Mar 2015 03:07:58 +0100 Subject: Bug 1116: Oculus SDK 0.4.4 support for JOGL - Part-3: New set of C-files, adapt to new SDK API - Tested on Windows and working StereoDemo01 w/ DK2! --- make/build-oculusvr.xml | 87 +++++++++++++--------- make/config/oculusvr/oculusvr-common.cfg | 19 +++-- make/config/oculusvr/oculusvr.c | 2 + make/config/oculusvr/oculusvr.cfg | 1 + make/scripts/tests-win.bat | 4 +- make/scripts/tests.sh | 3 +- oculusvr-sdk | 2 +- .../classes/com/jogamp/oculusvr/OVRVersion.java | 11 ++- .../opengl/oculusvr/OVRStereoDeviceFactory.java | 14 +++- .../opengl/oculusvr/OVRStereoDeviceRenderer.java | 5 +- src/oculusvr/native/OVRImplMisc.cpp | 30 -------- 11 files changed, 96 insertions(+), 82 deletions(-) delete mode 100644 src/oculusvr/native/OVRImplMisc.cpp diff --git a/make/build-oculusvr.xml b/make/build-oculusvr.xml index 48d48056d..717322efa 100644 --- a/make/build-oculusvr.xml +++ b/make/build-oculusvr.xml @@ -403,71 +403,81 @@ - - + + + - - - + + + - - - - - - - - + - + + + + - + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - + @@ -538,6 +548,7 @@ + @@ -560,6 +571,8 @@ + + diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index 7f25e33b8..0f73de53d 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -79,7 +79,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile02NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile02NEWTNoARBCtx $* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile03NEWTOffscreen $* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile04NEWTOffscreenNoARBCtx $* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile04NEWTOffscreenNoARBCtx $* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch02AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch01NEWT %* @@ -221,4 +221,4 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.graph.demos.GPUUISceneNewt REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug461FBOSupersamplingSwingAWT REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.glsl.TestRulerNEWT01 -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.stereo.StereoDemo01 %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.stereo.StereoDemo01 %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 2d137a0b3..ed9d85896 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -408,12 +408,13 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile02NEWTNoARBCtx $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile03NEWTOffscreen $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile04NEWTOffscreenNoARBCtx $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile04NEWTOffscreenNoARBCtx $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestVersionSemanticsNOUI $* # # Stereo # +testnoawt com.jogamp.oculusvr.OVRVersion $* #testnoawt com.jogamp.opengl.test.junit.jogl.stereo.StereoDemo01 $* # diff --git a/oculusvr-sdk b/oculusvr-sdk index 633f70342..3c7b8a17e 160000 --- a/oculusvr-sdk +++ b/oculusvr-sdk @@ -1 +1 @@ -Subproject commit 633f70342fe270fd91bca8f724049aceec602337 +Subproject commit 3c7b8a17e907f4ef2afd9f77db566a3f6179cbe4 diff --git a/src/oculusvr/classes/com/jogamp/oculusvr/OVRVersion.java b/src/oculusvr/classes/com/jogamp/oculusvr/OVRVersion.java index 9be37e193..50e0efd30 100644 --- a/src/oculusvr/classes/com/jogamp/oculusvr/OVRVersion.java +++ b/src/oculusvr/classes/com/jogamp/oculusvr/OVRVersion.java @@ -90,6 +90,10 @@ public class OVRVersion extends JogampVersion { if(null == hmdDesc) { throw new IllegalArgumentException("null hmdDesc"); } + final OvrHmdContext hmdCtx = hmdDesc.getHandle(); + if(null == hmdCtx) { + throw new IllegalArgumentException("null hmdCtx"); + } if(null==sb) { sb = new StringBuilder(); } @@ -100,15 +104,16 @@ public class OVRVersion extends JogampVersion { sb.append("\thmd."+ovrHmdIndex+".vendorId:\t0x"+Integer.toHexString(hmdDesc.getVendorId())).append(Platform.getNewline()); sb.append("\thmd."+ovrHmdIndex+".serial:\t"+hmdDesc.getSerialNumberAsString()).append(Platform.getNewline()); 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.getTrackingCaps()).append(Platform.getNewline()); + sb.append("\thmd."+ovrHmdIndex+".hmdCaps:\t"+toHexString(hmdDesc.getHmdCaps())).append(Platform.getNewline()); + sb.append("\thmd."+ovrHmdIndex+".distorCaps:\t"+toHexString(hmdDesc.getDistortionCaps())).append(Platform.getNewline()); + sb.append("\thmd."+ovrHmdIndex+".sensorCaps:\t"+toHexString(hmdDesc.getTrackingCaps())).append(Platform.getNewline()); final ovrSizei resolution = hmdDesc.getResolution(); sb.append("\thmd."+ovrHmdIndex+".resolution:\t"+resolution.getW()+"x"+resolution.getH()).append(Platform.getNewline()); final ovrVector2i winPos = hmdDesc.getWindowsPos(); sb.append("\thmd."+ovrHmdIndex+".winPos:\t"+winPos.getX()+" / "+winPos.getY()).append(Platform.getNewline()); return sb; } + private static String toHexString(final int v) { return "0x"+Integer.toHexString(v); } public static StringBuilder getAllAvailableCapabilitiesInfo(StringBuilder sb) { if(null==sb) { diff --git a/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDeviceFactory.java b/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDeviceFactory.java index ffe1371a4..21d6cab7b 100644 --- a/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDeviceFactory.java +++ b/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDeviceFactory.java @@ -43,6 +43,10 @@ public class OVRStereoDeviceFactory extends StereoDeviceFactory { return false; } + private void dumpCaps(final ovrHmdDesc hmdDesc, final int deviceIndex) { + System.err.println(OVRVersion.getAvailableCapabilitiesInfo(hmdDesc, deviceIndex, null).toString()); + } + @Override public final StereoDevice createDevice(final int deviceIndex, final StereoDeviceConfig config, final boolean verbose) { final ovrHmdDesc hmdDesc = OVR.ovrHmd_Create(deviceIndex); @@ -53,10 +57,16 @@ public class OVRStereoDeviceFactory extends StereoDeviceFactory { } return null; } - final OVRStereoDevice ctx = new OVRStereoDevice(this, hmdDesc, deviceIndex); + final int hmdCaps = hmdDesc.getHmdCaps(); + if( 0 == ( hmdCaps & OVR.ovrHmdCap_ExtendDesktop ) ) { + System.err.println("Device "+deviceIndex+" is not in ExtendDesktop mode as required."); + dumpCaps(hmdDesc, deviceIndex); + return null; + } if( verbose ) { - System.err.println(OVRVersion.getAvailableCapabilitiesInfo(ctx.hmdDesc, deviceIndex, null).toString()); + dumpCaps(hmdDesc, deviceIndex); } + final OVRStereoDevice ctx = new OVRStereoDevice(this, hmdDesc, deviceIndex); return ctx; } } diff --git a/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDeviceRenderer.java b/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDeviceRenderer.java index ff15d38d1..60fb8301e 100644 --- a/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDeviceRenderer.java +++ b/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDeviceRenderer.java @@ -386,6 +386,7 @@ public class OVRStereoDeviceRenderer implements StereoDeviceRenderer { private ShaderProgram sp; private ovrFrameTiming frameTiming; + private int frameCount; @Override public String toString() { @@ -440,6 +441,7 @@ public class OVRStereoDeviceRenderer implements StereoDeviceRenderer { eyes[1] = new OVREye(context.hmdDesc, this.distortionBits, eyePositionOffset, eyeRenderDescs[1], ovrTexture1Size, eyeViewports[1]); sp = null; frameTiming = null; + frameCount = 0; } @Override @@ -550,7 +552,7 @@ public class OVRStereoDeviceRenderer implements StereoDeviceRenderer { @Override public final void beginFrame(final GL gl) { - frameTiming = OVR.ovrHmd_BeginFrameTiming(context.hmdDesc, 0); + frameTiming = OVR.ovrHmd_BeginFrameTiming(context.hmdDesc, 0); // ovrHmd_GetFrameTiming not used, otherwise: frameCount); } @Override @@ -560,6 +562,7 @@ public class OVRStereoDeviceRenderer implements StereoDeviceRenderer { } OVR.ovrHmd_EndFrameTiming(context.hmdDesc); frameTiming = null; + frameCount++; } @Override diff --git a/src/oculusvr/native/OVRImplMisc.cpp b/src/oculusvr/native/OVRImplMisc.cpp deleted file mode 100644 index 08ebddf62..000000000 --- a/src/oculusvr/native/OVRImplMisc.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#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); } - -- cgit v1.2.3