void GVRActivity::onSurfaceChanged(JNIEnv& env) { LOGV("GVRActivityT::onSurfaceChanged"); initializeOculusJava(env, oculusJavaGlThread_); if (nullptr == oculusMobile_) { ovrModeParms parms = vrapi_DefaultModeParms(&oculusJavaGlThread_); configurationHelper_.getModeConfiguration(env, parms.AllowPowerSave, parms.ResetWindowFullscreen); oculusMobile_ = vrapi_EnterVrMode(&parms); oculusPerformanceParms_ = vrapi_DefaultPerformanceParms(); configurationHelper_.getPerformanceConfiguration(env, oculusPerformanceParms_); oculusHeadModelParms_ = vrapi_DefaultHeadModelParms(); configurationHelper_.getHeadModelConfiguration(env, oculusHeadModelParms_); for (int eye = 0; eye < VRAPI_FRAME_LAYER_EYE_MAX; eye++) { bool b = frameBuffer_[eye].create(mColorTextureFormatConfiguration, mWidthConfiguration, mHeightConfiguration, mMultisamplesConfiguration, mResolveDepthConfiguration, mDepthTextureFormatConfiguration); } projectionMatrix_ = ovrMatrix4f_CreateProjectionFov( vrapi_GetSystemPropertyFloat(&oculusJavaGlThread_, VRAPI_SYS_PROP_SUGGESTED_EYE_FOV_DEGREES_X), vrapi_GetSystemPropertyFloat(&oculusJavaGlThread_, VRAPI_SYS_PROP_SUGGESTED_EYE_FOV_DEGREES_Y), 0.0f, 0.0f, 1.0f, 0.0f); texCoordsTanAnglesMatrix_ = ovrMatrix4f_TanAngleMatrixFromProjection(&projectionMatrix_); } }
void GVRActivity::onSurfaceChanged(JNIEnv& env) { int maxSamples = MSAA::getMaxSampleCount(); LOGV("GVRActivityT::onSurfaceChanged"); initializeOculusJava(env, oculusJavaGlThread_); if (nullptr == oculusMobile_) { ovrModeParms parms = vrapi_DefaultModeParms(&oculusJavaGlThread_); bool AllowPowerSave, ResetWindowFullscreen; configurationHelper_.getModeConfiguration(env, AllowPowerSave, ResetWindowFullscreen); parms.Flags |=AllowPowerSave; parms.Flags |=ResetWindowFullscreen; oculusMobile_ = vrapi_EnterVrMode(&parms); oculusPerformanceParms_ = vrapi_DefaultPerformanceParms(); configurationHelper_.getPerformanceConfiguration(env, oculusPerformanceParms_); oculusHeadModelParms_ = vrapi_DefaultHeadModelParms(); configurationHelper_.getHeadModelConfiguration(env, oculusHeadModelParms_); if (mMultisamplesConfiguration > maxSamples) mMultisamplesConfiguration = maxSamples; bool multiview; configurationHelper_.getMultiviewConfiguration(env,multiview); const char* extensions = (const char*)glGetString(GL_EXTENSIONS); if(multiview && std::strstr(extensions, "GL_OVR_multiview2")!= NULL){ use_multiview = true; } if(multiview && !use_multiview){ std::string error = "Multiview is not supported by your device"; LOGE(" Multiview is not supported by your device"); throw error; } for (int eye = 0; eye < (use_multiview ? 1 :VRAPI_FRAME_LAYER_EYE_MAX); eye++) { bool b = frameBuffer_[eye].create(mColorTextureFormatConfiguration, mWidthConfiguration, mHeightConfiguration, mMultisamplesConfiguration, mResolveDepthConfiguration, mDepthTextureFormatConfiguration); } // default viewport same as window size x = 0; y = 0; width = mWidthConfiguration; height = mHeightConfiguration; configurationHelper_.getSceneViewport(env, x, y, width, height); projectionMatrix_ = ovrMatrix4f_CreateProjectionFov( vrapi_GetSystemPropertyFloat(&oculusJavaGlThread_, VRAPI_SYS_PROP_SUGGESTED_EYE_FOV_DEGREES_X), vrapi_GetSystemPropertyFloat(&oculusJavaGlThread_, VRAPI_SYS_PROP_SUGGESTED_EYE_FOV_DEGREES_Y), 0.0f, 0.0f, 1.0f, 0.0f); texCoordsTanAnglesMatrix_ = ovrMatrix4f_TanAngleMatrixFromProjection(&projectionMatrix_); } }
void GVRActivity::onSurfaceChanged(JNIEnv& env) { int maxSamples = MSAA::getMaxSampleCount(); LOGV("GVRActivityT::onSurfaceChanged"); initializeOculusJava(env, oculusJavaGlThread_); if (nullptr == oculusMobile_) { ovrModeParms parms = vrapi_DefaultModeParms(&oculusJavaGlThread_); bool allowPowerSave, resetWindowFullscreen; configurationHelper_.getModeConfiguration(env, allowPowerSave, resetWindowFullscreen); if (allowPowerSave) { parms.Flags |= VRAPI_MODE_FLAG_ALLOW_POWER_SAVE; } if (resetWindowFullscreen) { parms.Flags |= VRAPI_MODE_FLAG_RESET_WINDOW_FULLSCREEN; } oculusMobile_ = vrapi_EnterVrMode(&parms); if (gearController != nullptr) { gearController->setOvrMobile(oculusMobile_); } oculusPerformanceParms_ = vrapi_DefaultPerformanceParms(); env.ExceptionClear(); //clear a weird GearVrRemoteForBatteryWorkAround raised by Oculus configurationHelper_.getPerformanceConfiguration(env, oculusPerformanceParms_); oculusPerformanceParms_.MainThreadTid = mainThreadId_; oculusPerformanceParms_.RenderThreadTid = gettid(); oculusHeadModelParms_ = vrapi_DefaultHeadModelParms(); configurationHelper_.getHeadModelConfiguration(env, oculusHeadModelParms_); if (mMultisamplesConfiguration > maxSamples) mMultisamplesConfiguration = maxSamples; bool multiview; configurationHelper_.getMultiviewConfiguration(env,multiview); const char* extensions = (const char*)glGetString(GL_EXTENSIONS); if(multiview && std::strstr(extensions, "GL_OVR_multiview2")!= NULL){ use_multiview = true; } if(multiview && !use_multiview){ std::string error = "Multiview is not supported by your device"; LOGE(" Multiview is not supported by your device"); throw error; } clampToBorderSupported_ = nullptr != std::strstr(extensions, "GL_EXT_texture_border_clamp"); for (int eye = 0; eye < (use_multiview ? 1 :VRAPI_FRAME_LAYER_EYE_MAX); eye++) { frameBuffer_[eye].create(mColorTextureFormatConfiguration, mWidthConfiguration, mHeightConfiguration, mMultisamplesConfiguration, mResolveDepthConfiguration, mDepthTextureFormatConfiguration); } // default viewport same as window size x = 0; y = 0; width = mWidthConfiguration; height = mHeightConfiguration; configurationHelper_.getSceneViewport(env, x, y, width, height); projectionMatrix_ = ovrMatrix4f_CreateProjectionFov( vrapi_GetSystemPropertyFloat(&oculusJavaGlThread_, VRAPI_SYS_PROP_SUGGESTED_EYE_FOV_DEGREES_X), vrapi_GetSystemPropertyFloat(&oculusJavaGlThread_, VRAPI_SYS_PROP_SUGGESTED_EYE_FOV_DEGREES_Y), 0.0f, 0.0f, 1.0f, 0.0f); texCoordsTanAnglesMatrix_ = ovrMatrix4f_TanAngleMatrixFromProjection(&projectionMatrix_); } }