diff options
author | Juan Linietsky <reduzio@gmail.com> | 2014-10-03 00:10:51 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2014-10-03 00:10:51 -0300 |
commit | b24fe3dd206ce391ec4c5f68d32fc2259f275563 (patch) | |
tree | 5d05b14d21ba1c8a484f9b7f3739a63f42ca082d /platform | |
parent | 870c075ebf67749b21b6cc0c705088bbe273f1bb (diff) |
Huge Amount of BugFix
-=-=-=-=-=-=-=-=-=-=-
-Fixes to Collada Exporter (avoid crash situtions)
-Fixed to Collada Importer (Fixed Animation Optimizer Bugs)
-Fixes to RigidBody/RigidBody2D body_enter/body_exit, was buggy
-Fixed ability for RigidBody/RigidBody2D to get contacts reported and bodyin/out in Kinematic mode.
-Added proper trigger support for 3D Physics shapes
-Changed proper value for Z-Offset in OmniLight
-Fixed spot attenuation bug in SpotLight
-Fixed some 3D and 2D spatial soudn bugs related to distance attenuation.
-Fixed bugs in EventPlayer (channels were muted by default)
-Fix in ButtonGroup (get nodes in group are now returned in order)
-Fixed Linear->SRGB Conversion, previous algo sucked, new algo works OK
-Changed SRGB->Linear conversion to use hardware if supported, improves texture quality a lot
-Fixed options for Y-Fov and X-Fov in camera, should be more intuitive.
-Fixed bugs related to viewports and transparency
Huge Amount of New Stuff:
-=-=-=-=-=-=-=-==-=-=-=-
-Ability to manually advance an AnimationPlayer that is inactive (with advance() function)
-More work in WinRT platform
-Added XY normalmap support, imports on this format by default. Reduces normlmap size and enables much nice compression using LATC
-Added Anisotropic filter support to textures, can be specified on import
-Added support for Non-Square, Isometric and Hexagonal tilemaps in TileMap.
-Added Isometric Dungeon demo.
-Added simple hexagonal map demo.
-Added Truck-Town demo. Shows how most types of joints and vehicles are used. Please somebody make a nicer town, this one is too hardcore.
-Added an Object-Picking API to both RigidBody and Area! (and relevant demo)
Diffstat (limited to 'platform')
-rw-r--r-- | platform/winrt/SCsub | 5 | ||||
-rw-r--r-- | platform/winrt/app.cpp | 162 | ||||
-rw-r--r-- | platform/winrt/app.h | 51 | ||||
-rw-r--r-- | platform/winrt/detect.py | 6 | ||||
-rw-r--r-- | platform/winrt/gl_context_egl.cpp | 151 | ||||
-rw-r--r-- | platform/winrt/gl_context_egl.h | 44 | ||||
-rw-r--r-- | platform/winrt/os_winrt.cpp | 197 | ||||
-rw-r--r-- | platform/winrt/os_winrt.h | 7 |
8 files changed, 464 insertions, 159 deletions
diff --git a/platform/winrt/SCsub b/platform/winrt/SCsub index c83f4fab32..07e2ba81a6 100644 --- a/platform/winrt/SCsub +++ b/platform/winrt/SCsub @@ -3,6 +3,9 @@ Import('env') files = [ 'thread_winrt.cpp', # '#platform/windows/stream_peer_winsock.cpp', + 'gl_context_egl.cpp', + 'app.cpp', + 'os_winrt.cpp', ] -env.Program('#bin/godot_rt.exe', files) +env.Program('#bin/godot_rt', files) diff --git a/platform/winrt/app.cpp b/platform/winrt/app.cpp new file mode 100644 index 0000000000..e3213d574a --- /dev/null +++ b/platform/winrt/app.cpp @@ -0,0 +1,162 @@ +//
+// This file demonstrates how to initialize EGL in a Windows Store app, using ICoreWindow.
+//
+
+#include "app.h"
+
+#include "main/main.h"
+
+using namespace Windows::ApplicationModel::Core;
+using namespace Windows::ApplicationModel::Activation;
+using namespace Windows::UI::Core;
+using namespace Windows::UI::Input;
+using namespace Windows::Foundation;
+using namespace Windows::Graphics::Display;
+using namespace Microsoft::WRL;
+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.
+}
+
+// Implementation of the IFrameworkViewSource interface, necessary to run our app.
+ref class HelloTriangleApplicationSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource
+{
+public:
+ 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;
+}
+
+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);
+
+ // 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^ window)
+{
+ window->VisibilityChanged +=
+ ref new TypedEventHandler<CoreWindow^, VisibilityChangedEventArgs^>(this, &App::OnVisibilityChanged);
+
+ window->Closed +=
+ ref new TypedEventHandler<CoreWindow^, CoreWindowEventArgs^>(this, &App::OnWindowClosed);
+
+ 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;
+#endif
+
+ // The CoreWindow has been created, so EGL can be initialized.
+ ContextEGL* context = memnew(ContextEGL(window));
+ os->set_gl_context(context);
+ UpdateWindowSize(Size(window->Bounds.Width, window->Bounds.Height));
+}
+
+// Initializes scene resources
+void App::Load(Platform::String^ entryPoint)
+{
+ char** args = {NULL};
+ Main::setup("winrt", 0, args);
+}
+
+// This method is called after the window becomes active.
+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()
+{
+ 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();
+}
+
+// Window event handlers.
+void App::OnVisibilityChanged(CoreWindow^ sender, VisibilityChangedEventArgs^ args)
+{
+ mWindowVisible = args->Visible;
+}
+
+void App::OnWindowClosed(CoreWindow^ sender, CoreWindowEventArgs^ args)
+{
+ mWindowClosed = true;
+}
+
+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);
+#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.
+#endif
+}
+
+void App::UpdateWindowSize(Size size)
+{
+ /*
+ DisplayInformation^ currentDisplayInformation = DisplayInformation::GetForCurrentView();
+ Size pixelSize(ConvertDipsToPixels(size.Width, currentDisplayInformation->LogicalDpi), ConvertDipsToPixels(size.Height, currentDisplayInformation->LogicalDpi));
+
+ mWindowWidth = static_cast<GLsizei>(pixelSize.Width);
+ mWindowHeight = static_cast<GLsizei>(pixelSize.Height);
+ */
+}
diff --git a/platform/winrt/app.h b/platform/winrt/app.h new file mode 100644 index 0000000000..a67b936cdf --- /dev/null +++ b/platform/winrt/app.h @@ -0,0 +1,51 @@ +#pragma once
+
+#include <string>
+
+#include <wrl.h>
+
+#include "os_winrt.h"
+#include "GLES2/gl2.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();
+
+ // 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();
+
+ bool mWindowClosed;
+ bool mWindowVisible;
+ GLsizei mWindowWidth;
+ GLsizei mWindowHeight;
+
+ EGLDisplay mEglDisplay;
+ EGLContext mEglContext;
+ EGLSurface mEglSurface;
+
+ OSWinrt* os;
+ };
+
+}
diff --git a/platform/winrt/detect.py b/platform/winrt/detect.py index d09688b71c..00913b0ade 100644 --- a/platform/winrt/detect.py +++ b/platform/winrt/detect.py @@ -57,13 +57,13 @@ def configure(env): env.Append(CCFLAGS=['-g','-pg'])
env.Append(LINKFLAGS=['-pg'])
- env.Append(CCFLAGS=['/Gd','/GR','/nologo', '/ZW', '/EHsc'])
- env.Append(CXXFLAGS=['/TP'])
+ env.Append(CCFLAGS=['/Gd','/GR','/nologo', '/EHsc'])
+ env.Append(CXXFLAGS=['/TP', '/ZW'])
env.Append(CPPFLAGS=['/DMSVC', '/GR', ])
#env.Append(CCFLAGS=['/I'+os.getenv("WindowsSdkDir")+"/Include"])
env.Append(CCFLAGS=['/DWINRT_ENABLED'])
env.Append(CCFLAGS=['/DWINDOWS_ENABLED'])
- env.Append(CCFLAGS=['/DWINAPI_FAMILY=WINAPI_FAMILY_APP'])
+ env.Append(CCFLAGS=['/DWINAPI_FAMILY=WINAPI_FAMILY_APP', '/D_WIN32_WINNT=0x0603', '/DNTDDI_VERSION=0x06030000'])
env.Append(CCFLAGS=['/DRTAUDIO_ENABLED'])
#env.Append(CCFLAGS=['/DWIN32'])
env.Append(CCFLAGS=['/DTYPED_METHOD_BIND'])
diff --git a/platform/winrt/gl_context_egl.cpp b/platform/winrt/gl_context_egl.cpp new file mode 100644 index 0000000000..ca592c5d19 --- /dev/null +++ b/platform/winrt/gl_context_egl.cpp @@ -0,0 +1,151 @@ +#include "gl_context_egl.h" + +using namespace Platform; + +void ContextEGL::release_current() { + + eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, mEglContext); +}; + +void ContextEGL::make_current() { + + eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface, mEglContext); +}; + +int ContextEGL::get_window_width() { + + return width; +}; + +int ContextEGL::get_window_height() { + + return height; +}; + +void ContextEGL::swap_buffers() { + + if (eglSwapBuffers(mEglDisplay, mEglSurface) != EGL_TRUE) + { + cleanup(); + + window = CoreWindow::GetForCurrentThread(); + initialize(); + + // tell rasterizer to reload textures and stuff? + } +}; + +Error ContextEGL::initialize() { + + EGLint configAttribList[] = { + EGL_RED_SIZE, 8, + EGL_GREEN_SIZE, 8, + EGL_BLUE_SIZE, 8, + EGL_ALPHA_SIZE, 8, + EGL_DEPTH_SIZE, 8, + EGL_STENCIL_SIZE, 8, + EGL_SAMPLE_BUFFERS, 0, + EGL_NONE + }; + + EGLint surfaceAttribList[] = { + EGL_NONE, EGL_NONE + }; + + EGLint numConfigs = 0; + EGLint majorVersion = 1; + EGLint minorVersion = 0; + EGLDisplay display = EGL_NO_DISPLAY; + EGLContext context = EGL_NO_CONTEXT; + EGLSurface surface = EGL_NO_SURFACE; + EGLConfig config = nullptr; + EGLint contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE, EGL_NONE }; + + try { + + display = eglGetDisplay(EGL_DEFAULT_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) + { + throw Exception::CreateException(E_FAIL, L"Failed to initialize EGL"); + } + + 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) + { + 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) + { + 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) + { + throw Exception::CreateException(E_FAIL, L"Failed to create EGL context"); + } + + if (eglMakeCurrent(display, surface, surface, context) == EGL_FALSE) + { + throw Exception::CreateException(E_FAIL, L"Failed to make fullscreen EGLSurface current"); + } + } catch (...) { + return FAILED; + }; + + mEglDisplay = display; + mEglSurface = surface; + mEglContext = context; + + 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) + { + eglDestroySurface(mEglDisplay, mEglSurface); + mEglSurface = EGL_NO_SURFACE; + } + + if (mEglDisplay != EGL_NO_DISPLAY && mEglContext != EGL_NO_CONTEXT) + { + eglDestroyContext(mEglDisplay, mEglContext); + mEglContext = EGL_NO_CONTEXT; + } + + 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) + { + + window = p_window; +}; + +ContextEGL::~ContextEGL() { + + cleanup(); +}; + diff --git a/platform/winrt/gl_context_egl.h b/platform/winrt/gl_context_egl.h new file mode 100644 index 0000000000..56bf654ee5 --- /dev/null +++ b/platform/winrt/gl_context_egl.h @@ -0,0 +1,44 @@ +#ifndef CONTEXT_EGL_H +#define CONTEXT_EGL_H + +#include <wrl.h> + +#include "os/os.h" +#include "EGL/egl.h" +#include "error_list.h" +#include "drivers/gl_context/context_gl.h" + +using namespace Windows::UI::Core; + +class ContextEGL : public ContextGL { + + CoreWindow^ window; + + EGLDisplay mEglDisplay; + EGLContext mEglContext; + EGLSurface mEglSurface; + + EGLint width; + EGLint height; + +public: + + virtual void release_current(); + + virtual void make_current(); + + virtual int get_window_width(); + virtual int get_window_height(); + virtual void swap_buffers(); + + virtual Error initialize(); + + void cleanup(); + + ContextEGL(CoreWindow^ p_window); + ~ContextEGL(); + +}; + +#endif + diff --git a/platform/winrt/os_winrt.cpp b/platform/winrt/os_winrt.cpp index 16a74c877c..99c4ad968e 100644 --- a/platform/winrt/os_winrt.cpp +++ b/platform/winrt/os_winrt.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* os_windows.cpp */ +/* os_winrt.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,12 +28,12 @@ /*************************************************************************/ #include "drivers/gles2/rasterizer_gles2.h" #include "drivers/gles1/rasterizer_gles1.h" -#include "os_windows.h" +#include "os_winrt.h" #include "drivers/nedmalloc/memory_pool_static_nedmalloc.h" #include "drivers/unix/memory_pool_static_malloc.h" #include "os/memory_pool_dynamic_static.h" -#include "drivers/windows/thread_windows.h" -#include "drivers/windows/semaphore_windows.h" +#include "thread_winrt.h" +//#include "drivers/windows/semaphore_windows.h" #include "drivers/windows/mutex_windows.h" #include "main/main.h" #include "drivers/windows/file_access_windows.h" @@ -44,14 +44,22 @@ #include "servers/audio/audio_server_sw.h" #include "servers/visual/visual_server_wrap_mt.h" -#include "tcp_server_winsock.h" -#include "stream_peer_winsock.h" #include "os/pc_joystick_map.h" -#include "lang_table.h" #include "os/memory_pool_dynamic_prealloc.h" #include "globals.h" #include "io/marshalls.h" +#include <wrl.h> + +using namespace Windows::ApplicationModel::Core; +using namespace Windows::ApplicationModel::Activation; +using namespace Windows::UI::Core; +using namespace Windows::UI::Input; +using namespace Windows::Foundation; +using namespace Windows::Graphics::Display; +using namespace Microsoft::WRL; + + int OSWinrt::get_video_driver_count() const { return 2; @@ -129,59 +137,18 @@ bool OSWinrt::can_draw() const { }; -void OSWinrt::_touch_event(int idx, UINT uMsg, WPARAM wParam, LPARAM lParam) { - - InputEvent event; - event.type = InputEvent::SCREEN_TOUCH; - event.ID=++last_id; - event.screen_touch.index = idx; +void OSWinrt::set_gl_context(ContextEGL* p_context) { - switch (uMsg) { - case WM_LBUTTONDOWN: - case WM_MBUTTONDOWN: - case WM_RBUTTONDOWN: { - - event.screen_touch.pressed = true; - } break; - - case WM_LBUTTONUP: - case WM_MBUTTONUP: - case WM_RBUTTONUP: { - event.screen_touch.pressed = false; - } break; - }; - - event.screen_touch.x=GET_X_LPARAM(lParam); - event.screen_touch.y=GET_Y_LPARAM(lParam); - - if (main_loop) { - input->parse_input_event(event); - } + gl_context = p_context; }; -void OSWinrt::_drag_event(int idx,UINT uMsg, WPARAM wParam, LPARAM lParam) { - - InputEvent event; - event.type = InputEvent::SCREEN_DRAG; - event.ID=++last_id; - event.screen_drag.index = idx; - - event.screen_drag.x=GET_X_LPARAM(lParam); - event.screen_drag.y=GET_Y_LPARAM(lParam); - - if (main_loop) - input->parse_input_event(event); -}; - - void OSWinrt::initialize(const VideoMode& p_desired,int p_video_driver,int p_audio_driver) { - - main_loop=NULL; outside=true; - + gl_context->initialize(); + visual_server = memnew( VisualServerRaster(rasterizer) ); if (get_render_thread_mode()!=RENDER_THREAD_UNSAFE) { @@ -222,6 +189,7 @@ void OSWinrt::initialize(const VideoMode& p_desired,int p_video_driver,int p_aud void OSWinrt::set_clipboard(const String& p_text) { + /* if (!OpenClipboard(hWnd)) { ERR_EXPLAIN("Unable to open clipboard."); ERR_FAIL(); @@ -255,10 +223,12 @@ void OSWinrt::set_clipboard(const String& p_text) { SetClipboardData(CF_TEXT, mem); CloseClipboard(); + */ }; String OSWinrt::get_clipboard() const { + /* String ret; if (!OpenClipboard(hWnd)) { ERR_EXPLAIN("Unable to open clipboard."); @@ -295,6 +265,8 @@ String OSWinrt::get_clipboard() const { CloseClipboard(); return ret; + */ + return ""; }; @@ -327,10 +299,6 @@ void OSWinrt::finalize() { if (rasterizer) memdelete(rasterizer); - if (user_proc) { - SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)user_proc); - }; - spatial_sound_server->finish(); memdelete(spatial_sound_server); spatial_sound_2d_server->finish(); @@ -355,16 +323,11 @@ void OSWinrt::finalize() { } void OSWinrt::finalize_core() { - memdelete(process_map); - if (mempool_dynamic) memdelete( mempool_dynamic ); if (mempool_static) delete mempool_static; - - TCPServerWinsock::cleanup(); - StreamPeerWinsock::cleanup(); } void OSWinrt::vprint(const char* p_format, va_list p_list, bool p_stderr) { @@ -399,10 +362,7 @@ void OSWinrt::vprint(const char* p_format, va_list p_list, bool p_stderr) { void OSWinrt::alert(const String& p_alert,const String& p_title) { - if (!is_no_window_mode_enabled()) - MessageBoxW(NULL,p_alert.c_str(),p_title.c_str(),MB_OK|MB_ICONEXCLAMATION); - else - print_line("ALERT: "+p_alert); + print_line("ALERT: "+p_alert); } void OSWinrt::set_mouse_mode(MouseMode p_mode) { @@ -445,71 +405,16 @@ void OSWinrt::get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen) con 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) { - HANDLE hCon=GetStdHandle(STD_OUTPUT_HANDLE); - if (!hCon || hCon==INVALID_HANDLE_VALUE) { - if (p_rationale && p_rationale[0]) { - - print("\E[1;31;40mERROR: %s: \E[1;37;40m%s\n",p_function,p_rationale); - print("\E[0;31;40m At: %s:%i.\E[0;0;37m\n",p_file,p_line); + if (p_rationale && p_rationale[0]) { - } else { - print("\E[1;31;40mERROR: %s: \E[1;37;40m%s\n",p_function,p_code); - print("\E[0;31;40m At: %s:%i.\E[0;0;37m\n",p_file,p_line); + print("\E[1;31;40mERROR: %s: \E[1;37;40m%s\n",p_function,p_rationale); + print("\E[0;31;40m At: %s:%i.\E[0;0;37m\n",p_file,p_line); - } } else { + print("\E[1;31;40mERROR: %s: \E[1;37;40m%s\n",p_function,p_code); + print("\E[0;31;40m At: %s:%i.\E[0;0;37m\n",p_file,p_line); - CONSOLE_SCREEN_BUFFER_INFO sbi; //original - GetConsoleScreenBufferInfo(hCon,&sbi); - - SetConsoleTextAttribute(hCon,sbi.wAttributes); - - - - uint32_t basecol=0; - switch(p_type) { - case ERR_ERROR: basecol = FOREGROUND_RED; break; - case ERR_WARNING: basecol = FOREGROUND_RED|FOREGROUND_GREEN; break; - case ERR_SCRIPT: basecol = FOREGROUND_GREEN; break; - } - - if (p_rationale && p_rationale[0]) { - - SetConsoleTextAttribute(hCon,basecol|FOREGROUND_INTENSITY); - - - switch(p_type) { - case ERR_ERROR: print("ERROR: "); break; - case ERR_WARNING: print("WARNING: "); break; - case ERR_SCRIPT: print("SCRIPT ERROR: "); break; - } - - SetConsoleTextAttribute(hCon,FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_GREEN|FOREGROUND_INTENSITY); - print(" %s\n",p_rationale); - SetConsoleTextAttribute(hCon,basecol); - print("At: "); - SetConsoleTextAttribute(hCon,FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_GREEN); - print(" %s:%i\n",p_file,p_line); - - - } else { - SetConsoleTextAttribute(hCon,basecol|FOREGROUND_INTENSITY); - switch(p_type) { - case ERR_ERROR: print("ERROR: %s: ",p_function); break; - case ERR_WARNING: print("WARNING: %s: ",p_function); break; - case ERR_SCRIPT: print("SCRIPT ERROR: %s: ",p_function); break; - } - SetConsoleTextAttribute(hCon,FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_GREEN|FOREGROUND_INTENSITY); - print(" %s\n",p_code); - SetConsoleTextAttribute(hCon,basecol); - print("At: "); - SetConsoleTextAttribute(hCon,FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_GREEN); - print(" %s:%i\n",p_file,p_line); - } - - SetConsoleTextAttribute(hCon,sbi.wAttributes); } - } @@ -566,10 +471,10 @@ uint64_t OSWinrt::get_unix_time() const { void OSWinrt::delay_usec(uint32_t p_usec) const { - if (p_usec < 1000) - Sleep(1); - else - Sleep(p_usec / 1000); + int msec = p_usec < 1000 ? 1 : p_usec / 1000; + + // no Sleep() + WaitForSingleObjectEx(GetCurrentThread(), msec, false); } uint64_t OSWinrt::get_ticks_usec() const { @@ -607,19 +512,12 @@ Error OSWinrt::kill(const ProcessID& p_pid) { Error OSWinrt::set_cwd(const String& p_cwd) { - if (_wchdir(p_cwd.c_str())!=0) - return ERR_CANT_OPEN; - return OK; } String OSWinrt::get_executable_path() const { - wchar_t bufname[4096]; - GetModuleFileNameW(NULL,bufname,4096); - String s= bufname; - print_line("EXEC PATHPó: "+s); - return s; + return ""; } void OSWinrt::set_icon(const Image& p_icon) { @@ -629,25 +527,16 @@ void OSWinrt::set_icon(const Image& p_icon) { bool OSWinrt::has_environment(const String& p_var) const { - return getenv(p_var.utf8().get_data()) != NULL; + return false; }; String OSWinrt::get_environment(const String& p_var) const { - char* val = getenv(p_var.utf8().get_data()); - if (val) - return val; - return ""; }; String OSWinrt::get_stdin_string(bool p_block) { - if (p_block) { - char buff[1024]; - return fgets(buff,1024,stdin); - }; - return String(); } @@ -665,23 +554,22 @@ Error OSWinrt::shell_open(String p_uri) { String OSWinrt::get_locale() const { Platform::String ^language = Windows::Globalization::Language::CurrentInputMethodLanguageTag; - return language.Data(); + return language->Data(); } void OSWinrt::release_rendering_thread() { - //gl_context->release_current(); - + gl_context->release_current(); } void OSWinrt::make_rendering_thread() { - //gl_context->make_current(); + gl_context->make_current(); } void OSWinrt::swap_buffers() { - //gl_context->swap_buffers(); + gl_context->swap_buffers(); } @@ -699,6 +587,7 @@ void OSWinrt::run() { while (!force_quit) { + CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent); process_events(); // get rid of pending events if (Main::iteration()==true) break; @@ -724,7 +613,7 @@ String OSWinrt::get_data_dir() const { } -OSWinrt::OSWinrt(HINSTANCE _hInstance) { +OSWinrt::OSWinrt() { key_event_pos=0; force_quit=false; @@ -743,6 +632,8 @@ OSWinrt::OSWinrt(HINSTANCE _hInstance) { stdo=fopen("stdout.txt","wb"); #endif + gl_context = NULL; + } diff --git a/platform/winrt/os_winrt.h b/platform/winrt/os_winrt.h index bc7e188c20..c309239af1 100644 --- a/platform/winrt/os_winrt.h +++ b/platform/winrt/os_winrt.h @@ -41,11 +41,10 @@ #include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h" #include "servers/physics_2d/physics_2d_server_sw.h" +#include "gl_context_egl.h" #include <windows.h> -#include "key_mapping_win.h" -#include <windowsx.h> #include <io.h> #include <fcntl.h> @@ -93,6 +92,8 @@ class OSWinrt : public OS { Physics2DServer *physics_2d_server; int pressrc; + ContextEGL* gl_context; + struct Joystick { int id; @@ -224,6 +225,8 @@ public: virtual void move_window_to_foreground(); virtual String get_data_dir() const; + void set_gl_context(ContextEGL* p_context); + virtual void release_rendering_thread(); virtual void make_rendering_thread(); virtual void swap_buffers(); |