From ac1e8968254cf7810e84c0d90c80c94bc9dcd827 Mon Sep 17 00:00:00 2001 From: Comment Date: Tue, 11 Mar 2014 09:47:04 +0000 Subject: instagram loader --- json-instagram/config.make | 4 +- json-instagram/src/exampleApp.cpp | 47 +++++++-------- json-instagram/src/exampleApp.h | 118 +++++++++++++++++++++++++++++++++++++- 3 files changed, 141 insertions(+), 28 deletions(-) (limited to 'json-instagram') diff --git a/json-instagram/config.make b/json-instagram/config.make index 93c489d..d5a6b93 100644 --- a/json-instagram/config.make +++ b/json-instagram/config.make @@ -78,6 +78,8 @@ ################################################################################ # PROJECT_LDFLAGS=-Wl,-rpath=./libs +PROJECT_LDFLAGS= -ljsoncpp + ################################################################################ # PROJECT DEFINES # Create a space-delimited list of DEFINES. The list will be converted into @@ -104,7 +106,7 @@ # # Note: Leave a leading space when adding list items with the += operator ################################################################################ -# PROJECT_CFLAGS = + PROJECT_CFLAGS = `pkg-config --cflags jsoncpp` ################################################################################ # PROJECT OPTIMIZATION CFLAGS diff --git a/json-instagram/src/exampleApp.cpp b/json-instagram/src/exampleApp.cpp index 0559dce..deb4f35 100644 --- a/json-instagram/src/exampleApp.cpp +++ b/json-instagram/src/exampleApp.cpp @@ -14,34 +14,30 @@ could save with the tag id as the name of file, simpler how exactly do we parse or mipmap the images do we worry about memory - I guess not +identify the images + */ +long ofToLong(const string& intString) { + long x = 0; + istringstream cur(intString); + cur >> x; + return x; +} + //------------------------------------------------------------------------------ void exampleApp::setup() { ofSetFrameRate(24); - - std::string url = "https://api.instagram.com/v1/tags/tycleeson/media/recent?client_id=c1d74d701fdf4ddd9f8d30ee9e8f944b"; - - if (!response.open(url)) { - cout << "Failed to parse JSON\n" << endl; - } - //else cout< images; + deque to_update; + + instagramLoader(){ + count = 0; + url = "https://api.instagram.com/v1/tags/tycleeson/media/recent?client_id=c1d74d701fdf4ddd9f8d30ee9e8f944b"; + } + + void set_interval(float _interval){ + interval=_interval; + } + + void start(){ + startThread(true, false); // blocking, verbose + } + + void stop(){ + stopThread(); + } + + //-------------------------- + void threadedFunction(){ + + cout << "Api: " << url<::iterator i=images.begin();i!=images.end();++i){ + if(i->second.isUsingTexture()){ + drawcount++; + } + } + cout<<"loaded "<::iterator i=images.begin();i!=images.end();++i){ + if(i->second.isUsingTexture()){ + i->second.draw(ofToLong(i->first)%(long)(ofGetWidth()-i->second.getWidth()+1),ofToLong(i->first)%(long)(ofGetHeight()-i->second.getHeight()+1)); + } + } + unlock(); + } + } + + +}; class exampleApp : public ofBaseApp { public: void setup(); + void update(); void draw(); + instagramLoader loader; - ofxJSONElement response; - std::vector images; }; -- cgit v1.2.3