Update the code for the iOS demos to handle modern devices. Fixes bug #3337

This commit is contained in:
Alex Szpakowski 2016-09-25 00:23:35 -03:00
parent 40ecac8e60
commit a8b033d7c4
12 changed files with 233 additions and 143 deletions

View File

@ -24,6 +24,13 @@
FA30DECD1BBF5C14009C397F /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; }; FA30DECD1BBF5C14009C397F /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; };
FA30DECE1BBF5C14009C397F /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; }; FA30DECE1BBF5C14009C397F /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
FA30DECF1BBF5C14009C397F /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDF0D71D0E12D2AB00247964 /* CoreAudio.framework */; }; FA30DECF1BBF5C14009C397F /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDF0D71D0E12D2AB00247964 /* CoreAudio.framework */; };
FA86C0371D9765BB009CB637 /* iOS Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FA86C0361D9765BA009CB637 /* iOS Launch Screen.storyboard */; };
FA86C0381D9765BB009CB637 /* iOS Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FA86C0361D9765BA009CB637 /* iOS Launch Screen.storyboard */; };
FA86C0391D9765BB009CB637 /* iOS Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FA86C0361D9765BA009CB637 /* iOS Launch Screen.storyboard */; };
FA86C03A1D9765BB009CB637 /* iOS Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FA86C0361D9765BA009CB637 /* iOS Launch Screen.storyboard */; };
FA86C03B1D9765BB009CB637 /* iOS Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FA86C0361D9765BA009CB637 /* iOS Launch Screen.storyboard */; };
FA86C03C1D9765BB009CB637 /* iOS Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FA86C0361D9765BA009CB637 /* iOS Launch Screen.storyboard */; };
FA86C03D1D9765BB009CB637 /* iOS Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FA86C0361D9765BA009CB637 /* iOS Launch Screen.storyboard */; };
FA8B4BA31967070A00F8EB7C /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA8B4BA21967070A00F8EB7C /* CoreMotion.framework */; }; FA8B4BA31967070A00F8EB7C /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA8B4BA21967070A00F8EB7C /* CoreMotion.framework */; };
FA8B4BA41967071300F8EB7C /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA8B4BA21967070A00F8EB7C /* CoreMotion.framework */; }; FA8B4BA41967071300F8EB7C /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA8B4BA21967070A00F8EB7C /* CoreMotion.framework */; };
FA8B4BA51967071A00F8EB7C /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA8B4BA21967070A00F8EB7C /* CoreMotion.framework */; }; FA8B4BA51967071A00F8EB7C /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA8B4BA21967070A00F8EB7C /* CoreMotion.framework */; };
@ -220,6 +227,7 @@
1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
FA30DE961BBF59D9009C397F /* Happy-TV.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Happy-TV.app"; sourceTree = BUILT_PRODUCTS_DIR; }; FA30DE961BBF59D9009C397F /* Happy-TV.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Happy-TV.app"; sourceTree = BUILT_PRODUCTS_DIR; };
FA86C0361D9765BA009CB637 /* iOS Launch Screen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = "iOS Launch Screen.storyboard"; sourceTree = "<group>"; };
FA8B4BA21967070A00F8EB7C /* CoreMotion.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMotion.framework; path = System/Library/Frameworks/CoreMotion.framework; sourceTree = SDKROOT; }; FA8B4BA21967070A00F8EB7C /* CoreMotion.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMotion.framework; path = System/Library/Frameworks/CoreMotion.framework; sourceTree = SDKROOT; };
FABA34D31D8B5E5600915323 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; }; FABA34D31D8B5E5600915323 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; };
FABA34D71D8B5E7700915323 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS10.0.sdk/System/Library/Frameworks/AVFoundation.framework; sourceTree = DEVELOPER_DIR; }; FABA34D71D8B5E7700915323 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS10.0.sdk/System/Library/Frameworks/AVFoundation.framework; sourceTree = DEVELOPER_DIR; };
@ -423,6 +431,7 @@
29B97314FDCFA39411CA2CEA /* CustomTemplate */ = { 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
FA86C0361D9765BA009CB637 /* iOS Launch Screen.storyboard */,
FD1B48920E313154007AB34E /* SDL.xcodeproj */, FD1B48920E313154007AB34E /* SDL.xcodeproj */,
FD77A0040E26BC0500F39101 /* src */, FD77A0040E26BC0500F39101 /* src */,
29B97317FDCFA39411CA2CEA /* Resources */, 29B97317FDCFA39411CA2CEA /* Resources */,
@ -676,7 +685,9 @@
TargetAttributes = { TargetAttributes = {
FA30DE951BBF59D9009C397F = { FA30DE951BBF59D9009C397F = {
CreatedOnToolsVersion = 7.1; CreatedOnToolsVersion = 7.1;
DevelopmentTeam = DJN9C5VR5G; };
FDC52EC60E2843D6008D768C = {
ProvisioningStyle = Automatic;
}; };
}; };
}; };
@ -735,6 +746,7 @@
isa = PBXResourcesBuildPhase; isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
FA86C0371D9765BB009CB637 /* iOS Launch Screen.storyboard in Resources */,
FD925B1B0E0F276600E92347 /* Icon.png in Resources */, FD925B1B0E0F276600E92347 /* Icon.png in Resources */,
FD787AA20E22A5CC003E8E36 /* Default.png in Resources */, FD787AA20E22A5CC003E8E36 /* Default.png in Resources */,
); );
@ -755,6 +767,7 @@
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
FDB651D00E43D1AD00F688B5 /* icon.bmp in Resources */, FDB651D00E43D1AD00F688B5 /* icon.bmp in Resources */,
FA86C0381D9765BB009CB637 /* iOS Launch Screen.storyboard in Resources */,
FD925B1A0E0F276600E92347 /* Icon.png in Resources */, FD925B1A0E0F276600E92347 /* Icon.png in Resources */,
FD787AA10E22A5CC003E8E36 /* Default.png in Resources */, FD787AA10E22A5CC003E8E36 /* Default.png in Resources */,
); );
@ -768,6 +781,7 @@
FDB651D10E43D1B300F688B5 /* ship.bmp in Resources */, FDB651D10E43D1B300F688B5 /* ship.bmp in Resources */,
FD925B190E0F276600E92347 /* Icon.png in Resources */, FD925B190E0F276600E92347 /* Icon.png in Resources */,
FD787AA30E22A5CC003E8E36 /* Default.png in Resources */, FD787AA30E22A5CC003E8E36 /* Default.png in Resources */,
FA86C0391D9765BB009CB637 /* iOS Launch Screen.storyboard in Resources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -779,6 +793,7 @@
FDB651FA0E43D1F300F688B5 /* Icon.png in Resources */, FDB651FA0E43D1F300F688B5 /* Icon.png in Resources */,
FDB651FB0E43D1F300F688B5 /* Default.png in Resources */, FDB651FB0E43D1F300F688B5 /* Default.png in Resources */,
FDB652C70E43E25900F688B5 /* kromasky_16x16.bmp in Resources */, FDB652C70E43E25900F688B5 /* kromasky_16x16.bmp in Resources */,
FA86C03D1D9765BB009CB637 /* iOS Launch Screen.storyboard in Resources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -787,6 +802,7 @@
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
FDB651D30E43D1BA00F688B5 /* stroke.bmp in Resources */, FDB651D30E43D1BA00F688B5 /* stroke.bmp in Resources */,
FA86C03A1D9765BB009CB637 /* iOS Launch Screen.storyboard in Resources */,
FDC202E10E107B1200ABAC90 /* Icon.png in Resources */, FDC202E10E107B1200ABAC90 /* Icon.png in Resources */,
FD787AA40E22A5CC003E8E36 /* Default.png in Resources */, FD787AA40E22A5CC003E8E36 /* Default.png in Resources */,
); );
@ -797,6 +813,7 @@
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
FDB651D80E43D1D800F688B5 /* stroke.bmp in Resources */, FDB651D80E43D1D800F688B5 /* stroke.bmp in Resources */,
FA86C03C1D9765BB009CB637 /* iOS Launch Screen.storyboard in Resources */,
FDC52EC80E2843D6008D768C /* Icon.png in Resources */, FDC52EC80E2843D6008D768C /* Icon.png in Resources */,
FDC52EC90E2843D6008D768C /* Default.png in Resources */, FDC52EC90E2843D6008D768C /* Default.png in Resources */,
); );
@ -809,6 +826,7 @@
FDB651D40E43D1C500F688B5 /* ds_brush_snare.wav in Resources */, FDB651D40E43D1C500F688B5 /* ds_brush_snare.wav in Resources */,
FDB651D50E43D1C500F688B5 /* ds_china.wav in Resources */, FDB651D50E43D1C500F688B5 /* ds_china.wav in Resources */,
FDB651D60E43D1C500F688B5 /* ds_kick_big_amb.wav in Resources */, FDB651D60E43D1C500F688B5 /* ds_kick_big_amb.wav in Resources */,
FA86C03B1D9765BB009CB637 /* iOS Launch Screen.storyboard in Resources */,
FDB651D70E43D1C500F688B5 /* ds_loose_skin_mute.wav in Resources */, FDB651D70E43D1C500F688B5 /* ds_loose_skin_mute.wav in Resources */,
FDF0D6960E12D05400247964 /* Icon.png in Resources */, FDF0D6960E12D05400247964 /* Icon.png in Resources */,
FD787AA50E22A5CC003E8E36 /* Default.png in Resources */, FD787AA50E22A5CC003E8E36 /* Default.png in Resources */,
@ -940,6 +958,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
INFOPLIST_FILE = Info.plist; INFOPLIST_FILE = Info.plist;
PRODUCT_BUNDLE_IDENTIFIER = com.yourcompany.Rectangles;
PRODUCT_NAME = Rectangles; PRODUCT_NAME = Rectangles;
}; };
name = Debug; name = Debug;
@ -948,6 +967,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
INFOPLIST_FILE = Info.plist; INFOPLIST_FILE = Info.plist;
PRODUCT_BUNDLE_IDENTIFIER = com.yourcompany.Rectangles;
PRODUCT_NAME = Rectangles; PRODUCT_NAME = Rectangles;
}; };
name = Release; name = Release;
@ -995,6 +1015,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf; DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = "";
ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES; ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99; GCC_C_LANGUAGE_STANDARD = gnu99;
@ -1013,7 +1034,7 @@
INFOPLIST_FILE = Info.plist; INFOPLIST_FILE = Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MTL_ENABLE_DEBUG_INFO = YES; MTL_ENABLE_DEBUG_INFO = YES;
PRODUCT_BUNDLE_IDENTIFIER = "com.Happy-TV"; PRODUCT_BUNDLE_IDENTIFIER = "com.yourcompany.Happy-TV";
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = appletvos; SDKROOT = appletvos;
TARGETED_DEVICE_FAMILY = 3; TARGETED_DEVICE_FAMILY = 3;
@ -1040,6 +1061,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = "";
ENABLE_NS_ASSERTIONS = NO; ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99; GCC_C_LANGUAGE_STANDARD = gnu99;
@ -1053,7 +1075,7 @@
INFOPLIST_FILE = Info.plist; INFOPLIST_FILE = Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MTL_ENABLE_DEBUG_INFO = NO; MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_BUNDLE_IDENTIFIER = "com.Happy-TV"; PRODUCT_BUNDLE_IDENTIFIER = "com.yourcompany.Happy-TV";
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = appletvos; SDKROOT = appletvos;
TARGETED_DEVICE_FAMILY = 3; TARGETED_DEVICE_FAMILY = 3;
@ -1067,6 +1089,7 @@
buildSettings = { buildSettings = {
GCC_DYNAMIC_NO_PIC = NO; GCC_DYNAMIC_NO_PIC = NO;
INFOPLIST_FILE = Info.plist; INFOPLIST_FILE = Info.plist;
PRODUCT_BUNDLE_IDENTIFIER = com.yourcompany.Happy;
PRODUCT_NAME = Happy; PRODUCT_NAME = Happy;
SDKROOT = iphoneos; SDKROOT = iphoneos;
}; };
@ -1076,6 +1099,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
INFOPLIST_FILE = Info.plist; INFOPLIST_FILE = Info.plist;
PRODUCT_BUNDLE_IDENTIFIER = com.yourcompany.Happy;
PRODUCT_NAME = Happy; PRODUCT_NAME = Happy;
SDKROOT = iphoneos; SDKROOT = iphoneos;
}; };
@ -1085,6 +1109,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
INFOPLIST_FILE = Info.plist; INFOPLIST_FILE = Info.plist;
PRODUCT_BUNDLE_IDENTIFIER = com.yourcompany.Accel;
PRODUCT_NAME = Accel; PRODUCT_NAME = Accel;
SDKROOT = iphoneos; SDKROOT = iphoneos;
}; };
@ -1094,6 +1119,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
INFOPLIST_FILE = Info.plist; INFOPLIST_FILE = Info.plist;
PRODUCT_BUNDLE_IDENTIFIER = com.yourcompany.Accel;
PRODUCT_NAME = Accel; PRODUCT_NAME = Accel;
SDKROOT = iphoneos; SDKROOT = iphoneos;
}; };
@ -1103,6 +1129,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
INFOPLIST_FILE = Info.plist; INFOPLIST_FILE = Info.plist;
PRODUCT_BUNDLE_IDENTIFIER = com.yourcompany.Keyboard;
PRODUCT_NAME = Keyboard; PRODUCT_NAME = Keyboard;
SDKROOT = iphoneos; SDKROOT = iphoneos;
}; };
@ -1112,6 +1139,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
INFOPLIST_FILE = Info.plist; INFOPLIST_FILE = Info.plist;
PRODUCT_BUNDLE_IDENTIFIER = com.yourcompany.Keyboard;
PRODUCT_NAME = Keyboard; PRODUCT_NAME = Keyboard;
SDKROOT = iphoneos; SDKROOT = iphoneos;
}; };
@ -1121,6 +1149,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
INFOPLIST_FILE = Info.plist; INFOPLIST_FILE = Info.plist;
PRODUCT_BUNDLE_IDENTIFIER = com.yourcompany.Touch;
PRODUCT_NAME = Touch; PRODUCT_NAME = Touch;
SDKROOT = iphoneos; SDKROOT = iphoneos;
}; };
@ -1130,6 +1159,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
INFOPLIST_FILE = Info.plist; INFOPLIST_FILE = Info.plist;
PRODUCT_BUNDLE_IDENTIFIER = com.yourcompany.Touch;
PRODUCT_NAME = Touch; PRODUCT_NAME = Touch;
SDKROOT = iphoneos; SDKROOT = iphoneos;
}; };
@ -1138,7 +1168,10 @@
FDC52EDC0E2843D6008D768C /* Debug */ = { FDC52EDC0E2843D6008D768C /* Debug */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = Info.plist; INFOPLIST_FILE = Info.plist;
PRODUCT_BUNDLE_IDENTIFIER = com.yourcompany.Fireworks;
PRODUCT_NAME = Fireworks; PRODUCT_NAME = Fireworks;
SDKROOT = iphoneos; SDKROOT = iphoneos;
}; };
@ -1147,7 +1180,10 @@
FDC52EDD0E2843D6008D768C /* Release */ = { FDC52EDD0E2843D6008D768C /* Release */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = Info.plist; INFOPLIST_FILE = Info.plist;
PRODUCT_BUNDLE_IDENTIFIER = com.yourcompany.Fireworks;
PRODUCT_NAME = Fireworks; PRODUCT_NAME = Fireworks;
SDKROOT = iphoneos; SDKROOT = iphoneos;
}; };
@ -1157,6 +1193,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
INFOPLIST_FILE = Info.plist; INFOPLIST_FILE = Info.plist;
PRODUCT_BUNDLE_IDENTIFIER = com.yourcompany.Mixer;
PRODUCT_NAME = Mixer; PRODUCT_NAME = Mixer;
SDKROOT = iphoneos; SDKROOT = iphoneos;
}; };
@ -1166,6 +1203,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
INFOPLIST_FILE = Info.plist; INFOPLIST_FILE = Info.plist;
PRODUCT_BUNDLE_IDENTIFIER = com.yourcompany.Mixer;
PRODUCT_NAME = Mixer; PRODUCT_NAME = Mixer;
SDKROOT = iphoneos; SDKROOT = iphoneos;
}; };

