diff options
Diffstat (limited to 'liveengine/src')
| -rw-r--r-- | liveengine/src/layers.cpp | 56 | ||||
| -rw-r--r-- | liveengine/src/layers.h | 17 | ||||
| -rw-r--r-- | liveengine/src/playlist.cpp | 63 | ||||
| -rw-r--r-- | liveengine/src/playlist.h | 2 | ||||
| -rwxr-xr-x | liveengine/src/testApp.cpp | 54 | ||||
| -rwxr-xr-x | liveengine/src/testApp.h | 7 |
6 files changed, 125 insertions, 74 deletions
diff --git a/liveengine/src/layers.cpp b/liveengine/src/layers.cpp index 3ae7810..d2698ef 100644 --- a/liveengine/src/layers.cpp +++ b/liveengine/src/layers.cpp @@ -1,24 +1,5 @@ #include "layers.h"
-layer::layer() {}
-layer::layer(string _f)
-{
- load(_f);
-}
-
-void layer::load(string _f){
-}
-
-void layer::draw(float a) {
-
-}
-
-layer::~layer()
-{
- //dtor
-}
-
-
svglayer::svglayer() { xo=0;yo=0; }
@@ -45,6 +26,19 @@ void svglayer::draw(float a) { svg.getPathAt(i).setFillColor(fills[i]*a); svg.getPathAt(i).draw(xo,yo); }
+} +void svglayer::draw(float a,unsigned char* controllers) { + //draw layers tinted by controllers
+ for (int i=0;i<svg.getNumPath();i++) { + float h=fills[i].getHue(); + float ha=h/42.7; //0-5 + int h1=(int)ha; + int h2=h1+1; + float f2=ha-h1; + float f1=1.0f-f2; + svg.getPathAt(i).setFillColor(fills[i]*a*(((controllers[h1]*f1)+(controllers[h2]*f2))/127.0));; + svg.getPathAt(i).draw(xo,yo); + }
}
svglayer::~svglayer()
@@ -52,7 +46,9 @@ svglayer::~svglayer() //dtor
}
-imglayer::imglayer() {}
+imglayer::imglayer() { + //img.setUseTexture(false); +}
imglayer::imglayer(string _f)
{
load(_f);
@@ -62,12 +58,24 @@ void imglayer::load(string _f){ bool success=img.loadImage(_f);
printf("%s\n",success?"loaded":"not loaded");
}
+ +/* +WTF is going on with the image drawing + + +*/
+void imglayer::draw(float a) { + //if (img.isAllocated()) if (!img.isUsingTexture()) img.setUseTexture(true); //has to be done from the main thread? still doesn't work
+ img.draw(0,0,ofGetWidth(),ofGetHeight()); + printf("drawing %f\n",ofGetElapsedTimef());
+} + +void imglayer::draw(float a,unsigned char* controllers) { + imglayer::draw(a);
+} -void imglayer::draw(float a) {
- img.draw(0,0,ofGetWidth(),ofGetHeight());
-}
imglayer::~imglayer()
{
- //dtor
+ //img.setUseTexture(false); //free texture
}
diff --git a/liveengine/src/layers.h b/liveengine/src/layers.h index f7cbc85..11e50ab 100644 --- a/liveengine/src/layers.h +++ b/liveengine/src/layers.h @@ -6,11 +6,12 @@ class layer
{
public:
- layer();
- layer(string _f);
- virtual ~layer();
- virtual void load(string _f);
- virtual void draw(float a);
+ layer(){};
+ layer(string _f) {load(_f);};
+ virtual ~layer(){};
+ virtual void load(string _f){};
+ virtual void draw(float a){}; + virtual void draw(float a,unsigned char* controllers){ draw(a);};
protected:
private:
};
@@ -22,7 +23,8 @@ class svglayer: public layer svglayer(string _f);
virtual ~svglayer();
void load(string _f);
- void draw(float a);
+ void draw(float a); + void draw(float a,unsigned char* controllers);
protected:
private:
ofxSVGTiny svg; @@ -38,7 +40,8 @@ class imglayer: public layer imglayer(string _f);
virtual ~imglayer();
void load(string _f);
- void draw(float a);
+ void draw(float a); + void draw(float a,unsigned char* controllers);
protected:
private:
ofImage img;
diff --git a/liveengine/src/playlist.cpp b/liveengine/src/playlist.cpp index 896c788..3063595 100644 --- a/liveengine/src/playlist.cpp +++ b/liveengine/src/playlist.cpp @@ -12,6 +12,7 @@ void playlist::load(string _name){ printf("unable to load %s check data/ folder\n",_name.c_str());
}else { printf("starting loader thread\n"); + loadimg(); //how to do this from the worker thread??? startThread(false, false); //blocking, verbose } @@ -20,37 +21,45 @@ void playlist::load(string _name){ } void playlist::threadedFunction(){ - if( lock() ){ - - int numLayers=0; - layers.clear(); - if(XML.pushTag("playlist")) {
- numLayers=XML.getNumTags("svglayer");
- if(numLayers) {
- for (int i=0;i<numLayers;i++) {
- string s=XML.getAttribute("svglayer", "file", "",i);
- printf("loading %s: ",s.c_str());
- layers[XML.getAttribute("svglayer", "note", 0,i)]=new svglayer(XML.getAttribute("svglayer", "file", "",i));
- }
- }
- else printf("no SVG layers loaded!\n");
- numLayers=XML.getNumTags("imglayer");
- if(numLayers) {
- for (int i=0;i<numLayers;i++) {
- string s=XML.getAttribute("imglayer", "file", "",i);
- printf("%s: ",s.c_str());
- //int i=XML.getAttribute("imglayer", "note", 0,i);
- //ofImage i =
- layers[XML.getAttribute("imglayer", "note", 0,i)]=new imglayer(XML.getAttribute("imglayer", "file", "",i));
- }
- }
- else printf("no IMG layers loaded!\n");
- } + loadsvg(); unlock(); } - }
+ +void playlist::loadsvg(){ + int numLayers=0; + layers.clear(); + if(XML.pushTag("playlist")) {
+ numLayers=XML.getNumTags("svglayer");
+ if(numLayers) {
+ for (int i=0;i<numLayers;i++) {
+ string s=XML.getAttribute("svglayer", "file", "",i);
+ printf("loading %s: ",s.c_str());
+ layers[XML.getAttribute("svglayer", "note", 0,i)]=new svglayer(XML.getAttribute("svglayer", "file", "",i));
+ }
+ }
+ else printf("no SVG layers loaded!\n");
+ } + XML.popTag(); +} + +void playlist::loadimg(){ + int numLayers=0; + layers.clear(); + if(XML.pushTag("playlist")) {
+ numLayers=XML.getNumTags("imglayer");
+ if(numLayers) {
+ for (int i=0;i<numLayers;i++) {
+ string s=XML.getAttribute("imglayer", "file", "",i);
+ printf("%s: ",s.c_str());
+ layers[XML.getAttribute("imglayer", "note", 0,i)]=new imglayer(XML.getAttribute("imglayer", "file", "",i));
+ }
+ }
+ else printf("no IMG layers loaded!\n");
+ } + XML.popTag(); +} playlist::~playlist()
{
diff --git a/liveengine/src/playlist.h b/liveengine/src/playlist.h index afedec9..43982f9 100644 --- a/liveengine/src/playlist.h +++ b/liveengine/src/playlist.h @@ -11,6 +11,8 @@ class playlist : public ofThread { public:
playlist();
virtual ~playlist(); + void loadimg(); + void loadsvg(); void load(string _name); void threadedFunction(); diff --git a/liveengine/src/testApp.cpp b/liveengine/src/testApp.cpp index 0d8ec28..c23ec86 100755 --- a/liveengine/src/testApp.cpp +++ b/liveengine/src/testApp.cpp @@ -28,8 +28,9 @@ void testApp::setup(){ memset(controllers,NUM_CONTROLLERS,0); note=0; - controller_colours=new ofColor[NUM_CONTROLLERS]; - for (int i=0;i<NUM_CONTROLLERS;i++) controller_colours[i]=ofColor::fromHsb(ofRandom(255), 255, 255); + makeColours(); + + controlColours=false; grab.allocate(ofGetWidth(), ofGetHeight(),GL_RGB); //grab.setUseTexture(true); @@ -39,8 +40,10 @@ void testApp::setup(){ ofSetBackgroundAuto(false);
- xshift=1;
- yshift=1;
+ xshift=-1;
+ yshift=-1; + +
mode=BLOCKS; @@ -48,9 +51,19 @@ void testApp::setup(){ decayTime=2.0f;
//ofSetVerticalSync(true); deosn't seem effective
- //glXSwapIntervalSGI(1);
+ //glXSwapIntervalSGI(1); + /* + printf("hue of red is %f\n",ofColor(255,0,0).getHue()); + printf("hue of green is %f\n",ofColor(0,255,0).getHue()); + printf("hue of blue is %f\n",ofColor(0,0,255).getHue()); + hue is float from 0.0-255.0 + */
} +void testApp::makeColours() { + controller_colours=new ofColor[NUM_CONTROLLERS]; + for (int i=0;i<NUM_CONTROLLERS;i++) controller_colours[i]=ofColor::fromHsb(ofRandom(255), 255, 255); +} //-------------------------------------------------------------- void testApp::update(){
//for (int i=0;i<numLayers;i++) layers[i]->update(); @@ -60,10 +73,14 @@ void testApp::update(){ void testApp::draw(){
ofSetColor(255,255,255); grab.loadScreenData( 0, 0, ofGetWidth(), ofGetHeight() ); - //grab.update();
- //grab.reloadTexture(); - //ofBackground(0,0,0); - grab.draw( xshift,yshift); + + /* can this work? + grab.setAnchorPoint(xshift,yshift); + grab.setTextureWrap( GL_WRAP_BORDER, GL_WRAP_BORDER); + grab.draw(0,0); // xshift,yshift); + */ + int startx=(xshift>0?xshift-ofGetWidth():xshift); + int starty=(yshift>0?yshift-ofGetHeight():yshift); float notewidth=ofGetWidth()/NUM_NOTES; float noteheight=ofGetHeight()/NUM_CONTROLLERS; @@ -82,7 +99,10 @@ void testApp::draw(){ if (list.lock()) { //if playlist is loaded
ofPushMatrix();
//ofScale(sin(ofGetElapsedTimef())+1.1,sin(ofGetElapsedTimef())+1.1);
- if (list.layers.find(note)!=list.layers.end()) list.layers[note]->draw(lamda);
+ if (list.layers.find(note)!=list.layers.end()) { + if (controlColours) list.layers[note]->draw(lamda,controllers); + else list.layers[note]->draw(lamda); + }
ofPopMatrix(); list.unlock(); }
@@ -121,18 +141,24 @@ void testApp::keyPressed (int key){ mode=key-'0';
}
if(key == OF_KEY_LEFT){
- xshift--;
+ xshift++; +
}
if(key == OF_KEY_RIGHT){
- xshift++;
+ xshift--;
}
if(key == OF_KEY_DOWN){
yshift--;
}
if(key == OF_KEY_UP){
- yshift++;
+ yshift++; }
- + if(key == '='){
+ makeColours();
+ } + if(key == '-'){
+ controlColours=!controlColours;
+ } } //-------------------------------------------------------------- diff --git a/liveengine/src/testApp.h b/liveengine/src/testApp.h index 0f97068..af99c6a 100755 --- a/liveengine/src/testApp.h +++ b/liveengine/src/testApp.h @@ -95,14 +95,17 @@ class testApp : public ofBaseApp, public ofxMidiListener{ void dragEvent(ofDragInfo dragInfo); void gotMessage(ofMessage msg); + void makeColours(); + void toggleFPS(); bool showFPS; ofxXmlSettings XML; unsigned char* controllers; - int note, - mode; + int note, mode; + + bool controlColours; float lastnoteTime; float decayTime; |
