From 93807ee42f29379bba55de875cb23af511d5b65f Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Mon, 12 Feb 2018 09:29:47 -0800 Subject: Fixed unity emulator on iOS --- unityplugin/UnityEmulator/src/DiligentGraphicsAdapterGL.cpp | 13 +++++++++---- unityplugin/UnityEmulator/src/UnityAppBase.cpp | 5 ++++- 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'unityplugin/UnityEmulator') diff --git a/unityplugin/UnityEmulator/src/DiligentGraphicsAdapterGL.cpp b/unityplugin/UnityEmulator/src/DiligentGraphicsAdapterGL.cpp index 9a8a164..3779bca 100644 --- a/unityplugin/UnityEmulator/src/DiligentGraphicsAdapterGL.cpp +++ b/unityplugin/UnityEmulator/src/DiligentGraphicsAdapterGL.cpp @@ -21,10 +21,12 @@ public: using TBase = SwapChainBase; ProxySwapChainGL( IReferenceCounters *pRefCounters, + const UnityGraphicsGLCoreES_Emulator& UnityGraphicsGL, IRenderDevice *pDevice, IDeviceContext *pDeviceContext, const SwapChainDesc& SCDesc ) : - TBase(pRefCounters, pDevice, pDeviceContext,SCDesc) + TBase(pRefCounters, pDevice, pDeviceContext,SCDesc), + m_UnityGraphicsGL(UnityGraphicsGL) {} virtual void Present()override final @@ -39,8 +41,11 @@ public: virtual GLuint GetDefaultFBO()const override final { - return 0; + return m_UnityGraphicsGL.GetGraphicsImpl()->GetDefaultFBO(); } + +private: + const UnityGraphicsGLCoreES_Emulator& m_UnityGraphicsGL; }; } @@ -83,7 +88,7 @@ DiligentGraphicsAdapterGL::DiligentGraphicsAdapterGL(const UnityGraphicsGLCoreES SCDesc.BufferCount = 0; auto &DefaultAllocator = DefaultRawMemoryAllocator::GetAllocator(); - auto pProxySwapChainGL = NEW_RC_OBJ(DefaultAllocator, "ProxySwapChainGL instance", ProxySwapChainGL)(m_pDevice, m_pDeviceCtx, SCDesc); + auto pProxySwapChainGL = NEW_RC_OBJ(DefaultAllocator, "ProxySwapChainGL instance", ProxySwapChainGL)(m_UnityGraphicsGL, m_pDevice, m_pDeviceCtx, SCDesc); pProxySwapChainGL->QueryInterface(IID_SwapChain, reinterpret_cast(static_cast(&m_pProxySwapChain))); m_pDeviceCtx->SetSwapChain(m_pProxySwapChain); @@ -107,4 +112,4 @@ bool DiligentGraphicsAdapterGL::UsesReverseZ() return m_UnityGraphicsGL.UsesReverseZ(); } -#endif // OPENGL_SUPPORTED \ No newline at end of file +#endif // OPENGL_SUPPORTED diff --git a/unityplugin/UnityEmulator/src/UnityAppBase.cpp b/unityplugin/UnityEmulator/src/UnityAppBase.cpp index e84333b..14a8cfc 100644 --- a/unityplugin/UnityEmulator/src/UnityAppBase.cpp +++ b/unityplugin/UnityEmulator/src/UnityAppBase.cpp @@ -243,6 +243,9 @@ void UnityAppBase::WindowResize(int width, int height) m_DiligentGraphics->PreSwapChainResize(); m_GraphicsEmulator->ResizeSwapChain(width, height); m_DiligentGraphics->PostSwapChainResize(); - m_Scene->OnWindowResize(width, height); + unsigned int SCWidth = 0; + unsigned int SCHeight = 0; + m_GraphicsEmulator->GetBackBufferSize(SCWidth, SCHeight); + m_Scene->OnWindowResize(SCWidth, SCHeight); } } -- cgit v1.2.3