From 38e51e4a5f6f35c658df10f6d48a33e3ffaea2f3 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 7 Jul 2014 23:46:19 +0200 Subject: Bug 1021: Add GenericStereoDevice* Supporting custom configurations; Hook-in oculusvr-sdk java distortion-mesh calculation if available StereoDeviceFactory support new GenericStereoDeviceFactory, with it's GenericStereoDevice and GenericStereoDeviceRenderer. GenericStereoDevice maintains different configurations, triggered either by passing a GenericStereoDevice.Config instance directly or by the device-index parameter: - 0: monoscopi device: No post-processing - 1: stereoscopic device SBS: No post-processing - 2: stereoscopic device SBS + Lenses: Distortion post-processing (only available w/ oculusvr-sdk sub-module) Producing a 'GenericStereoDevice.Config' instance is self containing and may extend if supporting more device types like top-bottom, interlaced etc. StereoDemo01 handles all use-cases and may be used as a test-bed to add and experiment with stereoscopy, devices and settings. --- .../test/junit/jogl/stereo/StereoDemo01.java | 81 +++++++++++++++++----- 1 file changed, 65 insertions(+), 16 deletions(-) (limited to 'src/test') diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/stereo/StereoDemo01.java b/src/test/com/jogamp/opengl/test/junit/jogl/stereo/StereoDemo01.java index b33b18358..05685c05a 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/stereo/StereoDemo01.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/stereo/StereoDemo01.java @@ -30,6 +30,7 @@ package com.jogamp.opengl.test.junit.jogl.stereo; import java.io.File; import java.net.URI; import java.net.URISyntaxException; +import java.util.Arrays; import javax.media.nativewindow.util.DimensionImmutable; import javax.media.nativewindow.util.PointImmutable; @@ -37,6 +38,8 @@ import javax.media.opengl.GL; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLProfile; +import jogamp.opengl.util.stereo.GenericStereoDevice; + import com.jogamp.common.util.IOUtil; import com.jogamp.common.util.ReflectionUtil; import com.jogamp.newt.event.KeyAdapter; @@ -56,6 +59,7 @@ import com.jogamp.opengl.util.stereo.StereoDeviceRenderer; import com.jogamp.opengl.util.stereo.StereoDeviceFactory; import com.jogamp.opengl.util.stereo.StereoClientRenderer; import com.jogamp.opengl.util.stereo.StereoGLEventListener; +import com.jogamp.opengl.util.stereo.StereoUtil; /** * All distortions, no multisampling, bilinear filtering, manual-swap and using two FBOs (default, good) @@ -103,8 +107,14 @@ public class StereoDemo01 { static String useFilmFile = null; static String useFilmURI = null; static String stereoRendererListenerName = null; + static StereoDeviceFactory.DeviceType deviceType = StereoDeviceFactory.DeviceType.Default; + static int deviceIndex = 0; public static void main(final String args[]) throws InterruptedException, URISyntaxException { + boolean useRecommendedDistortionBits = true; + int posx = -1; + int posy = -1; + for(int i=0; i 1 ) { + System.err.println("Default Fov[1]: "+defaultEyeFov[1]); + System.err.println("Default Fov[1]: "+defaultEyeFov[1].toStringInDegrees()); + } + + final float[] eyePositionOffset = null == movieSimple || isGenericDevice ? stereoDevice.getDefaultEyePositionOffset() // default + : new float[] { 0f, 0.3f, 0f }; // better fixed movie position + System.err.println("Eye Position Offset: "+Arrays.toString(eyePositionOffset)); - final float[] eyePositionOffset = null == movieSimple ? StereoDevice.DEFAULT_EYE_POSITION_OFFSET // default - : new float[] { 0f, 0.3f, 0f }; // better fixed movie position final int textureUnit = 0; - final int distortionBits = ( useVignette ? StereoDeviceRenderer.DISTORTION_VIGNETTE : 0 ) | - ( useChromatic ? StereoDeviceRenderer.DISTORTION_CHROMATIC : 0 ) | - ( useTimewarp ? StereoDeviceRenderer.DISTORTION_TIMEWARP : 0 ); + final int reqDistortionBits; + if( useRecommendedDistortionBits ) { + reqDistortionBits = stereoDevice.getRecommendedDistortionBits(); + } else { + reqDistortionBits = ( useVignette ? StereoDeviceRenderer.DISTORTION_VIGNETTE : 0 ) | + ( useChromatic ? StereoDeviceRenderer.DISTORTION_CHROMATIC : 0 ) | + ( useTimewarp ? StereoDeviceRenderer.DISTORTION_TIMEWARP : 0 ); + } + System.err.println("Requesting Distortion Bits: "+StereoUtil.distortionBitsToString(reqDistortionBits)); + final float pixelsPerDisplayPixel = 1f; final StereoDeviceRenderer stereoDeviceRenderer = - stereoDevice.createRenderer(distortionBits, useSingleFBO ? 1 : 2, eyePositionOffset, + stereoDevice.createRenderer(reqDistortionBits, useSingleFBO ? 1 : 2, eyePositionOffset, defaultEyeFov, pixelsPerDisplayPixel, textureUnit); System.err.println("StereoDeviceRenderer: "+stereoDeviceRenderer); -- cgit v1.2.3