Initial source code support for SDL3. No build system support.

This commit is contained in:
Sasha Szpakowski
2024-02-04 17:02:26 -04:00
parent 5acc98ce43
commit 62ac858f30
23 changed files with 1622 additions and 161 deletions
+8 -2
View File
@@ -21,15 +21,21 @@
#include "delay.h"
#include <SDL_timer.h>
#include <SDL_version.h>
namespace love
{
void sleep(unsigned int ms)
// TODO: use ns.
void sleep(double ms)
{
// We don't need to initialize the SDL timer subsystem for SDL_Delay to
// function - and doing so causes SDL to create a worker thread.
SDL_Delay(ms);
#if SDL_VERSION_ATLEAST(3, 0, 0)
SDL_DelayNS(SDL_MS_TO_NS(ms));
#else
SDL_Delay((Uint32)ms);
#endif
}
} // love
+1 -1
View File
@@ -24,7 +24,7 @@
namespace love
{
void sleep(unsigned int ms);
void sleep(double ms);
} // namespace love
+15 -4
View File
@@ -26,12 +26,9 @@
#import <Cocoa/Cocoa.h>
#import <QuartzCore/CAMetalLayer.h>
#ifdef LOVE_MACOSX_SDL_DIRECT_INCLUDE
#include <SDL.h>
#if !SDL_VERSION_ATLEAST(3, 0, 0)
#include <SDL_syswm.h>
#else
#include <SDL2/SDL.h>
#include <SDL2/SDL_syswm.h>
#endif
namespace love
@@ -63,6 +60,13 @@ std::string checkDropEvents()
SDL_InitSubSystem(SDL_INIT_VIDEO);
SDL_PumpEvents();
#if SDL_VERSION_ATLEAST(3, 0, 0)
if (SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_EVENT_DROP_FILE, SDL_EVENT_DROP_FILE) > 0)
{
if (event.type == SDL_EVENT_DROP_FILE)
dropstr = std::string(event.drop.data);
}
#else
if (SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_DROPFILE, SDL_DROPFILE) > 0)
{
if (event.type == SDL_DROPFILE)
@@ -71,6 +75,7 @@ std::string checkDropEvents()
SDL_free(event.drop.file);
}
}
#endif
SDL_QuitSubSystem(SDL_INIT_VIDEO);
@@ -122,9 +127,15 @@ void setWindowSRGBColorSpace(SDL_Window *window)
// (at least, it was back when I tested in December 2016).
if (@available(macOS 11.0, *))
{
#if SDL_VERSION_ATLEAST(3, 0, 0)
SDL_PropertiesID props = SDL_GetWindowProperties(window);
NSWindow *window = (__bridge NSWindow *) SDL_GetProperty(props, SDL_PROP_WINDOW_COCOA_WINDOW_POINTER, nullptr);
window.colorSpace = [NSColorSpace sRGBColorSpace];
#else
SDL_SysWMinfo info = {};
if (SDL_GetWindowWMInfo(window, &info))
info.info.cocoa.window.colorSpace = [NSColorSpace sRGBColorSpace];
#endif
}
}
}