diff --git a/app/src/oculusvr/cpp/DeviceDelegateOculusVR.cpp b/app/src/oculusvr/cpp/DeviceDelegateOculusVR.cpp index 3bbb5f4f99..c8bfdd9ffb 100644 --- a/app/src/oculusvr/cpp/DeviceDelegateOculusVR.cpp +++ b/app/src/oculusvr/cpp/DeviceDelegateOculusVR.cpp @@ -1058,7 +1058,7 @@ DeviceDelegateOculusVR::CreateLayerQuad(int32_t aWidth, int32_t aHeight, return nullptr; } VRLayerQuadPtr layer = VRLayerQuad::Create(aWidth, aHeight, aSurfaceType); - OculusLayerQuadPtr oculusLayer = OculusLayerQuad::Create(layer); + OculusLayerQuadPtr oculusLayer = OculusLayerQuad::Create(m.java.Env, layer); m.AddUILayer(oculusLayer, aSurfaceType); return layer; } @@ -1074,7 +1074,7 @@ DeviceDelegateOculusVR::CreateLayerQuad(const VRLayerSurfacePtr& aMoveLayer) { for (int i = 0; i < m.uiLayers.size(); ++i) { if (m.uiLayers[i]->GetLayer() == aMoveLayer) { - oculusLayer = OculusLayerQuad::Create(layer, m.uiLayers[i]); + oculusLayer = OculusLayerQuad::Create(m.java.Env, layer, m.uiLayers[i]); m.uiLayers.erase(m.uiLayers.begin() + i); break; } @@ -1092,7 +1092,7 @@ DeviceDelegateOculusVR::CreateLayerCylinder(int32_t aWidth, int32_t aHeight, return nullptr; } VRLayerCylinderPtr layer = VRLayerCylinder::Create(aWidth, aHeight, aSurfaceType); - OculusLayerCylinderPtr oculusLayer = OculusLayerCylinder::Create(layer); + OculusLayerCylinderPtr oculusLayer = OculusLayerCylinder::Create(m.java.Env, layer); m.AddUILayer(oculusLayer, aSurfaceType); return layer; } @@ -1108,7 +1108,7 @@ DeviceDelegateOculusVR::CreateLayerCylinder(const VRLayerSurfacePtr& aMoveLayer) for (int i = 0; i < m.uiLayers.size(); ++i) { if (m.uiLayers[i]->GetLayer() == aMoveLayer) { - oculusLayer = OculusLayerCylinder::Create(layer, m.uiLayers[i]); + oculusLayer = OculusLayerCylinder::Create(m.java.Env, layer, m.uiLayers[i]); m.uiLayers.erase(m.uiLayers.begin() + i); break; } diff --git a/app/src/oculusvr/cpp/OculusVRLayers.cpp b/app/src/oculusvr/cpp/OculusVRLayers.cpp index 08b48a7bc5..1ab5c3ba91 100644 --- a/app/src/oculusvr/cpp/OculusVRLayers.cpp +++ b/app/src/oculusvr/cpp/OculusVRLayers.cpp @@ -17,11 +17,11 @@ bool OculusLayer::sForceClip = false; // OculusLayerQuad OculusLayerQuadPtr -OculusLayerQuad::Create(const VRLayerQuadPtr& aLayer, const OculusLayerPtr& aSource) { +OculusLayerQuad::Create(JNIEnv *aEnv, const VRLayerQuadPtr& aLayer, const OculusLayerPtr& aSource) { auto result = std::make_shared(); result->layer = aLayer; if (aSource) { - result->TakeSurface(aSource); + result->TakeSurface(aEnv, aSource); } return result; } @@ -68,11 +68,11 @@ OculusLayerQuad::Update(const ovrTracking2& aTracking, ovrTextureSwapChain* aCle // OculusLayerCylinder OculusLayerCylinderPtr -OculusLayerCylinder::Create(const VRLayerCylinderPtr& aLayer, const OculusLayerPtr& aSource) { +OculusLayerCylinder::Create(JNIEnv *aEnv, const VRLayerCylinderPtr& aLayer, const OculusLayerPtr& aSource) { auto result = std::make_shared(); result->layer = aLayer; if (aSource) { - result->TakeSurface(aSource); + result->TakeSurface(aEnv, aSource); } return result; } diff --git a/app/src/oculusvr/cpp/OculusVRLayers.h b/app/src/oculusvr/cpp/OculusVRLayers.h index 9b376c6c28..109cad001b 100644 --- a/app/src/oculusvr/cpp/OculusVRLayers.h +++ b/app/src/oculusvr/cpp/OculusVRLayers.h @@ -246,8 +246,9 @@ class OculusLayerSurface : public OculusLayerBase { } protected: - void TakeSurface(const OculusLayerPtr &aSource) { + void TakeSurface(JNIEnv * aEnv, const OculusLayerPtr &aSource) { this->swapChain = aSource->GetSwapChain(); + this->jniEnv = aEnv; this->surface = aSource->GetSurface(); this->surfaceChangedTarget = aSource->GetSurfaceChangedTarget(); if (this->surfaceChangedTarget) { @@ -307,7 +308,7 @@ typedef std::shared_ptr OculusLayerQuadPtr; class OculusLayerQuad : public OculusLayerSurface { public: static OculusLayerQuadPtr - Create(const VRLayerQuadPtr &aLayer, const OculusLayerPtr &aSource = nullptr); + Create(JNIEnv *aEnv, const VRLayerQuadPtr &aLayer, const OculusLayerPtr &aSource = nullptr); void Init(JNIEnv *aEnv, vrb::RenderContextPtr &aContext) override; void Update(const ovrTracking2 &aTracking, ovrTextureSwapChain *aClearSwapChain) override; }; @@ -320,7 +321,7 @@ typedef std::shared_ptr OculusLayerCylinderPtr; class OculusLayerCylinder : public OculusLayerSurface { public: static OculusLayerCylinderPtr - Create(const VRLayerCylinderPtr &aLayer, const OculusLayerPtr &aSource = nullptr); + Create(JNIEnv *aEnv, const VRLayerCylinderPtr &aLayer, const OculusLayerPtr &aSource = nullptr); void Init(JNIEnv *aEnv, vrb::RenderContextPtr &aContext) override; void Update(const ovrTracking2 &aTracking, ovrTextureSwapChain *aClearSwapChain) override; };