summaryrefslogtreecommitdiff
path: root/liveengine/src
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2012-09-14 19:24:39 +0100
committerTim Redfern <tim@eclectronics.org>2012-09-14 19:24:39 +0100
commit4fda3af17e55c0afff35b3f3ebbe5b4fd1ffad7e (patch)
treeca47926461a8c7176c3542ff7734ec74833abdba /liveengine/src
parent639dfe9190c06bba4dced32f282ad1fddc573b59 (diff)
working nicely multiscreen
Diffstat (limited to 'liveengine/src')
-rwxr-xr-x[-rw-r--r--]liveengine/src/layers.cpp31
-rwxr-xr-x[-rw-r--r--]liveengine/src/layers.h5
-rwxr-xr-xliveengine/src/main.cpp2
-rwxr-xr-xliveengine/src/testApp.cpp157
-rwxr-xr-xliveengine/src/testApp.h17
5 files changed, 170 insertions, 42 deletions
diff --git a/liveengine/src/layers.cpp b/liveengine/src/layers.cpp
index 6ab91ca..ad251ea 100644..100755
--- a/liveengine/src/layers.cpp
+++ b/liveengine/src/layers.cpp
@@ -17,33 +17,42 @@ void svglayer::load(string _f){
strokes.push_back(svg.getPathAt(i).getStrokeColor());
printf(" path %i: fill %08x stroke %08x\n",i,svg.getPathAt(i).getFillColor().getHex(),svg.getPathAt(i).getStrokeColor().getHex());
}
- if (svg.getNumPath()>0) {
- xo=(ofGetWidth()-svg.getWidth())/2;
- yo=(ofGetHeight()-svg.getHeight())/2;
- }
isLoaded= (svg.getNumPath()>0);
}
+void svglayer::getCentre() {
+ if (svg.getNumPath()>0) {
+ xo=(ofGetWidth()-svg.getWidth())/2;
+ yo=(ofGetHeight()-svg.getHeight())/2;
+ }
+}
void svglayer::draw(float a) {
- //svg.draw();
+ getCentre();
for (int i=0;i<svg.getNumPath();i++) {
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++) {
+
+void svglayer::draw(float a,unsigned char* controllers,bool transparentBlack) {
+ getCentre();
+ //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 h1=(((int)ha)+2)%6;
int h2=h1+1;
float f2=ha-h1;
float f1=1.0f-f2;
+ //if (transparentBlack) printf("transparent black draw %f\n",(a*(((controllers[h1]*f1)+(controllers[h2]*f2))/127.0)));
+
svg.getPathAt(i).setFillColor(fills[i]*a*(((controllers[h1]*f1)+(controllers[h2]*f2))/127.0));;
- svg.getPathAt(i).draw(xo,yo);
+ if (!transparentBlack||(a*(((controllers[h1]*f1)+(controllers[h2]*f2))/127.0))>0.1) {
+ svg.getPathAt(i).draw(xo,yo);
+ }
}
-}
+}
+
svglayer::~svglayer()
{
diff --git a/liveengine/src/layers.h b/liveengine/src/layers.h
index ae17989..6155626 100644..100755
--- a/liveengine/src/layers.h
+++ b/liveengine/src/layers.h
@@ -11,7 +11,7 @@ class layer
virtual ~layer(){};
virtual void load(string _f){};
virtual void draw(float a){};
- virtual void draw(float a,unsigned char* controllers){ draw(a);};
+ virtual void draw(float a,unsigned char* controllers,bool transparentBlack=false){ draw(a);};
bool getLoaded() {return isLoaded;};
protected:
bool isLoaded;
@@ -26,7 +26,8 @@ class svglayer: public layer
virtual ~svglayer();
void load(string _f);
void draw(float a);
- void draw(float a,unsigned char* controllers);
+ void draw(float a,unsigned char* controllers,bool transparentBlack=false);
+ void getCentre();
protected:
private:
ofxSVGTiny svg;
diff --git a/liveengine/src/main.cpp b/liveengine/src/main.cpp
index 28ab04b..dadd89f 100755
--- a/liveengine/src/main.cpp
+++ b/liveengine/src/main.cpp
@@ -7,7 +7,7 @@
int main( ){
ofAppGlutWindow window;
- ofSetupOpenGL(ofxFensterManager::get(),1024,768, OF_WINDOW);
+ ofSetupOpenGL(ofxFensterManager::get(),2048,768, OF_WINDOW);
//ofSetupOpenGL(&window, 1024,768, OF_WINDOW); // <-------- setup the GL context
//ofSetupOpenGL(&window, 1024,768, OF_WINDOW);
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;i<numLayers;i++) layers[i]->draw();
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);i<ofGetWidth()*2;i+=ofGetWidth()) {
+ for (int j=(xshift>0?xshift-ofGetHeight():xshift);j<ofGetHeight()*2;j+=ofGetHeight()) {
+ rb4.draw(i,j);
+ }
+ }
+
+ notewidth=ofGetHeight()/NUM_NOTES;
+ noteheight=ofGetWidth()/NUM_CONTROLLERS;
+
+ ofPushMatrix();
+ ofTranslate(ofGetWidth()/2,ofGetHeight()/2);
+ ofRotate(-90);
+
+ if (note>0) {
+ switch(mode) {
+ case BLOCKS:
+ for (int i=0;i<NUM_CONTROLLERS;i++){
+ ofSetColor(ofColor((controller_colours[i].r*controllers[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;i<numLayers;i++) layers[i]->draw();
+ 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) {
diff --git a/liveengine/src/testApp.h b/liveengine/src/testApp.h
index a556038..5e050da 100755
--- a/liveengine/src/testApp.h
+++ b/liveengine/src/testApp.h
@@ -58,6 +58,10 @@ non random colours
option to randomise colours on each note
+--make transparent
+
+--interface for exploring and saving - swapping?
+
*/
@@ -85,7 +89,7 @@ public:
ofFbo *rb;
void setup();
void setBuffer(ofFbo *buffer);
- void draw();
+ void draw();
};
//#define GRAB_TEXTURE
@@ -109,8 +113,8 @@ class testApp : public ofxFensterListener, public ofxMidiListener{
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);
- void mouseMovedEvent(ofMouseEventArgs &args);
- void keyPressedEvent(ofKeyEventArgs &args);
+ void mousePressedEvent(ofMouseEventArgs &args);
+ void keyPressedEvent(ofKeyEventArgs &args);
void makeColours();
@@ -122,8 +126,13 @@ class testApp : public ofxFensterListener, public ofxMidiListener{
unsigned char* controllers;
int note, mode;
+ //to be moved into svg object gui
+
bool debug, controlColours;
bool noteRandomiseColours;
+ bool transparentBlack;
+
+ bool fullscreenoutput;
float lastnoteTime;
float decayTime;
@@ -136,7 +145,7 @@ class testApp : public ofxFensterListener, public ofxMidiListener{
ofColor* controller_colours;
- ofFbo rb1,rb2;
+ ofFbo rb1,rb2,rb3,rb4; //2 buffers * 2 outputs
previewWindow prevWin;