summaryrefslogtreecommitdiff
path: root/platform/uwp
diff options
context:
space:
mode:
Diffstat (limited to 'platform/uwp')
-rw-r--r--platform/uwp/app.cpp15
-rw-r--r--platform/uwp/export/export.cpp100
-rw-r--r--platform/uwp/gl_context_egl.cpp30
-rw-r--r--platform/uwp/gl_context_egl.h11
-rw-r--r--platform/uwp/os_uwp.cpp50
-rw-r--r--platform/uwp/os_uwp.h9
6 files changed, 117 insertions, 98 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/export/export.cpp b/platform/uwp/export/export.cpp
index 35c0b30ce4..ebc2c2d7a2 100644
--- a/platform/uwp/export/export.cpp
+++ b/platform/uwp/export/export.cpp
@@ -301,37 +301,37 @@ Vector<uint8_t> AppxPackager::make_file_header(FileMeta p_file_meta) {
int offs = 0;
// Write magic
- offs += buf_put_int32(FILE_HEADER_MAGIC, &buf[offs]);
+ offs += buf_put_int32(FILE_HEADER_MAGIC, &buf.write[offs]);
// Version
- offs += buf_put_int16(ZIP_VERSION, &buf[offs]);
+ offs += buf_put_int16(ZIP_VERSION, &buf.write[offs]);
// Special flag
- offs += buf_put_int16(GENERAL_PURPOSE, &buf[offs]);
+ offs += buf_put_int16(GENERAL_PURPOSE, &buf.write[offs]);
// Compression
- offs += buf_put_int16(p_file_meta.compressed ? Z_DEFLATED : 0, &buf[offs]);
+ offs += buf_put_int16(p_file_meta.compressed ? Z_DEFLATED : 0, &buf.write[offs]);
// File date and time
- offs += buf_put_int32(0, &buf[offs]);
+ offs += buf_put_int32(0, &buf.write[offs]);
// CRC-32
- offs += buf_put_int32(p_file_meta.file_crc32, &buf[offs]);
+ offs += buf_put_int32(p_file_meta.file_crc32, &buf.write[offs]);
// Compressed size
- offs += buf_put_int32(p_file_meta.compressed_size, &buf[offs]);
+ offs += buf_put_int32(p_file_meta.compressed_size, &buf.write[offs]);
// Uncompressed size
- offs += buf_put_int32(p_file_meta.uncompressed_size, &buf[offs]);
+ offs += buf_put_int32(p_file_meta.uncompressed_size, &buf.write[offs]);
// File name length
- offs += buf_put_int16(p_file_meta.name.length(), &buf[offs]);
+ offs += buf_put_int16(p_file_meta.name.length(), &buf.write[offs]);
// Extra data length
- offs += buf_put_int16(0, &buf[offs]);
+ offs += buf_put_int16(0, &buf.write[offs]);
// File name
- offs += buf_put_string(p_file_meta.name, &buf[offs]);
+ offs += buf_put_string(p_file_meta.name, &buf.write[offs]);
// Done!
return buf;
@@ -344,47 +344,47 @@ void AppxPackager::store_central_dir_header(const FileMeta &p_file, bool p_do_ha
buf.resize(buf.size() + BASE_CENTRAL_DIR_SIZE + p_file.name.length());
// Write magic
- offs += buf_put_int32(CENTRAL_DIR_MAGIC, &buf[offs]);
+ offs += buf_put_int32(CENTRAL_DIR_MAGIC, &buf.write[offs]);
// ZIP versions
- offs += buf_put_int16(ZIP_ARCHIVE_VERSION, &buf[offs]);
- offs += buf_put_int16(ZIP_VERSION, &buf[offs]);
+ offs += buf_put_int16(ZIP_ARCHIVE_VERSION, &buf.write[offs]);
+ offs += buf_put_int16(ZIP_VERSION, &buf.write[offs]);
// General purpose flag
- offs += buf_put_int16(GENERAL_PURPOSE, &buf[offs]);
+ offs += buf_put_int16(GENERAL_PURPOSE, &buf.write[offs]);
// Compression
- offs += buf_put_int16(p_file.compressed ? Z_DEFLATED : 0, &buf[offs]);
+ offs += buf_put_int16(p_file.compressed ? Z_DEFLATED : 0, &buf.write[offs]);
// Modification date/time
- offs += buf_put_int32(0, &buf[offs]);
+ offs += buf_put_int32(0, &buf.write[offs]);
// Crc-32
- offs += buf_put_int32(p_file.file_crc32, &buf[offs]);
+ offs += buf_put_int32(p_file.file_crc32, &buf.write[offs]);
// File sizes
- offs += buf_put_int32(p_file.compressed_size, &buf[offs]);
- offs += buf_put_int32(p_file.uncompressed_size, &buf[offs]);
+ offs += buf_put_int32(p_file.compressed_size, &buf.write[offs]);
+ offs += buf_put_int32(p_file.uncompressed_size, &buf.write[offs]);
// File name length
- offs += buf_put_int16(p_file.name.length(), &buf[offs]);
+ offs += buf_put_int16(p_file.name.length(), &buf.write[offs]);
// Extra field length
- offs += buf_put_int16(0, &buf[offs]);
+ offs += buf_put_int16(0, &buf.write[offs]);
// Comment length
- offs += buf_put_int16(0, &buf[offs]);
+ offs += buf_put_int16(0, &buf.write[offs]);
// Disk number start, internal/external file attributes
for (int i = 0; i < 8; i++) {
- buf[offs++] = 0;
+ buf.write[offs++] = 0;
}
// Relative offset
- offs += buf_put_int32(p_file.zip_offset, &buf[offs]);
+ offs += buf_put_int32(p_file.zip_offset, &buf.write[offs]);
// File name
- offs += buf_put_string(p_file.name, &buf[offs]);
+ offs += buf_put_string(p_file.name, &buf.write[offs]);
// Done!
}
@@ -397,62 +397,62 @@ Vector<uint8_t> AppxPackager::make_end_of_central_record() {
int offs = 0;
// Write magic
- offs += buf_put_int32(ZIP64_END_OF_CENTRAL_DIR_MAGIC, &buf[offs]);
+ offs += buf_put_int32(ZIP64_END_OF_CENTRAL_DIR_MAGIC, &buf.write[offs]);
// Size of this record
- offs += buf_put_int64(ZIP64_END_OF_CENTRAL_DIR_SIZE, &buf[offs]);
+ offs += buf_put_int64(ZIP64_END_OF_CENTRAL_DIR_SIZE, &buf.write[offs]);
// Version (yes, twice)
- offs += buf_put_int16(ZIP_ARCHIVE_VERSION, &buf[offs]);
- offs += buf_put_int16(ZIP_ARCHIVE_VERSION, &buf[offs]);
+ offs += buf_put_int16(ZIP_ARCHIVE_VERSION, &buf.write[offs]);
+ offs += buf_put_int16(ZIP_ARCHIVE_VERSION, &buf.write[offs]);
// Disk number
for (int i = 0; i < 8; i++) {
- buf[offs++] = 0;
+ buf.write[offs++] = 0;
}
// Number of entries (total and per disk)
- offs += buf_put_int64(file_metadata.size(), &buf[offs]);
- offs += buf_put_int64(file_metadata.size(), &buf[offs]);
+ offs += buf_put_int64(file_metadata.size(), &buf.write[offs]);
+ offs += buf_put_int64(file_metadata.size(), &buf.write[offs]);
// Size of central dir
- offs += buf_put_int64(central_dir_data.size(), &buf[offs]);
+ offs += buf_put_int64(central_dir_data.size(), &buf.write[offs]);
// Central dir offset
- offs += buf_put_int64(central_dir_offset, &buf[offs]);
+ offs += buf_put_int64(central_dir_offset, &buf.write[offs]);
////// ZIP64 locator
// Write magic for zip64 central dir locator
- offs += buf_put_int32(ZIP64_END_DIR_LOCATOR_MAGIC, &buf[offs]);
+ offs += buf_put_int32(ZIP64_END_DIR_LOCATOR_MAGIC, &buf.write[offs]);
// Disk number
for (int i = 0; i < 4; i++) {
- buf[offs++] = 0;
+ buf.write[offs++] = 0;
}
// Relative offset
- offs += buf_put_int64(end_of_central_dir_offset, &buf[offs]);
+ offs += buf_put_int64(end_of_central_dir_offset, &buf.write[offs]);
// Number of disks
- offs += buf_put_int32(1, &buf[offs]);
+ offs += buf_put_int32(1, &buf.write[offs]);
/////// End of zip directory
// Write magic for end central dir
- offs += buf_put_int32(END_OF_CENTRAL_DIR_MAGIC, &buf[offs]);
+ offs += buf_put_int32(END_OF_CENTRAL_DIR_MAGIC, &buf.write[offs]);
// Dummy stuff for Zip64
for (int i = 0; i < 4; i++) {
- buf[offs++] = 0x0;
+ buf.write[offs++] = 0x0;
}
for (int i = 0; i < 12; i++) {
- buf[offs++] = 0xFF;
+ buf.write[offs++] = 0xFF;
}
// Size of comments
for (int i = 0; i < 2; i++) {
- buf[offs++] = 0;
+ buf.write[offs++] = 0;
}
// Done!
@@ -508,7 +508,7 @@ void AppxPackager::add_file(String p_file_name, const uint8_t *p_buffer, size_t
size_t block_size = (p_len - step) > BLOCK_SIZE ? BLOCK_SIZE : (p_len - step);
for (uint32_t i = 0; i < block_size; i++) {
- strm_in[i] = p_buffer[step + i];
+ strm_in.write[i] = p_buffer[step + i];
}
BlockHash bh;
@@ -530,14 +530,14 @@ void AppxPackager::add_file(String p_file_name, const uint8_t *p_buffer, size_t
int start = file_buffer.size();
file_buffer.resize(file_buffer.size() + bh.compressed_size);
for (uint32_t i = 0; i < bh.compressed_size; i++)
- file_buffer[start + i] = strm_out[i];
+ file_buffer.write[start + i] = strm_out[i];
} else {
bh.compressed_size = block_size;
//package->store_buffer(strm_in.ptr(), block_size);
int start = file_buffer.size();
file_buffer.resize(file_buffer.size() + block_size);
for (uint32_t i = 0; i < bh.compressed_size; i++)
- file_buffer[start + i] = strm_in[i];
+ file_buffer.write[start + i] = strm_in[i];
}
meta.hashes.push_back(bh);
@@ -560,7 +560,7 @@ void AppxPackager::add_file(String p_file_name, const uint8_t *p_buffer, size_t
int start = file_buffer.size();
file_buffer.resize(file_buffer.size() + (strm.total_out - total_out_before));
for (uint32_t i = 0; i < (strm.total_out - total_out_before); i++)
- file_buffer[start + i] = strm_out[i];
+ file_buffer.write[start + i] = strm_out[i];
deflateEnd(&strm);
meta.compressed_size = strm.total_out;
@@ -864,7 +864,7 @@ class EditorExportUWP : public EditorExportPlatform {
r_ret.resize(result.length());
for (int i = 0; i < result.length(); i++)
- r_ret[i] = result.utf8().get(i);
+ r_ret.write[i] = result.utf8().get(i);
return r_ret;
}
@@ -1371,8 +1371,8 @@ public:
CharString txt = cl[i].utf8();
int base = clf.size();
clf.resize(base + 4 + txt.length());
- encode_uint32(txt.length(), &clf[base]);
- copymem(&clf[base + 4], txt.ptr(), txt.length());
+ encode_uint32(txt.length(), &clf.write[base]);
+ copymem(&clf.write[base + 4], txt.ptr(), txt.length());
print_line(itos(i) + " param: " + cl[i]);
}
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();