summaryrefslogtreecommitdiffstats
path: root/src/oculusvr/classes/com
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-07-03 09:35:34 +0200
committerSven Gothel <[email protected]>2014-07-03 09:35:34 +0200
commitd44e8ada30d62149c5d4d4b8fdba7cc33f8c765b (patch)
treeb05fbfb142497d7d62760d8d908236c5f7280fe5 /src/oculusvr/classes/com
parent36327e24cf586b50bf18e87d7d13d53eb41cf1d9 (diff)
Bug 1021: Refine Stereo Rendering API and OculusVR implementing renderer
Refine API in regards to proper package names, interface and high-level access to eye specific constant parameter and variable eye movement. +++ Commit 36327e24cf586b50bf18e87d7d13d53eb41cf1d9 introduced 'GLEventListener2' Move javax.media.opengl.GLEventListener2 -> com.jogamp.opengl.util.CustomRendererListener -> com.jogamp.opengl.util.stereo.StereoRendererListener StereoRendererListener adds stereoscopic specific: public void reshapeEye(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height, final EyeParameter eyeParam, final EyePose eyePose); .. see below. ++ Add com.jogamp.opengl.util.stereo: - EyeParameter (Constant eye parameters, like IPD and FOV) - EyePose (Current eye position and orientation) +++ Add com.jogamp.opengl.math.FovHVHalves to support non-centered bi-directional FOV for lenses. Add respective FloatUtil.makePerspective(.. FovHVHalves fovhv ) variant. +++
Diffstat (limited to 'src/oculusvr/classes/com')
-rw-r--r--src/oculusvr/classes/com/jogamp/opengl/oculusvr/OVRSBSRendererDualFBO.java40
-rw-r--r--src/oculusvr/classes/com/jogamp/opengl/oculusvr/OVRSBSRendererSingleFBO.java38
2 files changed, 17 insertions, 61 deletions
diff --git a/src/oculusvr/classes/com/jogamp/opengl/oculusvr/OVRSBSRendererDualFBO.java b/src/oculusvr/classes/com/jogamp/opengl/oculusvr/OVRSBSRendererDualFBO.java
index b10a58842..ab53862cd 100644
--- a/src/oculusvr/classes/com/jogamp/opengl/oculusvr/OVRSBSRendererDualFBO.java
+++ b/src/oculusvr/classes/com/jogamp/opengl/oculusvr/OVRSBSRendererDualFBO.java
@@ -31,7 +31,6 @@ import javax.media.opengl.GL;
import javax.media.opengl.GL2ES2;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLEventListener;
-import javax.media.opengl.GLEventListener2;
import jogamp.opengl.oculusvr.OVRDistortion;
@@ -40,35 +39,27 @@ import com.jogamp.oculusvr.ovrFrameTiming;
import com.jogamp.opengl.FBObject;
import com.jogamp.opengl.FBObject.TextureAttachment;
import com.jogamp.opengl.FBObject.Attachment.Type;
-import com.jogamp.opengl.math.FloatUtil;
+import com.jogamp.opengl.util.CustomRendererListener;
+import com.jogamp.opengl.util.stereo.StereoRendererListener;
/**
* OculusVR (OVR) <i>Side By Side</i> Distortion Renderer utilizing {@link OVRDistortion}
* implementing {@link GLEventListener} for convenience.
* <p>
- * Implementation renders an {@link GLEventListener2} instance
+ * Implementation renders an {@link StereoRendererListener} instance
* side-by-side using two {@link FBObject}s according to {@link OVRDistortion}.
* </p>
*/
public class OVRSBSRendererDualFBO implements GLEventListener {
-
- private final float[] mat4Projection = new float[16];
- private final float[] mat4Modelview = new float[16];
private final OVRDistortion dist;
private final boolean ownsDist;
- private final GLEventListener2 upstream;
+ private final StereoRendererListener upstream;
private final FBObject[] fbos;
- // final float[] eyePos = { 0.0f, 1.6f, -5.0f };
- private final float[] eyePos = { 0.0f, 0.0f, -20.0f };
- // EyePos.y = ovrHmd_GetFloat(HMD, OVR_KEY_EYE_HEIGHT, EyePos.y);
- private float eyeYaw = FloatUtil.PI; // 180 degrees in radians
- private float frustumNear = 0.1f;
- private float frustumFar = 7000f;
private int numSamples;
private final TextureAttachment[] fboTexs;
- public OVRSBSRendererDualFBO(final OVRDistortion dist, final boolean ownsDist, final GLEventListener2 upstream, final int numSamples) {
+ public OVRSBSRendererDualFBO(final OVRDistortion dist, final boolean ownsDist, final StereoRendererListener upstream, final int numSamples) {
this.dist = dist;
this.ownsDist = ownsDist;
this.upstream = upstream;
@@ -79,20 +70,6 @@ public class OVRSBSRendererDualFBO implements GLEventListener {
fboTexs = new TextureAttachment[2];
}
- /**
- *
- * @param eyePos
- * @param eyeYaw
- * @param frustumNear
- * @param frustumFar
- */
- public void setUpstreamPMVParams(final float[] eyePos, final float eyeYaw, final float frustumNear, final float frustumFar) {
- System.arraycopy(eyePos, 0, this.eyePos, 0, 3);
- this.eyeYaw = eyeYaw;
- this.frustumNear = frustumNear;
- this.frustumFar = frustumFar;
- }
-
private void initFBOs(final GL gl, final int width, final int height) {
// remove all texture attachments, since MSAA uses just color-render-buffer
// and non-MSAA uses texture2d-buffer
@@ -191,9 +168,10 @@ public class OVRSBSRendererDualFBO implements GLEventListener {
final int[] viewport = eyeDist.viewport;
gl.glViewport(viewport[0], viewport[1], viewport[2], viewport[3]);
- dist.getSBSUpstreamPMV(eyeNum, eyePos, eyeYaw, frustumNear, frustumFar, mat4Projection, mat4Modelview);
- upstream.setProjectionModelview(drawable, mat4Projection, mat4Modelview);
- upstream.display(drawable, eyeNum > 0 ? GLEventListener2.DISPLAY_REPEAT : 0);
+ dist.updateEyePose(eyeNum);
+ upstream.reshapeEye(drawable, viewport[0], viewport[1], viewport[2], viewport[3],
+ dist.getEyeParam(eyeNum), dist.updateEyePose(eyeNum));
+ upstream.display(drawable, eyeNum > 0 ? CustomRendererListener.DISPLAY_REPEAT : 0);
fbos[eyeNum].unbind(gl);
}
gl.glViewport(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
diff --git a/src/oculusvr/classes/com/jogamp/opengl/oculusvr/OVRSBSRendererSingleFBO.java b/src/oculusvr/classes/com/jogamp/opengl/oculusvr/OVRSBSRendererSingleFBO.java
index 22b8b37ce..c9d307665 100644
--- a/src/oculusvr/classes/com/jogamp/opengl/oculusvr/OVRSBSRendererSingleFBO.java
+++ b/src/oculusvr/classes/com/jogamp/opengl/oculusvr/OVRSBSRendererSingleFBO.java
@@ -31,7 +31,6 @@ import javax.media.opengl.GL;
import javax.media.opengl.GL2ES2;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLEventListener;
-import javax.media.opengl.GLEventListener2;
import jogamp.opengl.oculusvr.OVRDistortion;
@@ -40,35 +39,28 @@ import com.jogamp.oculusvr.ovrFrameTiming;
import com.jogamp.opengl.FBObject;
import com.jogamp.opengl.FBObject.TextureAttachment;
import com.jogamp.opengl.FBObject.Attachment.Type;
-import com.jogamp.opengl.math.FloatUtil;
+import com.jogamp.opengl.util.CustomRendererListener;
+import com.jogamp.opengl.util.stereo.StereoRendererListener;
/**
* OculusVR (OVR) <i>Side By Side</i> Distortion Renderer utilizing {@link OVRDistortion}
* implementing {@link GLEventListener} for convenience.
* <p>
- * Implementation renders an {@link GLEventListener2} instance
+ * Implementation renders an {@link StereoRendererListener} instance
* side-by-side within one {@link FBObject} according to {@link OVRDistortion}.
* </p>
*/
public class OVRSBSRendererSingleFBO implements GLEventListener {
- private final float[] mat4Projection = new float[16];
- private final float[] mat4Modelview = new float[16];
private final OVRDistortion dist;
private final boolean ownsDist;
- private final GLEventListener2 upstream;
+ private final StereoRendererListener upstream;
private final FBObject fbo0;
- // final float[] eyePos = { 0.0f, 1.6f, -5.0f };
- private final float[] eyePos = { 0.0f, 0.0f, -20.0f };
- // EyePos.y = ovrHmd_GetFloat(HMD, OVR_KEY_EYE_HEIGHT, EyePos.y);
- private float eyeYaw = FloatUtil.PI; // 180 degrees in radians
- private float frustumNear = 0.1f;
- private float frustumFar = 7000f;
private int numSamples;
private TextureAttachment fbo0Tex;
- public OVRSBSRendererSingleFBO(final OVRDistortion dist, final boolean ownsDist, final GLEventListener2 upstream, final int numSamples) {
+ public OVRSBSRendererSingleFBO(final OVRDistortion dist, final boolean ownsDist, final StereoRendererListener upstream, final int numSamples) {
this.dist = dist;
this.ownsDist = ownsDist;
this.upstream = upstream;
@@ -76,20 +68,6 @@ public class OVRSBSRendererSingleFBO implements GLEventListener {
fbo0 = new FBObject();
}
- /**
- *
- * @param eyePos
- * @param eyeYaw
- * @param frustumNear
- * @param frustumFar
- */
- public void setUpstreamPMVParams(final float[] eyePos, final float eyeYaw, final float frustumNear, final float frustumFar) {
- System.arraycopy(eyePos, 0, this.eyePos, 0, 3);
- this.eyeYaw = eyeYaw;
- this.frustumNear = frustumNear;
- this.frustumFar = frustumFar;
- }
-
private void initFBOs(final GL gl, final int width, final int height) {
// remove all texture attachments, since MSAA uses just color-render-buffer
// and non-MSAA uses texture2d-buffer
@@ -170,9 +148,9 @@ public class OVRSBSRendererSingleFBO implements GLEventListener {
final int[] viewport = eyeDist.viewport;
gl.glViewport(viewport[0], viewport[1], viewport[2], viewport[3]);
- dist.getSBSUpstreamPMV(eyeNum, eyePos, eyeYaw, frustumNear, frustumFar, mat4Projection, mat4Modelview);
- upstream.setProjectionModelview(drawable, mat4Projection, mat4Modelview);
- upstream.display(drawable, eyeNum > 0 ? GLEventListener2.DISPLAY_REPEAT | GLEventListener2.DISPLAY_DONTCLEAR : 0);
+ upstream.reshapeEye(drawable, viewport[0], viewport[1], viewport[2], viewport[3],
+ dist.getEyeParam(eyeNum), dist.updateEyePose(eyeNum));
+ upstream.display(drawable, eyeNum > 0 ? CustomRendererListener.DISPLAY_REPEAT | CustomRendererListener.DISPLAY_DONTCLEAR : 0);
}
fbo0.unbind(gl);
gl.glViewport(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight());