add metal sample code and xcode project

This commit is contained in:
Ronja Enseleit 2023-07-01 17:24:53 +02:00
parent ab5d284b80
commit a3a5a5807f
22 changed files with 1125 additions and 0 deletions

View File

@ -0,0 +1,418 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 56;
objects = {
/* Begin PBXBuildFile section */
FBA9A7502A50790A00F960DA /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = FBA9A74F2A50790A00F960DA /* AppDelegate.m */; };
FBA9A7532A50790A00F960DA /* Renderer.m in Sources */ = {isa = PBXBuildFile; fileRef = FBA9A7522A50790A00F960DA /* Renderer.m */; };
FBA9A7562A50790A00F960DA /* GameViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FBA9A7552A50790A00F960DA /* GameViewController.m */; };
FBA9A7582A50790A00F960DA /* Shaders.metal in Sources */ = {isa = PBXBuildFile; fileRef = FBA9A7572A50790A00F960DA /* Shaders.metal */; };
FBA9A75C2A50790A00F960DA /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FBA9A75A2A50790A00F960DA /* Main.storyboard */; };
FBA9A75E2A50790A00F960DA /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = FBA9A75D2A50790A00F960DA /* Assets.xcassets */; };
FBA9A7612A50790A00F960DA /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FBA9A75F2A50790A00F960DA /* LaunchScreen.storyboard */; };
FBA9A7632A50790A00F960DA /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = FBA9A7622A50790A00F960DA /* main.m */; };
FBA9A7682A50795000F960DA /* StringRepository.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FBA9A7432A5078D800F960DA /* StringRepository.cpp */; };
FBA9A7692A50795400F960DA /* AssetManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FBA9A73D2A5078B800F960DA /* AssetManager.cpp */; };
FBA9A76A2A50795700F960DA /* Hash.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FBA9A73A2A5078B800F960DA /* Hash.cpp */; };
FBA9A76B2A5079BC00F960DA /* Texture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FBA9A73F2A5078D800F960DA /* Texture.cpp */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
FBA9A7342A5078B800F960DA /* AssetManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = AssetManager.h; path = cpp/AssetManager.h; sourceTree = "<group>"; };
FBA9A7352A5078B800F960DA /* Font.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = Font.cpp; path = cpp/Font.cpp; sourceTree = "<group>"; };
FBA9A7372A5078B800F960DA /* Hash.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Hash.h; path = cpp/Hash.h; sourceTree = "<group>"; };
FBA9A7382A5078B800F960DA /* Font.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Font.h; path = cpp/Font.h; sourceTree = "<group>"; };
FBA9A7392A5078B800F960DA /* Profiling.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Profiling.h; path = cpp/Profiling.h; sourceTree = "<group>"; };
FBA9A73A2A5078B800F960DA /* Hash.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = Hash.cpp; path = cpp/Hash.cpp; sourceTree = "<group>"; };
FBA9A73B2A5078B800F960DA /* Position.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Position.h; path = cpp/Position.h; sourceTree = "<group>"; };
FBA9A73C2A5078B800F960DA /* GameState.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = GameState.h; path = cpp/GameState.h; sourceTree = "<group>"; };
FBA9A73D2A5078B800F960DA /* AssetManager.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = AssetManager.cpp; path = cpp/AssetManager.cpp; sourceTree = "<group>"; };
FBA9A73E2A5078D800F960DA /* StringRepository.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = StringRepository.h; path = cpp/StringRepository.h; sourceTree = "<group>"; };
FBA9A73F2A5078D800F960DA /* Texture.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = Texture.cpp; path = cpp/Texture.cpp; sourceTree = "<group>"; };
FBA9A7402A5078D800F960DA /* stb_truetype.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = stb_truetype.h; path = cpp/stb_truetype.h; sourceTree = "<group>"; };
FBA9A7412A5078D800F960DA /* stb_image.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = stb_image.h; path = cpp/stb_image.h; sourceTree = "<group>"; };
FBA9A7422A5078D800F960DA /* Texture.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Texture.h; path = cpp/Texture.h; sourceTree = "<group>"; };
FBA9A7432A5078D800F960DA /* StringRepository.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = StringRepository.cpp; path = cpp/StringRepository.cpp; sourceTree = "<group>"; };
FBA9A7452A5078D800F960DA /* TouchInput.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = TouchInput.h; path = cpp/TouchInput.h; sourceTree = "<group>"; };
FBA9A74B2A50790A00F960DA /* KDE.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = KDE.app; sourceTree = BUILT_PRODUCTS_DIR; };
FBA9A74E2A50790A00F960DA /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
FBA9A74F2A50790A00F960DA /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
FBA9A7512A50790A00F960DA /* Renderer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Renderer.h; sourceTree = "<group>"; };
FBA9A7522A50790A00F960DA /* Renderer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Renderer.m; sourceTree = "<group>"; };
FBA9A7542A50790A00F960DA /* GameViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GameViewController.h; sourceTree = "<group>"; };
FBA9A7552A50790A00F960DA /* GameViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GameViewController.m; sourceTree = "<group>"; };
FBA9A7572A50790A00F960DA /* Shaders.metal */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.metal; path = Shaders.metal; sourceTree = "<group>"; };
FBA9A7592A50790A00F960DA /* ShaderTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ShaderTypes.h; sourceTree = "<group>"; };
FBA9A75B2A50790A00F960DA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
FBA9A75D2A50790A00F960DA /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
FBA9A7602A50790A00F960DA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
FBA9A7622A50790A00F960DA /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
FBA9A7482A50790A00F960DA /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
FBA9A7332A50789900F960DA /* cpp */ = {
isa = PBXGroup;
children = (
FBA9A7412A5078D800F960DA /* stb_image.h */,
FBA9A7402A5078D800F960DA /* stb_truetype.h */,
FBA9A7432A5078D800F960DA /* StringRepository.cpp */,
FBA9A73E2A5078D800F960DA /* StringRepository.h */,
FBA9A73F2A5078D800F960DA /* Texture.cpp */,
FBA9A7422A5078D800F960DA /* Texture.h */,
FBA9A7452A5078D800F960DA /* TouchInput.h */,
FBA9A73D2A5078B800F960DA /* AssetManager.cpp */,
FBA9A7342A5078B800F960DA /* AssetManager.h */,
FBA9A7352A5078B800F960DA /* Font.cpp */,
FBA9A7382A5078B800F960DA /* Font.h */,
FBA9A73C2A5078B800F960DA /* GameState.h */,
FBA9A73A2A5078B800F960DA /* Hash.cpp */,
FBA9A7372A5078B800F960DA /* Hash.h */,
FBA9A73B2A5078B800F960DA /* Position.h */,
FBA9A7392A5078B800F960DA /* Profiling.h */,
);
name = cpp;
sourceTree = "<group>";
};
FBA9A7462A5078DC00F960DA /* m */ = {
isa = PBXGroup;
children = (
FBA9A74E2A50790A00F960DA /* AppDelegate.h */,
FBA9A74F2A50790A00F960DA /* AppDelegate.m */,
FBA9A7512A50790A00F960DA /* Renderer.h */,
FBA9A7522A50790A00F960DA /* Renderer.m */,
FBA9A7542A50790A00F960DA /* GameViewController.h */,
FBA9A7552A50790A00F960DA /* GameViewController.m */,
FBA9A7572A50790A00F960DA /* Shaders.metal */,
FBA9A7592A50790A00F960DA /* ShaderTypes.h */,
FBA9A75A2A50790A00F960DA /* Main.storyboard */,
FBA9A75D2A50790A00F960DA /* Assets.xcassets */,
FBA9A75F2A50790A00F960DA /* LaunchScreen.storyboard */,
FBA9A7622A50790A00F960DA /* main.m */,
);
path = m;
sourceTree = "<group>";
};
FBA9A74C2A50790A00F960DA /* Products */ = {
isa = PBXGroup;
children = (
FBA9A74B2A50790A00F960DA /* KDE.app */,
);
name = Products;
sourceTree = "<group>";
};
FBC6DF7A2A50782C00CA10E7 = {
isa = PBXGroup;
children = (
FBA9A7462A5078DC00F960DA /* m */,
FBA9A7332A50789900F960DA /* cpp */,
FBA9A74C2A50790A00F960DA /* Products */,
);
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
FBA9A74A2A50790A00F960DA /* KDE */ = {
isa = PBXNativeTarget;
buildConfigurationList = FBA9A7642A50790A00F960DA /* Build configuration list for PBXNativeTarget "KDE" */;
buildPhases = (
FBA9A7472A50790A00F960DA /* Sources */,
FBA9A7482A50790A00F960DA /* Frameworks */,
FBA9A7492A50790A00F960DA /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = KDE;
productName = KDE;
productReference = FBA9A74B2A50790A00F960DA /* KDE.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
FBC6DF7B2A50782C00CA10E7 /* Project object */ = {
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = 1;
LastUpgradeCheck = 1430;
TargetAttributes = {
FBA9A74A2A50790A00F960DA = {
CreatedOnToolsVersion = 14.3.1;
};
};
};
buildConfigurationList = FBC6DF7E2A50782C00CA10E7 /* Build configuration list for PBXProject "KDE" */;
compatibilityVersion = "Xcode 14.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = FBC6DF7A2A50782C00CA10E7;
productRefGroup = FBA9A74C2A50790A00F960DA /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
FBA9A74A2A50790A00F960DA /* KDE */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
FBA9A7492A50790A00F960DA /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
FBA9A7612A50790A00F960DA /* LaunchScreen.storyboard in Resources */,
FBA9A75E2A50790A00F960DA /* Assets.xcassets in Resources */,
FBA9A75C2A50790A00F960DA /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
FBA9A7472A50790A00F960DA /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
FBA9A7692A50795400F960DA /* AssetManager.cpp in Sources */,
FBA9A7632A50790A00F960DA /* main.m in Sources */,
FBA9A7582A50790A00F960DA /* Shaders.metal in Sources */,
FBA9A76B2A5079BC00F960DA /* Texture.cpp in Sources */,
FBA9A7682A50795000F960DA /* StringRepository.cpp in Sources */,
FBA9A7532A50790A00F960DA /* Renderer.m in Sources */,
FBA9A76A2A50795700F960DA /* Hash.cpp in Sources */,
FBA9A7562A50790A00F960DA /* GameViewController.m in Sources */,
FBA9A7502A50790A00F960DA /* AppDelegate.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
FBA9A75A2A50790A00F960DA /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
FBA9A75B2A50790A00F960DA /* Base */,
);
name = Main.storyboard;
sourceTree = "<group>";
};
FBA9A75F2A50790A00F960DA /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
FBA9A7602A50790A00F960DA /* Base */,
);
name = LaunchScreen.storyboard;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
FBA9A7652A50790A00F960DA /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
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_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
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_STYLE = Automatic;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
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;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UIMainStoryboardFile = Main;
INFOPLIST_KEY_UIRequiredDeviceCapabilities = metal;
INFOPLIST_KEY_UIStatusBarHidden = YES;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 16.4;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.fumblegames.KDE;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
SWIFT_EMIT_LOC_STRINGS = YES;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
FBA9A7662A50790A00F960DA /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
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_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
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_STYLE = Automatic;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
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;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UIMainStoryboardFile = Main;
INFOPLIST_KEY_UIRequiredDeviceCapabilities = metal;
INFOPLIST_KEY_UIStatusBarHidden = YES;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 16.4;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.fumblegames.KDE;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
SWIFT_EMIT_LOC_STRINGS = YES;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
FBC6DF7F2A50782C00CA10E7 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
};
name = Debug;
};
FBC6DF802A50782C00CA10E7 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
FBA9A7642A50790A00F960DA /* Build configuration list for PBXNativeTarget "KDE" */ = {
isa = XCConfigurationList;
buildConfigurations = (
FBA9A7652A50790A00F960DA /* Debug */,
FBA9A7662A50790A00F960DA /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
FBC6DF7E2A50782C00CA10E7 /* Build configuration list for PBXProject "KDE" */ = {
isa = XCConfigurationList;
buildConfigurations = (
FBC6DF7F2A50782C00CA10E7 /* Debug */,
FBC6DF802A50782C00CA10E7 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = FBC6DF7B2A50782C00CA10E7 /* Project object */;
}

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:">
</FileRef>
</Workspace>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>KDE.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>

View File

@ -0,0 +1,16 @@
//
// AppDelegate.h
// KDE
//
// Created by Ronja Enseleit on 01.07.23.
//
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end

View File

@ -0,0 +1,44 @@
//
// AppDelegate.m
// KDE
//
// Created by Ronja Enseleit on 01.07.23.
//
#import "AppDelegate.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
@end

View File

@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@ -0,0 +1,13 @@
{
"images" : [
{
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@ -0,0 +1,17 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
},
"properties" : {
"origin" : "bottom-left",
"interpretation" : "non-premultiplied-colors"
},
"textures" : [
{
"idiom" : "universal",
"filename" : "Universal.mipmapset"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

View File

@ -0,0 +1,12 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
},
"levels" : [
{
"filename" : "ColorMap.png",
"mipmap-level" : "base"
}
]
}

View File

@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BV1-FR-VrT">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Game View Controller-->
<scene sceneID="tXr-a1-R10">
<objects>
<viewController id="BV1-FR-VrT" customClass="GameViewController" customModuleProvider="" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="3se-qz-xqx" customClass="MTKView">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="rZh-zQ-HcR"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="SZV-WD-TEh" sceneMemberID="firstResponder"/>
</objects>
</scene>
</scenes>
</document>

View File

@ -0,0 +1,16 @@
//
// GameViewController.h
// KDE
//
// Created by Ronja Enseleit on 01.07.23.
//
#import <UIKit/UIKit.h>
#import <Metal/Metal.h>
#import <MetalKit/MetalKit.h>
#import "Renderer.h"
// Our iOS view controller
@interface GameViewController : UIViewController
@end

View File

@ -0,0 +1,41 @@
//
// GameViewController.m
// KDE
//
// Created by Ronja Enseleit on 01.07.23.
//
#import "GameViewController.h"
#import "Renderer.h"
@implementation GameViewController
{
MTKView *_view;
Renderer *_renderer;
}
- (void)viewDidLoad
{
[super viewDidLoad];
_view = (MTKView *)self.view;
_view.device = MTLCreateSystemDefaultDevice();
_view.backgroundColor = UIColor.blackColor;
if(!_view.device)
{
NSLog(@"Metal is not supported on this device");
self.view = [[UIView alloc] initWithFrame:self.view.frame];
return;
}
_renderer = [[Renderer alloc] initWithMetalKitView:_view];
[_renderer mtkView:_view drawableSizeWillChange:_view.bounds.size];
_view.delegate = _renderer;
}
@end

17
app/src/main/m/Renderer.h Normal file
View File

@ -0,0 +1,17 @@
//
// Renderer.h
// KDE
//
// Created by Ronja Enseleit on 01.07.23.
//
#import <MetalKit/MetalKit.h>
// Our platform independent renderer class. Implements the MTKViewDelegate protocol which
// allows it to accept per-frame update and drawable resize callbacks.
@interface Renderer : NSObject <MTKViewDelegate>
-(nonnull instancetype)initWithMetalKitView:(nonnull MTKView *)view;
@end

316
app/src/main/m/Renderer.m Normal file
View File

@ -0,0 +1,316 @@
//
// Renderer.m
// KDE
//
// Created by Ronja Enseleit on 01.07.23.
//
#import <simd/simd.h>
#import <ModelIO/ModelIO.h>
#import "Renderer.h"
// Include header shared between C code here, which executes Metal API commands, and .metal files
#import "ShaderTypes.h"
static const NSUInteger MaxBuffersInFlight = 3;
@implementation Renderer
{
dispatch_semaphore_t _inFlightSemaphore;
id <MTLDevice> _device;
id <MTLCommandQueue> _commandQueue;
id <MTLBuffer> _dynamicUniformBuffer[MaxBuffersInFlight];
id <MTLRenderPipelineState> _pipelineState;
id <MTLDepthStencilState> _depthState;
id <MTLTexture> _colorMap;
MTLVertexDescriptor *_mtlVertexDescriptor;
uint8_t _uniformBufferIndex;
matrix_float4x4 _projectionMatrix;
float _rotation;
MTKMesh *_mesh;
}
-(nonnull instancetype)initWithMetalKitView:(nonnull MTKView *)view;
{
self = [super init];
if(self)
{
_device = view.device;
_inFlightSemaphore = dispatch_semaphore_create(MaxBuffersInFlight);
[self _loadMetalWithView:view];
[self _loadAssets];
}
return self;
}
- (void)_loadMetalWithView:(nonnull MTKView *)view;
{
/// Load Metal state objects and initialize renderer dependent view properties
view.depthStencilPixelFormat = MTLPixelFormatDepth32Float_Stencil8;
view.colorPixelFormat = MTLPixelFormatBGRA8Unorm_sRGB;
view.sampleCount = 1;
_mtlVertexDescriptor = [[MTLVertexDescriptor alloc] init];
_mtlVertexDescriptor.attributes[VertexAttributePosition].format = MTLVertexFormatFloat3;
_mtlVertexDescriptor.attributes[VertexAttributePosition].offset = 0;
_mtlVertexDescriptor.attributes[VertexAttributePosition].bufferIndex = BufferIndexMeshPositions;
_mtlVertexDescriptor.attributes[VertexAttributeTexcoord].format = MTLVertexFormatFloat2;
_mtlVertexDescriptor.attributes[VertexAttributeTexcoord].offset = 0;
_mtlVertexDescriptor.attributes[VertexAttributeTexcoord].bufferIndex = BufferIndexMeshGenerics;
_mtlVertexDescriptor.layouts[BufferIndexMeshPositions].stride = 12;
_mtlVertexDescriptor.layouts[BufferIndexMeshPositions].stepRate = 1;
_mtlVertexDescriptor.layouts[BufferIndexMeshPositions].stepFunction = MTLVertexStepFunctionPerVertex;
_mtlVertexDescriptor.layouts[BufferIndexMeshGenerics].stride = 8;
_mtlVertexDescriptor.layouts[BufferIndexMeshGenerics].stepRate = 1;
_mtlVertexDescriptor.layouts[BufferIndexMeshGenerics].stepFunction = MTLVertexStepFunctionPerVertex;
id<MTLLibrary> defaultLibrary = [_device newDefaultLibrary];
id <MTLFunction> vertexFunction = [defaultLibrary newFunctionWithName:@"vertexShader"];
id <MTLFunction> fragmentFunction = [defaultLibrary newFunctionWithName:@"fragmentShader"];
MTLRenderPipelineDescriptor *pipelineStateDescriptor = [[MTLRenderPipelineDescriptor alloc] init];
pipelineStateDescriptor.label = @"MyPipeline";
pipelineStateDescriptor.rasterSampleCount = view.sampleCount;
pipelineStateDescriptor.vertexFunction = vertexFunction;
pipelineStateDescriptor.fragmentFunction = fragmentFunction;
pipelineStateDescriptor.vertexDescriptor = _mtlVertexDescriptor;
pipelineStateDescriptor.colorAttachments[0].pixelFormat = view.colorPixelFormat;
pipelineStateDescriptor.depthAttachmentPixelFormat = view.depthStencilPixelFormat;
pipelineStateDescriptor.stencilAttachmentPixelFormat = view.depthStencilPixelFormat;
NSError *error = NULL;
_pipelineState = [_device newRenderPipelineStateWithDescriptor:pipelineStateDescriptor error:&error];
if (!_pipelineState)
{
NSLog(@"Failed to created pipeline state, error %@", error);
}
MTLDepthStencilDescriptor *depthStateDesc = [[MTLDepthStencilDescriptor alloc] init];
depthStateDesc.depthCompareFunction = MTLCompareFunctionLess;
depthStateDesc.depthWriteEnabled = YES;
_depthState = [_device newDepthStencilStateWithDescriptor:depthStateDesc];
for(NSUInteger i = 0; i < MaxBuffersInFlight; i++)
{
_dynamicUniformBuffer[i] = [_device newBufferWithLength:sizeof(Uniforms)
options:MTLResourceStorageModeShared];
_dynamicUniformBuffer[i].label = @"UniformBuffer";
}
_commandQueue = [_device newCommandQueue];
}
- (void)_loadAssets
{
/// Load assets into metal objects
NSError *error;
MTKMeshBufferAllocator *metalAllocator = [[MTKMeshBufferAllocator alloc]
initWithDevice: _device];
MDLMesh *mdlMesh = [MDLMesh newBoxWithDimensions:(vector_float3){4, 4, 4}
segments:(vector_uint3){2, 2, 2}
geometryType:MDLGeometryTypeTriangles
inwardNormals:NO
allocator:metalAllocator];
MDLVertexDescriptor *mdlVertexDescriptor =
MTKModelIOVertexDescriptorFromMetal(_mtlVertexDescriptor);
mdlVertexDescriptor.attributes[VertexAttributePosition].name = MDLVertexAttributePosition;
mdlVertexDescriptor.attributes[VertexAttributeTexcoord].name = MDLVertexAttributeTextureCoordinate;
mdlMesh.vertexDescriptor = mdlVertexDescriptor;
_mesh = [[MTKMesh alloc] initWithMesh:mdlMesh
device:_device
error:&error];
if(!_mesh || error)
{
NSLog(@"Error creating MetalKit mesh %@", error.localizedDescription);
}
MTKTextureLoader* textureLoader = [[MTKTextureLoader alloc] initWithDevice:_device];
NSDictionary *textureLoaderOptions =
@{
MTKTextureLoaderOptionTextureUsage : @(MTLTextureUsageShaderRead),
MTKTextureLoaderOptionTextureStorageMode : @(MTLStorageModePrivate)
};
_colorMap = [textureLoader newTextureWithName:@"ColorMap"
scaleFactor:1.0
bundle:nil
options:textureLoaderOptions
error:&error];
if(!_colorMap || error)
{
NSLog(@"Error creating texture %@", error.localizedDescription);
}
}
- (void)_updateGameState
{
/// Update any game state before encoding renderint commands to our drawable
Uniforms * uniforms = (Uniforms*)_dynamicUniformBuffer[_uniformBufferIndex].contents;
uniforms->projectionMatrix = _projectionMatrix;
vector_float3 rotationAxis = {1, 1, 0};
matrix_float4x4 modelMatrix = matrix4x4_rotation(_rotation, rotationAxis);
matrix_float4x4 viewMatrix = matrix4x4_translation(0.0, 0.0, -8.0);
uniforms->modelViewMatrix = matrix_multiply(viewMatrix, modelMatrix);
_rotation += .01;
}
- (void)drawInMTKView:(nonnull MTKView *)view
{
/// Per frame updates here
dispatch_semaphore_wait(_inFlightSemaphore, DISPATCH_TIME_FOREVER);
_uniformBufferIndex = (_uniformBufferIndex + 1) % MaxBuffersInFlight;
id <MTLCommandBuffer> commandBuffer = [_commandQueue commandBuffer];
commandBuffer.label = @"MyCommand";
__block dispatch_semaphore_t block_sema = _inFlightSemaphore;
[commandBuffer addCompletedHandler:^(id<MTLCommandBuffer> buffer)
{
dispatch_semaphore_signal(block_sema);
}];
[self _updateGameState];
/// Delay getting the currentRenderPassDescriptor until absolutely needed. This avoids
/// holding onto the drawable and blocking the display pipeline any longer than necessary
MTLRenderPassDescriptor* renderPassDescriptor = view.currentRenderPassDescriptor;
if(renderPassDescriptor != nil)
{
/// Final pass rendering code here
id <MTLRenderCommandEncoder> renderEncoder =
[commandBuffer renderCommandEncoderWithDescriptor:renderPassDescriptor];
renderEncoder.label = @"MyRenderEncoder";
[renderEncoder pushDebugGroup:@"DrawBox"];
[renderEncoder setFrontFacingWinding:MTLWindingCounterClockwise];
[renderEncoder setCullMode:MTLCullModeBack];
[renderEncoder setRenderPipelineState:_pipelineState];
[renderEncoder setDepthStencilState:_depthState];
[renderEncoder setVertexBuffer:_dynamicUniformBuffer[_uniformBufferIndex]
offset:0
atIndex:BufferIndexUniforms];
[renderEncoder setFragmentBuffer:_dynamicUniformBuffer[_uniformBufferIndex]
offset:0
atIndex:BufferIndexUniforms];
for (NSUInteger bufferIndex = 0; bufferIndex < _mesh.vertexBuffers.count; bufferIndex++)
{
MTKMeshBuffer *vertexBuffer = _mesh.vertexBuffers[bufferIndex];
if((NSNull*)vertexBuffer != [NSNull null])
{
[renderEncoder setVertexBuffer:vertexBuffer.buffer
offset:vertexBuffer.offset
atIndex:bufferIndex];
}
}
[renderEncoder setFragmentTexture:_colorMap
atIndex:TextureIndexColor];
for(MTKSubmesh *submesh in _mesh.submeshes)
{
[renderEncoder drawIndexedPrimitives:submesh.primitiveType
indexCount:submesh.indexCount
indexType:submesh.indexType
indexBuffer:submesh.indexBuffer.buffer
indexBufferOffset:submesh.indexBuffer.offset];
}
[renderEncoder popDebugGroup];
[renderEncoder endEncoding];
[commandBuffer presentDrawable:view.currentDrawable];
}
[commandBuffer commit];
}
- (void)mtkView:(nonnull MTKView *)view drawableSizeWillChange:(CGSize)size
{
/// Respond to drawable size or orientation changes here
float aspect = size.width / (float)size.height;
_projectionMatrix = matrix_perspective_right_hand(65.0f * (M_PI / 180.0f), aspect, 0.1f, 100.0f);
}
#pragma mark Matrix Math Utilities
matrix_float4x4 matrix4x4_translation(float tx, float ty, float tz)
{
return (matrix_float4x4) {{
{ 1, 0, 0, 0 },
{ 0, 1, 0, 0 },
{ 0, 0, 1, 0 },
{ tx, ty, tz, 1 }
}};
}
static matrix_float4x4 matrix4x4_rotation(float radians, vector_float3 axis)
{
axis = vector_normalize(axis);
float ct = cosf(radians);
float st = sinf(radians);
float ci = 1 - ct;
float x = axis.x, y = axis.y, z = axis.z;
return (matrix_float4x4) {{
{ ct + x * x * ci, y * x * ci + z * st, z * x * ci - y * st, 0},
{ x * y * ci - z * st, ct + y * y * ci, z * y * ci + x * st, 0},
{ x * z * ci + y * st, y * z * ci - x * st, ct + z * z * ci, 0},
{ 0, 0, 0, 1}
}};
}
matrix_float4x4 matrix_perspective_right_hand(float fovyRadians, float aspect, float nearZ, float farZ)
{
float ys = 1 / tanf(fovyRadians * 0.5);
float xs = ys / aspect;
float zs = farZ / (nearZ - farZ);
return (matrix_float4x4) {{
{ xs, 0, 0, 0 },
{ 0, ys, 0, 0 },
{ 0, 0, zs, -1 },
{ 0, 0, nearZ * zs, 0 }
}};
}
@end

View File

@ -0,0 +1,49 @@
//
// ShaderTypes.h
// KDE
//
// Created by Ronja Enseleit on 01.07.23.
//
//
// Header containing types and enum constants shared between Metal shaders and Swift/ObjC source
//
#ifndef ShaderTypes_h
#define ShaderTypes_h
#ifdef __METAL_VERSION__
#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
typedef metal::int32_t EnumBackingType;
#else
#import <Foundation/Foundation.h>
typedef NSInteger EnumBackingType;
#endif
#include <simd/simd.h>
typedef NS_ENUM(EnumBackingType, BufferIndex)
{
BufferIndexMeshPositions = 0,
BufferIndexMeshGenerics = 1,
BufferIndexUniforms = 2
};
typedef NS_ENUM(EnumBackingType, VertexAttribute)
{
VertexAttributePosition = 0,
VertexAttributeTexcoord = 1,
};
typedef NS_ENUM(EnumBackingType, TextureIndex)
{
TextureIndexColor = 0,
};
typedef struct
{
matrix_float4x4 projectionMatrix;
matrix_float4x4 modelViewMatrix;
} Uniforms;
#endif /* ShaderTypes_h */

View File

@ -0,0 +1,53 @@
//
// Shaders.metal
// KDE
//
// Created by Ronja Enseleit on 01.07.23.
//
// File for Metal kernel and shader functions
#include <metal_stdlib>
#include <simd/simd.h>
// Including header shared between this Metal shader code and Swift/C code executing Metal API commands
#import "ShaderTypes.h"
using namespace metal;
typedef struct
{
float3 position [[attribute(VertexAttributePosition)]];
float2 texCoord [[attribute(VertexAttributeTexcoord)]];
} Vertex;
typedef struct
{
float4 position [[position]];
float2 texCoord;
} ColorInOut;
vertex ColorInOut vertexShader(Vertex in [[stage_in]],
constant Uniforms & uniforms [[ buffer(BufferIndexUniforms) ]])
{
ColorInOut out;
float4 position = float4(in.position, 1.0);
out.position = uniforms.projectionMatrix * uniforms.modelViewMatrix * position;
out.texCoord = in.texCoord;
return out;
}
fragment float4 fragmentShader(ColorInOut in [[stage_in]],
constant Uniforms & uniforms [[ buffer(BufferIndexUniforms) ]],
texture2d<half> colorMap [[ texture(TextureIndexColor) ]])
{
constexpr sampler colorSampler(mip_filter::linear,
mag_filter::linear,
min_filter::linear);
half4 colorSample = colorMap.sample(colorSampler, in.texCoord.xy);
return float4(colorSample);
}

18
app/src/main/m/main.m Normal file
View File

@ -0,0 +1,18 @@
//
// main.m
// KDE
//
// Created by Ronja Enseleit on 01.07.23.
//
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char * argv[]) {
NSString * appDelegateClassName;
@autoreleasepool {
// Setup code that might create autoreleased objects goes here.
appDelegateClassName = NSStringFromClass([AppDelegate class]);
}
return UIApplicationMain(argc, argv, nil, appDelegateClassName);
}