From 674e38d8cba311867ce6d9bef46b4e97da68d201 Mon Sep 17 00:00:00 2001 From: omigamedev Date: Sat, 24 Mar 2018 16:57:48 +0100 Subject: [PATCH] add timelapse video generation on iOS and mac , fix history memory --- PanoPainter-OSX/main.cpp | 4 +- PanoPainter/GameViewController.m | 7 +- data/layout.xml | 24 +++ engine.xcodeproj/project.pbxproj | 40 ++-- engine/app.cpp | 308 +++++++++++++++++++++++++++++++ engine/app.h | 19 +- engine/app_layout.cpp | 46 +++++ engine/canvas.h | 10 +- engine/node.cpp | 2 + engine/node_button_custom.cpp | 2 +- engine/pch.h | 10 +- 11 files changed, 449 insertions(+), 23 deletions(-) diff --git a/PanoPainter-OSX/main.cpp b/PanoPainter-OSX/main.cpp index 6c85f52..3528840 100644 --- a/PanoPainter-OSX/main.cpp +++ b/PanoPainter-OSX/main.cpp @@ -141,6 +141,7 @@ static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTime App::I.clear(); App::I.update(now - _prevTime); CGLFlushDrawable([glctx CGLContextObj]); + _prevTime = now; } //[[self openGLContext] flushBuffer]; @@ -156,7 +157,7 @@ static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTime // return YES to have your layer redrawn return YES; } - + return kCVReturnSuccess; } @@ -328,6 +329,7 @@ static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTime @end @implementation Controller - (void)windowWillClose:(NSNotification *)notification { + App::I.terminate(); [[NSApplication sharedApplication] terminate:nil]; } @end diff --git a/PanoPainter/GameViewController.m b/PanoPainter/GameViewController.m index db717cd..b03c157 100644 --- a/PanoPainter/GameViewController.m +++ b/PanoPainter/GameViewController.m @@ -374,6 +374,10 @@ NSThread* lock_thread; - (void)glkView:(GLKView *)view drawInRect:(CGRect)rect { + static auto time = std::chrono::steady_clock::now(); + auto now = std::chrono::steady_clock::now(); + auto dt = std::chrono::duration(now - time); + [gl_lock lock]; if (!(App::I.redraw || App::I.animate)) { @@ -384,9 +388,10 @@ NSThread* lock_thread; [EAGLContext setCurrentContext:self.context]; [view bindDrawable]; App::I.clear(); - App::I.update(0); + App::I.update(dt.count()); [self.context presentRenderbuffer:GL_FRAMEBUFFER]; [gl_lock unlock]; + time = now; } @end diff --git a/data/layout.xml b/data/layout.xml index 906eef0..c79d017 100644 --- a/data/layout.xml +++ b/data/layout.xml @@ -614,6 +614,24 @@ + + + + + + + + + + + + + + + + + + @@ -636,6 +654,7 @@ --> + @@ -662,6 +681,9 @@ + + + @@ -725,6 +747,7 @@ +