move dirs init for iOS and OSX
This commit is contained in:
@@ -24,12 +24,6 @@ std::condition_variable render_cv;
|
||||
@implementation GameImagePicker
|
||||
@end
|
||||
|
||||
@interface GameViewController () {
|
||||
NSLock* gl_lock;
|
||||
}
|
||||
@property (strong, nonatomic) EAGLContext *context;
|
||||
@end
|
||||
|
||||
//std::map<
|
||||
bool pen_down = false;
|
||||
int t_count = 0;
|
||||
@@ -59,25 +53,18 @@ std::recursive_mutex lock_mutex;
|
||||
- (void)async_lock
|
||||
{
|
||||
lock_mutex.lock();
|
||||
// if (lock_thread != [NSThread currentThread] || lock_count == 0)
|
||||
// [gl_lock lock];
|
||||
// lock_thread = [NSThread currentThread];
|
||||
// lock_count++;
|
||||
[EAGLContext setCurrentContext:self.context];
|
||||
[EAGLContext setCurrentContext:context];
|
||||
GameView* view = (GameView*)self.view;
|
||||
[view bindDrawable];
|
||||
}
|
||||
- (void)async_unlock
|
||||
{
|
||||
// lock_count--;
|
||||
// if (lock_count == 0)
|
||||
// [gl_lock unlock];
|
||||
lock_mutex.unlock();
|
||||
}
|
||||
- (void)async_swap
|
||||
{
|
||||
[self.context presentRenderbuffer:GL_FRAMEBUFFER];
|
||||
[self->glview display];
|
||||
[context presentRenderbuffer:GL_FRAMEBUFFER];
|
||||
[glview display];
|
||||
}
|
||||
|
||||
- (void)share_file:(NSString *)file_path
|
||||
@@ -109,6 +96,44 @@ std::recursive_mutex lock_mutex;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)init_dirs
|
||||
{
|
||||
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
||||
NSString* docpath = (NSString*)[paths objectAtIndex:0];
|
||||
App::I->data_path = [docpath cStringUsingEncoding:NSASCIIStringEncoding];
|
||||
|
||||
NSError* err = nil;
|
||||
|
||||
NSString* recpath = [docpath stringByAppendingString:@"/rec"];
|
||||
App::I->rec_path = [recpath cStringUsingEncoding:NSASCIIStringEncoding];
|
||||
if (![[NSFileManager defaultManager] createDirectoryAtPath:recpath withIntermediateDirectories:YES attributes:nil error:&err])
|
||||
{
|
||||
LOG("error creating rec path: %s", [[err localizedDescription] cStringUsingEncoding:NSASCIIStringEncoding]);
|
||||
}
|
||||
// brushes
|
||||
if (![[NSFileManager defaultManager] createDirectoryAtPath:[docpath stringByAppendingString:@"/brushes"] withIntermediateDirectories:YES attributes:nil error:&err])
|
||||
{
|
||||
LOG("error creating brushes path: %s", [[err localizedDescription] cStringUsingEncoding:NSASCIIStringEncoding]);
|
||||
}
|
||||
if (![[NSFileManager defaultManager] createDirectoryAtPath:[docpath stringByAppendingString:@"/brushes/thumbs"] withIntermediateDirectories:YES attributes:nil error:&err])
|
||||
{
|
||||
LOG("error creating brushes thumbs path: %s", [[err localizedDescription] cStringUsingEncoding:NSASCIIStringEncoding]);
|
||||
}
|
||||
// patterns
|
||||
if (![[NSFileManager defaultManager] createDirectoryAtPath:[docpath stringByAppendingString:@"/patterns"] withIntermediateDirectories:YES attributes:nil error:&err])
|
||||
{
|
||||
LOG("error creating patterns path: %s", [[err localizedDescription] cStringUsingEncoding:NSASCIIStringEncoding]);
|
||||
}
|
||||
if (![[NSFileManager defaultManager] createDirectoryAtPath:[docpath stringByAppendingString:@"/patterns/thumbs"] withIntermediateDirectories:YES attributes:nil error:&err])
|
||||
{
|
||||
LOG("error creating patterns thumbs path: %s", [[err localizedDescription] cStringUsingEncoding:NSASCIIStringEncoding]);
|
||||
}
|
||||
// settings
|
||||
if (![[NSFileManager defaultManager] createDirectoryAtPath:[docpath stringByAppendingString:@"/settings"] withIntermediateDirectories:YES attributes:nil error:&err])
|
||||
{
|
||||
LOG("error creating settings path: %s", [[err localizedDescription] cStringUsingEncoding:NSASCIIStringEncoding]);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)pick_photo:(std::function<void(std::string)>) callback
|
||||
{
|
||||
@@ -393,20 +418,18 @@ std::set<UITouch*> ignored_touch;
|
||||
{
|
||||
[super viewDidLoad];
|
||||
App::I = new App;
|
||||
App::I->initLog();
|
||||
App::I->ios_view = self;
|
||||
App::I->initLog();
|
||||
|
||||
//self.preferredFramesPerSecond = 60;
|
||||
self.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];
|
||||
context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];
|
||||
|
||||
if (!self.context) {
|
||||
if (!context) {
|
||||
NSLog(@"Failed to create ES context");
|
||||
}
|
||||
|
||||
gl_lock = [[NSLock alloc] init];
|
||||
|
||||
GameView *view = (GameView *)self.view;
|
||||
view.context = self.context;
|
||||
view.context = context;
|
||||
view.drawableDepthFormat = GLKViewDrawableDepthFormat24;
|
||||
view.enableSetNeedsDisplay = NO;
|
||||
glview = view;
|
||||
|
||||
Reference in New Issue
Block a user