metal: implement vsync toggle on macOS

This commit is contained in:
Alex Szpakowski
2021-03-27 22:40:29 -03:00
parent 1e85e1b414
commit 0d94530374
3 changed files with 64 additions and 8 deletions
+27
View File
@@ -24,6 +24,7 @@
#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
#import <QuartzCore/CAMetalLayer.h>
#ifdef LOVE_MACOSX_SDL_DIRECT_INCLUDE
# include <SDL.h>
@@ -85,6 +86,32 @@ void requestAttention(bool continuous)
}
}
void setMetalLayerVSync(void *metallayer, bool vsync)
{
@autoreleasepool
{
if (@available(macOS 10.13, *))
{
CAMetalLayer *layer = (__bridge CAMetalLayer *) metallayer;
layer.displaySyncEnabled = vsync;
}
}
}
bool getMetalLayerVSync(void *metallayer)
{
@autoreleasepool
{
if (@available(macOS 10.13, *))
{
CAMetalLayer *layer = (__bridge CAMetalLayer *) metallayer;
return layer.displaySyncEnabled;
}
}
return true;
}
} // osx
} // love