2014-10-23 22:38:04 +08:00
|
|
|
|
/*
|
|
|
|
|
* 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
|
|
|
|
|
|
2016-03-24 03:14:12 +08:00
|
|
|
|
#include "OpenGLES.h"
|
2014-10-23 22:38:04 +08:00
|
|
|
|
#include "OpenGLESPage.g.h"
|
|
|
|
|
#include <memory>
|
2015-06-04 00:19:05 +08:00
|
|
|
|
#include <condition_variable>
|
|
|
|
|
#include <mutex>
|
2014-10-23 22:38:04 +08:00
|
|
|
|
|
2016-03-24 03:14:12 +08:00
|
|
|
|
#include "Cocos2dRenderer.h"
|
2014-10-23 22:38:04 +08:00
|
|
|
|
|
2015-08-19 02:06:47 +08:00
|
|
|
|
namespace CocosAppWinRT
|
2014-10-23 22:38:04 +08:00
|
|
|
|
{
|
|
|
|
|
public ref class OpenGLESPage sealed
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
OpenGLESPage();
|
|
|
|
|
virtual ~OpenGLESPage();
|
2015-08-19 02:06:47 +08:00
|
|
|
|
void SetVisibility(bool isVisible);
|
2014-10-23 22:38:04 +08:00
|
|
|
|
|
|
|
|
|
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);
|
2015-05-13 00:20:10 +08:00
|
|
|
|
#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) || _MSC_VER >= 1900
|
2015-04-18 06:47:52 +08:00
|
|
|
|
void OnBackButtonPressed(Platform::Object^ sender, Windows::Phone::UI::Input::BackPressedEventArgs^ args);
|
|
|
|
|
#endif
|
2014-10-23 22:38:04 +08:00
|
|
|
|
void CreateRenderSurface();
|
|
|
|
|
void DestroyRenderSurface();
|
|
|
|
|
void RecoverFromLostDevice();
|
2015-04-21 01:43:34 +08:00
|
|
|
|
void TerminateApp();
|
2014-10-23 22:38:04 +08:00
|
|
|
|
void StartRenderLoop();
|
|
|
|
|
void StopRenderLoop();
|
|
|
|
|
|
2015-09-18 03:09:41 +08:00
|
|
|
|
void CreateInput();
|
|
|
|
|
|
2014-10-23 22:38:04 +08:00
|
|
|
|
OpenGLES* mOpenGLES;
|
2015-08-19 02:06:47 +08:00
|
|
|
|
std::shared_ptr<Cocos2dRenderer> mRenderer;
|
2014-10-23 22:38:04 +08:00
|
|
|
|
|
|
|
|
|
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.
|
2015-06-04 00:19:05 +08:00
|
|
|
|
Windows::Foundation::IAsyncAction^ mInputLoopWorker;
|
|
|
|
|
Windows::UI::Core::CoreIndependentInputSource^ mCoreInput;
|
2014-10-23 22:38:04 +08:00
|
|
|
|
|
2015-09-18 03:09:41 +08:00
|
|
|
|
// Independent touch and pen handling functions.
|
2014-10-23 22:38:04 +08:00
|
|
|
|
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);
|
2015-09-18 03:09:41 +08:00
|
|
|
|
void OnPointerWheelChanged(Platform::Object^ sender, Windows::UI::Core::PointerEventArgs^ e);
|
|
|
|
|
|
|
|
|
|
// Independent keyboard handling functions.
|
2015-05-13 00:20:10 +08:00
|
|
|
|
void OnKeyPressed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args);
|
|
|
|
|
void OnKeyReleased(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args);
|
2015-09-18 03:09:41 +08:00
|
|
|
|
|
2015-05-13 00:20:10 +08:00
|
|
|
|
void OnCharacterReceived(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CharacterReceivedEventArgs^ args);
|
2014-10-28 02:07:00 +08:00
|
|
|
|
|
2015-01-20 01:38:49 +08:00
|
|
|
|
void OnOrientationChanged(Windows::Graphics::Display::DisplayInformation^ sender, Platform::Object^ args);
|
|
|
|
|
|
2015-06-04 00:19:05 +08:00
|
|
|
|
float mDpi;
|
|
|
|
|
bool mDeviceLost;
|
|
|
|
|
bool mVisible;
|
2015-09-18 03:09:41 +08:00
|
|
|
|
bool mCursorVisible;
|
2015-06-04 00:19:05 +08:00
|
|
|
|
Windows::Graphics::Display::DisplayOrientations mOrientation;
|
2014-11-22 08:24:51 +08:00
|
|
|
|
|
2015-06-04 00:19:05 +08:00
|
|
|
|
std::mutex mSleepMutex;
|
|
|
|
|
std::condition_variable mSleepCondition;
|
2014-10-23 22:38:04 +08:00
|
|
|
|
};
|
|
|
|
|
}
|