View File

@ -11,7 +11,7 @@
<key>CFBundleIconFile</key> <key>CFBundleIconFile</key>
<string></string> <string></string>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
<string>com.yourcompany.${PRODUCT_NAME:identifier}</string> <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key> <key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string> <string>6.0</string>
<key>CFBundleName</key> <key>CFBundleName</key>
@ -24,6 +24,8 @@
<string>1.0</string> <string>1.0</string>
<key>NSMainNibFile</key> <key>NSMainNibFile</key>
<string></string> <string></string>
<key>UILaunchStoryboardName</key>
<string>iOS Launch Screen</string>
<key>UISupportedInterfaceOrientations</key> <key>UISupportedInterfaceOrientations</key>
<array/> <array/>
</dict> </dict>

View File

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11201" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
<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">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
</layoutGuides>
<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"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="Default.png" translatesAutoresizingMaskIntoConstraints="NO" id="VeL-6u-rS3"/>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="VeL-6u-rS3" firstAttribute="top" secondItem="Ze5-6b-2t3" secondAttribute="top" id="C5X-Vg-tvO"/>
<constraint firstAttribute="trailing" secondItem="VeL-6u-rS3" secondAttribute="trailing" id="X4i-1U-3JE"/>
<constraint firstItem="VeL-6u-rS3" firstAttribute="bottom" secondItem="xb3-aO-Qok" secondAttribute="top" id="dSu-2l-DcF"/>
<constraint firstItem="VeL-6u-rS3" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leading" id="xKC-uj-bxE"/>
</constraints>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="52" y="374.66266866566718"/>
</scene>
</scenes>
<resources>
<image name="Default.png" width="320" height="480"/>
</resources>
</document>

