Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ using namespace Windows::UI::Xaml::Input;
using namespace Windows::UI::Xaml::Media;
using namespace Windows::UI::Xaml::Navigation;

#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
using namespace Windows::Phone::UI::Input;
#endif

OpenGLESPage::OpenGLESPage() :
OpenGLESPage(nullptr)
{
Expand Down Expand Up @@ -77,6 +81,7 @@ OpenGLESPage::OpenGLESPage(OpenGLES* openGLES) :

#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
Windows::UI::ViewManagement::StatusBar::GetForCurrentView()->HideAsync();
HardwareButtons::BackPressed += ref new EventHandler<BackPressedEventArgs^>(this, &OpenGLESPage::OnBackButtonPressed);
#else
// Disable all pointer visual feedback for better performance when touching.
// This is not supported on Windows Phone applications.
Expand Down Expand Up @@ -165,6 +170,21 @@ void OpenGLESPage::OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Wi
}
}

#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
void OpenGLESPage::OnBackButtonPressed(Object^ sender, BackPressedEventArgs^ args)
{
bool myAppCanNavigate = false;
if (myAppCanNavigate)
{
args->Handled = true;
}
else {
// Do nothing. Leave args->Handled set to the current value, false.
}
}
#endif


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
Expand Down Expand Up @@ -251,13 +271,17 @@ void OpenGLESPage::StartRenderLoop()

m_renderer->Resume();

while (action->Status == Windows::Foundation::AsyncStatus::Started && !m_deviceLost)
while (action->Status == Windows::Foundation::AsyncStatus::Started)
{
if (!m_visible)
{
m_renderer->Pause();
while (!m_visible)
{
if (action->Status != Windows::Foundation::AsyncStatus::Started)
{
return;
}
Sleep(500);
}
m_renderer->Resume();
Expand All @@ -280,6 +304,10 @@ void OpenGLESPage::StartRenderLoop()

while(m_deviceLost)
{
if (action->Status != Windows::Foundation::AsyncStatus::Started)
{
return;
}
Sleep(500);
}
mOpenGLES->MakeCurrent(mRenderSurface);
Expand All @@ -299,9 +327,4 @@ void OpenGLESPage::StopRenderLoop()
mRenderLoopWorker->Cancel();
mRenderLoopWorker = nullptr;
}

if (m_renderer)
{
m_renderer->Pause();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ namespace cocos2d
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);
#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
void OnBackButtonPressed(Platform::Object^ sender, Windows::Phone::UI::Input::BackPressedEventArgs^ args);
#endif
void GetSwapChainPanelSize(GLsizei* width, GLsizei* height);
void CreateRenderSurface();
void DestroyRenderSurface();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\..\frameworks\js-bindings\cocos2d-x\cocos\platform\win8.1-universal\Cocos2dRenderer.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\..\frameworks\js-bindings\cocos2d-x\cocos\platform\win8.1-universal\OpenGLES.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\..\frameworks\js-bindings\cocos2d-x\cocos\platform\win8.1-universal\OpenGLESPage.xaml.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\..\frameworks\js-bindings\external\win8.1-universal\OpenGLESPage.xaml.cpp" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="$(MSBuildThisFileDirectory)App.xaml" />
Expand All @@ -26,7 +26,7 @@
</ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\..\frameworks\js-bindings\cocos2d-x\cocos\platform\win8.1-universal\Cocos2dRenderer.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\..\frameworks\js-bindings\cocos2d-x\cocos\platform\win8.1-universal\OpenGLES.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\..\frameworks\js-bindings\cocos2d-x\cocos\platform\win8.1-universal\OpenGLESPage.xaml.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\..\frameworks\js-bindings\external\win8.1-universal\OpenGLESPage.xaml.h" />
</ItemGroup>
<ItemGroup>
<Page Include="$(MSBuildThisFileDirectory)..\..\..\..\..\frameworks\js-bindings\external\win8.1-universal\OpenGLESPage.xaml" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\..\frameworks\js-bindings\cocos2d-x\cocos\platform\win8.1-universal\Cocos2dRenderer.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\..\frameworks\js-bindings\cocos2d-x\cocos\platform\win8.1-universal\OpenGLES.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\..\frameworks\js-bindings\cocos2d-x\cocos\platform\win8.1-universal\OpenGLESPage.xaml.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\..\frameworks\js-bindings\external\win8.1-universal\OpenGLESPage.xaml.cpp" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="$(MSBuildThisFileDirectory)App.xaml" />
Expand All @@ -38,7 +38,7 @@
</ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\..\frameworks\js-bindings\cocos2d-x\cocos\platform\win8.1-universal\Cocos2dRenderer.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\..\frameworks\js-bindings\cocos2d-x\cocos\platform\win8.1-universal\OpenGLES.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\..\frameworks\js-bindings\cocos2d-x\cocos\platform\win8.1-universal\OpenGLESPage.xaml.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\..\frameworks\js-bindings\external\win8.1-universal\OpenGLESPage.xaml.h" />
</ItemGroup>
<ItemGroup>
<Page Include="$(MSBuildThisFileDirectory)..\..\..\..\..\frameworks\js-bindings\external\win8.1-universal\OpenGLESPage.xaml" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ using namespace Windows::UI::Xaml::Input;
using namespace Windows::UI::Xaml::Media;
using namespace Windows::UI::Xaml::Navigation;

#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
using namespace Windows::Phone::UI::Input;
#endif

OpenGLESPage::OpenGLESPage() :
OpenGLESPage(nullptr)
{
Expand Down Expand Up @@ -77,6 +81,7 @@ OpenGLESPage::OpenGLESPage(OpenGLES* openGLES) :

#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
Windows::UI::ViewManagement::StatusBar::GetForCurrentView()->HideAsync();
HardwareButtons::BackPressed += ref new EventHandler<BackPressedEventArgs^>(this, &OpenGLESPage::OnBackButtonPressed);
#else
// Disable all pointer visual feedback for better performance when touching.
// This is not supported on Windows Phone applications.
Expand Down Expand Up @@ -165,6 +170,21 @@ void OpenGLESPage::OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Wi
}
}

