diff --git a/frameworks/js-bindings/bindings/proj.wp8/libJSBinding.vcxproj b/frameworks/js-bindings/bindings/proj.wp8/libJSBinding.vcxproj index b1390fd9a5..6eaf5725c2 100644 --- a/frameworks/js-bindings/bindings/proj.wp8/libJSBinding.vcxproj +++ b/frameworks/js-bindings/bindings/proj.wp8/libJSBinding.vcxproj @@ -1,249 +1,255 @@ - - - - - Debug - Win32 - - - Debug - ARM - - - Release - Win32 - - - Release - ARM - - - - {DD11890A-006E-4D4B-BBE6-A577601288A2} - libjsbindings_wp8 - en-US - 11.0 - - - - StaticLibrary - true - v110_wp80 - - - StaticLibrary - true - v110_wp80 - - - StaticLibrary - false - true - v110_wp80 - - - StaticLibrary - false - true - v110_wp80 - - - - - - - - - - - - - - - - - - - - false - - - - _LIB;%(PreprocessorDefinitions) - NotUsing - pch.h - $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) - $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)\..\external\spidermonkey\include\wp8;$(ProjectDir)..\auto;$(ProjectDir)..\manual;$(ProjectDir)..\manual\cocostudio;$(ProjectDir)..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) - WP8;_DEBUG;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) - 4267;4251;4244;%(DisableSpecificWarnings) - - - /Zm200 %(AdditionalOptions) - - - Console - false - - - /IGNORE:4264 %(AdditionalOptions) - - - - - _LIB;NDEBUG;%(PreprocessorDefinitions) - NotUsing - pch.h - $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) - $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)\..\external\spidermonkey\include\wp8;$(ProjectDir)..\auto;$(ProjectDir)..\manual;$(ProjectDir)..\manual\cocostudio;$(ProjectDir)..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) - WP8;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) - - - /Zm200 %(AdditionalOptions) - - - Console - false - - - /IGNORE:4264 %(AdditionalOptions) - - - - - _LIB;%(PreprocessorDefinitions) - NotUsing - pch.h - $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) - $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)\..\external\spidermonkey\include\wp8;$(ProjectDir)..\auto;$(ProjectDir)..\manual;$(ProjectDir)..\manual\cocostudio;$(ProjectDir)..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) - WP8;_DEBUG;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) - 4267;4251;4244;%(DisableSpecificWarnings) - - - /Zm200 %(AdditionalOptions) - true - - - Console - false - - - /IGNORE:4264 %(AdditionalOptions) - - - - - _LIB;NDEBUG;%(PreprocessorDefinitions) - NotUsing - pch.h - $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) - $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)\..\external\spidermonkey\include\wp8;$(ProjectDir)..\auto;$(ProjectDir)..\manual;$(ProjectDir)..\manual\cocostudio;$(ProjectDir)..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) - WP8;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) - - - /Zm200 %(AdditionalOptions) - true - - - Console - false - - - /IGNORE:4264 %(AdditionalOptions) - - - - - true - - - true - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {7c5dbc42-27f6-4978-aabc-02ba77e2a7f0} - - - - - - + + + + + Debug + Win32 + + + Debug + ARM + + + Release + Win32 + + + Release + ARM + + + + {DD11890A-006E-4D4B-BBE6-A577601288A2} + libjsbindings_wp8 + en-US + 11.0 + + + + StaticLibrary + true + v110_wp80 + + + StaticLibrary + true + v110_wp80 + + + StaticLibrary + false + true + v110_wp80 + + + StaticLibrary + false + true + v110_wp80 + + + + + + + + + + + + + + + + + + + + false + + + + _LIB;%(PreprocessorDefinitions) + NotUsing + pch.h + $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) + $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)\..\external\spidermonkey\include\wp8;$(ProjectDir)..\auto;$(ProjectDir)..\manual;$(ProjectDir)..\manual\cocostudio;$(ProjectDir)..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + WP8;_DEBUG;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) + 4267;4251;4244;4700;4083;4068;%(DisableSpecificWarnings) + + + /Zm200 %(AdditionalOptions) + + + Console + false + + + /IGNORE:4264 %(AdditionalOptions) + + + + + _LIB;NDEBUG;%(PreprocessorDefinitions) + NotUsing + pch.h + $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) + $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)\..\external\spidermonkey\include\wp8;$(ProjectDir)..\auto;$(ProjectDir)..\manual;$(ProjectDir)..\manual\cocostudio;$(ProjectDir)..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + WP8;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) + + + /Zm200 %(AdditionalOptions) + 4267;4251;4244;4700;4083;4068;%(DisableSpecificWarnings) + false + + + Console + false + + + /IGNORE:4264 %(AdditionalOptions) + false + + + + + _LIB;%(PreprocessorDefinitions) + NotUsing + pch.h + $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) + $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)\..\external\spidermonkey\include\wp8;$(ProjectDir)..\auto;$(ProjectDir)..\manual;$(ProjectDir)..\manual\cocostudio;$(ProjectDir)..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + WP8;_DEBUG;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) + 4267;4251;4244;4700;4083;4068;%(DisableSpecificWarnings) + + + /Zm200 %(AdditionalOptions) + true + + + Console + false + + + /IGNORE:4264 %(AdditionalOptions) + + + + + _LIB;NDEBUG;%(PreprocessorDefinitions) + NotUsing + pch.h + $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) + $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)\..\external\spidermonkey\include\wp8;$(ProjectDir)..\auto;$(ProjectDir)..\manual;$(ProjectDir)..\manual\cocostudio;$(ProjectDir)..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + WP8;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) + + + /Zm200 %(AdditionalOptions) + true + 4267;4251;4244;4700;4083;4068;%(DisableSpecificWarnings) + false + + + Console + false + + + /IGNORE:4264 %(AdditionalOptions) + false + + + + + true + + + true + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {7c5dbc42-27f6-4978-aabc-02ba77e2a7f0} + + + + + + \ No newline at end of file diff --git a/frameworks/js-bindings/external/spidermonkey/prebuilt/wp8/arm/mozjs-33.dll b/frameworks/js-bindings/external/spidermonkey/prebuilt/wp8/arm/mozjs-33.dll index 93375b4871..49be0f1958 100644 Binary files a/frameworks/js-bindings/external/spidermonkey/prebuilt/wp8/arm/mozjs-33.dll and b/frameworks/js-bindings/external/spidermonkey/prebuilt/wp8/arm/mozjs-33.dll differ diff --git a/frameworks/js-bindings/external/spidermonkey/prebuilt/wp8/arm/mozjs-33.lib b/frameworks/js-bindings/external/spidermonkey/prebuilt/wp8/arm/mozjs-33.lib index 4ce310cc3d..c43eae34a8 100644 Binary files a/frameworks/js-bindings/external/spidermonkey/prebuilt/wp8/arm/mozjs-33.lib and b/frameworks/js-bindings/external/spidermonkey/prebuilt/wp8/arm/mozjs-33.lib differ diff --git a/frameworks/js-bindings/external/spidermonkey/prebuilt/wp8/win32/mozjs-33.dll b/frameworks/js-bindings/external/spidermonkey/prebuilt/wp8/win32/mozjs-33.dll index 9da6630d45..d92866d8b4 100644 Binary files a/frameworks/js-bindings/external/spidermonkey/prebuilt/wp8/win32/mozjs-33.dll and b/frameworks/js-bindings/external/spidermonkey/prebuilt/wp8/win32/mozjs-33.dll differ diff --git a/frameworks/js-bindings/external/spidermonkey/prebuilt/wp8/win32/mozjs-33.lib b/frameworks/js-bindings/external/spidermonkey/prebuilt/wp8/win32/mozjs-33.lib index 4e18739d8e..1f2a75923b 100644 Binary files a/frameworks/js-bindings/external/spidermonkey/prebuilt/wp8/win32/mozjs-33.lib and b/frameworks/js-bindings/external/spidermonkey/prebuilt/wp8/win32/mozjs-33.lib differ diff --git a/frameworks/js-bindings/external/win8.1-universal/OpenGLESPage.xaml b/frameworks/js-bindings/external/win8.1-universal/OpenGLESPage.xaml new file mode 100644 index 0000000000..2e15f8140d --- /dev/null +++ b/frameworks/js-bindings/external/win8.1-universal/OpenGLESPage.xaml @@ -0,0 +1,28 @@ + + + + + + + + + + + diff --git a/frameworks/js-bindings/external/win8.1-universal/OpenGLESPage.xaml.cpp b/frameworks/js-bindings/external/win8.1-universal/OpenGLESPage.xaml.cpp new file mode 100644 index 0000000000..8f810b771f --- /dev/null +++ b/frameworks/js-bindings/external/win8.1-universal/OpenGLESPage.xaml.cpp @@ -0,0 +1,307 @@ +/* +* cocos2d-x http://www.cocos2d-x.org +* +* Copyright (c) 2010-2014 - cocos2d-x community +* +* Portions Copyright (c) Microsoft Open Technologies, Inc. +* All Rights Reserved +* +* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and limitations under the License. +*/ + +#include "App.xaml.h" +#include "OpenGLESPage.xaml.h" + +using namespace cocos2d; +using namespace Platform; +using namespace Concurrency; +using namespace Windows::Foundation; +using namespace Windows::Foundation::Collections; +using namespace Windows::Graphics::Display; +using namespace Windows::System::Threading; +using namespace Windows::UI::Core; +using namespace Windows::UI::Input; +using namespace Windows::UI::Xaml; +using namespace Windows::UI::Xaml::Controls; +using namespace Windows::UI::Xaml::Controls::Primitives; +using namespace Windows::UI::Xaml::Data; +using namespace Windows::UI::Xaml::Input; +using namespace Windows::UI::Xaml::Media; +using namespace Windows::UI::Xaml::Navigation; + +OpenGLESPage::OpenGLESPage() : + OpenGLESPage(nullptr) +{ + +} + +OpenGLESPage::OpenGLESPage(OpenGLES* openGLES) : + mOpenGLES(openGLES), + mRenderSurface(EGL_NO_SURFACE), + mCustomRenderSurfaceSize(0,0), + mUseCustomRenderSurfaceSize(false), + m_coreInput(nullptr), + m_dpi(0.0f), + m_visible(false), + m_deviceLost(false), + m_orientation(DisplayOrientations::Landscape) +{ + InitializeComponent(); + + Windows::UI::Core::CoreWindow^ window = Windows::UI::Xaml::Window::Current->CoreWindow; + + window->VisibilityChanged += + ref new Windows::Foundation::TypedEventHandler(this, &OpenGLESPage::OnVisibilityChanged); + + swapChainPanel->SizeChanged += + ref new Windows::UI::Xaml::SizeChangedEventHandler(this, &OpenGLESPage::OnSwapChainPanelSizeChanged); + + DisplayInformation^ currentDisplayInformation = DisplayInformation::GetForCurrentView(); + + currentDisplayInformation->OrientationChanged += + ref new TypedEventHandler(this, &OpenGLESPage::OnOrientationChanged); + + m_orientation = currentDisplayInformation->CurrentOrientation; + + this->Loaded += + ref new Windows::UI::Xaml::RoutedEventHandler(this, &OpenGLESPage::OnPageLoaded); + + mSwapChainPanelSize = { swapChainPanel->RenderSize.Width, swapChainPanel->RenderSize.Height }; + +#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) + Windows::UI::ViewManagement::StatusBar::GetForCurrentView()->HideAsync(); +#else + // Disable all pointer visual feedback for better performance when touching. + // This is not supported on Windows Phone applications. + auto pointerVisualizationSettings = Windows::UI::Input::PointerVisualizationSettings::GetForCurrentView(); + pointerVisualizationSettings->IsContactFeedbackEnabled = false; + pointerVisualizationSettings->IsBarrelButtonFeedbackEnabled = false; +#endif + + // Register our SwapChainPanel to get independent input pointer events + auto workItemHandler = ref new WorkItemHandler([this](IAsyncAction ^) + { + // The CoreIndependentInputSource will raise pointer events for the specified device types on whichever thread it's created on. + m_coreInput = swapChainPanel->CreateCoreIndependentInputSource( + Windows::UI::Core::CoreInputDeviceTypes::Mouse | + Windows::UI::Core::CoreInputDeviceTypes::Touch | + Windows::UI::Core::CoreInputDeviceTypes::Pen + ); + + // Register for pointer events, which will be raised on the background thread. + m_coreInput->PointerPressed += ref new TypedEventHandler(this, &OpenGLESPage::OnPointerPressed); + m_coreInput->PointerMoved += ref new TypedEventHandler(this, &OpenGLESPage::OnPointerMoved); + m_coreInput->PointerReleased += ref new TypedEventHandler(this, &OpenGLESPage::OnPointerReleased); + + // Begin processing input messages as they're delivered. + m_coreInput->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessUntilQuit); + }); + + // Run task on a dedicated high priority background thread. + m_inputLoopWorker = ThreadPool::RunAsync(workItemHandler, WorkItemPriority::High, WorkItemOptions::TimeSliced); + +} + +OpenGLESPage::~OpenGLESPage() +{ + StopRenderLoop(); + DestroyRenderSurface(); +} + +void OpenGLESPage::OnPageLoaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) +{ + // The SwapChainPanel has been created and arranged in the page layout, so EGL can be initialized. + CreateRenderSurface(); + m_visible = true; + StartRenderLoop(); +} + +void OpenGLESPage::OnPointerPressed(Object^ sender, PointerEventArgs^ e) +{ + if (m_renderer) + { + m_renderer->QueuePointerEvent(PointerEventType::PointerPressed, e); + } +} + +void OpenGLESPage::OnPointerMoved(Object^ sender, PointerEventArgs^ e) +{ + if (m_renderer) + { + m_renderer->QueuePointerEvent(PointerEventType::PointerMoved, e); + } +} + +void OpenGLESPage::OnPointerReleased(Object^ sender, PointerEventArgs^ e) +{ + if (m_renderer) + { + m_renderer->QueuePointerEvent(PointerEventType::PointerReleased, e); + } +} + +void OpenGLESPage::OnOrientationChanged(DisplayInformation^ sender, Object^ args) +{ + critical_section::scoped_lock lock(mSwapChainPanelSizeCriticalSection); + m_orientation = sender->CurrentOrientation; +} + +void OpenGLESPage::OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args) +{ + if (args->Visible && mRenderSurface != EGL_NO_SURFACE) + { + m_visible = true; + } + else + { + m_visible = false; + } +} + +void OpenGLESPage::OnSwapChainPanelSizeChanged(Object^ sender, Windows::UI::Xaml::SizeChangedEventArgs^ e) +{ + // Size change events occur outside of the render thread. A lock is required when updating + // the swapchainpanel size + critical_section::scoped_lock lock(mSwapChainPanelSizeCriticalSection); + mSwapChainPanelSize = { e->NewSize.Width, e->NewSize.Height }; +} + +void OpenGLESPage::GetSwapChainPanelSize(GLsizei* width, GLsizei* height) +{ + critical_section::scoped_lock lock(mSwapChainPanelSizeCriticalSection); + // If a custom render surface size is specified, return its size instead of + // the swapchain panel size. + if (mUseCustomRenderSurfaceSize) + { + *width = static_cast(mCustomRenderSurfaceSize.Width); + *height = static_cast(mCustomRenderSurfaceSize.Height); + } + else + { + *width = static_cast(mSwapChainPanelSize.Width); + *height = static_cast(mSwapChainPanelSize.Height); + } +} + +void OpenGLESPage::CreateRenderSurface() +{ + if (mOpenGLES) + { + // + // A Custom render surface size can be specified by uncommenting the following lines. + // The render surface will be automatically scaled to fit the entire window. Using a + // smaller sized render surface can result in a performance gain. + // + //mCustomRenderSurfaceSize = Size(800, 600); + //mUseCustomRenderSurfaceSize = true; + + mRenderSurface = mOpenGLES->CreateSurface(swapChainPanel, mUseCustomRenderSurfaceSize ? &mCustomRenderSurfaceSize : nullptr); + } +} + +void OpenGLESPage::DestroyRenderSurface() +{ + if (mOpenGLES) + { + mOpenGLES->DestroySurface(mRenderSurface); + } + mRenderSurface = EGL_NO_SURFACE; +} + +void OpenGLESPage::RecoverFromLostDevice() +{ + // resets OpenGLES, recreates the render surface + DestroyRenderSurface(); + mOpenGLES->Reset(); + CreateRenderSurface(); +} + +void OpenGLESPage::StartRenderLoop() +{ + // If the render loop is already running then do not start another thread. + if (mRenderLoopWorker != nullptr && mRenderLoopWorker->Status == Windows::Foundation::AsyncStatus::Started) + { + return; + } + + DisplayInformation^ currentDisplayInformation = DisplayInformation::GetForCurrentView(); + m_dpi = currentDisplayInformation->LogicalDpi; + + auto dispatcher = Windows::UI::Xaml::Window::Current->CoreWindow->Dispatcher; + + // Create a task for rendering that will be run on a background thread. + auto workItemHandler = ref new Windows::System::Threading::WorkItemHandler([this, dispatcher](Windows::Foundation::IAsyncAction ^ action) + { + mOpenGLES->MakeCurrent(mRenderSurface); + GLsizei panelWidth = 0; + GLsizei panelHeight = 0; + GetSwapChainPanelSize(&panelWidth, &panelHeight); + + if (m_renderer.get() == nullptr) + { + m_renderer = std::make_shared(panelWidth, panelHeight, m_dpi, m_orientation, dispatcher, swapChainPanel); + } + + m_renderer->Resume(); + + while (action->Status == Windows::Foundation::AsyncStatus::Started && !m_deviceLost) + { + if (!m_visible) + { + m_renderer->Pause(); + while (!m_visible) + { + Sleep(500); + } + m_renderer->Resume(); + } + + 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) + { + m_deviceLost = true; + + // XAML objects like the SwapChainPanel must only be manipulated on the UI thread. + swapChainPanel->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::High, ref new Windows::UI::Core::DispatchedHandler([=]() + { + RecoverFromLostDevice(); + }, CallbackContext::Any)); + + while(m_deviceLost) + { + Sleep(500); + } + mOpenGLES->MakeCurrent(mRenderSurface); + m_renderer->DeviceLost(); + } + } + }); + + // Run task on a dedicated high priority background thread. + mRenderLoopWorker = Windows::System::Threading::ThreadPool::RunAsync(workItemHandler, Windows::System::Threading::WorkItemPriority::High, Windows::System::Threading::WorkItemOptions::TimeSliced); +} + +void OpenGLESPage::StopRenderLoop() +{ + if (mRenderLoopWorker) + { + mRenderLoopWorker->Cancel(); + mRenderLoopWorker = nullptr; + } + + if (m_renderer) + { + m_renderer->Pause(); + } +} \ No newline at end of file diff --git a/frameworks/js-bindings/external/win8.1-universal/OpenGLESPage.xaml.h b/frameworks/js-bindings/external/win8.1-universal/OpenGLESPage.xaml.h new file mode 100644 index 0000000000..f8736e619e --- /dev/null +++ b/frameworks/js-bindings/external/win8.1-universal/OpenGLESPage.xaml.h @@ -0,0 +1,79 @@ +/* +* cocos2d-x http://www.cocos2d-x.org +* +* Copyright (c) 2010-2014 - cocos2d-x community +* +* Portions Copyright (c) Microsoft Open Technologies, Inc. +* All Rights Reserved +* +* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and limitations under the License. +*/ + +#pragma once + +#include "OpenGLES.h" +#include "OpenGLESPage.g.h" +#include +#include + +#include "Cocos2dRenderer.h" + +namespace cocos2d +{ + public ref class OpenGLESPage sealed + { + public: + OpenGLESPage(); + virtual ~OpenGLESPage(); + + internal: + OpenGLESPage(OpenGLES* openGLES); + + private: + void OnPageLoaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); + void OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args); + void OnSwapChainPanelSizeChanged(Platform::Object^ sender, Windows::UI::Xaml::SizeChangedEventArgs^ e); + void GetSwapChainPanelSize(GLsizei* width, GLsizei* height); + void CreateRenderSurface(); + void DestroyRenderSurface(); + void RecoverFromLostDevice(); + void StartRenderLoop(); + void StopRenderLoop(); + + OpenGLES* mOpenGLES; + std::shared_ptr m_renderer; + + Windows::Foundation::Size mSwapChainPanelSize; + Concurrency::critical_section mSwapChainPanelSizeCriticalSection; + + Windows::Foundation::Size mCustomRenderSurfaceSize; + bool mUseCustomRenderSurfaceSize; + + EGLSurface mRenderSurface; // This surface is associated with a swapChainPanel on the page + Windows::Foundation::IAsyncAction^ mRenderLoopWorker; + + // Track user input on a background worker thread. + Windows::Foundation::IAsyncAction^ m_inputLoopWorker; + Windows::UI::Core::CoreIndependentInputSource^ m_coreInput; + + // Independent input handling functions. + void OnPointerPressed(Platform::Object^ sender, Windows::UI::Core::PointerEventArgs^ e); + void OnPointerMoved(Platform::Object^ sender, Windows::UI::Core::PointerEventArgs^ e); + void OnPointerReleased(Platform::Object^ sender, Windows::UI::Core::PointerEventArgs^ e); + + void OnOrientationChanged(Windows::Graphics::Display::DisplayInformation^ sender, Platform::Object^ args); + + float m_dpi; + std::atomic m_visible; + std::atomic m_deviceLost; + Windows::Graphics::Display::DisplayOrientations m_orientation; + + }; +} diff --git a/samples/js-moonwarriors/project/proj.win8.1-universal/App.Shared/js-moonwarriors.Shared.vcxitems b/samples/js-moonwarriors/project/proj.win8.1-universal/App.Shared/js-moonwarriors.Shared.vcxitems index 2913c8d3bc..2c19028268 100644 --- a/samples/js-moonwarriors/project/proj.win8.1-universal/App.Shared/js-moonwarriors.Shared.vcxitems +++ b/samples/js-moonwarriors/project/proj.win8.1-universal/App.Shared/js-moonwarriors.Shared.vcxitems @@ -18,8 +18,8 @@ - - $(MSBuildThisFileDirectory)..\..\..\..\..\frameworks\js-bindings\cocos2d-x\cocos\platform\win8.1-universal\OpenGLESPage.xaml + + $(MSBuildThisFileDirectory)..\..\..\..\..\frameworks\js-bindings\external\win8.1-universal\OpenGLESPage.xaml @@ -30,8 +30,8 @@ - - $(MSBuildThisFileDirectory)..\..\..\..\..\frameworks\js-bindings\cocos2d-x\cocos\platform\win8.1-universal\OpenGLESPage.xaml + + $(MSBuildThisFileDirectory)..\..\..\..\..\frameworks\js-bindings\external\win8.1-universal\OpenGLESPage.xaml @@ -49,7 +49,7 @@ - + diff --git a/samples/js-moonwarriors/project/proj.win8.1-universal/App.Shared/js-moonwarriors.Shared.vcxitems.filters b/samples/js-moonwarriors/project/proj.win8.1-universal/App.Shared/js-moonwarriors.Shared.vcxitems.filters index 91190702c1..37f67ba148 100644 --- a/samples/js-moonwarriors/project/proj.win8.1-universal/App.Shared/js-moonwarriors.Shared.vcxitems.filters +++ b/samples/js-moonwarriors/project/proj.win8.1-universal/App.Shared/js-moonwarriors.Shared.vcxitems.filters @@ -29,6 +29,6 @@ - + \ No newline at end of file diff --git a/samples/js-moonwarriors/project/proj.win8.1-universal/App.Windows/js-moonwarriors.Windows.vcxproj b/samples/js-moonwarriors/project/proj.win8.1-universal/App.Windows/js-moonwarriors.Windows.vcxproj index b461bea740..a36354a4ea 100644 --- a/samples/js-moonwarriors/project/proj.win8.1-universal/App.Windows/js-moonwarriors.Windows.vcxproj +++ b/samples/js-moonwarriors/project/proj.win8.1-universal/App.Windows/js-moonwarriors.Windows.vcxproj @@ -121,7 +121,7 @@ /bigobj /Zm200 %(AdditionalOptions) 4800;%(DisableSpecificWarnings) pch.h - $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) + $(EngineRoot)..\external\win8.1-universal;$(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) false @@ -130,7 +130,7 @@ /bigobj /Zm200 %(AdditionalOptions) 4800;%(DisableSpecificWarnings) pch.h - $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) + $(EngineRoot)..\external\win8.1-universal;$(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) false @@ -139,7 +139,7 @@ /bigobj /Zm200 %(AdditionalOptions) 4800;%(DisableSpecificWarnings) pch.h - $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) + $(EngineRoot)..\external\win8.1-universal;$(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) false @@ -148,7 +148,7 @@ /bigobj /Zm200 %(AdditionalOptions) 4800;%(DisableSpecificWarnings) pch.h - $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) + $(EngineRoot)..\external\win8.1-universal;$(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) false @@ -157,7 +157,7 @@ /bigobj /Zm200 %(AdditionalOptions) 4800;%(DisableSpecificWarnings) pch.h - $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) + $(EngineRoot)..\external\win8.1-universal;$(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) false @@ -166,7 +166,7 @@ /bigobj /Zm200 %(AdditionalOptions) 4800;%(DisableSpecificWarnings) pch.h - $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) + $(EngineRoot)..\external\win8.1-universal;$(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) false diff --git a/samples/js-moonwarriors/project/proj.win8.1-universal/App.WindowsPhone/js-moonwarriors.WindowsPhone.vcxproj b/samples/js-moonwarriors/project/proj.win8.1-universal/App.WindowsPhone/js-moonwarriors.WindowsPhone.vcxproj index 540b2145ec..61ac75734a 100644 --- a/samples/js-moonwarriors/project/proj.win8.1-universal/App.WindowsPhone/js-moonwarriors.WindowsPhone.vcxproj +++ b/samples/js-moonwarriors/project/proj.win8.1-universal/App.WindowsPhone/js-moonwarriors.WindowsPhone.vcxproj @@ -87,7 +87,7 @@ /bigobj /Zm200 %(AdditionalOptions) 4800;%(DisableSpecificWarnings) pch.h - $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) + $(EngineRoot)..\external\win8.1-universal;$(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) false @@ -96,7 +96,7 @@ /bigobj /Zm200 %(AdditionalOptions) 4800;%(DisableSpecificWarnings) pch.h - $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) + $(EngineRoot)..\external\win8.1-universal;$(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) false @@ -105,7 +105,7 @@ /bigobj /Zm200 %(AdditionalOptions) 4800;%(DisableSpecificWarnings) pch.h - $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) + $(EngineRoot)..\external\win8.1-universal;$(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) false @@ -114,7 +114,7 @@ /bigobj /Zm200 %(AdditionalOptions) 4800;%(DisableSpecificWarnings) pch.h - $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) + $(EngineRoot)..\external\win8.1-universal;$(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) false diff --git a/samples/js-tests/main.js b/samples/js-tests/main.js index 349eabccb5..71972dda54 100644 --- a/samples/js-tests/main.js +++ b/samples/js-tests/main.js @@ -89,7 +89,8 @@ if(cc.sys){ cc.game.onStart = function(){ cc.view.enableRetina(false); if (cc.sys.isNative) { - cc.view.setDesignResolutionSize(800, 450, cc.ResolutionPolicy.FIXED_HEIGHT); + var resolutionPolicy = (cc.sys.os == cc.sys.OS_WP8 || cc.sys.os == cc.sys.OS_WINRT) ? cc.ResolutionPolicy.SHOW_ALL : cc.ResolutionPolicy.FIXED_HEIGHT; + cc.view.setDesignResolutionSize(800, 450, resolutionPolicy); cc.view.resizeWithBrowserSize(true); var searchPaths = jsb.fileUtils.getSearchPaths(); searchPaths.push('script'); diff --git a/samples/js-tests/project/proj.win8.1-universal/App.Shared/js-tests.Shared.vcxitems b/samples/js-tests/project/proj.win8.1-universal/App.Shared/js-tests.Shared.vcxitems index 03e49a7640..e39dcb7d94 100644 --- a/samples/js-tests/project/proj.win8.1-universal/App.Shared/js-tests.Shared.vcxitems +++ b/samples/js-tests/project/proj.win8.1-universal/App.Shared/js-tests.Shared.vcxitems @@ -18,8 +18,8 @@ - - $(MSBuildThisFileDirectory)..\..\..\..\..\frameworks\js-bindings\cocos2d-x\cocos\platform\win8.1-universal\OpenGLESPage.xaml + + $(MSBuildThisFileDirectory)..\..\..\..\..\frameworks\js-bindings\external\win8.1-universal\OpenGLESPage.xaml @@ -29,8 +29,8 @@ - - $(MSBuildThisFileDirectory)..\..\..\..\..\frameworks\js-bindings\cocos2d-x\cocos\platform\win8.1-universal\OpenGLESPage.xaml + + $(MSBuildThisFileDirectory)..\..\..\..\..\frameworks\js-bindings\external\win8.1-universal\OpenGLESPage.xaml @@ -53,7 +53,7 @@ - + diff --git a/samples/js-tests/project/proj.win8.1-universal/App.Shared/js-tests.Shared.vcxitems.filters b/samples/js-tests/project/proj.win8.1-universal/App.Shared/js-tests.Shared.vcxitems.filters index 5093424a0d..551ca50370 100644 --- a/samples/js-tests/project/proj.win8.1-universal/App.Shared/js-tests.Shared.vcxitems.filters +++ b/samples/js-tests/project/proj.win8.1-universal/App.Shared/js-tests.Shared.vcxitems.filters @@ -41,6 +41,6 @@ - + \ No newline at end of file diff --git a/samples/js-tests/project/proj.win8.1-universal/App.Windows/js-tests.Windows.vcxproj b/samples/js-tests/project/proj.win8.1-universal/App.Windows/js-tests.Windows.vcxproj index 6e7480279a..d9c1482c44 100644 --- a/samples/js-tests/project/proj.win8.1-universal/App.Windows/js-tests.Windows.vcxproj +++ b/samples/js-tests/project/proj.win8.1-universal/App.Windows/js-tests.Windows.vcxproj @@ -121,54 +121,96 @@ /bigobj /Zm200 %(AdditionalOptions) 4800;%(DisableSpecificWarnings) pch.h - $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) + $(EngineRoot)..\external\win8.1-universal;$(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) false + + echo "Copying Windows 8.1 Universal App CPP template files" +xcopy "$(EngineRoot)..\external\win8.1-universal\OpenGLESPage.xaml" "$(EngineRoot)..\..\..\templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /eiycq +xcopy "$(EngineRoot)..\external\win8.1-universal\OpenGLESPage.xaml.cpp" "$(EngineRoot)..\..\..\templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /eiycq +xcopy "$(EngineRoot)..\external\win8.1-universal\OpenGLESPage.xaml.h" "$(EngineRoot)..\..\..\templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /eiycq + + /bigobj /Zm200 %(AdditionalOptions) 4800;%(DisableSpecificWarnings) pch.h - $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) + $(EngineRoot)..\external\win8.1-universal;$(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) false + + echo "Copying Windows 8.1 Universal App CPP template files" +xcopy "$(EngineRoot)..\external\win8.1-universal\OpenGLESPage.xaml" "$(EngineRoot)..\..\..\templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /eiycq +xcopy "$(EngineRoot)..\external\win8.1-universal\OpenGLESPage.xaml.cpp" "$(EngineRoot)..\..\..\templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /eiycq +xcopy "$(EngineRoot)..\external\win8.1-universal\OpenGLESPage.xaml.h" "$(EngineRoot)..\..\..\templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /eiycq + + /bigobj /Zm200 %(AdditionalOptions) 4800;%(DisableSpecificWarnings) pch.h - $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) + $(EngineRoot)..\external\win8.1-universal;$(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) false + + echo "Copying Windows 8.1 Universal App CPP template files" +xcopy "$(EngineRoot)..\external\win8.1-universal\OpenGLESPage.xaml" "$(EngineRoot)..\..\..\templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /eiycq +xcopy "$(EngineRoot)..\external\win8.1-universal\OpenGLESPage.xaml.cpp" "$(EngineRoot)..\..\..\templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /eiycq +xcopy "$(EngineRoot)..\external\win8.1-universal\OpenGLESPage.xaml.h" "$(EngineRoot)..\..\..\templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /eiycq + + /bigobj /Zm200 %(AdditionalOptions) 4800;%(DisableSpecificWarnings) pch.h - $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) + $(EngineRoot)..\external\win8.1-universal;$(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) false + + echo "Copying Windows 8.1 Universal App CPP template files" +xcopy "$(EngineRoot)..\external\win8.1-universal\OpenGLESPage.xaml" "$(EngineRoot)..\..\..\templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /eiycq +xcopy "$(EngineRoot)..\external\win8.1-universal\OpenGLESPage.xaml.cpp" "$(EngineRoot)..\..\..\templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /eiycq +xcopy "$(EngineRoot)..\external\win8.1-universal\OpenGLESPage.xaml.h" "$(EngineRoot)..\..\..\templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /eiycq + + /bigobj /Zm200 %(AdditionalOptions) 4800;%(DisableSpecificWarnings) pch.h - $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) + $(EngineRoot)..\external\win8.1-universal;$(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) false + + echo "Copying Windows 8.1 Universal App CPP template files" +xcopy "$(EngineRoot)..\external\win8.1-universal\OpenGLESPage.xaml" "$(EngineRoot)..\..\..\templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /eiycq +xcopy "$(EngineRoot)..\external\win8.1-universal\OpenGLESPage.xaml.cpp" "$(EngineRoot)..\..\..\templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /eiycq +xcopy "$(EngineRoot)..\external\win8.1-universal\OpenGLESPage.xaml.h" "$(EngineRoot)..\..\..\templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /eiycq + + /bigobj /Zm200 %(AdditionalOptions) 4800;%(DisableSpecificWarnings) pch.h - $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) + $(EngineRoot)..\external\win8.1-universal;$(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) false + + echo "Copying Windows 8.1 Universal App CPP template files" +xcopy "$(EngineRoot)..\external\win8.1-universal\OpenGLESPage.xaml" "$(EngineRoot)..\..\..\templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /eiycq +xcopy "$(EngineRoot)..\external\win8.1-universal\OpenGLESPage.xaml.cpp" "$(EngineRoot)..\..\..\templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /eiycq +xcopy "$(EngineRoot)..\external\win8.1-universal\OpenGLESPage.xaml.h" "$(EngineRoot)..\..\..\templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /eiycq + + diff --git a/samples/js-tests/project/proj.win8.1-universal/App.WindowsPhone/js-tests.WindowsPhone.vcxproj b/samples/js-tests/project/proj.win8.1-universal/App.WindowsPhone/js-tests.WindowsPhone.vcxproj index 64ccbae9dc..3ebe068858 100644 --- a/samples/js-tests/project/proj.win8.1-universal/App.WindowsPhone/js-tests.WindowsPhone.vcxproj +++ b/samples/js-tests/project/proj.win8.1-universal/App.WindowsPhone/js-tests.WindowsPhone.vcxproj @@ -87,7 +87,7 @@ /bigobj /Zm200 %(AdditionalOptions) 4800;%(DisableSpecificWarnings) pch.h - $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) + $(EngineRoot)..\external\win8.1-universal;$(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) false @@ -96,7 +96,7 @@ /bigobj /Zm200 %(AdditionalOptions) 4800;%(DisableSpecificWarnings) pch.h - $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) + $(EngineRoot)..\external\win8.1-universal;$(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) false @@ -105,7 +105,7 @@ /bigobj /Zm200 %(AdditionalOptions) 4800;%(DisableSpecificWarnings) pch.h - $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) + $(EngineRoot)..\external\win8.1-universal;$(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) false @@ -114,7 +114,7 @@ /bigobj /Zm200 %(AdditionalOptions) 4800;%(DisableSpecificWarnings) pch.h - $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) + $(EngineRoot)..\external\win8.1-universal;$(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) false diff --git a/samples/js-tests/project/proj.wp8-xaml/js-tests/js-tests.csproj.user b/samples/js-tests/project/proj.wp8-xaml/js-tests/js-tests.csproj.user deleted file mode 100644 index ffd0bfc785..0000000000 --- a/samples/js-tests/project/proj.wp8-xaml/js-tests/js-tests.csproj.user +++ /dev/null @@ -1,31 +0,0 @@ - - - - 256 - 5E7661DF-D928-40ff-B747-A4B1957194F9 - - - 256 - 5E7661DF-D928-40ff-B747-A4B1957194F9 - - - 256 - 30F105C9-681E-420b-A277-7C086EAD8A4E - - - 256 - 30F105C9-681E-420b-A277-7C086EAD8A4E - - - - - - False - Native - Native - False - - - - - \ No newline at end of file diff --git a/templates/js-template-default/frameworks/runtime-src/proj.win8.1-universal/App.Shared/OpenGLESPage.xaml.cpp b/templates/js-template-default/frameworks/runtime-src/proj.win8.1-universal/App.Shared/OpenGLESPage.xaml.cpp index 9c62c40805..8f810b771f 100644 --- a/templates/js-template-default/frameworks/runtime-src/proj.win8.1-universal/App.Shared/OpenGLESPage.xaml.cpp +++ b/templates/js-template-default/frameworks/runtime-src/proj.win8.1-universal/App.Shared/OpenGLESPage.xaml.cpp @@ -49,6 +49,7 @@ OpenGLESPage::OpenGLESPage(OpenGLES* openGLES) : mUseCustomRenderSurfaceSize(false), m_coreInput(nullptr), m_dpi(0.0f), + m_visible(false), m_deviceLost(false), m_orientation(DisplayOrientations::Landscape) { @@ -118,6 +119,7 @@ void OpenGLESPage::OnPageLoaded(Platform::Object^ sender, Windows::UI::Xaml::Rou { // The SwapChainPanel has been created and arranged in the page layout, so EGL can be initialized. CreateRenderSurface(); + m_visible = true; StartRenderLoop(); } @@ -155,11 +157,11 @@ void OpenGLESPage::OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Wi { if (args->Visible && mRenderSurface != EGL_NO_SURFACE) { - StartRenderLoop(); + m_visible = true; } else { - StopRenderLoop(); + m_visible = false; } } @@ -215,19 +217,10 @@ void OpenGLESPage::DestroyRenderSurface() void OpenGLESPage::RecoverFromLostDevice() { - // Stop the render loop, reset OpenGLES, recreate the render surface - // and start the render loop again to recover from a lost device. - - StopRenderLoop(); - - { - critical_section::scoped_lock lock(mRenderSurfaceCriticalSection); - DestroyRenderSurface(); - mOpenGLES->Reset(); - CreateRenderSurface(); - } - - StartRenderLoop(); + // resets OpenGLES, recreates the render surface + DestroyRenderSurface(); + mOpenGLES->Reset(); + CreateRenderSurface(); } void OpenGLESPage::StartRenderLoop() @@ -246,34 +239,30 @@ void OpenGLESPage::StartRenderLoop() // Create a task for rendering that will be run on a background thread. auto workItemHandler = ref new Windows::System::Threading::WorkItemHandler([this, dispatcher](Windows::Foundation::IAsyncAction ^ action) { - critical_section::scoped_lock lock(mRenderSurfaceCriticalSection); - mOpenGLES->MakeCurrent(mRenderSurface); - GLsizei panelWidth = 0; GLsizei panelHeight = 0; GetSwapChainPanelSize(&panelWidth, &panelHeight); - - if (m_renderer.get() == nullptr) { m_renderer = std::make_shared(panelWidth, panelHeight, m_dpi, m_orientation, dispatcher, swapChainPanel); } - if (m_deviceLost) - { - m_deviceLost = false; - m_renderer->DeviceLost(); - } - else - { - m_renderer->Resume(); - } - + m_renderer->Resume(); while (action->Status == Windows::Foundation::AsyncStatus::Started && !m_deviceLost) { + if (!m_visible) + { + m_renderer->Pause(); + while (!m_visible) + { + Sleep(500); + } + m_renderer->Resume(); + } + GetSwapChainPanelSize(&panelWidth, &panelHeight); m_renderer.get()->Draw(panelWidth, panelHeight, m_dpi, m_orientation); @@ -289,7 +278,12 @@ void OpenGLESPage::StartRenderLoop() RecoverFromLostDevice(); }, CallbackContext::Any)); - return; + while(m_deviceLost) + { + Sleep(500); + } + mOpenGLES->MakeCurrent(mRenderSurface); + m_renderer->DeviceLost(); } } }); diff --git a/templates/js-template-default/frameworks/runtime-src/proj.win8.1-universal/App.Shared/OpenGLESPage.xaml.h b/templates/js-template-default/frameworks/runtime-src/proj.win8.1-universal/App.Shared/OpenGLESPage.xaml.h index da5cc39163..f8736e619e 100644 --- a/templates/js-template-default/frameworks/runtime-src/proj.win8.1-universal/App.Shared/OpenGLESPage.xaml.h +++ b/templates/js-template-default/frameworks/runtime-src/proj.win8.1-universal/App.Shared/OpenGLESPage.xaml.h @@ -21,6 +21,7 @@ #include "OpenGLES.h" #include "OpenGLESPage.g.h" #include +#include #include "Cocos2dRenderer.h" @@ -56,7 +57,6 @@ namespace cocos2d bool mUseCustomRenderSurfaceSize; EGLSurface mRenderSurface; // This surface is associated with a swapChainPanel on the page - Concurrency::critical_section mRenderSurfaceCriticalSection; Windows::Foundation::IAsyncAction^ mRenderLoopWorker; // Track user input on a background worker thread. @@ -71,7 +71,8 @@ namespace cocos2d void OnOrientationChanged(Windows::Graphics::Display::DisplayInformation^ sender, Platform::Object^ args); float m_dpi; - bool m_deviceLost; + std::atomic m_visible; + std::atomic m_deviceLost; Windows::Graphics::Display::DisplayOrientations m_orientation; };