diff options
| author | Tim Redfern <tim@eclectronics.org> | 2012-09-15 17:38:00 +0100 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2012-09-15 17:38:00 +0100 |
| commit | 530bf6501e6f13ed3e91d4d0e2763613146774a2 (patch) | |
| tree | 3bf4f0ba78842c4e6cb74dc0a62b154b64b890cf /liveengine/src/testApp.cpp | |
| parent | 4fda3af17e55c0afff35b3f3ebbe5b4fd1ffad7e (diff) | |
performance 2.0
Diffstat (limited to 'liveengine/src/testApp.cpp')
| -rwxr-xr-x | liveengine/src/testApp.cpp | 116 |
1 files changed, 68 insertions, 48 deletions
diff --git a/liveengine/src/testApp.cpp b/liveengine/src/testApp.cpp index fc0adf4..07c34e4 100755 --- a/liveengine/src/testApp.cpp +++ b/liveengine/src/testApp.cpp @@ -7,16 +7,9 @@ void previewWindow::setBuffer(ofFbo *buffer){ rb=buffer; } void previewWindow::draw(){ - float offset=(ofGetWidth()-ofGetHeight())/2; - ofPushMatrix(); - - ofTranslate(ofGetWidth()/2,ofGetHeight()/2); - ofRotate(90); - ofTranslate(-ofGetWidth()/2,-ofGetHeight()/2); + rb->draw(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);i<ofGetWidth()*2;i+=ofGetWidth()) { - for (int j=(yshift>0?yshift-ofGetHeight():yshift);j<ofGetHeight()*2;j+=ofGetHeight()) { + for (int i=(xshift>0?xshift-rb1.getWidth():xshift);i<rb1.getWidth()*2;i+=ofGetWidth()) { + for (int j=(yshift>0?yshift-rb1.getHeight():yshift);j<rb1.getHeight()*2;j+=rb1.getHeight()) { rb2.draw(i,j); } } - float notewidth=ofGetWidth()/NUM_NOTES; - float noteheight=ofGetHeight()/NUM_CONTROLLERS; + float notewidth=rb1.getWidth()/NUM_NOTES; + float noteheight=rb1.getHeight()/NUM_CONTROLLERS; @@ -145,13 +146,13 @@ void testApp::draw(){ case LIST: if (list.lock()) { //if playlist is loaded
ofPushMatrix(); - ofTranslate(ofGetWidth()/2,ofGetHeight()/2);
+ ofTranslate(rb1.getWidth()/2,rb1.getHeight()/2); ofScale(scale,scale,scale); ofRotate(rotate); - ofTranslate(-ofGetWidth()/2,-ofGetHeight()/2);
+ ofTranslate(-rb1.getWidth()/2,-rb1.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(); @@ -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);i<ofGetWidth()*2;i+=ofGetWidth()) { - for (int j=(xshift>0?xshift-ofGetHeight():xshift);j<ofGetHeight()*2;j+=ofGetHeight()) { + for (int i=(xshift>0?xshift-rb3.getWidth():xshift);i<rb3.getWidth()*2;i+=ofGetWidth()) { + for (int j=(yshift>0?yshift-rb3.getHeight():yshift);j<rb3.getHeight()*2;j+=rb3.getHeight()) { rb4.draw(i,j); } } - notewidth=ofGetHeight()/NUM_NOTES; - noteheight=ofGetWidth()/NUM_CONTROLLERS; + notewidth=rb3.getHeight()/NUM_NOTES; + noteheight=rb3.getWidth()/NUM_CONTROLLERS; ofPushMatrix(); - ofTranslate(ofGetWidth()/2,ofGetHeight()/2); - ofRotate(-90); + ofTranslate(rb3.getWidth(),rb3.getHeight()/2); + ofRotate(90); + ofTranslate(-rb3.getWidth()/2,-rb3.getHeight()/2); if (note>0) { 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; } } |
