Set up a TerrainViewController with an MTKView

This commit is contained in:
Eryn Wells 2018-11-03 09:55:46 -04:00
parent 28caab9052
commit 75f23a94a4
3 changed files with 36 additions and 2 deletions

View file

@ -0,0 +1,29 @@
//
// TerrainViewController.swift
// Terrain
//
// Created by Eryn Wells on 11/3/18.
// Copyright © 2018 Eryn Wells. All rights reserved.
//
import Cocoa
import MetalKit
class TerrainViewController: NSViewController {
private var metalView: MTKView! {
return view as? MTKView
}
override func loadView() {
guard let device = MTLCreateSystemDefaultDevice() else {
return
}
let v = MTKView(frame: CGRect(), device: device)
v.translatesAutoresizingMaskIntoConstraints = false
v.widthAnchor.constraint(greaterThanOrEqualToConstant: 640).isActive = true
v.heightAnchor.constraint(greaterThanOrEqualToConstant: 480).isActive = true
view = v
}
}