2014-10-15 07:32:39 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2010 cocos2d-x.org
|
|
|
|
Copyright (c) Microsoft Open Technologies, Inc.
|
|
|
|
|
|
|
|
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.
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __CC_EGLVIEWIMPL_WINRT_H__
|
|
|
|
#define __CC_EGLVIEWIMPL_WINRT_H__
|
|
|
|
|
2016-03-20 21:53:44 +08:00
|
|
|
#include "platform/winrt/CCStdC.h"
|
2014-10-15 07:32:39 +08:00
|
|
|
#include "platform/CCCommon.h"
|
2016-03-20 21:53:44 +08:00
|
|
|
#include "platform/winrt/Keyboard-winrt.h"
|
2014-10-15 07:32:39 +08:00
|
|
|
#include "platform/CCGLView.h"
|
2015-10-03 09:49:41 +08:00
|
|
|
#include "base/CCEventKeyboard.h"
|
2014-10-15 07:32:39 +08:00
|
|
|
|
|
|
|
#include <agile.h>
|
2014-10-27 23:32:19 +08:00
|
|
|
#include <concurrent_queue.h>
|
2014-10-23 22:07:58 +08:00
|
|
|
#include <string>
|
2014-10-28 02:07:00 +08:00
|
|
|
#include <memory>
|
2014-10-15 07:32:39 +08:00
|
|
|
#include <wrl/client.h>
|
|
|
|
|
|
|
|
NS_CC_BEGIN
|
|
|
|
|
|
|
|
class GLViewImpl;
|
|
|
|
|
|
|
|
class CC_DLL GLViewImpl : public GLView
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static GLViewImpl* create(const std::string& viewName);
|
|
|
|
|
|
|
|
/* override functions */
|
|
|
|
virtual bool isOpenGLReady();
|
|
|
|
virtual void end();
|
|
|
|
virtual void swapBuffers();
|
|
|
|
|
|
|
|
Windows::Graphics::Display::DisplayOrientations getDeviceOrientation() {return m_orientation;};
|
|
|
|
Size getRenerTargetSize() const { return Size(m_width, m_height); }
|
|
|
|
|
2015-08-28 02:19:59 +08:00
|
|
|
virtual void setIMEKeyboardState(bool bOpen) override;
|
2015-05-09 00:19:13 +08:00
|
|
|
virtual void setIMEKeyboardState(bool bOpen, const std::string& str);
|
2014-10-15 07:32:39 +08:00
|
|
|
|
2014-10-28 02:07:00 +08:00
|
|
|
virtual bool Create(float width, float height, float dpi, Windows::Graphics::Display::DisplayOrientations orientation);
|
2014-10-23 22:07:58 +08:00
|
|
|
|
2015-08-28 02:19:59 +08:00
|
|
|
/**
|
|
|
|
* Hide or Show the mouse cursor if there is one.
|
|
|
|
*
|
|
|
|
* @param isVisible Hide or Show the mouse cursor if there is one.
|
|
|
|
*/
|
|
|
|
virtual void setCursorVisible(bool isVisible) override;
|
|
|
|
|
|
|
|
bool isCursorVisible() { return _isCursorVisible; }
|
|
|
|
|
2014-10-23 22:07:58 +08:00
|
|
|
void setDispatcher(Windows::UI::Core::CoreDispatcher^ dispatcher);
|
|
|
|
Windows::UI::Core::CoreDispatcher^ getDispatcher() {return m_dispatcher.Get();}
|
|
|
|
|
|
|
|
void setPanel(Windows::UI::Xaml::Controls::Panel^ panel);
|
|
|
|
Windows::UI::Xaml::Controls::Panel^ getPanel() {return m_panel.Get();}
|
2014-10-15 07:32:39 +08:00
|
|
|
|
|
|
|
void OnPointerPressed(Windows::UI::Core::PointerEventArgs^ args);
|
|
|
|
void OnPointerMoved(Windows::UI::Core::PointerEventArgs^ args);
|
|
|
|
void OnPointerReleased(Windows::UI::Core::PointerEventArgs^ args);
|
2015-08-28 02:34:25 +08:00
|
|
|
|
|
|
|
void OnMousePressed(Windows::UI::Core::PointerEventArgs^ args);
|
|
|
|
void OnMouseMoved(Windows::UI::Core::PointerEventArgs^ args);
|
|
|
|
void OnMouseReleased(Windows::UI::Core::PointerEventArgs^ args);
|
|
|
|
void OnMouseWheelChanged(Windows::UI::Core::PointerEventArgs^ args);
|
|
|
|
|
2015-05-13 00:20:10 +08:00
|
|
|
void OnWinRTKeyboardEvent(WinRTKeyboardEventType type, Windows::UI::Core::KeyEventArgs^ args);
|
|
|
|
|
|
|
|
|
2014-10-15 07:32:39 +08:00
|
|
|
void OnPointerPressed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
|
|
|
|
void OnPointerWheelChanged(Windows::UI::Core::CoreWindow^, Windows::UI::Core::PointerEventArgs^ args);
|
|
|
|
void OnPointerMoved(Windows::UI::Core::CoreWindow^, Windows::UI::Core::PointerEventArgs^ args);
|
|
|
|
void OnPointerReleased(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
|
|
|
|
void OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args);
|
|
|
|
void OnWindowClosed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CoreWindowEventArgs^ args);
|
|
|
|
void OnResuming(Platform::Object^ sender, Platform::Object^ args);
|
|
|
|
void OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ args);
|
|
|
|
void OnBackKeyPress();
|
2015-04-21 01:43:34 +08:00
|
|
|
bool AppShouldExit();
|
2015-04-20 09:53:10 +08:00
|
|
|
void BackButtonListener(cocos2d::EventKeyboard::KeyCode keyCode, cocos2d::Event* event);
|
2014-10-15 07:32:39 +08:00
|
|
|
|
|
|
|
void QueueBackKeyPress();
|
2015-05-13 00:20:10 +08:00
|
|
|
void QueuePointerEvent(PointerEventType type, Windows::UI::Core::PointerEventArgs^ args);
|
|
|
|
void QueueWinRTKeyboardEvent(WinRTKeyboardEventType type, Windows::UI::Core::KeyEventArgs^ args);
|
|
|
|
void QueueEvent(std::shared_ptr<InputEvent>& event);
|
2014-10-15 07:32:39 +08:00
|
|
|
|
|
|
|
bool ShowMessageBox(Platform::String^ title, Platform::String^ message);
|
|
|
|
|
|
|
|
int Run();
|
|
|
|
void Render();
|
|
|
|
|
|
|
|
void resize(int width, int height);
|
|
|
|
|
|
|
|
float getFrameZoomFactor();
|
|
|
|
void centerWindow();
|
|
|
|
|
|
|
|
void UpdateOrientation(Windows::Graphics::Display::DisplayOrientations orientation);
|
2014-10-28 02:07:00 +08:00
|
|
|
void UpdateForWindowSizeChange(float width, float height);
|
|
|
|
|
|
|
|
void SetDPI(float dpi) { m_dpi = dpi; }
|
|
|
|
float GetDPI() { return m_dpi; }
|
|
|
|
|
2014-10-15 07:32:39 +08:00
|
|
|
// static function
|
|
|
|
/**
|
|
|
|
@brief get the shared main open gl window
|
|
|
|
*/
|
|
|
|
static GLViewImpl* sharedOpenGLView();
|
|
|
|
|
|
|
|
void ProcessEvents();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
GLViewImpl();
|
|
|
|
virtual ~GLViewImpl();
|
|
|
|
|
|
|
|
bool initWithRect(const std::string& viewName, Rect rect, float frameZoomFactor);
|
|
|
|
bool initWithFullScreen(const std::string& viewName);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set zoom factor for frame. This method is for debugging big resolution (e.g.new ipad) app on desktop.
|
|
|
|
*/
|
|
|
|
void setFrameZoomFactor(float zoomFactor);
|
|
|
|
|
|
|
|
inline bool isRetina() { return _isRetina; };
|
|
|
|
|
|
|
|
float _frameZoomFactor;
|
|
|
|
bool _supportTouch;
|
|
|
|
bool _isRetina;
|
2015-08-28 02:19:59 +08:00
|
|
|
bool _isCursorVisible;
|
2014-10-15 07:32:39 +08:00
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(GLViewImpl);
|
|
|
|
|
|
|
|
void OnRendering();
|
|
|
|
void UpdateWindowSize();
|
2014-10-23 22:07:58 +08:00
|
|
|
|
2014-10-15 07:32:39 +08:00
|
|
|
cocos2d::Vec2 TransformToOrientation(Windows::Foundation::Point point);
|
|
|
|
cocos2d::Vec2 GetPoint(Windows::UI::Core::PointerEventArgs^ args);
|
2015-08-28 02:34:25 +08:00
|
|
|
cocos2d::Vec2 GetPointMouse(Windows::UI::Core::PointerEventArgs^ args);
|
2014-10-15 07:32:39 +08:00
|
|
|
|
|
|
|
Windows::Foundation::Rect m_windowBounds;
|
|
|
|
Windows::Foundation::EventRegistrationToken m_eventToken;
|
|
|
|
Windows::Foundation::Point m_lastPoint;
|
|
|
|
|
|
|
|
float m_width;
|
|
|
|
float m_height;
|
2014-10-28 02:07:00 +08:00
|
|
|
float m_dpi;
|
2014-10-15 07:32:39 +08:00
|
|
|
|
|
|
|
Windows::Graphics::Display::DisplayOrientations m_orientation;
|
|
|
|
Windows::Foundation::Rect m_keyboardRect;
|
|
|
|
|
|
|
|
bool m_lastPointValid;
|
|
|
|
bool m_windowClosed;
|
|
|
|
bool m_windowVisible;
|
2015-08-28 02:34:25 +08:00
|
|
|
// PointerReleased for mouse not send button id, need save in PointerPressed last button
|
|
|
|
MouseButton _lastMouseButtonPressed;
|
2014-10-15 07:32:39 +08:00
|
|
|
|
|
|
|
bool m_running;
|
|
|
|
bool m_initialized;
|
2015-04-21 01:43:34 +08:00
|
|
|
bool m_appShouldExit;
|
2014-10-15 07:32:39 +08:00
|
|
|
|
2014-10-27 23:32:19 +08:00
|
|
|
Concurrency::concurrent_queue<std::shared_ptr<InputEvent>> mInputEvents;
|
2014-10-15 07:32:39 +08:00
|
|
|
|
2014-10-23 22:07:58 +08:00
|
|
|
Platform::Agile<Windows::UI::Core::CoreDispatcher> m_dispatcher;
|
|
|
|
Platform::Agile<Windows::UI::Xaml::Controls::Panel> m_panel;
|
2015-08-28 02:34:25 +08:00
|
|
|
|
2014-10-23 22:07:58 +08:00
|
|
|
KeyBoardWinRT^ m_keyboard;
|
2015-04-20 09:53:10 +08:00
|
|
|
|
|
|
|
cocos2d::EventListenerKeyboard* m_backButtonListener;
|
|
|
|
|
2014-10-15 07:32:39 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
NS_CC_END
|
|
|
|
|
|
|
|
#endif // end of __CC_EGLVIEWIMPL_WINRT_H__
|