diff --git a/Terrain.xcodeproj/project.pbxproj b/Terrain.xcodeproj/project.pbxproj index 59b1b51..5a82fac 100644 --- a/Terrain.xcodeproj/project.pbxproj +++ b/Terrain.xcodeproj/project.pbxproj @@ -10,6 +10,7 @@ C0C15A8E218DDD85007494E2 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0C15A8D218DDD85007494E2 /* AppDelegate.swift */; }; C0C15A90218DDD87007494E2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C0C15A8F218DDD87007494E2 /* Assets.xcassets */; }; C0C15A93218DDD87007494E2 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = C0C15A91218DDD87007494E2 /* MainMenu.xib */; }; + C0C15A9D218DDDC3007494E2 /* TerrainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0C15A9B218DDDC3007494E2 /* TerrainViewController.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -19,6 +20,7 @@ C0C15A92218DDD87007494E2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; C0C15A94218DDD87007494E2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; C0C15A95218DDD87007494E2 /* Terrain.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Terrain.entitlements; sourceTree = ""; }; + C0C15A9B218DDDC3007494E2 /* TerrainViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TerrainViewController.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -52,6 +54,7 @@ isa = PBXGroup; children = ( C0C15A8D218DDD85007494E2 /* AppDelegate.swift */, + C0C15A9B218DDDC3007494E2 /* TerrainViewController.swift */, C0C15A8F218DDD87007494E2 /* Assets.xcassets */, C0C15A91218DDD87007494E2 /* MainMenu.xib */, C0C15A94218DDD87007494E2 /* Info.plist */, @@ -130,6 +133,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + C0C15A9D218DDDC3007494E2 /* TerrainViewController.swift in Sources */, C0C15A8E218DDD85007494E2 /* AppDelegate.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Terrain/AppDelegate.swift b/Terrain/AppDelegate.swift index 8a6a18c..8c57d74 100644 --- a/Terrain/AppDelegate.swift +++ b/Terrain/AppDelegate.swift @@ -13,9 +13,10 @@ class AppDelegate: NSObject, NSApplicationDelegate { @IBOutlet weak var window: NSWindow! - func applicationDidFinishLaunching(_ aNotification: Notification) { - // Insert code here to initialize your application + let terrainVC = TerrainViewController() + window.contentViewController = terrainVC + window.makeKeyAndOrderFront(nil) } func applicationWillTerminate(_ aNotification: Notification) { diff --git a/Terrain/TerrainViewController.swift b/Terrain/TerrainViewController.swift new file mode 100644 index 0000000..6e7cc22 --- /dev/null +++ b/Terrain/TerrainViewController.swift @@ -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 + } + +}