From e134ba553deaf34d413b73b410a908faff8cc8d5 Mon Sep 17 00:00:00 2001 From: omigamedev Date: Wed, 9 Aug 2017 09:59:39 +0100 Subject: [PATCH] implement frame buffer fetch extension for iOS, change composition on stroke drawing and commit, add rename layer dialog --- PanoPainter-OSX/main.cpp | 35 +++++---- PanoPainter/AppDelegate.m | 3 + data/layout.xml | 41 +++++++++- engine.xcodeproj/project.pbxproj | 12 ++- engine/app.h | 1 + engine/app_layout.cpp | 33 +++++++- engine/app_shaders.cpp | 113 +++++++++++++++++++++++++-- engine/canvas.cpp | 117 ++++++++++++++++++---------- engine/canvas.h | 4 +- engine/canvas_modes.cpp | 8 +- engine/node_canvas.cpp | 62 +++++++++++---- engine/node_dialog_layer_rename.cpp | 47 +++++++++++ engine/node_dialog_layer_rename.h | 19 +++++ engine/shader.h | 12 ++- 14 files changed, 415 insertions(+), 92 deletions(-) create mode 100644 engine/node_dialog_layer_rename.cpp create mode 100644 engine/node_dialog_layer_rename.h diff --git a/PanoPainter-OSX/main.cpp b/PanoPainter-OSX/main.cpp index f2bd452..04387bd 100644 --- a/PanoPainter-OSX/main.cpp +++ b/PanoPainter-OSX/main.cpp @@ -14,11 +14,15 @@ @interface View : NSOpenGLView { CVDisplayLinkRef dl; + NSOpenGLContext* glctx; + _CGLContextObject* cgl; + bool gl_ready; } - (void)terminateGL; @end @implementation View - (instancetype)initWithFrame:(NSRect)frameRect { + gl_ready = false; NSOpenGLPixelFormatAttribute attrs[] = { NSOpenGLPFADoubleBuffer, @@ -57,14 +61,18 @@ CGLPixelFormatObj cglPixelFormat = [[self pixelFormat] CGLPixelFormatObj]; CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext(dl, cglContext, cglPixelFormat); + CGLEnable([self.openGLContext CGLContextObj], kCGLCECrashOnRemovedFunctions); + // Activate the display link CVDisplayLinkStart(dl); - - CGLEnable([self.openGLContext CGLContextObj], kCGLCECrashOnRemovedFunctions); + + cgl = [[self openGLContext] CGLContextObj]; + glctx = [self openGLContext]; CGLLockContext([[self openGLContext] CGLContextObj]); App::I.init(); CGLUnlockContext([[self openGLContext] CGLContextObj]); + gl_ready = true; } - (void)terminateGL @@ -90,24 +98,23 @@ static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTime double now = hostTime / _timeFreq; // this will not update unless 1/30th of a second has passed since the last update - if ( now < _prevTime + (1.0 / 30.0) ) + if ( now < _prevTime + (1.0 / 30.0) && App::I.redraw ) { - // Add your drawing codes here - [[self openGLContext] makeCurrentContext]; - // We draw on a secondary thread through the display link // When resizing the view, -reshape is called automatically on the main // thread. Add a mutex around to avoid the threads accessing the context // simultaneously when resizing - CGLLockContext([[self openGLContext] CGLContextObj]); + [glctx makeCurrentContext]; + CGLLockContext([glctx CGLContextObj]); + App::I.clear(); App::I.update(now - _prevTime); //[[self openGLContext] flushBuffer]; // returning NO will cause the layer to NOT be redrawn - CGLFlushDrawable([[self openGLContext] CGLContextObj]); - CGLUnlockContext([[self openGLContext] CGLContextObj]); + CGLFlushDrawable([glctx CGLContextObj]); + CGLUnlockContext([glctx CGLContextObj]); return NO; } else @@ -130,21 +137,21 @@ static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTime - (void)drawRect:(NSRect)dirtyRect { NSLog(@"drawRect"); - // Add your drawing codes here - [[self openGLContext] makeCurrentContext]; // We draw on a secondary thread through the display link // When resizing the view, -reshape is called automatically on the main // thread. Add a mutex around to avoid the threads accessing the context // simultaneously when resizing - CGLLockContext([[self openGLContext] CGLContextObj]); + [glctx makeCurrentContext]; + CGLLockContext(cgl); + App::I.update(0); //[[self openGLContext] flushBuffer]; // returning NO will cause the layer to NOT be redrawn - CGLFlushDrawable([[self openGLContext] CGLContextObj]); - CGLUnlockContext([[self openGLContext] CGLContextObj]); + CGLFlushDrawable(cgl); + CGLUnlockContext(cgl); } - (void)reshape diff --git a/PanoPainter/AppDelegate.m b/PanoPainter/AppDelegate.m index 63752ef..58061ca 100644 --- a/PanoPainter/AppDelegate.m +++ b/PanoPainter/AppDelegate.m @@ -7,6 +7,7 @@ // #import "AppDelegate.h" +#include "app.h" @interface AppDelegate () @@ -32,10 +33,12 @@ - (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. + App::I.redraw = true; } - (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. + App::I.redraw = true; } - (void)applicationWillTerminate:(UIApplication *)application { diff --git a/data/layout.xml b/data/layout.xml index e36854d..649be86 100644 --- a/data/layout.xml +++ b/data/layout.xml @@ -165,6 +165,34 @@ + + + + + + + + + + + + + +