summaryrefslogtreecommitdiff
path: root/liveengine/src/testApp.cpp
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2012-08-27 20:34:24 +0100
committerTim Redfern <tim@eclectronics.org>2012-08-27 20:34:24 +0100
commit766266368648487735894e6bf01c0330db6be2aa (patch)
tree9855b2287103b5cadf4533d1746451f2525131c1 /liveengine/src/testApp.cpp
parent5e95c9719795a4fb4feeed7e57ab3c893f2541a4 (diff)
svg layers
Diffstat (limited to 'liveengine/src/testApp.cpp')
-rwxr-xr-xliveengine/src/testApp.cpp97
1 files changed, 38 insertions, 59 deletions
diff --git a/liveengine/src/testApp.cpp b/liveengine/src/testApp.cpp
index 62d18b2..9a84eda 100755
--- a/liveengine/src/testApp.cpp
+++ b/liveengine/src/testApp.cpp
@@ -5,7 +5,7 @@
void testApp::setup(){
int midiPort=0;
midiChannel=0;
- //numLayers=0;
+ int numLayers=0;
if( !XML.loadFile("settings.xml") ){
printf("unable to load settings.xml check data/ folder\n");
}else{
@@ -14,36 +14,18 @@ void testApp::setup(){
midiChannel=ofToInt(XML.getAttribute("liveEngine", "channel", "0"));
if (midiChannel) printf("listening on port %d, midi channel %d\n",midiPort,midiChannel);
else printf("listening on port %d, all midi channels\n",midiPort);
- if(XML.pushTag("liveEngine")) {
- /*
- numLayers=XML.getNumTags("layer");
+ if(XML.pushTag("liveEngine")) {
+ numLayers=XML.getNumTags("svglayer");
if(numLayers) {
- layers=new globeLayer*[numLayers];
- for (int i=0;i<numLayers;i++){
- XML.pushTag("layer",i);
- string layerType=XML.getAttribute("content", "type", "");
- XML.pushTag("content");
- float x=ofToFloat(XML.getAttribute("pos", "x", ""));
- float y=ofToFloat(XML.getAttribute("pos", "y", ""));
- float w=ofToFloat(XML.getAttribute("pos", "w", ""));
- float h=ofToFloat(XML.getAttribute("pos", "h", ""));
- int midiNote=ofToInt(XML.getAttribute("midi", "note", "0"));
- int midiMix=ofToInt(XML.getAttribute("midi", "mix", "0"));
- if (layerType=="player") {
- string fileName=XML.getAttribute("media", "name", "0");
- layers[i]=new globePlayer(x,y,w,h,midiNote,midiMix,fileName);
- }
- if (layerType=="grabber") {
- bool deInt=ofToInt(XML.getAttribute("grab", "deInt", "0"));
- layers[i]=new globeGrabber(x,y,w,h,midiNote,midiMix,deInt);
- }
- XML.popTag();
- XML.popTag();
- }
- }
- */
+ 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 layers loaded!\n");
}
- //if (numLayers==0) printf("no layers loaded!\n");
+
}
midiIn.listPorts();
@@ -69,13 +51,10 @@ void testApp::setup(){
showFPS=false;
ofBackground(0,0,0);
- //drawing.load("test.svg");
- //drawing.fill("0xffffff");
- svg.load("Ag01036x.wmf.svg");
- printf("loaded Ag01036x.wmf.svg: %i paths\n",svg.getNumPath());
- for (int i=0;i<svg.getNumPath();i++) {
- printf("path %i: fill %08x stroke %08x\n",i,svg.getPathAt(i).getFillColor().getHex(),svg.getPathAt(i).getStrokeColor().getHex());
- }
+
+
+ //ofSetVerticalSync(true); deosn't seem effective
+ //glXSwapIntervalSGI(1);
}
//--------------------------------------------------------------
@@ -85,29 +64,29 @@ void testApp::update(){
//--------------------------------------------------------------
void testApp::draw(){
- ofSetColor(255,255,255);
- grab.grabScreen( 0, 0, ofGetWidth(), ofGetHeight() );
- grab.update();
- grab.reloadTexture();
- ofBackground(0,0,0);
- //grab.draw( 1,1);
-
- float notewidth=ofGetWidth()/NUM_NOTES;
- float noteheight=ofGetHeight()/NUM_CONTROLLERS;
-
- 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*notewidth,i*noteheight,notewidth,noteheight);
- }
-
- ofPushMatrix();
- ofScale(sin(ofGetElapsedTimef())+1.1,sin(ofGetElapsedTimef())+1.1);
- svg.draw();
- ofPopMatrix();
-
- //for (int i=0;i<numLayers;i++) layers[i]->draw();
- ofSetColor(255,255,255);
- if (showFPS) ofDrawBitmapString(ofToString(ofGetFrameRate(), 2),20,20);
+ ofSetColor(255,255,255);
+ grab.grabScreen( 0, 0, ofGetWidth(), ofGetHeight() );
+ grab.update();
+ grab.reloadTexture();
+ ofBackground(0,0,0);
+ //grab.draw( 1,1);
+
+ float notewidth=ofGetWidth()/NUM_NOTES;
+ float noteheight=ofGetHeight()/NUM_CONTROLLERS;
+
+ 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*notewidth,i*noteheight,notewidth,noteheight);
+ }
+ ofSetColor((sin(ofGetElapsedTimef())+1)*128,255,255);
+ ofPushMatrix();
+ //ofScale(sin(ofGetElapsedTimef())+1.1,sin(ofGetElapsedTimef())+1.1);
+ if (layers.find(note)!=layers.end()) layers[note]->draw();
+ ofPopMatrix();
+
+ //for (int i=0;i<numLayers;i++) layers[i]->draw();
+ ofSetColor(255,255,255);
+ if (showFPS) ofDrawBitmapString(ofToString(ofGetFrameRate(), 2),20,20);
}