From 3dd25bd4c04d1c78ded11a738dbd2694161a464e Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Tue, 12 Mar 2019 16:10:27 +0200 Subject: [PATCH] - implemented OpenGL / Vulkan switch in Cocoa backend --- src/posix/cocoa/i_video.mm | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index 57d2f3bdb..1b6b5815f 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -95,6 +95,7 @@ EXTERN_CVAR(Bool, vid_vsync) EXTERN_CVAR(Bool, vid_hidpi) EXTERN_CVAR(Int, vid_defwidth) EXTERN_CVAR(Int, vid_defheight) +EXTERN_CVAR(Int, vid_backend) CUSTOM_CVAR(Bool, vid_autoswitch, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { @@ -342,7 +343,7 @@ class CocoaVideo : public IVideo public: CocoaVideo() { - ms_isVulkanSupported = true; // todo + ms_isVulkanEnabled = vid_backend == 0 && NSAppKitVersionNumber >= 1404; // NSAppKitVersionNumber10_11 } ~CocoaVideo() @@ -359,7 +360,7 @@ public: SystemBaseFrameBuffer *fb = nullptr; - if (ms_isVulkanSupported) + if (ms_isVulkanEnabled) { const NSRect contentRect = [ms_window contentRectForFrameRect:[ms_window frame]]; @@ -380,7 +381,7 @@ public: } catch (std::exception const&) { - ms_isVulkanSupported = false; + ms_isVulkanEnabled = false; SetupOpenGLView(ms_window); } @@ -402,23 +403,18 @@ public: return ms_window; } - static bool IsVulkanSupported() - { - return ms_isVulkanSupported; - } - private: VulkanDevice *m_vulkanDevice = nullptr; static CocoaWindow* ms_window; - static bool ms_isVulkanSupported; + static bool ms_isVulkanEnabled; }; CocoaWindow* CocoaVideo::ms_window; -bool CocoaVideo::ms_isVulkanSupported; +bool CocoaVideo::ms_isVulkanEnabled; // ---------------------------------------------------------------------------