-
Notifications
You must be signed in to change notification settings - Fork 70
/
appleutils.mm
53 lines (42 loc) · 1.39 KB
/
appleutils.mm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifdef VK_USE_PLATFORM_METAL_EXT
#import <Foundation/Foundation.h>
#import <QuartzCore/CAMetalLayer.h>
#include <TargetConditionals.h>
#if TARGET_OS_IPHONE
#include <UIKit/UIView.h>
#else
#import <AppKit/AppKit.h>
#endif
#import <Metal/Metal.h>
#import <MetalKit/MetalKit.h>
extern "C" void setWorkingFolderForiOS(void)
{
// On iOS, only the document directory for the app can be read/written from.
// This function just sets that as the current working folder.
NSArray *docPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *myPath = [docPath objectAtIndex:0];
chdir( [myPath UTF8String]);
}
extern "C" const char *getWorkingFolderForiOS(void)
{
static char cWorkingFolder[512];
NSArray *docPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *myPath = [docPath objectAtIndex:0];
strncpy(cWorkingFolder, [myPath UTF8String], 512);
return cWorkingFolder;
}
extern "C" void *makeViewMetalCompatible(void* handle)
{
#if TARGET_OS_IPHONE
UIView* view = (__bridge UIView*)handle;
assert([view isKindOfClass:[UIView class]]);
void *pLayer =(__bridge void*)view.layer;
return pLayer;
#else
NSView* view = (__bridge NSView*)handle;
assert([view isKindOfClass:[NSView class]]);
void *pLayer = (__bridge void *)view.layer;
return pLayer;
#endif
}
#endif