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 --- .../util/stereo/GenericStereoDeviceRenderer.java | 36 ++++++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) (limited to 'src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDeviceRenderer.java') diff --git a/src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDeviceRenderer.java b/src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDeviceRenderer.java index 3b9fb9c26..6650342e7 100644 --- a/src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDeviceRenderer.java +++ b/src/jogl/classes/jogamp/opengl/util/stereo/GenericStereoDeviceRenderer.java @@ -29,6 +29,7 @@ package jogamp.opengl.util.stereo; import java.nio.FloatBuffer; import java.nio.ShortBuffer; +import java.util.Arrays; import com.jogamp.nativewindow.util.Dimension; import com.jogamp.nativewindow.util.DimensionImmutable; @@ -380,7 +381,7 @@ public class GenericStereoDeviceRenderer implements StereoDeviceRenderer { private final GenericEye[] eyes; private final int distortionBits; private final int textureCount; - private final DimensionImmutable singleTextureSize; + private final DimensionImmutable[] eyeTextureSizes; private final DimensionImmutable totalTextureSize; /** if texUnit0 is null: no post-processing */ private final GLUniformData texUnit0; @@ -391,7 +392,7 @@ public class GenericStereoDeviceRenderer implements StereoDeviceRenderer { @Override public String toString() { return "GenericStereo[distortion["+StereoUtil.distortionBitsToString(distortionBits)+ - "], singleSize "+singleTextureSize+ + "], eyeTexSize "+Arrays.toString(eyeTextureSizes)+ ", sbsSize "+totalTextureSize+ ", texCount "+textureCount+", texUnit "+(null != texUnit0 ? texUnit0.intValue() : "n/a")+ ", "+PlatformPropsImpl.NEWLINE+" "+(0 < eyes.length ? eyes[0] : "none")+ @@ -404,13 +405,17 @@ public class GenericStereoDeviceRenderer implements StereoDeviceRenderer { /* pp */ GenericStereoDeviceRenderer(final GenericStereoDevice context, final int distortionBits, final int textureCount, final float[] eyePositionOffset, final EyeParameter[] eyeParam, final float pixelsPerDisplayPixel, final int textureUnit, - final DimensionImmutable singleTextureSize, final DimensionImmutable totalTextureSize, + final DimensionImmutable[] eyeTextureSizes, final DimensionImmutable totalTextureSize, final RectangleImmutable[] eyeViewports) { + if( eyeParam.length != eyeTextureSizes.length || + eyeParam.length != eyeViewports.length ) { + throw new IllegalArgumentException("eye arrays of different length"); + } this.device = context; this.eyes = new GenericEye[eyeParam.length]; this.distortionBits = ( distortionBits | context.getMinimumDistortionBits() ) & context.getSupportedDistortionBits(); final boolean usePP = null != device.config.distortionMeshProducer && 0 != this.distortionBits; - final DimensionImmutable textureSize; + final DimensionImmutable[] textureSizes; if( usePP ) { if( 1 > textureCount || 2 < textureCount ) { @@ -418,19 +423,30 @@ public class GenericStereoDeviceRenderer implements StereoDeviceRenderer { } else { this.textureCount = textureCount; } - this.singleTextureSize = singleTextureSize; + this.eyeTextureSizes = eyeTextureSizes; this.totalTextureSize = totalTextureSize; - textureSize = 1 == textureCount ? totalTextureSize : singleTextureSize; + if( 1 == textureCount ) { + textureSizes = new DimensionImmutable[eyeParam.length]; + for(int i=0; i