diff --git a/objc/02-ClearScreen/ClearScreen.xcodeproj/project.pbxproj b/objc/02-ClearScreen/ClearScreen.xcodeproj/project.pbxproj
index 97237cc..12a907f 100644
--- a/objc/02-ClearScreen/ClearScreen.xcodeproj/project.pbxproj
+++ b/objc/02-ClearScreen/ClearScreen.xcodeproj/project.pbxproj
@@ -110,7 +110,7 @@
833FBB9B1BBE0B0E001EFE4D /* Project object */ = {
isa = PBXProject;
attributes = {
- LastUpgradeCheck = 0900;
+ LastUpgradeCheck = 0940;
ORGANIZATIONNAME = "Metal by Example";
TargetAttributes = {
833FBBA21BBE0B0E001EFE4D = {
@@ -195,12 +195,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -247,12 +249,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
diff --git a/objc/02-ClearScreen/ClearScreen.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/objc/02-ClearScreen/ClearScreen.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
new file mode 100644
index 0000000..18d9810
--- /dev/null
+++ b/objc/02-ClearScreen/ClearScreen.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
@@ -0,0 +1,8 @@
+
+
+
+
+ IDEDidComputeMac32BitWarning
+
+
+
diff --git a/objc/02-ClearScreen/ClearScreen.xcodeproj/xcshareddata/xcschemes/ClearScreen.xcscheme b/objc/02-ClearScreen/ClearScreen.xcodeproj/xcshareddata/xcschemes/ClearScreen.xcscheme
index 03bae38..2ed7c45 100644
--- a/objc/02-ClearScreen/ClearScreen.xcodeproj/xcshareddata/xcschemes/ClearScreen.xcscheme
+++ b/objc/02-ClearScreen/ClearScreen.xcodeproj/xcshareddata/xcschemes/ClearScreen.xcscheme
@@ -1,6 +1,6 @@
@@ -46,7 +45,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
- language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
diff --git a/objc/03-DrawingIn2D/DrawingIn2D-Mac/AppDelegate.h b/objc/03-DrawingIn2D/DrawingIn2D-Mac/AppDelegate.h
new file mode 100644
index 0000000..8566931
--- /dev/null
+++ b/objc/03-DrawingIn2D/DrawingIn2D-Mac/AppDelegate.h
@@ -0,0 +1,15 @@
+//
+// AppDelegate.h
+// DrawingIn2D-Mac
+//
+// Created by Brent Gulanowski on 2018-06-18.
+// Copyright © 2018 Metal by Example. All rights reserved.
+//
+
+#import
+
+@interface AppDelegate : NSObject
+
+
+@end
+
diff --git a/objc/03-DrawingIn2D/DrawingIn2D-Mac/AppDelegate.m b/objc/03-DrawingIn2D/DrawingIn2D-Mac/AppDelegate.m
new file mode 100644
index 0000000..d3dac90
--- /dev/null
+++ b/objc/03-DrawingIn2D/DrawingIn2D-Mac/AppDelegate.m
@@ -0,0 +1,27 @@
+//
+// AppDelegate.m
+// DrawingIn2D-Mac
+//
+// Created by Brent Gulanowski on 2018-06-18.
+// Copyright © 2018 Metal by Example. All rights reserved.
+//
+
+#import "AppDelegate.h"
+
+@interface AppDelegate ()
+
+@end
+
+@implementation AppDelegate
+
+- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
+ // Insert code here to initialize your application
+}
+
+
+- (void)applicationWillTerminate:(NSNotification *)aNotification {
+ // Insert code here to tear down your application
+}
+
+
+@end
diff --git a/objc/03-DrawingIn2D/DrawingIn2D-Mac/Assets.xcassets/AppIcon.appiconset/Contents.json b/objc/03-DrawingIn2D/DrawingIn2D-Mac/Assets.xcassets/AppIcon.appiconset/Contents.json
new file mode 100644
index 0000000..2db2b1c
--- /dev/null
+++ b/objc/03-DrawingIn2D/DrawingIn2D-Mac/Assets.xcassets/AppIcon.appiconset/Contents.json
@@ -0,0 +1,58 @@
+{
+ "images" : [
+ {
+ "idiom" : "mac",
+ "size" : "16x16",
+ "scale" : "1x"
+ },
+ {
+ "idiom" : "mac",
+ "size" : "16x16",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "mac",
+ "size" : "32x32",
+ "scale" : "1x"
+ },
+ {
+ "idiom" : "mac",
+ "size" : "32x32",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "mac",
+ "size" : "128x128",
+ "scale" : "1x"
+ },
+ {
+ "idiom" : "mac",
+ "size" : "128x128",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "mac",
+ "size" : "256x256",
+ "scale" : "1x"
+ },
+ {
+ "idiom" : "mac",
+ "size" : "256x256",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "mac",
+ "size" : "512x512",
+ "scale" : "1x"
+ },
+ {
+ "idiom" : "mac",
+ "size" : "512x512",
+ "scale" : "2x"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/objc/03-DrawingIn2D/DrawingIn2D-Mac/Assets.xcassets/Contents.json b/objc/03-DrawingIn2D/DrawingIn2D-Mac/Assets.xcassets/Contents.json
new file mode 100644
index 0000000..da4a164
--- /dev/null
+++ b/objc/03-DrawingIn2D/DrawingIn2D-Mac/Assets.xcassets/Contents.json
@@ -0,0 +1,6 @@
+{
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/objc/03-DrawingIn2D/DrawingIn2D-Mac/Base.lproj/Main.storyboard b/objc/03-DrawingIn2D/DrawingIn2D-Mac/Base.lproj/Main.storyboard
new file mode 100644
index 0000000..c5d6fb6
--- /dev/null
+++ b/objc/03-DrawingIn2D/DrawingIn2D-Mac/Base.lproj/Main.storyboard
@@ -0,0 +1,718 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/objc/03-DrawingIn2D/DrawingIn2D-Mac/DrawingIn2D_Mac.entitlements b/objc/03-DrawingIn2D/DrawingIn2D-Mac/DrawingIn2D_Mac.entitlements
new file mode 100644
index 0000000..f2ef3ae
--- /dev/null
+++ b/objc/03-DrawingIn2D/DrawingIn2D-Mac/DrawingIn2D_Mac.entitlements
@@ -0,0 +1,10 @@
+
+
+
+
+ com.apple.security.app-sandbox
+
+ com.apple.security.files.user-selected.read-only
+
+
+
diff --git a/objc/03-DrawingIn2D/DrawingIn2D-Mac/Info.plist b/objc/03-DrawingIn2D/DrawingIn2D-Mac/Info.plist
new file mode 100644
index 0000000..7dd54bb
--- /dev/null
+++ b/objc/03-DrawingIn2D/DrawingIn2D-Mac/Info.plist
@@ -0,0 +1,32 @@
+
+
+
+
+ CFBundleDevelopmentRegion
+ $(DEVELOPMENT_LANGUAGE)
+ CFBundleExecutable
+ $(EXECUTABLE_NAME)
+ CFBundleIconFile
+
+ CFBundleIdentifier
+ $(PRODUCT_BUNDLE_IDENTIFIER)
+ CFBundleInfoDictionaryVersion
+ 6.0
+ CFBundleName
+ $(PRODUCT_NAME)
+ CFBundlePackageType
+ APPL
+ CFBundleShortVersionString
+ 1.0
+ CFBundleVersion
+ 1
+ LSMinimumSystemVersion
+ $(MACOSX_DEPLOYMENT_TARGET)
+ NSHumanReadableCopyright
+ Copyright © 2018 Metal by Example. All rights reserved.
+ NSMainStoryboardFile
+ Main
+ NSPrincipalClass
+ NSApplication
+
+
diff --git a/objc/03-DrawingIn2D/DrawingIn2D-Mac/ViewController.h b/objc/03-DrawingIn2D/DrawingIn2D-Mac/ViewController.h
new file mode 100644
index 0000000..6c16c95
--- /dev/null
+++ b/objc/03-DrawingIn2D/DrawingIn2D-Mac/ViewController.h
@@ -0,0 +1,15 @@
+//
+// ViewController.h
+// DrawingIn2D-Mac
+//
+// Created by Brent Gulanowski on 2018-06-18.
+// Copyright © 2018 Metal by Example. All rights reserved.
+//
+
+#import
+
+@interface ViewController : NSViewController
+
+
+@end
+
diff --git a/objc/03-DrawingIn2D/DrawingIn2D-Mac/ViewController.m b/objc/03-DrawingIn2D/DrawingIn2D-Mac/ViewController.m
new file mode 100644
index 0000000..1934e03
--- /dev/null
+++ b/objc/03-DrawingIn2D/DrawingIn2D-Mac/ViewController.m
@@ -0,0 +1,27 @@
+//
+// ViewController.m
+// DrawingIn2D-Mac
+//
+// Created by Brent Gulanowski on 2018-06-18.
+// Copyright © 2018 Metal by Example. All rights reserved.
+//
+
+#import "ViewController.h"
+
+@implementation ViewController
+
+- (void)viewDidLoad {
+ [super viewDidLoad];
+
+ // Do any additional setup after loading the view.
+}
+
+
+- (void)setRepresentedObject:(id)representedObject {
+ [super setRepresentedObject:representedObject];
+
+ // Update the view, if already loaded.
+}
+
+
+@end
diff --git a/objc/03-DrawingIn2D/DrawingIn2D-Mac/main.m b/objc/03-DrawingIn2D/DrawingIn2D-Mac/main.m
new file mode 100644
index 0000000..177bc8e
--- /dev/null
+++ b/objc/03-DrawingIn2D/DrawingIn2D-Mac/main.m
@@ -0,0 +1,13 @@
+//
+// main.m
+// DrawingIn2D-Mac
+//
+// Created by Brent Gulanowski on 2018-06-18.
+// Copyright © 2018 Metal by Example. All rights reserved.
+//
+
+#import
+
+int main(int argc, const char * argv[]) {
+ return NSApplicationMain(argc, argv);
+}
diff --git a/objc/03-DrawingIn2D/DrawingIn2D.xcodeproj/project.pbxproj b/objc/03-DrawingIn2D/DrawingIn2D.xcodeproj/project.pbxproj
index d393a58..1022545 100644
--- a/objc/03-DrawingIn2D/DrawingIn2D.xcodeproj/project.pbxproj
+++ b/objc/03-DrawingIn2D/DrawingIn2D.xcodeproj/project.pbxproj
@@ -15,6 +15,13 @@
83E2D7771BD188110006DDD8 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 83E2D7751BD188110006DDD8 /* LaunchScreen.storyboard */; };
83E2D7811BD188710006DDD8 /* MBEMetalView.m in Sources */ = {isa = PBXBuildFile; fileRef = 83E2D77F1BD188710006DDD8 /* MBEMetalView.m */; };
83E2D7821BD188710006DDD8 /* Shaders.metal in Sources */ = {isa = PBXBuildFile; fileRef = 83E2D7801BD188710006DDD8 /* Shaders.metal */; };
+ 845182C620D808C700BF473E /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 845182C520D808C700BF473E /* AppDelegate.m */; };
+ 845182C920D808C700BF473E /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 845182C820D808C700BF473E /* ViewController.m */; };
+ 845182CB20D808C800BF473E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 845182CA20D808C800BF473E /* Assets.xcassets */; };
+ 845182CE20D808C800BF473E /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 845182CC20D808C800BF473E /* Main.storyboard */; };
+ 845182D120D808C800BF473E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 845182D020D808C800BF473E /* main.m */; };
+ 845182D620D8096300BF473E /* MBEMetalView.m in Sources */ = {isa = PBXBuildFile; fileRef = 83E2D77F1BD188710006DDD8 /* MBEMetalView.m */; };
+ 845182DC20D80E3E00BF473E /* Shaders.metal in Sources */ = {isa = PBXBuildFile; fileRef = 83E2D7801BD188710006DDD8 /* Shaders.metal */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@@ -31,6 +38,16 @@
83E2D77E1BD188710006DDD8 /* MBEMetalView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MBEMetalView.h; sourceTree = ""; };
83E2D77F1BD188710006DDD8 /* MBEMetalView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MBEMetalView.m; sourceTree = ""; };
83E2D7801BD188710006DDD8 /* Shaders.metal */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.metal; path = Shaders.metal; sourceTree = ""; };
+ 845182C220D808C700BF473E /* Drawing In 2D.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Drawing In 2D.app"; sourceTree = BUILT_PRODUCTS_DIR; };
+ 845182C420D808C700BF473E /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
+ 845182C520D808C700BF473E /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; };
+ 845182C720D808C700BF473E /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; };
+ 845182C820D808C700BF473E /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; };
+ 845182CA20D808C800BF473E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
+ 845182CD20D808C800BF473E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
+ 845182CF20D808C800BF473E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
+ 845182D020D808C800BF473E /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
+ 845182D220D808C800BF473E /* DrawingIn2D_Mac.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DrawingIn2D_Mac.entitlements; sourceTree = ""; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -41,6 +58,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ 845182BF20D808C700BF473E /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
@@ -48,6 +72,7 @@
isa = PBXGroup;
children = (
83E2D7661BD188110006DDD8 /* DrawingIn2D */,
+ 845182C320D808C700BF473E /* DrawingIn2D-Mac */,
83E2D7651BD188110006DDD8 /* Products */,
);
sourceTree = "";
@@ -56,6 +81,7 @@
isa = PBXGroup;
children = (
83E2D7641BD188110006DDD8 /* DrawingIn2D.app */,
+ 845182C220D808C700BF473E /* Drawing In 2D.app */,
);
name = Products;
sourceTree = "";
@@ -87,6 +113,22 @@
name = "Supporting Files";
sourceTree = "";
};
+ 845182C320D808C700BF473E /* DrawingIn2D-Mac */ = {
+ isa = PBXGroup;
+ children = (
+ 845182C420D808C700BF473E /* AppDelegate.h */,
+ 845182C520D808C700BF473E /* AppDelegate.m */,
+ 845182C720D808C700BF473E /* ViewController.h */,
+ 845182C820D808C700BF473E /* ViewController.m */,
+ 845182CA20D808C800BF473E /* Assets.xcassets */,
+ 845182CC20D808C800BF473E /* Main.storyboard */,
+ 845182CF20D808C800BF473E /* Info.plist */,
+ 845182D020D808C800BF473E /* main.m */,
+ 845182D220D808C800BF473E /* DrawingIn2D_Mac.entitlements */,
+ );
+ path = "DrawingIn2D-Mac";
+ sourceTree = "";
+ };
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@@ -107,18 +149,39 @@
productReference = 83E2D7641BD188110006DDD8 /* DrawingIn2D.app */;
productType = "com.apple.product-type.application";
};
+ 845182C120D808C700BF473E /* DrawingIn2D-Mac */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 845182D520D808C800BF473E /* Build configuration list for PBXNativeTarget "DrawingIn2D-Mac" */;
+ buildPhases = (
+ 845182BE20D808C700BF473E /* Sources */,
+ 845182BF20D808C700BF473E /* Frameworks */,
+ 845182C020D808C700BF473E /* Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = "DrawingIn2D-Mac";
+ productName = "DrawingIn2D-Mac";
+ productReference = 845182C220D808C700BF473E /* Drawing In 2D.app */;
+ productType = "com.apple.product-type.application";
+ };
/* End PBXNativeTarget section */
/* Begin PBXProject section */
83E2D75C1BD188110006DDD8 /* Project object */ = {
isa = PBXProject;
attributes = {
- LastUpgradeCheck = 0900;
+ LastUpgradeCheck = 0940;
ORGANIZATIONNAME = "Metal by Example";
TargetAttributes = {
83E2D7631BD188110006DDD8 = {
CreatedOnToolsVersion = 7.0;
};
+ 845182C120D808C700BF473E = {
+ CreatedOnToolsVersion = 9.4;
+ ProvisioningStyle = Automatic;
+ };
};
};
buildConfigurationList = 83E2D75F1BD188110006DDD8 /* Build configuration list for PBXProject "DrawingIn2D" */;
@@ -135,6 +198,7 @@
projectRoot = "";
targets = (
83E2D7631BD188110006DDD8 /* DrawingIn2D */,
+ 845182C120D808C700BF473E /* DrawingIn2D-Mac */,
);
};
/* End PBXProject section */
@@ -150,6 +214,15 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ 845182C020D808C700BF473E /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 845182CB20D808C800BF473E /* Assets.xcassets in Resources */,
+ 845182CE20D808C800BF473E /* Main.storyboard in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
@@ -165,6 +238,18 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ 845182BE20D808C700BF473E /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 845182C920D808C700BF473E /* ViewController.m in Sources */,
+ 845182D120D808C800BF473E /* main.m in Sources */,
+ 845182C620D808C700BF473E /* AppDelegate.m in Sources */,
+ 845182D620D8096300BF473E /* MBEMetalView.m in Sources */,
+ 845182DC20D80E3E00BF473E /* Shaders.metal in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
@@ -184,6 +269,14 @@
name = LaunchScreen.storyboard;
sourceTree = "";
};
+ 845182CC20D808C800BF473E /* Main.storyboard */ = {
+ isa = PBXVariantGroup;
+ children = (
+ 845182CD20D808C800BF473E /* Base */,
+ );
+ name = Main.storyboard;
+ sourceTree = "";
+ };
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
@@ -199,12 +292,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -251,12 +346,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -289,7 +386,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
- INFOPLIST_FILE = "DrawingIn2D/Info.plist";
+ INFOPLIST_FILE = DrawingIn2D/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.4;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.metalbyexample.-2-DrawingIn2D";
@@ -301,7 +398,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
- INFOPLIST_FILE = "DrawingIn2D/Info.plist";
+ INFOPLIST_FILE = DrawingIn2D/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.4;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.metalbyexample.-2-DrawingIn2D";
@@ -309,6 +406,54 @@
};
name = Release;
};
+ 845182D320D808C800BF473E /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_ENABLE_OBJC_WEAK = YES;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+ CODE_SIGN_ENTITLEMENTS = "DrawingIn2D-Mac/DrawingIn2D_Mac.entitlements";
+ CODE_SIGN_IDENTITY = "-";
+ CODE_SIGN_STYLE = Automatic;
+ COMBINE_HIDPI_IMAGES = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ INFOPLIST_FILE = "DrawingIn2D-Mac/Info.plist";
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
+ MACOSX_DEPLOYMENT_TARGET = 10.13;
+ PRODUCT_BUNDLE_IDENTIFIER = "com.Metal-by-Example.DrawingIn2D-Mac";
+ PRODUCT_NAME = "Drawing In 2D";
+ SDKROOT = macosx;
+ };
+ name = Debug;
+ };
+ 845182D420D808C800BF473E /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_ENABLE_OBJC_WEAK = YES;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+ CODE_SIGN_ENTITLEMENTS = "DrawingIn2D-Mac/DrawingIn2D_Mac.entitlements";
+ CODE_SIGN_IDENTITY = "-";
+ CODE_SIGN_STYLE = Automatic;
+ COMBINE_HIDPI_IMAGES = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ INFOPLIST_FILE = "DrawingIn2D-Mac/Info.plist";
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
+ MACOSX_DEPLOYMENT_TARGET = 10.13;
+ PRODUCT_BUNDLE_IDENTIFIER = "com.Metal-by-Example.DrawingIn2D-Mac";
+ PRODUCT_NAME = "Drawing In 2D";
+ SDKROOT = macosx;
+ };
+ name = Release;
+ };
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
@@ -330,6 +475,15 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
+ 845182D520D808C800BF473E /* Build configuration list for PBXNativeTarget "DrawingIn2D-Mac" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 845182D320D808C800BF473E /* Debug */,
+ 845182D420D808C800BF473E /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
/* End XCConfigurationList section */
};
rootObject = 83E2D75C1BD188110006DDD8 /* Project object */;
diff --git a/objc/03-DrawingIn2D/DrawingIn2D.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/objc/03-DrawingIn2D/DrawingIn2D.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
new file mode 100644
index 0000000..18d9810
--- /dev/null
+++ b/objc/03-DrawingIn2D/DrawingIn2D.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
@@ -0,0 +1,8 @@
+
+
+
+
+ IDEDidComputeMac32BitWarning
+
+
+
diff --git a/objc/03-DrawingIn2D/DrawingIn2D.xcodeproj/xcshareddata/xcschemes/DrawingIn2D.xcscheme b/objc/03-DrawingIn2D/DrawingIn2D.xcodeproj/xcshareddata/xcschemes/DrawingIn2D.xcscheme
index fc08a89..d38cb48 100644
--- a/objc/03-DrawingIn2D/DrawingIn2D.xcodeproj/xcshareddata/xcschemes/DrawingIn2D.xcscheme
+++ b/objc/03-DrawingIn2D/DrawingIn2D.xcodeproj/xcshareddata/xcschemes/DrawingIn2D.xcscheme
@@ -1,6 +1,6 @@
@@ -46,7 +45,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
- language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
diff --git a/objc/03-DrawingIn2D/DrawingIn2D/MBEMetalView.h b/objc/03-DrawingIn2D/DrawingIn2D/MBEMetalView.h
index 6b804e3..0b999b4 100644
--- a/objc/03-DrawingIn2D/DrawingIn2D/MBEMetalView.h
+++ b/objc/03-DrawingIn2D/DrawingIn2D/MBEMetalView.h
@@ -1,6 +1,15 @@
+#import
+
+#if TARGET_OS_IPHONE
@import UIKit;
+#define NSUIView UIView
+#else
+@import AppKit;
+@import QuartzCore;
+#define NSUIView NSView
+#endif
-@interface MBEMetalView : UIView
+@interface MBEMetalView : NSUIView
@property (readonly) CAMetalLayer *metalLayer;
diff --git a/objc/03-DrawingIn2D/DrawingIn2D/MBEMetalView.m b/objc/03-DrawingIn2D/DrawingIn2D/MBEMetalView.m
index 4528f72..8dc37e8 100644
--- a/objc/03-DrawingIn2D/DrawingIn2D/MBEMetalView.m
+++ b/objc/03-DrawingIn2D/DrawingIn2D/MBEMetalView.m
@@ -1,6 +1,7 @@
#import "MBEMetalView.h"
@import Metal;
@import simd;
+@import CoreVideo;
typedef struct
{
@@ -9,17 +10,40 @@
} MBEVertex;
@interface MBEMetalView ()
+#if TARGET_OS_IPHONE
@property (nonatomic, strong) CADisplayLink *displayLink;
+#else
+@property (nonatomic) CVDisplayLinkRef displayLink;
+@property (nonatomic, strong) CAMetalLayer *metalLayer;
+#endif
@property (nonatomic, strong) id device;
@property (nonatomic, strong) id pipeline;
@property (nonatomic, strong) id commandQueue;
@property (nonatomic, strong) id vertexBuffer;
+
+- (void)redraw;
@end
+#if TARGET_OS_OSX
+static CVReturn C3DViewDisplayLink(CVDisplayLinkRef displayLink,
+ const CVTimeStamp *inNow,
+ const CVTimeStamp *inOutputTime,
+ CVOptionFlags flagsIn,
+ CVOptionFlags *flagsOut,
+ void *view) {
+ @autoreleasepool {
+ [(__bridge MBEMetalView *)view redraw];
+ }
+
+ return kCVReturnSuccess;
+}
+#endif
+
@implementation MBEMetalView
@synthesize device=device;
+#if TARGET_OS_IPHONE
+ (Class)layerClass
{
return [CAMetalLayer class];
@@ -56,11 +80,49 @@ - (void)didMoveToSuperview
self.displayLink = nil;
}
}
+#else
+
+- (CALayer *)makeBackingLayer
+{
+ CAMetalLayer *layer = [[CAMetalLayer alloc] init];
+ _metalLayer = layer;
+ return layer;
+}
+
+- (void)viewDidMoveToSuperview
+{
+ [super viewDidMoveToSuperview];
+
+ if (!self.device) {
+ [self makeDevice];
+ [self makeBuffers];
+ [self makePipeline];
+ }
+
+ if (self.superview) {
+ CVDisplayLinkCreateWithActiveCGDisplays(&_displayLink);
+ CVDisplayLinkSetOutputCallback(_displayLink, C3DViewDisplayLink, (__bridge void *)(self));
+ CVDisplayLinkStart(_displayLink);
+ }
+ else {
+ CVDisplayLinkStop(_displayLink);
+ CVDisplayLinkRelease(_displayLink);
+ _displayLink = NULL;
+ }
+}
+#endif
- (void)setFrame:(CGRect)frame
{
[super setFrame:frame];
+ self.metalLayer.drawableSize = self.drawableSize;
+}
+
+#if TARGET_OS_IPHONE
+- (CGSize)drawableSize {
+ CGSize drawableSize = self.bounds.size;
+
// During the first layout pass, we will not be in a view hierarchy, so we guess our scale
CGFloat scale = [UIScreen mainScreen].scale;
@@ -70,17 +132,25 @@ - (void)setFrame:(CGRect)frame
scale = self.window.screen.scale;
}
- CGSize drawableSize = self.bounds.size;
-
// Since drawable size is in pixels, we need to multiply by the scale to move from points to pixels
drawableSize.width *= scale;
drawableSize.height *= scale;
- self.metalLayer.drawableSize = drawableSize;
+ return drawableSize;
+}
+
+#else
+- (CGSize)drawableSize {
+ return self.bounds.size;
}
+#endif
- (CAMetalLayer *)metalLayer {
+#if TARGET_OS_IPHONE
return (CAMetalLayer *)self.layer;
+#else
+ return _metalLayer;
+#endif
}
- (void)makeDevice
@@ -154,9 +224,11 @@ - (void)redraw
}
}
+#if TARGET_OS_IPHONE
- (void)displayLinkDidFire:(CADisplayLink *)displayLink
{
[self redraw];
}
+#endif
@end