View File

@ -8,7 +8,6 @@
#include "math.h" #include "math.h"
#include "common.h" #include "common.h"
#define MILLESECONDS_PER_FRAME 16 /* about 60 frames per second */
#define DAMPING 0.5f; /* after bouncing off a wall, damping coefficient determines final speed */ #define DAMPING 0.5f; /* after bouncing off a wall, damping coefficient determines final speed */
#define FRICTION 0.0008f /* coefficient of acceleration that opposes direction of motion */ #define FRICTION 0.0008f /* coefficient of acceleration that opposes direction of motion */
#define GRAVITY_CONSTANT 0.004f /* how sensitive the ship is to the accelerometer */ #define GRAVITY_CONSTANT 0.004f /* how sensitive the ship is to the accelerometer */
@ -31,9 +30,9 @@ static SDL_Texture *ship = 0; /* texture for spaceship */
static SDL_Texture *space = 0; /* texture for space (background */ static SDL_Texture *space = 0; /* texture for space (background */
void void
render(SDL_Renderer *renderer, int w, int h) render(SDL_Renderer *renderer, int w, int h, double deltaTime)
{ {
double deltaMilliseconds = deltaTime * 1000;
float speed; float speed;
/* get joystick (accelerometer) axis values and normalize them */ /* get joystick (accelerometer) axis values and normalize them */
@ -54,10 +53,10 @@ render(SDL_Renderer *renderer, int w, int h)
*/ */
shipData.vx += shipData.vx +=
ax * SDL_IPHONE_MAX_GFORCE / SINT16_MAX * GRAVITY_CONSTANT * ax * SDL_IPHONE_MAX_GFORCE / SINT16_MAX * GRAVITY_CONSTANT *
MILLESECONDS_PER_FRAME; deltaMilliseconds;
shipData.vy += shipData.vy +=
ay * SDL_IPHONE_MAX_GFORCE / SINT16_MAX * GRAVITY_CONSTANT * ay * SDL_IPHONE_MAX_GFORCE / SINT16_MAX * GRAVITY_CONSTANT *
MILLESECONDS_PER_FRAME; deltaMilliseconds;
speed = sqrt(shipData.vx * shipData.vx + shipData.vy * shipData.vy); speed = sqrt(shipData.vx * shipData.vx + shipData.vy * shipData.vy);
@ -67,10 +66,10 @@ render(SDL_Renderer *renderer, int w, int h)
float diry = shipData.vy / speed; /* normalized y velocity */ float diry = shipData.vy / speed; /* normalized y velocity */
/* update velocity due to friction */ /* update velocity due to friction */
if (speed - FRICTION * MILLESECONDS_PER_FRAME > 0) { if (speed - FRICTION * deltaMilliseconds > 0) {
/* apply friction */ /* apply friction */
shipData.vx -= dirx * FRICTION * MILLESECONDS_PER_FRAME; shipData.vx -= dirx * FRICTION * deltaMilliseconds;
shipData.vy -= diry * FRICTION * MILLESECONDS_PER_FRAME; shipData.vy -= diry * FRICTION * deltaMilliseconds;
} else { } else {
/* applying friction would MORE than stop the ship, so just stop the ship */ /* applying friction would MORE than stop the ship, so just stop the ship */
shipData.vx = 0.0f; shipData.vx = 0.0f;
@ -79,8 +78,8 @@ render(SDL_Renderer *renderer, int w, int h)
} }
/* update ship location */ /* update ship location */
shipData.x += shipData.vx * MILLESECONDS_PER_FRAME; shipData.x += shipData.vx * deltaMilliseconds;
shipData.y += shipData.vy * MILLESECONDS_PER_FRAME; shipData.y += shipData.vy * deltaMilliseconds;
if (shipData.x > maxx) { if (shipData.x > maxx) {
shipData.x = maxx; shipData.x = maxx;
@ -161,9 +160,6 @@ main(int argc, char *argv[])
SDL_Window *window; /* main window */ SDL_Window *window; /* main window */
SDL_Renderer *renderer; SDL_Renderer *renderer;
Uint32 startFrame; /* time frame began to process */
Uint32 endFrame; /* time frame ended processing */
Sint32 delay; /* time to pause waiting to draw next frame */
int done; /* should we clean up and exit? */ int done; /* should we clean up and exit? */
int w, h; int w, h;
@ -173,12 +169,11 @@ main(int argc, char *argv[])
} }
/* create main window and renderer */ /* create main window and renderer */
window = SDL_CreateWindow(NULL, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, window = SDL_CreateWindow(NULL, 0, 0, 320, 480, SDL_WINDOW_FULLSCREEN | SDL_WINDOW_ALLOW_HIGHDPI);
SDL_WINDOW_OPENGL |
SDL_WINDOW_FULLSCREEN);
renderer = SDL_CreateRenderer(window, 0, 0); renderer = SDL_CreateRenderer(window, 0, 0);
SDL_GetWindowSize(window, &w, &h); SDL_GetWindowSize(window, &w, &h);
SDL_RenderSetLogicalSize(renderer, w, h);
/* print out some info about joysticks and try to open accelerometer for use */ /* print out some info about joysticks and try to open accelerometer for use */
printf("There are %d joysticks available\n", SDL_NumJoysticks()); printf("There are %d joysticks available\n", SDL_NumJoysticks());
@ -208,24 +203,15 @@ main(int argc, char *argv[])
done = 0; done = 0;
/* enter main loop */ /* enter main loop */
while (!done) { while (!done) {
double deltaTime = updateDeltaTime();
SDL_Event event; SDL_Event event;
startFrame = SDL_GetTicks();
while (SDL_PollEvent(&event)) { while (SDL_PollEvent(&event)) {
if (event.type == SDL_QUIT) { if (event.type == SDL_QUIT) {
done = 1; done = 1;
} }
} }
render(renderer, w, h); render(renderer, w, h, deltaTime);
endFrame = SDL_GetTicks(); SDL_Delay(1);
/* figure out how much time we have left, and then sleep */
delay = MILLESECONDS_PER_FRAME - (endFrame - startFrame);
if (delay < 0) {
delay = 0;
} else if (delay > MILLESECONDS_PER_FRAME) {
delay = MILLESECONDS_PER_FRAME;
}
SDL_Delay(delay);
} }
/* delete textures */ /* delete textures */

View File

@ -32,5 +32,25 @@ void
fatalError(const char *string) fatalError(const char *string)
{ {
printf("%s: %s\n", string, SDL_GetError()); printf("%s: %s\n", string, SDL_GetError());
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, string, SDL_GetError(), NULL);
exit(1); exit(1);
} }
static Uint64 prevTime = 0;
double
updateDeltaTime()
{
Uint64 curTime;
double deltaTime;
if (prevTime == 0) {
prevTime = SDL_GetPerformanceCounter();
}
curTime = SDL_GetPerformanceCounter();
deltaTime = (double) (curTime - prevTime) / (double) SDL_GetPerformanceFrequency();
prevTime = curTime;
return deltaTime;
}

View File

@ -4,14 +4,7 @@
* use however you want * use however you want
*/ */
#if __TVOS__
#define SCREEN_WIDTH 1920
#define SCREEN_HEIGHT 1080
#else
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 480
#endif
extern int randomInt(int min, int max); extern int randomInt(int min, int max);
extern float randomFloat(float min, float max); extern float randomFloat(float min, float max);
extern void fatalError(const char *string); extern void fatalError(const char *string);
extern double updateDeltaTime();

View File

@ -10,13 +10,13 @@
#include <math.h> #include <math.h>
#include <time.h> #include <time.h>
#define MILLESECONDS_PER_FRAME 16 /* about 60 frames per second */
#define ACCEL 0.0001f /* acceleration due to gravity, units in pixels per millesecond squared */ #define ACCEL 0.0001f /* acceleration due to gravity, units in pixels per millesecond squared */
#define WIND_RESISTANCE 0.00005f /* acceleration per unit velocity due to wind resistance */ #define WIND_RESISTANCE 0.00005f /* acceleration per unit velocity due to wind resistance */
#define MAX_PARTICLES 2000 /* maximum number of particles displayed at once */ #define MAX_PARTICLES 2000 /* maximum number of particles displayed at once */
static GLuint particleTextureID; /* OpenGL particle texture id */ static GLuint particleTextureID; /* OpenGL particle texture id */
static SDL_bool pointSizeExtensionSupported; /* is GL_OES_point_size_array supported ? */ static SDL_bool pointSizeExtensionSupported; /* is GL_OES_point_size_array supported ? */
static float pointSizeScale;
/* /*
used to describe what type of particle a given struct particle is. used to describe what type of particle a given struct particle is.
emitter - this particle flies up, shooting off trail particles, then finally explodes into dust particles. emitter - this particle flies up, shooting off trail particles, then finally explodes into dust particles.
@ -55,7 +55,7 @@ void initializeParticles(void);
void initializeTexture(); void initializeTexture();
int nextPowerOfTwo(int x); int nextPowerOfTwo(int x);
void drawParticles(); void drawParticles();
void stepParticles(void); void stepParticles(double deltaTime);
/* helper function (used in texture loading) /* helper function (used in texture loading)
returns next power of two greater than or equal to x returns next power of two greater than or equal to x
@ -74,8 +74,9 @@ nextPowerOfTwo(int x)
steps each active particle by timestep MILLESECONDS_PER_FRAME steps each active particle by timestep MILLESECONDS_PER_FRAME
*/ */
void void
stepParticles(void) stepParticles(double deltaTime)
{ {
float deltaMilliseconds = deltaTime * 1000;
int i; int i;
struct particle *slot = particles; struct particle *slot = particles;
struct particle *curr = particles; struct particle *curr = particles;
@ -93,10 +94,10 @@ stepParticles(void)
curr->isActive = 0; curr->isActive = 0;
/* step velocity, then step position */ /* step velocity, then step position */
curr->yvel += ACCEL * MILLESECONDS_PER_FRAME; curr->yvel += ACCEL * deltaMilliseconds;
curr->xvel += 0.0f; curr->xvel += 0.0f;
curr->y += curr->yvel * MILLESECONDS_PER_FRAME; curr->y += curr->yvel * deltaMilliseconds;
curr->x += curr->xvel * MILLESECONDS_PER_FRAME; curr->x += curr->xvel * deltaMilliseconds;
/* particle behavior */ /* particle behavior */
if (curr->type == emitter) { if (curr->type == emitter) {
@ -111,29 +112,29 @@ stepParticles(void)
sqrt(curr->xvel * curr->xvel + curr->yvel * curr->yvel); sqrt(curr->xvel * curr->xvel + curr->yvel * curr->yvel);
/* if wind resistance is not powerful enough to stop us completely, /* if wind resistance is not powerful enough to stop us completely,
then apply winde resistance, otherwise just stop us completely */ then apply winde resistance, otherwise just stop us completely */
if (WIND_RESISTANCE * MILLESECONDS_PER_FRAME < speed) { if (WIND_RESISTANCE * deltaMilliseconds < speed) {
float normx = curr->xvel / speed; float normx = curr->xvel / speed;
float normy = curr->yvel / speed; float normy = curr->yvel / speed;
curr->xvel -= curr->xvel -=
normx * WIND_RESISTANCE * MILLESECONDS_PER_FRAME; normx * WIND_RESISTANCE * deltaMilliseconds;
curr->yvel -= curr->yvel -=
normy * WIND_RESISTANCE * MILLESECONDS_PER_FRAME; normy * WIND_RESISTANCE * deltaMilliseconds;
} else { } else {
curr->xvel = curr->yvel = 0; /* stop particle */ curr->xvel = curr->yvel = 0; /* stop particle */
} }
if (curr->color[3] <= MILLESECONDS_PER_FRAME * 0.1275f) { if (curr->color[3] <= deltaMilliseconds * 0.1275f) {
/* if this next step will cause us to fade out completely /* if this next step will cause us to fade out completely
then just mark for deletion */ then just mark for deletion */
curr->isActive = 0; curr->isActive = 0;
} else { } else {
/* otherwise, let's fade a bit more */ /* otherwise, let's fade a bit more */
curr->color[3] -= MILLESECONDS_PER_FRAME * 0.1275f; curr->color[3] -= deltaMilliseconds * 0.1275f;
} }
/* if we're a dust particle, shrink our size */ /* if we're a dust particle, shrink our size */
if (curr->type == dust) if (curr->type == dust)
curr->size -= MILLESECONDS_PER_FRAME * 0.010f; curr->size -= deltaMilliseconds * 0.010f;
} }
@ -147,7 +148,7 @@ stepParticles(void)
/* the number of active particles is computed as the difference between /* the number of active particles is computed as the difference between
old number of active particles, where slot points, and the old number of active particles, where slot points, and the
new size of the array, where particles points */ new size of the array, where particles points */
num_active_particles = slot - particles; num_active_particles = (int) (slot - particles);
} }
/* /*
@ -206,7 +207,7 @@ explodeEmitter(struct particle *emitter)
p->y = emitter->y + emitter->yvel; p->y = emitter->y + emitter->yvel;
p->isActive = 1; p->isActive = 1;
p->type = dust; p->type = dust;
p->size = 15; p->size = 15 * pointSizeScale;
/* inherit emitter's color */ /* inherit emitter's color */
p->color[0] = emitter->color[0]; p->color[0] = emitter->color[0];
p->color[1] = emitter->color[1]; p->color[1] = emitter->color[1];
@ -244,7 +245,7 @@ spawnTrailFromEmitter(struct particle *emitter)
p->color[3] = (0.7f) * 255; p->color[3] = (0.7f) * 255;
/* set other attributes */ /* set other attributes */
p->size = 10; p->size = 10 * pointSizeScale;
p->type = trail; p->type = trail;
p->isActive = 1; p->isActive = 1;
@ -298,7 +299,7 @@ spawnEmitterParticle(GLfloat x, GLfloat y)
p->xvel = 0; p->xvel = 0;
p->yvel = -sqrt(2 * ACCEL * (screen_h - y)); p->yvel = -sqrt(2 * ACCEL * (screen_h - y));
/* set other attributes */ /* set other attributes */
p->size = 10; p->size = 10 * pointSizeScale;
p->type = emitter; p->type = emitter;
p->isActive = 1; p->isActive = 1;
/* our array has expanded at the end */ /* our array has expanded at the end */
@ -363,7 +364,7 @@ main(int argc, char *argv[])
{ {
SDL_Window *window; /* main window */ SDL_Window *window; /* main window */
SDL_GLContext context; SDL_GLContext context;
int w, h; int drawableW, drawableH;
Uint32 startFrame; /* time frame began to process */ Uint32 startFrame; /* time frame began to process */
Uint32 endFrame; /* time frame ended processing */ Uint32 endFrame; /* time frame ended processing */
Uint32 delay; /* time to pause waiting to draw next frame */ Uint32 delay; /* time to pause waiting to draw next frame */
@ -391,11 +392,19 @@ main(int argc, char *argv[])
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
/* create main window and renderer */ /* create main window and renderer */
window = SDL_CreateWindow(NULL, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, window = SDL_CreateWindow(NULL, 0, 0, 320, 480,
SDL_WINDOW_OPENGL | SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS | SDL_WINDOW_ALLOW_HIGHDPI);
SDL_WINDOW_BORDERLESS);
context = SDL_GL_CreateContext(window); context = SDL_GL_CreateContext(window);
/* The window size and drawable size may be different when highdpi is enabled,
* due to the increased pixel density of the drawable. */
SDL_GetWindowSize(window, &screen_w, &screen_h);
SDL_GL_GetDrawableSize(window, &drawableW, &drawableH);
/* In OpenGL, point sizes are always in pixels. We don't want them looking
* tiny on a retina screen. */
pointSizeScale = (float) drawableH / (float) screen_h;
/* load the particle texture */ /* load the particle texture */
initializeTexture(); initializeTexture();
@ -412,8 +421,7 @@ main(int argc, char *argv[])
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); glLoadIdentity();
SDL_GetWindowSize(window, &screen_w, &screen_h); glViewport(0, 0, drawableW, drawableH);
glViewport(0, 0, screen_w, screen_h);
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); glLoadIdentity();
@ -436,14 +444,14 @@ main(int argc, char *argv[])
glEnableClientState(GL_POINT_SIZE_ARRAY_OES); glEnableClientState(GL_POINT_SIZE_ARRAY_OES);
} else { } else {
/* if extension not available then all particles have size 10 */ /* if extension not available then all particles have size 10 */
glPointSize(10); glPointSize(10 * pointSizeScale);
} }
done = 0; done = 0;
/* enter main loop */ /* enter main loop */
while (!done) { while (!done) {
startFrame = SDL_GetTicks();
SDL_Event event; SDL_Event event;
double deltaTime = updateDeltaTime();
while (SDL_PollEvent(&event)) { while (SDL_PollEvent(&event)) {
if (event.type == SDL_QUIT) { if (event.type == SDL_QUIT) {
done = 1; done = 1;
@ -454,19 +462,10 @@ main(int argc, char *argv[])
spawnEmitterParticle(x, y); spawnEmitterParticle(x, y);
} }
} }
stepParticles(); stepParticles(deltaTime);
drawParticles(); drawParticles();
SDL_GL_SwapWindow(window); SDL_GL_SwapWindow(window);
endFrame = SDL_GetTicks(); SDL_Delay(1);
/* figure out how much time we have left, and then sleep */
delay = MILLESECONDS_PER_FRAME - (endFrame - startFrame);
if (delay > MILLESECONDS_PER_FRAME) {
delay = MILLESECONDS_PER_FRAME;
}
if (delay > 0) {
SDL_Delay(delay);
}
} }
/* delete textures */ /* delete textures */

