Initial support for building and running SDL platform on macOS

This commit is contained in:
2025-04-20 15:57:18 +03:00
parent ef8f6b8d47
commit 26012d0b74
10 changed files with 113 additions and 14 deletions

View File

@@ -423,11 +423,15 @@ String MacPlatform::GetMainDirectory()
return path;
}
#if !PLATFORM_SDL
Window* MacPlatform::CreateWindow(const CreateWindowSettings& settings)
{
return New<MacWindow>(settings);
}
#endif
int32 MacPlatform::CreateProcess(CreateProcessSettings& settings)
{
LOG(Info, "Command: {0} {1}", settings.FileName, settings.Arguments);

View File

@@ -1,6 +1,6 @@
// Copyright (c) Wojciech Figat. All rights reserved.
#if PLATFORM_MAC
#if PLATFORM_MAC && !PLATFORM_SDL
#include "../Window.h"
#include "Engine/Platform/Apple/AppleUtils.h"

View File

@@ -2,11 +2,81 @@
#if PLATFORM_SDL && PLATFORM_MAC
static_assert(false, "TODO");
#include "SDLWindow.h"
#include "Engine/Core/Log.h"
#include "Engine/Core/Collections/Array.h"
#include "Engine/Engine/CommandLine.h"
#include "Engine/Engine/Engine.h"
#include "Engine/Engine/Time.h"
#include "Engine/Graphics/RenderTask.h"
#include "Engine/Input/Input.h"
#include "Engine/Input/Mouse.h"
#include "Engine/Platform/IGuiData.h"
#include "Engine/Platform/MessageBox.h"
#include "Engine/Platform/Platform.h"
#include "Engine/Platform/WindowsManager.h"
#include "Engine/Platform/Base/DragDropHelper.h"
#include "Engine/Platform/SDL/SDLClipboard.h"
#include "Engine/Platform/Unix/UnixFile.h"
#include "Engine/Profiler/ProfilerCPU.h"
#include "Engine/Platform/Linux/IncludeX11.h"
#include <SDL3/SDL_events.h>
#include <SDL3/SDL_hints.h>
#include <SDL3/SDL_messagebox.h>
#include <SDL3/SDL_mouse.h>
#include <SDL3/SDL_system.h>
#include <SDL3/SDL_timer.h>
#include <SDL3/SDL_video.h>
bool SDLPlatform::InitInternal()
{
return false;
}
bool SDLPlatform::UsesWindows()
{
return false;
}
bool SDLPlatform::UsesWayland()
{
return false;
}
bool SDLPlatform::UsesX11()
{
return false;
}
void SDLPlatform::PreHandleEvents()
{
}
void SDLPlatform::PostHandleEvents()
{
}
bool SDLWindow::HandleEventInternal(SDL_Event& event)
{
return false;
}
void SDLPlatform::SetHighDpiAwarenessEnabled(bool enable)
{
// TODO: This is now called before Platform::Init, ensure the scaling is changed accordingly during Platform::Init (see ApplePlatform::SetHighDpiAwarenessEnabled)
}
DragDropEffect SDLWindow::DoDragDrop(const StringView& data)
{
return DragDropEffect::None;
}
DragDropEffect SDLWindow::DoDragDrop(const StringView& data, const Float2& offset, Window* dragSourceWindow)
{
Show();
return DragDropEffect::None;
}
#endif

View File

@@ -11,7 +11,10 @@ typedef struct tagMSG MSG;
#elif PLATFORM_LINUX
#include "Engine/Platform/Linux/LinuxPlatform.h"
union _XEvent;
#elif PLATFORM_MAC
#include "Engine/Platform/Mac/MacPlatform.h"
#else
static_assert(false, "Unsupported Platform");
#endif
class SDLWindow;
@@ -29,8 +32,13 @@ class FLAXENGINE_API SDLPlatform
: public LinuxPlatform
{
using base = LinuxPlatform;
#elif PLATFORM_MAC
: public MacPlatform
{
using base = MacPlatform;
#else
{
static_assert(false, "Unsupported Platform");
#endif
friend SDLWindow;

View File

@@ -30,6 +30,10 @@
#endif
#elif PLATFORM_LINUX
#include "Engine/Platform/Linux/IncludeX11.h"
#elif PLATFORM_MAC
#else
static_assert(false, "Unsupported Platform");
#endif
#define DefaultDPI 96

View File

@@ -265,10 +265,12 @@ class AppleThread;
typedef AppleThread Thread;
class MacClipboard;
typedef MacClipboard Clipboard;
#if !PLATFORM_SDL
class MacPlatform;
typedef MacPlatform Platform;
class MacWindow;
typedef MacWindow Window;
#endif
class UnixNetwork;
typedef UnixNetwork Network;
class UserBase;