summaryrefslogtreecommitdiffstats
path: root/NativeApp/Apple/Source/Classes/iOS/MetalView.mm
blob: c56049fc1552516e9320dd44b095286f3e366eba (plain)
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
#import "MetalView.h"

#import <QuartzCore/CAMetalLayer.h>

#include "GraphicsTypes.h"

@implementation MetalView

+ (Class) layerClass
{
    return [CAMetalLayer class];
}

- (instancetype) initWithCoder:(NSCoder*)coder
{
    if ((self = [super initWithCoder:coder]))
	{
        [self initApp:(int)Diligent::RENDER_DEVICE_TYPE_METAL];
    }

    return self;
}

- (void) drawView:(id)sender
{
    // There is no autorelease pool when this method is called
    // because it will be called from a background thread.
    // It's important to create one or app can leak objects.
    @autoreleasepool
    {
        [self render];
    }
}

- (void) dealloc
{
    [self terminate];
    [super dealloc];
}

@end