Update the code for the iOS demos to handle modern devices. Fixes bug #3337
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072
diff --git a/Xcode-iOS/Demos/Demos.xcodeproj/project.pbxproj b/Xcode-iOS/Demos/Demos.xcodeproj/project.pbxproj
index 44434d6..d4ace90 100755
--- a/Xcode-iOS/Demos/Demos.xcodeproj/project.pbxproj
+++ b/Xcode-iOS/Demos/Demos.xcodeproj/project.pbxproj
@@ -24,6 +24,13 @@
FA30DECD1BBF5C14009C397F /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; };
FA30DECE1BBF5C14009C397F /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.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 */; };
FA8B4BA41967071300F8EB7C /* 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; };
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; };
+ 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; };
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; };
@@ -423,6 +431,7 @@
29B97314FDCFA39411CA2CEA /* CustomTemplate */ = {
isa = PBXGroup;
children = (
+ FA86C0361D9765BA009CB637 /* iOS Launch Screen.storyboard */,
FD1B48920E313154007AB34E /* SDL.xcodeproj */,
FD77A0040E26BC0500F39101 /* src */,
29B97317FDCFA39411CA2CEA /* Resources */,
@@ -676,7 +685,9 @@
TargetAttributes = {
FA30DE951BBF59D9009C397F = {
CreatedOnToolsVersion = 7.1;
- DevelopmentTeam = DJN9C5VR5G;
+ };
+ FDC52EC60E2843D6008D768C = {
+ ProvisioningStyle = Automatic;
};
};
};
@@ -735,6 +746,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ FA86C0371D9765BB009CB637 /* iOS Launch Screen.storyboard in Resources */,
FD925B1B0E0F276600E92347 /* Icon.png in Resources */,
FD787AA20E22A5CC003E8E36 /* Default.png in Resources */,
);
@@ -755,6 +767,7 @@
buildActionMask = 2147483647;
files = (
FDB651D00E43D1AD00F688B5 /* icon.bmp in Resources */,
+ FA86C0381D9765BB009CB637 /* iOS Launch Screen.storyboard in Resources */,
FD925B1A0E0F276600E92347 /* Icon.png in Resources */,
FD787AA10E22A5CC003E8E36 /* Default.png in Resources */,
);
@@ -768,6 +781,7 @@
FDB651D10E43D1B300F688B5 /* ship.bmp in Resources */,
FD925B190E0F276600E92347 /* Icon.png in Resources */,
FD787AA30E22A5CC003E8E36 /* Default.png in Resources */,
+ FA86C0391D9765BB009CB637 /* iOS Launch Screen.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -779,6 +793,7 @@
FDB651FA0E43D1F300F688B5 /* Icon.png in Resources */,
FDB651FB0E43D1F300F688B5 /* Default.png in Resources */,
FDB652C70E43E25900F688B5 /* kromasky_16x16.bmp in Resources */,
+ FA86C03D1D9765BB009CB637 /* iOS Launch Screen.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -787,6 +802,7 @@
buildActionMask = 2147483647;
files = (
FDB651D30E43D1BA00F688B5 /* stroke.bmp in Resources */,
+ FA86C03A1D9765BB009CB637 /* iOS Launch Screen.storyboard in Resources */,
FDC202E10E107B1200ABAC90 /* Icon.png in Resources */,
FD787AA40E22A5CC003E8E36 /* Default.png in Resources */,
);
@@ -797,6 +813,7 @@
buildActionMask = 2147483647;
files = (
FDB651D80E43D1D800F688B5 /* stroke.bmp in Resources */,
+ FA86C03C1D9765BB009CB637 /* iOS Launch Screen.storyboard in Resources */,
FDC52EC80E2843D6008D768C /* Icon.png in Resources */,
FDC52EC90E2843D6008D768C /* Default.png in Resources */,
);
@@ -809,6 +826,7 @@
FDB651D40E43D1C500F688B5 /* ds_brush_snare.wav in Resources */,
FDB651D50E43D1C500F688B5 /* ds_china.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 */,
FDF0D6960E12D05400247964 /* Icon.png in Resources */,
FD787AA50E22A5CC003E8E36 /* Default.png in Resources */,
@@ -940,6 +958,7 @@
isa = XCBuildConfiguration;
buildSettings = {
INFOPLIST_FILE = Info.plist;
+ PRODUCT_BUNDLE_IDENTIFIER = com.yourcompany.Rectangles;
PRODUCT_NAME = Rectangles;
};
name = Debug;
@@ -948,6 +967,7 @@
isa = XCBuildConfiguration;
buildSettings = {
INFOPLIST_FILE = Info.plist;
+ PRODUCT_BUNDLE_IDENTIFIER = com.yourcompany.Rectangles;
PRODUCT_NAME = Rectangles;
};
name = Release;
@@ -995,6 +1015,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
+ DEVELOPMENT_TEAM = "";
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
@@ -1013,7 +1034,7 @@
INFOPLIST_FILE = Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MTL_ENABLE_DEBUG_INFO = YES;
- PRODUCT_BUNDLE_IDENTIFIER = "com.Happy-TV";
+ PRODUCT_BUNDLE_IDENTIFIER = "com.yourcompany.Happy-TV";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = appletvos;
TARGETED_DEVICE_FAMILY = 3;
@@ -1040,6 +1061,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ DEVELOPMENT_TEAM = "";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
@@ -1053,7 +1075,7 @@
INFOPLIST_FILE = Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MTL_ENABLE_DEBUG_INFO = NO;
- PRODUCT_BUNDLE_IDENTIFIER = "com.Happy-TV";
+ PRODUCT_BUNDLE_IDENTIFIER = "com.yourcompany.Happy-TV";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = appletvos;
TARGETED_DEVICE_FAMILY = 3;
@@ -1067,6 +1089,7 @@
buildSettings = {
GCC_DYNAMIC_NO_PIC = NO;
INFOPLIST_FILE = Info.plist;
+ PRODUCT_BUNDLE_IDENTIFIER = com.yourcompany.Happy;
PRODUCT_NAME = Happy;
SDKROOT = iphoneos;
};
@@ -1076,6 +1099,7 @@
isa = XCBuildConfiguration;
buildSettings = {
INFOPLIST_FILE = Info.plist;
+ PRODUCT_BUNDLE_IDENTIFIER = com.yourcompany.Happy;
PRODUCT_NAME = Happy;
SDKROOT = iphoneos;
};
@@ -1085,6 +1109,7 @@
isa = XCBuildConfiguration;
buildSettings = {
INFOPLIST_FILE = Info.plist;
+ PRODUCT_BUNDLE_IDENTIFIER = com.yourcompany.Accel;
PRODUCT_NAME = Accel;
SDKROOT = iphoneos;
};
@@ -1094,6 +1119,7 @@
isa = XCBuildConfiguration;
buildSettings = {
INFOPLIST_FILE = Info.plist;
+ PRODUCT_BUNDLE_IDENTIFIER = com.yourcompany.Accel;
PRODUCT_NAME = Accel;
SDKROOT = iphoneos;
};
@@ -1103,6 +1129,7 @@
isa = XCBuildConfiguration;
buildSettings = {
INFOPLIST_FILE = Info.plist;
+ PRODUCT_BUNDLE_IDENTIFIER = com.yourcompany.Keyboard;
PRODUCT_NAME = Keyboard;
SDKROOT = iphoneos;
};
@@ -1112,6 +1139,7 @@
isa = XCBuildConfiguration;
buildSettings = {
INFOPLIST_FILE = Info.plist;
+ PRODUCT_BUNDLE_IDENTIFIER = com.yourcompany.Keyboard;
PRODUCT_NAME = Keyboard;
SDKROOT = iphoneos;
};
@@ -1121,6 +1149,7 @@
isa = XCBuildConfiguration;
buildSettings = {
INFOPLIST_FILE = Info.plist;
+ PRODUCT_BUNDLE_IDENTIFIER = com.yourcompany.Touch;
PRODUCT_NAME = Touch;
SDKROOT = iphoneos;
};
@@ -1130,6 +1159,7 @@
isa = XCBuildConfiguration;
buildSettings = {
INFOPLIST_FILE = Info.plist;
+ PRODUCT_BUNDLE_IDENTIFIER = com.yourcompany.Touch;
PRODUCT_NAME = Touch;
SDKROOT = iphoneos;
};
@@ -1138,7 +1168,10 @@
FDC52EDC0E2843D6008D768C /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = Info.plist;
+ PRODUCT_BUNDLE_IDENTIFIER = com.yourcompany.Fireworks;
PRODUCT_NAME = Fireworks;
SDKROOT = iphoneos;
};
@@ -1147,7 +1180,10 @@
FDC52EDD0E2843D6008D768C /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = Info.plist;
+ PRODUCT_BUNDLE_IDENTIFIER = com.yourcompany.Fireworks;
PRODUCT_NAME = Fireworks;
SDKROOT = iphoneos;
};
@@ -1157,6 +1193,7 @@
isa = XCBuildConfiguration;
buildSettings = {
INFOPLIST_FILE = Info.plist;
+ PRODUCT_BUNDLE_IDENTIFIER = com.yourcompany.Mixer;
PRODUCT_NAME = Mixer;
SDKROOT = iphoneos;
};
@@ -1166,6 +1203,7 @@
isa = XCBuildConfiguration;
buildSettings = {
INFOPLIST_FILE = Info.plist;
+ PRODUCT_BUNDLE_IDENTIFIER = com.yourcompany.Mixer;
PRODUCT_NAME = Mixer;
SDKROOT = iphoneos;
};
diff --git a/Xcode-iOS/Demos/Info.plist b/Xcode-iOS/Demos/Info.plist
index 0398f00..fbbaf7f 100644
--- a/Xcode-iOS/Demos/Info.plist
+++ b/Xcode-iOS/Demos/Info.plist
@@ -11,7 +11,7 @@
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
- <string>com.yourcompany.${PRODUCT_NAME:identifier}</string>
+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
@@ -24,6 +24,8 @@
<string>1.0</string>
<key>NSMainNibFile</key>
<string></string>
+ <key>UILaunchStoryboardName</key>
+ <string>iOS Launch Screen</string>
<key>UISupportedInterfaceOrientations</key>
<array/>
</dict>
diff --git a/Xcode-iOS/Demos/iOS Launch Screen.storyboard b/Xcode-iOS/Demos/iOS Launch Screen.storyboard
new file mode 100644
index 0000000..4d8722a
--- /dev/null
+++ b/Xcode-iOS/Demos/iOS Launch Screen.storyboard
@@ -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>
diff --git a/Xcode-iOS/Demos/src/accelerometer.c b/Xcode-iOS/Demos/src/accelerometer.c
index 9ff61ae..e15de3e 100644
--- a/Xcode-iOS/Demos/src/accelerometer.c
+++ b/Xcode-iOS/Demos/src/accelerometer.c
@@ -8,7 +8,6 @@
#include "math.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 FRICTION 0.0008f /* coefficient of acceleration that opposes direction of motion */
#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 */
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;
/* get joystick (accelerometer) axis values and normalize them */
@@ -54,10 +53,10 @@ render(SDL_Renderer *renderer, int w, int h)
*/
shipData.vx +=
ax * SDL_IPHONE_MAX_GFORCE / SINT16_MAX * GRAVITY_CONSTANT *
- MILLESECONDS_PER_FRAME;
+ deltaMilliseconds;
shipData.vy +=
ay * SDL_IPHONE_MAX_GFORCE / SINT16_MAX * GRAVITY_CONSTANT *
- MILLESECONDS_PER_FRAME;
+ deltaMilliseconds;
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 */
/* update velocity due to friction */
- if (speed - FRICTION * MILLESECONDS_PER_FRAME > 0) {
+ if (speed - FRICTION * deltaMilliseconds > 0) {
/* apply friction */
- shipData.vx -= dirx * FRICTION * MILLESECONDS_PER_FRAME;
- shipData.vy -= diry * FRICTION * MILLESECONDS_PER_FRAME;
+ shipData.vx -= dirx * FRICTION * deltaMilliseconds;
+ shipData.vy -= diry * FRICTION * deltaMilliseconds;
} else {
/* applying friction would MORE than stop the ship, so just stop the ship */
shipData.vx = 0.0f;
@@ -79,8 +78,8 @@ render(SDL_Renderer *renderer, int w, int h)
}
/* update ship location */
- shipData.x += shipData.vx * MILLESECONDS_PER_FRAME;
- shipData.y += shipData.vy * MILLESECONDS_PER_FRAME;
+ shipData.x += shipData.vx * deltaMilliseconds;
+ shipData.y += shipData.vy * deltaMilliseconds;
if (shipData.x > maxx) {
shipData.x = maxx;
@@ -161,9 +160,6 @@ main(int argc, char *argv[])
SDL_Window *window; /* main window */
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 w, h;
@@ -173,12 +169,11 @@ main(int argc, char *argv[])
}
/* create main window and renderer */
- window = SDL_CreateWindow(NULL, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT,
- SDL_WINDOW_OPENGL |
- SDL_WINDOW_FULLSCREEN);
+ window = SDL_CreateWindow(NULL, 0, 0, 320, 480, SDL_WINDOW_FULLSCREEN | SDL_WINDOW_ALLOW_HIGHDPI);
renderer = SDL_CreateRenderer(window, 0, 0);
SDL_GetWindowSize(window, &w, &h);
+ SDL_RenderSetLogicalSize(renderer, w, h);
/* print out some info about joysticks and try to open accelerometer for use */
printf("There are %d joysticks available\n", SDL_NumJoysticks());
@@ -208,24 +203,15 @@ main(int argc, char *argv[])
done = 0;
/* enter main loop */
while (!done) {
+ double deltaTime = updateDeltaTime();
SDL_Event event;
- startFrame = SDL_GetTicks();
while (SDL_PollEvent(&event)) {
if (event.type == SDL_QUIT) {
done = 1;
}
}
- render(renderer, w, h);
- endFrame = SDL_GetTicks();
-
- /* 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);
+ render(renderer, w, h, deltaTime);
+ SDL_Delay(1);
}
/* delete textures */
diff --git a/Xcode-iOS/Demos/src/common.c b/Xcode-iOS/Demos/src/common.c
index b2d9634..0a1485a 100644
--- a/Xcode-iOS/Demos/src/common.c
+++ b/Xcode-iOS/Demos/src/common.c
@@ -32,5 +32,25 @@ void
fatalError(const char *string)
{
printf("%s: %s\n", string, SDL_GetError());
+ SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, string, SDL_GetError(), NULL);
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;
+}
diff --git a/Xcode-iOS/Demos/src/common.h b/Xcode-iOS/Demos/src/common.h
index 94e1387..96b2c96 100644
--- a/Xcode-iOS/Demos/src/common.h
+++ b/Xcode-iOS/Demos/src/common.h
@@ -4,14 +4,7 @@
* 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 float randomFloat(float min, float max);
extern void fatalError(const char *string);
+extern double updateDeltaTime();
diff --git a/Xcode-iOS/Demos/src/fireworks.c b/Xcode-iOS/Demos/src/fireworks.c
index a5beada..1006fa0 100644
--- a/Xcode-iOS/Demos/src/fireworks.c
+++ b/Xcode-iOS/Demos/src/fireworks.c
@@ -10,13 +10,13 @@
#include <math.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 WIND_RESISTANCE 0.00005f /* acceleration per unit velocity due to wind resistance */
#define MAX_PARTICLES 2000 /* maximum number of particles displayed at once */
static GLuint particleTextureID; /* OpenGL particle texture id */
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.
emitter - this particle flies up, shooting off trail particles, then finally explodes into dust particles.
@@ -55,7 +55,7 @@ void initializeParticles(void);
void initializeTexture();
int nextPowerOfTwo(int x);
void drawParticles();
-void stepParticles(void);
+void stepParticles(double deltaTime);
/* helper function (used in texture loading)
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
*/
void
-stepParticles(void)
+stepParticles(double deltaTime)
{
+ float deltaMilliseconds = deltaTime * 1000;
int i;
struct particle *slot = particles;
struct particle *curr = particles;
@@ -93,10 +94,10 @@ stepParticles(void)
curr->isActive = 0;
/* step velocity, then step position */
- curr->yvel += ACCEL * MILLESECONDS_PER_FRAME;
+ curr->yvel += ACCEL * deltaMilliseconds;
curr->xvel += 0.0f;
- curr->y += curr->yvel * MILLESECONDS_PER_FRAME;
- curr->x += curr->xvel * MILLESECONDS_PER_FRAME;
+ curr->y += curr->yvel * deltaMilliseconds;
+ curr->x += curr->xvel * deltaMilliseconds;
/* particle behavior */
if (curr->type == emitter) {
@@ -111,29 +112,29 @@ stepParticles(void)
sqrt(curr->xvel * curr->xvel + curr->yvel * curr->yvel);
/* if wind resistance is not powerful enough to 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 normy = curr->yvel / speed;
curr->xvel -=
- normx * WIND_RESISTANCE * MILLESECONDS_PER_FRAME;
+ normx * WIND_RESISTANCE * deltaMilliseconds;
curr->yvel -=
- normy * WIND_RESISTANCE * MILLESECONDS_PER_FRAME;
+ normy * WIND_RESISTANCE * deltaMilliseconds;
} else {
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
then just mark for deletion */
curr->isActive = 0;
} else {
/* 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 (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
old number of active particles, where slot points, and the
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->isActive = 1;
p->type = dust;
- p->size = 15;
+ p->size = 15 * pointSizeScale;
/* inherit emitter's color */
p->color[0] = emitter->color[0];
p->color[1] = emitter->color[1];
@@ -244,7 +245,7 @@ spawnTrailFromEmitter(struct particle *emitter)
p->color[3] = (0.7f) * 255;
/* set other attributes */
- p->size = 10;
+ p->size = 10 * pointSizeScale;
p->type = trail;
p->isActive = 1;
@@ -298,7 +299,7 @@ spawnEmitterParticle(GLfloat x, GLfloat y)
p->xvel = 0;
p->yvel = -sqrt(2 * ACCEL * (screen_h - y));
/* set other attributes */
- p->size = 10;
+ p->size = 10 * pointSizeScale;
p->type = emitter;
p->isActive = 1;
/* our array has expanded at the end */
@@ -363,7 +364,7 @@ main(int argc, char *argv[])
{
SDL_Window *window; /* main window */
SDL_GLContext context;
- int w, h;
+ int drawableW, drawableH;
Uint32 startFrame; /* time frame began to process */
Uint32 endFrame; /* time frame ended processing */
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);
/* create main window and renderer */
- window = SDL_CreateWindow(NULL, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT,
- SDL_WINDOW_OPENGL |
- SDL_WINDOW_BORDERLESS);
+ window = SDL_CreateWindow(NULL, 0, 0, 320, 480,
+ SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS | SDL_WINDOW_ALLOW_HIGHDPI);
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 */
initializeTexture();
@@ -412,8 +421,7 @@ main(int argc, char *argv[])
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
- SDL_GetWindowSize(window, &screen_w, &screen_h);
- glViewport(0, 0, screen_w, screen_h);
+ glViewport(0, 0, drawableW, drawableH);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
@@ -436,14 +444,14 @@ main(int argc, char *argv[])
glEnableClientState(GL_POINT_SIZE_ARRAY_OES);
} else {
/* if extension not available then all particles have size 10 */
- glPointSize(10);
+ glPointSize(10 * pointSizeScale);
}
done = 0;
/* enter main loop */
while (!done) {
- startFrame = SDL_GetTicks();
SDL_Event event;
+ double deltaTime = updateDeltaTime();
while (SDL_PollEvent(&event)) {
if (event.type == SDL_QUIT) {
done = 1;
@@ -454,19 +462,10 @@ main(int argc, char *argv[])
spawnEmitterParticle(x, y);
}
}
- stepParticles();
+ stepParticles(deltaTime);
drawParticles();
SDL_GL_SwapWindow(window);
- endFrame = SDL_GetTicks();
-
- /* 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);
- }
+ SDL_Delay(1);
}
/* delete textures */
diff --git a/Xcode-iOS/Demos/src/happy.c b/Xcode-iOS/Demos/src/happy.c
index c8a7ec3..658a65f 100644
--- a/Xcode-iOS/Demos/src/happy.c
+++ b/Xcode-iOS/Demos/src/happy.c
@@ -8,8 +8,7 @@
#include "common.h"
#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 (pixels) */
+#define HAPPY_FACE_SIZE 32 /* width and height of happyface */
static SDL_Texture *texture = 0; /* reference to texture holding happyface */
@@ -24,30 +23,37 @@ static struct
units of velocity are pixels per millesecond
*/
void
-initializeHappyFaces()
+initializeHappyFaces(SDL_Renderer *renderer)
{
int i;
+ int w;
+ int h;
+ SDL_RenderGetLogicalSize(renderer, &w, &h);
+
for (i = 0; i < NUM_HAPPY_FACES; i++) {
- faces[i].x = randomFloat(0.0f, SCREEN_WIDTH - HAPPY_FACE_SIZE);
- faces[i].y = randomFloat(0.0f, SCREEN_HEIGHT - HAPPY_FACE_SIZE);
- faces[i].xvel = randomFloat(-0.1f, 0.1f);
- faces[i].yvel = randomFloat(-0.1f, 0.1f);
+ faces[i].x = randomFloat(0.0f, w - HAPPY_FACE_SIZE);
+ faces[i].y = randomFloat(0.0f, h - HAPPY_FACE_SIZE);
+ faces[i].xvel = randomFloat(-60.0f, 60.0f);
+ faces[i].yvel = randomFloat(-60.0f, 60.0f);
}
}
void
-render(SDL_Renderer *renderer)
+render(SDL_Renderer *renderer, double deltaTime)
{
-
int i;
SDL_Rect srcRect;
SDL_Rect dstRect;
+ int w;
+ int h;
+
+ SDL_RenderGetLogicalSize(renderer, &w, &h);
/* setup boundaries for happyface bouncing */
- Uint16 maxx = SCREEN_WIDTH - HAPPY_FACE_SIZE;
- Uint16 maxy = SCREEN_HEIGHT - HAPPY_FACE_SIZE;
- Uint16 minx = 0;
- Uint16 miny = 0;
+ int maxx = w - HAPPY_FACE_SIZE;
+ int maxy = h - HAPPY_FACE_SIZE;
+ int minx = 0;
+ int miny = 0;
/* setup rects for drawing */
srcRect.x = 0;
@@ -68,8 +74,8 @@ render(SDL_Renderer *renderer)
- draw
*/
for (i = 0; i < NUM_HAPPY_FACES; i++) {
- faces[i].x += faces[i].xvel * MILLESECONDS_PER_FRAME;
- faces[i].y += faces[i].yvel * MILLESECONDS_PER_FRAME;
+ faces[i].x += faces[i].xvel * deltaTime;
+ faces[i].y += faces[i].yvel * deltaTime;
if (faces[i].x > maxx) {
faces[i].x = maxx;
faces[i].xvel = -faces[i].xvel;
@@ -123,48 +129,45 @@ initializeTexture(SDL_Renderer *renderer)
int
main(int argc, char *argv[])
{
-
SDL_Window *window;
SDL_Renderer *renderer;
- Uint32 startFrame;
- Uint32 endFrame;
- Uint32 delay;
int done;
+ int width;
+ int height;
/* initialize SDL */
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
fatalError("Could not initialize SDL");
}
- window = SDL_CreateWindow(NULL, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT,
- SDL_WINDOW_OPENGL |
- SDL_WINDOW_BORDERLESS);
+
+ /* The specified window size doesn't matter - except for its aspect ratio,
+ * 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);
+ SDL_GetWindowSize(window, &width, &height);
+ SDL_RenderSetLogicalSize(renderer, width, height);
+
initializeTexture(renderer);
- initializeHappyFaces();
+ initializeHappyFaces(renderer);
+
/* main loop */
done = 0;
while (!done) {
SDL_Event event;
- startFrame = SDL_GetTicks();
+ double deltaTime = updateDeltaTime();
+
while (SDL_PollEvent(&event)) {
if (event.type == SDL_QUIT) {
done = 1;
}
}
- render(renderer);
- endFrame = SDL_GetTicks();
-
- /* 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);
+
+ render(renderer, deltaTime);
+ SDL_Delay(1);
}
/* cleanup */
diff --git a/Xcode-iOS/Demos/src/keyboard.c b/Xcode-iOS/Demos/src/keyboard.c
index ab819f1..1932ad4 100644
--- a/Xcode-iOS/Demos/src/keyboard.c
+++ b/Xcode-iOS/Demos/src/keyboard.c
@@ -132,10 +132,13 @@ keyToIndex(SDL_Keysym key)
void
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 y_padding = 32; /* padding space at top of 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 */
*x = (n % max_x_chars) * GLYPH_SIZE_SCREEN + x_padding;
*y = (n / max_x_chars) * (GLYPH_SIZE_SCREEN + line_separation) +
@@ -228,21 +231,25 @@ loadFont(void)
int
main(int argc, char *argv[])
{
-
int index; /* index of last key we pushed in the bitmap font */
SDL_Window *window;
SDL_Event event; /* last event received */
SDL_Keymod mod; /* key modifiers 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) {
printf("Error initializing SDL: %s", SDL_GetError());
}
/* 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 */
renderer = SDL_CreateRenderer(window, -1, 0);
+ SDL_GetWindowSize(window, &width, &height);
+ SDL_RenderSetLogicalSize(renderer, width, height);
+
/* load up our font */
loadFont();
diff --git a/Xcode-iOS/Demos/src/mixer.c b/Xcode-iOS/Demos/src/mixer.c
index 8c21ba8..30d7e47 100644
--- a/Xcode-iOS/Demos/src/mixer.c
+++ b/Xcode-iOS/Demos/src/mixer.c
@@ -33,7 +33,7 @@ static struct sound drums[NUM_DRUMS];
void handleMouseButtonDown(SDL_Event * event);
void handleMouseButtonUp(SDL_Event * event);
int playSound(struct sound *);
-void initializeButtons();
+void initializeButtons(SDL_Renderer *);
void audioCallback(void *userdata, Uint8 * stream, int len);
void loadSound(const char *file, struct sound *s);
@@ -52,19 +52,21 @@ struct
/* sets up the buttons (color, position, state) */
void
-initializeButtons()
+initializeButtons(SDL_Renderer *renderer)
{
-
int i;
int spacing = 10; /* gap between drum buttons */
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 downColor = { 191, 191, 221, 255 }; /* color of drum when pressed */
+ int renderW, renderH;
+
+ SDL_RenderGetLogicalSize(renderer, &renderW, &renderH);
buttonRect.x = spacing;
buttonRect.y = spacing;
- buttonRect.w = SCREEN_WIDTH - 2 * spacing;
- buttonRect.h = (SCREEN_HEIGHT - (NUM_DRUMS + 1) * spacing) / NUM_DRUMS;
+ buttonRect.w = renderW - 2 * spacing;
+ buttonRect.h = (renderH - (NUM_DRUMS + 1) * spacing) / NUM_DRUMS;
/* setup each button */
for (i = 0; i < NUM_DRUMS; i++) {
@@ -270,24 +272,23 @@ audioCallback(void *userdata, Uint8 * stream, int len)
int
main(int argc, char *argv[])
{
-
int done; /* has user tried to quit ? */
SDL_Window *window; /* main window */
SDL_Renderer *renderer;
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 width;
+ int height;
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) {
fatalError("could not initialize SDL");
}
- window =
- SDL_CreateWindow(NULL, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT,
- SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS);
+ window = SDL_CreateWindow(NULL, 0, 0, 320, 480, SDL_WINDOW_BORDERLESS | SDL_WINDOW_ALLOW_HIGHDPI);
renderer = SDL_CreateRenderer(window, 0, 0);
+ SDL_GetWindowSize(window, &width, &height);
+ SDL_RenderSetLogicalSize(renderer, width, height);
+
/* initialize the mixer */
SDL_memset(&mixer, 0, sizeof(mixer));
/* setup output format */
@@ -310,12 +311,11 @@ main(int argc, char *argv[])
loadSound("ds_china.wav", &drums[0]);
/* setup positions, colors, and state of buttons */
- initializeButtons();
+ initializeButtons(renderer);
/* enter main loop */
done = 0;
while (!done) {
- startFrame = SDL_GetTicks();
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_MOUSEBUTTONDOWN:
@@ -330,16 +330,8 @@ main(int argc, char *argv[])
}
}
render(renderer); /* draw buttons */
- endFrame = SDL_GetTicks();
-
- /* 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);
+
+ SDL_Delay(1);
}
/* cleanup code, let's free up those sound buffers */
diff --git a/Xcode-iOS/Demos/src/rectangles.c b/Xcode-iOS/Demos/src/rectangles.c
index 77e2a56..10f9f85 100644
--- a/Xcode-iOS/Demos/src/rectangles.c
+++ b/Xcode-iOS/Demos/src/rectangles.c
@@ -11,14 +11,18 @@
void
render(SDL_Renderer *renderer)
{
-
Uint8 r, g, b;
+ int renderW;
+ int renderH;
+
+ SDL_RenderGetLogicalSize(renderer, &renderW, &renderH);
+
/* Come up with a random rectangle */
SDL_Rect rect;
rect.w = randomInt(64, 128);
rect.h = randomInt(64, 128);
- rect.x = randomInt(0, SCREEN_WIDTH);
- rect.y = randomInt(0, SCREEN_HEIGHT);
+ rect.x = randomInt(0, renderW);
+ rect.y = randomInt(0, renderH);
/* Come up with a random color */
r = randomInt(50, 255);
@@ -31,7 +35,6 @@ render(SDL_Renderer *renderer)
/* update screen */
SDL_RenderPresent(renderer);
-
}
int
@@ -42,6 +45,8 @@ main(int argc, char *argv[])
SDL_Renderer *renderer;
int done;
SDL_Event event;
+ int windowW;
+ int windowH;
/* initialize SDL */
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
@@ -52,7 +57,7 @@ main(int argc, char *argv[])
srand(time(NULL));
/* 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) {
fatalError("Could not initialize Window");
}
@@ -61,6 +66,9 @@ main(int argc, char *argv[])
fatalError("Could not create renderer");
}
+ SDL_GetWindowSize(window, &windowW, &windowH);
+ SDL_RenderSetLogicalSize(renderer, windowW, windowH);
+
/* Fill screen with black */
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
SDL_RenderClear(renderer);
diff --git a/Xcode-iOS/Demos/src/touch.c b/Xcode-iOS/Demos/src/touch.c
index fc5fd46..32e6cea 100644
--- a/Xcode-iOS/Demos/src/touch.c
+++ b/Xcode-iOS/Demos/src/touch.c
@@ -82,6 +82,7 @@ main(int argc, char *argv[])
SDL_Window *window; /* main window */
SDL_Renderer *renderer;
int done; /* does user want to quit? */
+ int w, h;
/* initialize SDL */
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
@@ -89,11 +90,12 @@ main(int argc, char *argv[])
}
/* create main window and renderer */
- window = SDL_CreateWindow(NULL, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT,
- SDL_WINDOW_OPENGL |
- SDL_WINDOW_BORDERLESS);
+ window = SDL_CreateWindow(NULL, 0, 0, 320, 480, SDL_WINDOW_BORDERLESS | SDL_WINDOW_ALLOW_HIGHDPI);
renderer = SDL_CreateRenderer(window, 0, 0);
+ SDL_GetWindowSize(window, &w, &h);
+ SDL_RenderSetLogicalSize(renderer, w, h);
+
/* load brush texture */
initializeTexture(renderer);