diff options
Diffstat (limited to 'src/jogl/classes/jogamp/opengl')
3 files changed, 79 insertions, 53 deletions
diff --git a/src/jogl/classes/jogamp/opengl/ProjectFloat.java b/src/jogl/classes/jogamp/opengl/ProjectFloat.java index ee9560214..5ec5a8e3f 100644 --- a/src/jogl/classes/jogamp/opengl/ProjectFloat.java +++ b/src/jogl/classes/jogamp/opengl/ProjectFloat.java @@ -170,7 +170,8 @@ public class ProjectFloat { * @param aspect * @param zNear * @param zFar - * @throws GLException with GL_INVALID_VALUE if zNear is <= 0, or zFar < 0, or if zNear == zFar. + * @throws GLException if {@code zNear <= 0} or {@code zFar <= zNear} + * @see FloatUtil#makePerspective(float[], int, boolean, float, float, float, float) */ public void gluPerspective(final GLMatrixFunc gl, final float fovy_deg, final float aspect, final float zNear, final float zFar) throws GLException { gl.glMultMatrixf(FloatUtil.makePerspective(mat4Tmp1, 0, true, fovy_deg * FloatUtil.PI / 180.0f, aspect, zNear, zFar), 0); diff --git a/src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDevice.java b/src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDevice.java index 9c0a5045b..bfe93b59c 100644 --- a/src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDevice.java +++ b/src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDevice.java @@ -36,9 +36,11 @@ import com.jogamp.nativewindow.util.RectangleImmutable; import com.jogamp.opengl.math.FovHVHalves; import com.jogamp.opengl.util.stereo.StereoDeviceConfig; import com.jogamp.opengl.util.stereo.EyeParameter; +import com.jogamp.opengl.util.stereo.LocationSensorParameter; 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 +119,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 +140,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 +150,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,52 +160,69 @@ public class GenericStereoDevice implements StereoDevice { @Override public final void dispose() { - // NOP + stopSensors(); } @Override - public boolean isValid() { - return true; - } + public boolean isValid() { return true; } @Override - public final PointImmutable getPosition() { - return surfacePos; - } + public final PointImmutable getPosition() { return surfacePos; } @Override - public final DimensionImmutable getSurfaceSize() { - return config.surfaceSizeInPixels; - } + public final DimensionImmutable getSurfaceSize() { return config.surfaceSizeInPixels; } @Override public int getRequiredRotation() { return 0; } @Override - public float[] getDefaultEyePositionOffset() { - return config.defaultEyeParam[0].positionOffset; - } + public float[] getDefaultEyePositionOffset() { return config.defaultEyeParam[0].positionOffset; } @Override - public final FovHVHalves[] getDefaultFOV() { - return defaultEyeFov; - } + public final FovHVHalves[] getDefaultFOV() { return defaultEyeFov; } + + @Override + public final LocationSensorParameter getLocationSensorParams() { return null; } @Override - public final boolean startSensors(final boolean start) { - if( start && !sensorsStarted ) { - if( startSensorsImpl(true) ) { + public final void resetLocationSensorOrigin() { } + + @Override + 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 +230,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 |