diff options
Diffstat (limited to 'platform/winrt')
| -rw-r--r-- | platform/winrt/app.cpp | 194 | ||||
| -rw-r--r-- | platform/winrt/app.h | 80 | ||||
| -rw-r--r-- | platform/winrt/gl_context_egl.cpp | 64 | ||||
| -rw-r--r-- | platform/winrt/gl_context_egl.h | 11 | ||||
| -rw-r--r-- | platform/winrt/os_winrt.cpp | 235 | ||||
| -rw-r--r-- | platform/winrt/os_winrt.h | 70 | ||||
| -rw-r--r-- | platform/winrt/thread_winrt.cpp | 17 | ||||
| -rw-r--r-- | platform/winrt/thread_winrt.h | 11 |
8 files changed, 293 insertions, 389 deletions
diff --git a/platform/winrt/app.cpp b/platform/winrt/app.cpp index 45a3f68d4..c917c780d 100644 --- a/platform/winrt/app.cpp +++ b/platform/winrt/app.cpp @@ -32,9 +32,9 @@ #include "app.h" -#include "main/main.h" #include "core/os/dir_access.h" #include "core/os/file_access.h" +#include "main/main.h" using namespace Windows::ApplicationModel::Core; using namespace Windows::ApplicationModel::Activation; @@ -48,113 +48,101 @@ using namespace Platform; using namespace $ext_safeprojectname$; // Helper to convert a length in device-independent pixels (DIPs) to a length in physical pixels. -inline float ConvertDipsToPixels(float dips, float dpi) -{ - static const float dipsPerInch = 96.0f; - return floor(dips * dpi / dipsPerInch + 0.5f); // Round to nearest integer. +inline float ConvertDipsToPixels(float dips, float dpi) { + static const float dipsPerInch = 96.0f; + return floor(dips * dpi / dipsPerInch + 0.5f); // Round to nearest integer. } // Implementation of the IFrameworkViewSource interface, necessary to run our app. -ref class HelloTriangleApplicationSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource -{ +ref class HelloTriangleApplicationSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource { public: - virtual Windows::ApplicationModel::Core::IFrameworkView^ CreateView() - { - return ref new App(); - } + virtual Windows::ApplicationModel::Core::IFrameworkView ^ CreateView() { + return ref new App(); + } }; // The main function creates an IFrameworkViewSource for our app, and runs the app. -[Platform::MTAThread] -int main(Platform::Array<Platform::String^>^) -{ - auto helloTriangleApplicationSource = ref new HelloTriangleApplicationSource(); - CoreApplication::Run(helloTriangleApplicationSource); - return 0; +[Platform::MTAThread] int main(Platform::Array<Platform::String ^> ^) { + auto helloTriangleApplicationSource = ref new HelloTriangleApplicationSource(); + CoreApplication::Run(helloTriangleApplicationSource); + return 0; } -App::App() : - mWindowClosed(false), - mWindowVisible(true), - mWindowWidth(0), - mWindowHeight(0), - mEglDisplay(EGL_NO_DISPLAY), - mEglContext(EGL_NO_CONTEXT), - mEglSurface(EGL_NO_SURFACE) -{ +App::App() + : mWindowClosed(false), + mWindowVisible(true), + mWindowWidth(0), + mWindowHeight(0), + mEglDisplay(EGL_NO_DISPLAY), + mEglContext(EGL_NO_CONTEXT), + mEglSurface(EGL_NO_SURFACE) { } // The first method called when the IFrameworkView is being created. -void App::Initialize(CoreApplicationView^ applicationView) -{ - // Register event handlers for app lifecycle. This example includes Activated, so that we - // can make the CoreWindow active and start rendering on the window. - applicationView->Activated += - ref new TypedEventHandler<CoreApplicationView^, IActivatedEventArgs^>(this, &App::OnActivated); +void App::Initialize(CoreApplicationView ^ applicationView) { + // Register event handlers for app lifecycle. This example includes Activated, so that we + // can make the CoreWindow active and start rendering on the window. + applicationView->Activated += + ref new TypedEventHandler<CoreApplicationView ^, IActivatedEventArgs ^>(this, &App::OnActivated); - // Logic for other event handlers could go here. - // Information about the Suspending and Resuming event handlers can be found here: - // http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh994930.aspx + // Logic for other event handlers could go here. + // Information about the Suspending and Resuming event handlers can be found here: + // http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh994930.aspx os = new OSWinrt; } // Called when the CoreWindow object is created (or re-created). -void App::SetWindow(CoreWindow^ p_window) -{ +void App::SetWindow(CoreWindow ^ p_window) { window = p_window; - window->VisibilityChanged += - ref new TypedEventHandler<CoreWindow^, VisibilityChangedEventArgs^>(this, &App::OnVisibilityChanged); + window->VisibilityChanged += + ref new TypedEventHandler<CoreWindow ^, VisibilityChangedEventArgs ^>(this, &App::OnVisibilityChanged); - window->Closed += - ref new TypedEventHandler<CoreWindow^, CoreWindowEventArgs^>(this, &App::OnWindowClosed); + window->Closed += + ref new TypedEventHandler<CoreWindow ^, CoreWindowEventArgs ^>(this, &App::OnWindowClosed); - window->SizeChanged += - ref new TypedEventHandler<CoreWindow^, WindowSizeChangedEventArgs^>(this, &App::OnWindowSizeChanged); + window->SizeChanged += + ref new TypedEventHandler<CoreWindow ^, WindowSizeChangedEventArgs ^>(this, &App::OnWindowSizeChanged); #if !(WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) - // Disable all pointer visual feedback for better performance when touching. - // This is not supported on Windows Phone applications. - auto pointerVisualizationSettings = PointerVisualizationSettings::GetForCurrentView(); - pointerVisualizationSettings->IsContactFeedbackEnabled = false; - pointerVisualizationSettings->IsBarrelButtonFeedbackEnabled = false; + // Disable all pointer visual feedback for better performance when touching. + // This is not supported on Windows Phone applications. + auto pointerVisualizationSettings = PointerVisualizationSettings::GetForCurrentView(); + pointerVisualizationSettings->IsContactFeedbackEnabled = false; + pointerVisualizationSettings->IsBarrelButtonFeedbackEnabled = false; #endif - window->PointerPressed += - ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &App::OnPointerPressed); + ref new TypedEventHandler<CoreWindow ^, PointerEventArgs ^>(this, &App::OnPointerPressed); window->PointerMoved += - ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &App::OnPointerMoved); + ref new TypedEventHandler<CoreWindow ^, PointerEventArgs ^>(this, &App::OnPointerMoved); window->PointerReleased += - ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &App::OnPointerReleased); + ref new TypedEventHandler<CoreWindow ^, PointerEventArgs ^>(this, &App::OnPointerReleased); //window->PointerWheelChanged += // ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &App::OnPointerWheelChanged); - - - char* args[] = {"-path", "game", NULL}; + char *args[] = { "-path", "game", NULL }; Main::setup("winrt", 2, args, false); // The CoreWindow has been created, so EGL can be initialized. - ContextEGL* context = memnew(ContextEGL(window)); + ContextEGL *context = memnew(ContextEGL(window)); os->set_gl_context(context); UpdateWindowSize(Size(window->Bounds.Width, window->Bounds.Height)); Main::setup2(); } -static int _get_button(Windows::UI::Input::PointerPoint ^pt) { +static int _get_button(Windows::UI::Input::PointerPoint ^ pt) { using namespace Windows::UI::Input; #if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP return BUTTON_LEFT; #else - switch (pt->Properties->PointerUpdateKind) - { + switch (pt->Properties->PointerUpdateKind) { case PointerUpdateKind::LeftButtonPressed: case PointerUpdateKind::LeftButtonReleased: return BUTTON_LEFT; @@ -183,7 +171,7 @@ static int _get_button(Windows::UI::Input::PointerPoint ^pt) { return 0; }; -static bool _is_touch(Windows::UI::Input::PointerPoint ^pointerPoint) { +static bool _is_touch(Windows::UI::Input::PointerPoint ^ pointerPoint) { #if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP return true; #else @@ -198,20 +186,18 @@ static bool _is_touch(Windows::UI::Input::PointerPoint ^pointerPoint) { #endif } - -static Windows::Foundation::Point _get_pixel_position(CoreWindow^ window, Windows::Foundation::Point rawPosition, OS* os) { +static Windows::Foundation::Point _get_pixel_position(CoreWindow ^ window, Windows::Foundation::Point rawPosition, OS *os) { Windows::Foundation::Point outputPosition; - // Compute coordinates normalized from 0..1. - // If the coordinates need to be sized to the SDL window, - // we'll do that after. - #if 1 || WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP +// Compute coordinates normalized from 0..1. +// If the coordinates need to be sized to the SDL window, +// we'll do that after. +#if 1 || WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP outputPosition.X = rawPosition.X / window->Bounds.Width; outputPosition.Y = rawPosition.Y / window->Bounds.Height; - #else - switch (DisplayProperties::CurrentOrientation) - { +#else + switch (DisplayProperties::CurrentOrientation) { case DisplayOrientations::Portrait: outputPosition.X = rawPosition.X / window->Bounds.Width; outputPosition.Y = rawPosition.Y / window->Bounds.Height; @@ -231,7 +217,7 @@ static Windows::Foundation::Point _get_pixel_position(CoreWindow^ window, Window default: break; } - #endif +#endif OS::VideoMode vm = os->get_video_mode(); outputPosition.X *= vm.width; @@ -245,9 +231,9 @@ static int _get_finger(uint32_t p_touch_id) { return p_touch_id % 31; // for now }; -void App::pointer_event(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args, bool p_pressed) { +void App::pointer_event(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args, bool p_pressed) { - Windows::UI::Input::PointerPoint ^point = args->CurrentPoint; + Windows::UI::Input::PointerPoint ^ point = args->CurrentPoint; Windows::Foundation::Point pos = _get_pixel_position(window, point->Position, os); int but = _get_button(point); if (_is_touch(point)) { @@ -285,21 +271,19 @@ void App::pointer_event(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core os->input_event(event); }; - -void App::OnPointerPressed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args) { +void App::OnPointerPressed(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args) { pointer_event(sender, args, true); }; - -void App::OnPointerReleased(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args) { +void App::OnPointerReleased(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args) { pointer_event(sender, args, false); }; -void App::OnPointerMoved(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args) { +void App::OnPointerMoved(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args) { - Windows::UI::Input::PointerPoint ^point = args->CurrentPoint; + Windows::UI::Input::PointerPoint ^ point = args->CurrentPoint; Windows::Foundation::Point pos = _get_pixel_position(window, point->Position, os); if (_is_touch(point)) { @@ -330,79 +314,69 @@ void App::OnPointerMoved(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Cor event.mouse_motion.relative_y = pos.Y - last_touch_y[31]; os->input_event(event); - }; - // Initializes scene resources -void App::Load(Platform::String^ entryPoint) -{ +void App::Load(Platform::String ^ entryPoint) { //char* args[] = {"-test", "render", NULL}; //Main::setup("winrt", 2, args); } // This method is called after the window becomes active. -void App::Run() -{ +void App::Run() { if (Main::start()) os->run(); } // Terminate events do not cause Uninitialize to be called. It will be called if your IFrameworkView // class is torn down while the app is in the foreground. -void App::Uninitialize() -{ +void App::Uninitialize() { Main::cleanup(); delete os; } // Application lifecycle event handler. -void App::OnActivated(CoreApplicationView^ applicationView, IActivatedEventArgs^ args) -{ - // Run() won't start until the CoreWindow is activated. - CoreWindow::GetForCurrentThread()->Activate(); +void App::OnActivated(CoreApplicationView ^ applicationView, IActivatedEventArgs ^ args) { + // Run() won't start until the CoreWindow is activated. + CoreWindow::GetForCurrentThread()->Activate(); } // Window event handlers. -void App::OnVisibilityChanged(CoreWindow^ sender, VisibilityChangedEventArgs^ args) -{ - mWindowVisible = args->Visible; +void App::OnVisibilityChanged(CoreWindow ^ sender, VisibilityChangedEventArgs ^ args) { + mWindowVisible = args->Visible; } -void App::OnWindowClosed(CoreWindow^ sender, CoreWindowEventArgs^ args) -{ - mWindowClosed = true; +void App::OnWindowClosed(CoreWindow ^ sender, CoreWindowEventArgs ^ args) { + mWindowClosed = true; } -void App::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEventArgs^ args) -{ +void App::OnWindowSizeChanged(CoreWindow ^ sender, WindowSizeChangedEventArgs ^ args) { #if (WINAPI_FAMILY == WINAPI_FAMILY_PC_APP) - // On Windows 8.1, apps are resized when they are snapped alongside other apps, or when the device is rotated. - // The default framebuffer will be automatically resized when either of these occur. - // In particular, on a 90 degree rotation, the default framebuffer's width and height will switch. - UpdateWindowSize(args->Size); + // On Windows 8.1, apps are resized when they are snapped alongside other apps, or when the device is rotated. + // The default framebuffer will be automatically resized when either of these occur. + // In particular, on a 90 degree rotation, the default framebuffer's width and height will switch. + UpdateWindowSize(args->Size); #else if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) - // On Windows Phone 8.1, the window size changes when the device is rotated. - // The default framebuffer will not be automatically resized when this occurs. - // It is therefore up to the app to handle rotation-specific logic in its rendering code. + // On Windows Phone 8.1, the window size changes when the device is rotated. + // The default framebuffer will not be automatically resized when this occurs. + // It is therefore up to the app to handle rotation-specific logic in its rendering code. //os->screen_size_changed(); UpdateWindowSize(args->Size); #endif } -void App::UpdateWindowSize(Size size) -{ +void App::UpdateWindowSize(Size size) { float dpi; #if (WINAPI_FAMILY == WINAPI_FAMILY_PC_APP) - DisplayInformation^ currentDisplayInformation = DisplayInformation::GetForCurrentView(); + DisplayInformation ^ currentDisplayInformation = DisplayInformation::GetForCurrentView(); dpi = currentDisplayInformation->LogicalDpi; #else if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) dpi = DisplayProperties::LogicalDpi; #endif Size pixelSize(ConvertDipsToPixels(size.Width, dpi), ConvertDipsToPixels(size.Height, dpi)); - mWindowWidth = static_cast<GLsizei>(pixelSize.Width); - mWindowHeight = static_cast<GLsizei>(pixelSize.Height); + mWindowWidth = static_cast<GLsizei>(pixelSize.Width); + mWindowHeight = static_cast<GLsizei>(pixelSize.Height); OS::VideoMode vm; vm.width = mWindowWidth; diff --git a/platform/winrt/app.h b/platform/winrt/app.h index 25b0d524a..7e13bd6fe 100644 --- a/platform/winrt/app.h +++ b/platform/winrt/app.h @@ -4,58 +4,54 @@ #include <wrl.h> -#include "os_winrt.h" #include "GLES2/gl2.h" +#include "os_winrt.h" -namespace $ext_safeprojectname$ -{ - ref class App sealed : public Windows::ApplicationModel::Core::IFrameworkView - { - public: - App(); - - // IFrameworkView Methods. - virtual void Initialize(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView); - virtual void SetWindow(Windows::UI::Core::CoreWindow^ window); - virtual void Load(Platform::String^ entryPoint); - virtual void Run(); - virtual void Uninitialize(); - - private: - void RecreateRenderer(); +namespace $ext_safeprojectname$ { +ref class App sealed : public Windows::ApplicationModel::Core::IFrameworkView { +public: + App(); - // Application lifecycle event handlers. - void OnActivated(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView, Windows::ApplicationModel::Activation::IActivatedEventArgs^ args); + // IFrameworkView Methods. + virtual void Initialize(Windows::ApplicationModel::Core::CoreApplicationView ^ applicationView); + virtual void SetWindow(Windows::UI::Core::CoreWindow ^ window); + virtual void Load(Platform::String ^ entryPoint); + virtual void Run(); + virtual void Uninitialize(); - // Window event handlers. - void OnWindowSizeChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ 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); +private: + void RecreateRenderer(); - void pointer_event(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args, bool p_pressed); - 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 OnPointerMoved(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args); + // Application lifecycle event handlers. + void OnActivated(Windows::ApplicationModel::Core::CoreApplicationView ^ applicationView, Windows::ApplicationModel::Activation::IActivatedEventArgs ^ args); + // Window event handlers. + void OnWindowSizeChanged(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::WindowSizeChangedEventArgs ^ 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 UpdateWindowSize(Windows::Foundation::Size size); - void InitializeEGL(Windows::UI::Core::CoreWindow^ window); - void CleanupEGL(); + void pointer_event(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args, bool p_pressed); + 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 OnPointerMoved(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::PointerEventArgs ^ args); - bool mWindowClosed; - bool mWindowVisible; - GLsizei mWindowWidth; - GLsizei mWindowHeight; + void UpdateWindowSize(Windows::Foundation::Size size); + void InitializeEGL(Windows::UI::Core::CoreWindow ^ window); + void CleanupEGL(); - EGLDisplay mEglDisplay; - EGLContext mEglContext; - EGLSurface mEglSurface; + bool mWindowClosed; + bool mWindowVisible; + GLsizei mWindowWidth; + GLsizei mWindowHeight; - CoreWindow^ window; - OSWinrt* os; + EGLDisplay mEglDisplay; + EGLContext mEglContext; + EGLSurface mEglSurface; - int last_touch_x[32]; // 20 fingers, index 31 reserved for the mouse - int last_touch_y[32]; - }; + CoreWindow ^ window; + OSWinrt *os; + int last_touch_x[32]; // 20 fingers, index 31 reserved for the mouse + int last_touch_y[32]; +}; } diff --git a/platform/winrt/gl_context_egl.cpp b/platform/winrt/gl_context_egl.cpp index f3f6e0e61..a6e04edc5 100644 --- a/platform/winrt/gl_context_egl.cpp +++ b/platform/winrt/gl_context_egl.cpp @@ -62,8 +62,7 @@ void ContextEGL::reset() { void ContextEGL::swap_buffers() { - if (eglSwapBuffers(mEglDisplay, mEglSurface) != EGL_TRUE) - { + if (eglSwapBuffers(mEglDisplay, mEglSurface) != EGL_TRUE) { cleanup(); window = CoreWindow::GetForCurrentThread(); @@ -102,56 +101,48 @@ Error ContextEGL::initialize() { try { const EGLint displayAttributes[] = - { - EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, - EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE, 9, - EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE, 3, - EGL_NONE, - }; + { + EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, + EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE, 9, + EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE, 3, + EGL_NONE, + }; PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT = reinterpret_cast<PFNEGLGETPLATFORMDISPLAYEXTPROC>(eglGetProcAddress("eglGetPlatformDisplayEXT")); - if (!eglGetPlatformDisplayEXT) - { + if (!eglGetPlatformDisplayEXT) { throw Exception::CreateException(E_FAIL, L"Failed to get function eglGetPlatformDisplayEXT"); } display = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, EGL_DEFAULT_DISPLAY, displayAttributes); - if (display == EGL_NO_DISPLAY) - { + if (display == EGL_NO_DISPLAY) { throw Exception::CreateException(E_FAIL, L"Failed to get default EGL display"); } - if (eglInitialize(display, &majorVersion, &minorVersion) == EGL_FALSE) - { + if (eglInitialize(display, &majorVersion, &minorVersion) == EGL_FALSE) { throw Exception::CreateException(E_FAIL, L"Failed to initialize EGL"); } - if (eglGetConfigs(display, NULL, 0, &numConfigs) == EGL_FALSE) - { + if (eglGetConfigs(display, NULL, 0, &numConfigs) == EGL_FALSE) { throw Exception::CreateException(E_FAIL, L"Failed to get EGLConfig count"); } - if (eglChooseConfig(display, configAttribList, &config, 1, &numConfigs) == EGL_FALSE) - { + if (eglChooseConfig(display, configAttribList, &config, 1, &numConfigs) == EGL_FALSE) { throw Exception::CreateException(E_FAIL, L"Failed to choose first EGLConfig count"); } - surface = eglCreateWindowSurface(display, config, reinterpret_cast<IInspectable*>(window), surfaceAttribList); - if (surface == EGL_NO_SURFACE) - { + surface = eglCreateWindowSurface(display, config, reinterpret_cast<IInspectable *>(window), surfaceAttribList); + if (surface == EGL_NO_SURFACE) { throw Exception::CreateException(E_FAIL, L"Failed to create EGL fullscreen surface"); } context = eglCreateContext(display, config, EGL_NO_CONTEXT, contextAttribs); - if (context == EGL_NO_CONTEXT) - { + if (context == EGL_NO_CONTEXT) { throw Exception::CreateException(E_FAIL, L"Failed to create EGL context"); } - if (eglMakeCurrent(display, surface, surface, context) == EGL_FALSE) - { + if (eglMakeCurrent(display, surface, surface, context) == EGL_FALSE) { throw Exception::CreateException(E_FAIL, L"Failed to make fullscreen EGLSurface current"); } } catch (...) { @@ -162,38 +153,34 @@ Error ContextEGL::initialize() { mEglSurface = surface; mEglContext = context; - eglQuerySurface(display,surface,EGL_WIDTH,&width); - eglQuerySurface(display,surface,EGL_HEIGHT,&height); + eglQuerySurface(display, surface, EGL_WIDTH, &width); + eglQuerySurface(display, surface, EGL_HEIGHT, &height); return OK; }; void ContextEGL::cleanup() { - if (mEglDisplay != EGL_NO_DISPLAY && mEglSurface != EGL_NO_SURFACE) - { + if (mEglDisplay != EGL_NO_DISPLAY && mEglSurface != EGL_NO_SURFACE) { eglDestroySurface(mEglDisplay, mEglSurface); mEglSurface = EGL_NO_SURFACE; } - if (mEglDisplay != EGL_NO_DISPLAY && mEglContext != EGL_NO_CONTEXT) - { + if (mEglDisplay != EGL_NO_DISPLAY && mEglContext != EGL_NO_CONTEXT) { eglDestroyContext(mEglDisplay, mEglContext); mEglContext = EGL_NO_CONTEXT; } - if (mEglDisplay != EGL_NO_DISPLAY) - { + if (mEglDisplay != EGL_NO_DISPLAY) { eglTerminate(mEglDisplay); mEglDisplay = EGL_NO_DISPLAY; } }; -ContextEGL::ContextEGL(CoreWindow^ p_window) : - mEglDisplay(EGL_NO_DISPLAY), - mEglContext(EGL_NO_CONTEXT), - mEglSurface(EGL_NO_SURFACE) - { +ContextEGL::ContextEGL(CoreWindow ^ p_window) + : mEglDisplay(EGL_NO_DISPLAY), + mEglContext(EGL_NO_CONTEXT), + mEglSurface(EGL_NO_SURFACE) { window = p_window; }; @@ -202,4 +189,3 @@ ContextEGL::~ContextEGL() { cleanup(); }; - diff --git a/platform/winrt/gl_context_egl.h b/platform/winrt/gl_context_egl.h index 0eaa7329c..091733aed 100644 --- a/platform/winrt/gl_context_egl.h +++ b/platform/winrt/gl_context_egl.h @@ -31,16 +31,16 @@ #include <wrl.h> -#include "os/os.h" #include "EGL/egl.h" -#include "error_list.h" #include "drivers/gl_context/context_gl.h" +#include "error_list.h" +#include "os/os.h" using namespace Windows::UI::Core; class ContextEGL : public ContextGL { - CoreWindow^ window; + CoreWindow ^ window; EGLDisplay mEglDisplay; EGLContext mEglContext; @@ -50,7 +50,6 @@ class ContextEGL : public ContextGL { EGLint height; public: - virtual void release_current(); virtual void make_current(); @@ -64,10 +63,8 @@ public: void cleanup(); - ContextEGL(CoreWindow^ p_window); + ContextEGL(CoreWindow ^ p_window); ~ContextEGL(); - }; #endif - diff --git a/platform/winrt/os_winrt.cpp b/platform/winrt/os_winrt.cpp index 35eb1bb45..e14b0f074 100644 --- a/platform/winrt/os_winrt.cpp +++ b/platform/winrt/os_winrt.cpp @@ -26,25 +26,24 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "drivers/gles2/rasterizer_gles2.h" #include "os_winrt.h" +#include "drivers/gles2/rasterizer_gles2.h" #include "drivers/unix/memory_pool_static_malloc.h" #include "os/memory_pool_dynamic_static.h" #include "thread_winrt.h" //#include "drivers/windows/semaphore_windows.h" +#include "drivers/windows/dir_access_windows.h" +#include "drivers/windows/file_access_windows.h" #include "drivers/windows/mutex_windows.h" #include "main/main.h" -#include "drivers/windows/file_access_windows.h" -#include "drivers/windows/dir_access_windows.h" - -#include "servers/visual/visual_server_raster.h" #include "servers/audio/audio_server_sw.h" +#include "servers/visual/visual_server_raster.h" #include "servers/visual/visual_server_wrap_mt.h" -#include "os/memory_pool_dynamic_prealloc.h" #include "globals.h" #include "io/marshalls.h" +#include "os/memory_pool_dynamic_prealloc.h" #include <wrl.h> @@ -56,12 +55,11 @@ using namespace Windows::Foundation; using namespace Windows::Graphics::Display; using namespace Microsoft::WRL; - int OSWinrt::get_video_driver_count() const { return 1; } -const char * OSWinrt::get_video_driver_name(int p_driver) const { +const char *OSWinrt::get_video_driver_name(int p_driver) const { return "GLES2"; } @@ -75,20 +73,19 @@ int OSWinrt::get_audio_driver_count() const { return AudioDriverManagerSW::get_driver_count(); } -const char * OSWinrt::get_audio_driver_name(int p_driver) const { +const char *OSWinrt::get_audio_driver_name(int p_driver) const { - AudioDriverSW* driver = AudioDriverManagerSW::get_driver(p_driver); - ERR_FAIL_COND_V( !driver, "" ); + AudioDriverSW *driver = AudioDriverManagerSW::get_driver(p_driver); + ERR_FAIL_COND_V(!driver, ""); return AudioDriverManagerSW::get_driver(p_driver)->get_name(); } -static MemoryPoolStatic *mempool_static=NULL; -static MemoryPoolDynamic *mempool_dynamic=NULL; +static MemoryPoolStatic *mempool_static = NULL; +static MemoryPoolDynamic *mempool_dynamic = NULL; void OSWinrt::initialize_core() { - - last_button_state=0; + last_button_state = 0; //RedirectIOToConsole(); @@ -109,23 +106,23 @@ void OSWinrt::initialize_core() { mempool_static = new MemoryPoolStaticMalloc; #if 1 - mempool_dynamic = memnew( MemoryPoolDynamicStatic ); + mempool_dynamic = memnew(MemoryPoolDynamicStatic); #else -#define DYNPOOL_SIZE 4*1024*1024 - void * buffer = malloc( DYNPOOL_SIZE ); - mempool_dynamic = memnew( MemoryPoolDynamicPrealloc(buffer,DYNPOOL_SIZE) ); +#define DYNPOOL_SIZE 4 * 1024 * 1024 + void *buffer = malloc(DYNPOOL_SIZE); + mempool_dynamic = memnew(MemoryPoolDynamicPrealloc(buffer, DYNPOOL_SIZE)); #endif - // We need to know how often the clock is updated - if( !QueryPerformanceFrequency((LARGE_INTEGER *)&ticks_per_second) ) + // We need to know how often the clock is updated + if (!QueryPerformanceFrequency((LARGE_INTEGER *)&ticks_per_second)) ticks_per_second = 1000; // If timeAtGameStart is 0 then we get the time since // the start of the computer when we call GetGameTime() ticks_start = 0; ticks_start = get_ticks_usec(); - cursor_shape=CURSOR_ARROW; + cursor_shape = CURSOR_ARROW; } bool OSWinrt::can_draw() const { @@ -133,8 +130,7 @@ bool OSWinrt::can_draw() const { return !minimized; }; - -void OSWinrt::set_gl_context(ContextEGL* p_context) { +void OSWinrt::set_gl_context(ContextEGL *p_context) { gl_context = p_context; }; @@ -144,10 +140,10 @@ void OSWinrt::screen_size_changed() { gl_context->reset(); }; -void OSWinrt::initialize(const VideoMode& p_desired,int p_video_driver,int p_audio_driver) { +void OSWinrt::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) { - main_loop=NULL; - outside=true; + main_loop = NULL; + outside = true; gl_context->initialize(); VideoMode vm; @@ -159,47 +155,46 @@ void OSWinrt::initialize(const VideoMode& p_desired,int p_video_driver,int p_aud set_video_mode(vm); gl_context->make_current(); - rasterizer = memnew( RasterizerGLES2 ); + rasterizer = memnew(RasterizerGLES2); - visual_server = memnew( VisualServerRaster(rasterizer) ); - if (get_render_thread_mode()!=RENDER_THREAD_UNSAFE) { + visual_server = memnew(VisualServerRaster(rasterizer)); + if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) { - visual_server =memnew(VisualServerWrapMT(visual_server,get_render_thread_mode()==RENDER_SEPARATE_THREAD)); + visual_server = memnew(VisualServerWrapMT(visual_server, get_render_thread_mode() == RENDER_SEPARATE_THREAD)); } // - physics_server = memnew( PhysicsServerSW ); + physics_server = memnew(PhysicsServerSW); physics_server->init(); - physics_2d_server = memnew( Physics2DServerSW ); + physics_2d_server = memnew(Physics2DServerSW); physics_2d_server->init(); visual_server->init(); - input = memnew( InputDefault ); + input = memnew(InputDefault); AudioDriverManagerSW::get_driver(p_audio_driver)->set_singleton(); - if (AudioDriverManagerSW::get_driver(p_audio_driver)->init()!=OK) { + if (AudioDriverManagerSW::get_driver(p_audio_driver)->init() != OK) { ERR_PRINT("Initializing audio failed."); } - sample_manager = memnew( SampleManagerMallocSW ); - audio_server = memnew( AudioServerSW(sample_manager) ); + sample_manager = memnew(SampleManagerMallocSW); + audio_server = memnew(AudioServerSW(sample_manager)); audio_server->init(); - spatial_sound_server = memnew( SpatialSoundServerSW ); + spatial_sound_server = memnew(SpatialSoundServerSW); spatial_sound_server->init(); - spatial_sound_2d_server = memnew( SpatialSound2DServerSW ); + spatial_sound_2d_server = memnew(SpatialSound2DServerSW); spatial_sound_2d_server->init(); - _ensure_data_dir(); } -void OSWinrt::set_clipboard(const String& p_text) { +void OSWinrt::set_clipboard(const String &p_text){ /* if (!OpenClipboard(hWnd)) { @@ -281,7 +276,6 @@ String OSWinrt::get_clipboard() const { return ""; }; - void OSWinrt::input_event(InputEvent &p_event) { p_event.ID = ++last_id; input->parse_input_event(p_event); @@ -291,21 +285,21 @@ void OSWinrt::delete_main_loop() { if (main_loop) memdelete(main_loop); - main_loop=NULL; + main_loop = NULL; } -void OSWinrt::set_main_loop( MainLoop * p_main_loop ) { +void OSWinrt::set_main_loop(MainLoop *p_main_loop) { input->set_main_loop(p_main_loop); - main_loop=p_main_loop; + main_loop = p_main_loop; } void OSWinrt::finalize() { - if(main_loop) + if (main_loop) memdelete(main_loop); - main_loop=NULL; + main_loop = NULL; visual_server->finish(); memdelete(visual_server); @@ -322,8 +316,8 @@ void OSWinrt::finalize() { memdelete(spatial_sound_2d_server); //if (debugger_connection_console) { -// memdelete(debugger_connection_console); -//} + // memdelete(debugger_connection_console); + //} memdelete(sample_manager); @@ -337,62 +331,56 @@ void OSWinrt::finalize() { physics_2d_server->finish(); memdelete(physics_2d_server); - } void OSWinrt::finalize_core() { if (mempool_dynamic) - memdelete( mempool_dynamic ); + memdelete(mempool_dynamic); delete mempool_static; - } -void OSWinrt::vprint(const char* p_format, va_list p_list, bool p_stderr) { +void OSWinrt::vprint(const char *p_format, va_list p_list, bool p_stderr) { - char buf[16384+1]; - int len = vsnprintf(buf,16384,p_format,p_list); - if (len<=0) + char buf[16384 + 1]; + int len = vsnprintf(buf, 16384, p_format, p_list); + if (len <= 0) return; - buf[len]=0; - + buf[len] = 0; - int wlen = MultiByteToWideChar(CP_UTF8,0,buf,len,NULL,0); - if (wlen<0) + int wlen = MultiByteToWideChar(CP_UTF8, 0, buf, len, NULL, 0); + if (wlen < 0) return; - wchar_t *wbuf = (wchar_t*)malloc((len+1)*sizeof(wchar_t)); - MultiByteToWideChar(CP_UTF8,0,buf,len,wbuf,wlen); - wbuf[wlen]=0; + wchar_t *wbuf = (wchar_t *)malloc((len + 1) * sizeof(wchar_t)); + MultiByteToWideChar(CP_UTF8, 0, buf, len, wbuf, wlen); + wbuf[wlen] = 0; if (p_stderr) - fwprintf(stderr,L"%s",wbuf); + fwprintf(stderr, L"%s", wbuf); else - wprintf(L"%s",wbuf); + wprintf(L"%s", wbuf); #ifdef STDOUT_FILE - //vwfprintf(stdo,p_format,p_list); +//vwfprintf(stdo,p_format,p_list); #endif free(wbuf); fflush(stdout); }; -void OSWinrt::alert(const String& p_alert,const String& p_title) { +void OSWinrt::alert(const String &p_alert, const String &p_title) { - print_line("ALERT: "+p_alert); + print_line("ALERT: " + p_alert); } void OSWinrt::set_mouse_mode(MouseMode p_mode) { - } -OSWinrt::MouseMode OSWinrt::get_mouse_mode() const{ +OSWinrt::MouseMode OSWinrt::get_mouse_mode() const { return mouse_mode; } - - Point2 OSWinrt::get_mouse_pos() const { return Point2(old_x, old_y); @@ -403,11 +391,10 @@ int OSWinrt::get_mouse_button_state() const { return last_button_state; } -void OSWinrt::set_window_title(const String& p_title) { - +void OSWinrt::set_window_title(const String &p_title) { } -void OSWinrt::set_video_mode(const VideoMode& p_video_mode,int p_screen) { +void OSWinrt::set_video_mode(const VideoMode &p_video_mode, int p_screen) { video_mode = p_video_mode; } @@ -415,20 +402,18 @@ OS::VideoMode OSWinrt::get_video_mode(int p_screen) const { return video_mode; } -void OSWinrt::get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen) const { - - +void OSWinrt::get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen) const { } -void OSWinrt::print_error(const char* p_function, const char* p_file, int p_line, const char* p_code, const char* p_rationale, ErrorType p_type) { +void OSWinrt::print_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, ErrorType p_type) { - const char* err_details; + const char *err_details; if (p_rationale && p_rationale[0]) err_details = p_rationale; else err_details = p_code; - switch(p_type) { + switch (p_type) { case ERR_ERROR: print("ERROR: %s: %s\n", p_function, err_details); print(" At: %s:%i\n", p_file, p_line); @@ -444,7 +429,6 @@ void OSWinrt::print_error(const char* p_function, const char* p_file, int p_line } } - String OSWinrt::get_name() { return "WinRT"; @@ -459,11 +443,11 @@ OS::Date OSWinrt::get_date(bool utc) const { GetLocalTime(&systemtime); Date date; - date.day=systemtime.wDay; - date.month=Month(systemtime.wMonth); - date.weekday=Weekday(systemtime.wDayOfWeek); - date.year=systemtime.wYear; - date.dst=false; + date.day = systemtime.wDay; + date.month = Month(systemtime.wMonth); + date.weekday = Weekday(systemtime.wDayOfWeek); + date.year = systemtime.wYear; + date.dst = false; return date; } OS::Time OSWinrt::get_time(bool utc) const { @@ -475,9 +459,9 @@ OS::Time OSWinrt::get_time(bool utc) const { GetLocalTime(&systemtime); Time time; - time.hour=systemtime.wHour; - time.min=systemtime.wMinute; - time.sec=systemtime.wSecond; + time.hour = systemtime.wHour; + time.min = systemtime.wMinute; + time.sec = systemtime.wSecond; return time; } @@ -517,7 +501,7 @@ uint64_t OSWinrt::get_unix_time() const { FILETIME fep; SystemTimeToFileTime(&ep, &fep); - return (*(uint64_t*)&ft - *(uint64_t*)&fep) / 10000000; + return (*(uint64_t *)&ft - *(uint64_t *)&fep) / 10000000; }; void OSWinrt::delay_usec(uint32_t p_usec) const { @@ -526,7 +510,6 @@ void OSWinrt::delay_usec(uint32_t p_usec) const { // no Sleep() WaitForSingleObjectEx(GetCurrentThread(), msec, false); - } uint64_t OSWinrt::get_ticks_usec() const { @@ -542,26 +525,23 @@ uint64_t OSWinrt::get_ticks_usec() const { return time; } - void OSWinrt::process_events() { - } void OSWinrt::set_cursor_shape(CursorShape p_shape) { - } -Error OSWinrt::execute(const String& p_path, const List<String>& p_arguments,bool p_blocking,ProcessID *r_child_id,String* r_pipe,int *r_exitcode) { +Error OSWinrt::execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id, String *r_pipe, int *r_exitcode) { return FAILED; }; -Error OSWinrt::kill(const ProcessID& p_pid) { +Error OSWinrt::kill(const ProcessID &p_pid) { return FAILED; }; -Error OSWinrt::set_cwd(const String& p_cwd) { +Error OSWinrt::set_cwd(const String &p_cwd) { return FAILED; } @@ -571,17 +551,15 @@ String OSWinrt::get_executable_path() const { return ""; } -void OSWinrt::set_icon(const Image& p_icon) { - +void OSWinrt::set_icon(const Image &p_icon) { } - -bool OSWinrt::has_environment(const String& p_var) const { +bool OSWinrt::has_environment(const String &p_var) const { return false; }; -String OSWinrt::get_environment(const String& p_var) const { +String OSWinrt::get_environment(const String &p_var) const { return ""; }; @@ -591,9 +569,7 @@ String OSWinrt::get_stdin_string(bool p_block) { return String(); } - void OSWinrt::move_window_to_foreground() { - } Error OSWinrt::shell_open(String p_uri) { @@ -601,13 +577,12 @@ Error OSWinrt::shell_open(String p_uri) { return FAILED; } - String OSWinrt::get_locale() const { #if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP // this should work on phone 8.1, but it doesn't return "en"; #else - Platform::String ^language = Windows::Globalization::Language::CurrentInputMethodLanguageTag; + Platform::String ^ language = Windows::Globalization::Language::CurrentInputMethodLanguageTag; return language->Data(); #endif } @@ -627,7 +602,6 @@ void OSWinrt::swap_buffers() { gl_context->swap_buffers(); } - void OSWinrt::run() { if (!main_loop) @@ -635,56 +609,51 @@ void OSWinrt::run() { main_loop->init(); - uint64_t last_ticks=get_ticks_usec(); + uint64_t last_ticks = get_ticks_usec(); - int frames=0; - uint64_t frame=0; + int frames = 0; + uint64_t frame = 0; while (!force_quit) { CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent); process_events(); // get rid of pending events - if (Main::iteration()==true) + if (Main::iteration() == true) break; }; main_loop->finish(); - } - - MainLoop *OSWinrt::get_main_loop() const { return main_loop; } - String OSWinrt::get_data_dir() const { - Windows::Storage::StorageFolder ^data_folder = Windows::Storage::ApplicationData::Current->LocalFolder; + Windows::Storage::StorageFolder ^ data_folder = Windows::Storage::ApplicationData::Current->LocalFolder; return data_folder->Path->Data(); } - OSWinrt::OSWinrt() { - key_event_pos=0; - force_quit=false; - alt_mem=false; - gr_mem=false; - shift_mem=false; - control_mem=false; - meta_mem=false; + key_event_pos = 0; + force_quit = false; + alt_mem = false; + gr_mem = false; + shift_mem = false; + control_mem = false; + meta_mem = false; minimized = false; - pressrc=0; - old_invalid=true; - last_id=0; - mouse_mode=MOUSE_MODE_VISIBLE; + pressrc = 0; + old_invalid = true; + last_id = 0; + mouse_mode = MOUSE_MODE_VISIBLE; #ifdef STDOUT_FILE - stdo=fopen("stdout.txt","wb"); + stdo = fopen("stdout.txt", "wb"); #endif gl_context = NULL; @@ -692,12 +661,8 @@ OSWinrt::OSWinrt() { AudioDriverManagerSW::add_driver(&audio_driver); } - -OSWinrt::~OSWinrt() -{ +OSWinrt::~OSWinrt() { #ifdef STDOUT_FILE fclose(stdo); #endif } - - diff --git a/platform/winrt/os_winrt.h b/platform/winrt/os_winrt.h index 99b094988..44ad9d6bc 100644 --- a/platform/winrt/os_winrt.h +++ b/platform/winrt/os_winrt.h @@ -31,16 +31,16 @@ #include "os/input.h" #include "os/os.h" -#include "servers/visual_server.h" -#include "servers/visual/rasterizer.h" #include "servers/physics/physics_server_sw.h" +#include "servers/visual/rasterizer.h" +#include "servers/visual_server.h" +#include "servers/audio/audio_driver_dummy.h" #include "servers/audio/audio_server_sw.h" #include "servers/audio/sample_manager_sw.h" +#include "servers/physics_2d/physics_2d_server_sw.h" #include "servers/spatial_sound/spatial_sound_server_sw.h" #include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h" -#include "servers/physics_2d/physics_2d_server_sw.h" -#include "servers/audio/audio_driver_dummy.h" #include "gl_context_egl.h" @@ -48,9 +48,9 @@ #include <io.h> +#include "main/input_default.h" #include <fcntl.h> #include <stdio.h> -#include "main/input_default.h" /** @author Juan Linietsky <reduzio@gmail.com> @@ -61,32 +61,29 @@ class OSWinrt : public OS { JOYSTICKS_MAX = 8, JOY_AXIS_COUNT = 6, MAX_JOY_AXIS = 32768, // I've no idea - KEY_EVENT_BUFFER_SIZE=512 + KEY_EVENT_BUFFER_SIZE = 512 }; FILE *stdo; - struct KeyEvent { InputModifierState mod_state; UINT uMsg; - WPARAM wParam; - LPARAM lParam; - + WPARAM wParam; + LPARAM lParam; }; KeyEvent key_event_buffer[KEY_EVENT_BUFFER_SIZE]; int key_event_pos; - uint64_t ticks_start; uint64_t ticks_per_second; bool minimized; bool old_invalid; bool outside; - int old_x,old_y; + int old_x, old_y; Point2i center; unsigned int last_id; VisualServer *visual_server; @@ -95,7 +92,7 @@ class OSWinrt : public OS { Physics2DServer *physics_2d_server; int pressrc; - ContextEGL* gl_context; + ContextEGL *gl_context; struct Joystick { @@ -110,7 +107,7 @@ class OSWinrt : public OS { Joystick() { id = -1; attached = false; - for (int i=0; i<JOY_AXIS_COUNT; i++) { + for (int i = 0; i < JOY_AXIS_COUNT; i++) { last_axis[i] = 0; }; @@ -148,24 +145,23 @@ class OSWinrt : public OS { void _post_dpad(DWORD p_dpad, int p_device, bool p_pressed); - void _drag_event(int idx,UINT uMsg, WPARAM wParam, LPARAM lParam); - void _touch_event(int idx, UINT uMsg, WPARAM wParam, LPARAM lParam); - + void _drag_event(int idx, UINT uMsg, WPARAM wParam, LPARAM lParam); + void _touch_event(int idx, UINT uMsg, WPARAM wParam, LPARAM lParam); // functions used by main to initialize/deintialize the OS protected: virtual int get_video_driver_count() const; - virtual const char * get_video_driver_name(int p_driver) const; + virtual const char *get_video_driver_name(int p_driver) const; virtual VideoMode get_default_video_mode() const; virtual int get_audio_driver_count() const; - virtual const char * get_audio_driver_name(int p_driver) const; + virtual const char *get_audio_driver_name(int p_driver) const; virtual void initialize_core(); - virtual void initialize(const VideoMode& p_desired,int p_video_driver,int p_audio_driver); + virtual void initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver); - virtual void set_main_loop( MainLoop * p_main_loop ); + virtual void set_main_loop(MainLoop *p_main_loop); virtual void delete_main_loop(); virtual void finalize(); @@ -178,11 +174,10 @@ protected: void process_key_events(); public: + void print_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, ErrorType p_type); - void print_error(const char* p_function,const char* p_file,int p_line,const char *p_code,const char*p_rationale,ErrorType p_type); - - virtual void vprint(const char *p_format, va_list p_list, bool p_stderr=false); - virtual void alert(const String& p_alert,const String& p_title="ALERT!"); + virtual void vprint(const char *p_format, va_list p_list, bool p_stderr = false); + virtual void alert(const String &p_alert, const String &p_title = "ALERT!"); String get_stdin_string(bool p_block); void set_mouse_mode(MouseMode p_mode); @@ -190,11 +185,11 @@ public: virtual Point2 get_mouse_pos() const; virtual int get_mouse_button_state() const; - virtual void set_window_title(const String& p_title); + virtual void set_window_title(const String &p_title); - virtual void set_video_mode(const VideoMode& p_video_mode,int p_screen=0); - virtual VideoMode get_video_mode(int p_screen=0) const; - virtual void get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen=0) const; + virtual void set_video_mode(const VideoMode &p_video_mode, int p_screen = 0); + virtual VideoMode get_video_mode(int p_screen = 0) const; + virtual void get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen = 0) const; virtual MainLoop *get_main_loop() const; @@ -206,22 +201,22 @@ public: virtual uint64_t get_unix_time() const; virtual bool can_draw() const; - virtual Error set_cwd(const String& p_cwd); + virtual Error set_cwd(const String &p_cwd); virtual void delay_usec(uint32_t p_usec) const; virtual uint64_t get_ticks_usec() const; - virtual Error execute(const String& p_path, const List<String>& p_arguments,bool p_blocking,ProcessID *r_child_id=NULL,String* r_pipe=NULL,int *r_exitcode=NULL); - virtual Error kill(const ProcessID& p_pid); + virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id = NULL, String *r_pipe = NULL, int *r_exitcode = NULL); + virtual Error kill(const ProcessID &p_pid); - virtual bool has_environment(const String& p_var) const; - virtual String get_environment(const String& p_var) const; + virtual bool has_environment(const String &p_var) const; + virtual String get_environment(const String &p_var) const; - virtual void set_clipboard(const String& p_text); + virtual void set_clipboard(const String &p_text); virtual String get_clipboard() const; void set_cursor_shape(CursorShape p_shape); - void set_icon(const Image& p_icon); + void set_icon(const Image &p_icon); virtual String get_executable_path() const; @@ -230,7 +225,7 @@ public: virtual void move_window_to_foreground(); virtual String get_data_dir() const; - void set_gl_context(ContextEGL* p_context); + void set_gl_context(ContextEGL *p_context); void screen_size_changed(); virtual void release_rendering_thread(); @@ -249,7 +244,6 @@ public: OSWinrt(); ~OSWinrt(); - }; #endif diff --git a/platform/winrt/thread_winrt.cpp b/platform/winrt/thread_winrt.cpp index 0386d8c65..ed92a52b2 100644 --- a/platform/winrt/thread_winrt.cpp +++ b/platform/winrt/thread_winrt.cpp @@ -30,10 +30,9 @@ #include "os/memory.h" -Thread* ThreadWinrt::create_func_winrt(ThreadCreateCallback p_callback,void *p_user,const Settings&) { - - ThreadWinrt* thread = memnew(ThreadWinrt); +Thread *ThreadWinrt::create_func_winrt(ThreadCreateCallback p_callback, void *p_user, const Settings &) { + ThreadWinrt *thread = memnew(ThreadWinrt); std::thread new_thread(p_callback, p_user); std::swap(thread->thread, new_thread); @@ -46,27 +45,25 @@ Thread::ID ThreadWinrt::get_thread_ID_func_winrt() { return std::hash<std::thread::id>()(std::this_thread::get_id()); }; -void ThreadWinrt::wait_to_finish_func_winrt(Thread* p_thread) { +void ThreadWinrt::wait_to_finish_func_winrt(Thread *p_thread) { - ThreadWinrt *tp=static_cast<ThreadWinrt*>(p_thread); + ThreadWinrt *tp = static_cast<ThreadWinrt *>(p_thread); tp->thread.join(); }; - Thread::ID ThreadWinrt::get_ID() const { return std::hash<std::thread::id>()(thread.get_id()); }; -void ThreadWinrt::make_default() { +void ThreadWinrt::make_default(){ }; -ThreadWinrt::ThreadWinrt() { +ThreadWinrt::ThreadWinrt(){ }; -ThreadWinrt::~ThreadWinrt() { +ThreadWinrt::~ThreadWinrt(){ }; - diff --git a/platform/winrt/thread_winrt.h b/platform/winrt/thread_winrt.h index 013a8dc7b..d179d63ab 100644 --- a/platform/winrt/thread_winrt.h +++ b/platform/winrt/thread_winrt.h @@ -39,25 +39,20 @@ class ThreadWinrt : public Thread { std::thread thread; - static Thread* create_func_winrt(ThreadCreateCallback p_callback,void *,const Settings&); + static Thread *create_func_winrt(ThreadCreateCallback p_callback, void *, const Settings &); static ID get_thread_ID_func_winrt(); - static void wait_to_finish_func_winrt(Thread* p_thread); + static void wait_to_finish_func_winrt(Thread *p_thread); ThreadWinrt(); -public: - +public: virtual ID get_ID() const; static void make_default(); - ~ThreadWinrt(); - }; - #endif #endif - |
