diff options
Diffstat (limited to 'platform/uwp')
-rw-r--r-- | platform/uwp/app.cpp | 15 | ||||
-rw-r--r-- | platform/uwp/detect.py | 6 | ||||
-rw-r--r-- | platform/uwp/gl_context_egl.cpp | 30 | ||||
-rw-r--r-- | platform/uwp/gl_context_egl.h | 11 | ||||
-rw-r--r-- | platform/uwp/os_uwp.cpp | 50 | ||||
-rw-r--r-- | platform/uwp/os_uwp.h | 9 |
6 files changed, 70 insertions, 51 deletions
diff --git a/platform/uwp/app.cpp b/platform/uwp/app.cpp index c18aa36402..b769925849 100644 --- a/platform/uwp/app.cpp +++ b/platform/uwp/app.cpp @@ -143,14 +143,13 @@ void App::SetWindow(CoreWindow ^ p_window) { window->KeyUp += ref new TypedEventHandler<CoreWindow ^, KeyEventArgs ^>(this, &App::OnKeyUp); + os->set_window(window); + unsigned int argc; char **argv = get_command_line(&argc); Main::setup("uwp", argc, argv, false); - // 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)); Main::setup2(); @@ -513,7 +512,7 @@ char **App::get_command_line(unsigned int *out_argc) { if (f == NULL) { - wprintf(L"Couldn't open command line file."); + wprintf(L"Couldn't open command line file.\n"); return fail_cl; } @@ -527,7 +526,7 @@ char **App::get_command_line(unsigned int *out_argc) { if (r < 4) { fclose(f); - wprintf(L"Wrong cmdline length."); + wprintf(L"Wrong cmdline length.\n"); return (fail_cl); } @@ -539,7 +538,7 @@ char **App::get_command_line(unsigned int *out_argc) { if (r < 4) { fclose(f); - wprintf(L"Wrong cmdline param length."); + wprintf(L"Wrong cmdline param length.\n"); return (fail_cl); } @@ -547,7 +546,7 @@ char **App::get_command_line(unsigned int *out_argc) { if (strlen > CMD_MAX_LEN) { fclose(f); - wprintf(L"Wrong command length."); + wprintf(L"Wrong command length.\n"); return (fail_cl); } @@ -568,7 +567,7 @@ char **App::get_command_line(unsigned int *out_argc) { delete[] arg; fclose(f); - wprintf(L"Error reading command."); + wprintf(L"Error reading command.\n"); return (fail_cl); } } diff --git a/platform/uwp/detect.py b/platform/uwp/detect.py index 0e7b125dc5..559f23ca5b 100644 --- a/platform/uwp/detect.py +++ b/platform/uwp/detect.py @@ -28,8 +28,8 @@ def get_opts(): from SCons.Variables import BoolVariable return [ - ('msvc_version', 'MSVC version to use. Ignored if VCINSTALLDIR is set in shell env.', None), - BoolVariable('use_mingw', 'Use the Mingw compiler, even if MSVC is installed. Only used on Windows.', False), + ('msvc_version', 'MSVC version to use (ignored if the VCINSTALLDIR environment variable is set)', None), + BoolVariable('use_mingw', 'Use the MinGW compiler even if MSVC is installed (only used on Windows)', False), ] @@ -112,7 +112,7 @@ def configure(env): env["bits"] = "32" print("Compiled program architecture will be a x86 executable. (forcing bits=32).") else: - print("Failed to detect MSVC compiler architecture version... Defaulting to 32bit executable settings (forcing bits=32). Compilation attempt will continue, but SCons can not detect for what architecture this build is compiled for. You should check your settings/compilation setup.") + print("Failed to detect MSVC compiler architecture version... Defaulting to 32-bit executable settings (forcing bits=32). Compilation attempt will continue, but SCons can not detect for what architecture this build is compiled for. You should check your settings/compilation setup.") env["bits"] = "32" if (env["bits"] == "32"): diff --git a/platform/uwp/gl_context_egl.cpp b/platform/uwp/gl_context_egl.cpp index 88c9c8d687..6c60b27f5a 100644 --- a/platform/uwp/gl_context_egl.cpp +++ b/platform/uwp/gl_context_egl.cpp @@ -93,12 +93,26 @@ Error ContextEGL::initialize() { EGLint numConfigs = 0; EGLint majorVersion = 1; - EGLint minorVersion = 0; + EGLint minorVersion; + if (driver == GLES_2_0) { + minorVersion = 0; + } else { + minorVersion = 5; + } EGLDisplay display = EGL_NO_DISPLAY; EGLContext context = EGL_NO_CONTEXT; EGLSurface surface = EGL_NO_SURFACE; EGLConfig config = nullptr; - EGLint contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 3, EGL_NONE, EGL_NONE }; + EGLint contextAttribs[3]; + if (driver == GLES_2_0) { + contextAttribs[0] = EGL_CONTEXT_CLIENT_VERSION; + contextAttribs[1] = 2; + contextAttribs[2] = EGL_NONE; + } else { + contextAttribs[0] = EGL_CONTEXT_CLIENT_VERSION; + contextAttribs[1] = 3; + contextAttribs[2] = EGL_NONE; + } try { @@ -114,7 +128,8 @@ Error ContextEGL::initialize() { // EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER is an optimization that can have large performance benefits on mobile devices. // Its syntax is subject to change, though. Please update your Visual Studio templates if you experience compilation issues with it. - //EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, EGL_TRUE, + EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, + EGL_TRUE, // EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE is an option that enables ANGLE to automatically call // the IDXGIDevice3::Trim method on behalf of the application when it gets suspended. @@ -193,13 +208,12 @@ void ContextEGL::cleanup() { } }; -ContextEGL::ContextEGL(CoreWindow ^ p_window) : +ContextEGL::ContextEGL(CoreWindow ^ p_window, Driver p_driver) : mEglDisplay(EGL_NO_DISPLAY), mEglContext(EGL_NO_CONTEXT), - mEglSurface(EGL_NO_SURFACE) { - - window = p_window; -}; + mEglSurface(EGL_NO_SURFACE), + driver(p_driver), + window(p_window) {} ContextEGL::~ContextEGL() { diff --git a/platform/uwp/gl_context_egl.h b/platform/uwp/gl_context_egl.h index 527baf1054..df0108c124 100644 --- a/platform/uwp/gl_context_egl.h +++ b/platform/uwp/gl_context_egl.h @@ -42,6 +42,13 @@ using namespace Windows::UI::Core; class ContextEGL : public ContextGL { +public: + enum Driver { + GLES_2_0, + GLES_3_0, + }; + +private: CoreWindow ^ window; EGLDisplay mEglDisplay; @@ -53,6 +60,8 @@ class ContextEGL : public ContextGL { bool vsync; + Driver driver; + public: virtual void release_current(); @@ -70,7 +79,7 @@ public: void cleanup(); - ContextEGL(CoreWindow ^ p_window); + ContextEGL(CoreWindow ^ p_window, Driver p_driver); ~ContextEGL(); }; diff --git a/platform/uwp/os_uwp.cpp b/platform/uwp/os_uwp.cpp index d00da3dbcd..8549a44ce5 100644 --- a/platform/uwp/os_uwp.cpp +++ b/platform/uwp/os_uwp.cpp @@ -30,6 +30,7 @@ #include "os_uwp.h" +#include "drivers/gles2/rasterizer_gles2.h" #include "drivers/gles3/rasterizer_gles3.h" #include "drivers/unix/ip_unix.h" #include "drivers/windows/dir_access_windows.h" @@ -66,12 +67,7 @@ using namespace Windows::ApplicationModel::DataTransfer; using namespace concurrency; int OSUWP::get_video_driver_count() const { - - return 1; -} -const char *OSUWP::get_video_driver_name(int p_driver) const { - - return "GLES3"; + return 2; } Size2 OSUWP::get_window_size() const { @@ -81,6 +77,10 @@ Size2 OSUWP::get_window_size() const { return size; } +int OSUWP::get_current_video_driver() const { + return video_driver_index; +} + void OSUWP::set_window_size(const Size2 p_size) { Windows::Foundation::Size new_size; @@ -133,18 +133,6 @@ void OSUWP::set_keep_screen_on(bool p_enabled) { OS::set_keep_screen_on(p_enabled); } -int OSUWP::get_audio_driver_count() const { - - return AudioDriverManager::get_driver_count(); -} - -const char *OSUWP::get_audio_driver_name(int p_driver) const { - - AudioDriver *driver = AudioDriverManager::get_driver(p_driver); - ERR_FAIL_COND_V(!driver, ""); - return AudioDriverManager::get_driver(p_driver)->get_name(); -} - void OSUWP::initialize_core() { last_button_state = 0; @@ -185,10 +173,9 @@ bool OSUWP::can_draw() const { return !minimized; }; -void OSUWP::set_gl_context(ContextEGL *p_context) { - - gl_context = p_context; -}; +void OSUWP::set_window(Windows::UI::Core::CoreWindow ^ p_window) { + window = p_window; +} void OSUWP::screen_size_changed() { @@ -200,6 +187,11 @@ Error OSUWP::initialize(const VideoMode &p_desired, int p_video_driver, int p_au main_loop = NULL; outside = true; + if (p_video_driver == VIDEO_DRIVER_GLES2) { + gl_context = memnew(ContextEGL(window, ContextEGL::GLES_2_0)); + } else { + gl_context = memnew(ContextEGL(window, ContextEGL::GLES_3_0)); + } gl_context->initialize(); VideoMode vm; vm.width = gl_context->get_window_width(); @@ -240,10 +232,17 @@ Error OSUWP::initialize(const VideoMode &p_desired, int p_video_driver, int p_au gl_context->make_current(); - RasterizerGLES3::register_config(); - RasterizerGLES3::make_current(); + if (p_video_driver == VIDEO_DRIVER_GLES2) { + RasterizerGLES2::register_config(); + RasterizerGLES2::make_current(); + } else { + RasterizerGLES3::register_config(); + RasterizerGLES3::make_current(); + } gl_context->set_use_vsync(vm.use_vsync); + video_driver_index = p_video_driver; + visual_server = memnew(VisualServerRaster); // FIXME: Reimplement threaded rendering? Or remove? /* @@ -297,7 +296,7 @@ Error OSUWP::initialize(const VideoMode &p_desired, int p_video_driver, int p_au if (is_keep_screen_on()) display_request->RequestActive(); - set_keep_screen_on(GLOBAL_DEF("display/window/keep_screen_on", true)); + set_keep_screen_on(GLOBAL_DEF("display/window/energy_saving/keep_screen_on", true)); return OK; } @@ -392,7 +391,6 @@ void OSUWP::ManagedType::update_clipboard() { if (data->Contains(StandardDataFormats::Text)) { create_task(data->GetTextAsync()).then([this](Platform::String ^ clipboard_content) { - this->clipboard = clipboard_content; }); } diff --git a/platform/uwp/os_uwp.h b/platform/uwp/os_uwp.h index 95afdab469..3b48063fe9 100644 --- a/platform/uwp/os_uwp.h +++ b/platform/uwp/os_uwp.h @@ -96,8 +96,10 @@ private: int pressrc; ContextEGL *gl_context; + Windows::UI::Core::CoreWindow ^ window; VideoMode video_mode; + int video_driver_index; MainLoop *main_loop; @@ -153,10 +155,7 @@ private: // 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 int get_audio_driver_count() const; - virtual const char *get_audio_driver_name(int p_driver) const; + virtual int get_current_video_driver() const; virtual void initialize_core(); virtual Error initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver); @@ -231,7 +230,7 @@ public: virtual bool _check_internal_feature_support(const String &p_feature); - void set_gl_context(ContextEGL *p_context); + void set_window(Windows::UI::Core::CoreWindow ^ p_window); void screen_size_changed(); virtual void release_rendering_thread(); |