diff --git a/.gitignore b/.gitignore index ac289464..d27c2533 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ node_modules /examples/c_canvas_minimal/build /shaders/build /c/build +/examples/macos_app/Pathfinder\ Example.xcodeproj/project.xcworkspace/xcuserdata/* # Editors *.swp diff --git a/examples/macos_app/Pathfinder Example.xcodeproj/project.pbxproj b/examples/macos_app/Pathfinder Example.xcodeproj/project.pbxproj new file mode 100644 index 00000000..9a359ecf --- /dev/null +++ b/examples/macos_app/Pathfinder Example.xcodeproj/project.pbxproj @@ -0,0 +1,354 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + 6A9A35B322C1E14700B86652 /* libpathfinder_c.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6A9A35B222C1E14700B86652 /* libpathfinder_c.a */; }; + 6AFD6FFA22BD780D00AC1ED3 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 6AFD6FF922BD780D00AC1ED3 /* AppDelegate.m */; }; + 6AFD6FFC22BD781000AC1ED3 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6AFD6FFB22BD781000AC1ED3 /* Assets.xcassets */; }; + 6AFD6FFF22BD781000AC1ED3 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6AFD6FFD22BD781000AC1ED3 /* MainMenu.xib */; }; + 6AFD700222BD781000AC1ED3 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 6AFD700122BD781000AC1ED3 /* main.m */; }; + 6AFD700B22BD7B7A00AC1ED3 /* PathfinderView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6AFD700A22BD7B7A00AC1ED3 /* PathfinderView.m */; }; + 6AFD700F22BD930500AC1ED3 /* libharfbuzz.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6AFD700E22BD930500AC1ED3 /* libharfbuzz.a */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 6A9A35B222C1E14700B86652 /* libpathfinder_c.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libpathfinder_c.a; path = ../../../target/release/libpathfinder_c.a; sourceTree = ""; }; + 6AFD6FF522BD780D00AC1ED3 /* Pathfinder Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Pathfinder Example.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 6AFD6FF822BD780D00AC1ED3 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 6AFD6FF922BD780D00AC1ED3 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 6AFD6FFB22BD781000AC1ED3 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 6AFD6FFE22BD781000AC1ED3 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; + 6AFD700022BD781000AC1ED3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 6AFD700122BD781000AC1ED3 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 6AFD700322BD781000AC1ED3 /* Pathfinder_Example.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Pathfinder_Example.entitlements; sourceTree = ""; }; + 6AFD700922BD7B7A00AC1ED3 /* PathfinderView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PathfinderView.h; sourceTree = ""; }; + 6AFD700A22BD7B7A00AC1ED3 /* PathfinderView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PathfinderView.m; sourceTree = ""; }; + 6AFD700E22BD930500AC1ED3 /* libharfbuzz.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libharfbuzz.a; path = ../../../../../../../usr/local/lib/libharfbuzz.a; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 6AFD6FF222BD780D00AC1ED3 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 6A9A35B322C1E14700B86652 /* libpathfinder_c.a in Frameworks */, + 6AFD700F22BD930500AC1ED3 /* libharfbuzz.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 6AFD6FEC22BD780D00AC1ED3 = { + isa = PBXGroup; + children = ( + 6AFD6FF722BD780D00AC1ED3 /* Pathfinder Example */, + 6AFD6FF622BD780D00AC1ED3 /* Products */, + ); + sourceTree = ""; + }; + 6AFD6FF622BD780D00AC1ED3 /* Products */ = { + isa = PBXGroup; + children = ( + 6AFD6FF522BD780D00AC1ED3 /* Pathfinder Example.app */, + ); + name = Products; + sourceTree = ""; + }; + 6AFD6FF722BD780D00AC1ED3 /* Pathfinder Example */ = { + isa = PBXGroup; + children = ( + 6AFD6FF822BD780D00AC1ED3 /* AppDelegate.h */, + 6AFD6FF922BD780D00AC1ED3 /* AppDelegate.m */, + 6AFD6FFB22BD781000AC1ED3 /* Assets.xcassets */, + 6AFD6FFD22BD781000AC1ED3 /* MainMenu.xib */, + 6AFD700022BD781000AC1ED3 /* Info.plist */, + 6AFD700922BD7B7A00AC1ED3 /* PathfinderView.h */, + 6AFD700A22BD7B7A00AC1ED3 /* PathfinderView.m */, + 6AFD700122BD781000AC1ED3 /* main.m */, + 6AFD700322BD781000AC1ED3 /* Pathfinder_Example.entitlements */, + 6A9A35B222C1E14700B86652 /* libpathfinder_c.a */, + 6AFD700E22BD930500AC1ED3 /* libharfbuzz.a */, + ); + path = "Pathfinder Example"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 6AFD6FF422BD780D00AC1ED3 /* Pathfinder Example */ = { + isa = PBXNativeTarget; + buildConfigurationList = 6AFD700622BD781000AC1ED3 /* Build configuration list for PBXNativeTarget "Pathfinder Example" */; + buildPhases = ( + 6AFD6FF122BD780D00AC1ED3 /* Sources */, + 6AFD6FF222BD780D00AC1ED3 /* Frameworks */, + 6AFD6FF322BD780D00AC1ED3 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "Pathfinder Example"; + productName = "Pathfinder Example"; + productReference = 6AFD6FF522BD780D00AC1ED3 /* Pathfinder Example.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 6AFD6FED22BD780D00AC1ED3 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1020; + ORGANIZATIONNAME = "The Pathfinder Project Deelopers"; + TargetAttributes = { + 6AFD6FF422BD780D00AC1ED3 = { + CreatedOnToolsVersion = 10.2.1; + SystemCapabilities = { + com.apple.Sandbox = { + enabled = 0; + }; + }; + }; + }; + }; + buildConfigurationList = 6AFD6FF022BD780D00AC1ED3 /* Build configuration list for PBXProject "Pathfinder Example" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 6AFD6FEC22BD780D00AC1ED3; + productRefGroup = 6AFD6FF622BD780D00AC1ED3 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 6AFD6FF422BD780D00AC1ED3 /* Pathfinder Example */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 6AFD6FF322BD780D00AC1ED3 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 6AFD6FFC22BD781000AC1ED3 /* Assets.xcassets in Resources */, + 6AFD6FFF22BD781000AC1ED3 /* MainMenu.xib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 6AFD6FF122BD780D00AC1ED3 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 6AFD700222BD781000AC1ED3 /* main.m in Sources */, + 6AFD700B22BD7B7A00AC1ED3 /* PathfinderView.m in Sources */, + 6AFD6FFA22BD780D00AC1ED3 /* AppDelegate.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 6AFD6FFD22BD781000AC1ED3 /* MainMenu.xib */ = { + isa = PBXVariantGroup; + children = ( + 6AFD6FFE22BD781000AC1ED3 /* Base */, + ); + name = MainMenu.xib; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 6AFD700422BD781000AC1ED3 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + 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_DOCUMENTATION_COMMENTS = YES; + 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; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + 6AFD700522BD781000AC1ED3 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + 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_DOCUMENTATION_COMMENTS = YES; + 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; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = macosx; + }; + name = Release; + }; + 6AFD700722BD781000AC1ED3 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + FRAMEWORK_SEARCH_PATHS = ""; + HEADER_SEARCH_PATHS = ../../c/build/include; + INFOPLIST_FILE = "Pathfinder Example/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + LIBRARY_SEARCH_PATHS = ( + ../../target/release, + /usr/local/lib, + ); + PRODUCT_BUNDLE_IDENTIFIER = "graphics.pathfinder.Pathfinder-Example"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 6AFD700822BD781000AC1ED3 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + FRAMEWORK_SEARCH_PATHS = ""; + HEADER_SEARCH_PATHS = ../../c/build/include; + INFOPLIST_FILE = "Pathfinder Example/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + LIBRARY_SEARCH_PATHS = ( + ../../target/release, + /usr/local/lib, + ); + PRODUCT_BUNDLE_IDENTIFIER = "graphics.pathfinder.Pathfinder-Example"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 6AFD6FF022BD780D00AC1ED3 /* Build configuration list for PBXProject "Pathfinder Example" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 6AFD700422BD781000AC1ED3 /* Debug */, + 6AFD700522BD781000AC1ED3 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 6AFD700622BD781000AC1ED3 /* Build configuration list for PBXNativeTarget "Pathfinder Example" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 6AFD700722BD781000AC1ED3 /* Debug */, + 6AFD700822BD781000AC1ED3 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 6AFD6FED22BD780D00AC1ED3 /* Project object */; +} diff --git a/examples/macos_app/Pathfinder Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/examples/macos_app/Pathfinder Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..acd84826 --- /dev/null +++ b/examples/macos_app/Pathfinder Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/examples/macos_app/Pathfinder Example.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/examples/macos_app/Pathfinder Example.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/examples/macos_app/Pathfinder Example.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/examples/macos_app/Pathfinder Example.xcodeproj/xcshareddata/xcschemes/Pathfinder Example.xcscheme b/examples/macos_app/Pathfinder Example.xcodeproj/xcshareddata/xcschemes/Pathfinder Example.xcscheme new file mode 100644 index 00000000..06c13d8b --- /dev/null +++ b/examples/macos_app/Pathfinder Example.xcodeproj/xcshareddata/xcschemes/Pathfinder Example.xcscheme @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/macos_app/Pathfinder Example.xcodeproj/xcuserdata/pcwalton.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/examples/macos_app/Pathfinder Example.xcodeproj/xcuserdata/pcwalton.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 00000000..8f940316 --- /dev/null +++ b/examples/macos_app/Pathfinder Example.xcodeproj/xcuserdata/pcwalton.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,17 @@ + + + + + + + + + diff --git a/examples/macos_app/Pathfinder Example.xcodeproj/xcuserdata/pcwalton.xcuserdatad/xcschemes/xcschememanagement.plist b/examples/macos_app/Pathfinder Example.xcodeproj/xcuserdata/pcwalton.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 00000000..29a687c5 --- /dev/null +++ b/examples/macos_app/Pathfinder Example.xcodeproj/xcuserdata/pcwalton.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,22 @@ + + + + + SchemeUserState + + Pathfinder Example.xcscheme_^#shared#^_ + + orderHint + 0 + + + SuppressBuildableAutocreation + + 6AFD6FF422BD780D00AC1ED3 + + primary + + + + + diff --git a/examples/macos_app/Pathfinder Example/AppDelegate.h b/examples/macos_app/Pathfinder Example/AppDelegate.h new file mode 100644 index 00000000..e8197344 --- /dev/null +++ b/examples/macos_app/Pathfinder Example/AppDelegate.h @@ -0,0 +1,15 @@ +// +// AppDelegate.h +// Pathfinder Example +// +// Created by Patrick Walton on 6/21/19. +// Copyright © 2019 The Pathfinder Project Developers. All rights reserved. +// + +#import + +@interface AppDelegate : NSObject + + +@end + diff --git a/examples/macos_app/Pathfinder Example/AppDelegate.m b/examples/macos_app/Pathfinder Example/AppDelegate.m new file mode 100644 index 00000000..a2448b23 --- /dev/null +++ b/examples/macos_app/Pathfinder Example/AppDelegate.m @@ -0,0 +1,28 @@ +// +// AppDelegate.m +// Pathfinder Example +// +// Created by Patrick Walton on 6/21/19. +// Copyright © 2019 The Pathfinder Project Developers. All rights reserved. +// + +#import "AppDelegate.h" + +@interface AppDelegate () + +@property (weak) IBOutlet NSWindow *window; +@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/examples/macos_app/Pathfinder Example/Assets.xcassets/AppIcon.appiconset/Contents.json b/examples/macos_app/Pathfinder Example/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..2db2b1c7 --- /dev/null +++ b/examples/macos_app/Pathfinder Example/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/examples/macos_app/Pathfinder Example/Assets.xcassets/Contents.json b/examples/macos_app/Pathfinder Example/Assets.xcassets/Contents.json new file mode 100644 index 00000000..da4a164c --- /dev/null +++ b/examples/macos_app/Pathfinder Example/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/examples/macos_app/Pathfinder Example/Base.lproj/MainMenu.xib b/examples/macos_app/Pathfinder Example/Base.lproj/MainMenu.xib new file mode 100644 index 00000000..7423b96f --- /dev/null +++ b/examples/macos_app/Pathfinder Example/Base.lproj/MainMenu.xib @@ -0,0 +1,373 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/macos_app/Pathfinder Example/Info.plist b/examples/macos_app/Pathfinder Example/Info.plist new file mode 100644 index 00000000..bff81736 --- /dev/null +++ b/examples/macos_app/Pathfinder Example/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 © 2019 The Pathfinder Project Developers. All rights reserved. + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/examples/macos_app/Pathfinder Example/PathfinderView.h b/examples/macos_app/Pathfinder Example/PathfinderView.h new file mode 100644 index 00000000..59cf7f5d --- /dev/null +++ b/examples/macos_app/Pathfinder Example/PathfinderView.h @@ -0,0 +1,30 @@ +// +// PathfinderView.h +// Pathfinder Example +// +// Created by Patrick Walton on 6/21/19. +// Copyright © 2019 The Pathfinder Project Developers. All rights reserved. +// + +#import +#import +#include + +NS_ASSUME_NONNULL_BEGIN + +@interface PathfinderView : NSView { + id mDevice; + PFMetalRendererRef mRenderer; + PFCanvasFontContextRef mFontContext; + PFBuildOptionsRef mBuildOptions; + CVDisplayLinkRef mDisplayLink; + int32_t mFrameNumber; + CGSize mLayerSize; + NSLock *mRenderLock; +} + +- (void)_render; + +@end + +NS_ASSUME_NONNULL_END diff --git a/examples/macos_app/Pathfinder Example/PathfinderView.m b/examples/macos_app/Pathfinder Example/PathfinderView.m new file mode 100644 index 00000000..03e539d3 --- /dev/null +++ b/examples/macos_app/Pathfinder Example/PathfinderView.m @@ -0,0 +1,194 @@ +// +// PathfinderView.m +// Pathfinder Example +// +// Created by Patrick Walton on 6/21/19. +// Copyright © 2019 The Pathfinder Project Developers. All rights reserved. +// + +#import +#import "PathfinderView.h" +#import +#include + +static CVReturn outputCallback(CVDisplayLinkRef displayLink, + const CVTimeStamp *now, + const CVTimeStamp *outputTime, + CVOptionFlags flagsIn, + CVOptionFlags *flagsOut, + void *userData) { + [(__bridge PathfinderView *)userData _render]; + return kCVReturnSuccess; +} + +static CATransform3D createPerspectiveMatrix(CGFloat fovY, + CGFloat aspect, + CGFloat zNear, + CGFloat zFar) { + CGFloat f = tan(1.0 / (fovY * 0.5)); + CGFloat zDenom = 1.0 / (zNear - zFar); + + CATransform3D transform = CATransform3DIdentity; + transform.m11 = f / aspect; + transform.m22 = f; + transform.m33 = (zFar + zNear) * zDenom; + transform.m34 = -1.0; + transform.m43 = 2.0 * zFar * zNear * zDenom; + return transform; +} + +static PFTransform3DF pfTransformFromCATransform(const CATransform3D *transform) { + // Core Animation matrices are in column-major order, while Pathfinder matrices are in + // row-major order (at least in the latter's C API). So transpose here. + PFTransform3DF pfTransform; + pfTransform.m00 = (float)transform->m11; + pfTransform.m01 = (float)transform->m21; + pfTransform.m02 = (float)transform->m31; + pfTransform.m03 = (float)transform->m41; + pfTransform.m10 = (float)transform->m12; + pfTransform.m11 = (float)transform->m22; + pfTransform.m12 = (float)transform->m32; + pfTransform.m13 = (float)transform->m42; + pfTransform.m20 = (float)transform->m13; + pfTransform.m21 = (float)transform->m23; + pfTransform.m22 = (float)transform->m33; + pfTransform.m23 = (float)transform->m43; + pfTransform.m30 = (float)transform->m14; + pfTransform.m31 = (float)transform->m24; + pfTransform.m32 = (float)transform->m34; + pfTransform.m33 = (float)transform->m44; + return pfTransform; +} + +@implementation PathfinderView + +#define FONT_SIZE 256.0f + +- (void)_render { + [mRenderLock lock]; + + CGSize size = mLayerSize; + + PFCanvasRef canvas = PFCanvasCreate(mFontContext, &(PFVector2F){size.width, size.height}); + PFFillStyleRef fillStyle = + PFFillStyleCreateColor(&(PFColorU){0, 0, 0, 255}); + PFCanvasSetFillStyle(canvas, fillStyle); + PFCanvasSetFontSize(canvas, FONT_SIZE); + PFCanvasSetTextAlign(canvas, PF_TEXT_ALIGN_CENTER); + PFVector2F textOrigin; + textOrigin.x = 0.0; + textOrigin.y = FONT_SIZE * 0.25; + PFCanvasFillText(canvas, "Pathfinder", 0, &textOrigin); + PFCanvasFillRect(canvas, &(const PFRectF){0.0, 0.0, 1.0, 1.0}); + PFFillStyleDestroy(fillStyle); + + PFSceneRef scene = PFCanvasCreateScene(canvas); + PFSceneProxyRef sceneProxy = PFSceneProxyCreateFromSceneAndRayonExecutor(scene); + + int32_t frame = mFrameNumber; + int32_t nT = frame % 240; + if (nT > 120) + nT = 240 - nT; + + CATransform3D transform = + CATransform3DMakeTranslation(0.0, 0.0, -8.0 + (CGFloat)nT / 120.0 * 8.0); + transform = CATransform3DRotate(transform, + frame / 120.0 * M_PI * 2.0, + 0.0, + 1.0, + 0.0); + transform = CATransform3DScale(transform, -2.0 / size.width, 2.0 / size.height, 1.0); + CGFloat aspect = size.width / size.height; + transform = CATransform3DConcat(transform, + createPerspectiveMatrix(M_PI * 0.25, aspect, 0.01, 10.0)); + PFPerspective pfPerspective; + pfPerspective.transform = pfTransformFromCATransform(&transform); + pfPerspective.window_size.x = size.width; + pfPerspective.window_size.y = size.height; + + PFBuildOptionsRef buildOptions = PFBuildOptionsCreate(); + PFRenderTransformRef renderTransform = PFRenderTransformCreatePerspective(&pfPerspective); + PFBuildOptionsSetTransform(buildOptions, renderTransform); + PFSceneProxyBuildAndRenderMetal(sceneProxy, mRenderer, buildOptions); + + PFMetalDevicePresentDrawable(PFMetalRendererGetDevice(mRenderer)); + + mFrameNumber++; + + [mRenderLock unlock]; +} + +- (void)_checkCVResult:(CVReturn)result { + if (result != kCVReturnSuccess) { + @throw [NSException exceptionWithName:@"CoreVideoCallFailed" + reason:@"Core Video call failed" + userInfo:nil]; + } +} + +- (void)_initializeIfNecessary:(CAMetalLayer *)layer { + if (mDevice != nil) + return; + + mFrameNumber = 0; + + mDevice = MTLCreateSystemDefaultDevice(); + [layer setDevice:mDevice]; + [layer setContentsScale:[[self window] backingScaleFactor]]; + + mRenderLock = [[NSLock alloc] init]; + mLayerSize = [self convertSizeToBacking:[layer bounds].size]; + + PFMetalDeviceRef device = PFMetalDeviceCreate(layer); + PFResourceLoaderRef resourceLoader = PFFilesystemResourceLoaderLocate(); + PFMetalDestFramebufferRef destFramebuffer = + PFMetalDestFramebufferCreateFullWindow(&(PFVector2I){mLayerSize.width, mLayerSize.height}); + + PFRendererOptions rendererOptions; + rendererOptions.background_color = (PFColorF){1.0, 1.0, 1.0, 1.0}; + rendererOptions.flags = PF_RENDERER_OPTIONS_FLAGS_HAS_BACKGROUND_COLOR; + mRenderer = PFMetalRendererCreate(device, + resourceLoader, + destFramebuffer, + &rendererOptions); + + mFontContext = PFCanvasFontContextCreateWithSystemSource(); + + mBuildOptions = PFBuildOptionsCreate(); + + [self _checkCVResult:CVDisplayLinkCreateWithActiveCGDisplays(&mDisplayLink)]; + [self _checkCVResult:CVDisplayLinkSetOutputCallback(mDisplayLink, + outputCallback, + (__bridge void *_Nullable)(self))]; + [self _checkCVResult:CVDisplayLinkStart(mDisplayLink)]; +} + +- (CALayer *)makeBackingLayer { + return [[CAMetalLayer alloc] init]; +} + +- (BOOL)wantsLayer { + return YES; +} + +- (BOOL)wantsUpdateLayer { + return YES; +} + +- (NSViewLayerContentsRedrawPolicy)layerContentsRedrawPolicy { + return NSViewLayerContentsRedrawOnSetNeedsDisplay; +} + +- (void)drawRect:(NSRect)dirtyRect { + [self _initializeIfNecessary:(CAMetalLayer *)[self layer]]; +} + +- (void)displayLayer:(CALayer *)layer { + [self _initializeIfNecessary:(CAMetalLayer *)layer]; +} + +- (void)awakeFromNib { + [self _initializeIfNecessary:(CAMetalLayer *)[self layer]]; +} + +@end diff --git a/examples/macos_app/Pathfinder Example/Pathfinder_Example.entitlements b/examples/macos_app/Pathfinder Example/Pathfinder_Example.entitlements new file mode 100644 index 00000000..0c67376e --- /dev/null +++ b/examples/macos_app/Pathfinder Example/Pathfinder_Example.entitlements @@ -0,0 +1,5 @@ + + + + + diff --git a/examples/macos_app/Pathfinder Example/main.m b/examples/macos_app/Pathfinder Example/main.m new file mode 100644 index 00000000..8f6058f1 --- /dev/null +++ b/examples/macos_app/Pathfinder Example/main.m @@ -0,0 +1,13 @@ +// +// main.m +// Pathfinder Example +// +// Created by Patrick Walton on 6/21/19. +// Copyright © 2019 The Pathfinder Project Developers. All rights reserved. +// + +#import + +int main(int argc, const char * argv[]) { + return NSApplicationMain(argc, argv); +}