istereo2

changeset 3:dc735bdeeb8a

mkicons script added content-scale support for "retina" devices
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 21 Sep 2015 07:40:34 +0300
parents 81d35769f546
children d4fed8aac9a6
files .hgignore ios/Info.plist ios/icons/mkicons istereo.xcodeproj/project.pbxproj src/ios/viewctl.m
diffstat 5 files changed, 119 insertions(+), 4 deletions(-) [+]
line diff
     1.1 --- a/.hgignore	Sat Sep 19 05:51:51 2015 +0300
     1.2 +++ b/.hgignore	Mon Sep 21 07:40:34 2015 +0300
     1.3 @@ -3,5 +3,8 @@
     1.4  \.d$
     1.5  \.xcuserstate$
     1.6  \.xcworkspace
     1.7 +\.xcassets
     1.8  xcuserdata/
     1.9  ^build/
    1.10 +\.png$
    1.11 +^data/
     2.1 --- a/ios/Info.plist	Sat Sep 19 05:51:51 2015 +0300
     2.2 +++ b/ios/Info.plist	Mon Sep 21 07:40:34 2015 +0300
     2.3 @@ -30,9 +30,9 @@
     2.4  	<true/>
     2.5  	<key>UISupportedInterfaceOrientations</key>
     2.6  	<array>
     2.7 -		<string>UIInterfaceOrientationPortrait</string>
     2.8  		<string>UIInterfaceOrientationLandscapeLeft</string>
     2.9  		<string>UIInterfaceOrientationLandscapeRight</string>
    2.10 +		<string>UIInterfaceOrientationPortrait</string>
    2.11  	</array>
    2.12  	<key>UISupportedInterfaceOrientations~ipad</key>
    2.13  	<array>
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/ios/icons/mkicons	Mon Sep 21 07:40:34 2015 +0300
     3.3 @@ -0,0 +1,95 @@
     3.4 +#!/bin/sh
     3.5 +
     3.6 +srcicon=icon.png
     3.7 +srclaunch=launch.png
     3.8 +
     3.9 +while [ $# -gt 0 ]; do
    3.10 +	case $1 in
    3.11 +	-icon)
    3.12 +		shift
    3.13 +		srcicon=$1
    3.14 +		;;
    3.15 +	-launch)
    3.16 +		shift
    3.17 +		srclaunch=$1
    3.18 +		;;
    3.19 +	*)
    3.20 +		echo "unexpected argument: $1"
    3.21 +		exit 1
    3.22 +		;;
    3.23 +	esac
    3.24 +	shift
    3.25 +done
    3.26 +
    3.27 +if [ ! -f "$srcicon" ]; then
    3.28 +	echo "source icon ($srcicon) missing" >&2
    3.29 +	exit 1
    3.30 +fi
    3.31 +if [ ! -f "$srclaunch" ]; then
    3.32 +	echo "source launch screen ($srclaunch) missing" >&2
    3.33 +	exit 1
    3.34 +fi
    3.35 +
    3.36 +mkicon()
    3.37 +{
    3.38 +	out=$1
    3.39 +	sz=$2
    3.40 +
    3.41 +	echo "$srcicon -> $out (${sz}x${sz})"
    3.42 +	convert $srcicon -resize $sz $out
    3.43 +}
    3.44 +
    3.45 +mklaunch()
    3.46 +{
    3.47 +	out=$1
    3.48 +	xsz=$2
    3.49 +	ysz=$3
    3.50 +
    3.51 +	echo "$srclaunch -> $out (${xsz}x${ysz})"
    3.52 +	convert $srclaunch -resize ${xsz}x${ysz}^ \
    3.53 +		-gravity Center -crop ${xsz}x${ysz}+0+0 +repage \
    3.54 +		$out
    3.55 +}
    3.56 +
    3.57 +echo "Generating icons ..."
    3.58 +# --- iphone spotlight icons
    3.59 +mkicon icon29.png 29	# Icon-Small
    3.60 +mkicon icon58.png 58	# Icon-Small@2x
    3.61 +mkicon icon87.png 87	# Icon-Small@3x
    3.62 +mkicon icon40.png 40	# Icon-Small-40
    3.63 +mkicon icon80.png 80	# Icon-Small-40@2x
    3.64 +mkicon icon120.png 120	# Icon-Small-40@3x
    3.65 +
    3.66 +# --- iphone app icons
    3.67 +mkicon icon57.png 57	# Icon
    3.68 +mkicon icon114.png 114	# Icon@2x
    3.69 +mkicon icon120.png 120	# Icon-60@2x
    3.70 +mkicon icon180.png 180	# Icon-60@3x
    3.71 +
    3.72 +# --- ipad spotlight (40 series plus the following)
    3.73 +mkicon icon50.png 50	# Icon-Small-50
    3.74 +mkicon icon100.png 100	# Icon-Small-50@2x
    3.75 +
    3.76 +# --- ipad app icons
    3.77 +mkicon icon72.png 72	# Icon-72
    3.78 +mkicon icon144.png 144	# Icon-72@2x
    3.79 +mkicon icon76.png 76	# Icon-76
    3.80 +mkicon icon152.png 152	# Icon-76@2x
    3.81 +
    3.82 +echo "Generating launch screens ..."
    3.83 +# iphone portrait launch screen images
    3.84 +mklaunch launch-1242x2208.png 1242 2208
    3.85 +mklaunch launch-750x1334.png 750 1334
    3.86 +mklaunch launch-640x960.png 640 960
    3.87 +mklaunch launch-640x1136.png 640 1136
    3.88 +mklaunch launch-320x480.png 320 480
    3.89 +mklaunch launch-640x960.png 640 960
    3.90 +mklaunch launch-640x1136.png 640 1136
    3.91 +
    3.92 +
    3.93 +# ipad portrait launch screen images
    3.94 +mklaunch launch-768x1024.png 768 1024
    3.95 +mklaunch launch-1536x2048.png 1536 2048
    3.96 +mklaunch launch-768x1004.png 768 1004
    3.97 +mklaunch launch-1536x2008.png 1536 2008
    3.98 +
     4.1 --- a/istereo.xcodeproj/project.pbxproj	Sat Sep 19 05:51:51 2015 +0300
     4.2 +++ b/istereo.xcodeproj/project.pbxproj	Mon Sep 21 07:40:34 2015 +0300
     4.3 @@ -7,7 +7,6 @@
     4.4  	objects = {
     4.5  
     4.6  /* Begin PBXBuildFile section */
     4.7 -		0669D6751BA858BF00611CFA /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 0669D6741BA858BF00611CFA /* Info.plist */; };
     4.8  		0669D67F1BA85DDE00611CFA /* app_delegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 0669D67B1BA85DDE00611CFA /* app_delegate.m */; };
     4.9  		0669D6801BA85DDE00611CFA /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 0669D67C1BA85DDE00611CFA /* main.m */; };
    4.10  		0669D6811BA85DDE00611CFA /* viewctl.m in Sources */ = {isa = PBXBuildFile; fileRef = 0669D67E1BA85DDE00611CFA /* viewctl.m */; };
    4.11 @@ -115,6 +114,7 @@
    4.12  		0669D78E1BAD02DC00611CFA /* stonewall.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 0669D78A1BAD02DC00611CFA /* stonewall.jpg */; };
    4.13  		0669D78F1BAD02DC00611CFA /* text.png in Resources */ = {isa = PBXBuildFile; fileRef = 0669D78B1BAD02DC00611CFA /* text.png */; };
    4.14  		0669D7901BAD02DC00611CFA /* tiles.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 0669D78C1BAD02DC00611CFA /* tiles.jpg */; };
    4.15 +		06ED084A1BAF9A2E00C1211D /* icons.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 06ED08491BAF9A2E00C1211D /* icons.xcassets */; settings = {ASSET_TAGS = (); }; };
    4.16  /* End PBXBuildFile section */
    4.17  
    4.18  /* Begin PBXFileReference section */
    4.19 @@ -279,6 +279,7 @@
    4.20  		0669D78A1BAD02DC00611CFA /* stonewall.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; name = stonewall.jpg; path = data/stonewall.jpg; sourceTree = "<group>"; };
    4.21  		0669D78B1BAD02DC00611CFA /* text.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = text.png; path = data/text.png; sourceTree = "<group>"; };
    4.22  		0669D78C1BAD02DC00611CFA /* tiles.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; name = tiles.jpg; path = data/tiles.jpg; sourceTree = "<group>"; };
    4.23 +		06ED08491BAF9A2E00C1211D /* icons.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = icons.xcassets; path = ios/icons.xcassets; sourceTree = "<group>"; };
    4.24  /* End PBXFileReference section */
    4.25  
    4.26  /* Begin PBXFrameworksBuildPhase section */
    4.27 @@ -295,6 +296,7 @@
    4.28  		0669D63E1BA851BE00611CFA = {
    4.29  			isa = PBXGroup;
    4.30  			children = (
    4.31 +				06ED08491BAF9A2E00C1211D /* icons.xcassets */,
    4.32  				0669D7881BAD02B000611CFA /* data */,
    4.33  				0669D77B1BAD028300611CFA /* sdr */,
    4.34  				0669D6971BAD01C200611CFA /* libs */,
    4.35 @@ -606,11 +608,11 @@
    4.36  			buildActionMask = 2147483647;
    4.37  			files = (
    4.38  				0669D7861BAD02A200611CFA /* tunnel.p.glsl in Resources */,
    4.39 -				0669D6751BA858BF00611CFA /* Info.plist in Resources */,
    4.40  				0669D7821BAD02A200611CFA /* test.p.glsl in Resources */,
    4.41  				0669D78D1BAD02DC00611CFA /* stonewall_normal.jpg in Resources */,
    4.42  				0669D78E1BAD02DC00611CFA /* stonewall.jpg in Resources */,
    4.43  				0669D7841BAD02A200611CFA /* text.p.glsl in Resources */,
    4.44 +				06ED084A1BAF9A2E00C1211D /* icons.xcassets in Resources */,
    4.45  				0669D7901BAD02DC00611CFA /* tiles.jpg in Resources */,
    4.46  				0669D7871BAD02A200611CFA /* tunnel.v.glsl in Resources */,
    4.47  				0669D78F1BAD02DC00611CFA /* text.png in Resources */,
    4.48 @@ -816,6 +818,7 @@
    4.49  			buildSettings = {
    4.50  				ALWAYS_SEARCH_USER_PATHS = YES;
    4.51  				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
    4.52 +				ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
    4.53  				CODE_SIGN_IDENTITY = "iPhone Developer";
    4.54  				INFOPLIST_FILE = "$(SRCROOT)/ios/Info.plist";
    4.55  				IPHONEOS_DEPLOYMENT_TARGET = 6.0;
    4.56 @@ -829,6 +832,7 @@
    4.57  			buildSettings = {
    4.58  				ALWAYS_SEARCH_USER_PATHS = YES;
    4.59  				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
    4.60 +				ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
    4.61  				CODE_SIGN_IDENTITY = "iPhone Developer";
    4.62  				INFOPLIST_FILE = "$(SRCROOT)/ios/Info.plist";
    4.63  				IPHONEOS_DEPLOYMENT_TARGET = 6.0;
     5.1 --- a/src/ios/viewctl.m	Sat Sep 19 05:51:51 2015 +0300
     5.2 +++ b/src/ios/viewctl.m	Mon Sep 21 07:40:34 2015 +0300
     5.3 @@ -5,6 +5,7 @@
     5.4  
     5.5  @interface ViewController () {
     5.6  	EAGLContext *ctx;
     5.7 +	float pixel_scale;
     5.8  
     5.9  	ADBannerView *ad;
    5.10  	BOOL ad_visible;
    5.11 @@ -25,6 +26,7 @@
    5.12  {
    5.13      [super viewDidLoad];
    5.14  
    5.15 +
    5.16      self->ctx = [[EAGLContext alloc] initWithAPI: kEAGLRenderingAPIOpenGLES2];
    5.17      if(!self->ctx) {
    5.18          NSLog(@"Failed to create OpenGL ES 2.0 context");
    5.19 @@ -34,6 +36,14 @@
    5.20      view.context = self->ctx;
    5.21      view.drawableDepthFormat = GLKViewDrawableDepthFormat24;
    5.22  
    5.23 +	if([view respondsToSelector: NSSelectorFromString(@"contentScaleFactor")]) {
    5.24 +		pixel_scale = [[UIScreen mainScreen] scale];
    5.25 +		view.contentScaleFactor = pixel_scale;
    5.26 +		printf("pixel scale: %g\n", pixel_scale);
    5.27 +	} else {
    5.28 +		pixel_scale = 1.0f;
    5.29 +	}
    5.30 +
    5.31  	[self create_ad];
    5.32  
    5.33  	[self init_gl];
    5.34 @@ -124,7 +134,10 @@
    5.35  - (void)viewDidLayoutSubviews
    5.36  {
    5.37  	CGRect rect = self.view.frame;
    5.38 -	reshape(rect.size.width, rect.size.height);
    5.39 +	int xsz = rect.size.width * pixel_scale;
    5.40 +	int ysz = rect.size.height * pixel_scale;
    5.41 +	reshape(xsz, ysz);
    5.42 +	printf("viewport %dx%d (scale: %g)\n", xsz, ysz, pixel_scale);
    5.43  }
    5.44  
    5.45  // ADBannerDelegate functions