diff options
author | Sven Gothel <[email protected]> | 2015-03-27 03:07:58 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2015-03-27 03:07:58 +0100 |
commit | e626312c79f49b2244b5fdae8dbbf1ee22520817 (patch) | |
tree | 717c760aa7f02bd67ca5ab020844286ae4caa367 /src/oculusvr | |
parent | bb6a8fdc8decdbec64bbab0fe2175e76211d0e77 (diff) |
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!
Diffstat (limited to 'src/oculusvr')
4 files changed, 24 insertions, 36 deletions
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); } - |