Skip to content

Commit

Permalink
- implemented OpenGL / Vulkan switch in Cocoa backend
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-lysiuk committed Mar 12, 2019
1 parent 7b5eede commit 3dd25bd
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/posix/cocoa/i_video.mm
Expand Up @@ -95,6 +95,7 @@ - (void)enterFullscreenOnZoom
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)
{
Expand Down Expand Up @@ -342,7 +343,7 @@ void SetupOpenGLView(CocoaWindow* window)
public:
CocoaVideo()
{
ms_isVulkanSupported = true; // todo
ms_isVulkanEnabled = vid_backend == 0 && NSAppKitVersionNumber >= 1404; // NSAppKitVersionNumber10_11
}

~CocoaVideo()
Expand All @@ -359,7 +360,7 @@ void SetupOpenGLView(CocoaWindow* window)

SystemBaseFrameBuffer *fb = nullptr;

if (ms_isVulkanSupported)
if (ms_isVulkanEnabled)
{
const NSRect contentRect = [ms_window contentRectForFrameRect:[ms_window frame]];

Expand All @@ -380,7 +381,7 @@ void SetupOpenGLView(CocoaWindow* window)
}
catch (std::exception const&)
{
ms_isVulkanSupported = false;
ms_isVulkanEnabled = false;

SetupOpenGLView(ms_window);
}
Expand All @@ -402,23 +403,18 @@ void SetupOpenGLView(CocoaWindow* window)
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;


// ---------------------------------------------------------------------------
Expand Down

0 comments on commit 3dd25bd

Please sign in to comment.