From 4fda3af17e55c0afff35b3f3ebbe5b4fd1ffad7e Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Fri, 14 Sep 2012 19:24:39 +0100 Subject: working nicely multiscreen --- liveengine/src/testApp.cpp | 157 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 133 insertions(+), 24 deletions(-) (limited to 'liveengine/src/testApp.cpp') diff --git a/liveengine/src/testApp.cpp b/liveengine/src/testApp.cpp index 5e5a140..fc0adf4 100755 --- a/liveengine/src/testApp.cpp +++ b/liveengine/src/testApp.cpp @@ -10,11 +10,11 @@ void previewWindow::draw(){ float offset=(ofGetWidth()-ofGetHeight())/2; ofPushMatrix(); - + ofTranslate(ofGetWidth()/2,ofGetHeight()/2); ofRotate(90); ofTranslate(-ofGetWidth()/2,-ofGetHeight()/2); - + rb->draw(offset,-offset,ofGetHeight(),ofGetWidth()); ofPopMatrix(); } @@ -50,10 +50,13 @@ void testApp::setup(){ controlColours=false; 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); showFPS=false; ofBackground(0,0,0); @@ -68,7 +71,7 @@ void testApp::setup(){ mode=BLOCKS; lastnoteTime=ofGetElapsedTimef(); - decayTime=2.0f; + decayTime=1.0f; //ofSetVerticalSync(true); deosn't seem effective //glXSwapIntervalSGI(1); @@ -85,14 +88,16 @@ void testApp::setup(){ //window stuff ofxFenster* win=ofxFensterManager::get()->createFenster(0, 0, ofGetHeight()/2, ofGetWidth()/2, OF_WINDOW); - ofAddListener(win->events.mouseMoved, this, &testApp::mouseMovedEvent); + 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); - + fullscreenoutput=false; + } void testApp::makeColours() { @@ -105,10 +110,12 @@ void testApp::update(){ } //-------------------------------------------------------------- -void testApp::draw(){ +void testApp::draw(){ + + float lamda=max(0.0f,1.0f-((ofGetElapsedTimef()-lastnoteTime)/decayTime)); rb1.begin(); - + /* can this work? grab.setAnchorPoint(xshift,yshift); @@ -121,11 +128,11 @@ void testApp::draw(){ rb2.draw(i,j); } } - + float notewidth=ofGetWidth()/NUM_NOTES; float noteheight=ofGetHeight()/NUM_CONTROLLERS; - float lamda=max(0.0f,1.0f-((ofGetElapsedTimef()-lastnoteTime)/decayTime)); + if (note>0) { switch(mode) { @@ -143,7 +150,7 @@ void testApp::draw(){ ofRotate(rotate); ofTranslate(-ofGetWidth()/2,-ofGetHeight()/2); if (list.layers.find(note)!=list.layers.end()) { - if (controlColours) list.layers[note]->draw(lamda,controllers); + if (controlColours) list.layers[note]->draw(lamda,controllers,transparentBlack); else list.layers[note]->draw(lamda); } ofPopMatrix(); @@ -156,23 +163,94 @@ void testApp::draw(){ //for (int i=0;idraw(); ofSetColor(255,255,255); if (showFPS) ofDrawBitmapString(ofToString(ofGetFrameRate(), 2),20,20); - + rb1.end(); - + rb2.begin(); ofSetColor(255,255,255); rb1.draw(0,0); rb2.end(); + + rb2.draw(1024,0); + + 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) { + 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 + ofPushMatrix(); + ofTranslate(ofGetWidth()/2,ofGetHeight()/2); + ofScale(scale,scale,scale); + ofRotate(rotate); + ofTranslate(-ofGetWidth()/2,-ofGetHeight()/2); + if (list.layers.find(note)!=list.layers.end()) { + if (controlColours) list.layers[note]->draw(lamda,controllers,transparentBlack); + else list.layers[note]->draw(lamda); + } + ofPopMatrix(); + list.unlock(); + } + break; + } + } - rb2.draw(0,0); - + ofPopMatrix(); + + //for (int i=0;idraw(); + ofSetColor(255,255,255); + if (showFPS) ofDrawBitmapString(ofToString(ofGetFrameRate(), 2),20,20); + + rb3.end(); + + rb4.begin(); + ofSetColor(255,255,255); + rb3.draw(0,0); + rb4.end(); + + rb4.draw(0,0); + + /* test screen shape + ofSetColor(255,0,0); + ofRect(0,0,1024,768); + ofSetColor(0,255,0); + ofRect(1024,0,1024,768); + */ } //-------------------------------------------------------------- void testApp::keyPressed(int key, ofxFenster* win){ if(key == ' '){ - win->toggleFullscreen(); + fullscreenoutput=!fullscreenoutput; + win->setFullscreen(fullscreenoutput); + printf("resolution: %ix%i %s\n",win->getWidth(),win->getHeight(),fullscreenoutput?"fullscreen":"windowed"); } else keyPressed(key); } @@ -180,20 +258,35 @@ void testApp::keyPressed(int key){ if(key == 'q'){ list.load("insects.xml"); } - if(key == 'w'){ - list.load("women_ethnic.xml"); + if(key == 'Q'){ + list.load("birds.xml"); + } + if(key == 'w'){ + list.load("teamsports.xml"); + } + if(key == 'W'){ + list.load("american_football.xml"); } if(key == 'e'){ list.load("organs.xml"); } + if(key == 'E'){ + list.load("crests.xml"); + } if(key == 'r'){ list.load("tai_chi.xml"); } + if(key == 'R'){ + list.load("cricket.xml"); + } if(key == 't'){ list.load("reptiles.xml"); } if(key == 'y'){ - list.load("military_ladies.xml"); + list.load("miltary_ladies.xml"); + } + if(key == 'Y'){ + list.load("women_ethnic.xml"); } if(key == 'u'){ list.load("knights.xml"); @@ -201,6 +294,9 @@ void testApp::keyPressed(int key){ if(key == 'i'){ list.load("mil_historic.xml"); } + if(key == 'I'){ + list.load("mil_ethnic.xml"); + } if(key == 'o'){ list.load("yoga.xml"); } @@ -233,7 +329,8 @@ void testApp::keyPressed(int key){ makeColours(); } if(key == '-'){ - controlColours=!controlColours; + controlColours=!controlColours; + printf("%s control colours\n",controlColours?"do":"don't"); } if(key == '+'){ fadetime=min(128,fadetime+1); @@ -253,13 +350,18 @@ void testApp::keyPressed(int key){ if(key == '{'){ rotate-=90; } - - + + if(key == 'd'){ debug=!debug; } - if(key == 'p'){ + if(key == 'l'){ noteRandomiseColours=!noteRandomiseColours; + printf("%s randomise colours\n",noteRandomiseColours?"do":"don't"); + } + if (key=='k') { + transparentBlack=!transparentBlack; + printf("%s transparent black\n",transparentBlack?"use":"don't use"); } } @@ -301,8 +403,15 @@ void testApp::dragEvent(ofDragInfo dragInfo){ } -void testApp::mouseMovedEvent(ofMouseEventArgs &args) { - //cout << "MOUSE WAS MOVED" << endl; +void testApp::mousePressedEvent(ofMouseEventArgs &args) { + //printf("mouse: %i,%i %i\n",args.x,args.y,args.button); + //0-2 + switch (args.button) { + case 0: + yshift=(ofGetWidth()/2)-args.x; + xshift=args.y-(ofGetHeight()/2); + break; + } } void testApp::keyPressedEvent(ofKeyEventArgs &args) { -- cgit v1.2.3