From a6dce6861d00d8066770d3d55c83584cc425cb09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Sun, 20 Mar 2022 10:02:31 +0100 Subject: [PATCH] macOS fixes --- .../OpenGLRenderer/Wrapper/Win32/EGLContextWin32.hpp | 2 +- include/Nazara/Platform/WindowHandle.hpp | 6 ++++++ src/Nazara/Platform/SDL2/WindowImpl.cpp | 9 ++++++++- src/Nazara/VulkanRenderer/VulkanSurface.cpp | 1 + xmake.lua | 3 ++- 5 files changed, 18 insertions(+), 3 deletions(-) diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Win32/EGLContextWin32.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Win32/EGLContextWin32.hpp index 00176a8af..b9bc8fb11 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Win32/EGLContextWin32.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/Win32/EGLContextWin32.hpp @@ -21,7 +21,7 @@ namespace Nz::GL EGLContextWin32(EGLContextWin32&&) = default; ~EGLContextWin32() = default; - bool Create(const ContextParams& params, const EGLContextBase* shareContext = nullptr); + bool Create(const ContextParams& params, const EGLContextBase* shareContext = nullptr) override; bool Create(const ContextParams& params, WindowHandle window, const EGLContextBase* shareContext = nullptr) override; void Destroy() override; diff --git a/include/Nazara/Platform/WindowHandle.hpp b/include/Nazara/Platform/WindowHandle.hpp index a5322352e..1bac1489f 100644 --- a/include/Nazara/Platform/WindowHandle.hpp +++ b/include/Nazara/Platform/WindowHandle.hpp @@ -16,6 +16,7 @@ namespace Nz { Invalid, + Cocoa, X11, Wayland, Windows @@ -27,6 +28,11 @@ namespace Nz union { + struct + { + void* window; //< NSWindow* + } cocoa; + struct { void* display; //< Display* diff --git a/src/Nazara/Platform/SDL2/WindowImpl.cpp b/src/Nazara/Platform/SDL2/WindowImpl.cpp index fa4031778..1e20e8002 100644 --- a/src/Nazara/Platform/SDL2/WindowImpl.cpp +++ b/src/Nazara/Platform/SDL2/WindowImpl.cpp @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include @@ -202,6 +201,14 @@ namespace Nz switch (wmInfo.subsystem) { +#if defined(SDL_VIDEO_DRIVER_COCOA) + case SDL_SYSWM_COCOA: + { + handle.type = WindowManager::Cocoa; + handle.cocoa.window = wmInfo.info.cocoa.window; + break; + } +#endif #if defined(SDL_VIDEO_DRIVER_X11) case SDL_SYSWM_X11: { diff --git a/src/Nazara/VulkanRenderer/VulkanSurface.cpp b/src/Nazara/VulkanRenderer/VulkanSurface.cpp index c26d028e1..efd66e7f1 100644 --- a/src/Nazara/VulkanRenderer/VulkanSurface.cpp +++ b/src/Nazara/VulkanRenderer/VulkanSurface.cpp @@ -59,6 +59,7 @@ namespace Nz } } } + #elif defined(NAZARA_PLATFORM_MACOS) #else #error This OS is not supported by Vulkan #endif diff --git a/xmake.lua b/xmake.lua index dd1aeafbd..25b50cb7f 100644 --- a/xmake.lua +++ b/xmake.lua @@ -72,6 +72,7 @@ local modules = { add_defines("SDL_VIDEO_DRIVER_WAYLAND=1") elseif is_plat("macosx") then add_defines("SDL_VIDEO_DRIVER_COCOA=1") + add_sysincludedirs("/opt/X11/include") end end }, @@ -101,7 +102,7 @@ local modules = { add_defines("VK_USE_PLATFORM_XLIB_KHR") add_defines("VK_USE_PLATFORM_WAYLAND_KHR") elseif is_plat("macosx") then - add_defines("VK_USE_PLATFORM_MACOS_MVK") + add_defines("VK_USE_PLATFORM_METAL_EXT") end end },