2014-03-29 03:52:16 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2010 cocos2d-x.org
|
|
|
|
Copyright (c) Microsoft Open Technologies, Inc.
|
2018-01-29 16:25:32 +08:00
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
2014-03-29 03:52:16 +08:00
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2014-08-07 18:38:11 +08:00
|
|
|
#ifndef __CC_EGLVIEWIMPL_WINRT_H__
|
|
|
|
#define __CC_EGLVIEWIMPL_WINRT_H__
|
2014-03-29 03:52:16 +08:00
|
|
|
|
2014-09-10 08:53:08 +08:00
|
|
|
#include "platform/CCPlatformConfig.h"
|
2014-05-17 05:36:00 +08:00
|
|
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
|
|
|
|
|
2016-03-20 21:53:44 +08:00
|
|
|
#include "platform/winrt/CCStdC.h"
|
|
|
|
#include "platform/winrt/CCGL.h"
|
2014-03-29 03:52:16 +08:00
|
|
|
#include "platform/CCCommon.h"
|
2016-03-20 21:53:44 +08:00
|
|
|
#include "platform/winrt/InputEvent.h"
|
2014-08-07 18:38:11 +08:00
|
|
|
#include "platform/CCGLView.h"
|
2014-03-29 03:52:16 +08:00
|
|
|
|
|
|
|
#include <wrl/client.h>
|
|
|
|
|
|
|
|
#include <agile.h>
|
|
|
|
#include <DirectXMath.h>
|
2014-04-20 00:37:54 +08:00
|
|
|
#include <mutex>
|
|
|
|
#include <queue>
|
2014-03-29 03:52:16 +08:00
|
|
|
|
|
|
|
NS_CC_BEGIN
|
|
|
|
|
|
|
|
class CCEGL;
|
2014-08-07 18:38:11 +08:00
|
|
|
class GLViewImpl;
|
2014-03-29 03:52:16 +08:00
|
|
|
|
|
|
|
ref class WinRTWindow sealed
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
WinRTWindow(Windows::UI::Core::CoreWindow^ window);
|
|
|
|
void Initialize(Windows::UI::Core::CoreWindow^ window, Windows::UI::Xaml::Controls::SwapChainBackgroundPanel^ panel);
|
|
|
|
void setIMEKeyboardState(bool bOpen);
|
|
|
|
void swapBuffers();
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
2014-05-15 01:07:09 +08:00
|
|
|
cocos2d::Vec2 GetCCPoint(Windows::UI::Core::PointerEventArgs^ args);
|
2014-03-29 03:52:16 +08:00
|
|
|
|
|
|
|
void OnTextKeyDown(Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e);
|
|
|
|
void OnTextKeyUp(Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e);
|
|
|
|
|
|
|
|
void OnPointerWheelChanged(Windows::UI::Core::CoreWindow^, Windows::UI::Core::PointerEventArgs^ args);
|
|
|
|
void OnPointerMoved(Windows::UI::Core::CoreWindow^, Windows::UI::Core::PointerEventArgs^ args);
|
|
|
|
void OnPointerPressed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
|
|
|
|
void OnPointerReleased(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
|
|
|
|
void OnWindowSizeChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ args);
|
|
|
|
void OnLogicalDpiChanged(Platform::Object^ sender);
|
|
|
|
void OnOrientationChanged(Platform::Object^ sender);
|
|
|
|
void OnDisplayContentsInvalidated(Platform::Object^ sender);
|
|
|
|
void OnRendering(Platform::Object^ sender, Platform::Object^ args);
|
|
|
|
void OnSuspending();
|
|
|
|
void ResizeWindow();
|
|
|
|
|
|
|
|
|
|
|
|
void ShowKeyboard(Windows::UI::ViewManagement::InputPane^ inputPane, Windows::UI::ViewManagement::InputPaneVisibilityEventArgs^ args);
|
|
|
|
void HideKeyboard(Windows::UI::ViewManagement::InputPane^ inputPane, Windows::UI::ViewManagement::InputPaneVisibilityEventArgs^ args);
|
|
|
|
|
|
|
|
Platform::Agile<Windows::UI::Core::CoreWindow> m_window;
|
|
|
|
|
2014-05-13 00:25:37 +08:00
|
|
|
Windows::Foundation::Point m_lastPoint;
|
2014-03-29 03:52:16 +08:00
|
|
|
Windows::Foundation::EventRegistrationToken m_eventToken;
|
|
|
|
bool m_lastPointValid;
|
|
|
|
bool m_textInputEnabled;
|
|
|
|
Microsoft::WRL::ComPtr<IWinrtEglWindow> m_eglWindow;
|
|
|
|
Windows::UI::Xaml::Controls::TextBox^ m_textBox;
|
|
|
|
Windows::UI::Xaml::Controls::Button^ m_dummy;
|
|
|
|
|
|
|
|
ESContext m_esContext;
|
|
|
|
|
|
|
|
|
2014-08-07 18:38:11 +08:00
|
|
|
friend GLViewImpl;
|
2014-03-29 03:52:16 +08:00
|
|
|
};
|
|
|
|
|
2014-08-07 18:38:11 +08:00
|
|
|
class CC_DLL GLViewImpl : public GLView
|
2014-03-29 03:52:16 +08:00
|
|
|
{
|
|
|
|
public:
|
2014-08-07 18:38:11 +08:00
|
|
|
GLViewImpl();
|
|
|
|
virtual ~GLViewImpl();
|
2014-03-29 03:52:16 +08:00
|
|
|
|
|
|
|
/* override functions */
|
|
|
|
virtual bool isOpenGLReady();
|
|
|
|
virtual void end();
|
|
|
|
virtual void swapBuffers();
|
|
|
|
virtual void setFrameSize(float width, float height);
|
|
|
|
virtual void setIMEKeyboardState(bool bOpen);
|
|
|
|
void ShowKeyboard(Windows::Foundation::Rect r);
|
|
|
|
void HideKeyboard(Windows::Foundation::Rect r);
|
|
|
|
virtual bool Create(Windows::UI::Core::CoreWindow^ window, Windows::UI::Xaml::Controls::SwapChainBackgroundPanel^ panel);
|
|
|
|
void UpdateForWindowSizeChange();
|
|
|
|
void OnRendering();
|
|
|
|
void OnSuspending();
|
2014-08-07 18:38:11 +08:00
|
|
|
void GLViewImpl::QueueEvent(std::shared_ptr<InputEvent>& event);
|
2014-03-29 03:52:16 +08:00
|
|
|
|
2014-05-13 00:25:37 +08:00
|
|
|
void OnPointerPressed(Windows::UI::Core::PointerEventArgs^ args);
|
|
|
|
void OnPointerMoved(Windows::UI::Core::PointerEventArgs^ args);
|
|
|
|
void OnPointerReleased(Windows::UI::Core::PointerEventArgs^ args);
|
|
|
|
void OnPointerPressed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
|
|
|
|
void OnBackKeyPress();
|
|
|
|
|
|
|
|
|
2014-03-29 03:52:16 +08:00
|
|
|
private:
|
|
|
|
Windows::Foundation::EventRegistrationToken m_eventToken;
|
2014-05-13 00:25:37 +08:00
|
|
|
Windows::Foundation::Point m_lastPoint;
|
2014-03-29 03:52:16 +08:00
|
|
|
bool m_lastPointValid;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
// winrt platform functions
|
|
|
|
Windows::UI::Core::CoreWindow^ getWindow() { return m_window.Get(); };
|
|
|
|
|
|
|
|
int Run();
|
|
|
|
|
|
|
|
void resize(int width, int height);
|
|
|
|
/*
|
|
|
|
* Set zoom factor for frame. This method is for debugging big resolution (e.g.new ipad) app on desktop.
|
|
|
|
*/
|
|
|
|
void setFrameZoomFactor(float fZoomFactor);
|
|
|
|
float getFrameZoomFactor();
|
|
|
|
void centerWindow();
|
|
|
|
|
|
|
|
|
|
|
|
// static function
|
|
|
|
/**
|
|
|
|
@brief get the shared main open gl window
|
|
|
|
*/
|
2014-08-07 18:38:11 +08:00
|
|
|
static GLViewImpl* sharedOpenGLView();
|
2014-03-29 03:52:16 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
private:
|
|
|
|
Platform::Agile<Windows::UI::Core::CoreWindow> m_window;
|
|
|
|
bool m_running;
|
|
|
|
bool m_initialized;
|
|
|
|
bool m_bSupportTouch;
|
|
|
|
float m_fFrameZoomFactor;
|
|
|
|
WinRTWindow^ m_winRTWindow;
|
|
|
|
Windows::Foundation::Rect m_keyboardRect;
|
2014-04-20 00:37:54 +08:00
|
|
|
|
|
|
|
std::queue<std::shared_ptr<InputEvent>> mInputEvents;
|
|
|
|
std::mutex mMutex;
|
2014-03-29 03:52:16 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
NS_CC_END
|
|
|
|
|
2014-05-17 05:36:00 +08:00
|
|
|
#endif // (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
|
|
|
|
|
2014-08-07 18:38:11 +08:00
|
|
|
#endif // end of __CC_EGLVIEWIMPL_WINRT_H__
|