From d1ce547abd87a7196346ce48ca89815b3d3c047a Mon Sep 17 00:00:00 2001 From: omigamedev Date: Sun, 7 May 2017 23:49:46 +0100 Subject: [PATCH] add iOS support --- PanoPainter/AppDelegate.h | 17 ++ PanoPainter/AppDelegate.m | 45 ++++ .../AppIcon.appiconset/Contents.json | 73 ++++++ .../Base.lproj/LaunchScreen.storyboard | 27 ++ PanoPainter/Base.lproj/Main.storyboard | 26 ++ PanoPainter/GameViewController.h | 14 + PanoPainter/GameViewController.m | 119 +++++++++ PanoPainter/Info.plist | 49 ++++ PanoPainter/main.m | 16 ++ engine.xcodeproj/project.pbxproj | 242 +++++++++++++++++- .../xcschemes/xcschememanagement.plist | 5 + engine/app.cpp | 18 +- engine/asset.cpp | 17 +- engine/layout.cpp | 6 +- engine/main.cpp | 4 +- engine/pch.h | 24 +- 16 files changed, 682 insertions(+), 20 deletions(-) create mode 100644 PanoPainter/AppDelegate.h create mode 100644 PanoPainter/AppDelegate.m create mode 100644 PanoPainter/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 PanoPainter/Base.lproj/LaunchScreen.storyboard create mode 100644 PanoPainter/Base.lproj/Main.storyboard create mode 100644 PanoPainter/GameViewController.h create mode 100644 PanoPainter/GameViewController.m create mode 100644 PanoPainter/Info.plist create mode 100644 PanoPainter/main.m diff --git a/PanoPainter/AppDelegate.h b/PanoPainter/AppDelegate.h new file mode 100644 index 0000000..53a5a4a --- /dev/null +++ b/PanoPainter/AppDelegate.h @@ -0,0 +1,17 @@ +// +// AppDelegate.h +// PanoPainter +// +// Created by Omar Mohamed Ali Mudhir on 07/05/17. +// Copyright © 2017 Omar Mohamed Ali Mudhir. All rights reserved. +// + +#import + +@interface AppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + + +@end + diff --git a/PanoPainter/AppDelegate.m b/PanoPainter/AppDelegate.m new file mode 100644 index 0000000..63752ef --- /dev/null +++ b/PanoPainter/AppDelegate.m @@ -0,0 +1,45 @@ +// +// AppDelegate.m +// PanoPainter +// +// Created by Omar Mohamed Ali Mudhir on 07/05/17. +// Copyright © 2017 Omar Mohamed Ali Mudhir. All rights reserved. +// + +#import "AppDelegate.h" + +@interface AppDelegate () + +@end + +@implementation AppDelegate + + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + // Override point for customization after application launch. + return YES; +} + +- (void)applicationWillResignActive:(UIApplication *)application { + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. +} + +- (void)applicationDidEnterBackground:(UIApplication *)application { + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. +} + +- (void)applicationWillEnterForeground:(UIApplication *)application { + // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. +} + +- (void)applicationDidBecomeActive:(UIApplication *)application { + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. +} + +- (void)applicationWillTerminate:(UIApplication *)application { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. +} + +@end diff --git a/PanoPainter/Assets.xcassets/AppIcon.appiconset/Contents.json b/PanoPainter/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..eeea76c --- /dev/null +++ b/PanoPainter/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,73 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "83.5x83.5", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/PanoPainter/Base.lproj/LaunchScreen.storyboard b/PanoPainter/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..78686cd --- /dev/null +++ b/PanoPainter/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PanoPainter/Base.lproj/Main.storyboard b/PanoPainter/Base.lproj/Main.storyboard new file mode 100644 index 0000000..2fd7b8e --- /dev/null +++ b/PanoPainter/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PanoPainter/GameViewController.h b/PanoPainter/GameViewController.h new file mode 100644 index 0000000..2547401 --- /dev/null +++ b/PanoPainter/GameViewController.h @@ -0,0 +1,14 @@ +// +// GameViewController.h +// PanoPainter +// +// Created by Omar Mohamed Ali Mudhir on 07/05/17. +// Copyright © 2017 Omar Mohamed Ali Mudhir. All rights reserved. +// + +#import +#import + +@interface GameViewController : GLKViewController + +@end diff --git a/PanoPainter/GameViewController.m b/PanoPainter/GameViewController.m new file mode 100644 index 0000000..9a6d8d5 --- /dev/null +++ b/PanoPainter/GameViewController.m @@ -0,0 +1,119 @@ +// +// GameViewController.m +// PanoPainter +// +// Created by Omar Mohamed Ali Mudhir on 07/05/17. +// Copyright © 2017 Omar Mohamed Ali Mudhir. All rights reserved. +// + +#include "pch.h" +#import "GameViewController.h" +#import +#include "app.h" + +@interface GameViewController () { +} +@property (strong, nonatomic) EAGLContext *context; + +- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)coordinator; +- (void)setupGL; +- (void)tearDownGL; +//- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event; +- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event; +@end + +@implementation GameViewController + +- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event +{ + UITouch *touch = [[event allTouches] anyObject]; + CGPoint touchLocation = [touch locationInView:self.view]; + float scale = self.view.contentScaleFactor; + App::I.mouse_move(touchLocation.x * scale, touchLocation.y * scale); +} + +- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)coordinator +{ + App::I.resize(size.width * self.view.contentScaleFactor, + size.height * self.view.contentScaleFactor); +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + App::I.initLog(); + + + self.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3]; + + if (!self.context) { + NSLog(@"Failed to create ES context"); + } + + GLKView *view = (GLKView *)self.view; + view.context = self.context; + view.drawableDepthFormat = GLKViewDrawableDepthFormat24; + + App::I.width = view.frame.size.width * view.contentScaleFactor; + App::I.height = view.frame.size.height * view.contentScaleFactor; + + [self setupGL]; +} + +- (void)dealloc +{ + [self tearDownGL]; + + if ([EAGLContext currentContext] == self.context) { + [EAGLContext setCurrentContext:nil]; + } +} + +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; + + if ([self isViewLoaded] && ([[self view] window] == nil)) { + self.view = nil; + + [self tearDownGL]; + + if ([EAGLContext currentContext] == self.context) { + [EAGLContext setCurrentContext:nil]; + } + self.context = nil; + } + + // Dispose of any resources that can be recreated. +} + +- (BOOL)prefersStatusBarHidden { + return YES; +} + +- (void)setupGL +{ + [EAGLContext setCurrentContext:self.context]; + App::I.init(); +} + +- (void)tearDownGL +{ + [EAGLContext setCurrentContext:self.context]; + +} + +#pragma mark - GLKView and GLKViewController delegate methods + +- (void)update +{ + +} + +- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect +{ + App::I.clear(); + App::I.update(0); +} + +@end diff --git a/PanoPainter/Info.plist b/PanoPainter/Info.plist new file mode 100644 index 0000000..44468d2 --- /dev/null +++ b/PanoPainter/Info.plist @@ -0,0 +1,49 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UIStatusBarHidden + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/PanoPainter/main.m b/PanoPainter/main.m new file mode 100644 index 0000000..c9d05c6 --- /dev/null +++ b/PanoPainter/main.m @@ -0,0 +1,16 @@ +// +// main.m +// PanoPainter +// +// Created by Omar Mohamed Ali Mudhir on 07/05/17. +// Copyright © 2017 Omar Mohamed Ali Mudhir. All rights reserved. +// + +#import +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} diff --git a/engine.xcodeproj/project.pbxproj b/engine.xcodeproj/project.pbxproj index 1a0b28e..48a53ee 100644 --- a/engine.xcodeproj/project.pbxproj +++ b/engine.xcodeproj/project.pbxproj @@ -14,6 +14,7 @@ AD4C08DB1E89BD0F0051D85F /* brush.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD4C08D31E89BD0F0051D85F /* brush.cpp */; }; AD4C08DC1E89BD0F0051D85F /* canvas.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD4C08D51E89BD0F0051D85F /* canvas.cpp */; }; AD4C08DD1E89BD0F0051D85F /* rtt.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD4C08D71E89BD0F0051D85F /* rtt.cpp */; }; + AD5016591EBFC7F00079A826 /* data in Resources */ = {isa = PBXBuildFile; fileRef = AD58E0611E17F23D006ACC15 /* data */; }; AD58E0531E107411006ACC15 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD58E0521E107411006ACC15 /* main.cpp */; }; AD58E05A1E10752E006ACC15 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD58E0591E10752E006ACC15 /* OpenGL.framework */; }; AD58E05C1E107536006ACC15 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD58E05B1E107536006ACC15 /* Cocoa.framework */; }; @@ -35,6 +36,42 @@ AD95AEC71E41EDEC002DD03A /* pch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD95AEC51E41EDEC002DD03A /* pch.cpp */; }; ADB1C3DA1EA3A156009A65BD /* event.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ADB1C3D81EA3A156009A65BD /* event.cpp */; }; ADB61C821E3D38450093280F /* util.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ADB61C801E3D38450093280F /* util.cpp */; }; + ADD7D26F1EBF9AE300D5A897 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = ADD7D26E1EBF9AE300D5A897 /* main.m */; }; + ADD7D2721EBF9AE300D5A897 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = ADD7D2711EBF9AE300D5A897 /* AppDelegate.m */; }; + ADD7D2791EBF9AE300D5A897 /* GameViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = ADD7D2781EBF9AE300D5A897 /* GameViewController.m */; }; + ADD7D27C1EBF9AE300D5A897 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = ADD7D27A1EBF9AE300D5A897 /* Main.storyboard */; }; + ADD7D27E1EBF9AE300D5A897 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = ADD7D27D1EBF9AE300D5A897 /* Assets.xcassets */; }; + ADD7D2811EBF9AE300D5A897 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = ADD7D27F1EBF9AE300D5A897 /* LaunchScreen.storyboard */; }; + ADD7D2871EBF9C6700D5A897 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ADD7D2861EBF9C6700D5A897 /* Foundation.framework */; }; + ADD7D2891EBF9D2A00D5A897 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ADD7D2881EBF9D2A00D5A897 /* OpenGLES.framework */; }; + ADD7D28B1EBF9D5D00D5A897 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ADD7D28A1EBF9D5D00D5A897 /* UIKit.framework */; }; + ADD7D28D1EBF9D6F00D5A897 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ADD7D28C1EBF9D6F00D5A897 /* CoreFoundation.framework */; }; + ADD7D28F1EBF9D8C00D5A897 /* GLKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ADD7D28E1EBF9D8C00D5A897 /* GLKit.framework */; }; + ADD7D2901EBF9E1C00D5A897 /* canvas_modes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD744B6C1EBC9EF700B66E30 /* canvas_modes.cpp */; }; + ADD7D2911EBF9E1C00D5A897 /* event.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ADB1C3D81EA3A156009A65BD /* event.cpp */; }; + ADD7D2921EBF9E1C00D5A897 /* action.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD29CC601EA2B214008C8BFA /* action.cpp */; }; + ADD7D2931EBF9E1C00D5A897 /* log.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD8CF71F1E913F0500083FFD /* log.cpp */; }; + ADD7D2941EBF9E1C00D5A897 /* asset.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD4C08CF1E89BD0F0051D85F /* asset.cpp */; }; + ADD7D2951EBF9E1C00D5A897 /* bezier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD4C08D11E89BD0F0051D85F /* bezier.cpp */; }; + ADD7D2961EBF9E1C00D5A897 /* brush.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD4C08D31E89BD0F0051D85F /* brush.cpp */; }; + ADD7D2971EBF9E1C00D5A897 /* canvas.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD4C08D51E89BD0F0051D85F /* canvas.cpp */; }; + ADD7D2981EBF9E1C00D5A897 /* rtt.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD4C08D71E89BD0F0051D85F /* rtt.cpp */; }; + ADD7D2991EBF9E1C00D5A897 /* font.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD95AEC31E41EDEC002DD03A /* font.cpp */; }; + ADD7D29A1EBF9E1C00D5A897 /* pch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD95AEC51E41EDEC002DD03A /* pch.cpp */; }; + ADD7D29B1EBF9E1C00D5A897 /* layout.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD3B1EBE1E3B8B7600E918E3 /* layout.cpp */; }; + ADD7D29C1EBF9E1C00D5A897 /* shader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD58E0631E2A76FD006ACC15 /* shader.cpp */; }; + ADD7D29D1EBF9E1C00D5A897 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD58E0521E107411006ACC15 /* main.cpp */; }; + ADD7D29E1EBF9E1C00D5A897 /* shape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD58E06D1E2A80BC006ACC15 /* shape.cpp */; }; + ADD7D29F1EBF9E1C00D5A897 /* app.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD58E0701E2A90EF006ACC15 /* app.cpp */; }; + ADD7D2A01EBF9E1C00D5A897 /* image.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD58E0661E2A7741006ACC15 /* image.cpp */; }; + ADD7D2A11EBF9E1C00D5A897 /* texture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD58E0691E2A774F006ACC15 /* texture.cpp */; }; + ADD7D2A21EBF9E1C00D5A897 /* util.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ADB61C801E3D38450093280F /* util.cpp */; }; + ADD7D2A31EBFA06F00D5A897 /* tinyxml2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD58E0781E342205006ACC15 /* tinyxml2.cpp */; }; + ADD7D2A41EBFA06F00D5A897 /* YGNodeList.c in Sources */ = {isa = PBXBuildFile; fileRef = AD58E0741E3421F2006ACC15 /* YGNodeList.c */; }; + ADD7D2A51EBFA06F00D5A897 /* Yoga.c in Sources */ = {isa = PBXBuildFile; fileRef = AD58E0751E3421F2006ACC15 /* Yoga.c */; }; + ADD7D2AF1EBFA35F00D5A897 /* libcurl.a in Frameworks */ = {isa = PBXBuildFile; fileRef = ADD7D2AE1EBFA35F00D5A897 /* libcurl.a */; }; + ADD7D2B11EBFA42600D5A897 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = ADD7D2B01EBFA42600D5A897 /* libz.tbd */; }; + ADD7D2B31EBFA42C00D5A897 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ADD7D2B21EBFA42C00D5A897 /* Security.framework */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -55,7 +92,7 @@ AD29CC611EA2B214008C8BFA /* action.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = action.h; sourceTree = ""; }; AD3B1EBE1E3B8B7600E918E3 /* layout.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = layout.cpp; sourceTree = ""; }; AD3B1EBF1E3B8B7600E918E3 /* layout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = layout.h; sourceTree = ""; }; - AD4C08CF1E89BD0F0051D85F /* asset.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = asset.cpp; sourceTree = ""; }; + AD4C08CF1E89BD0F0051D85F /* asset.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; path = asset.cpp; sourceTree = ""; }; AD4C08D01E89BD0F0051D85F /* asset.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = asset.h; sourceTree = ""; }; AD4C08D11E89BD0F0051D85F /* bezier.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = bezier.cpp; sourceTree = ""; }; AD4C08D21E89BD0F0051D85F /* bezier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bezier.h; sourceTree = ""; }; @@ -99,6 +136,24 @@ ADB1C3DB1EA531B0009A65BD /* keymap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = keymap.h; sourceTree = ""; }; ADB61C801E3D38450093280F /* util.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = util.cpp; sourceTree = ""; }; ADB61C811E3D38450093280F /* util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = util.h; sourceTree = ""; }; + ADD7D26B1EBF9AE300D5A897 /* PanoPainter.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PanoPainter.app; sourceTree = BUILT_PRODUCTS_DIR; }; + ADD7D26E1EBF9AE300D5A897 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + ADD7D2701EBF9AE300D5A897 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + ADD7D2711EBF9AE300D5A897 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + ADD7D2771EBF9AE300D5A897 /* GameViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GameViewController.h; sourceTree = ""; }; + ADD7D2781EBF9AE300D5A897 /* GameViewController.m */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; path = GameViewController.m; sourceTree = ""; }; + ADD7D27B1EBF9AE300D5A897 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + ADD7D27D1EBF9AE300D5A897 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + ADD7D2801EBF9AE300D5A897 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + ADD7D2821EBF9AE300D5A897 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + ADD7D2861EBF9C6700D5A897 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; }; + ADD7D2881EBF9D2A00D5A897 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk/System/Library/Frameworks/OpenGLES.framework; sourceTree = DEVELOPER_DIR; }; + ADD7D28A1EBF9D5D00D5A897 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; }; + ADD7D28C1EBF9D6F00D5A897 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk/System/Library/Frameworks/CoreFoundation.framework; sourceTree = DEVELOPER_DIR; }; + ADD7D28E1EBF9D8C00D5A897 /* GLKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GLKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk/System/Library/Frameworks/GLKit.framework; sourceTree = DEVELOPER_DIR; }; + ADD7D2AE1EBFA35F00D5A897 /* libcurl.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libcurl.a; path = "../../Downloads/curl-android-ios-master/prebuilt-with-ssl/iOS/x86_64/libcurl.a"; sourceTree = ""; }; + ADD7D2B01EBFA42600D5A897 /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk/usr/lib/libz.tbd; sourceTree = DEVELOPER_DIR; }; + ADD7D2B21EBFA42C00D5A897 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk/System/Library/Frameworks/Security.framework; sourceTree = DEVELOPER_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -114,13 +169,36 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + ADD7D2681EBF9AE300D5A897 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ADD7D2B31EBFA42C00D5A897 /* Security.framework in Frameworks */, + ADD7D2B11EBFA42600D5A897 /* libz.tbd in Frameworks */, + ADD7D28F1EBF9D8C00D5A897 /* GLKit.framework in Frameworks */, + ADD7D28D1EBF9D6F00D5A897 /* CoreFoundation.framework in Frameworks */, + ADD7D28B1EBF9D5D00D5A897 /* UIKit.framework in Frameworks */, + ADD7D2891EBF9D2A00D5A897 /* OpenGLES.framework in Frameworks */, + ADD7D2871EBF9C6700D5A897 /* Foundation.framework in Frameworks */, + ADD7D2AF1EBFA35F00D5A897 /* libcurl.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ AD58E0461E107411006ACC15 = { isa = PBXGroup; children = ( + ADD7D2B21EBFA42C00D5A897 /* Security.framework */, + ADD7D2B01EBFA42600D5A897 /* libz.tbd */, + ADD7D28E1EBF9D8C00D5A897 /* GLKit.framework */, + ADD7D28C1EBF9D6F00D5A897 /* CoreFoundation.framework */, + ADD7D28A1EBF9D5D00D5A897 /* UIKit.framework */, + ADD7D2881EBF9D2A00D5A897 /* OpenGLES.framework */, + ADD7D2861EBF9C6700D5A897 /* Foundation.framework */, AD8CF7221E914DE400083FFD /* libcurl.tbd */, + ADD7D2AE1EBFA35F00D5A897 /* libcurl.a */, AD58E0731E3421CB006ACC15 /* libs */, AD58E0611E17F23D006ACC15 /* data */, AD58E05F1E12DA86006ACC15 /* CoreVideo.framework */, @@ -128,6 +206,7 @@ AD58E05B1E107536006ACC15 /* Cocoa.framework */, AD58E0591E10752E006ACC15 /* OpenGL.framework */, AD58E0511E107411006ACC15 /* engine */, + ADD7D26C1EBF9AE300D5A897 /* PanoPainter */, AD58E0501E107411006ACC15 /* Products */, ); sourceTree = ""; @@ -136,6 +215,7 @@ isa = PBXGroup; children = ( AD58E04F1E107411006ACC15 /* engine */, + ADD7D26B1EBF9AE300D5A897 /* PanoPainter.app */, ); name = Products; sourceTree = ""; @@ -195,6 +275,30 @@ name = libs; sourceTree = ""; }; + ADD7D26C1EBF9AE300D5A897 /* PanoPainter */ = { + isa = PBXGroup; + children = ( + ADD7D2701EBF9AE300D5A897 /* AppDelegate.h */, + ADD7D2711EBF9AE300D5A897 /* AppDelegate.m */, + ADD7D2771EBF9AE300D5A897 /* GameViewController.h */, + ADD7D2781EBF9AE300D5A897 /* GameViewController.m */, + ADD7D27A1EBF9AE300D5A897 /* Main.storyboard */, + ADD7D27D1EBF9AE300D5A897 /* Assets.xcassets */, + ADD7D27F1EBF9AE300D5A897 /* LaunchScreen.storyboard */, + ADD7D2821EBF9AE300D5A897 /* Info.plist */, + ADD7D26D1EBF9AE300D5A897 /* Supporting Files */, + ); + path = PanoPainter; + sourceTree = ""; + }; + ADD7D26D1EBF9AE300D5A897 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + ADD7D26E1EBF9AE300D5A897 /* main.m */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -215,6 +319,23 @@ productReference = AD58E04F1E107411006ACC15 /* engine */; productType = "com.apple.product-type.tool"; }; + ADD7D26A1EBF9AE300D5A897 /* PanoPainter */ = { + isa = PBXNativeTarget; + buildConfigurationList = ADD7D2851EBF9AE300D5A897 /* Build configuration list for PBXNativeTarget "PanoPainter" */; + buildPhases = ( + ADD7D2671EBF9AE300D5A897 /* Sources */, + ADD7D2681EBF9AE300D5A897 /* Frameworks */, + ADD7D2691EBF9AE300D5A897 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = PanoPainter; + productName = PanoPainter; + productReference = ADD7D26B1EBF9AE300D5A897 /* PanoPainter.app */; + productType = "com.apple.product-type.application"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -227,6 +348,9 @@ AD58E04E1E107411006ACC15 = { CreatedOnToolsVersion = 7.2; }; + ADD7D26A1EBF9AE300D5A897 = { + CreatedOnToolsVersion = 7.2; + }; }; }; buildConfigurationList = AD58E04A1E107411006ACC15 /* Build configuration list for PBXProject "engine" */; @@ -235,6 +359,7 @@ hasScannedForEncodings = 0; knownRegions = ( en, + Base, ); mainGroup = AD58E0461E107411006ACC15; productRefGroup = AD58E0501E107411006ACC15 /* Products */; @@ -242,10 +367,25 @@ projectRoot = ""; targets = ( AD58E04E1E107411006ACC15 /* engine */, + ADD7D26A1EBF9AE300D5A897 /* PanoPainter */, ); }; /* End PBXProject section */ +/* Begin PBXResourcesBuildPhase section */ + ADD7D2691EBF9AE300D5A897 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + AD5016591EBFC7F00079A826 /* data in Resources */, + ADD7D27C1EBF9AE300D5A897 /* Main.storyboard in Resources */, + ADD7D27E1EBF9AE300D5A897 /* Assets.xcassets in Resources */, + ADD7D2811EBF9AE300D5A897 /* LaunchScreen.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ AD58E04B1E107411006ACC15 /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -276,8 +416,59 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + ADD7D2671EBF9AE300D5A897 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ADD7D2951EBF9E1C00D5A897 /* bezier.cpp in Sources */, + ADD7D29E1EBF9E1C00D5A897 /* shape.cpp in Sources */, + ADD7D2901EBF9E1C00D5A897 /* canvas_modes.cpp in Sources */, + ADD7D2A31EBFA06F00D5A897 /* tinyxml2.cpp in Sources */, + ADD7D29C1EBF9E1C00D5A897 /* shader.cpp in Sources */, + ADD7D2A51EBFA06F00D5A897 /* Yoga.c in Sources */, + ADD7D2921EBF9E1C00D5A897 /* action.cpp in Sources */, + ADD7D29A1EBF9E1C00D5A897 /* pch.cpp in Sources */, + ADD7D29D1EBF9E1C00D5A897 /* main.cpp in Sources */, + ADD7D29F1EBF9E1C00D5A897 /* app.cpp in Sources */, + ADD7D2941EBF9E1C00D5A897 /* asset.cpp in Sources */, + ADD7D29B1EBF9E1C00D5A897 /* layout.cpp in Sources */, + ADD7D2931EBF9E1C00D5A897 /* log.cpp in Sources */, + ADD7D2971EBF9E1C00D5A897 /* canvas.cpp in Sources */, + ADD7D2991EBF9E1C00D5A897 /* font.cpp in Sources */, + ADD7D2981EBF9E1C00D5A897 /* rtt.cpp in Sources */, + ADD7D2721EBF9AE300D5A897 /* AppDelegate.m in Sources */, + ADD7D2A21EBF9E1C00D5A897 /* util.cpp in Sources */, + ADD7D2791EBF9AE300D5A897 /* GameViewController.m in Sources */, + ADD7D26F1EBF9AE300D5A897 /* main.m in Sources */, + ADD7D2A01EBF9E1C00D5A897 /* image.cpp in Sources */, + ADD7D2A11EBF9E1C00D5A897 /* texture.cpp in Sources */, + ADD7D2961EBF9E1C00D5A897 /* brush.cpp in Sources */, + ADD7D2911EBF9E1C00D5A897 /* event.cpp in Sources */, + ADD7D2A41EBFA06F00D5A897 /* YGNodeList.c in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXSourcesBuildPhase section */ +/* Begin PBXVariantGroup section */ + ADD7D27A1EBF9AE300D5A897 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + ADD7D27B1EBF9AE300D5A897 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + ADD7D27F1EBF9AE300D5A897 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + ADD7D2801EBF9AE300D5A897 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + /* Begin XCBuildConfiguration section */ AD58E0541E107411006ACC15 /* Debug */ = { isa = XCBuildConfiguration; @@ -381,6 +572,7 @@ AD58E0571E107411006ACC15 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + MACH_O_TYPE = mh_execute; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Debug; @@ -388,10 +580,49 @@ AD58E0581E107411006ACC15 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + MACH_O_TYPE = mh_execute; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Release; }; + ADD7D2831EBF9AE300D5A897 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_CXX_LANGUAGE_STANDARD = "c++14"; + CLANG_ENABLE_MODULES = NO; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + INFOPLIST_FILE = PanoPainter/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.2; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LIBRARY_SEARCH_PATHS = "/Users/omimac/Downloads/curl-android-ios-master/prebuilt-with-ssl/iOS"; + PRODUCT_BUNDLE_IDENTIFIER = com.omixlab.PanoPainter; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + ADD7D2841EBF9AE300D5A897 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_CXX_LANGUAGE_STANDARD = "c++14"; + CLANG_ENABLE_MODULES = NO; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + INFOPLIST_FILE = PanoPainter/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.2; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LIBRARY_SEARCH_PATHS = "/Users/omimac/Downloads/curl-android-ios-master/prebuilt-with-ssl/iOS"; + PRODUCT_BUNDLE_IDENTIFIER = com.omixlab.PanoPainter; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -413,6 +644,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + ADD7D2851EBF9AE300D5A897 /* Build configuration list for PBXNativeTarget "PanoPainter" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + ADD7D2831EBF9AE300D5A897 /* Debug */, + ADD7D2841EBF9AE300D5A897 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; /* End XCConfigurationList section */ }; rootObject = AD58E0471E107411006ACC15 /* Project object */; diff --git a/engine.xcodeproj/xcuserdata/omimac.xcuserdatad/xcschemes/xcschememanagement.plist b/engine.xcodeproj/xcuserdata/omimac.xcuserdatad/xcschemes/xcschememanagement.plist index d4e76f9..914f5d1 100644 --- a/engine.xcodeproj/xcuserdata/omimac.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/engine.xcodeproj/xcuserdata/omimac.xcuserdatad/xcschemes/xcschememanagement.plist @@ -17,6 +17,11 @@ primary + ADD7D26A1EBF9AE300D5A897 + + primary + + diff --git a/engine/app.cpp b/engine/app.cpp index 02b4113..c08da73 100644 --- a/engine/app.cpp +++ b/engine/app.cpp @@ -277,10 +277,10 @@ void App::initShaders() "in mediump vec2 uv;\n" "out mediump vec4 frag;\n" "void main(){\n" - " const vec4 c1 = vec4(1.0, 1.0, 1.0, 1.0);\n" - " const vec4 c2 = vec4(0.9, 0.9, 0.9, 1.0);\n" - " vec2 c = floor(fract(uv * 10.0) * 2.0);\n" - " float alpha = mix(c.x, 1.0 - c.x, c.y);\n" + " const mediump vec4 c1 = vec4(1.0, 1.0, 1.0, 1.0);\n" + " const mediump vec4 c2 = vec4(0.9, 0.9, 0.9, 1.0);\n" + " mediump vec2 c = floor(fract(uv * 10.0) * 2.0);\n" + " mediump float alpha = mix(c.x, 1.0 - c.x, c.y);\n" " frag = mix(c1, c2, alpha);\n" "}"; @@ -302,11 +302,11 @@ void App::initShaders() "in mediump vec2 uv;\n" "out mediump vec4 frag;\n" "void main(){\n" - " float anglex = uv.x;\n" - " float angley = uv.y;\n" - " float sx = sin(anglex);\n" - " float cx = cos(anglex);\n" - " vec3 dir = vec3(0.0, 0.0, 0.0);\n" + " mediump float anglex = uv.x;\n" + " mediump float angley = uv.y;\n" + " mediump float sx = sin(anglex);\n" + " mediump float cx = cos(anglex);\n" + " mediump vec3 dir = vec3(0.0, 0.0, 0.0);\n" " dir.x = sin(angley) * cx;\n" " dir.y = cos(angley);\n" " dir.z = sin(angley) * sx;\n" diff --git a/engine/asset.cpp b/engine/asset.cpp index 6004f43..4565b26 100644 --- a/engine/asset.cpp +++ b/engine/asset.cpp @@ -2,14 +2,19 @@ #include "log.h" #include "asset.h" +#ifdef __IOS__ +#include +#endif + #ifdef __ANDROID__ AAssetManager* Asset::m_am; #endif bool Asset::open(const char* path) { - //LOG("Asset::open %s", path); + LOG("Asset::open %s", path); m_current_path = path; + std::string file_path = path; #ifdef __ANDROID__ if (!(m_asset = AAssetManager_open(m_am, path, AASSET_MODE_RANDOM))) { @@ -19,8 +24,16 @@ bool Asset::open(const char* path) m_len = (int)AAsset_getLength(m_asset); m_data = (uint8_t*)AAsset_getBuffer(m_asset); #else - if (!(m_fp = fopen(path, "rb"))) +#ifdef __IOS__ + NSString* bundle_path = [[NSBundle mainBundle] bundlePath]; + std::string base = [bundle_path cStringUsingEncoding:1]; + file_path = base + "/" + path; +#endif + if (!(m_fp = fopen(file_path.c_str(), "rb"))) + { + LOG("errno = %d", errno); return false; + } fseek(m_fp, 0, SEEK_END); m_len = (int)ftell(m_fp); fseek(m_fp, 0, SEEK_SET); diff --git a/engine/layout.cpp b/engine/layout.cpp index 08928c8..64d8ca7 100644 --- a/engine/layout.cpp +++ b/engine/layout.cpp @@ -540,7 +540,8 @@ bool LayoutManager::load(const char* path) if (m_loaded) return true; // already loaded -#ifndef __ANDROID__ +/* +#if !defined(__ANDROID__) struct stat tmp_info; if (stat(path, &tmp_info) != 0) return false; @@ -548,7 +549,8 @@ bool LayoutManager::load(const char* path) return false; m_file_info = tmp_info; #endif // __ANDROID__ - +*/ + m_path = path; auto old = std::move(m_layouts); diff --git a/engine/main.cpp b/engine/main.cpp index 949a9ce..4edecef 100644 --- a/engine/main.cpp +++ b/engine/main.cpp @@ -8,11 +8,12 @@ #include "keymap.h" #ifdef __APPLE__ + +#ifdef TARGET_OS_OSX #include #include #include #include - @interface View : NSOpenGLView { CVDisplayLinkRef dl; @@ -360,6 +361,7 @@ int main(int argc, const char * argv[]) return 0; } #endif +#endif #ifdef _WIN32 diff --git a/engine/pch.h b/engine/pch.h index e8d2cd4..61aaf9c 100644 --- a/engine/pch.h +++ b/engine/pch.h @@ -4,14 +4,28 @@ #define USE_SAMPLER 1 #ifdef __APPLE__ - #include - #include + + #include "TargetConditionals.h" + #if TARGET_OS_IPHONE && TARGET_IPHONE_SIMULATOR + #define TARGET_OS_IOS 1 + #define __IOS__ 1 + #include + #include + #include + #define SHADER_VERSION "#version 300 es\n" + #elif TARGET_OS_IPHONE + // define something for iphone + #else + #define TARGET_OS_OSX 1 + #include + #include + #define SHADER_VERSION "#version 150\n" + #endif + #include #include #include - #define SHADER_VERSION "#version 150\n" - #elif __ANDROID__ #include #include @@ -22,7 +36,7 @@ #include #include -#define SHADER_VERSION "#version 300 es\n" + #define SHADER_VERSION "#version 300 es\n" #elif _WIN32 #define _USE_MATH_DEFINES