OpenGLESPage.xaml.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * cocos2d-x http://www.cocos2d-x.org
  3. *
  4. * Copyright (c) 2010-2014 - cocos2d-x community
  5. *
  6. * Portions Copyright (c) Microsoft Open Technologies, Inc.
  7. * All Rights Reserved
  8. *
  9. * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
  10. * You may obtain a copy of the License at
  11. *
  12. * http://www.apache.org/licenses/LICENSE-2.0
  13. *
  14. * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
  15. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and limitations under the License.
  17. */
  18. #pragma once
  19. #include "OpenGLES.h"
  20. #include "OpenGLESPage.g.h"
  21. #include <memory>
  22. #include <condition_variable>
  23. #include <mutex>
  24. #include "Cocos2dRenderer.h"
  25. namespace CocosAppWinRT
  26. {
  27. public ref class OpenGLESPage sealed
  28. {
  29. public:
  30. OpenGLESPage();
  31. virtual ~OpenGLESPage();
  32. void SetVisibility(bool isVisible);
  33. internal:
  34. OpenGLESPage(OpenGLES* openGLES);
  35. private:
  36. void OnPageLoaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
  37. void OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args);
  38. #if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) || _MSC_VER >= 1900
  39. void OnBackButtonPressed(Platform::Object^ sender, Windows::Phone::UI::Input::BackPressedEventArgs^ args);
  40. #endif
  41. void CreateRenderSurface();
  42. void DestroyRenderSurface();
  43. void RecoverFromLostDevice();
  44. void TerminateApp();
  45. void StartRenderLoop();
  46. void StopRenderLoop();
  47. void CreateInput();
  48. OpenGLES* mOpenGLES;
  49. std::shared_ptr<Cocos2dRenderer> mRenderer;
  50. EGLSurface mRenderSurface; // This surface is associated with a swapChainPanel on the page
  51. Concurrency::critical_section mRenderSurfaceCriticalSection;
  52. Windows::Foundation::IAsyncAction^ mRenderLoopWorker;
  53. // Track user input on a background worker thread.
  54. Windows::Foundation::IAsyncAction^ mInputLoopWorker;
  55. Windows::UI::Core::CoreIndependentInputSource^ mCoreInput;
  56. // Independent touch and pen handling functions.
  57. void OnPointerPressed(Platform::Object^ sender, Windows::UI::Core::PointerEventArgs^ e);
  58. void OnPointerMoved(Platform::Object^ sender, Windows::UI::Core::PointerEventArgs^ e);
  59. void OnPointerReleased(Platform::Object^ sender, Windows::UI::Core::PointerEventArgs^ e);
  60. void OnPointerWheelChanged(Platform::Object^ sender, Windows::UI::Core::PointerEventArgs^ e);
  61. // Independent keyboard handling functions.
  62. void OnKeyPressed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args);
  63. void OnKeyReleased(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args);
  64. void OnCharacterReceived(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CharacterReceivedEventArgs^ args);
  65. void OnOrientationChanged(Windows::Graphics::Display::DisplayInformation^ sender, Platform::Object^ args);
  66. float mDpi;
  67. bool mDeviceLost;
  68. bool mVisible;
  69. bool mCursorVisible;
  70. Windows::Graphics::Display::DisplayOrientations mOrientation;
  71. std::mutex mSleepMutex;
  72. std::condition_variable mSleepCondition;
  73. };
  74. }