Skip to content

Commit

Permalink
Merge pull request #250 from thomasflynn/ovr_062
Browse files Browse the repository at this point in the history
port to oculus mobile sdk 0.6.2
  • Loading branch information
thomasflynn committed Sep 16, 2015
2 parents a9d98e7 + c339668 commit 7a27901
Show file tree
Hide file tree
Showing 47 changed files with 157 additions and 67 deletions.
2 changes: 2 additions & 0 deletions GVRf/Framework/jni/engine/memory/gl_delete.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@

#include <vector>
#include <pthread.h>
#ifndef GL_ES_VERSION_3_0
#include "GLES3/gl3.h"
#endif

#define GVR_INVALID 0

Expand Down
2 changes: 2 additions & 0 deletions GVRf/Framework/jni/engine/renderer/renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@
#define __gl2_h_
#include "EGL/egl.h"
#include "EGL/eglext.h"
#ifndef GL_ES_VERSION_3_0
#include "GLES3/gl3.h"
#include <GLES2/gl2ext.h>
#include "GLES3/gl3ext.h"
#endif

#include "glm/glm.hpp"

Expand Down
2 changes: 2 additions & 0 deletions GVRf/Framework/jni/gl/gl_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
#ifndef GL_BUFFER_H_
#define GL_BUFFER_H_

#ifndef GL_ES_VERSION_3_0
#include "GLES3/gl3.h"
#endif

#include "engine/memory/gl_delete.h"

Expand Down
2 changes: 2 additions & 0 deletions GVRf/Framework/jni/gl/gl_frame_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
#ifndef GL_FRAME_BUFFER_H_
#define GL_FRAME_BUFFER_H_

#ifndef GL_ES_VERSION_3_0
#include "GLES3/gl3.h"
#endif

#include "engine/memory/gl_delete.h"

Expand Down
2 changes: 2 additions & 0 deletions GVRf/Framework/jni/gl/gl_program.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
#ifndef GL_PROGRAM_H_
#define GL_PROGRAM_H_

#ifndef GL_ES_VERSION_3_0
#include "GLES3/gl3.h"
#endif

#include "engine/memory/gl_delete.h"

Expand Down
2 changes: 2 additions & 0 deletions GVRf/Framework/jni/gl/gl_render_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
#ifndef GL_RENDER_BUFFER_H_
#define GL_RENDER_BUFFER_H_

#ifndef GL_ES_VERSION_3_0
#include "GLES3/gl3.h"
#endif

#include "engine/memory/gl_delete.h"

Expand Down
3 changes: 3 additions & 0 deletions GVRf/Framework/jni/gl/gl_texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
#endif /* GL_EXT_texture_filter_anisotropic */

#ifndef GL_ES_VERSION_3_0
#include "GLES3/gl3.h"
#endif

#include "util/gvr_log.h"

#include "engine/memory/gl_delete.h"
Expand Down
3 changes: 3 additions & 0 deletions GVRf/Framework/jni/objects/mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
#include <vector>
#include <string>

#ifndef GL_ES_VERSION_3_0
#include "GLES3/gl3.h"
#endif

