summaryrefslogtreecommitdiff
path: root/liveengine/src
diff options
context:
space:
mode:
Diffstat (limited to 'liveengine/src')
-rw-r--r--liveengine/src/layers.cpp43
-rw-r--r--liveengine/src/layers.h31
-rwxr-xr-xliveengine/src/testApp.cpp97
-rwxr-xr-xliveengine/src/testApp.h12
4 files changed, 121 insertions, 62 deletions
diff --git a/liveengine/src/layers.cpp b/liveengine/src/layers.cpp
new file mode 100644
index 0000000..dbf6ccd
--- /dev/null
+++ b/liveengine/src/layers.cpp
@@ -0,0 +1,43 @@
+#include "layers.h"
+
+layer::layer() {}
+layer::layer(string _f)
+{
+ load(_f);
+}
+
+void layer::load(string _f){
+}
+
+void layer::draw() {
+
+}
+
+layer::~layer()
+{
+ //dtor
+}
+
+
+svglayer::svglayer() {}
+svglayer::svglayer(string _f)
+{
+ load(_f);
+}
+
+void svglayer::load(string _f){
+ svg.load(_f);
+ printf("%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());
+ }
+}
+
+void svglayer::draw() {
+ svg.draw();
+}
+
+svglayer::~svglayer()
+{
+ //dtor
+}
diff --git a/liveengine/src/layers.h b/liveengine/src/layers.h
new file mode 100644
index 0000000..e3b0fd8
--- /dev/null
+++ b/liveengine/src/layers.h
@@ -0,0 +1,31 @@
+#ifndef SVGLAYER_H
+#define SVGLAYER_H
+
+#include "ofxSVGTiny.h"
+
+class layer
+{
+ public:
+ layer();
+ layer(string _f);
+ virtual ~layer();
+ virtual void load(string _f);
+ virtual void draw();
+ protected:
+ private:
+};
+
+class svglayer: public layer
+{
+ public:
+ svglayer();
+ svglayer(string _f);
+ virtual ~svglayer();
+ void load(string _f);
+ void draw();
+ protected:
+ private:
+ ofxSVGTiny svg;
+};
+
+#endif // SVGLAYER_H
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);
}
diff --git a/liveengine/src/testApp.h b/liveengine/src/testApp.h
index 57458fd..0ad4dc3 100755
--- a/liveengine/src/testApp.h
+++ b/liveengine/src/testApp.h
@@ -1,5 +1,7 @@
#pragma once
+//#include <GL/glxew.h>
+
#include "ofMain.h"
#include "ofxXmlSettings.h"
@@ -54,7 +56,12 @@ can draw
#include "ofxMidi.h"
-#include "ofxSVGTiny.h"
+
+
+#include "layers.h"
+
+
+
class testApp : public ofBaseApp, public ofxMidiListener{
@@ -91,7 +98,6 @@ class testApp : public ofBaseApp, public ofxMidiListener{
void newMidiMessage(ofxMidiEventArgs& eventArgs);
- //ofxSVG drawing;
- ofxSVGTiny svg;
+ map<int,layer*> layers;
};