From a0b504d11542097843db77653d3e26516a892593 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Mon, 10 Sep 2018 23:24:49 +0100 Subject: lut blend --- gui/addons.make | 2 +- gui/src/chainImage.cpp | 23 +++++-- gui/src/chainImage.h | 20 +++++- gui/src/main.cpp | 4 ++ gui/src/ofApp.cpp | 10 +++ gui/src/ofApp.h | 1 - gui/src/ofxGpuLutBlend.cpp | 127 ++++++++++++++++++++++++++++++++++++++ gui/src/ofxGpuLutBlend.h | 26 ++++++++ gui/src/threadedSystemDialogs.cpp | 29 +++++++++ gui/src/threadedSystemDialogs.h | 20 ++++++ 10 files changed, 252 insertions(+), 10 deletions(-) create mode 100644 gui/src/ofxGpuLutBlend.cpp create mode 100644 gui/src/ofxGpuLutBlend.h create mode 100644 gui/src/threadedSystemDialogs.cpp create mode 100644 gui/src/threadedSystemDialogs.h diff --git a/gui/addons.make b/gui/addons.make index 49ff8bc..f722f82 100644 --- a/gui/addons.make +++ b/gui/addons.make @@ -5,4 +5,4 @@ ofxArtnet ofxThreadedImageLoader ofxSyphon ofxEasing -ofxGpuLut \ No newline at end of file +#ofxGpuLut \ No newline at end of file diff --git a/gui/src/chainImage.cpp b/gui/src/chainImage.cpp index 369ab77..3c6680f 100644 --- a/gui/src/chainImage.cpp +++ b/gui/src/chainImage.cpp @@ -467,15 +467,16 @@ void chainImage::drawChain(float fadeIn,bool additive,float intensity,float zoom glScalef(zoomFactor,zoomFactor,zoomFactor); //ofSetColor(colour); - /* + float gamma=1.0f; //(startGamma*transition)+(1.0f*(1.0f-transition)); float pedestal=0.0f; - float clamp=1.0f-transition; + float clamp=1.0f; //-transition; lut.load(makeLut(gamma,pedestal,clamp)); + lut.setBlend(1.0f); lut.begin(); - */ + //setAlpha(1.0f); draw(0,0,getWidth(),getHeight()); - //lut.end(); + lut.end(); glPopMatrix(); @@ -488,13 +489,25 @@ void chainImage::drawChain(float fadeIn,bool additive,float intensity,float zoom //ofEnableAlphaBlending(); glEnable(GL_BLEND); - ofSetColor(255,255,255,255*min(1.0,transition/fadeIn)*intensity); + //ofSetColor(255,255,255,255*min(1.0,transition/fadeIn)*intensity); + //setting alpha here doesn't work with shader? + //possibly if you could set the alpha when drawing? link->setAnchorPoint(link->getWidth()/2,link->getHeight()/2); + gamma=1.0f; //(startGamma*transition)+(1.0f*(1.0f-transition)); + pedestal=0.0f; + clamp=1.0f; //-transition; + lut.load(makeLut(gamma,pedestal,clamp)); + lut.setBlend(transition); + lut.begin(); + //ofSetColor(link->colour); + //link->setAlpha(transition); link->draw(0,0,link->getWidth(),link->getHeight()); + lut.end(); + glDisable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); diff --git a/gui/src/chainImage.h b/gui/src/chainImage.h index 30ea55a..3763aab 100644 --- a/gui/src/chainImage.h +++ b/gui/src/chainImage.h @@ -3,7 +3,7 @@ #include "ofMain.h" #include "ofxJSON.h" #include "ofxEasing.h" -#include "ofxGpuLut.h" +#include "ofxGpuLutBlend.h" #define min(a,b) ((a) < (b) ? (a) : (b)) #define max(a,b) ((a) > (b) ? (a) : (b)) @@ -47,7 +47,7 @@ class chainImage : public ofImage{ filename=_filename; if (ofImage::load(filename)){ makeThumbnail(); - + //setImageType(OF_IMAGE_COLOR_ALPHA); //could there be a way to load without committing the texture //setUseTexture(false); setAnchorPoint(getWidth()/2,getHeight()/2); @@ -59,6 +59,20 @@ class chainImage : public ofImage{ return false; } + void setAlpha(uint8_t a){ + if (isAllocated()){ + ofPixelsRef pixels = getPixels(); + //uint8_t *im=(uint8_t *)&getPixels(); + for (int i=0;isetVerticalSync(false); shared_ptr mainApp(new ofApp); + mainApp->arguments = vector(argv, argv + argc); //mainApp->setupGui(); ofAddListener(guiWindow->events().update,mainApp.get(),&ofApp::updateGui); diff --git a/gui/src/ofApp.cpp b/gui/src/ofApp.cpp index 89e92c8..059b498 100644 --- a/gui/src/ofApp.cpp +++ b/gui/src/ofApp.cpp @@ -59,6 +59,16 @@ void ofApp::setup(){ ofSetFrameRate(30); // if vertical sync is off, we can go a bit fast... this caps the framerate at 60fps. + + if (arguments.size()>1){ + vector args; + for (int i=1;i _callback){ //bool (*_callback)(std::string filename)){ + caption=_caption; + load_callback=_callback; + startThread(); +} + +void threadedSystemLoadDialog::threadedFunction() { + setThreadName("threadedSystemLoadDialog " + ofToString(thread.get_id())); + ofFileDialogResult openFileResult= ofSystemLoadDialog(caption); + + //Check if the user opened a file + if (openFileResult.bSuccess){ + + + bool success=load_callback(openFileResult.fileName); + + ofLogVerbose("Load %s %s\n", + openFileResult.filePath.c_str(), + success?"succeeded":"failed"); + + + }else { + ofLogVerbose("User hit cancel"); + } +} \ No newline at end of file diff --git a/gui/src/threadedSystemDialogs.h b/gui/src/threadedSystemDialogs.h new file mode 100644 index 0000000..5a055b2 --- /dev/null +++ b/gui/src/threadedSystemDialogs.h @@ -0,0 +1,20 @@ + +#pragma once + +#include "ofThread.h" +#include "ofURLFileLoader.h" +#include "ofTypes.h" + + +class threadedSystemLoadDialog : public ofThread { + public: + threadedSystemLoadDialog(){}; + ~threadedSystemLoadDialog(){}; + + void load(std::string _caption,std::function _callback); //bool (*_callback)(std::string filename)); + + std::string caption; + std::function load_callback; + + virtual void threadedFunction(); +}; -- cgit v1.2.3