#include "glm/glm.hpp"
#include "gl/gl_buffer.h"
#include "gl/gl_program.h"
Expand Down
30 changes: 20 additions & 10 deletions GVRf/Framework/jni/oculus/activity_jni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,21 @@ template <class R> void GVRActivityT<R>::Configure(OVR::ovrSettings & settings)
jclass eyeParmsClass = env->GetObjectClass(eyeParmsSettings);
settings.EyeBufferParms.multisamples = env->GetIntField(eyeParmsSettings, env->GetFieldID(eyeParmsClass, "multiSamples", "I"));
settings.EyeBufferParms.resolveDepth = env->GetBooleanField(eyeParmsSettings, env->GetFieldID(eyeParmsClass, "resolveDepth", "Z"));
jint resolution = env->GetIntField(eyeParmsSettings, env->GetFieldID(eyeParmsClass, "resolution", "I"));
if(resolution == -1){
env->SetIntField(eyeParmsSettings, env->GetFieldID(eyeParmsClass, "resolution", "I"), settings.EyeBufferParms.resolution);

jint resolutionWidth = env->GetIntField(eyeParmsSettings, env->GetFieldID(eyeParmsClass, "resolutionWidth", "I"));
if(resolutionWidth == -1){
env->SetIntField(eyeParmsSettings, env->GetFieldID(eyeParmsClass, "resolutionWidth", "I"), settings.EyeBufferParms.resolutionWidth);
}else{
settings.EyeBufferParms.resolution = resolution;
settings.EyeBufferParms.resolutionWidth = resolutionWidth;
}

jint resolutionHeight = env->GetIntField(eyeParmsSettings, env->GetFieldID(eyeParmsClass, "resolutionHeight", "I"));
if(resolutionHeight == -1){
env->SetIntField(eyeParmsSettings, env->GetFieldID(eyeParmsClass, "resolutionHeight", "I"), settings.EyeBufferParms.resolutionHeight);
}else{
settings.EyeBufferParms.resolutionHeight = resolutionHeight;
}

jobject depthFormat = env->GetObjectField(eyeParmsSettings, env->GetFieldID(eyeParmsClass, "depthFormat", "Lorg/gearvrf/utility/VrAppSettings$EyeBufferParms$DepthFormat;"));
jmethodID getValueID;
getValueID = env->GetMethodID(env->GetObjectClass(depthFormat),"getValue","()I");
Expand Down Expand Up @@ -320,7 +329,8 @@ template <class R> void GVRActivityT<R>::Configure(OVR::ovrSettings & settings)
}
logInfo << "; ResolveDepth = " << settings.EyeBufferParms.resolveDepth
<< "; multiSample = " << settings.EyeBufferParms.multisamples
<< "; resolution = " << settings.EyeBufferParms.resolution
<< "; resolutionWidth = " << settings.EyeBufferParms.resolutionWidth
<< "; resolutionHeight = " << settings.EyeBufferParms.resolutionHeight
<< std::endl;
logInfo << "====== Head Model Configuration ======" << std::endl;
logInfo << "EyeHeight = " << settings.HeadModelParms.EyeHeight
Expand Down Expand Up @@ -354,15 +364,15 @@ template <class R> void GVRActivityT<R>::OneTimeShutdown()
// Free GL resources
}

template <class R> OVR::Matrix4f GVRActivityT<R>::GetEyeView(const int eye, const float fovDegrees) const
template <class R> OVR::Matrix4f GVRActivityT<R>::GetEyeView(const int eye, const float fovDegreesX, const float fovDegreesY) const
{
const OVR::Matrix4f projectionMatrix = Scene.GetEyeProjectionMatrix( eye, fovDegrees );
const OVR::Matrix4f projectionMatrix = Scene.GetEyeProjectionMatrix( eye, fovDegreesX, fovDegreesY );
const OVR::Matrix4f viewMatrix = Scene.GetEyeViewMatrix( eye );
return ( projectionMatrix * viewMatrix );
}