#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
void OpenGLESPage::OnBackButtonPressed(Object^ sender, BackPressedEventArgs^ args)
{
bool myAppCanNavigate = false;
if (myAppCanNavigate)
{
args->Handled = true;
}
else {
// Do nothing. Leave args->Handled set to the current value, false.
}
}
#endif


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
Expand Down Expand Up @@ -251,13 +271,17 @@ void OpenGLESPage::StartRenderLoop()

m_renderer->Resume();

while (action->Status == Windows::Foundation::AsyncStatus::Started && !m_deviceLost)
while (action->Status == Windows::Foundation::AsyncStatus::Started)
{
if (!m_visible)
{
m_renderer->Pause();
while (!m_visible)
{
if (action->Status != Windows::Foundation::AsyncStatus::Started)
{
return;
}
Sleep(500);
}
m_renderer->Resume();
Expand All @@ -280,6 +304,10 @@ void OpenGLESPage::StartRenderLoop()

while(m_deviceLost)
{
if (action->Status != Windows::Foundation::AsyncStatus::Started)
{
return;
}
Sleep(500);
}
mOpenGLES->MakeCurrent(mRenderSurface);
Expand All @@ -299,9 +327,4 @@ void OpenGLESPage::StopRenderLoop()
mRenderLoopWorker->Cancel();
mRenderLoopWorker = nullptr;
}

if (m_renderer)
{
m_renderer->Pause();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ namespace cocos2d
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);
#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
void OnBackButtonPressed(Platform::Object^ sender, Windows::Phone::UI::Input::BackPressedEventArgs^ args);
#endif
void GetSwapChainPanelSize(GLsizei* width, GLsizei* height);
void CreateRenderSurface();
void DestroyRenderSurface();
Expand Down