add file picking for osx and ios and implement equirectangular import
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <GLKit/GLKit.h>
|
||||
|
||||
@interface GameViewController : GLKViewController <UIKeyInput>
|
||||
@interface GameViewController : GLKViewController <UIKeyInput,UIImagePickerControllerDelegate,UINavigationControllerDelegate>
|
||||
{
|
||||
@public GLKView* glview;
|
||||
}
|
||||
@@ -17,5 +17,7 @@
|
||||
- (void)async_lock;
|
||||
- (void)async_unlock;
|
||||
- (void)async_swap;
|
||||
|
||||
- (void)pick_photo:(std::function<void(std::string)>) callback;
|
||||
- (void)registerForKeyboardNotifications;
|
||||
- (void)unregisterForKeyboardNotifications;
|
||||
@end
|
||||
|
||||
@@ -11,6 +11,15 @@
|
||||
#import <OpenGLES/ES3/glext.h>
|
||||
#include "app.h"
|
||||
|
||||
@interface GameImagePicker : UIImagePickerController
|
||||
{
|
||||
@public std::promise<std::string> promise;
|
||||
@public std::function<void(std::string)> callback;
|
||||
}
|
||||
@end
|
||||
@implementation GameImagePicker
|
||||
@end
|
||||
|
||||
@interface GameViewController () {
|
||||
NSLock* gl_lock;
|
||||
}
|
||||
@@ -48,6 +57,33 @@ NSThread* lock_thread;
|
||||
[self.context presentRenderbuffer:GL_RENDERBUFFER];
|
||||
}
|
||||
|
||||
- (void)pick_photo:(std::function<void(std::string)>) callback
|
||||
{
|
||||
GameImagePicker *picker = [[GameImagePicker alloc] init];
|
||||
picker.delegate = self;
|
||||
picker.allowsEditing = NO;
|
||||
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
|
||||
picker->callback = callback;
|
||||
[self presentViewController:picker animated:YES completion:NULL];
|
||||
}
|
||||
|
||||
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
|
||||
{
|
||||
NSString *chosenImage = [info[UIImagePickerControllerImageURL] path];
|
||||
GameImagePicker* p = static_cast<GameImagePicker*>(picker);
|
||||
std::string path = [chosenImage cStringUsingEncoding:NSUTF8StringEncoding];
|
||||
p->callback(path);
|
||||
[picker dismissViewControllerAnimated:YES completion:^{
|
||||
[self keyboardWillBeHidden:nil];
|
||||
}];
|
||||
}
|
||||
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
|
||||
{
|
||||
[picker dismissViewControllerAnimated:YES completion:^{
|
||||
[self keyboardWillBeHidden:nil];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)insertText:(NSString *)text
|
||||
{
|
||||
if (const char* cstr = [text cStringUsingEncoding:NSASCIIStringEncoding])
|
||||
@@ -84,6 +120,18 @@ NSThread* lock_thread;
|
||||
selector:@selector(keyboardWasHidden:)
|
||||
name:UIKeyboardDidHideNotification object:nil];
|
||||
}
|
||||
- (void)unregisterForKeyboardNotifications
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self
|
||||
name:UIKeyboardWillShowNotification object:nil];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self
|
||||
name:UIKeyboardWillHideNotification object:nil];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self
|
||||
name:UIKeyboardDidShowNotification object:nil];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self
|
||||
name:UIKeyboardDidHideNotification object:nil];
|
||||
}
|
||||
|
||||
- (void)keyboardWillBeShown:(NSNotification*)aNotification
|
||||
{
|
||||
@@ -94,6 +142,7 @@ NSThread* lock_thread;
|
||||
{
|
||||
App::I.redraw = true;
|
||||
App::I.animate = false;
|
||||
[self unregisterForKeyboardNotifications];
|
||||
}
|
||||
|
||||
// Called when the UIKeyboardDidShowNotification is sent.
|
||||
@@ -233,7 +282,7 @@ NSThread* lock_thread;
|
||||
{
|
||||
App::I.redraw = true;
|
||||
[self resignFirstResponder];
|
||||
[self registerForKeyboardNotifications];
|
||||
//[self registerForKeyboardNotifications];
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
|
||||
Reference in New Issue
Block a user