template <class R> OVR::Matrix4f GVRActivityT<R>::DrawEyeView(const int eye, const float fovDegrees, ovrFrameParms & frameParms) {
const OVR::Matrix4f view = GetEyeView(eye, fovDegrees);
template <class R> OVR::Matrix4f GVRActivityT<R>::DrawEyeView(const int eye, const float fovDegreesX, const float fovDegreesY, ovrFrameParms & frameParms) {
const OVR::Matrix4f view = GetEyeView(eye, fovDegreesX, fovDegreesY);

// Transpose view matrix from oculus to mvp_matrix to rendering correctly with gvrf renderer.
mvp_matrix = glm::mat4(view.M[0][0], view.M[1][0], view.M[2][0],
Expand All @@ -380,7 +390,7 @@ template <class R> OVR::Matrix4f GVRActivityT<R>::DrawEyeView(const int eye, con
cameraRig_->getHeadTransform()->set_rotation(headRotation);

JNIEnv* jni = app->GetVrJni();
jni->CallVoidMethod(app->GetJava()->ActivityObject, drawEyeViewMethodId, eye, fovDegrees);
jni->CallVoidMethod(app->GetJava()->ActivityObject, drawEyeViewMethodId, eye, fovDegreesY);

if (eye == 1) {
jni->CallVoidMethod(app->GetJava()->ActivityObject, afterDrawEyesMethodId);
Expand Down
4 changes: 2 additions & 2 deletions GVRf/Framework/jni/oculus/activity_jni.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ template <class R> class GVRActivityT : public OVR::VrAppInterface
virtual void Configure( OVR::ovrSettings & settings );
virtual void OneTimeInit( const char * fromPackage, const char * launchIntentJSON, const char * launchIntentURI );
virtual void OneTimeShutdown();
virtual OVR::Matrix4f DrawEyeView( const int eye, const float fovDegrees, ovrFrameParms & frameParms );
virtual OVR::Matrix4f DrawEyeView( const int eye, const float fovDegreesX, const float fovDegreesY, ovrFrameParms & frameParms );
virtual OVR::Matrix4f Frame( const OVR::VrFrame & vrFrame );
virtual bool OnKeyEvent( const int keyCode, const int repeatCount, const OVR::KeyEventType eventType );
bool updateSensoredScene();
Expand Down Expand Up @@ -69,7 +69,7 @@ template <class R> class GVRActivityT : public OVR::VrAppInterface
}

JNIEnv* uiJni; // for use by the Java UI thread
OVR::Matrix4f GetEyeView( const int eye, const float fovDegrees ) const;
OVR::Matrix4f GetEyeView( const int eye, const float fovDegreesX, const float fovDegreesY ) const;

jclass activityClass; // must be looked up from main thread or FindClass() will fail

Expand Down
3 changes: 2 additions & 1 deletion GVRf/Framework/jni/util/gvr_gl.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@

#include <android/bitmap.h>
#include "util/gvr_jni.h"
#ifndef GL_ES_VERSION_3_0
#include <GLES3/gl3.h>
#include <GLES3/gl3ext.h>

#endif
#include "util/gvr_log.h"

#define _GVRF_USE_GLES3_ 1
Expand Down
4 changes: 2 additions & 2 deletions GVRf/Framework/src/org/gearvrf/GVRLensInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void update() {
*/
public int getFBOWidth() {
if (!mCustomFBOSize)
return mAppSettings.getEyeBufferParms().getResolution();
return mAppSettings.getEyeBufferParms().getResolutionWidth();
else
return mFBOWidth;
}
Expand All @@ -101,7 +101,7 @@ public void setFBOWidth(int width) {
*/
public int getFBOHeight() {
if (!mCustomFBOSize)
return mAppSettings.getEyeBufferParms().getResolution();
return mAppSettings.getEyeBufferParms().getResolutionHeight();
else
return mFBOHeight;
}
Expand Down
4 changes: 2 additions & 2 deletions GVRf/Framework/src/org/gearvrf/GVRMonoscopicViewManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ class GVRMonoscopicViewManager extends GVRViewManager {
GVRPerspectiveCamera.setDefaultFovY(gvrActivity.getAppSettings()
.getEyeBufferParms().getFovY());
int fboWidth = gvrActivity.getAppSettings().getEyeBufferParms()
.getResolution();
.getResolutionWidth();
int fboHeight = gvrActivity.getAppSettings().getEyeBufferParms()
.getResolution();
.getResolutionHeight();
if (gvrActivity.getAppSettings().getMonoScopicModeParms()
.isMonoFullScreenMode()) {
fboWidth = screenWidthPixels;
Expand Down
11 changes: 8 additions & 3 deletions GVRf/Framework/src/org/gearvrf/GVRXMLParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,16 @@ class GVRXMLParser {
} else if (attributeName.equals("resolveDepth")) {
settings.eyeBufferParms.enableResolveDepth(Boolean
.parseBoolean(attributeValue));
} else if (attributeName.equals("resolution")) {
int resolution = Integer
} else if (attributeName.equals("resolutionWidth")) {
int resolutionWidth = Integer
.parseInt(attributeValue);
settings.eyeBufferParms
.setResolution(resolution);
.setResolutionWidth(resolutionWidth);
} else if (attributeName.equals("resolutionHeight")) {
int resolutionHeight = Integer
.parseInt(attributeValue);
settings.eyeBufferParms
.setResolutionHeight(resolutionHeight);
}
} else if (tagName.equals("head-model-parms")) {
if (attributeName.equals("interpupillaryDistance")) {
Expand Down
50 changes: 37 additions & 13 deletions GVRf/Framework/src/org/gearvrf/utility/VrAppSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,11 @@ public static class EyeBufferParms {
// Defaults to FMT_8888.
public ColorFormat colorFormat;

// Resolution for each eye buffer.
public int resolution;
// Resolution for eye buffer width.
public int resolutionWidth;

// Resolution for eye buffer height.
public int resolutionHeight;

//Is depth buffer resolved to a texture or not.
boolean resolveDepth;
Expand Down Expand Up @@ -205,22 +208,41 @@ public void setColorFormat(ColorFormat colorFormat) {
}

/**
* Get current resolution.
* Get current resolution width.
*
* @return Current resolution width.
*/
public int getResolutionWidth() {
return resolutionWidth;
}

/**
* Get current resolution height.
*
* @return Current resolution height.
*/
public int getResolutionHeight() {
return resolutionHeight;
}

/**
* Set resolution width.
*
* @return Current resolution.
* @param resolutionWidth
* Resolution width to set.
*/
public int getResolution() {
return resolution;
public void setResolutionWidth(int resolutionWidth) {
this.resolutionWidth = resolutionWidth;
}

/**
* Set resolution.
* Set resolution height.
*
* @param resolution
* Resolution to set.
* @param resolutionHeight
* Resolution height to set.
*/
public void setResolution(int resolution) {
this.resolution = resolution;
public void setResolutionHeight(int resolutionHeight) {
this.resolutionHeight = resolutionHeight;
}

/**
Expand Down Expand Up @@ -283,7 +305,8 @@ public float getFovY() {
public EyeBufferParms() {
multiSamples = 2;
resolveDepth = false;
resolution = -1;
resolutionWidth = -1;
resolutionHeight = -1;
depthFormat = DepthFormat.DEPTH_24;
colorFormat = ColorFormat.COLOR_8888;
mFovY = 90.0f;
Expand All @@ -294,7 +317,8 @@ public String toString() {
StringBuilder res = new StringBuilder();
res.append(" multiSamples = " + this.multiSamples);
res.append(" resolveDepth = " + this.resolveDepth);
res.append(" resolution = " + this.resolution);
res.append(" resolutionWidth = " + this.resolutionWidth);
res.append(" resolutionHeight = " + this.resolutionHeight);
res.append(" depthFormat = " + this.depthFormat.name());
res.append(" colorFormat = " + this.colorFormat.name());
res.append(" fovY = " + this.mFovY);
Expand Down
3 changes: 2 additions & 1 deletion GVRf/Sample/collision/assets/gvr_note4.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
depthFormat="DEPTH_24"
fov-y="90.0"
multiSamples="1"
resolution="DEFAULT"
resolutionWidth="DEFAULT"
resolutionHeight="DEFAULT"
resolveDepth="false" />

<head-model-parms
Expand Down
3 changes: 2 additions & 1 deletion GVRf/Sample/eye-picking/assets/gvr_note4.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
depthFormat="DEPTH_24"
fov-y="90.0"
multiSamples="1"
resolution="DEFAULT"
resolutionWidth="DEFAULT"
resolutionHeight="DEFAULT"
resolveDepth="false" />

<head-model-parms
Expand Down
3 changes: 2 additions & 1 deletion GVRf/Sample/gamepad/assets/gvr_note4.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
depthFormat="DEPTH_24"
fov-y="90.0"
multiSamples="1"
resolution="DEFAULT"
resolutionWidth="DEFAULT"
resolutionHeight="DEFAULT"
resolveDepth="false" />

<head-model-parms
Expand Down
3 changes: 2 additions & 1 deletion GVRf/Sample/gvr-cubemap/assets/gvr_note4.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
depthFormat="DEPTH_24"
fov-y="90.0"
multiSamples="1"
resolution="DEFAULT"
resolutionWidth="DEFAULT"
resolutionHeight="DEFAULT"
resolveDepth="false" />

<head-model-parms
Expand Down
3 changes: 2 additions & 1 deletion GVRf/Sample/gvr-litshader/assets/gvr_note4.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
depthFormat="DEPTH_24"
fov-y="90.0"
multiSamples="1"
resolution="DEFAULT"
resolutionWidth="DEFAULT"
resolutionHeight="DEFAULT"
resolveDepth="false" />

<head-model-parms
Expand Down
3 changes: 2 additions & 1 deletion GVRf/Sample/gvr-outlinesample/assets/gvr_note4.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
depthFormat="DEPTH_24"
fov-y="90.0"
multiSamples="1"
resolution="DEFAULT"
resolutionWidth="DEFAULT"
resolutionHeight="DEFAULT"
resolveDepth="false" />

<head-model-parms
Expand Down
3 changes: 2 additions & 1 deletion GVRf/Sample/gvr-pickandmove/assets/gvr_note4.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
depthFormat="DEPTH_24"
fov-y="90.0"
multiSamples="1"
resolution="DEFAULT"
resolutionWidth="DEFAULT"
resolutionHeight="DEFAULT"
resolveDepth="false" />

<head-model-parms
Expand Down
3 changes: 2 additions & 1 deletion GVRf/Sample/gvr-sample/assets/gvr_note4.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
depthFormat="DEPTH_24"
fov-y="90.0"
multiSamples="1"
resolution="DEFAULT"
resolutionWidth="DEFAULT"
resolutionHeight="DEFAULT"
resolveDepth="false" />

<head-model-parms
Expand Down
Loading

0 comments on commit 7a27901

Please sign in to comment.