From 53966f92042d44483cb44f6c6b3c95a6a1fdd325 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 18 Jul 2015 03:50:02 +0200 Subject: Bug 1151 - Working OculusVR SDK 0.5.0.1 on GNU/Linux w/ Positional Tracker (DK2) Note: The ovrd server must run, otherwise no device is being detected. General Stereo API Changes: - EyePose -> ViewerPose - We only use the viewer pose and derive the pupile position via EyeParameter. - Hence we reduce complexity. - A single ViewerPose will be maintained by StereoDeviceRenderer - position is in meter, allowing StereoGLEventListener to scale device independent. - StereoDevice receives knowledge of certain sensors, to be queried and used for start-sensors. OVR: - Simply apply the above general changes - Build: Remove [more] unused API entries for SDK rendering --- .../opengl/util/stereo/GenericStereoDevice.java | 56 ++++++++++++++++++---- .../util/stereo/GenericStereoDeviceRenderer.java | 46 ++++++++---------- 2 files changed, 65 insertions(+), 37 deletions(-) (limited to 'src/jogl/classes/jogamp') diff --git a/src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDevice.java b/src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDevice.java index 9c0a5045b..491535dc1 100644 --- a/src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDevice.java +++ b/src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDevice.java @@ -39,6 +39,7 @@ import com.jogamp.opengl.util.stereo.EyeParameter; import com.jogamp.opengl.util.stereo.StereoDevice; import com.jogamp.opengl.util.stereo.StereoDeviceFactory; import com.jogamp.opengl.util.stereo.StereoDeviceRenderer; +import com.jogamp.opengl.util.stereo.StereoUtil; import com.jogamp.opengl.util.stereo.generic.GenericStereoDeviceConfig; import com.jogamp.opengl.util.stereo.generic.GenericStereoDeviceFactory; @@ -117,6 +118,7 @@ public class GenericStereoDevice implements StereoDevice { public final Point surfacePos; private final FovHVHalves[] defaultEyeFov; + private int usedSensorBits; private boolean sensorsStarted = false; public GenericStereoDevice(final StereoDeviceFactory factory, final int deviceIndex, final StereoDeviceConfig customConfig) { @@ -137,6 +139,9 @@ public class GenericStereoDevice implements StereoDevice { for(int i=0; i Success + return true; + } + } + protected boolean startSensorsImpl(final boolean start, final int desiredSensorBits, final int requiredSensorBits) { + // TODO: Add SPI for sensors + // TODO: start sensors in override / or SPI + // TODO: set usedSensorBits + return false; + } + + @Override + public final boolean stopSensors() { + if( sensorsStarted ) { + if( startSensorsImpl(false, 0, 0) ) { sensorsStarted = false; + usedSensorBits = 0; return true; } else { - sensorsStarted = true; return false; } } else { @@ -206,11 +233,20 @@ public class GenericStereoDevice implements StereoDevice { return true; } } - private boolean startSensorsImpl(final boolean start) { return start; } @Override public boolean getSensorsStarted() { return sensorsStarted; } + @Override + public final int getSupportedSensorBits() { + return config.supportedSensorBits; + } + + @Override + public final int getEnabledSensorBits() { + return usedSensorBits; + } + @Override public int[] getEyeRenderOrder() { return config.eyeRenderOrder; } diff --git a/src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDeviceRenderer.java b/src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDeviceRenderer.java index 6650342e7..21567a0f1 100644 --- a/src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDeviceRenderer.java +++ b/src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDeviceRenderer.java @@ -49,7 +49,7 @@ import com.jogamp.opengl.util.GLArrayDataServer; import com.jogamp.opengl.util.glsl.ShaderCode; import com.jogamp.opengl.util.glsl.ShaderProgram; import com.jogamp.opengl.util.stereo.EyeParameter; -import com.jogamp.opengl.util.stereo.EyePose; +import com.jogamp.opengl.util.stereo.ViewerPose; import com.jogamp.opengl.util.stereo.StereoDevice; import com.jogamp.opengl.util.stereo.StereoDeviceRenderer; import com.jogamp.opengl.util.stereo.StereoUtil; @@ -82,7 +82,6 @@ public class GenericStereoDeviceRenderer implements StereoDeviceRenderer { private final EyeParameter eyeParameter; - private final EyePose eyePose; @Override public final RectangleImmutable getViewport() { return viewport; } @@ -90,12 +89,9 @@ public class GenericStereoDeviceRenderer implements StereoDeviceRenderer { @Override public final EyeParameter getEyeParameter() { return eyeParameter; } - @Override - public final EyePose getLastEyePose() { return eyePose; } - - private GenericEye(final GenericStereoDevice device, final int distortionBits, - final float[] eyePositionOffset, final EyeParameter eyeParam, - final DimensionImmutable textureSize, final RectangleImmutable eyeViewport) { + /* pp */ GenericEye(final GenericStereoDevice device, final int distortionBits, + final float[] eyePositionOffset, final EyeParameter eyeParam, + final DimensionImmutable textureSize, final RectangleImmutable eyeViewport) { this.eyeName = eyeParam.number; this.distortionBits = distortionBits; this.viewport = eyeViewport; @@ -123,10 +119,6 @@ public class GenericStereoDeviceRenderer implements StereoDeviceRenderer { this.eyeParameter = eyeParam; - this.eyePose = new EyePose(eyeName); - - updateEyePose(device); // 1st init - // Setup: eyeToSourceUVScale, eyeToSourceUVOffset if( usePP ) { final ScaleAndOffset2D textureScaleAndOffset = new ScaleAndOffset2D(eyeParam.fovhv, textureSize, eyeViewport); @@ -333,18 +325,18 @@ public class GenericStereoDeviceRenderer implements StereoDeviceRenderer { indices.enableBuffer(gl, false); } - private void dispose(final GL2ES2 gl) { + /* pp */ void dispose(final GL2ES2 gl) { if( null == iVBO ) return; iVBO.destroy(gl); indices.destroy(gl); } - private void enableVBO(final GL2ES2 gl, final boolean enable) { + /* pp */ void enableVBO(final GL2ES2 gl, final boolean enable) { if( null == iVBO ) return; iVBO.enableBuffer(gl, enable); indices.bindBuffer(gl, enable); // keeps VBO binding if enable:=true } - private void updateUniform(final GL2ES2 gl, final ShaderProgram sp) { + /* pp */ void updateUniform(final GL2ES2 gl, final ShaderProgram sp) { if( null == iVBO ) return; gl.glUniform(eyeToSourceUVScale); gl.glUniform(eyeToSourceUVOffset); @@ -354,15 +346,6 @@ public class GenericStereoDeviceRenderer implements StereoDeviceRenderer { } } - /** - * Updates {@link #ovrEyePose} and it's extracted - * {@link #eyeRenderPoseOrientation} and {@link #eyeRenderPosePosition}. - * @param hmdCtx used get the {@link #ovrEyePose} via {@link OVR#ovrHmd_GetEyePose(OvrHmdContext, int)} - */ - private EyePose updateEyePose(final GenericStereoDevice hmdCtx) { - return eyePose; - } - @Override public String toString() { final String ppTxt = null == iVBO ? ", no post-processing" : @@ -373,12 +356,13 @@ public class GenericStereoDeviceRenderer implements StereoDeviceRenderer { ", "+eyeParameter+ ", vertices "+vertexCount+", indices "+indexCount+ ppTxt+ - ", desc"+eyeParameter+", "+eyePose+"]"; + ", desc "+eyeParameter+"]"; } } private final GenericStereoDevice device; private final GenericEye[] eyes; + private final ViewerPose viewerPose; private final int distortionBits; private final int textureCount; private final DimensionImmutable[] eyeTextureSizes; @@ -445,9 +429,11 @@ public class GenericStereoDeviceRenderer implements StereoDeviceRenderer { this.totalTextureSize = zeroSize; texUnit0 = null; } + viewerPose = new ViewerPose(); for(int i=0; i