summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/gdnative/gdnative.cpp3
-rw-r--r--modules/gdnative/gdnative_library_editor_plugin.cpp4
-rw-r--r--platform/uwp/export/export.cpp11
-rw-r--r--platform/uwp/os_uwp.cpp45
-rw-r--r--platform/uwp/os_uwp.h4
5 files changed, 65 insertions, 2 deletions
diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp
index 9c0041cbe0..51dbba7d28 100644
--- a/modules/gdnative/gdnative.cpp
+++ b/modules/gdnative/gdnative.cpp
@@ -130,6 +130,9 @@ bool GDNative::initialize() {
// we should pass library name to dlopen(). The library name is flattened
// during export.
String path = lib_path.get_file();
+#elif defined(UWP_ENABLED)
+ // On UWP we use a relative path from the app
+ String path = lib_path.replace("res://", "");
#else
String path = ProjectSettings::get_singleton()->globalize_path(lib_path);
#endif
diff --git a/modules/gdnative/gdnative_library_editor_plugin.cpp b/modules/gdnative/gdnative_library_editor_plugin.cpp
index 1e638ab702..22fb058851 100644
--- a/modules/gdnative/gdnative_library_editor_plugin.cpp
+++ b/modules/gdnative/gdnative_library_editor_plugin.cpp
@@ -299,8 +299,8 @@ GDNativeLibraryEditor::GDNativeLibraryEditor() {
NativePlatformConfig platform_uwp;
platform_uwp.name = "Windows Universal";
platform_uwp.entries.push_back("arm");
- platform_uwp.entries.push_back("x86");
- platform_uwp.entries.push_back("x64");
+ platform_uwp.entries.push_back("32");
+ platform_uwp.entries.push_back("64");
platform_uwp.library_extension = "*.dll";
platforms["UWP"] = platform_uwp;
diff --git a/platform/uwp/export/export.cpp b/platform/uwp/export/export.cpp
index 9fbbca0716..24e88bcc76 100644
--- a/platform/uwp/export/export.cpp
+++ b/platform/uwp/export/export.cpp
@@ -1024,6 +1024,17 @@ public:
virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) {
r_features->push_back("s3tc");
r_features->push_back("etc");
+ switch ((int)p_preset->get("architecture/target")) {
+ case EditorExportUWP::ARM: {
+ r_features->push_back("arm");
+ } break;
+ case EditorExportUWP::X86: {
+ r_features->push_back("32");
+ } break;
+ case EditorExportUWP::X64: {
+ r_features->push_back("64");
+ } break;
+ }
}
virtual void get_export_options(List<ExportOption> *r_options) {
diff --git a/platform/uwp/os_uwp.cpp b/platform/uwp/os_uwp.cpp
index 3018ac0bef..15bb6fbcf2 100644
--- a/platform/uwp/os_uwp.cpp
+++ b/platform/uwp/os_uwp.cpp
@@ -745,6 +745,51 @@ void OSUWP::hide_virtual_keyboard() {
pane->TryHide();
}
+static String format_error_message(DWORD id) {
+
+ LPWSTR messageBuffer = NULL;
+ size_t size = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, id, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&messageBuffer, 0, NULL);
+
+ String msg = "Error " + itos(id) + ": " + String(messageBuffer, size);
+
+ LocalFree(messageBuffer);
+
+ return msg;
+}
+
+Error OSUWP::open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path) {
+
+ String full_path = "game/" + p_path;
+ p_library_handle = (void *)LoadPackagedLibrary(full_path.c_str(), 0);
+
+ if (!p_library_handle) {
+ ERR_EXPLAIN("Can't open dynamic library: " + full_path + ". Error: " + format_error_message(GetLastError()));
+ ERR_FAIL_V(ERR_CANT_OPEN);
+ }
+ return OK;
+}
+
+Error OSUWP::close_dynamic_library(void *p_library_handle) {
+ if (!FreeLibrary((HMODULE)p_library_handle)) {
+ return FAILED;
+ }
+ return OK;
+}
+
+Error OSUWP::get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle, bool p_optional) {
+ p_symbol_handle = (void *)GetProcAddress((HMODULE)p_library_handle, p_name.utf8().get_data());
+ if (!p_symbol_handle) {
+ if (!p_optional) {
+ ERR_EXPLAIN("Can't resolve symbol " + p_name + ". Error: " + String::num(GetLastError()));
+ ERR_FAIL_V(ERR_CANT_RESOLVE);
+ } else {
+ return ERR_CANT_RESOLVE;
+ }
+ }
+ return OK;
+}
+
void OSUWP::run() {
if (!main_loop)
diff --git a/platform/uwp/os_uwp.h b/platform/uwp/os_uwp.h
index 8d69cd53fd..4d889906c1 100644
--- a/platform/uwp/os_uwp.h
+++ b/platform/uwp/os_uwp.h
@@ -242,6 +242,10 @@ public:
virtual void show_virtual_keyboard(const String &p_existing_text, const Rect2 &p_screen_rect = Rect2());
virtual void hide_virtual_keyboard();
+ virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false);
+ virtual Error close_dynamic_library(void *p_library_handle);
+ virtual Error get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle, bool p_optional = false);
+
virtual Error shell_open(String p_uri);
void run();