# HG changeset patch # User John Tsiombikas # Date 1442810434 -10800 # Node ID dc735bdeeb8a9f8a51f76e96785ea186793ed8d0 # Parent 81d35769f546eb73cc17a04121953e6e28bbf06b mkicons script added content-scale support for "retina" devices diff -r 81d35769f546 -r dc735bdeeb8a .hgignore --- a/.hgignore Sat Sep 19 05:51:51 2015 +0300 +++ b/.hgignore Mon Sep 21 07:40:34 2015 +0300 @@ -3,5 +3,8 @@ \.d$ \.xcuserstate$ \.xcworkspace +\.xcassets xcuserdata/ ^build/ +\.png$ +^data/ diff -r 81d35769f546 -r dc735bdeeb8a ios/Info.plist --- a/ios/Info.plist Sat Sep 19 05:51:51 2015 +0300 +++ b/ios/Info.plist Mon Sep 21 07:40:34 2015 +0300 @@ -30,9 +30,9 @@ UISupportedInterfaceOrientations - UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight + UIInterfaceOrientationPortrait UISupportedInterfaceOrientations~ipad diff -r 81d35769f546 -r dc735bdeeb8a ios/icons/mkicons --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ios/icons/mkicons Mon Sep 21 07:40:34 2015 +0300 @@ -0,0 +1,95 @@ +#!/bin/sh + +srcicon=icon.png +srclaunch=launch.png + +while [ $# -gt 0 ]; do + case $1 in + -icon) + shift + srcicon=$1 + ;; + -launch) + shift + srclaunch=$1 + ;; + *) + echo "unexpected argument: $1" + exit 1 + ;; + esac + shift +done + +if [ ! -f "$srcicon" ]; then + echo "source icon ($srcicon) missing" >&2 + exit 1 +fi +if [ ! -f "$srclaunch" ]; then + echo "source launch screen ($srclaunch) missing" >&2 + exit 1 +fi + +mkicon() +{ + out=$1 + sz=$2 + + echo "$srcicon -> $out (${sz}x${sz})" + convert $srcicon -resize $sz $out +} + +mklaunch() +{ + out=$1 + xsz=$2 + ysz=$3 + + echo "$srclaunch -> $out (${xsz}x${ysz})" + convert $srclaunch -resize ${xsz}x${ysz}^ \ + -gravity Center -crop ${xsz}x${ysz}+0+0 +repage \ + $out +} + +echo "Generating icons ..." +# --- iphone spotlight icons +mkicon icon29.png 29 # Icon-Small +mkicon icon58.png 58 # Icon-Small@2x +mkicon icon87.png 87 # Icon-Small@3x +mkicon icon40.png 40 # Icon-Small-40 +mkicon icon80.png 80 # Icon-Small-40@2x +mkicon icon120.png 120 # Icon-Small-40@3x + +# --- iphone app icons +mkicon icon57.png 57 # Icon +mkicon icon114.png 114 # Icon@2x +mkicon icon120.png 120 # Icon-60@2x +mkicon icon180.png 180 # Icon-60@3x + +# --- ipad spotlight (40 series plus the following) +mkicon icon50.png 50 # Icon-Small-50 +mkicon icon100.png 100 # Icon-Small-50@2x + +# --- ipad app icons +mkicon icon72.png 72 # Icon-72 +mkicon icon144.png 144 # Icon-72@2x +mkicon icon76.png 76 # Icon-76 +mkicon icon152.png 152 # Icon-76@2x + +echo "Generating launch screens ..." +# iphone portrait launch screen images +mklaunch launch-1242x2208.png 1242 2208 +mklaunch launch-750x1334.png 750 1334 +mklaunch launch-640x960.png 640 960 +mklaunch launch-640x1136.png 640 1136 +mklaunch launch-320x480.png 320 480 +mklaunch launch-640x960.png 640 960 +mklaunch launch-640x1136.png 640 1136 + + +# ipad portrait launch screen images +mklaunch launch-768x1024.png 768 1024 +mklaunch launch-1536x2048.png 1536 2048 +mklaunch launch-768x1004.png 768 1004 +mklaunch launch-1536x2008.png 1536 2008 + diff -r 81d35769f546 -r dc735bdeeb8a istereo.xcodeproj/project.pbxproj --- a/istereo.xcodeproj/project.pbxproj Sat Sep 19 05:51:51 2015 +0300 +++ b/istereo.xcodeproj/project.pbxproj Mon Sep 21 07:40:34 2015 +0300 @@ -7,7 +7,6 @@ objects = { /* Begin PBXBuildFile section */ - 0669D6751BA858BF00611CFA /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 0669D6741BA858BF00611CFA /* Info.plist */; }; 0669D67F1BA85DDE00611CFA /* app_delegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 0669D67B1BA85DDE00611CFA /* app_delegate.m */; }; 0669D6801BA85DDE00611CFA /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 0669D67C1BA85DDE00611CFA /* main.m */; }; 0669D6811BA85DDE00611CFA /* viewctl.m in Sources */ = {isa = PBXBuildFile; fileRef = 0669D67E1BA85DDE00611CFA /* viewctl.m */; }; @@ -115,6 +114,7 @@ 0669D78E1BAD02DC00611CFA /* stonewall.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 0669D78A1BAD02DC00611CFA /* stonewall.jpg */; }; 0669D78F1BAD02DC00611CFA /* text.png in Resources */ = {isa = PBXBuildFile; fileRef = 0669D78B1BAD02DC00611CFA /* text.png */; }; 0669D7901BAD02DC00611CFA /* tiles.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 0669D78C1BAD02DC00611CFA /* tiles.jpg */; }; + 06ED084A1BAF9A2E00C1211D /* icons.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 06ED08491BAF9A2E00C1211D /* icons.xcassets */; settings = {ASSET_TAGS = (); }; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -279,6 +279,7 @@ 0669D78A1BAD02DC00611CFA /* stonewall.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; name = stonewall.jpg; path = data/stonewall.jpg; sourceTree = ""; }; 0669D78B1BAD02DC00611CFA /* text.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = text.png; path = data/text.png; sourceTree = ""; }; 0669D78C1BAD02DC00611CFA /* tiles.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; name = tiles.jpg; path = data/tiles.jpg; sourceTree = ""; }; + 06ED08491BAF9A2E00C1211D /* icons.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = icons.xcassets; path = ios/icons.xcassets; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -295,6 +296,7 @@ 0669D63E1BA851BE00611CFA = { isa = PBXGroup; children = ( + 06ED08491BAF9A2E00C1211D /* icons.xcassets */, 0669D7881BAD02B000611CFA /* data */, 0669D77B1BAD028300611CFA /* sdr */, 0669D6971BAD01C200611CFA /* libs */, @@ -606,11 +608,11 @@ buildActionMask = 2147483647; files = ( 0669D7861BAD02A200611CFA /* tunnel.p.glsl in Resources */, - 0669D6751BA858BF00611CFA /* Info.plist in Resources */, 0669D7821BAD02A200611CFA /* test.p.glsl in Resources */, 0669D78D1BAD02DC00611CFA /* stonewall_normal.jpg in Resources */, 0669D78E1BAD02DC00611CFA /* stonewall.jpg in Resources */, 0669D7841BAD02A200611CFA /* text.p.glsl in Resources */, + 06ED084A1BAF9A2E00C1211D /* icons.xcassets in Resources */, 0669D7901BAD02DC00611CFA /* tiles.jpg in Resources */, 0669D7871BAD02A200611CFA /* tunnel.v.glsl in Resources */, 0669D78F1BAD02DC00611CFA /* text.png in Resources */, @@ -816,6 +818,7 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; CODE_SIGN_IDENTITY = "iPhone Developer"; INFOPLIST_FILE = "$(SRCROOT)/ios/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 6.0; @@ -829,6 +832,7 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; CODE_SIGN_IDENTITY = "iPhone Developer"; INFOPLIST_FILE = "$(SRCROOT)/ios/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 6.0; diff -r 81d35769f546 -r dc735bdeeb8a src/ios/viewctl.m --- a/src/ios/viewctl.m Sat Sep 19 05:51:51 2015 +0300 +++ b/src/ios/viewctl.m Mon Sep 21 07:40:34 2015 +0300 @@ -5,6 +5,7 @@ @interface ViewController () { EAGLContext *ctx; + float pixel_scale; ADBannerView *ad; BOOL ad_visible; @@ -25,6 +26,7 @@ { [super viewDidLoad]; + self->ctx = [[EAGLContext alloc] initWithAPI: kEAGLRenderingAPIOpenGLES2]; if(!self->ctx) { NSLog(@"Failed to create OpenGL ES 2.0 context"); @@ -34,6 +36,14 @@ view.context = self->ctx; view.drawableDepthFormat = GLKViewDrawableDepthFormat24; + if([view respondsToSelector: NSSelectorFromString(@"contentScaleFactor")]) { + pixel_scale = [[UIScreen mainScreen] scale]; + view.contentScaleFactor = pixel_scale; + printf("pixel scale: %g\n", pixel_scale); + } else { + pixel_scale = 1.0f; + } + [self create_ad]; [self init_gl]; @@ -124,7 +134,10 @@ - (void)viewDidLayoutSubviews { CGRect rect = self.view.frame; - reshape(rect.size.width, rect.size.height); + int xsz = rect.size.width * pixel_scale; + int ysz = rect.size.height * pixel_scale; + reshape(xsz, ysz); + printf("viewport %dx%d (scale: %g)\n", xsz, ysz, pixel_scale); } // ADBannerDelegate functions