mirror of
https://github.com/love2d/love.git
synced 2026-08-17 11:00:31 +02:00
metal: implement vsync toggle on macOS
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user