├── macOSMetal
├── Assets.xcassets
│ ├── Contents.json
│ └── AppIcon.appiconset
│ │ └── Contents.json
├── macOSMetal.entitlements
├── Node
│ ├── Node.swift
│ ├── CubeScene.swift
│ ├── Scene.swift
│ ├── Cube.swift
│ └── Primitive.swift
├── AppDelegate.swift
├── Types.swift
├── MetalView.swift
├── Info.plist
├── Shaders.metal
├── Renderer.swift
├── Math.swift
└── Base.lproj
│ └── Main.storyboard
└── macOSMetal.xcodeproj
├── project.xcworkspace
├── contents.xcworkspacedata
└── xcshareddata
│ └── IDEWorkspaceChecks.plist
├── xcuserdata
└── leif.xcuserdatad
│ └── xcschemes
│ └── xcschememanagement.plist
└── project.pbxproj
/macOSMetal/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/macOSMetal.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/macOSMetal.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/macOSMetal/macOSMetal.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.security.app-sandbox
6 |
7 | com.apple.security.files.user-selected.read-only
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/macOSMetal.xcodeproj/xcuserdata/leif.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | macOSMetal.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/macOSMetal/Node/Node.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Node.swift
3 | // macOSMetal
4 | //
5 | // Created by Zach Eriksen on 6/29/18.
6 | // Copyright © 2018 Zach Eriksen. All rights reserved.
7 | //
8 |
9 | import MetalKit
10 |
11 | class Node {
12 | var childern: [Node] = []
13 |
14 | func add(child: Node) {
15 | childern.append(child)
16 | }
17 |
18 | func render(commandEncoder: MTLRenderCommandEncoder, deltaTime: Float) {
19 | childern.forEach{ $0.render(commandEncoder: commandEncoder, deltaTime: deltaTime) }
20 | }
21 | }
22 |
23 |
--------------------------------------------------------------------------------
/macOSMetal/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // macOSMetal
4 | //
5 | // Created by Zach Eriksen on 4/30/18.
6 | // Copyright © 2018 Zach Eriksen. All rights reserved.
7 | //
8 |
9 | import Cocoa
10 |
11 | @NSApplicationMain
12 | class AppDelegate: NSObject, NSApplicationDelegate {
13 |
14 |
15 |
16 | func applicationDidFinishLaunching(_ aNotification: Notification) {
17 | // Insert code here to initialize your application
18 | }
19 |
20 | func applicationWillTerminate(_ aNotification: Notification) {
21 | // Insert code here to tear down your application
22 | }
23 |
24 |
25 | }
26 |
27 |
--------------------------------------------------------------------------------
/macOSMetal/Types.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Types.swift
3 | // macOSMetal
4 | //
5 | // Created by Zach Eriksen on 6/29/18.
6 | // Copyright © 2018 Zach Eriksen. All rights reserved.
7 | //
8 |
9 | import MetalKit
10 |
11 | struct Vertex {
12 | var position: float3
13 | var color: float4
14 | }
15 |
16 | struct ModelConstraints {
17 | var modelMatrix = matrix_identity_float4x4
18 | }
19 |
20 | struct SceneConstraints {
21 | var projectionMatrix = matrix_identity_float4x4
22 | }
23 |
24 | protocol Constraintable {
25 | func scale(axis: float3)
26 |
27 | func translate(direction: float3)
28 |
29 | func rotate(angle: Float, axis: float3)
30 | }
31 |
--------------------------------------------------------------------------------
/macOSMetal/Node/CubeScene.swift:
--------------------------------------------------------------------------------
1 | //
2 | // CubeScene.swift
3 | // macOSMetal
4 | //
5 | // Created by Zach Eriksen on 6/29/18.
6 | // Copyright © 2018 Zach Eriksen. All rights reserved.
7 | //
8 |
9 | import MetalKit
10 |
11 | class CubeScene: Scene {
12 | override init(device: MTLDevice) {
13 |
14 | super.init(device: device)
15 |
16 | let c = Cube(withDevice: device)
17 | objects.append(c)
18 | c.translate(direction: float3(0,0,-6))
19 | add(child: c)
20 | }
21 |
22 | override func render(commandEncoder: MTLRenderCommandEncoder, deltaTime: Float) {
23 | objects.forEach{ $0.rotate(angle: deltaTime, axis: float3(1,1,0)) }
24 | super.render(commandEncoder: commandEncoder, deltaTime: deltaTime)
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/macOSMetal/Node/Scene.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Scene.swift
3 | // macOSMetal
4 | //
5 | // Created by Zach Eriksen on 6/29/18.
6 | // Copyright © 2018 Zach Eriksen. All rights reserved.
7 | //
8 |
9 | import MetalKit
10 |
11 | class Scene: Node {
12 | var device: MTLDevice!
13 | var sceneConstraints = SceneConstraints()
14 | var objects: [Primitive] = []
15 |
16 | init(device: MTLDevice) {
17 | self.device = device
18 | super.init()
19 | sceneConstraints.projectionMatrix = matrix_float4x4(degreesFov: 45, aspectRatio: 1, nearZ: 0.1, farZ: 100)
20 | }
21 |
22 | override func render(commandEncoder: MTLRenderCommandEncoder, deltaTime: Float) {
23 | commandEncoder.setVertexBytes(&sceneConstraints, length: MemoryLayout.stride, index: 2)
24 | super.render(commandEncoder: commandEncoder, deltaTime: deltaTime)
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/macOSMetal/MetalView.swift:
--------------------------------------------------------------------------------
1 | //
2 | // MetalView.swift
3 | // macOSMetal
4 | //
5 | // Created by Zach Eriksen on 4/30/18.
6 | // Copyright © 2018 Zach Eriksen. All rights reserved.
7 | //
8 |
9 | import MetalKit
10 |
11 | class MetalView: MTKView {
12 | var renderer: Renderer!
13 |
14 | required init(coder: NSCoder) {
15 | super.init(coder: coder)
16 | // Make sure we are on a device that can run metal!
17 | guard let defaultDevice = MTLCreateSystemDefaultDevice() else {
18 | fatalError("Device loading error")
19 | }
20 | device = defaultDevice
21 | depthStencilPixelFormat = .depth32Float
22 | colorPixelFormat = .bgra8Unorm
23 | // Our clear color, can be set to any color
24 | clearColor = MTLClearColor(red: 0.1, green: 0.57, blue: 0.25, alpha: 1)
25 | createRenderer(device: defaultDevice)
26 | }
27 |
28 | func createRenderer(device: MTLDevice){
29 | renderer = Renderer(device: device)
30 | delegate = renderer
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/macOSMetal/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleVersion
22 | 1
23 | LSMinimumSystemVersion
24 | $(MACOSX_DEPLOYMENT_TARGET)
25 | NSHumanReadableCopyright
26 | Copyright © 2018 Zach Eriksen. All rights reserved.
27 | NSMainStoryboardFile
28 | Main
29 | NSPrincipalClass
30 | NSApplication
31 |
32 |
33 |
--------------------------------------------------------------------------------
/macOSMetal/Node/Cube.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Cube.swift
3 | // macOSMetal
4 | //
5 | // Created by Zach Eriksen on 6/29/18.
6 | // Copyright © 2018 Zach Eriksen. All rights reserved.
7 | //
8 |
9 | import MetalKit
10 |
11 | class Cube: Primitive {
12 |
13 | override func buildVertices() {
14 | vertices = [
15 | Vertex(position: float3(-1,1,1), color: float4(1,0,0,1)),
16 | Vertex(position: float3(-1,-1,1), color: float4(0,1,0,1)),
17 | Vertex(position: float3(1,1,1), color: float4(0,0,1,1)),
18 | Vertex(position: float3(1,-1,1), color: float4(1,0,1,1)),
19 | Vertex(position: float3(-1,1,-1), color: float4(1,1,0,1)),
20 | Vertex(position: float3(1,1,-1), color: float4(0,1,1,1)),
21 | Vertex(position: float3(-1,-1,-1), color: float4(0.5,0.5,0,1)),
22 | Vertex(position: float3(1,-1,-1), color: float4(1,0,0.5,1))
23 | ]
24 | indices = [
25 | 0,1,2, 2,1,3, //Front
26 | 5,2,3, 5,3,7,
27 | 0,2,4, 2,5,4,
28 | 0,1,4, 4,1,6,
29 | 5,4,6, 5,6,7,
30 | 3,1,6, 3,6,7
31 |
32 | ]
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/macOSMetal/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "mac",
5 | "size" : "16x16",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "mac",
10 | "size" : "16x16",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "mac",
15 | "size" : "32x32",
16 | "scale" : "1x"
17 | },
18 | {
19 | "idiom" : "mac",
20 | "size" : "32x32",
21 | "scale" : "2x"
22 | },
23 | {
24 | "idiom" : "mac",
25 | "size" : "128x128",
26 | "scale" : "1x"
27 | },
28 | {
29 | "idiom" : "mac",
30 | "size" : "128x128",
31 | "scale" : "2x"
32 | },
33 | {
34 | "idiom" : "mac",
35 | "size" : "256x256",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "mac",
40 | "size" : "256x256",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "mac",
45 | "size" : "512x512",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "mac",
50 | "size" : "512x512",
51 | "scale" : "2x"
52 | }
53 | ],
54 | "info" : {
55 | "version" : 1,
56 | "author" : "xcode"
57 | }
58 | }
--------------------------------------------------------------------------------
/macOSMetal/Shaders.metal:
--------------------------------------------------------------------------------
1 | //
2 | // Shaders.metal
3 | // macOSMetal
4 | //
5 | // Created by Zach Eriksen on 4/30/18.
6 | // Copyright © 2018 Zach Eriksen. All rights reserved.
7 | //
8 |
9 | #include
10 | using namespace metal;
11 |
12 | struct VertexIn {
13 | float3 position [[ attribute(0) ]];
14 | float4 color [[ attribute(1) ]];
15 | };
16 |
17 | struct VertexOut {
18 | float4 position [[ position ]];
19 | float4 color;
20 | };
21 |
22 | struct ModelConstraints {
23 | float4x4 modelMatrix;
24 | };
25 |
26 | struct SceneConstraints {
27 | float4x4 projectionMatrix;
28 | };
29 |
30 | vertex VertexOut basic_vertex_function(VertexIn vIn [[ stage_in ]],
31 | constant ModelConstraints &modelConstants [[ buffer(1) ]],
32 | constant SceneConstraints &sceneConstants [[ buffer(2) ]]) {
33 | VertexOut vOut;
34 | vOut.position = sceneConstants.projectionMatrix * modelConstants.modelMatrix * float4(vIn.position,1);
35 | vOut.color = vIn.color;
36 | return vOut;
37 | }
38 |
39 | fragment float4 basic_fragment_function(VertexOut vIn [[ stage_in ]]) {
40 | return vIn.color;
41 | }
42 |
--------------------------------------------------------------------------------
/macOSMetal/Renderer.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Renderer.swift
3 | // macOSMetal
4 | //
5 | // Created by Zach Eriksen on 4/30/18.
6 | // Copyright © 2018 Zach Eriksen. All rights reserved.
7 | //
8 |
9 | import MetalKit
10 |
11 | class Renderer: NSObject {
12 | var commandQueue: MTLCommandQueue!
13 | var scenes: [Scene] = []
14 |
15 | init(device: MTLDevice) {
16 | super.init()
17 | createCommandQueue(device: device)
18 | scenes.append(CubeScene(device: device))
19 | }
20 |
21 | //MARK: Builders
22 | func createCommandQueue(device: MTLDevice) {
23 | commandQueue = device.makeCommandQueue()
24 | }
25 | }
26 |
27 | extension Renderer: MTKViewDelegate {
28 | func mtkView(_ view: MTKView, drawableSizeWillChange size: CGSize) {}
29 |
30 | func draw(in view: MTKView) {
31 | // Get the current drawable and descriptor
32 | guard let drawable = view.currentDrawable,
33 | let renderPassDescriptor = view.currentRenderPassDescriptor else {
34 | return
35 | }
36 | // Create a buffer from the commandQueue
37 | let commandBuffer = commandQueue.makeCommandBuffer()
38 | let commandEncoder = commandBuffer?.makeRenderCommandEncoder(descriptor: renderPassDescriptor)
39 |
40 | let deltaTime = 1 / Float(view.preferredFramesPerSecond)
41 |
42 | scenes.forEach{ $0.render(commandEncoder: commandEncoder!,
43 | deltaTime: deltaTime) }
44 |
45 | commandEncoder?.endEncoding()
46 | commandBuffer?.present(drawable)
47 | commandBuffer?.commit()
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/macOSMetal/Math.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Math.swift
3 | // macOSMetal
4 | //
5 | // Created by Zach Eriksen on 6/29/18.
6 | // Copyright © 2018 Zach Eriksen. All rights reserved.
7 | //
8 |
9 | import MetalKit
10 |
11 | extension Float {
12 | var rads: Float {
13 | return (self / 180) * Float.pi
14 | }
15 | }
16 |
17 | extension matrix_float4x4 {
18 |
19 | init(degreesFov: Float, aspectRatio: Float, nearZ: Float, farZ: Float) {
20 | let fov = degreesFov.rads
21 |
22 | let y = 1 / tan(fov * 0.5)
23 | let x = y / aspectRatio
24 | let z1 = farZ / (nearZ - farZ)
25 | let w = (z1 * nearZ)
26 |
27 | columns = (
28 | float4(x,0,0,0),
29 | float4(0,y,0,0),
30 | float4(0,0,z1,-1),
31 | float4(0,0,w,0)
32 | )
33 | }
34 |
35 | mutating func scale(axis: float3) {
36 | var result = matrix_identity_float4x4
37 |
38 | let x,y,z :Float
39 | (x,y,z) = (axis.x,axis.y,axis.z)
40 |
41 | result.columns = (
42 | float4(x,0,0,0),
43 | float4(0,y,0,0),
44 | float4(0,0,z,0),
45 | float4(0,0,0,1)
46 | )
47 |
48 | self = matrix_multiply(self, result)
49 | }
50 |
51 | mutating func rotate(angle: Float, axis: float3) {
52 | var result = matrix_identity_float4x4
53 |
54 | let x,y,z :Float
55 | (x,y,z) = (axis.x,axis.y,axis.z)
56 | let c: Float = cos(angle)
57 | let s: Float = sin(angle)
58 |
59 | let mc: Float = (1 - c)
60 |
61 | let r1c1 = x * x * mc + c
62 | let r2c1 = x * y * mc + z * s
63 | let r3c1 = x * z * mc - y * s
64 | let r4c1: Float = 0.0
65 |
66 | let r1c2 = y * x * mc - z * s
67 | let r2c2 = y * y * mc + c
68 | let r3c2 = y * z * mc + x * s
69 | let r4c2: Float = 0.0
70 |
71 | let r1c3 = z * x * mc + y * s
72 | let r2c3 = z * y * mc - x * s
73 | let r3c3 = z * z * mc + c
74 | let r4c3: Float = 0.0
75 |
76 | let r1c4: Float = 0.0
77 | let r2c4: Float = 0.0
78 | let r3c4: Float = 0.0
79 | let r4c4: Float = 1.0
80 |
81 | result.columns = (
82 | float4(r1c1,r2c1,r3c1,r4c1),
83 | float4(r1c2,r2c2,r3c2,r4c2),
84 | float4(r1c3,r2c3,r3c3,r4c3),
85 | float4(r1c4,r2c4,r3c4,r4c4)
86 | )
87 |
88 | self = matrix_multiply(self, result)
89 | }
90 |
91 | mutating func translate(direction: float3) {
92 | var result = matrix_identity_float4x4
93 |
94 | let x,y,z :Float
95 | (x,y,z) = (direction.x,direction.y,direction.z)
96 |
97 | result.columns = (
98 | float4(1,0,0,0),
99 | float4(0,1,0,0),
100 | float4(0,0,1,0),
101 | float4(x,y,z,1)
102 | )
103 |
104 | self = matrix_multiply(self, result)
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/macOSMetal/Node/Primitive.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Primitive.swift
3 | // macOSMetal
4 | //
5 | // Created by Zach Eriksen on 6/29/18.
6 | // Copyright © 2018 Zach Eriksen. All rights reserved.
7 | //
8 |
9 | import MetalKit
10 |
11 | class Primitive: Node {
12 | // Buffers
13 | var vertexBuffer: MTLBuffer!
14 | var indexBuffer: MTLBuffer!
15 | // BufferData
16 | var vertices: [Vertex]!
17 | var indices: [UInt16]!
18 | // States
19 | var renderPipelineState: MTLRenderPipelineState!
20 | var depthStencilState: MTLDepthStencilState!
21 | // Constraints
22 | var modelConstraints = ModelConstraints()
23 |
24 | // MARK: init withDevice
25 | init(withDevice device: MTLDevice) {
26 | super.init()
27 | buildVertices()
28 | buildBuffers(device: device)
29 | buildPipelineState(device: device)
30 | buildDepthStencil(device: device)
31 | }
32 |
33 | public func buildVertices() {
34 |
35 | }
36 |
37 | /// Create the MTLBuffers from the MTLDevice
38 | private func buildBuffers(device: MTLDevice) {
39 | vertexBuffer = device.makeBuffer(bytes: vertices,
40 | length: MemoryLayout.stride * vertices.count,
41 | options: [])
42 | indexBuffer = device.makeBuffer(bytes: indices,
43 | length: MemoryLayout.stride * indices.count,
44 | options: [])
45 | }
46 |
47 | /// Creatre the PipelineState containing the Shader functions
48 | private func buildPipelineState(device: MTLDevice) {
49 | let library = device.makeDefaultLibrary()
50 | // Retrieve the shader functions
51 | let vertexFunction = library?.makeFunction(name: "basic_vertex_function")
52 | let fragmentFunction = library?.makeFunction(name: "basic_fragment_function")
53 |
54 | // Create the renderPiplineDescriptor
55 | let renderPipelineDescriptor = MTLRenderPipelineDescriptor()
56 | renderPipelineDescriptor.colorAttachments[0].pixelFormat = .bgra8Unorm
57 | renderPipelineDescriptor.vertexFunction = vertexFunction
58 | renderPipelineDescriptor.fragmentFunction = fragmentFunction
59 | renderPipelineDescriptor.depthAttachmentPixelFormat = .depth32Float
60 |
61 | // Create the VertexDescriptor
62 | let vertexDescriptor = MTLVertexDescriptor()
63 | vertexDescriptor.attributes[0].bufferIndex = 0
64 | vertexDescriptor.attributes[0].format = .float3
65 | vertexDescriptor.attributes[0].offset = 0
66 |
67 | vertexDescriptor.attributes[1].bufferIndex = 0
68 | vertexDescriptor.attributes[1].format = .float4
69 | vertexDescriptor.attributes[1].offset = MemoryLayout.size
70 |
71 | vertexDescriptor.layouts[0].stride = MemoryLayout.stride
72 |
73 | // Create the PipelineState
74 | renderPipelineDescriptor.vertexDescriptor = vertexDescriptor
75 |
76 | do {
77 | renderPipelineState = try device.makeRenderPipelineState(descriptor: renderPipelineDescriptor)
78 | } catch {
79 | print(error.localizedDescription)
80 | }
81 | }
82 |
83 | // Create DepthStencil
84 | private func buildDepthStencil(device: MTLDevice) {
85 | let depthStencilDescriptor = MTLDepthStencilDescriptor()
86 | depthStencilDescriptor.isDepthWriteEnabled = true
87 | depthStencilDescriptor.depthCompareFunction = .less
88 | depthStencilState = device.makeDepthStencilState(descriptor: depthStencilDescriptor)
89 | }
90 |
91 | // MARK: Render
92 | override func render(commandEncoder: MTLRenderCommandEncoder, deltaTime: Float) {
93 | commandEncoder.setRenderPipelineState(renderPipelineState)
94 | super.render(commandEncoder: commandEncoder, deltaTime: deltaTime)
95 | commandEncoder.setVertexBuffer(vertexBuffer,
96 | offset: 0,
97 | index: 0)
98 | commandEncoder.setDepthStencilState(depthStencilState)
99 | commandEncoder.setVertexBytes(&modelConstraints, length: MemoryLayout.stride, index: 1)
100 | commandEncoder.drawIndexedPrimitives(type: .triangle,
101 | indexCount: indices.count,
102 | indexType: .uint16,
103 | indexBuffer: indexBuffer,
104 | indexBufferOffset: 0)
105 | }
106 | }
107 |
108 | extension Primitive: Constraintable {
109 | func scale(axis: float3) {
110 | modelConstraints.modelMatrix.scale(axis: axis)
111 | }
112 |
113 | func translate(direction: float3) {
114 | modelConstraints.modelMatrix.translate(direction: direction)
115 | }
116 |
117 | func rotate(angle: Float, axis: float3) {
118 | modelConstraints.modelMatrix.rotate(angle: angle, axis: axis)
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/macOSMetal.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 50;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 2900940420E6BD6400CE1EA5 /* Node.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2900940320E6BD6400CE1EA5 /* Node.swift */; };
11 | 2900940720E6BEB300CE1EA5 /* Primitive.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2900940620E6BEB300CE1EA5 /* Primitive.swift */; };
12 | 2900940920E6BF5E00CE1EA5 /* Types.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2900940820E6BF5E00CE1EA5 /* Types.swift */; };
13 | 2900940B20E6C2C100CE1EA5 /* Math.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2900940A20E6C2C100CE1EA5 /* Math.swift */; };
14 | 2900940D20E6C39A00CE1EA5 /* Scene.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2900940C20E6C39A00CE1EA5 /* Scene.swift */; };
15 | 2900940F20E6C3DE00CE1EA5 /* CubeScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2900940E20E6C3DE00CE1EA5 /* CubeScene.swift */; };
16 | 2900941120E6C40900CE1EA5 /* Cube.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2900941020E6C40900CE1EA5 /* Cube.swift */; };
17 | 2942685C2097593A008B0C65 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2942685B2097593A008B0C65 /* AppDelegate.swift */; };
18 | 294268602097593B008B0C65 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2942685F2097593B008B0C65 /* Assets.xcassets */; };
19 | 294268632097593B008B0C65 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 294268612097593B008B0C65 /* Main.storyboard */; };
20 | 2942686C20975A34008B0C65 /* MetalView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2942686B20975A34008B0C65 /* MetalView.swift */; };
21 | 2942686E20975C55008B0C65 /* Renderer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2942686D20975C55008B0C65 /* Renderer.swift */; };
22 | 2942687020976100008B0C65 /* Shaders.metal in Sources */ = {isa = PBXBuildFile; fileRef = 2942686F20976100008B0C65 /* Shaders.metal */; };
23 | /* End PBXBuildFile section */
24 |
25 | /* Begin PBXFileReference section */
26 | 2900940320E6BD6400CE1EA5 /* Node.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Node.swift; sourceTree = ""; };
27 | 2900940620E6BEB300CE1EA5 /* Primitive.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Primitive.swift; sourceTree = ""; };
28 | 2900940820E6BF5E00CE1EA5 /* Types.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Types.swift; sourceTree = ""; };
29 | 2900940A20E6C2C100CE1EA5 /* Math.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Math.swift; sourceTree = ""; };
30 | 2900940C20E6C39A00CE1EA5 /* Scene.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Scene.swift; sourceTree = ""; };
31 | 2900940E20E6C3DE00CE1EA5 /* CubeScene.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CubeScene.swift; sourceTree = ""; };
32 | 2900941020E6C40900CE1EA5 /* Cube.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Cube.swift; sourceTree = ""; };
33 | 294268582097593A008B0C65 /* macOSMetal.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = macOSMetal.app; sourceTree = BUILT_PRODUCTS_DIR; };
34 | 2942685B2097593A008B0C65 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
35 | 2942685F2097593B008B0C65 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
36 | 294268622097593B008B0C65 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
37 | 294268642097593B008B0C65 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
38 | 294268652097593B008B0C65 /* macOSMetal.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = macOSMetal.entitlements; sourceTree = ""; };
39 | 2942686B20975A34008B0C65 /* MetalView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MetalView.swift; sourceTree = ""; };
40 | 2942686D20975C55008B0C65 /* Renderer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Renderer.swift; sourceTree = ""; };
41 | 2942686F20976100008B0C65 /* Shaders.metal */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.metal; path = Shaders.metal; sourceTree = ""; };
42 | /* End PBXFileReference section */
43 |
44 | /* Begin PBXFrameworksBuildPhase section */
45 | 294268552097593A008B0C65 /* Frameworks */ = {
46 | isa = PBXFrameworksBuildPhase;
47 | buildActionMask = 2147483647;
48 | files = (
49 | );
50 | runOnlyForDeploymentPostprocessing = 0;
51 | };
52 | /* End PBXFrameworksBuildPhase section */
53 |
54 | /* Begin PBXGroup section */
55 | 2900940520E6BD8A00CE1EA5 /* Node */ = {
56 | isa = PBXGroup;
57 | children = (
58 | 2900940320E6BD6400CE1EA5 /* Node.swift */,
59 | 2900940620E6BEB300CE1EA5 /* Primitive.swift */,
60 | 2900940C20E6C39A00CE1EA5 /* Scene.swift */,
61 | 2900940E20E6C3DE00CE1EA5 /* CubeScene.swift */,
62 | 2900941020E6C40900CE1EA5 /* Cube.swift */,
63 | );
64 | path = Node;
65 | sourceTree = "";
66 | };
67 | 2942684F2097593A008B0C65 = {
68 | isa = PBXGroup;
69 | children = (
70 | 2942685A2097593A008B0C65 /* macOSMetal */,
71 | 294268592097593A008B0C65 /* Products */,
72 | );
73 | sourceTree = "";
74 | };
75 | 294268592097593A008B0C65 /* Products */ = {
76 | isa = PBXGroup;
77 | children = (
78 | 294268582097593A008B0C65 /* macOSMetal.app */,
79 | );
80 | name = Products;
81 | sourceTree = "";
82 | };
83 | 2942685A2097593A008B0C65 /* macOSMetal */ = {
84 | isa = PBXGroup;
85 | children = (
86 | 2942685B2097593A008B0C65 /* AppDelegate.swift */,
87 | 2942685F2097593B008B0C65 /* Assets.xcassets */,
88 | 294268612097593B008B0C65 /* Main.storyboard */,
89 | 294268642097593B008B0C65 /* Info.plist */,
90 | 294268652097593B008B0C65 /* macOSMetal.entitlements */,
91 | 2942686B20975A34008B0C65 /* MetalView.swift */,
92 | 2942686D20975C55008B0C65 /* Renderer.swift */,
93 | 2942686F20976100008B0C65 /* Shaders.metal */,
94 | 2900940520E6BD8A00CE1EA5 /* Node */,
95 | 2900940820E6BF5E00CE1EA5 /* Types.swift */,
96 | 2900940A20E6C2C100CE1EA5 /* Math.swift */,
97 | );
98 | path = macOSMetal;
99 | sourceTree = "";
100 | };
101 | /* End PBXGroup section */
102 |
103 | /* Begin PBXNativeTarget section */
104 | 294268572097593A008B0C65 /* macOSMetal */ = {
105 | isa = PBXNativeTarget;
106 | buildConfigurationList = 294268682097593B008B0C65 /* Build configuration list for PBXNativeTarget "macOSMetal" */;
107 | buildPhases = (
108 | 294268542097593A008B0C65 /* Sources */,
109 | 294268552097593A008B0C65 /* Frameworks */,
110 | 294268562097593A008B0C65 /* Resources */,
111 | );
112 | buildRules = (
113 | );
114 | dependencies = (
115 | );
116 | name = macOSMetal;
117 | productName = macOSMetal;
118 | productReference = 294268582097593A008B0C65 /* macOSMetal.app */;
119 | productType = "com.apple.product-type.application";
120 | };
121 | /* End PBXNativeTarget section */
122 |
123 | /* Begin PBXProject section */
124 | 294268502097593A008B0C65 /* Project object */ = {
125 | isa = PBXProject;
126 | attributes = {
127 | LastSwiftUpdateCheck = 0930;
128 | LastUpgradeCheck = 0930;
129 | ORGANIZATIONNAME = "Zach Eriksen";
130 | TargetAttributes = {
131 | 294268572097593A008B0C65 = {
132 | CreatedOnToolsVersion = 9.3;
133 | };
134 | };
135 | };
136 | buildConfigurationList = 294268532097593A008B0C65 /* Build configuration list for PBXProject "macOSMetal" */;
137 | compatibilityVersion = "Xcode 9.3";
138 | developmentRegion = en;
139 | hasScannedForEncodings = 0;
140 | knownRegions = (
141 | en,
142 | Base,
143 | );
144 | mainGroup = 2942684F2097593A008B0C65;
145 | productRefGroup = 294268592097593A008B0C65 /* Products */;
146 | projectDirPath = "";
147 | projectRoot = "";
148 | targets = (
149 | 294268572097593A008B0C65 /* macOSMetal */,
150 | );
151 | };
152 | /* End PBXProject section */
153 |
154 | /* Begin PBXResourcesBuildPhase section */
155 | 294268562097593A008B0C65 /* Resources */ = {
156 | isa = PBXResourcesBuildPhase;
157 | buildActionMask = 2147483647;
158 | files = (
159 | 294268602097593B008B0C65 /* Assets.xcassets in Resources */,
160 | 294268632097593B008B0C65 /* Main.storyboard in Resources */,
161 | );
162 | runOnlyForDeploymentPostprocessing = 0;
163 | };
164 | /* End PBXResourcesBuildPhase section */
165 |
166 | /* Begin PBXSourcesBuildPhase section */
167 | 294268542097593A008B0C65 /* Sources */ = {
168 | isa = PBXSourcesBuildPhase;
169 | buildActionMask = 2147483647;
170 | files = (
171 | 2942687020976100008B0C65 /* Shaders.metal in Sources */,
172 | 2900941120E6C40900CE1EA5 /* Cube.swift in Sources */,
173 | 2900940720E6BEB300CE1EA5 /* Primitive.swift in Sources */,
174 | 2900940920E6BF5E00CE1EA5 /* Types.swift in Sources */,
175 | 2900940420E6BD6400CE1EA5 /* Node.swift in Sources */,
176 | 2942686C20975A34008B0C65 /* MetalView.swift in Sources */,
177 | 2900940F20E6C3DE00CE1EA5 /* CubeScene.swift in Sources */,
178 | 2942686E20975C55008B0C65 /* Renderer.swift in Sources */,
179 | 2942685C2097593A008B0C65 /* AppDelegate.swift in Sources */,
180 | 2900940B20E6C2C100CE1EA5 /* Math.swift in Sources */,
181 | 2900940D20E6C39A00CE1EA5 /* Scene.swift in Sources */,
182 | );
183 | runOnlyForDeploymentPostprocessing = 0;
184 | };
185 | /* End PBXSourcesBuildPhase section */
186 |
187 | /* Begin PBXVariantGroup section */
188 | 294268612097593B008B0C65 /* Main.storyboard */ = {
189 | isa = PBXVariantGroup;
190 | children = (
191 | 294268622097593B008B0C65 /* Base */,
192 | );
193 | name = Main.storyboard;
194 | sourceTree = "";
195 | };
196 | /* End PBXVariantGroup section */
197 |
198 | /* Begin XCBuildConfiguration section */
199 | 294268662097593B008B0C65 /* Debug */ = {
200 | isa = XCBuildConfiguration;
201 | buildSettings = {
202 | ALWAYS_SEARCH_USER_PATHS = NO;
203 | CLANG_ANALYZER_NONNULL = YES;
204 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
205 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
206 | CLANG_CXX_LIBRARY = "libc++";
207 | CLANG_ENABLE_MODULES = YES;
208 | CLANG_ENABLE_OBJC_ARC = YES;
209 | CLANG_ENABLE_OBJC_WEAK = YES;
210 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
211 | CLANG_WARN_BOOL_CONVERSION = YES;
212 | CLANG_WARN_COMMA = YES;
213 | CLANG_WARN_CONSTANT_CONVERSION = YES;
214 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
215 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
216 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
217 | CLANG_WARN_EMPTY_BODY = YES;
218 | CLANG_WARN_ENUM_CONVERSION = YES;
219 | CLANG_WARN_INFINITE_RECURSION = YES;
220 | CLANG_WARN_INT_CONVERSION = YES;
221 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
222 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
223 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
224 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
225 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
226 | CLANG_WARN_STRICT_PROTOTYPES = YES;
227 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
228 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
229 | CLANG_WARN_UNREACHABLE_CODE = YES;
230 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
231 | CODE_SIGN_IDENTITY = "Mac Developer";
232 | COPY_PHASE_STRIP = NO;
233 | DEBUG_INFORMATION_FORMAT = dwarf;
234 | ENABLE_STRICT_OBJC_MSGSEND = YES;
235 | ENABLE_TESTABILITY = YES;
236 | GCC_C_LANGUAGE_STANDARD = gnu11;
237 | GCC_DYNAMIC_NO_PIC = NO;
238 | GCC_NO_COMMON_BLOCKS = YES;
239 | GCC_OPTIMIZATION_LEVEL = 0;
240 | GCC_PREPROCESSOR_DEFINITIONS = (
241 | "DEBUG=1",
242 | "$(inherited)",
243 | );
244 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
245 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
246 | GCC_WARN_UNDECLARED_SELECTOR = YES;
247 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
248 | GCC_WARN_UNUSED_FUNCTION = YES;
249 | GCC_WARN_UNUSED_VARIABLE = YES;
250 | MACOSX_DEPLOYMENT_TARGET = 10.13;
251 | MTL_ENABLE_DEBUG_INFO = YES;
252 | ONLY_ACTIVE_ARCH = YES;
253 | SDKROOT = macosx;
254 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
255 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
256 | };
257 | name = Debug;
258 | };
259 | 294268672097593B008B0C65 /* Release */ = {
260 | isa = XCBuildConfiguration;
261 | buildSettings = {
262 | ALWAYS_SEARCH_USER_PATHS = NO;
263 | CLANG_ANALYZER_NONNULL = YES;
264 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
265 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
266 | CLANG_CXX_LIBRARY = "libc++";
267 | CLANG_ENABLE_MODULES = YES;
268 | CLANG_ENABLE_OBJC_ARC = YES;
269 | CLANG_ENABLE_OBJC_WEAK = YES;
270 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
271 | CLANG_WARN_BOOL_CONVERSION = YES;
272 | CLANG_WARN_COMMA = YES;
273 | CLANG_WARN_CONSTANT_CONVERSION = YES;
274 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
275 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
276 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
277 | CLANG_WARN_EMPTY_BODY = YES;
278 | CLANG_WARN_ENUM_CONVERSION = YES;
279 | CLANG_WARN_INFINITE_RECURSION = YES;
280 | CLANG_WARN_INT_CONVERSION = YES;
281 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
282 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
283 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
284 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
285 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
286 | CLANG_WARN_STRICT_PROTOTYPES = YES;
287 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
288 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
289 | CLANG_WARN_UNREACHABLE_CODE = YES;
290 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
291 | CODE_SIGN_IDENTITY = "Mac Developer";
292 | COPY_PHASE_STRIP = NO;
293 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
294 | ENABLE_NS_ASSERTIONS = NO;
295 | ENABLE_STRICT_OBJC_MSGSEND = YES;
296 | GCC_C_LANGUAGE_STANDARD = gnu11;
297 | GCC_NO_COMMON_BLOCKS = YES;
298 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
299 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
300 | GCC_WARN_UNDECLARED_SELECTOR = YES;
301 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
302 | GCC_WARN_UNUSED_FUNCTION = YES;
303 | GCC_WARN_UNUSED_VARIABLE = YES;
304 | MACOSX_DEPLOYMENT_TARGET = 10.13;
305 | MTL_ENABLE_DEBUG_INFO = NO;
306 | SDKROOT = macosx;
307 | SWIFT_COMPILATION_MODE = wholemodule;
308 | SWIFT_OPTIMIZATION_LEVEL = "-O";
309 | };
310 | name = Release;
311 | };
312 | 294268692097593B008B0C65 /* Debug */ = {
313 | isa = XCBuildConfiguration;
314 | buildSettings = {
315 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
316 | CODE_SIGN_ENTITLEMENTS = macOSMetal/macOSMetal.entitlements;
317 | CODE_SIGN_STYLE = Automatic;
318 | COMBINE_HIDPI_IMAGES = YES;
319 | DEVELOPMENT_TEAM = 8M8SAX62V2;
320 | INFOPLIST_FILE = macOSMetal/Info.plist;
321 | LD_RUNPATH_SEARCH_PATHS = (
322 | "$(inherited)",
323 | "@executable_path/../Frameworks",
324 | );
325 | PRODUCT_BUNDLE_IDENTIFIER = cri.blog.macOSMetal;
326 | PRODUCT_NAME = "$(TARGET_NAME)";
327 | SWIFT_VERSION = 4.0;
328 | };
329 | name = Debug;
330 | };
331 | 2942686A2097593B008B0C65 /* Release */ = {
332 | isa = XCBuildConfiguration;
333 | buildSettings = {
334 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
335 | CODE_SIGN_ENTITLEMENTS = macOSMetal/macOSMetal.entitlements;
336 | CODE_SIGN_STYLE = Automatic;
337 | COMBINE_HIDPI_IMAGES = YES;
338 | DEVELOPMENT_TEAM = 8M8SAX62V2;
339 | INFOPLIST_FILE = macOSMetal/Info.plist;
340 | LD_RUNPATH_SEARCH_PATHS = (
341 | "$(inherited)",
342 | "@executable_path/../Frameworks",
343 | );
344 | PRODUCT_BUNDLE_IDENTIFIER = cri.blog.macOSMetal;
345 | PRODUCT_NAME = "$(TARGET_NAME)";
346 | SWIFT_VERSION = 4.0;
347 | };
348 | name = Release;
349 | };
350 | /* End XCBuildConfiguration section */
351 |
352 | /* Begin XCConfigurationList section */
353 | 294268532097593A008B0C65 /* Build configuration list for PBXProject "macOSMetal" */ = {
354 | isa = XCConfigurationList;
355 | buildConfigurations = (
356 | 294268662097593B008B0C65 /* Debug */,
357 | 294268672097593B008B0C65 /* Release */,
358 | );
359 | defaultConfigurationIsVisible = 0;
360 | defaultConfigurationName = Release;
361 | };
362 | 294268682097593B008B0C65 /* Build configuration list for PBXNativeTarget "macOSMetal" */ = {
363 | isa = XCConfigurationList;
364 | buildConfigurations = (
365 | 294268692097593B008B0C65 /* Debug */,
366 | 2942686A2097593B008B0C65 /* Release */,
367 | );
368 | defaultConfigurationIsVisible = 0;
369 | defaultConfigurationName = Release;
370 | };
371 | /* End XCConfigurationList section */
372 | };
373 | rootObject = 294268502097593A008B0C65 /* Project object */;
374 | }
375 |
--------------------------------------------------------------------------------
/macOSMetal/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
673 |
674 |
675 |
676 |
677 |
678 |
679 |
680 |
681 |
682 |
683 |
684 |
685 |
686 |
687 |
688 |
689 |
690 |
691 |
692 |
693 |
694 |
695 |
696 |
697 |
698 |
699 |
700 |
701 |
702 |
703 |
704 |
705 |
706 |
707 |
708 |
709 |
710 |
711 |
712 |
713 |
714 |
715 |
716 |
717 |
718 |
719 |
--------------------------------------------------------------------------------