diff --git a/objc/02-ClearScreen/ClearScreen-Mac/AppDelegate.h b/objc/02-ClearScreen/ClearScreen-Mac/AppDelegate.h new file mode 100644 index 0000000..e9e7367 --- /dev/null +++ b/objc/02-ClearScreen/ClearScreen-Mac/AppDelegate.h @@ -0,0 +1,15 @@ +// +// AppDelegate.h +// ClearScreen-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/02-ClearScreen/ClearScreen-Mac/AppDelegate.m b/objc/02-ClearScreen/ClearScreen-Mac/AppDelegate.m new file mode 100644 index 0000000..4c0a509 --- /dev/null +++ b/objc/02-ClearScreen/ClearScreen-Mac/AppDelegate.m @@ -0,0 +1,27 @@ +// +// AppDelegate.m +// ClearScreen-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/02-ClearScreen/ClearScreen-Mac/Assets.xcassets/AppIcon.appiconset/Contents.json b/objc/02-ClearScreen/ClearScreen-Mac/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..2db2b1c --- /dev/null +++ b/objc/02-ClearScreen/ClearScreen-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/02-ClearScreen/ClearScreen-Mac/Assets.xcassets/Contents.json b/objc/02-ClearScreen/ClearScreen-Mac/Assets.xcassets/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/objc/02-ClearScreen/ClearScreen-Mac/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/objc/02-ClearScreen/ClearScreen-Mac/Base.lproj/Main.storyboard b/objc/02-ClearScreen/ClearScreen-Mac/Base.lproj/Main.storyboard new file mode 100644 index 0000000..34a9062 --- /dev/null +++ b/objc/02-ClearScreen/ClearScreen-Mac/Base.lproj/Main.storyboard @@ -0,0 +1,718 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Default + + + + + + + Left to Right + + + + + + + Right to Left + + + + + + + + + + + Default + + + + + + + Left to Right + + + + + + + Right to Left + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/objc/02-ClearScreen/ClearScreen-Mac/ClearScreen_Mac.entitlements b/objc/02-ClearScreen/ClearScreen-Mac/ClearScreen_Mac.entitlements new file mode 100644 index 0000000..f2ef3ae --- /dev/null +++ b/objc/02-ClearScreen/ClearScreen-Mac/ClearScreen_Mac.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.files.user-selected.read-only + + + diff --git a/objc/02-ClearScreen/ClearScreen-Mac/Info.plist b/objc/02-ClearScreen/ClearScreen-Mac/Info.plist new file mode 100644 index 0000000..7dd54bb --- /dev/null +++ b/objc/02-ClearScreen/ClearScreen-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/02-ClearScreen/ClearScreen-Mac/ViewController.h b/objc/02-ClearScreen/ClearScreen-Mac/ViewController.h new file mode 100644 index 0000000..32e36ad --- /dev/null +++ b/objc/02-ClearScreen/ClearScreen-Mac/ViewController.h @@ -0,0 +1,15 @@ +// +// ViewController.h +// ClearScreen-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/02-ClearScreen/ClearScreen-Mac/ViewController.m b/objc/02-ClearScreen/ClearScreen-Mac/ViewController.m new file mode 100644 index 0000000..82b65f7 --- /dev/null +++ b/objc/02-ClearScreen/ClearScreen-Mac/ViewController.m @@ -0,0 +1,27 @@ +// +// ViewController.m +// ClearScreen-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/02-ClearScreen/ClearScreen-Mac/main.m b/objc/02-ClearScreen/ClearScreen-Mac/main.m new file mode 100644 index 0000000..ed23388 --- /dev/null +++ b/objc/02-ClearScreen/ClearScreen-Mac/main.m @@ -0,0 +1,13 @@ +// +// main.m +// ClearScreen-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/02-ClearScreen/ClearScreen.xcodeproj/project.pbxproj b/objc/02-ClearScreen/ClearScreen.xcodeproj/project.pbxproj index 97237cc..9cfa0b3 100644 --- a/objc/02-ClearScreen/ClearScreen.xcodeproj/project.pbxproj +++ b/objc/02-ClearScreen/ClearScreen.xcodeproj/project.pbxproj @@ -14,6 +14,12 @@ 833FBBB31BBE0B0E001EFE4D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 833FBBB21BBE0B0E001EFE4D /* Assets.xcassets */; }; 833FBBB61BBE0B0E001EFE4D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 833FBBB41BBE0B0E001EFE4D /* LaunchScreen.storyboard */; }; 833FBBBF1BBE0C19001EFE4D /* MBEMetalView.m in Sources */ = {isa = PBXBuildFile; fileRef = 833FBBBE1BBE0C19001EFE4D /* MBEMetalView.m */; }; + 845182A920D7ECBD00BF473E /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 845182A820D7ECBD00BF473E /* AppDelegate.m */; }; + 845182AC20D7ECBD00BF473E /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 845182AB20D7ECBD00BF473E /* ViewController.m */; }; + 845182AE20D7ECBE00BF473E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 845182AD20D7ECBE00BF473E /* Assets.xcassets */; }; + 845182B120D7ECBE00BF473E /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 845182AF20D7ECBE00BF473E /* Main.storyboard */; }; + 845182B420D7ECBE00BF473E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 845182B320D7ECBE00BF473E /* main.m */; }; + 845182B920D7ED1300BF473E /* MBEMetalView.m in Sources */ = {isa = PBXBuildFile; fileRef = 833FBBBE1BBE0C19001EFE4D /* MBEMetalView.m */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -29,6 +35,16 @@ 833FBBB71BBE0B0E001EFE4D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 833FBBBD1BBE0C19001EFE4D /* MBEMetalView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MBEMetalView.h; sourceTree = ""; }; 833FBBBE1BBE0C19001EFE4D /* MBEMetalView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MBEMetalView.m; sourceTree = ""; }; + 845182A520D7ECBD00BF473E /* Clear Screen.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Clear Screen.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 845182A720D7ECBD00BF473E /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 845182A820D7ECBD00BF473E /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 845182AA20D7ECBD00BF473E /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + 845182AB20D7ECBD00BF473E /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; + 845182AD20D7ECBE00BF473E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 845182B020D7ECBE00BF473E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 845182B220D7ECBE00BF473E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 845182B320D7ECBE00BF473E /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 845182B520D7ECBE00BF473E /* ClearScreen_Mac.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = ClearScreen_Mac.entitlements; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -39,6 +55,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 845182A220D7ECBD00BF473E /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -46,6 +69,7 @@ isa = PBXGroup; children = ( 833FBBA51BBE0B0E001EFE4D /* ClearScreen */, + 845182A620D7ECBD00BF473E /* ClearScreen-Mac */, 833FBBA41BBE0B0E001EFE4D /* Products */, ); sourceTree = ""; @@ -54,6 +78,7 @@ isa = PBXGroup; children = ( 833FBBA31BBE0B0E001EFE4D /* ClearScreen.app */, + 845182A520D7ECBD00BF473E /* Clear Screen.app */, ); name = Products; sourceTree = ""; @@ -84,6 +109,22 @@ name = "Supporting Files"; sourceTree = ""; }; + 845182A620D7ECBD00BF473E /* ClearScreen-Mac */ = { + isa = PBXGroup; + children = ( + 845182A720D7ECBD00BF473E /* AppDelegate.h */, + 845182A820D7ECBD00BF473E /* AppDelegate.m */, + 845182AA20D7ECBD00BF473E /* ViewController.h */, + 845182AB20D7ECBD00BF473E /* ViewController.m */, + 845182AD20D7ECBE00BF473E /* Assets.xcassets */, + 845182AF20D7ECBE00BF473E /* Main.storyboard */, + 845182B220D7ECBE00BF473E /* Info.plist */, + 845182B320D7ECBE00BF473E /* main.m */, + 845182B520D7ECBE00BF473E /* ClearScreen_Mac.entitlements */, + ); + path = "ClearScreen-Mac"; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -104,18 +145,39 @@ productReference = 833FBBA31BBE0B0E001EFE4D /* ClearScreen.app */; productType = "com.apple.product-type.application"; }; + 845182A420D7ECBD00BF473E /* ClearScreen-Mac */ = { + isa = PBXNativeTarget; + buildConfigurationList = 845182B620D7ECBE00BF473E /* Build configuration list for PBXNativeTarget "ClearScreen-Mac" */; + buildPhases = ( + 845182A120D7ECBD00BF473E /* Sources */, + 845182A220D7ECBD00BF473E /* Frameworks */, + 845182A320D7ECBD00BF473E /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "ClearScreen-Mac"; + productName = "ClearScreen-Mac"; + productReference = 845182A520D7ECBD00BF473E /* Clear Screen.app */; + productType = "com.apple.product-type.application"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ 833FBB9B1BBE0B0E001EFE4D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0900; + LastUpgradeCheck = 0940; ORGANIZATIONNAME = "Metal by Example"; TargetAttributes = { 833FBBA21BBE0B0E001EFE4D = { CreatedOnToolsVersion = 7.0; }; + 845182A420D7ECBD00BF473E = { + CreatedOnToolsVersion = 9.4; + ProvisioningStyle = Automatic; + }; }; }; buildConfigurationList = 833FBB9E1BBE0B0E001EFE4D /* Build configuration list for PBXProject "ClearScreen" */; @@ -132,6 +194,7 @@ projectRoot = ""; targets = ( 833FBBA21BBE0B0E001EFE4D /* ClearScreen */, + 845182A420D7ECBD00BF473E /* ClearScreen-Mac */, ); }; /* End PBXProject section */ @@ -147,6 +210,15 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 845182A320D7ECBD00BF473E /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 845182AE20D7ECBE00BF473E /* Assets.xcassets in Resources */, + 845182B120D7ECBE00BF473E /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -161,6 +233,17 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 845182A120D7ECBD00BF473E /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 845182AC20D7ECBD00BF473E /* ViewController.m in Sources */, + 845182B420D7ECBE00BF473E /* main.m in Sources */, + 845182A920D7ECBD00BF473E /* AppDelegate.m in Sources */, + 845182B920D7ED1300BF473E /* MBEMetalView.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXSourcesBuildPhase section */ /* Begin PBXVariantGroup section */ @@ -180,6 +263,14 @@ name = LaunchScreen.storyboard; sourceTree = ""; }; + 845182AF20D7ECBE00BF473E /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 845182B020D7ECBE00BF473E /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ @@ -195,12 +286,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 +340,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; @@ -305,6 +400,54 @@ }; name = Release; }; + 845182B720D7ECBE00BF473E /* 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 = "ClearScreen-Mac/ClearScreen_Mac.entitlements"; + CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = "ClearScreen-Mac/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.13; + PRODUCT_BUNDLE_IDENTIFIER = "com.Metal-by-Example.ClearScreen-Mac"; + PRODUCT_NAME = "Clear Screen"; + SDKROOT = macosx; + }; + name = Debug; + }; + 845182B820D7ECBE00BF473E /* 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 = "ClearScreen-Mac/ClearScreen_Mac.entitlements"; + CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = "ClearScreen-Mac/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.13; + PRODUCT_BUNDLE_IDENTIFIER = "com.Metal-by-Example.ClearScreen-Mac"; + PRODUCT_NAME = "Clear Screen"; + SDKROOT = macosx; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -326,6 +469,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 845182B620D7ECBE00BF473E /* Build configuration list for PBXNativeTarget "ClearScreen-Mac" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 845182B720D7ECBE00BF473E /* Debug */, + 845182B820D7ECBE00BF473E /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; /* End XCConfigurationList section */ }; rootObject = 833FBB9B1BBE0B0E001EFE4D /* Project object */; 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/02-ClearScreen/ClearScreen/MBEMetalView.h b/objc/02-ClearScreen/ClearScreen/MBEMetalView.h index 6b804e3..0b999b4 100644 --- a/objc/02-ClearScreen/ClearScreen/MBEMetalView.h +++ b/objc/02-ClearScreen/ClearScreen/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/02-ClearScreen/ClearScreen/MBEMetalView.m b/objc/02-ClearScreen/ClearScreen/MBEMetalView.m index 833538f..ef17e24 100644 --- a/objc/02-ClearScreen/ClearScreen/MBEMetalView.m +++ b/objc/02-ClearScreen/ClearScreen/MBEMetalView.m @@ -7,32 +7,56 @@ @interface MBEMetalView () @implementation MBEMetalView +- (CAMetalLayer *)metalLayer { + return (CAMetalLayer *)self.layer; +} + +#if TARGET_OS_IPHONE + (id)layerClass { return [CAMetalLayer class]; } +#else +- (CALayer *)makeBackingLayer { + return [[CAMetalLayer alloc] init]; +} + +- (BOOL)wantsUpdateLayer { + return YES; +} + +- (void)viewDidMoveToSuperview { + [self configureMetal]; + [self.layer setNeedsDisplay]; +} + +- (void)displayLayer:(CALayer *)layer { + [self redraw]; +} +#endif + - (instancetype)initWithCoder:(NSCoder *)aDecoder { if ((self = [super initWithCoder:aDecoder])) { _device = MTLCreateSystemDefaultDevice(); - self.metalLayer.device = _device; - self.metalLayer.pixelFormat = MTLPixelFormatBGRA8Unorm; + [self configureMetal]; } return self; } -- (CAMetalLayer *)metalLayer { - return (CAMetalLayer *)self.layer; -} - - (void)didMoveToWindow { [self redraw]; } +- (void)configureMetal { + self.metalLayer.device = _device; + self.metalLayer.pixelFormat = MTLPixelFormatBGRA8Unorm; +} + - (void)redraw { id drawable = [self.metalLayer nextDrawable];