Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from MSOpenTech/v3.10-win10
V3.10 Add support for Windows 10 UWP and Windows 8.1 Universal Apps
- Loading branch information
Showing
61 changed files
with
4,572 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<Application | ||
x:Class="CocosAppWinRT.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:CocosAppWinRT" | ||
xmlns:localData="using:Shared"> | ||
|
||
<Application.Resources> | ||
|
||
<x:String x:Key="AppName">HelloCpp</x:String> | ||
|
||
</Application.Resources> | ||
</Application> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#include "App.xaml.h" | ||
#include "OpenGLESPage.xaml.h" | ||
|
||
using namespace Platform; | ||
using namespace Windows::ApplicationModel; | ||
using namespace Windows::ApplicationModel::Activation; | ||
using namespace Windows::Foundation; | ||
using namespace Windows::Foundation::Collections; | ||
using namespace Windows::UI::Xaml::Media::Animation; | ||
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::Interop; | ||
using namespace Windows::UI::Xaml::Media; | ||
using namespace Windows::UI::Xaml::Navigation; | ||
using namespace cocos2d; | ||
using namespace CocosAppWinRT; | ||
|
||
App::App() | ||
{ | ||
InitializeComponent(); | ||
Suspending += ref new SuspendingEventHandler(this, &App::OnSuspending); | ||
Resuming += ref new EventHandler<Object^>(this, &App::OnResuming); | ||
} | ||
|
||
void App::OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ e) | ||
{ | ||
if (mPage == nullptr) | ||
{ | ||
mPage = ref new OpenGLESPage(&mOpenGLES); | ||
} | ||
|
||
// Place the page in the current window and ensure that it is active. | ||
Windows::UI::Xaml::Window::Current->Content = mPage; | ||
Windows::UI::Xaml::Window::Current->Activate(); | ||
} | ||
|
||
/// <summary> | ||
/// Invoked when application execution is being suspended. Application state is saved | ||
/// without knowing whether the application will be terminated or resumed with the contents | ||
/// of memory still intact. | ||
/// </summary> | ||
void App::OnSuspending(Object^ sender, SuspendingEventArgs^ e) | ||
{ | ||
(void)sender; // Unused parameter | ||
(void)e; // Unused parameter | ||
|
||
mPage->SetVisibility(false); | ||
} | ||
|
||
/// <summary> | ||
/// Invoked when application execution is being resumed. | ||
/// </summary> | ||
/// <param name="sender">The source of the resume request.</param> | ||
/// <param name="args">Details about the resume request.</param> | ||
void App::OnResuming(Object ^sender, Object ^args) | ||
{ | ||
(void)sender; // Unused parameter | ||
(void)args; // Unused parameter | ||
|
||
mPage->SetVisibility(true); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#pragma once | ||
|
||
#include "app.g.h" | ||
#include "OpenGLES.h" | ||
#include "openglespage.xaml.h" | ||
|
||
namespace CocosAppWinRT | ||
{ | ||
ref class App sealed | ||
{ | ||
public: | ||
App(); | ||
virtual void OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ e) override; | ||
|
||
private: | ||
void OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ e); | ||
void OnResuming(Platform::Object ^sender, Platform::Object ^args); | ||
|
||
OpenGLESPage^ mPage; | ||
OpenGLES mOpenGLES; | ||
}; | ||
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.23 KB
cpp/proj.win10/App/Assets/Square44x44Logo.targetsize-24_altform-unplated.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
/* | ||
* 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 "Cocos2dRenderer.h" | ||
#include "AppDelegate.h" | ||
#include "CCGLViewImpl-winrt.h" | ||
#include "CCApplication.h" | ||
#include "cocos2d.h" | ||
#include "renderer/CCTextureCache.h" | ||
|
||
// These are used by the shader compilation methods. | ||
#include <vector> | ||
#include <iostream> | ||
#include <fstream> | ||
|
||
using namespace Platform; | ||
using namespace Windows::UI::Core; | ||
using namespace Windows::UI::Xaml::Controls; | ||
using namespace Windows::Graphics::Display; | ||
using namespace cocos2d; | ||
|
||
Cocos2dRenderer::Cocos2dRenderer(int width, int height, float dpi, DisplayOrientations orientation, CoreDispatcher^ dispatcher, Panel^ panel) | ||
: m_app(nullptr) | ||
, m_width(width) | ||
, m_height(height) | ||
, m_dpi(dpi) | ||
, m_dispatcher(dispatcher) | ||
, m_panel(panel) | ||
, m_orientation(orientation) | ||
{ | ||
m_app = new AppDelegate(); | ||
} | ||
|
||
Cocos2dRenderer::~Cocos2dRenderer() | ||
{ | ||
delete m_app; | ||
} | ||
|
||
void Cocos2dRenderer::Resume() | ||
{ | ||
auto director = cocos2d::Director::getInstance(); | ||
auto glview = director->getOpenGLView(); | ||
|
||
if (!glview) | ||
{ | ||
GLViewImpl* glview = GLViewImpl::create("Test Cpp"); | ||
glview->setDispatcher(m_dispatcher.Get()); | ||
glview->setPanel(m_panel.Get()); | ||
glview->Create(static_cast<float>(m_width), static_cast<float>(m_height), m_dpi, m_orientation); | ||
director->setOpenGLView(glview); | ||
CCApplication::getInstance()->run(); | ||
} | ||
else | ||
{ | ||
Application::getInstance()->applicationWillEnterForeground(); | ||
cocos2d::EventCustom foregroundEvent(EVENT_COME_TO_FOREGROUND); | ||
cocos2d::Director::getInstance()->getEventDispatcher()->dispatchEvent(&foregroundEvent); | ||
} | ||
} | ||
|
||
void Cocos2dRenderer::Pause() | ||
{ | ||
if (Director::getInstance()->getOpenGLView()) { | ||
Application::getInstance()->applicationDidEnterBackground(); | ||
cocos2d::EventCustom backgroundEvent(EVENT_COME_TO_BACKGROUND); | ||
cocos2d::Director::getInstance()->getEventDispatcher()->dispatchEvent(&backgroundEvent); | ||
} | ||
} | ||
|
||
bool Cocos2dRenderer::AppShouldExit() | ||
{ | ||
return GLViewImpl::sharedOpenGLView()->AppShouldExit(); | ||
} | ||
|
||
void Cocos2dRenderer::DeviceLost() | ||
{ | ||
Pause(); | ||
|
||
auto director = cocos2d::Director::getInstance(); | ||
if (director->getOpenGLView()) { | ||
cocos2d::GL::invalidateStateCache(); | ||
cocos2d::GLProgramCache::getInstance()->reloadDefaultGLPrograms(); | ||
cocos2d::DrawPrimitives::init(); | ||
cocos2d::VolatileTextureMgr::reloadAllTextures(); | ||
|
||
cocos2d::EventCustom recreatedEvent(EVENT_RENDERER_RECREATED); | ||
director->getEventDispatcher()->dispatchEvent(&recreatedEvent); | ||
director->setGLDefaultValues(); | ||
|
||
Application::getInstance()->applicationWillEnterForeground(); | ||
cocos2d::EventCustom foregroundEvent(EVENT_COME_TO_FOREGROUND); | ||
cocos2d::Director::getInstance()->getEventDispatcher()->dispatchEvent(&foregroundEvent); | ||
} | ||
} | ||
|
||
|
||
|
||
void Cocos2dRenderer::Draw(GLsizei width, GLsizei height, float dpi, DisplayOrientations orientation) | ||
{ | ||
auto glView = GLViewImpl::sharedOpenGLView(); | ||
|
||
if (orientation != m_orientation) | ||
{ | ||
m_orientation = orientation; | ||
glView->UpdateOrientation(orientation); | ||
} | ||
|
||
if (width != m_width || height != m_height) | ||
{ | ||
m_width = width; | ||
m_height = height; | ||
glView->UpdateForWindowSizeChange(static_cast<float>(width), static_cast<float>(height)); | ||
} | ||
|
||
if (dpi != m_dpi) | ||
{ | ||
m_dpi = dpi; | ||
glView->SetDPI(m_dpi); | ||
} | ||
|
||
glView->ProcessEvents(); | ||
glView->Render(); | ||
} | ||
|
||
void Cocos2dRenderer::QueuePointerEvent(cocos2d::PointerEventType type, Windows::UI::Core::PointerEventArgs^ args) | ||
{ | ||
GLViewImpl::sharedOpenGLView()->QueuePointerEvent(type, args); | ||
} | ||
|
||
void Cocos2dRenderer::QueueBackButtonEvent() | ||
{ | ||
GLViewImpl::sharedOpenGLView()->QueueBackKeyPress(); | ||
} | ||
|
||
void Cocos2dRenderer::QueueKeyboardEvent(WinRTKeyboardEventType type, Windows::UI::Core::KeyEventArgs^ args) | ||
{ | ||
GLViewImpl::sharedOpenGLView()->QueueWinRTKeyboardEvent(type, args); | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* 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 <agile.h> | ||
|
||
#include "cocos2d.h" | ||
|
||
|
||
class AppDelegate; | ||
|
||
class Cocos2dRenderer | ||
{ | ||
public: | ||
Cocos2dRenderer(int width, int height, float dpi, | ||
Windows::Graphics::Display::DisplayOrientations orientation, | ||
Windows::UI::Core::CoreDispatcher^ dispatcher, Windows::UI::Xaml::Controls::Panel^ panel); | ||
~Cocos2dRenderer(); | ||
void Draw(GLsizei width, GLsizei height, float dpi, Windows::Graphics::Display::DisplayOrientations orientation); | ||
void QueuePointerEvent(cocos2d::PointerEventType type, Windows::UI::Core::PointerEventArgs^ args); | ||
void QueueKeyboardEvent(cocos2d::WinRTKeyboardEventType type, Windows::UI::Core::KeyEventArgs^ args); | ||
void QueueBackButtonEvent(); | ||
void Pause(); | ||
void Resume(); | ||
void DeviceLost(); | ||
bool AppShouldExit(); | ||
|
||
private: | ||
|
||
int m_width; | ||
int m_height; | ||
float m_dpi; | ||
|
||
// The AppDelegate for the Cocos2D app | ||
AppDelegate* m_app; | ||
Platform::Agile<Windows::UI::Core::CoreDispatcher> m_dispatcher; | ||
Platform::Agile<Windows::UI::Xaml::Controls::Panel> m_panel; | ||
Windows::Graphics::Display::DisplayOrientations m_orientation; | ||
}; |
Oops, something went wrong.