summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/util
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2015-07-18 03:50:02 +0200
committerSven Gothel <[email protected]>2015-07-18 03:50:02 +0200
commit53966f92042d44483cb44f6c6b3c95a6a1fdd325 (patch)
tree12e5d23ad9bf6607f97cea59110b003baf356c4f /src/jogl/classes/jogamp/opengl/util
parent07823202e897751e742a9a96d7d683033c5e07d5 (diff)
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
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/util')
-rw-r--r--src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDevice.java56
-rw-r--r--src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDeviceRenderer.java46
2 files changed, 65 insertions, 37 deletions
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<defaultEyeFov.length; i++) {
defaultEyeFov[i] = config.defaultEyeParam[i].fovhv;
}
+
+ // default
+ usedSensorBits = 0;
}
@Override
@@ -144,7 +149,8 @@ public class GenericStereoDevice implements StereoDevice {
@Override
public String toString() {
- return "GenericStereoDevice["+config+", surfacePos "+surfacePos+"]";
+ return "GenericStereoDevice["+config+", surfacePos "+surfacePos+
+ ", sensorBits[enabled ["+StereoUtil.sensorBitsToString(getEnabledSensorBits())+"]]]";
}
public void setSurfacePosition(final int x, final int y) {
@@ -153,7 +159,7 @@ public class GenericStereoDevice implements StereoDevice {
@Override
public final void dispose() {
- // NOP
+ stopSensors();
}
@Override
@@ -184,21 +190,42 @@ public class GenericStereoDevice implements StereoDevice {
}
@Override
- public final boolean startSensors(final boolean start) {
- if( start && !sensorsStarted ) {
- if( startSensorsImpl(true) ) {
+ public final boolean startSensors(final int desiredSensorBits, final int requiredSensorBits) {
+ if( !sensorsStarted ) {
+ if( requiredSensorBits != ( config.supportedSensorBits & requiredSensorBits ) ) {
+ // required sensors not available
+ return false;
+ }
+ if( 0 == ( config.supportedSensorBits & ( requiredSensorBits | desiredSensorBits ) ) ) {
+ // no sensors available
+ return false;
+ }
+ if( startSensorsImpl(true, desiredSensorBits, requiredSensorBits) ) {
sensorsStarted = true;
return true;
} else {
- sensorsStarted = false;
return false;
}
- } else if( sensorsStarted ) {
- if( startSensorsImpl(false) ) {
+ } else {
+ // No state change -> 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,12 +233,21 @@ 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; }
@Override
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<eyeParam.length; i++) {
eyes[i] = new GenericEye(context, this.distortionBits, eyePositionOffset, eyeParam[i], textureSizes[i], eyeViewports[i]);
}
+
sp = null;
}
@@ -559,8 +545,14 @@ public class GenericStereoDeviceRenderer implements StereoDeviceRenderer {
}
@Override
- public final EyePose updateEyePose(final int eyeNum) {
- return eyes[eyeNum].updateEyePose(device);
+ public final ViewerPose updateViewerPose() {
+ // NOP
+ return viewerPose;
+ }
+
+ @Override
+ public final ViewerPose getLastViewerPose() {
+ return viewerPose;
}
@Override