summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--platform/android/display_server_android.h4
-rw-r--r--platform/iphone/display_server_iphone.h4
-rw-r--r--platform/iphone/display_server_iphone.mm28
-rw-r--r--platform/linuxbsd/display_server_x11.cpp24
-rw-r--r--platform/osx/display_server_osx.mm54
-rw-r--r--platform/windows/display_server_windows.cpp31
-rw-r--r--platform/windows/display_server_windows.h6
7 files changed, 73 insertions, 78 deletions
diff --git a/platform/android/display_server_android.h b/platform/android/display_server_android.h
index 669a1c80e4..5b987ad70e 100644
--- a/platform/android/display_server_android.h
+++ b/platform/android/display_server_android.h
@@ -70,8 +70,8 @@ class DisplayServerAndroid : public DisplayServer {
CursorShape cursor_shape = CursorShape::CURSOR_ARROW;
#if defined(VULKAN_ENABLED)
- VulkanContextAndroid *context_vulkan;
- RenderingDeviceVulkan *rendering_device_vulkan;
+ VulkanContextAndroid *context_vulkan = nullptr;
+ RenderingDeviceVulkan *rendering_device_vulkan = nullptr;
#endif
ObjectID window_attached_instance_id;
diff --git a/platform/iphone/display_server_iphone.h b/platform/iphone/display_server_iphone.h
index 5cfcc1765c..5ed03cc06e 100644
--- a/platform/iphone/display_server_iphone.h
+++ b/platform/iphone/display_server_iphone.h
@@ -54,8 +54,8 @@ class DisplayServerIPhone : public DisplayServer {
_THREAD_SAFE_CLASS_
#if defined(VULKAN_ENABLED)
- VulkanContextIPhone *context_vulkan;
- RenderingDeviceVulkan *rendering_device_vulkan;
+ VulkanContextIPhone *context_vulkan = nullptr;
+ RenderingDeviceVulkan *rendering_device_vulkan = nullptr;
#endif
DisplayServer::ScreenOrientation screen_orientation;
diff --git a/platform/iphone/display_server_iphone.mm b/platform/iphone/display_server_iphone.mm
index b746c60d4e..6a01ca1b13 100644
--- a/platform/iphone/display_server_iphone.mm
+++ b/platform/iphone/display_server_iphone.mm
@@ -54,6 +54,8 @@ DisplayServerIPhone::DisplayServerIPhone(const String &p_rendering_driver, Windo
#if defined(GLES3_ENABLED)
// FIXME: Add support for both OpenGL and Vulkan when OpenGL is implemented
// again,
+ // Note that we should be checking "opengl3" as the driver, might never enable this seeing OpenGL is deprecated on iOS
+ // We are hardcoding the rendering_driver to "vulkan" down below
if (rendering_driver == "opengl_es") {
bool gl_initialization_error = false;
@@ -131,18 +133,16 @@ DisplayServerIPhone::DisplayServerIPhone(const String &p_rendering_driver, Windo
DisplayServerIPhone::~DisplayServerIPhone() {
#if defined(VULKAN_ENABLED)
- if (rendering_driver == "vulkan") {
- if (rendering_device_vulkan) {
- rendering_device_vulkan->finalize();
- memdelete(rendering_device_vulkan);
- rendering_device_vulkan = nullptr;
- }
+ if (rendering_device_vulkan) {
+ rendering_device_vulkan->finalize();
+ memdelete(rendering_device_vulkan);
+ rendering_device_vulkan = nullptr;
+ }
- if (context_vulkan) {
- context_vulkan->window_destroy(MAIN_WINDOW_ID);
- memdelete(context_vulkan);
- context_vulkan = nullptr;
- }
+ if (context_vulkan) {
+ context_vulkan->window_destroy(MAIN_WINDOW_ID);
+ memdelete(context_vulkan);
+ context_vulkan = nullptr;
}
#endif
}
@@ -565,10 +565,8 @@ void DisplayServerIPhone::resize_window(CGSize viewSize) {
Size2i size = Size2i(viewSize.width, viewSize.height) * screen_get_max_scale();
#if defined(VULKAN_ENABLED)
- if (rendering_driver == "vulkan") {
- if (context_vulkan) {
- context_vulkan->window_resize(MAIN_WINDOW_ID, size.x, size.y);
- }
+ if (context_vulkan) {
+ context_vulkan->window_resize(MAIN_WINDOW_ID, size.x, size.y);
}
#endif
diff --git a/platform/linuxbsd/display_server_x11.cpp b/platform/linuxbsd/display_server_x11.cpp
index 74ec8b652f..247665e313 100644
--- a/platform/linuxbsd/display_server_x11.cpp
+++ b/platform/linuxbsd/display_server_x11.cpp
@@ -1150,7 +1150,7 @@ void DisplayServerX11::delete_sub_window(WindowID p_id) {
}
#ifdef VULKAN_ENABLED
- if (rendering_driver == "vulkan") {
+ if (context_vulkan) {
context_vulkan->window_destroy(p_id);
}
#endif
@@ -2927,7 +2927,7 @@ void DisplayServerX11::_window_changed(XEvent *event) {
wd.size = new_rect.size;
#if defined(VULKAN_ENABLED)
- if (rendering_driver == "vulkan") {
+ if (context_vulkan) {
context_vulkan->window_resize(window_id, wd.size.width, wd.size.height);
}
#endif
@@ -4672,12 +4672,12 @@ DisplayServerX11::~DisplayServerX11() {
//destroy all windows
for (KeyValue<WindowID, WindowData> &E : windows) {
#ifdef VULKAN_ENABLED
- if (rendering_driver == "vulkan") {
+ if (context_vulkan) {
context_vulkan->window_destroy(E.key);
}
#endif
#ifdef GLES3_ENABLED
- if (rendering_driver == "opengl3") {
+ if (gl_manager) {
gl_manager->window_destroy(E.key);
}
#endif
@@ -4693,15 +4693,15 @@ DisplayServerX11::~DisplayServerX11() {
//destroy drivers
#if defined(VULKAN_ENABLED)
- if (rendering_driver == "vulkan") {
- if (rendering_device_vulkan) {
- rendering_device_vulkan->finalize();
- memdelete(rendering_device_vulkan);
- }
+ if (rendering_device_vulkan) {
+ rendering_device_vulkan->finalize();
+ memdelete(rendering_device_vulkan);
+ rendering_device_vulkan = nullptr;
+ }
- if (context_vulkan) {
- memdelete(context_vulkan);
- }
+ if (context_vulkan) {
+ memdelete(context_vulkan);
+ context_vulkan = nullptr;
}
#endif
diff --git a/platform/osx/display_server_osx.mm b/platform/osx/display_server_osx.mm
index fec5c98a99..7cd51611b3 100644
--- a/platform/osx/display_server_osx.mm
+++ b/platform/osx/display_server_osx.mm
@@ -167,12 +167,12 @@ static NSCursor *_cursorFromSelector(SEL selector, SEL fallback = nil) {
}
#if defined(GLES3_ENABLED)
- if (DS_OSX->rendering_driver == "opengl3") {
+ if (DS_OSX->gl_manager) {
DS_OSX->gl_manager->window_destroy(window_id);
}
#endif
#ifdef VULKAN_ENABLED
- if (DS_OSX->rendering_driver == "vulkan") {
+ if (DS_OSX->context_vulkan) {
DS_OSX->context_vulkan->window_destroy(window_id);
}
#endif
@@ -272,12 +272,12 @@ static NSCursor *_cursorFromSelector(SEL selector, SEL fallback = nil) {
}
#if defined(GLES3_ENABLED)
- if (DS_OSX->rendering_driver == "opengl3") {
+ if (DS_OSX->gl_manager) {
DS_OSX->gl_manager->window_resize(window_id, wd.size.width, wd.size.height);
}
#endif
#if defined(VULKAN_ENABLED)
- if (DS_OSX->rendering_driver == "vulkan") {
+ if (DS_OSX->context_vulkan) {
DS_OSX->context_vulkan->window_resize(window_id, wd.size.width, wd.size.height);
}
#endif
@@ -403,7 +403,7 @@ static NSCursor *_cursorFromSelector(SEL selector, SEL fallback = nil) {
- (CALayer *)makeBackingLayer {
#if defined(VULKAN_ENABLED)
- if (DS_OSX->rendering_driver == "vulkan") {
+ if (DS_OSX->context_vulkan) {
CALayer *layer = [[CAMetalLayer class] layer];
return layer;
}
@@ -413,12 +413,12 @@ static NSCursor *_cursorFromSelector(SEL selector, SEL fallback = nil) {
- (void)updateLayer {
#if defined(GLES3_ENABLED)
- if (DS_OSX->rendering_driver == "opengl3") {
+ if (DS_OSX->gl_manager) {
DS_OSX->gl_manager->window_update(window_id);
}
#endif
#if defined(VULKAN_ENABLED)
- if (DS_OSX->rendering_driver == "vulkan") {
+ if (DS_OSX->context_vulkan) {
[super updateLayer];
}
#endif
@@ -2577,12 +2577,12 @@ void DisplayServerOSX::_set_window_per_pixel_transparency_enabled(bool p_enabled
[layer setOpaque:NO];
}
#if defined(VULKAN_ENABLED)
- if (rendering_driver == "vulkan") {
+ if (context_vulkan) {
//TODO - implement transparency for Vulkan
}
#endif
#if defined(GLES3_ENABLED)
- if (rendering_driver == "opengl3") {
+ if (gl_manager) {
//TODO - reimplement OpenGLES
}
#endif
@@ -2596,24 +2596,24 @@ void DisplayServerOSX::_set_window_per_pixel_transparency_enabled(bool p_enabled
[layer setOpaque:YES];
}
#if defined(VULKAN_ENABLED)
- if (rendering_driver == "vulkan") {
+ if (context_vulkan) {
//TODO - implement transparency for Vulkan
}
#endif
#if defined(GLES3_ENABLED)
- if (rendering_driver == "opengl3") {
+ if (gl_manager) {
//TODO - reimplement OpenGLES
}
#endif
wd.layered_window = false;
}
#if defined(GLES3_ENABLED)
- if (rendering_driver == "opengl3") {
+ if (gl_manager) {
//TODO - reimplement OpenGLES
}
#endif
#if defined(VULKAN_ENABLED)
- if (rendering_driver == "vulkan") {
+ if (context_vulkan) {
//TODO - implement transparency for Vulkan
}
#endif
@@ -3451,12 +3451,12 @@ void DisplayServerOSX::set_icon(const Ref<Image> &p_icon) {
void DisplayServerOSX::window_set_vsync_mode(DisplayServer::VSyncMode p_vsync_mode, WindowID p_window) {
_THREAD_SAFE_METHOD_
#if defined(GLES3_ENABLED)
- if (rendering_driver == "opengl3") {
+ if (gl_manager) {
gl_manager->swap_buffers();
}
#endif
#if defined(VULKAN_ENABLED)
- if (rendering_driver == "vulkan") {
+ if (context_vulkan) {
context_vulkan->set_vsync_mode(p_window, p_vsync_mode);
}
#endif
@@ -3465,12 +3465,12 @@ void DisplayServerOSX::window_set_vsync_mode(DisplayServer::VSyncMode p_vsync_mo
DisplayServer::VSyncMode DisplayServerOSX::window_get_vsync_mode(WindowID p_window) const {
_THREAD_SAFE_METHOD_
#if defined(GLES3_ENABLED)
- if (rendering_driver == "opengl3") {
+ if (gl_manager) {
return (gl_manager->is_using_vsync() ? DisplayServer::VSyncMode::VSYNC_ENABLED : DisplayServer::VSyncMode::VSYNC_DISABLED);
}
#endif
#if defined(VULKAN_ENABLED)
- if (rendering_driver == "vulkan") {
+ if (context_vulkan) {
return context_vulkan->get_vsync_mode(p_window);
}
#endif
@@ -3586,19 +3586,15 @@ DisplayServerOSX::WindowID DisplayServerOSX::_create_window(WindowMode p_mode, V
}
#if defined(VULKAN_ENABLED)
- if (rendering_driver == "vulkan") {
- if (context_vulkan) {
- Error err = context_vulkan->window_create(window_id_counter, p_vsync_mode, wd.window_view, p_rect.size.width, p_rect.size.height);
- ERR_FAIL_COND_V_MSG(err != OK, INVALID_WINDOW_ID, "Can't create a Vulkan context");
- }
+ if (context_vulkan) {
+ Error err = context_vulkan->window_create(window_id_counter, p_vsync_mode, wd.window_view, p_rect.size.width, p_rect.size.height);
+ ERR_FAIL_COND_V_MSG(err != OK, INVALID_WINDOW_ID, "Can't create a Vulkan context");
}
#endif
#if defined(GLES3_ENABLED)
- if (rendering_driver == "opengl3") {
- if (gl_manager) {
- Error err = gl_manager->window_create(window_id_counter, wd.window_view, p_rect.size.width, p_rect.size.height);
- ERR_FAIL_COND_V_MSG(err != OK, INVALID_WINDOW_ID, "Can't create an OpenGL context");
- }
+ if (gl_manager) {
+ Error err = gl_manager->window_create(window_id_counter, wd.window_view, p_rect.size.width, p_rect.size.height);
+ ERR_FAIL_COND_V_MSG(err != OK, INVALID_WINDOW_ID, "Can't create an OpenGL context");
}
#endif
id = window_id_counter++;
@@ -3618,12 +3614,12 @@ DisplayServerOSX::WindowID DisplayServerOSX::_create_window(WindowMode p_mode, V
}
#if defined(GLES3_ENABLED)
- if (rendering_driver == "opengl3") {
+ if (gl_manager) {
gl_manager->window_resize(id, wd.size.width, wd.size.height);
}
#endif
#if defined(VULKAN_ENABLED)
- if (rendering_driver == "vulkan") {
+ if (context_vulkan) {
context_vulkan->window_resize(id, wd.size.width, wd.size.height);
}
#endif
diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp
index f83029e662..899cf5dfad 100644
--- a/platform/windows/display_server_windows.cpp
+++ b/platform/windows/display_server_windows.cpp
@@ -538,12 +538,12 @@ void DisplayServerWindows::delete_sub_window(WindowID p_window) {
}
#ifdef VULKAN_ENABLED
- if (rendering_driver == "vulkan") {
+ if (context_vulkan) {
context_vulkan->window_destroy(p_window);
}
#endif
#ifdef GLES3_ENABLED
- if (rendering_driver == "opengl3") {
+ if (gl_manager) {
gl_manager->window_destroy(p_window);
}
#endif
@@ -828,12 +828,12 @@ void DisplayServerWindows::window_set_size(const Size2i p_size, WindowID p_windo
wd.height = h;
#if defined(VULKAN_ENABLED)
- if (rendering_driver == "vulkan") {
+ if (context_vulkan) {
context_vulkan->window_resize(p_window, w, h);
}
#endif
#if defined(GLES3_ENABLED)
- if (rendering_driver == "opengl3") {
+ if (gl_manager) {
gl_manager->window_resize(p_window, w, h);
}
#endif
@@ -2646,7 +2646,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
windows[window_id].height = window_h;
#if defined(VULKAN_ENABLED)
- if ((rendering_driver == "vulkan") && window_created) {
+ if (context_vulkan && window_created) {
context_vulkan->window_resize(window_id, windows[window_id].width, windows[window_id].height);
}
#endif
@@ -3108,7 +3108,7 @@ DisplayServer::WindowID DisplayServerWindows::_create_window(WindowMode p_mode,
}
#ifdef VULKAN_ENABLED
- if (rendering_driver == "vulkan") {
+ if (context_vulkan) {
if (context_vulkan->window_create(id, p_vsync_mode, wd.hWnd, hInstance, WindowRect.right - WindowRect.left, WindowRect.bottom - WindowRect.top) == -1) {
memdelete(context_vulkan);
context_vulkan = nullptr;
@@ -3119,7 +3119,7 @@ DisplayServer::WindowID DisplayServerWindows::_create_window(WindowMode p_mode,
#endif
#ifdef GLES3_ENABLED
- if (rendering_driver == "opengl3") {
+ if (gl_manager) {
Error err = gl_manager->window_create(id, wd.hWnd, hInstance, WindowRect.right - WindowRect.left, WindowRect.bottom - WindowRect.top);
ERR_FAIL_COND_V_MSG(err != OK, INVALID_WINDOW_ID, "Failed to create an OpenGL window.");
}
@@ -3458,7 +3458,7 @@ DisplayServerWindows::~DisplayServerWindows() {
if (windows.has(MAIN_WINDOW_ID)) {
#ifdef VULKAN_ENABLED
- if (rendering_driver == "vulkan") {
+ if (context_vulkan) {
context_vulkan->window_destroy(MAIN_WINDOW_ID);
}
#endif
@@ -3470,14 +3470,15 @@ DisplayServerWindows::~DisplayServerWindows() {
}
#if defined(VULKAN_ENABLED)
- if (rendering_driver == "vulkan") {
- if (rendering_device_vulkan) {
- rendering_device_vulkan->finalize();
- memdelete(rendering_device_vulkan);
- }
+ if (rendering_device_vulkan) {
+ rendering_device_vulkan->finalize();
+ memdelete(rendering_device_vulkan);
+ rendering_device_vulkan = nullptr;
+ }
- if (context_vulkan)
- memdelete(context_vulkan);
+ if (context_vulkan) {
+ memdelete(context_vulkan);
+ context_vulkan = nullptr;
}
#endif
diff --git a/platform/windows/display_server_windows.h b/platform/windows/display_server_windows.h
index a59f8ebb44..fec449ebce 100644
--- a/platform/windows/display_server_windows.h
+++ b/platform/windows/display_server_windows.h
@@ -305,12 +305,12 @@ class DisplayServerWindows : public DisplayServer {
Point2i center;
#if defined(GLES3_ENABLED)
- GLManager_Windows *gl_manager;
+ GLManager_Windows *gl_manager = nullptr;
#endif
#if defined(VULKAN_ENABLED)
- VulkanContextWindows *context_vulkan;
- RenderingDeviceVulkan *rendering_device_vulkan;
+ VulkanContextWindows *context_vulkan = nullptr;
+ RenderingDeviceVulkan *rendering_device_vulkan = nullptr;
#endif
Map<int, Vector2> touch_state;