From 662f8374ae9e8a978878cf2c87ba84240c7a53bb Mon Sep 17 00:00:00 2001 From: Dale Stammen Date: Wed, 22 Apr 2015 17:58:10 -0700 Subject: [PATCH 1/8] removed CC_PLATFORM_WINRT code. It is now allowed to exit a WinRT app --- templates/cpp-template-default/Classes/HelloWorldScene.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/templates/cpp-template-default/Classes/HelloWorldScene.cpp b/templates/cpp-template-default/Classes/HelloWorldScene.cpp index 5c273b9b8b..162c6ad792 100644 --- a/templates/cpp-template-default/Classes/HelloWorldScene.cpp +++ b/templates/cpp-template-default/Classes/HelloWorldScene.cpp @@ -78,11 +78,6 @@ bool HelloWorld::init() void HelloWorld::menuCloseCallback(Ref* pSender) { -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) - MessageBox("You pressed the close button. Windows Store Apps do not implement a close button.","Alert"); - return; -#endif - Director::getInstance()->end(); #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) From c3335551b80e1b70ba5a1f68a42faf3c51f6941a Mon Sep 17 00:00:00 2001 From: Dale Stammen Date: Wed, 22 Apr 2015 19:07:48 -0700 Subject: [PATCH 2/8] added EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE --- cocos/platform/win8.1-universal/OpenGLES.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cocos/platform/win8.1-universal/OpenGLES.cpp b/cocos/platform/win8.1-universal/OpenGLES.cpp index c375a709e7..3afdab08a9 100644 --- a/cocos/platform/win8.1-universal/OpenGLES.cpp +++ b/cocos/platform/win8.1-universal/OpenGLES.cpp @@ -62,7 +62,12 @@ void OpenGLES::Initialize() // EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER is an optimization that can have large performance benefits on mobile devices. // Its syntax is subject to change, though. Please update your Visual Studio templates if you experience compilation issues with it. - EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, EGL_TRUE, + EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, EGL_TRUE, + + // EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE is an option that enables ANGLE to automatically call + // the IDXGIDevice3::Trim method on behalf of the application when it gets suspended. + // Calling IDXGIDevice3::Trim when an application is suspended is a Windows Store application certification requirement. + EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE, EGL_TRUE, EGL_NONE, }; @@ -74,6 +79,7 @@ void OpenGLES::Initialize() EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE, 9, EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE, 3, EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, EGL_TRUE, + EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE, EGL_TRUE, EGL_NONE, }; @@ -84,6 +90,7 @@ void OpenGLES::Initialize() EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE, EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, EGL_TRUE, + EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE, EGL_TRUE, EGL_NONE, }; From 22daece170f3f9f99d43c2f046665955910af469 Mon Sep 17 00:00:00 2001 From: Dale Stammen Date: Wed, 22 Apr 2015 19:08:11 -0700 Subject: [PATCH 3/8] made Cleanup() public --- cocos/platform/win8.1-universal/OpenGLES.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/platform/win8.1-universal/OpenGLES.h b/cocos/platform/win8.1-universal/OpenGLES.h index 1a57b68739..e2e7d7e8aa 100644 --- a/cocos/platform/win8.1-universal/OpenGLES.h +++ b/cocos/platform/win8.1-universal/OpenGLES.h @@ -39,10 +39,10 @@ public: void MakeCurrent(const EGLSurface surface); EGLBoolean SwapBuffers(const EGLSurface surface); void Reset(); + void Cleanup(); private: void Initialize(); - void Cleanup(); private: EGLDisplay mEglDisplay; From 4119b0f10d6ef179814f1d517fe8a6a990536a98 Mon Sep 17 00:00:00 2001 From: Dale Stammen Date: Wed, 22 Apr 2015 19:11:29 -0700 Subject: [PATCH 4/8] cleaned up Draw() --- .../win8.1-universal/Cocos2dRenderer.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/cocos/platform/win8.1-universal/Cocos2dRenderer.cpp b/cocos/platform/win8.1-universal/Cocos2dRenderer.cpp index 81e78540c1..148d04a6cb 100644 --- a/cocos/platform/win8.1-universal/Cocos2dRenderer.cpp +++ b/cocos/platform/win8.1-universal/Cocos2dRenderer.cpp @@ -114,27 +114,33 @@ void Cocos2dRenderer::DeviceLost() void Cocos2dRenderer::Draw(GLsizei width, GLsizei height, float dpi, DisplayOrientations orientation) { + auto glView = GLViewImpl::sharedOpenGLView(); + if (orientation != m_orientation) { m_orientation = orientation; - GLViewImpl::sharedOpenGLView()->UpdateOrientation(orientation); + glView->UpdateOrientation(orientation); } if (width != m_width || height != m_height) { m_width = width; m_height = height; - GLViewImpl::sharedOpenGLView()->UpdateForWindowSizeChange(static_cast(width), static_cast(height)); + glView->UpdateForWindowSizeChange(static_cast(width), static_cast(height)); } if (dpi != m_dpi) { m_dpi = dpi; - GLViewImpl::sharedOpenGLView()->SetDPI(m_dpi); + glView->SetDPI(m_dpi); } - GLViewImpl::sharedOpenGLView()->ProcessEvents(); - GLViewImpl::sharedOpenGLView()->Render(); + glView->ProcessEvents(); + + if (!(glView->AppShouldExit())) + { + glView->Render(); + } } void Cocos2dRenderer::QueuePointerEvent(cocos2d::PointerEventType type, Windows::UI::Core::PointerEventArgs^ args) From b78f830ed8780f0541ec4de38ac19e7e8d92ca03 Mon Sep 17 00:00:00 2001 From: Dale Stammen Date: Wed, 22 Apr 2015 19:11:42 -0700 Subject: [PATCH 5/8] cleaned up Draw() --- cocos/platform/win8.1-universal/Cocos2dRenderer.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/cocos/platform/win8.1-universal/Cocos2dRenderer.cpp b/cocos/platform/win8.1-universal/Cocos2dRenderer.cpp index 148d04a6cb..d8ffe6913b 100644 --- a/cocos/platform/win8.1-universal/Cocos2dRenderer.cpp +++ b/cocos/platform/win8.1-universal/Cocos2dRenderer.cpp @@ -136,11 +136,7 @@ void Cocos2dRenderer::Draw(GLsizei width, GLsizei height, float dpi, DisplayOrie } glView->ProcessEvents(); - - if (!(glView->AppShouldExit())) - { - glView->Render(); - } + glView->Render(); } void Cocos2dRenderer::QueuePointerEvent(cocos2d::PointerEventType type, Windows::UI::Core::PointerEventArgs^ args) From ac8755868d1406acc13e6b75ab1d0005c5b31ed5 Mon Sep 17 00:00:00 2001 From: Dale Stammen Date: Wed, 22 Apr 2015 19:13:12 -0700 Subject: [PATCH 6/8] need to call Cleanup() if app is terminating --- .../win8.1-universal/OpenGLESPage.xaml.cpp | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/cocos/platform/win8.1-universal/OpenGLESPage.xaml.cpp b/cocos/platform/win8.1-universal/OpenGLESPage.xaml.cpp index 6a6a5fd00c..b53511535b 100644 --- a/cocos/platform/win8.1-universal/OpenGLESPage.xaml.cpp +++ b/cocos/platform/win8.1-universal/OpenGLESPage.xaml.cpp @@ -261,7 +261,13 @@ void OpenGLESPage::TerminateApp() { { critical_section::scoped_lock lock(mRenderSurfaceCriticalSection); - DestroyRenderSurface(); + + if (mOpenGLES) + { + mOpenGLES->DestroySurface(mRenderSurface); + mOpenGLES->Cleanup(); + } + } Windows::UI::Xaml::Application::Current->Exit(); } @@ -311,10 +317,21 @@ void OpenGLESPage::StartRenderLoop() GetSwapChainPanelSize(&panelWidth, &panelHeight); m_renderer.get()->Draw(panelWidth, panelHeight, m_dpi, m_orientation); - // The call to eglSwapBuffers might not be successful (i.e. due to Device Lost) - // If the call fails, then we must reinitialize EGL and the GL resources. - if (mOpenGLES->SwapBuffers(mRenderSurface) != GL_TRUE) + // run on main UI thread + if (m_renderer->AppShouldExit()) { + swapChainPanel->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, ref new DispatchedHandler([this]() + { + TerminateApp(); + })); + + return; + } + else if (mOpenGLES->SwapBuffers(mRenderSurface) != GL_TRUE) + { + // The call to eglSwapBuffers might not be successful (i.e. due to Device Lost) + // If the call fails, then we must reinitialize EGL and the GL resources. + m_deviceLost = true; if (m_renderer) @@ -330,17 +347,6 @@ void OpenGLESPage::StartRenderLoop() return; } - - // run on main UI thread - if (m_renderer->AppShouldExit()) - { - swapChainPanel->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, ref new DispatchedHandler([this]() - { - TerminateApp(); - })); - - return; - } } if (m_renderer) From 102726784e3cf8b8a7725f5785a63d282e5c1cdc Mon Sep 17 00:00:00 2001 From: Dale Stammen Date: Wed, 22 Apr 2015 19:13:57 -0700 Subject: [PATCH 7/8] update windows 8.1 univeral app cpp-template files --- .../App.Shared/Cocos2dRenderer.cpp | 12 ++++--- .../App.Shared/OpenGLES.cpp | 9 ++++- .../App.Shared/OpenGLES.h | 2 +- .../App.Shared/OpenGLESPage.xaml.cpp | 36 +++++++++++-------- 4 files changed, 37 insertions(+), 22 deletions(-) diff --git a/templates/cpp-template-default/proj.win8.1-universal/App.Shared/Cocos2dRenderer.cpp b/templates/cpp-template-default/proj.win8.1-universal/App.Shared/Cocos2dRenderer.cpp index 81e78540c1..d8ffe6913b 100644 --- a/templates/cpp-template-default/proj.win8.1-universal/App.Shared/Cocos2dRenderer.cpp +++ b/templates/cpp-template-default/proj.win8.1-universal/App.Shared/Cocos2dRenderer.cpp @@ -114,27 +114,29 @@ void Cocos2dRenderer::DeviceLost() void Cocos2dRenderer::Draw(GLsizei width, GLsizei height, float dpi, DisplayOrientations orientation) { + auto glView = GLViewImpl::sharedOpenGLView(); + if (orientation != m_orientation) { m_orientation = orientation; - GLViewImpl::sharedOpenGLView()->UpdateOrientation(orientation); + glView->UpdateOrientation(orientation); } if (width != m_width || height != m_height) { m_width = width; m_height = height; - GLViewImpl::sharedOpenGLView()->UpdateForWindowSizeChange(static_cast(width), static_cast(height)); + glView->UpdateForWindowSizeChange(static_cast(width), static_cast(height)); } if (dpi != m_dpi) { m_dpi = dpi; - GLViewImpl::sharedOpenGLView()->SetDPI(m_dpi); + glView->SetDPI(m_dpi); } - GLViewImpl::sharedOpenGLView()->ProcessEvents(); - GLViewImpl::sharedOpenGLView()->Render(); + glView->ProcessEvents(); + glView->Render(); } void Cocos2dRenderer::QueuePointerEvent(cocos2d::PointerEventType type, Windows::UI::Core::PointerEventArgs^ args) diff --git a/templates/cpp-template-default/proj.win8.1-universal/App.Shared/OpenGLES.cpp b/templates/cpp-template-default/proj.win8.1-universal/App.Shared/OpenGLES.cpp index c375a709e7..3afdab08a9 100644 --- a/templates/cpp-template-default/proj.win8.1-universal/App.Shared/OpenGLES.cpp +++ b/templates/cpp-template-default/proj.win8.1-universal/App.Shared/OpenGLES.cpp @@ -62,7 +62,12 @@ void OpenGLES::Initialize() // EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER is an optimization that can have large performance benefits on mobile devices. // Its syntax is subject to change, though. Please update your Visual Studio templates if you experience compilation issues with it. - EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, EGL_TRUE, + EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, EGL_TRUE, + + // EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE is an option that enables ANGLE to automatically call + // the IDXGIDevice3::Trim method on behalf of the application when it gets suspended. + // Calling IDXGIDevice3::Trim when an application is suspended is a Windows Store application certification requirement. + EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE, EGL_TRUE, EGL_NONE, }; @@ -74,6 +79,7 @@ void OpenGLES::Initialize() EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE, 9, EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE, 3, EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, EGL_TRUE, + EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE, EGL_TRUE, EGL_NONE, }; @@ -84,6 +90,7 @@ void OpenGLES::Initialize() EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE, EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, EGL_TRUE, + EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE, EGL_TRUE, EGL_NONE, }; diff --git a/templates/cpp-template-default/proj.win8.1-universal/App.Shared/OpenGLES.h b/templates/cpp-template-default/proj.win8.1-universal/App.Shared/OpenGLES.h index 1a57b68739..e2e7d7e8aa 100644 --- a/templates/cpp-template-default/proj.win8.1-universal/App.Shared/OpenGLES.h +++ b/templates/cpp-template-default/proj.win8.1-universal/App.Shared/OpenGLES.h @@ -39,10 +39,10 @@ public: void MakeCurrent(const EGLSurface surface); EGLBoolean SwapBuffers(const EGLSurface surface); void Reset(); + void Cleanup(); private: void Initialize(); - void Cleanup(); private: EGLDisplay mEglDisplay; diff --git a/templates/cpp-template-default/proj.win8.1-universal/App.Shared/OpenGLESPage.xaml.cpp b/templates/cpp-template-default/proj.win8.1-universal/App.Shared/OpenGLESPage.xaml.cpp index 6a6a5fd00c..b53511535b 100644 --- a/templates/cpp-template-default/proj.win8.1-universal/App.Shared/OpenGLESPage.xaml.cpp +++ b/templates/cpp-template-default/proj.win8.1-universal/App.Shared/OpenGLESPage.xaml.cpp @@ -261,7 +261,13 @@ void OpenGLESPage::TerminateApp() { { critical_section::scoped_lock lock(mRenderSurfaceCriticalSection); - DestroyRenderSurface(); + + if (mOpenGLES) + { + mOpenGLES->DestroySurface(mRenderSurface); + mOpenGLES->Cleanup(); + } + } Windows::UI::Xaml::Application::Current->Exit(); } @@ -311,10 +317,21 @@ void OpenGLESPage::StartRenderLoop() GetSwapChainPanelSize(&panelWidth, &panelHeight); m_renderer.get()->Draw(panelWidth, panelHeight, m_dpi, m_orientation); - // The call to eglSwapBuffers might not be successful (i.e. due to Device Lost) - // If the call fails, then we must reinitialize EGL and the GL resources. - if (mOpenGLES->SwapBuffers(mRenderSurface) != GL_TRUE) + // run on main UI thread + if (m_renderer->AppShouldExit()) { + swapChainPanel->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, ref new DispatchedHandler([this]() + { + TerminateApp(); + })); + + return; + } + else if (mOpenGLES->SwapBuffers(mRenderSurface) != GL_TRUE) + { + // The call to eglSwapBuffers might not be successful (i.e. due to Device Lost) + // If the call fails, then we must reinitialize EGL and the GL resources. + m_deviceLost = true; if (m_renderer) @@ -330,17 +347,6 @@ void OpenGLESPage::StartRenderLoop() return; } - - // run on main UI thread - if (m_renderer->AppShouldExit()) - { - swapChainPanel->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, ref new DispatchedHandler([this]() - { - TerminateApp(); - })); - - return; - } } if (m_renderer) From 431937edb4b734606c221991a257fd3810b85144 Mon Sep 17 00:00:00 2001 From: Dale Stammen Date: Wed, 22 Apr 2015 19:49:37 -0700 Subject: [PATCH 8/8] updated version to v3-deps-44 --- external/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/config.json b/external/config.json index a16307e253..0d89768e8c 100644 --- a/external/config.json +++ b/external/config.json @@ -1,5 +1,5 @@ { - "version":"v3-deps-43", + "version":"v3-deps-44", "zip_file_size":"74127526", "repo_name":"cocos2d-x-3rd-party-libs-bin", "repo_parent":"https://github.com/cocos2d/",