From 76f9edd28cda706adc268dab193b26fe90ead96e Mon Sep 17 00:00:00 2001 From: Imanol Fernandez Date: Fri, 17 Jul 2020 22:35:43 +0200 Subject: [PATCH] Move WaveVR render initialization to a separate method (#3695) Fixes #3692 --- app/src/wavevr/cpp/DeviceDelegateWaveVR.cpp | 13 ++++++++++++- app/src/wavevr/cpp/DeviceDelegateWaveVR.h | 1 + app/src/wavevr/cpp/native-lib.cpp | 12 +++++++----- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/app/src/wavevr/cpp/DeviceDelegateWaveVR.cpp b/app/src/wavevr/cpp/DeviceDelegateWaveVR.cpp index 2351b98aa..ddac693c3 100644 --- a/app/src/wavevr/cpp/DeviceDelegateWaveVR.cpp +++ b/app/src/wavevr/cpp/DeviceDelegateWaveVR.cpp @@ -194,6 +194,11 @@ struct DeviceDelegateWaveVR::State { cameras[device::EyeIndex(device::Eye::Left)] = vrb::CameraEye::Create(create); cameras[device::EyeIndex(device::Eye::Right)] = vrb::CameraEye::Create(create); InitializeCameras(); + + elbow = ElbowModel::Create(); + } + + void InitializeRender() { WVR_GetRenderTargetSize(&renderWidth, &renderHeight); VRB_GL_CHECK(glViewport(0, 0, renderWidth, renderHeight)); VRB_DEBUG("Recommended size is %ux%u", renderWidth, renderHeight); @@ -201,8 +206,10 @@ struct DeviceDelegateWaveVR::State { VRB_ERROR("Please check Wave server configuration"); return; } + if (immersiveDisplay) { + immersiveDisplay->SetEyeResolution(renderWidth, renderHeight); + } InitializeTextureQueues(); - elbow = ElbowModel::Create(); } void InitializeTextureQueues() { @@ -461,6 +468,10 @@ DeviceDelegateWaveVR::Create(vrb::RenderContextPtr& aContext) { return result; } +void DeviceDelegateWaveVR::InitializeRender() { + m.InitializeRender(); +} + device::DeviceType DeviceDelegateWaveVR::GetDeviceType() { return m.deviceType; diff --git a/app/src/wavevr/cpp/DeviceDelegateWaveVR.h b/app/src/wavevr/cpp/DeviceDelegateWaveVR.h index f4e32e93b..e51ebb1ba 100644 --- a/app/src/wavevr/cpp/DeviceDelegateWaveVR.h +++ b/app/src/wavevr/cpp/DeviceDelegateWaveVR.h @@ -14,6 +14,7 @@ typedef std::shared_ptr DeviceDelegateWaveVRPtr; class DeviceDelegateWaveVR : public DeviceDelegate { public: static DeviceDelegateWaveVRPtr Create(vrb::RenderContextPtr& aContext); + void InitializeRender(); // DeviceDelegate interface device::DeviceType GetDeviceType() override; void SetRenderMode(const device::RenderMode aMode) override; diff --git a/app/src/wavevr/cpp/native-lib.cpp b/app/src/wavevr/cpp/native-lib.cpp index 1debb0b24..809cfce23 100644 --- a/app/src/wavevr/cpp/native-lib.cpp +++ b/app/src/wavevr/cpp/native-lib.cpp @@ -45,11 +45,6 @@ JNI_METHOD(void, activityResumed) int main(int argc, char *argv[]) { sQueue->AttachToThread(); VRB_LOG("Call WVR_Init"); - sDevice = DeviceDelegateWaveVR::Create(BrowserWorld::Instance().GetRenderContext()); - BrowserWorld::Instance().RegisterDeviceDelegate(sDevice); - while(!sJavaInitialized) { - sQueue->ProcessRunnables(); - } WVR_InitError eError = WVR_Init(WVR_AppType_VRContent); if (eError != WVR_InitError_None) { @@ -57,6 +52,12 @@ int main(int argc, char *argv[]) { return 1; } + sDevice = DeviceDelegateWaveVR::Create(BrowserWorld::Instance().GetRenderContext()); + BrowserWorld::Instance().RegisterDeviceDelegate(sDevice); + while(!sJavaInitialized) { + sQueue->ProcessRunnables(); + } + WVR_InputAttribute inputIdAndTypes[] = { {WVR_InputId_Alias1_Menu, WVR_InputType_Button, WVR_AnalogType_None}, {WVR_InputId_Alias1_Touchpad, WVR_InputType_Button | WVR_InputType_Touch | WVR_InputType_Analog, WVR_AnalogType_2D}, @@ -76,6 +77,7 @@ int main(int argc, char *argv[]) { if (pError != WVR_RenderError_None) { VRB_LOG("Present init failed - Error[%d]", pError); } + sDevice->InitializeRender(); VRB_GL_CHECK(glEnable(GL_DEPTH_TEST)); VRB_GL_CHECK(glEnable(GL_CULL_FACE)); VRB_GL_CHECK(glEnable(GL_BLEND));