From 32fc8f3a64cfeee8936af98ae49f8e7c8dfe982f Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 21 Mar 2015 04:31:27 +0100 Subject: Bug 1116 - Add OculusVR DK2 Support - Part-1 (DK2 on DK1 SDK w/o Eye Tracker) - DK2's screen on X11 (at least) starts in rotated mode, detect and apply MonitorDevice rotation via NEWT's OpenGL StereoDeviceUtil - Move StereoDevice.Config -> StereoDeviceConfig - Expose generic StereoDevice to public: GenericStereoDeviceConfig + GenericStereoDeviceFactory - GenericStereoDeviceFactory exposes public GenericStereoDeviceConfig creation for mono, sbs-stereo and lense-sbs-stereo w/ diff. parameters. - Pass eye surface/texture size for each eye from device to renderer, instead of assuming unified values. - Unify GenericStereoDevice.createRenderer(..) and OVRStereoDevice.createRenderer(..) code --- .../jogamp/opengl/oculusvr/OVRStereoDevice.java | 97 ++++++++++++++-------- .../opengl/oculusvr/OVRStereoDeviceFactory.java | 4 +- .../opengl/oculusvr/OVRStereoDeviceRenderer.java | 25 ++++-- 3 files changed, 83 insertions(+), 43 deletions(-) (limited to 'src/oculusvr/classes') diff --git a/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDevice.java b/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDevice.java index d0d9f5a85..3dadb94b0 100644 --- a/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDevice.java +++ b/src/oculusvr/classes/jogamp/opengl/oculusvr/OVRStereoDevice.java @@ -32,7 +32,6 @@ import com.jogamp.nativewindow.util.DimensionImmutable; import com.jogamp.nativewindow.util.PointImmutable; import com.jogamp.nativewindow.util.Rectangle; import com.jogamp.nativewindow.util.RectangleImmutable; - import com.jogamp.oculusvr.OVR; import com.jogamp.oculusvr.OvrHmdContext; import com.jogamp.oculusvr.ovrEyeRenderDesc; @@ -59,6 +58,12 @@ public class OVRStereoDevice implements StereoDevice { private final int[] eyeRenderOrder; private final int supportedDistortionBits, recommendedDistortionBits, minimumDistortionBits; + private final String deviceName; + private final DimensionImmutable resolution; + private final int requiredRotation; + private final PointImmutable position; + private final int dkVersion; + public OVRStereoDevice(final StereoDeviceFactory factory, final OvrHmdContext nativeContext, final int deviceIndex) { if( null == nativeContext ) { throw new IllegalArgumentException("Passed null nativeContext"); @@ -68,16 +73,30 @@ public class OVRStereoDevice implements StereoDevice { this.deviceIndex = deviceIndex; this.hmdDesc = ovrHmdDesc.create(); OVR.ovrHmd_GetDesc(handle, hmdDesc); - final ovrFovPort[] defaultOVREyeFov = hmdDesc.getDefaultEyeFov(0, new ovrFovPort[hmdDesc.getEyeRenderOrderArrayLength()]); + final ovrFovPort[] defaultOVREyeFov = hmdDesc.getDefaultEyeFov(0, new ovrFovPort[ovrHmdDesc.getEyeRenderOrderArrayLength()]); defaultEyeFov = new FovHVHalves[defaultOVREyeFov.length]; for(int i=0; i textureCount || 2 < textureCount ) { throw new IllegalArgumentException("textureCount can only be 1 or 2, has "+textureCount); @@ -421,14 +423,21 @@ public class OVRStereoDeviceRenderer implements StereoDeviceRenderer { this.eyes = new OVREye[2]; this.distortionBits = ( distortionBits | context.getMinimumDistortionBits() ) & context.getSupportedDistortionBits(); this.textureCount = textureCount; - this.singleTextureSize = singleTextureSize; + this.eyeTextureSizes = eyeTextureSizes; this.totalTextureSize = totalTextureSize; texUnit0 = new GLUniformData("ovr_Texture0", textureUnit); - final ovrSizei ovrTextureSize = OVRUtil.createOVRSizei( 1 == textureCount ? totalTextureSize : singleTextureSize ); - eyes[0] = new OVREye(context.handle, this.distortionBits, eyePositionOffset, eyeRenderDescs[0], ovrTextureSize, eyeViewports[0]); - eyes[1] = new OVREye(context.handle, this.distortionBits, eyePositionOffset, eyeRenderDescs[1], ovrTextureSize, eyeViewports[1]); + final ovrSizei ovrTexture0Size, ovrTexture1Size; + if( 1 == textureCount ) { + ovrTexture0Size = OVRUtil.createOVRSizei(totalTextureSize); + ovrTexture1Size = ovrTexture0Size; + } else { + ovrTexture0Size = OVRUtil.createOVRSizei(eyeTextureSizes[0]); + ovrTexture1Size = OVRUtil.createOVRSizei(eyeTextureSizes[1]); + } + eyes[0] = new OVREye(context.handle, this.distortionBits, eyePositionOffset, eyeRenderDescs[0], ovrTexture0Size, eyeViewports[0]); + eyes[1] = new OVREye(context.handle, this.distortionBits, eyePositionOffset, eyeRenderDescs[1], ovrTexture1Size, eyeViewports[1]); sp = null; frameTiming = null; } @@ -445,7 +454,7 @@ public class OVRStereoDeviceRenderer implements StereoDeviceRenderer { public final boolean usesSideBySideStereo() { return true; } @Override - public final DimensionImmutable getSingleSurfaceSize() { return singleTextureSize; } + public final DimensionImmutable[] getEyeSurfaceSize() { return eyeTextureSizes; } @Override public final DimensionImmutable getTotalSurfaceSize() { return totalTextureSize; } -- cgit v1.2.3