summaryrefslogtreecommitdiff
path: root/platform/iphone
diff options
context:
space:
mode:
Diffstat (limited to 'platform/iphone')
-rw-r--r--platform/iphone/SCsub1
-rw-r--r--platform/iphone/app_delegate.h11
-rw-r--r--platform/iphone/app_delegate.mm15
-rw-r--r--platform/iphone/detect.py14
-rw-r--r--platform/iphone/export/export.cpp211
-rw-r--r--platform/iphone/game_center.mm14
-rw-r--r--platform/iphone/gl_view.mm16
-rw-r--r--platform/iphone/icloud.mm16
-rw-r--r--platform/iphone/in_app_store.mm16
-rw-r--r--platform/iphone/os_iphone.cpp75
-rw-r--r--platform/iphone/os_iphone.h9
-rw-r--r--platform/iphone/platform_config.h1
-rw-r--r--platform/iphone/semaphore_iphone.cpp112
-rw-r--r--platform/iphone/semaphore_iphone.h59
-rw-r--r--platform/iphone/vulkan_context_iphone.h (renamed from platform/iphone/power_iphone.h)27
-rw-r--r--platform/iphone/vulkan_context_iphone.mm (renamed from platform/iphone/power_iphone.cpp)48
16 files changed, 302 insertions, 343 deletions
diff --git a/platform/iphone/SCsub b/platform/iphone/SCsub
index fa1b124561..1f82f51888 100644
--- a/platform/iphone/SCsub
+++ b/platform/iphone/SCsub
@@ -14,6 +14,7 @@ iphone_lib = [
'in_app_store.mm',
'icloud.mm',
'ios.mm',
+ 'vulkan_context_iphone.mm',
]
env_ios = env.Clone()
diff --git a/platform/iphone/app_delegate.h b/platform/iphone/app_delegate.h
index b4454aab11..27552d781a 100644
--- a/platform/iphone/app_delegate.h
+++ b/platform/iphone/app_delegate.h
@@ -28,13 +28,22 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#if defined(OPENGL_ENABLED)
#import "gl_view.h"
+#endif
#import "view_controller.h"
#import <UIKit/UIKit.h>
#import <CoreMotion/CoreMotion.h>
-@interface AppDelegate : NSObject <UIApplicationDelegate, GLViewDelegate> {
+// FIXME: Add support for both GLES2 and Vulkan when GLES2 is implemented again,
+// so it can't be done with compilation time branching.
+//#if defined(OPENGL_ENABLED)
+//@interface AppDelegate : NSObject <UIApplicationDelegate, GLViewDelegate> {
+//#endif
+#if defined(VULKAN_ENABLED)
+@interface AppDelegate : NSObject <UIApplicationDelegate> {
+#endif
//@property (strong, nonatomic) UIWindow *window;
ViewController *view_controller;
bool is_focus_out;
diff --git a/platform/iphone/app_delegate.mm b/platform/iphone/app_delegate.mm
index 4de321fa04..0ac8bb7a56 100644
--- a/platform/iphone/app_delegate.mm
+++ b/platform/iphone/app_delegate.mm
@@ -32,7 +32,9 @@
#include "core/project_settings.h"
#include "drivers/coreaudio/audio_driver_coreaudio.h"
+#if defined(OPENGL_ENABLED)
#import "gl_view.h"
+#endif
#include "main/main.h"
#include "os_iphone.h"
@@ -412,10 +414,12 @@ static void on_focus_in(ViewController *view_controller, bool *is_focus_out) {
OS::VideoMode _get_video_mode() {
int backingWidth;
int backingHeight;
+#if defined(OPENGL_ENABLED)
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES,
GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES,
GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);
+#endif
OS::VideoMode vm;
vm.fullscreen = true;
@@ -426,7 +430,7 @@ OS::VideoMode _get_video_mode() {
};
static int frame_count = 0;
-- (void)drawView:(GLView *)view;
+- (void)drawView:(UIView *)view;
{
switch (frame_count) {
@@ -634,6 +638,7 @@ static int frame_count = 0;
return FALSE;
};
+#if defined(OPENGL_ENABLED)
// WARNING: We must *always* create the GLView after we have constructed the
// OS with iphone_main. This allows the GLView to access project settings so
// it can properly initialize the OpenGL context
@@ -642,7 +647,6 @@ static int frame_count = 0;
view_controller = [[ViewController alloc] init];
view_controller.view = glView;
- window.rootViewController = view_controller;
_set_keep_screen_on(bool(GLOBAL_DEF("display/window/energy_saving/keep_screen_on", true)) ? YES : NO);
glView.useCADisplayLink =
@@ -650,6 +654,13 @@ static int frame_count = 0;
printf("cadisaplylink: %d", glView.useCADisplayLink);
glView.animationInterval = 1.0 / kRenderingFrequency;
[glView startAnimation];
+#endif
+
+#if defined(VULKAN_ENABLED)
+ view_controller = [[ViewController alloc] init];
+#endif
+
+ window.rootViewController = view_controller;
// Show the window
[window makeKeyAndVisible];
diff --git a/platform/iphone/detect.py b/platform/iphone/detect.py
index f646b8b1d5..e01950c1db 100644
--- a/platform/iphone/detect.py
+++ b/platform/iphone/detect.py
@@ -23,6 +23,7 @@ def get_opts():
return [
('IPHONEPATH', 'Path to iPhone toolchain', '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain'),
('IPHONESDK', 'Path to the iPhone SDK', ''),
+ BoolVariable('use_static_mvk', 'Link MoltenVK statically as Level-0 driver (better portability) or use Vulkan ICD loader (enables validation layers)', False),
BoolVariable('game_center', 'Support for game center', True),
BoolVariable('store_kit', 'Support for in-app store', True),
BoolVariable('icloud', 'Support for iCloud', True),
@@ -149,7 +150,7 @@ def configure(env):
'-framework', 'Foundation',
'-framework', 'GameController',
'-framework', 'MediaPlayer',
- '-framework', 'OpenGLES',
+ '-framework', 'Metal',
'-framework', 'QuartzCore',
'-framework', 'Security',
'-framework', 'SystemConfiguration',
@@ -170,11 +171,18 @@ def configure(env):
env.Append(CPPDEFINES=['ICLOUD_ENABLED'])
env.Prepend(CPPPATH=['$IPHONESDK/usr/include',
- '$IPHONESDK/System/Library/Frameworks/OpenGLES.framework/Headers',
'$IPHONESDK/System/Library/Frameworks/AudioUnit.framework/Headers',
])
env['ENV']['CODESIGN_ALLOCATE'] = '/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate'
env.Prepend(CPPPATH=['#platform/iphone'])
- env.Append(CPPDEFINES=['IPHONE_ENABLED', 'UNIX_ENABLED', 'GLES_ENABLED', 'COREAUDIO_ENABLED'])
+ env.Append(CPPDEFINES=['IPHONE_ENABLED', 'UNIX_ENABLED', 'COREAUDIO_ENABLED'])
+
+ env.Append(CPPDEFINES=['VULKAN_ENABLED'])
+ env.Append(LINKFLAGS=['-framework', 'IOSurface'])
+ if (env['use_static_mvk']):
+ env.Append(LINKFLAGS=['-framework', 'MoltenVK'])
+ env['builtin_vulkan'] = False
+ elif not env['builtin_vulkan']:
+ env.Append(LIBS=['vulkan'])
diff --git a/platform/iphone/export/export.cpp b/platform/iphone/export/export.cpp
index b606d570c2..08f3c3f91f 100644
--- a/platform/iphone/export/export.cpp
+++ b/platform/iphone/export/export.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "export.h"
+#include "core/io/image_loader.h"
#include "core/io/marshalls.h"
#include "core/io/resource_saver.h"
#include "core/io/zip_io.h"
@@ -39,6 +40,7 @@
#include "editor/editor_export.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
+#include "main/splash.gen.h"
#include "platform/iphone/logo.gen.h"
#include "string.h"
@@ -55,6 +57,7 @@ class EditorExportPlatformIOS : public EditorExportPlatform {
typedef Error (*FileHandler)(String p_file, void *p_userdata);
static Error _walk_dir_recursive(DirAccess *p_da, FileHandler p_handler, void *p_userdata);
static Error _codesign(String p_file, void *p_userdata);
+ void _blend_and_rotate(Ref<Image> &p_dst, Ref<Image> &p_src, bool p_rot);
struct IOSConfigData {
String pkg_name;
@@ -134,7 +137,7 @@ protected:
public:
virtual String get_name() const { return "iOS"; }
virtual String get_os_name() const { return "iOS"; }
- virtual Ref<Texture> get_logo() const { return logo; }
+ virtual Ref<Texture2D> get_logo() const { return logo; }
virtual List<String> get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const {
List<String> list;
@@ -164,11 +167,9 @@ void EditorExportPlatformIOS::get_preset_features(const Ref<EditorExportPreset>
String driver = ProjectSettings::get_singleton()->get("rendering/quality/driver/driver_name");
if (driver == "GLES2") {
r_features->push_back("etc");
- } else if (driver == "GLES3") {
+ } else if (driver == "Vulkan") {
+ // FIXME: Review if this is correct.
r_features->push_back("etc2");
- if (ProjectSettings::get_singleton()->get("rendering/quality/driver/fallback_to_gles2")) {
- r_features->push_back("etc");
- }
}
Vector<String> architectures = _get_preset_architectures(p_preset);
@@ -187,21 +188,24 @@ Vector<EditorExportPlatformIOS::ExportArchitecture> EditorExportPlatformIOS::_ge
struct LoadingScreenInfo {
const char *preset_key;
const char *export_name;
+ int width;
+ int height;
+ bool rotate;
};
static const LoadingScreenInfo loading_screen_infos[] = {
- { "landscape_launch_screens/iphone_2436x1125", "Default-Landscape-X.png" },
- { "landscape_launch_screens/iphone_2208x1242", "Default-Landscape-736h@3x.png" },
- { "landscape_launch_screens/ipad_1024x768", "Default-Landscape.png" },
- { "landscape_launch_screens/ipad_2048x1536", "Default-Landscape@2x.png" },
-
- { "portrait_launch_screens/iphone_640x960", "Default-480h@2x.png" },
- { "portrait_launch_screens/iphone_640x1136", "Default-568h@2x.png" },
- { "portrait_launch_screens/iphone_750x1334", "Default-667h@2x.png" },
- { "portrait_launch_screens/iphone_1125x2436", "Default-Portrait-X.png" },
- { "portrait_launch_screens/ipad_768x1024", "Default-Portrait.png" },
- { "portrait_launch_screens/ipad_1536x2048", "Default-Portrait@2x.png" },
- { "portrait_launch_screens/iphone_1242x2208", "Default-Portrait-736h@3x.png" }
+ { "landscape_launch_screens/iphone_2436x1125", "Default-Landscape-X.png", 2436, 1125, false },
+ { "landscape_launch_screens/iphone_2208x1242", "Default-Landscape-736h@3x.png", 2208, 1242, false },
+ { "landscape_launch_screens/ipad_1024x768", "Default-Landscape.png", 1024, 768, false },
+ { "landscape_launch_screens/ipad_2048x1536", "Default-Landscape@2x.png", 2048, 1536, false },
+
+ { "portrait_launch_screens/iphone_640x960", "Default-480h@2x.png", 640, 960, true },
+ { "portrait_launch_screens/iphone_640x1136", "Default-568h@2x.png", 640, 1136, true },
+ { "portrait_launch_screens/iphone_750x1334", "Default-667h@2x.png", 750, 1334, true },
+ { "portrait_launch_screens/iphone_1125x2436", "Default-Portrait-X.png", 1125, 2436, true },
+ { "portrait_launch_screens/ipad_768x1024", "Default-Portrait.png", 768, 1024, true },
+ { "portrait_launch_screens/ipad_1536x2048", "Default-Portrait@2x.png", 1536, 2048, true },
+ { "portrait_launch_screens/iphone_1242x2208", "Default-Portrait-736h@3x.png", 1242, 2208, true }
};
void EditorExportPlatformIOS::get_export_options(List<ExportOption> *r_options) {
@@ -247,6 +251,8 @@ void EditorExportPlatformIOS::get_export_options(List<ExportOption> *r_options)
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "orientation/landscape_right"), true));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "orientation/portrait_upside_down"), true));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "icons/generate_missing"), false));
+
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "required_icons/iphone_120x120", PROPERTY_HINT_FILE, "*.png"), "")); // Home screen on iPhone/iPod Touch with retina display
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "required_icons/ipad_76x76", PROPERTY_HINT_FILE, "*.png"), "")); // Home screen on iPad
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "required_icons/app_store_1024x1024", PROPERTY_HINT_FILE, "*.png"), "")); // App Store
@@ -257,6 +263,8 @@ void EditorExportPlatformIOS::get_export_options(List<ExportOption> *r_options)
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "optional_icons/spotlight_40x40", PROPERTY_HINT_FILE, "*.png"), "")); // Spotlight
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "optional_icons/spotlight_80x80", PROPERTY_HINT_FILE, "*.png"), "")); // Spotlight on devices with retina display
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "launch_screens/generate_missing"), false));
+
for (uint64_t i = 0; i < sizeof(loading_screen_infos) / sizeof(loading_screen_infos[0]); ++i) {
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, loading_screen_infos[i].preset_key, PROPERTY_HINT_FILE, "*.png"), ""));
}
@@ -402,7 +410,7 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_
}
String EditorExportPlatformIOS::_get_additional_plist_content() {
- Vector<Ref<EditorExportPlugin> > export_plugins = EditorExport::get_singleton()->get_export_plugins();
+ Vector<Ref<EditorExportPlugin>> export_plugins = EditorExport::get_singleton()->get_export_plugins();
String result;
for (int i = 0; i < export_plugins.size(); ++i) {
result += export_plugins[i]->get_ios_plist_content();
@@ -411,7 +419,7 @@ String EditorExportPlatformIOS::_get_additional_plist_content() {
}
String EditorExportPlatformIOS::_get_linker_flags() {
- Vector<Ref<EditorExportPlugin> > export_plugins = EditorExport::get_singleton()->get_export_plugins();
+ Vector<Ref<EditorExportPlugin>> export_plugins = EditorExport::get_singleton()->get_export_plugins();
String result;
for (int i = 0; i < export_plugins.size(); ++i) {
String flags = export_plugins[i]->get_ios_linker_flags();
@@ -426,7 +434,7 @@ String EditorExportPlatformIOS::_get_linker_flags() {
}
String EditorExportPlatformIOS::_get_cpp_code() {
- Vector<Ref<EditorExportPlugin> > export_plugins = EditorExport::get_singleton()->get_export_plugins();
+ Vector<Ref<EditorExportPlugin>> export_plugins = EditorExport::get_singleton()->get_export_plugins();
String result;
for (int i = 0; i < export_plugins.size(); ++i) {
result += export_plugins[i]->get_ios_cpp_code();
@@ -434,6 +442,36 @@ String EditorExportPlatformIOS::_get_cpp_code() {
return result;
}
+void EditorExportPlatformIOS::_blend_and_rotate(Ref<Image> &p_dst, Ref<Image> &p_src, bool p_rot) {
+
+ ERR_FAIL_COND(p_dst.is_null());
+ ERR_FAIL_COND(p_src.is_null());
+
+ int sw = p_rot ? p_src->get_height() : p_src->get_width();
+ int sh = p_rot ? p_src->get_width() : p_src->get_height();
+
+ int x_pos = (p_dst->get_width() - sw) / 2;
+ int y_pos = (p_dst->get_height() - sh) / 2;
+
+ int xs = (x_pos >= 0) ? 0 : -x_pos;
+ int ys = (y_pos >= 0) ? 0 : -y_pos;
+
+ if (sw + x_pos > p_dst->get_width()) sw = p_dst->get_width() - x_pos;
+ if (sh + y_pos > p_dst->get_height()) sh = p_dst->get_height() - y_pos;
+
+ for (int y = ys; y < sh; y++) {
+ for (int x = xs; x < sw; x++) {
+ Color sc = p_rot ? p_src->get_pixel(p_src->get_width() - y - 1, x) : p_src->get_pixel(x, y);
+ Color dc = p_dst->get_pixel(x_pos + x, y_pos + y);
+ dc.r = (double)(sc.a * sc.r + dc.a * (1.0 - sc.a) * dc.r);
+ dc.g = (double)(sc.a * sc.g + dc.a * (1.0 - sc.a) * dc.g);
+ dc.b = (double)(sc.a * sc.b + dc.a * (1.0 - sc.a) * dc.b);
+ dc.a = (double)(sc.a + dc.a * (1.0 - sc.a));
+ p_dst->set_pixel(x_pos + x, y_pos + y, dc);
+ }
+ }
+}
+
struct IconInfo {
const char *preset_key;
const char *idiom;
@@ -448,8 +486,8 @@ static const IconInfo icon_infos[] = {
{ "required_icons/iphone_120x120", "iphone", "Icon-120.png", "120", "2x", "60x60", true },
{ "required_icons/iphone_120x120", "iphone", "Icon-120.png", "120", "3x", "40x40", true },
- { "required_icons/ipad_76x76", "ipad", "Icon-76.png", "76", "1x", "76x76", false },
- { "required_icons/app_store_1024x1024", "ios-marketing", "Icon-1024.png", "1024", "1x", "1024x1024", false },
+ { "required_icons/ipad_76x76", "ipad", "Icon-76.png", "76", "1x", "76x76", true },
+ { "required_icons/app_store_1024x1024", "ios-marketing", "Icon-1024.png", "1024", "1x", "1024x1024", true },
{ "optional_icons/iphone_180x180", "iphone", "Icon-180.png", "180", "3x", "60x60", false },
@@ -473,20 +511,56 @@ Error EditorExportPlatformIOS::_export_icons(const Ref<EditorExportPreset> &p_pr
for (uint64_t i = 0; i < (sizeof(icon_infos) / sizeof(icon_infos[0])); ++i) {
IconInfo info = icon_infos[i];
+ int side_size = String(info.actual_size_side).to_int();
String icon_path = p_preset->get(info.preset_key);
if (icon_path.length() == 0) {
- if (info.is_required) {
- ERR_PRINT("Required icon is not specified in the preset");
+ if ((bool)p_preset->get("icons/generate_missing")) {
+ // Resize main app icon
+ icon_path = ProjectSettings::get_singleton()->get("application/config/icon");
+ Ref<Image> img = memnew(Image);
+ Error err = ImageLoader::load_image(icon_path, img);
+ if (err != OK) {
+ ERR_PRINT("Invalid icon (" + String(info.preset_key) + "): '" + icon_path + "'.");
+ return ERR_UNCONFIGURED;
+ }
+ img->resize(side_size, side_size);
+ err = img->save_png(p_iconset_dir + info.export_name);
+ if (err) {
+ String err_str = String("Failed to export icon(" + String(info.preset_key) + "): '" + icon_path + "'.");
+ ERR_PRINT(err_str.utf8().get_data());
+ return err;
+ }
+ } else {
+ if (info.is_required) {
+ String err_str = String("Required icon (") + info.preset_key + ") is not specified in the preset.";
+ ERR_PRINT(err_str);
+ return ERR_UNCONFIGURED;
+ } else {
+ String err_str = String("Icon (") + info.preset_key + ") is not specified in the preset.";
+ WARN_PRINT(err_str);
+ }
+ continue;
+ }
+ } else {
+ // Load custom icon
+ Ref<Image> img = memnew(Image);
+ Error err = ImageLoader::load_image(icon_path, img);
+ if (err != OK) {
+ ERR_PRINT("Invalid icon (" + String(info.preset_key) + "): '" + icon_path + "'.");
return ERR_UNCONFIGURED;
}
- continue;
- }
- Error err = da->copy(icon_path, p_iconset_dir + info.export_name);
- if (err) {
- memdelete(da);
- String err_str = String("Failed to export icon: ") + icon_path;
- ERR_PRINT(err_str.utf8().get_data());
- return err;
+ if (img->get_width() != side_size || img->get_height() != side_size) {
+ ERR_PRINT("Invalid icon size (" + String(info.preset_key) + "): '" + icon_path + "'.");
+ return ERR_UNCONFIGURED;
+ }
+
+ err = da->copy(icon_path, p_iconset_dir + info.export_name);
+ if (err) {
+ memdelete(da);
+ String err_str = String("Failed to export icon(" + String(info.preset_key) + "): '" + icon_path + "'.");
+ ERR_PRINT(err_str.utf8().get_data());
+ return err;
+ }
}
sizes += String(info.actual_size_side) + "\n";
if (i > 0) {
@@ -525,13 +599,72 @@ Error EditorExportPlatformIOS::_export_loading_screens(const Ref<EditorExportPre
LoadingScreenInfo info = loading_screen_infos[i];
String loading_screen_file = p_preset->get(info.preset_key);
if (loading_screen_file.size() > 0) {
- Error err = da->copy(loading_screen_file, p_dest_dir + info.export_name);
+ // Load custom loading screens
+ Ref<Image> img = memnew(Image);
+ Error err = ImageLoader::load_image(loading_screen_file, img);
+ if (err != OK) {
+ ERR_PRINT("Invalid loading screen (" + String(info.preset_key) + "): '" + loading_screen_file + "'.");
+ return ERR_UNCONFIGURED;
+ }
+ if (img->get_width() != info.width || img->get_height() != info.height) {
+ ERR_PRINT("Invalid loading screen size (" + String(info.preset_key) + "): '" + loading_screen_file + "'.");
+ return ERR_UNCONFIGURED;
+ }
+ err = da->copy(loading_screen_file, p_dest_dir + info.export_name);
if (err) {
memdelete(da);
String err_str = String("Failed to export loading screen (") + info.preset_key + ") from path '" + loading_screen_file + "'.";
ERR_PRINT(err_str.utf8().get_data());
return err;
}
+ } else if ((bool)p_preset->get("launch_screens/generate_missing")) {
+ // Generate loading screen from the splash screen
+ Color boot_bg_color = ProjectSettings::get_singleton()->get("application/boot_splash/bg_color");
+ String boot_logo_path = ProjectSettings::get_singleton()->get("application/boot_splash/image");
+ bool boot_logo_scale = ProjectSettings::get_singleton()->get("application/boot_splash/fullsize");
+
+ Ref<Image> img = memnew(Image);
+ img->create(info.width, info.height, false, Image::FORMAT_RGBA8);
+ img->fill(boot_bg_color);
+
+ Ref<Image> img_bs;
+
+ if (boot_logo_path.length() > 0) {
+ img_bs = Ref<Image>(memnew(Image));
+ ImageLoader::load_image(boot_logo_path, img_bs);
+ }
+ if (!img_bs.is_valid()) {
+ img_bs = Ref<Image>(memnew(Image(boot_splash_png)));
+ }
+ if (img_bs.is_valid()) {
+ float aspect_ratio = (float)img_bs->get_width() / (float)img_bs->get_height();
+ if (info.rotate) {
+ if (boot_logo_scale) {
+ if (info.width * aspect_ratio <= info.height) {
+ img_bs->resize(info.width * aspect_ratio, info.width);
+ } else {
+ img_bs->resize(info.height, info.height / aspect_ratio);
+ }
+ }
+ } else {
+ if (boot_logo_scale) {
+ if (info.height * aspect_ratio <= info.width) {
+ img_bs->resize(info.height * aspect_ratio, info.height);
+ } else {
+ img_bs->resize(info.width, info.width / aspect_ratio);
+ }
+ }
+ }
+ _blend_and_rotate(img, img_bs, info.rotate);
+ }
+ Error err = img->save_png(p_dest_dir + info.export_name);
+ if (err) {
+ String err_str = String("Failed to export loading screen (") + info.preset_key + ") from splash screen.";
+ WARN_PRINT(err_str.utf8().get_data());
+ }
+ } else {
+ String err_str = String("No loading screen (") + info.preset_key + ") specified.";
+ WARN_PRINT(err_str.utf8().get_data());
}
}
memdelete(da);
@@ -643,7 +776,7 @@ struct ExportLibsData {
};
void EditorExportPlatformIOS::_add_assets_to_project(const Ref<EditorExportPreset> &p_preset, Vector<uint8_t> &p_project_data, const Vector<IOSExportAsset> &p_additional_assets) {
- Vector<Ref<EditorExportPlugin> > export_plugins = EditorExport::get_singleton()->get_export_plugins();
+ Vector<Ref<EditorExportPlugin>> export_plugins = EditorExport::get_singleton()->get_export_plugins();
Vector<String> frameworks;
for (int i = 0; i < export_plugins.size(); ++i) {
Vector<String> plugin_frameworks = export_plugins[i]->get_ios_frameworks();
@@ -787,7 +920,7 @@ Error EditorExportPlatformIOS::_export_additional_assets(const String &p_out_dir
}
Error EditorExportPlatformIOS::_export_additional_assets(const String &p_out_dir, const Vector<SharedObject> &p_libraries, Vector<IOSExportAsset> &r_exported_assets) {
- Vector<Ref<EditorExportPlugin> > export_plugins = EditorExport::get_singleton()->get_export_plugins();
+ Vector<Ref<EditorExportPlugin>> export_plugins = EditorExport::get_singleton()->get_export_plugins();
for (int i = 0; i < export_plugins.size(); i++) {
Vector<String> frameworks = export_plugins[i]->get_ios_frameworks();
Error err = _export_additional_assets(p_out_dir, frameworks, true, r_exported_assets);
@@ -1030,7 +1163,7 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
print_line("Creating " + dir_name);
Error dir_err = tmp_app_path->make_dir_recursive(dir_name);
if (dir_err) {
- ERR_PRINTS("Can't create '" + dir_name + "'.");
+ ERR_PRINT("Can't create '" + dir_name + "'.");
unzClose(src_pkg_zip);
memdelete(tmp_app_path);
return ERR_CANT_CREATE;
@@ -1040,7 +1173,7 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
/* write the file */
FileAccess *f = FileAccess::open(file, FileAccess::WRITE);
if (!f) {
- ERR_PRINTS("Can't write '" + file + "'.");
+ ERR_PRINT("Can't write '" + file + "'.");
unzClose(src_pkg_zip);
memdelete(tmp_app_path);
return ERR_CANT_CREATE;
@@ -1064,7 +1197,7 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
unzClose(src_pkg_zip);
if (!found_library) {
- ERR_PRINTS("Requested template library '" + library_to_use + "' not found. It might be missing from your template archive.");
+ ERR_PRINT("Requested template library '" + library_to_use + "' not found. It might be missing from your template archive.");
memdelete(tmp_app_path);
return ERR_FILE_NOT_FOUND;
}
@@ -1093,7 +1226,7 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
String project_file_name = dest_dir + binary_name + ".xcodeproj/project.pbxproj";
FileAccess *f = FileAccess::open(project_file_name, FileAccess::WRITE);
if (!f) {
- ERR_PRINTS("Can't write '" + project_file_name + "'.");
+ ERR_PRINT("Can't write '" + project_file_name + "'.");
return ERR_CANT_CREATE;
};
f->store_buffer(project_file_data.ptr(), project_file_data.size());
diff --git a/platform/iphone/game_center.mm b/platform/iphone/game_center.mm
index 696f61f954..99d539d4ff 100644
--- a/platform/iphone/game_center.mm
+++ b/platform/iphone/game_center.mm
@@ -198,11 +198,11 @@ void GameCenter::request_achievement_descriptions() {
ret["type"] = "achievement_descriptions";
if (error == nil) {
ret["result"] = "ok";
- PoolStringArray names;
- PoolStringArray titles;
- PoolStringArray unachieved_descriptions;
- PoolStringArray achieved_descriptions;
- PoolIntArray maximum_points;
+ PackedStringArray names;
+ PackedStringArray titles;
+ PackedStringArray unachieved_descriptions;
+ PackedStringArray achieved_descriptions;
+ PackedInt32Array maximum_points;
Array hidden;
Array replayable;
@@ -253,8 +253,8 @@ void GameCenter::request_achievements() {
ret["type"] = "achievements";
if (error == nil) {
ret["result"] = "ok";
- PoolStringArray names;
- PoolRealArray percentages;
+ PackedStringArray names;
+ PackedFloat32Array percentages;
for (int i = 0; i < [achievements count]; i++) {
diff --git a/platform/iphone/gl_view.mm b/platform/iphone/gl_view.mm
index e8d737d9c3..ede60a502d 100644
--- a/platform/iphone/gl_view.mm
+++ b/platform/iphone/gl_view.mm
@@ -47,7 +47,6 @@
@end
*/
-bool gles3_available = true;
int gl_view_base_fb;
static String keyboard_text;
static GLView *_instance = NULL;
@@ -284,20 +283,11 @@ static void clear_touches() {
kEAGLColorFormatRGBA8,
kEAGLDrawablePropertyColorFormat,
nil];
- bool fallback_gl2 = false;
- // Create a GL ES 3 context based on the gl driver from project settings
- if (GLOBAL_GET("rendering/quality/driver/driver_name") == "GLES3") {
- context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];
- NSLog(@"Setting up an OpenGL ES 3.0 context. Based on Project Settings \"rendering/quality/driver/driver_name\"");
- if (!context && GLOBAL_GET("rendering/quality/driver/fallback_to_gles2")) {
- gles3_available = false;
- fallback_gl2 = true;
- NSLog(@"Failed to create OpenGL ES 3.0 context. Falling back to OpenGL ES 2.0");
- }
- }
+
+ // FIXME: Add Vulkan support via MoltenVK. Add fallback code back?
// Create GL ES 2 context
- if (GLOBAL_GET("rendering/quality/driver/driver_name") == "GLES2" || fallback_gl2) {
+ if (GLOBAL_GET("rendering/quality/driver/driver_name") == "GLES2") {
context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
NSLog(@"Setting up an OpenGL ES 2.0 context.");
if (!context) {
diff --git a/platform/iphone/icloud.mm b/platform/iphone/icloud.mm
index f846043dde..251f78f2da 100644
--- a/platform/iphone/icloud.mm
+++ b/platform/iphone/icloud.mm
@@ -80,13 +80,13 @@ Variant nsobject_to_variant(NSObject *object) {
const char *str = [(NSString *)object UTF8String];
return String::utf8(str != NULL ? str : "");
} else if ([object isKindOfClass:[NSData class]]) {
- PoolByteArray ret;
+ PackedByteArray ret;
NSData *data = (NSData *)object;
if ([data length] > 0) {
ret.resize([data length]);
{
- PoolByteArray::Write w = ret.write();
- copymem(w.ptr(), [data bytes], [data length]);
+ // PackedByteArray::Write w = ret.write();
+ copymem((void *)ret.ptr(), [data bytes], [data length]);
}
}
return ret;
@@ -184,10 +184,10 @@ NSObject *variant_to_nsobject(Variant v) {
[result addObject:value];
}
return result;
- } else if (v.get_type() == Variant::POOL_BYTE_ARRAY) {
- PoolByteArray arr = v;
- PoolByteArray::Read r = arr.read();
- NSData *result = [NSData dataWithBytes:r.ptr() length:arr.size()];
+ } else if (v.get_type() == Variant::PACKED_BYTE_ARRAY) {
+ PackedByteArray arr = v;
+ // PackedByteArray::Read r = arr.read();
+ NSData *result = [NSData dataWithBytes:arr.ptr() length:arr.size()];
return result;
}
WARN_PRINT(String("Could not add unsupported type to iCloud: '" + Variant::get_type_name(v.get_type()) + "'").utf8().get_data());
@@ -315,7 +315,7 @@ ICloud::ICloud() {
Dictionary ret;
ret["type"] = "key_value_changed";
- //PoolStringArray result_keys;
+ //PackedStringArray result_keys;
//Array result_values;
Dictionary keyValues;
String reason = "";
diff --git a/platform/iphone/in_app_store.mm b/platform/iphone/in_app_store.mm
index 855ab195b0..a8a887824f 100644
--- a/platform/iphone/in_app_store.mm
+++ b/platform/iphone/in_app_store.mm
@@ -85,12 +85,12 @@ void InAppStore::_bind_methods() {
Dictionary ret;
ret["type"] = "product_info";
ret["result"] = "ok";
- PoolStringArray titles;
- PoolStringArray descriptions;
- PoolRealArray prices;
- PoolStringArray ids;
- PoolStringArray localized_prices;
- PoolStringArray currency_codes;
+ PackedStringArray titles;
+ PackedStringArray descriptions;
+ PackedFloat32Array prices;
+ PackedStringArray ids;
+ PackedStringArray localized_prices;
+ PackedStringArray currency_codes;
for (NSUInteger i = 0; i < [products count]; i++) {
@@ -113,7 +113,7 @@ void InAppStore::_bind_methods() {
ret["localized_prices"] = localized_prices;
ret["currency_codes"] = currency_codes;
- PoolStringArray invalid_ids;
+ PackedStringArray invalid_ids;
for (NSString *ipid in response.invalidProductIdentifiers) {
@@ -133,7 +133,7 @@ Error InAppStore::request_product_info(Variant p_params) {
Dictionary params = p_params;
ERR_FAIL_COND_V(!params.has("product_ids"), ERR_INVALID_PARAMETER);
- PoolStringArray pids = params["product_ids"];
+ PackedStringArray pids = params["product_ids"];
printf("************ request product info! %i\n", pids.size());
NSMutableArray *array = [[[NSMutableArray alloc] initWithCapacity:pids.size()] autorelease];
diff --git a/platform/iphone/os_iphone.cpp b/platform/iphone/os_iphone.cpp
index 7a699f9b50..497f2f747d 100644
--- a/platform/iphone/os_iphone.cpp
+++ b/platform/iphone/os_iphone.cpp
@@ -32,8 +32,16 @@
#include "os_iphone.h"
+#if defined(OPENGL_ENABLED)
#include "drivers/gles2/rasterizer_gles2.h"
-#include "drivers/gles3/rasterizer_gles3.h"
+#endif
+
+#if defined(VULKAN_ENABLED)
+#include "servers/visual/rasterizer_rd/rasterizer_rd.h"
+// #import <QuartzCore/CAMetalLayer.h>
+#include <vulkan/vulkan_metal.h>
+#endif
+
#include "servers/visual/visual_server_raster.h"
#include "servers/visual/visual_server_wrap_mt.h"
@@ -57,8 +65,6 @@ int OSIPhone::get_video_driver_count() const {
const char *OSIPhone::get_video_driver_name(int p_driver) const {
switch (p_driver) {
- case VIDEO_DRIVER_GLES3:
- return "GLES3";
case VIDEO_DRIVER_GLES2:
return "GLES2";
}
@@ -94,7 +100,6 @@ String OSIPhone::get_unique_id() const {
void OSIPhone::initialize_core() {
OS_Unix::initialize_core();
- SemaphoreIphone::make_default();
set_data_dir(data_dir);
};
@@ -103,62 +108,44 @@ int OSIPhone::get_current_video_driver() const {
return video_driver_index;
}
-extern bool gles3_available; // from gl_view.mm
-
Error OSIPhone::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
+ video_driver_index = p_video_driver;
- bool use_gl3 = GLOBAL_GET("rendering/quality/driver/driver_name") == "GLES3";
+#if defined(OPENGL_ENABLED)
bool gl_initialization_error = false;
- while (true) {
- if (use_gl3) {
- if (RasterizerGLES3::is_viable() == OK && gles3_available) {
- RasterizerGLES3::register_config();
- RasterizerGLES3::make_current();
- break;
- } else {
- if (GLOBAL_GET("rendering/quality/driver/fallback_to_gles2")) {
- p_video_driver = VIDEO_DRIVER_GLES2;
- use_gl3 = false;
- continue;
- } else {
- gl_initialization_error = true;
- break;
- }
- }
- } else {
- if (RasterizerGLES2::is_viable() == OK) {
- RasterizerGLES2::register_config();
- RasterizerGLES2::make_current();
- break;
- } else {
- gl_initialization_error = true;
- break;
- }
- }
+ // FIXME: Add Vulkan support via MoltenVK. Add fallback code back?
+
+ if (RasterizerGLES2::is_viable() == OK) {
+ RasterizerGLES2::register_config();
+ RasterizerGLES2::make_current();
+ } else {
+ gl_initialization_error = true;
}
if (gl_initialization_error) {
OS::get_singleton()->alert("Your device does not support any of the supported OpenGL versions.",
- "Unable to initialize Video driver");
+ "Unable to initialize video driver");
return ERR_UNAVAILABLE;
}
+#endif
+
+#if defined(VULKAN_ENABLED)
+ RasterizerRD::make_current();
+#endif
- video_driver_index = p_video_driver;
visual_server = memnew(VisualServerRaster);
// FIXME: Reimplement threaded rendering
if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) {
visual_server = memnew(VisualServerWrapMT(visual_server, false));
}
-
visual_server->init();
//visual_server->cursor_set_visible(false, 0);
+#if defined(OPENGL_ENABLED)
// reset this to what it should be, it will have been set to 0 after visual_server->init() is called
- if (use_gl3)
- RasterizerStorageGLES3::system_fbo = gl_view_base_fb;
- else
- RasterizerStorageGLES2::system_fbo = gl_view_base_fb;
+ RasterizerStorageGLES2::system_fbo = gl_view_base_fb;
+#endif
AudioDriverManager::initialize(p_audio_driver);
@@ -223,7 +210,8 @@ void OSIPhone::key(uint32_t p_key, bool p_pressed) {
ev.instance();
ev->set_echo(false);
ev->set_pressed(p_pressed);
- ev->set_scancode(p_key);
+ ev->set_keycode(p_key);
+ ev->set_physical_keycode(p_key);
ev->set_unicode(p_key);
queue_event(ev);
};
@@ -465,9 +453,10 @@ bool OSIPhone::can_draw() const {
};
int OSIPhone::set_base_framebuffer(int p_fb) {
-
+#if defined(OPENGL_ENABLED)
// gl_view_base_fb has not been updated yet
- RasterizerStorageGLES3::system_fbo = p_fb;
+ RasterizerStorageGLES2::system_fbo = p_fb;
+#endif
return 0;
};
diff --git a/platform/iphone/os_iphone.h b/platform/iphone/os_iphone.h
index d2d96181f5..f42679e754 100644
--- a/platform/iphone/os_iphone.h
+++ b/platform/iphone/os_iphone.h
@@ -46,6 +46,11 @@
#include "servers/visual/rasterizer.h"
#include "servers/visual_server.h"
+#if defined(VULKAN_ENABLED)
+#include "drivers/vulkan/rendering_device_vulkan.h"
+#include "platform/iphone/vulkan_context_iphone.h"
+#endif
+
class OSIPhone : public OS_Unix {
private:
@@ -74,6 +79,10 @@ private:
MainLoop *main_loop;
+#if defined(VULKAN_ENABLED)
+ VulkanContextIPhone *context_vulkan;
+ RenderingDeviceVulkan *rendering_device_vulkan;
+#endif
VideoMode video_mode;
virtual int get_video_driver_count() const;
diff --git a/platform/iphone/platform_config.h b/platform/iphone/platform_config.h
index d39c64eed6..bc190ba956 100644
--- a/platform/iphone/platform_config.h
+++ b/platform/iphone/platform_config.h
@@ -31,7 +31,6 @@
#include <alloca.h>
#define GLES2_INCLUDE_H <ES2/gl.h>
-#define GLES3_INCLUDE_H <ES3/gl.h>
#define PLATFORM_REFCOUNT
diff --git a/platform/iphone/semaphore_iphone.cpp b/platform/iphone/semaphore_iphone.cpp
deleted file mode 100644
index 0c1d4d2d5c..0000000000
--- a/platform/iphone/semaphore_iphone.cpp
+++ /dev/null
@@ -1,112 +0,0 @@
-/*************************************************************************/
-/* semaphore_iphone.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#include "semaphore_iphone.h"
-
-#include <fcntl.h>
-#include <unistd.h>
-
-void cgsem_init(cgsem_t *);
-void cgsem_post(cgsem_t *);
-void cgsem_wait(cgsem_t *);
-void cgsem_destroy(cgsem_t *);
-
-void cgsem_init(cgsem_t *cgsem) {
- int flags, fd, i;
-
- pipe(cgsem->pipefd);
-
- /* Make the pipes FD_CLOEXEC to allow them to close should we call
- * execv on restart. */
- for (i = 0; i < 2; i++) {
- fd = cgsem->pipefd[i];
- flags = fcntl(fd, F_GETFD, 0);
- flags |= FD_CLOEXEC;
- fcntl(fd, F_SETFD, flags);
- }
-}
-
-void cgsem_post(cgsem_t *cgsem) {
- const char buf = 1;
-
- write(cgsem->pipefd[1], &buf, 1);
-}
-
-void cgsem_wait(cgsem_t *cgsem) {
- char buf;
-
- read(cgsem->pipefd[0], &buf, 1);
-}
-
-void cgsem_destroy(cgsem_t *cgsem) {
- close(cgsem->pipefd[1]);
- close(cgsem->pipefd[0]);
-}
-
-#include "core/os/memory.h"
-
-#include <errno.h>
-
-Error SemaphoreIphone::wait() {
-
- cgsem_wait(&sem);
- return OK;
-}
-
-Error SemaphoreIphone::post() {
-
- cgsem_post(&sem);
-
- return OK;
-}
-int SemaphoreIphone::get() const {
-
- return 0;
-}
-
-Semaphore *SemaphoreIphone::create_semaphore_iphone() {
-
- return memnew(SemaphoreIphone);
-}
-
-void SemaphoreIphone::make_default() {
-
- create_func = create_semaphore_iphone;
-}
-
-SemaphoreIphone::SemaphoreIphone() {
-
- cgsem_init(&sem);
-}
-
-SemaphoreIphone::~SemaphoreIphone() {
-
- cgsem_destroy(&sem);
-}
diff --git a/platform/iphone/semaphore_iphone.h b/platform/iphone/semaphore_iphone.h
deleted file mode 100644
index 9356c65f1e..0000000000
--- a/platform/iphone/semaphore_iphone.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*************************************************************************/
-/* semaphore_iphone.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#ifndef SEMAPHORE_IPHONE_H
-#define SEMAPHORE_IPHONE_H
-
-struct cgsem {
- int pipefd[2];
-};
-
-typedef struct cgsem cgsem_t;
-
-#include "core/os/semaphore.h"
-
-class SemaphoreIphone : public Semaphore {
-
- mutable cgsem_t sem;
-
- static Semaphore *create_semaphore_iphone();
-
-public:
- virtual Error wait();
- virtual Error post();
- virtual int get() const;
-
- static void make_default();
- SemaphoreIphone();
-
- ~SemaphoreIphone();
-};
-
-#endif // SEMAPHORE_IPHONE_H
diff --git a/platform/iphone/power_iphone.h b/platform/iphone/vulkan_context_iphone.h
index 47a4508509..200057e14d 100644
--- a/platform/iphone/power_iphone.h
+++ b/platform/iphone/vulkan_context_iphone.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* power_iphone.h */
+/* vulkan_context_osx.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,26 +28,21 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef POWER_IPHONE_H
-#define POWER_IPHONE_H
+#ifndef VULKAN_CONTEXT_IPHONE_H
+#define VULKAN_CONTEXT_IPHONE_H
-#include <os/os.h>
+#include "drivers/vulkan/vulkan_context.h"
+// #import <UIKit/UIKit.h>
-class PowerIphone {
-private:
- int nsecs_left;
- int percent_left;
- OS::PowerState power_state;
+class VulkanContextIPhone : public VulkanContext {
- bool UpdatePowerInfo();
+ virtual const char *_get_platform_surface_extension() const;
public:
- PowerIphone();
- virtual ~PowerIphone();
+ int window_create(void *p_window, int p_width, int p_height);
- OS::PowerState get_power_state();
- int get_power_seconds_left();
- int get_power_percent_left();
+ VulkanContextIPhone();
+ ~VulkanContextIPhone();
};
-#endif // POWER_IPHONE_H
+#endif // VULKAN_CONTEXT_IPHONE_H
diff --git a/platform/iphone/power_iphone.cpp b/platform/iphone/vulkan_context_iphone.mm
index 36bac8da38..f49b85c097 100644
--- a/platform/iphone/power_iphone.cpp
+++ b/platform/iphone/vulkan_context_iphone.mm
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* power_iphone.cpp */
+/* vulkan_context_osx.mm */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,43 +28,29 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "power_iphone.h"
+#include "vulkan_context_iphone.h"
+#include <vulkan/vulkan_ios.h>
-bool PowerIphone::UpdatePowerInfo() {
- return false;
+const char *VulkanContextIPhone::_get_platform_surface_extension() const {
+ return VK_MVK_IOS_SURFACE_EXTENSION_NAME;
}
-OS::PowerState PowerIphone::get_power_state() {
- if (UpdatePowerInfo()) {
- return power_state;
- } else {
- return OS::POWERSTATE_UNKNOWN;
- }
-}
+int VulkanContextIPhone::window_create(void *p_window, int p_width, int p_height) {
-int PowerIphone::get_power_seconds_left() {
- if (UpdatePowerInfo()) {
- return nsecs_left;
- } else {
- return -1;
- }
-}
+ VkIOSSurfaceCreateInfoMVK createInfo;
+ createInfo.sType = VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK;
+ createInfo.pNext = NULL;
+ createInfo.flags = 0;
+ createInfo.pView = p_window;
-int PowerIphone::get_power_percent_left() {
- if (UpdatePowerInfo()) {
- return percent_left;
- } else {
- return -1;
- }
+ VkSurfaceKHR surface;
+ VkResult err = vkCreateIOSSurfaceMVK(_get_instance(), &createInfo, NULL, &surface);
+ ERR_FAIL_COND_V(err, -1);
+ return _window_create(surface, p_width, p_height);
}
-PowerIphone::PowerIphone() :
- nsecs_left(-1),
- percent_left(-1),
- power_state(OS::POWERSTATE_UNKNOWN) {
- // TODO Auto-generated constructor stub
+VulkanContextIPhone::VulkanContextIPhone() {
}
-PowerIphone::~PowerIphone() {
- // TODO Auto-generated destructor stub
+VulkanContextIPhone::~VulkanContextIPhone() {
}