View File

@ -8,8 +8,7 @@
#include "common.h" #include "common.h"
#define NUM_HAPPY_FACES 100 /* number of faces to draw */ #define NUM_HAPPY_FACES 100 /* number of faces to draw */
#define MILLESECONDS_PER_FRAME 16 /* about 60 frames per second */ #define HAPPY_FACE_SIZE 32 /* width and height of happyface */
#define HAPPY_FACE_SIZE 32 /* width and height of happyface (pixels) */
static SDL_Texture *texture = 0; /* reference to texture holding happyface */ static SDL_Texture *texture = 0; /* reference to texture holding happyface */
@ -24,30 +23,37 @@ static struct
units of velocity are pixels per millesecond units of velocity are pixels per millesecond
*/ */
void void
initializeHappyFaces() initializeHappyFaces(SDL_Renderer *renderer)
{ {
int i; int i;
int w;
int h;
SDL_RenderGetLogicalSize(renderer, &w, &h);
for (i = 0; i < NUM_HAPPY_FACES; i++) { for (i = 0; i < NUM_HAPPY_FACES; i++) {
faces[i].x = randomFloat(0.0f, SCREEN_WIDTH - HAPPY_FACE_SIZE); faces[i].x = randomFloat(0.0f, w - HAPPY_FACE_SIZE);
faces[i].y = randomFloat(0.0f, SCREEN_HEIGHT - HAPPY_FACE_SIZE); faces[i].y = randomFloat(0.0f, h - HAPPY_FACE_SIZE);
faces[i].xvel = randomFloat(-0.1f, 0.1f); faces[i].xvel = randomFloat(-60.0f, 60.0f);
faces[i].yvel = randomFloat(-0.1f, 0.1f); faces[i].yvel = randomFloat(-60.0f, 60.0f);
} }
} }
void void
render(SDL_Renderer *renderer) render(SDL_Renderer *renderer, double deltaTime)
{ {
int i; int i;
SDL_Rect srcRect; SDL_Rect srcRect;
SDL_Rect dstRect; SDL_Rect dstRect;
int w;
int h;
SDL_RenderGetLogicalSize(renderer, &w, &h);
/* setup boundaries for happyface bouncing */ /* setup boundaries for happyface bouncing */
Uint16 maxx = SCREEN_WIDTH - HAPPY_FACE_SIZE; int maxx = w - HAPPY_FACE_SIZE;
Uint16 maxy = SCREEN_HEIGHT - HAPPY_FACE_SIZE; int maxy = h - HAPPY_FACE_SIZE;
Uint16 minx = 0; int minx = 0;
Uint16 miny = 0; int miny = 0;
/* setup rects for drawing */ /* setup rects for drawing */
srcRect.x = 0; srcRect.x = 0;
@ -68,8 +74,8 @@ render(SDL_Renderer *renderer)
- draw - draw
*/ */
for (i = 0; i < NUM_HAPPY_FACES; i++) { for (i = 0; i < NUM_HAPPY_FACES; i++) {
faces[i].x += faces[i].xvel * MILLESECONDS_PER_FRAME; faces[i].x += faces[i].xvel * deltaTime;
faces[i].y += faces[i].yvel * MILLESECONDS_PER_FRAME; faces[i].y += faces[i].yvel * deltaTime;
if (faces[i].x > maxx) { if (faces[i].x > maxx) {
faces[i].x = maxx; faces[i].x = maxx;
faces[i].xvel = -faces[i].xvel; faces[i].xvel = -faces[i].xvel;
@ -123,48 +129,45 @@ initializeTexture(SDL_Renderer *renderer)
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
SDL_Window *window; SDL_Window *window;
SDL_Renderer *renderer; SDL_Renderer *renderer;
Uint32 startFrame;
Uint32 endFrame;
Uint32 delay;
int done; int done;
int width;
int height;
/* initialize SDL */ /* initialize SDL */
if (SDL_Init(SDL_INIT_VIDEO) < 0) { if (SDL_Init(SDL_INIT_VIDEO) < 0) {
fatalError("Could not initialize SDL"); fatalError("Could not initialize SDL");
} }
window = SDL_CreateWindow(NULL, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT,
SDL_WINDOW_OPENGL | /* The specified window size doesn't matter - except for its aspect ratio,
SDL_WINDOW_BORDERLESS); * which determines whether the window is in portrait or landscape on iOS
* (if SDL_WINDOW_RESIZABLE isn't specified). */
window = SDL_CreateWindow(NULL, 0, 0, 320, 480, SDL_WINDOW_FULLSCREEN | SDL_WINDOW_ALLOW_HIGHDPI);
renderer = SDL_CreateRenderer(window, -1, 0); renderer = SDL_CreateRenderer(window, -1, 0);
SDL_GetWindowSize(window, &width, &height);
SDL_RenderSetLogicalSize(renderer, width, height);
initializeTexture(renderer); initializeTexture(renderer);
initializeHappyFaces(); initializeHappyFaces(renderer);
/* main loop */ /* main loop */
done = 0; done = 0;
while (!done) { while (!done) {
SDL_Event event; SDL_Event event;
startFrame = SDL_GetTicks(); double deltaTime = updateDeltaTime();
while (SDL_PollEvent(&event)) { while (SDL_PollEvent(&event)) {
if (event.type == SDL_QUIT) { if (event.type == SDL_QUIT) {
done = 1; done = 1;
} }
} }
render(renderer);
endFrame = SDL_GetTicks();
/* figure out how much time we have left, and then sleep */ render(renderer, deltaTime);
delay = MILLESECONDS_PER_FRAME - (endFrame - startFrame); SDL_Delay(1);
if (delay < 0) {
delay = 0;
} else if (delay > MILLESECONDS_PER_FRAME) {
delay = MILLESECONDS_PER_FRAME;
}
SDL_Delay(delay);
} }
/* cleanup */ /* cleanup */

View File

@ -132,10 +132,13 @@ keyToIndex(SDL_Keysym key)
void void
getPositionForCharNumber(int n, int *x, int *y) getPositionForCharNumber(int n, int *x, int *y)
{ {
int renderW, renderH;
SDL_RenderGetLogicalSize(renderer, &renderW, &renderH);
int x_padding = 16; /* padding space on left and right side of screen */ int x_padding = 16; /* padding space on left and right side of screen */
int y_padding = 32; /* padding space at top of screen */ int y_padding = 32; /* padding space at top of screen */
/* figure out the number of characters that can fit horizontally across the screen */ /* figure out the number of characters that can fit horizontally across the screen */
int max_x_chars = (SCREEN_WIDTH - 2 * x_padding) / GLYPH_SIZE_SCREEN; int max_x_chars = (renderW - 2 * x_padding) / GLYPH_SIZE_SCREEN;
int line_separation = 5; /* pixels between each line */ int line_separation = 5; /* pixels between each line */
*x = (n % max_x_chars) * GLYPH_SIZE_SCREEN + x_padding; *x = (n % max_x_chars) * GLYPH_SIZE_SCREEN + x_padding;
*y = (n / max_x_chars) * (GLYPH_SIZE_SCREEN + line_separation) + *y = (n / max_x_chars) * (GLYPH_SIZE_SCREEN + line_separation) +
@ -228,21 +231,25 @@ loadFont(void)
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
int index; /* index of last key we pushed in the bitmap font */ int index; /* index of last key we pushed in the bitmap font */
SDL_Window *window; SDL_Window *window;
SDL_Event event; /* last event received */ SDL_Event event; /* last event received */
SDL_Keymod mod; /* key modifiers of last key we pushed */ SDL_Keymod mod; /* key modifiers of last key we pushed */
SDL_Scancode scancode; /* scancode of last key we pushed */ SDL_Scancode scancode; /* scancode of last key we pushed */
int width;
int height;
if (SDL_Init(SDL_INIT_VIDEO) < 0) { if (SDL_Init(SDL_INIT_VIDEO) < 0) {
printf("Error initializing SDL: %s", SDL_GetError()); printf("Error initializing SDL: %s", SDL_GetError());
} }
/* create window */ /* create window */
window = SDL_CreateWindow("iPhone keyboard test", 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0); window = SDL_CreateWindow("iPhone keyboard test", 0, 0, 320, 480, SDL_WINDOW_ALLOW_HIGHDPI);
/* create renderer */ /* create renderer */
renderer = SDL_CreateRenderer(window, -1, 0); renderer = SDL_CreateRenderer(window, -1, 0);
SDL_GetWindowSize(window, &width, &height);
SDL_RenderSetLogicalSize(renderer, width, height);
/* load up our font */ /* load up our font */
loadFont(); loadFont();

View File

@ -33,7 +33,7 @@ static struct sound drums[NUM_DRUMS];
void handleMouseButtonDown(SDL_Event * event); void handleMouseButtonDown(SDL_Event * event);
void handleMouseButtonUp(SDL_Event * event); void handleMouseButtonUp(SDL_Event * event);
int playSound(struct sound *); int playSound(struct sound *);
void initializeButtons(); void initializeButtons(SDL_Renderer *);
void audioCallback(void *userdata, Uint8 * stream, int len); void audioCallback(void *userdata, Uint8 * stream, int len);
void loadSound(const char *file, struct sound *s); void loadSound(const char *file, struct sound *s);
@ -52,19 +52,21 @@ struct
/* sets up the buttons (color, position, state) */ /* sets up the buttons (color, position, state) */
void void
initializeButtons() initializeButtons(SDL_Renderer *renderer)
{ {
int i; int i;
int spacing = 10; /* gap between drum buttons */ int spacing = 10; /* gap between drum buttons */
SDL_Rect buttonRect; /* keeps track of where to position drum */ SDL_Rect buttonRect; /* keeps track of where to position drum */
SDL_Color upColor = { 86, 86, 140, 255 }; /* color of drum when not pressed */ SDL_Color upColor = { 86, 86, 140, 255 }; /* color of drum when not pressed */
SDL_Color downColor = { 191, 191, 221, 255 }; /* color of drum when pressed */ SDL_Color downColor = { 191, 191, 221, 255 }; /* color of drum when pressed */
int renderW, renderH;
SDL_RenderGetLogicalSize(renderer, &renderW, &renderH);
buttonRect.x = spacing; buttonRect.x = spacing;
buttonRect.y = spacing; buttonRect.y = spacing;
buttonRect.w = SCREEN_WIDTH - 2 * spacing; buttonRect.w = renderW - 2 * spacing;
buttonRect.h = (SCREEN_HEIGHT - (NUM_DRUMS + 1) * spacing) / NUM_DRUMS; buttonRect.h = (renderH - (NUM_DRUMS + 1) * spacing) / NUM_DRUMS;
/* setup each button */ /* setup each button */
for (i = 0; i < NUM_DRUMS; i++) { for (i = 0; i < NUM_DRUMS; i++) {
@ -270,24 +272,23 @@ audioCallback(void *userdata, Uint8 * stream, int len)
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
int done; /* has user tried to quit ? */ int done; /* has user tried to quit ? */
SDL_Window *window; /* main window */ SDL_Window *window; /* main window */
SDL_Renderer *renderer; SDL_Renderer *renderer;
SDL_Event event; SDL_Event event;
Uint32 startFrame; /* holds when frame started processing */
Uint32 endFrame; /* holds when frame ended processing */
Uint32 delay; /* calculated delay, how long should we wait before next frame? */
int i; int i;
int width;
int height;
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) { if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) {
fatalError("could not initialize SDL"); fatalError("could not initialize SDL");
} }
window = window = SDL_CreateWindow(NULL, 0, 0, 320, 480, SDL_WINDOW_BORDERLESS | SDL_WINDOW_ALLOW_HIGHDPI);
SDL_CreateWindow(NULL, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT,
SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS);
renderer = SDL_CreateRenderer(window, 0, 0); renderer = SDL_CreateRenderer(window, 0, 0);
SDL_GetWindowSize(window, &width, &height);
SDL_RenderSetLogicalSize(renderer, width, height);
/* initialize the mixer */ /* initialize the mixer */
SDL_memset(&mixer, 0, sizeof(mixer)); SDL_memset(&mixer, 0, sizeof(mixer));
/* setup output format */ /* setup output format */
@ -310,12 +311,11 @@ main(int argc, char *argv[])
loadSound("ds_china.wav", &drums[0]); loadSound("ds_china.wav", &drums[0]);
/* setup positions, colors, and state of buttons */ /* setup positions, colors, and state of buttons */
initializeButtons(); initializeButtons(renderer);
/* enter main loop */ /* enter main loop */
done = 0; done = 0;
while (!done) { while (!done) {
startFrame = SDL_GetTicks();
while (SDL_PollEvent(&event)) { while (SDL_PollEvent(&event)) {
switch (event.type) { switch (event.type) {
case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONDOWN:
@ -330,16 +330,8 @@ main(int argc, char *argv[])
} }
} }
render(renderer); /* draw buttons */ render(renderer); /* draw buttons */
endFrame = SDL_GetTicks();
/* figure out how much time we have left, and then sleep */ SDL_Delay(1);
delay = MILLESECONDS_PER_FRAME - (endFrame - startFrame);
if (delay < 0) {
delay = 0;
} else if (delay > MILLESECONDS_PER_FRAME) {
delay = MILLESECONDS_PER_FRAME;
}
SDL_Delay(delay);
} }
/* cleanup code, let's free up those sound buffers */ /* cleanup code, let's free up those sound buffers */

View File

@ -11,14 +11,18 @@
void void
render(SDL_Renderer *renderer) render(SDL_Renderer *renderer)
{ {
Uint8 r, g, b; Uint8 r, g, b;
int renderW;
int renderH;
SDL_RenderGetLogicalSize(renderer, &renderW, &renderH);
/* Come up with a random rectangle */ /* Come up with a random rectangle */
SDL_Rect rect; SDL_Rect rect;
rect.w = randomInt(64, 128); rect.w = randomInt(64, 128);
rect.h = randomInt(64, 128); rect.h = randomInt(64, 128);
rect.x = randomInt(0, SCREEN_WIDTH); rect.x = randomInt(0, renderW);
rect.y = randomInt(0, SCREEN_HEIGHT); rect.y = randomInt(0, renderH);
/* Come up with a random color */ /* Come up with a random color */
r = randomInt(50, 255); r = randomInt(50, 255);
@ -31,7 +35,6 @@ render(SDL_Renderer *renderer)
/* update screen */ /* update screen */
SDL_RenderPresent(renderer); SDL_RenderPresent(renderer);
} }
int int
@ -42,6 +45,8 @@ main(int argc, char *argv[])
SDL_Renderer *renderer; SDL_Renderer *renderer;
int done; int done;
SDL_Event event; SDL_Event event;
int windowW;
int windowH;
/* initialize SDL */ /* initialize SDL */
if (SDL_Init(SDL_INIT_VIDEO) < 0) { if (SDL_Init(SDL_INIT_VIDEO) < 0) {
@ -52,7 +57,7 @@ main(int argc, char *argv[])
srand(time(NULL)); srand(time(NULL));
/* create window and renderer */ /* create window and renderer */
window = SDL_CreateWindow(NULL, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0); window = SDL_CreateWindow(NULL, 0, 0, 320, 480, SDL_WINDOW_ALLOW_HIGHDPI);
if (window == 0) { if (window == 0) {
fatalError("Could not initialize Window"); fatalError("Could not initialize Window");
} }
@ -61,6 +66,9 @@ main(int argc, char *argv[])
fatalError("Could not create renderer"); fatalError("Could not create renderer");
} }
SDL_GetWindowSize(window, &windowW, &windowH);
SDL_RenderSetLogicalSize(renderer, windowW, windowH);
/* Fill screen with black */ /* Fill screen with black */
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
SDL_RenderClear(renderer); SDL_RenderClear(renderer);

View File

@ -82,6 +82,7 @@ main(int argc, char *argv[])
SDL_Window *window; /* main window */ SDL_Window *window; /* main window */
SDL_Renderer *renderer; SDL_Renderer *renderer;
int done; /* does user want to quit? */ int done; /* does user want to quit? */
int w, h;
/* initialize SDL */ /* initialize SDL */
if (SDL_Init(SDL_INIT_VIDEO) < 0) { if (SDL_Init(SDL_INIT_VIDEO) < 0) {
@ -89,11 +90,12 @@ main(int argc, char *argv[])
} }
/* create main window and renderer */ /* create main window and renderer */
window = SDL_CreateWindow(NULL, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, window = SDL_CreateWindow(NULL, 0, 0, 320, 480, SDL_WINDOW_BORDERLESS | SDL_WINDOW_ALLOW_HIGHDPI);
SDL_WINDOW_OPENGL |
SDL_WINDOW_BORDERLESS);
renderer = SDL_CreateRenderer(window, 0, 0); renderer = SDL_CreateRenderer(window, 0, 0);
SDL_GetWindowSize(window, &w, &h);
SDL_RenderSetLogicalSize(renderer, w, h);
/* load brush texture */ /* load brush texture */
initializeTexture(renderer); initializeTexture(renderer);