From 530bf6501e6f13ed3e91d4d0e2763613146774a2 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Sat, 15 Sep 2012 17:38:00 +0100 Subject: performance 2.0 --- liveengine/bin/data/yoga.xml | 124 ++++++++++++++++++++++++------------------- liveengine/liveengine.cbp | 2 + liveengine/liveengine.layout | 19 +++++-- liveengine/src/layers.cpp | 20 +++---- liveengine/src/layers.h | 17 +++--- liveengine/src/playlist.cpp | 0 liveengine/src/testApp.cpp | 116 +++++++++++++++++++++++----------------- liveengine/src/testApp.h | 15 ++---- liveengine/src/viewport.cpp | 107 +++++++++++++++++++++++++++++++++++++ liveengine/src/viewport.h | 33 ++++++++++++ 10 files changed, 316 insertions(+), 137 deletions(-) mode change 100644 => 100755 liveengine/src/playlist.cpp create mode 100755 liveengine/src/viewport.cpp create mode 100755 liveengine/src/viewport.h (limited to 'liveengine') diff --git a/liveengine/bin/data/yoga.xml b/liveengine/bin/data/yoga.xml index fc9c103..5c26932 100644 --- a/liveengine/bin/data/yoga.xml +++ b/liveengine/bin/data/yoga.xml @@ -1,56 +1,68 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/liveengine/liveengine.cbp b/liveengine/liveengine.cbp index d657653..de55eca 100644 --- a/liveengine/liveengine.cbp +++ b/liveengine/liveengine.cbp @@ -64,6 +64,8 @@ + + diff --git a/liveengine/liveengine.layout b/liveengine/liveengine.layout index 82581a6..c4d9071 100644 --- a/liveengine/liveengine.layout +++ b/liveengine/liveengine.layout @@ -1,6 +1,6 @@ - + @@ -17,18 +17,27 @@ - + - + + + + - + - + + + + + + + diff --git a/liveengine/src/layers.cpp b/liveengine/src/layers.cpp index ad251ea..e69023b 100755 --- a/liveengine/src/layers.cpp +++ b/liveengine/src/layers.cpp @@ -19,23 +19,23 @@ void svglayer::load(string _f){ } isLoaded= (svg.getNumPath()>0); } -void svglayer::getCentre() { +void svglayer::getCentre(int cx,int cy) { if (svg.getNumPath()>0) { - xo=(ofGetWidth()-svg.getWidth())/2; - yo=(ofGetHeight()-svg.getHeight())/2; + xo=(cx-svg.getWidth())/2; + yo=(cy-svg.getHeight())/2; } } -void svglayer::draw(float a) { - getCentre(); +void svglayer::draw(float a,int cx,int cy) { + getCentre(cx,cy); for (int i=0;idraw(0,0,ofGetWidth(),ofGetHeight()); - rb->draw(offset,-offset,ofGetHeight(),ofGetWidth()); - ofPopMatrix(); } //-------------------------------------------------------------- void testApp::setup(){ @@ -51,12 +44,10 @@ void testApp::setup(){ debug=false; noteRandomiseColours=false; transparentBlack=false; - - //ofGetWidth(), ofGetHeight(),GL_RGB); // - rb1.allocate(1024,768,GL_RGB); - rb2.allocate(1024,768,GL_RGB); - rb3.allocate(1024,768,GL_RGB); - rb4.allocate(1024,768,GL_RGB); + reversemain=false; + + vp1.setup(768,1024,1024,0,-90,-256,-384); + vp2.setup(1024,768,0,0,0,-512,-384); showFPS=false; ofBackground(0,0,0); @@ -84,17 +75,18 @@ void testApp::setup(){ ofSetFrameRate(60); rotate=-90; scale=1.0f; + fscale=1.0f; //window stuff - ofxFenster* win=ofxFensterManager::get()->createFenster(0, 0, ofGetHeight()/2, ofGetWidth()/2, OF_WINDOW); + ofxFenster* win=ofxFensterManager::get()->createFenster(0, 0, 600, 800, OF_WINDOW); ofAddListener(win->events.mouseDragged, this, &testApp::mousePressedEvent); ofAddListener(win->events.mousePressed, this, &testApp::mousePressedEvent); ofAddListener(win->events.keyPressed, this, &testApp::keyPressedEvent); win->setWindowTitle("preview"); win->addListener(&prevWin); prevWin.setup(); - prevWin.setBuffer(&rb2); + prevWin.setBuffer(&vp1.rb2); fullscreenoutput=false; @@ -112,25 +104,34 @@ void testApp::update(){ //-------------------------------------------------------------- void testApp::draw(){ - float lamda=max(0.0f,1.0f-((ofGetElapsedTimef()-lastnoteTime)/decayTime)); + float lambda=max(0.0f,1.0f-((ofGetElapsedTimef()-lastnoteTime)/decayTime)); + + ofSetColor(255-fadetime,255-fadetime,255-fadetime); //for feedback + vp1.draw(lambda,controllers,xshift,yshift,list,transparentBlack,note,mode,controller_colours,controlColours,scale,fscale); + vp2.draw(lambda,controllers,reversemain?-xshift:xshift,yshift,list,transparentBlack,note,mode,controller_colours,controlColours,reversemain?1.0f/scale:scale,reversemain?1.0f/fscale:fscale); + + ofSetColor(255,255,255); + if (showFPS) ofDrawBitmapString(ofToString(ofGetFrameRate(), 2),20,20); + + /* rb1.begin(); - /* can this work? - grab.setAnchorPoint(xshift,yshift); - grab.setTextureWrap( GL_WRAP_BORDER, GL_WRAP_BORDER); - grab.draw(0,0); // xshift,yshift); - */ + // can this work? + //grab.setAnchorPoint(xshift,yshift); + //grab.setTextureWrap( GL_WRAP_BORDER, GL_WRAP_BORDER); + //grab.draw(0,0); // xshift,yshift); + ofSetColor(255-fadetime,255-fadetime,255-fadetime); - for (int i=(xshift>0?xshift-ofGetWidth():xshift);i0?yshift-ofGetHeight():yshift);j0?xshift-rb1.getWidth():xshift);i0?yshift-rb1.getHeight():yshift);jdraw(lamda,controllers,transparentBlack); - else list.layers[note]->draw(lamda); + if (controlColours) list.layers[note]->draw(lamda,controllers,512,384,transparentBlack); + else list.layers[note]->draw(lamda,512,384); } ofPopMatrix(); list.unlock(); @@ -176,24 +177,21 @@ void testApp::draw(){ rb3.begin(); //landscape - /* can this work? - grab.setAnchorPoint(xshift,yshift); - grab.setTextureWrap( GL_WRAP_BORDER, GL_WRAP_BORDER); - grab.draw(0,0); // xshift,yshift); - */ + ofSetColor(255-fadetime,255-fadetime,255-fadetime); - for (int i=(yshift>0?yshift-ofGetWidth():yshift);i0?xshift-ofGetHeight():xshift);j0?xshift-rb3.getWidth():xshift);i0?yshift-rb3.getHeight():yshift);j0) { switch(mode) { @@ -206,13 +204,13 @@ void testApp::draw(){ case LIST: if (list.lock()) { //if playlist is loaded ofPushMatrix(); - ofTranslate(ofGetWidth()/2,ofGetHeight()/2); + ofTranslate(rb3.getWidth()/2,rb3.getHeight()/2); ofScale(scale,scale,scale); ofRotate(rotate); - ofTranslate(-ofGetWidth()/2,-ofGetHeight()/2); + ofTranslate(-rb3.getWidth()/2,-rb3.getHeight()/2); if (list.layers.find(note)!=list.layers.end()) { - if (controlColours) list.layers[note]->draw(lamda,controllers,transparentBlack); - else list.layers[note]->draw(lamda); + if (controlColours) list.layers[note]->draw(lamda,controllers,512,384,transparentBlack); + else list.layers[note]->draw(lamda,512,384); } ofPopMatrix(); list.unlock(); @@ -236,6 +234,8 @@ void testApp::draw(){ rb4.draw(0,0); + */ + /* test screen shape ofSetColor(255,0,0); ofRect(0,0,1024,768); @@ -303,6 +303,9 @@ void testApp::keyPressed(int key){ if(key == 'p'){ list.load("dancing.xml"); } + if(key == 'P'){ + list.load("trainers.xml"); + } if(key == 's'){ XML.saveFile("settings.xml"); printf("settings saved!\n"); @@ -363,6 +366,17 @@ void testApp::keyPressed(int key){ transparentBlack=!transparentBlack; printf("%s transparent black\n",transparentBlack?"use":"don't use"); } + if (key=='j') { + fscale=1.0f; + } + if (key=='h') { + scale=1.0f; + } + if (key=='h') { + reversemain=!reversemain; + printf("%s main screen\n",reversemain?"reversing":"not reversing"); + } + } //-------------------------------------------------------------- @@ -404,12 +418,18 @@ void testApp::dragEvent(ofDragInfo dragInfo){ } void testApp::mousePressedEvent(ofMouseEventArgs &args) { - //printf("mouse: %i,%i %i\n",args.x,args.y,args.button); + //printf("mouse: %i,%i %i of %ix%i\n",args.x,args.y,args.button,ofGetWidth(),ofGetHeight()); //0-2 switch (args.button) { case 0: - yshift=(ofGetWidth()/2)-args.x; - xshift=args.y-(ofGetHeight()/2); + xshift=args.x-(ofGetWidth()/2); + yshift=args.y-(ofGetHeight()/2); + break; + case 1: + scale=pow(pow(args.x-(ofGetWidth()/2),2)+pow(args.y-(ofGetHeight()/2),2),0.5)/(ofGetWidth()*.1); + break; + case 2: + fscale=(pow(pow(args.x-(ofGetWidth()/2),2)+pow(args.y-(ofGetHeight()/2),2),0.5)/(ofGetWidth()))+0.5; break; } } diff --git a/liveengine/src/testApp.h b/liveengine/src/testApp.h index 5e050da..27380af 100755 --- a/liveengine/src/testApp.h +++ b/liveengine/src/testApp.h @@ -69,19 +69,12 @@ option to randomise colours on each note #define OF_ADDON_USING_OFXMIDIIN -#define NUM_NOTES 64 -#define START_NOTE 36 -#define NUM_CONTROLLERS 6 -#define START_CONTROLLER 102 #include "ofxMidi.h" #include "ofxFensterManager.h" -#define NOTHING 0 -#define BLOCKS 1 -#define LIST 2 -#include "playlist.h" +#include "viewport.h" class previewWindow: public ofxFensterListener{ public: @@ -132,6 +125,8 @@ class testApp : public ofxFensterListener, public ofxMidiListener{ bool noteRandomiseColours; bool transparentBlack; + bool reversemain; + bool fullscreenoutput; float lastnoteTime; @@ -139,13 +134,13 @@ class testApp : public ofxFensterListener, public ofxMidiListener{ int fadetime; int rotate; - float scale; + float scale,fscale; int xshift,yshift; ofColor* controller_colours; - ofFbo rb1,rb2,rb3,rb4; //2 buffers * 2 outputs + viewport vp1,vp2; previewWindow prevWin; diff --git a/liveengine/src/viewport.cpp b/liveengine/src/viewport.cpp new file mode 100755 index 0000000..74333b0 --- /dev/null +++ b/liveengine/src/viewport.cpp @@ -0,0 +1,107 @@ +#include "viewport.h" + + + +viewport::viewport() +{ + //ctor +} + +void viewport::setup(int _w,int _h,int _x,int _y,float _r,int _ox,int _oy) { + r=_r; + w=_w; + h=_h; + x=_x; + y=_y; + ox=_ox; + oy=_oy; + rb1.allocate(w,h,GL_RGB); + rb2.allocate(w,h,GL_RGB); + + printf("%ix%i, vp offset: %f,%f\n",w,h,-(sin(ofDegToRad(r))*h/2)-(cos(ofDegToRad(r))*w/2),-(sin(ofDegToRad(r))*w/2)-(cos(ofDegToRad(r))*h/2)); +} + +void viewport::draw(float a,unsigned char* controllers,int xshift,int yshift,playlist &list,bool transparentBlack,int note,int mode,ofColor* controller_colours,bool controlColours,float scale,float fscale){ + + + + // test screen shape + /* + ofSetColor(255,0,0); + ofRect(0,0,w/2,h/2); + ofRect(w/2,h/2,w/2,h/2); + ofSetColor(0,255,0); + ofRect(0,h/2,w/2,h/2); + ofRect(w/2,0,w/2,h/2); + */ + + rb1.begin(); + + //can be done with texture offset? + + int startx=((w-(w*fscale))/2)+xshift; + while (startx>0) startx-=(w*fscale); + int starty=((h-(h*fscale))/2)+yshift; + while (starty>0) starty-=(h*fscale); + + for (int i=startx;i0) { + switch(mode) { + case BLOCKS: + for (int i=0;i>7,(controller_colours[i].g*controllers[i])>>7,(controller_colours[i].b*controllers[i])>>7)); + ofRect((note-START_NOTE)*notewidth,i*noteheight,notewidth,noteheight); + } + break; + case LIST: + if (list.lock()) { //if playlist is loaded + if (list.layers.find(note)!=list.layers.end()) { + ofPushMatrix(); + ofTranslate(w/2,h/2); + ofScale(scale,scale,scale); + ofTranslate(-w/2,-h/2); + if (controlColours) list.layers[note]->draw(a,controllers,w,h,transparentBlack); + else list.layers[note]->draw(a,w,h); + ofPopMatrix(); + } + list.unlock(); + } + break; + } + } + + rb1.end(); + + rb2.begin(); + ofSetColor(255,255,255); + rb1.draw(0,0); + rb2.end(); + + ofPushMatrix(); + ofTranslate(x+(w/2),y+(h/2)); + ofRotate(r); + //ofTranslate(-abs(sin(ofDegToRad(r))*h/2)-abs(cos(ofDegToRad(r))*w/2),-abs(sin(ofDegToRad(r))*w/2)-abs(cos(ofDegToRad(r))*h/2)); + ofTranslate(ox,oy); + + rb2.draw(0,0); + + ofPopStyle(); + + ofPopMatrix(); + +} + +viewport::~viewport() +{ + //dtor +} diff --git a/liveengine/src/viewport.h b/liveengine/src/viewport.h new file mode 100755 index 0000000..5d990a0 --- /dev/null +++ b/liveengine/src/viewport.h @@ -0,0 +1,33 @@ +#ifndef VIEWPORT_H +#define VIEWPORT_H + +#include "ofMain.h" +#include "playlist.h" + +#define NUM_NOTES 64 +#define START_NOTE 36 +#define NUM_CONTROLLERS 6 +#define START_CONTROLLER 102 + +#define NOTHING 0 +#define BLOCKS 1 +#define LIST 2 + + + +class viewport +{ + public: + viewport(); + void setup(int w,int h,int x, int y,float r,int _ox,int _oy); + void draw(float a,unsigned char* controllers,int xshift,int yshift,playlist &list,bool transparentBlack,int note,int mode,ofColor* controller_colours,bool controlColours,float scale,float fscale); + virtual ~viewport(); + ofFbo rb1,rb2; + float r; + protected: + private: + int x, y,w,h,ox,oy; + +}; + +#endif // VIEWPORT_H -- cgit v1.2.3