From 983d4a8a596a680edc9a1bc78a6b5b61b6486be5 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Wed, 12 Dec 2018 01:17:00 +0000 Subject: mame vector receiver --- oscReceiveExample/src/main.cpp | 14 ++ oscReceiveExample/src/ofApp.cpp | 282 ++++++++++++++++++++++++++++++++++++++++ oscReceiveExample/src/ofApp.h | 50 +++++++ 3 files changed, 346 insertions(+) create mode 100644 oscReceiveExample/src/main.cpp create mode 100644 oscReceiveExample/src/ofApp.cpp create mode 100644 oscReceiveExample/src/ofApp.h (limited to 'oscReceiveExample/src') diff --git a/oscReceiveExample/src/main.cpp b/oscReceiveExample/src/main.cpp new file mode 100644 index 0000000..b156efd --- /dev/null +++ b/oscReceiveExample/src/main.cpp @@ -0,0 +1,14 @@ +#include "ofMain.h" +#include "ofApp.h" + +//======================================================================== +int main( ){ + + ofSetupOpenGL(640,480, OF_WINDOW); // <-------- setup the GL context + + // this kicks off the running of my app + // can be OF_WINDOW or OF_FULLSCREEN + // pass in width and height too: + ofRunApp( new ofApp()); + +} diff --git a/oscReceiveExample/src/ofApp.cpp b/oscReceiveExample/src/ofApp.cpp new file mode 100644 index 0000000..b7dbc8f --- /dev/null +++ b/oscReceiveExample/src/ofApp.cpp @@ -0,0 +1,282 @@ +#include "ofApp.h" + +//-------------------------------------------------------------- +void ofApp::setup(){ + // listen on the given port + cout << "listening for osc messages on port " << PORT << "\n"; + receiver.setup(PORT); + +/* + ofxUDPSettings settings; + settings.receiveOn(PORT); + settings.blocking = false; + + udpConnection.Setup(settings); +*/ + current_msg_string = 0; + mouseX = 0; + mouseY = 0; + mouseButtonState = ""; + + ofSetWindowTitle("osc receiver"); + + poly.clear(); + + //ofSetFrameRate(50); + + copy_polys=1000; + create_polys=0; + + ofSetFrameRate(60); +} + +//-------------------------------------------------------------- +void ofApp::update(){ + + // hide old messages + for(int i = 0; i < NUM_MSG_STRINGS; i++){ + if(timers[i] < ofGetElapsedTimef()){ + msg_strings[i] = ""; + } + } + + int received_frames=0; + int dumped_frames=0; + + int numpoints=0; + ofBuffer buf; + + // check for waiting messages + while(receiver.hasWaitingMessages()){ + + // get the next message + ofxOscMessage m; + receiver.getNextMessage(m); + + //cout << "got a message " << m.getAddress() << " args: "<< m.getNumArgs() << std::endl;; + + if(m.getAddress() == "/points"){ + // both the arguments are float's + + + + //for (int i=0;i': + create_polys+=10; + break; + } + +} + +//-------------------------------------------------------------- +void ofApp::keyReleased(int key){ + +} + +//-------------------------------------------------------------- +void ofApp::mouseMoved(int x, int y){ + +} + +//-------------------------------------------------------------- +void ofApp::mouseDragged(int x, int y, int button){ + +} + +//-------------------------------------------------------------- +void ofApp::mousePressed(int x, int y, int button){ +} + +//-------------------------------------------------------------- +void ofApp::mouseReleased(int x, int y, int button){ + +} + +//-------------------------------------------------------------- +void ofApp::mouseEntered(int x, int y){ + +} + +//-------------------------------------------------------------- +void ofApp::mouseExited(int x, int y){ + +} + +//-------------------------------------------------------------- +void ofApp::windowResized(int w, int h){ + +} + +//-------------------------------------------------------------- +void ofApp::gotMessage(ofMessage msg){ + +} + +//-------------------------------------------------------------- +void ofApp::dragEvent(ofDragInfo dragInfo){ + +} diff --git a/oscReceiveExample/src/ofApp.h b/oscReceiveExample/src/ofApp.h new file mode 100644 index 0000000..bc91852 --- /dev/null +++ b/oscReceiveExample/src/ofApp.h @@ -0,0 +1,50 @@ +#pragma once + +#include "ofMain.h" +#include "ofxOsc.h" +#include "colourPolyline.h" + +#define PORT 7070 +#define NUM_MSG_STRINGS 20 + +class ofApp : public ofBaseApp { + public: + + void setup(); + void update(); + void draw(); + ~ofApp(){ + receiver.stop(); + } + + void keyPressed(int key); + void keyReleased(int key); + void mouseMoved(int x, int y); + void mouseDragged(int x, int y, int button); + void mousePressed(int x, int y, int button); + void mouseReleased(int x, int y, int button); + void mouseEntered(int x, int y); + void mouseExited(int x, int y); + void windowResized(int w, int h); + void dragEvent(ofDragInfo dragInfo); + void gotMessage(ofMessage msg); + + ofTrueTypeFont font; + ofxOscReceiver receiver; + + int current_msg_string; + string msg_strings[NUM_MSG_STRINGS]; + float timers[NUM_MSG_STRINGS]; + + float mouseXf, mouseYf; + int mouseButtonInt; + string mouseButtonState; + + ofImage receivedImage; + colourPolyline poly; + + string stats_message; + + int copy_polys; + int create_polys; +}; -- cgit v1.2.3