Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
No results found
Show changes
#include "ofMain.h"
#include "ofApp.h"
//========================================================================
int main( ){
ofSetupOpenGL(1024,768,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());
}
#include "ofApp.h"
//--------------------------------------------------------------
void ofApp::setup(){
receiver.setup ( PORT );
rv.setup(ofRectangle(0,0,1024,768));
current_msg_string = 0;
ofBackground(30, 30, 30);
}
//--------------------------------------------------------------
void ofApp::update(){
static float a = 0;
while( receiver.hasWaitingMessages() )
{
ofxOscMessage m;
receiver.getNextMessage(m);
std::string address = m.getAddress();
std::vector<double> values;
for ( int i=0; i<m.getNumArgs(); i++ )
{
double value = 0.0;
// display the argument - make sure we get the right type
if( m.getArgType( i ) == OFXOSC_TYPE_INT32 )
value = static_cast<double>( m.getArgAsInt32( i ) );
else if( m.getArgType( i ) == OFXOSC_TYPE_INT64 )
value = static_cast<double>( m.getArgAsInt64( i ) );
else if( m.getArgType( i ) == OFXOSC_TYPE_FLOAT )
value = static_cast<double>( m.getArgAsFloat( i ) );
else if( m.getArgType( i ) == OFXOSC_TYPE_DOUBLE)
value = static_cast<double>( m.getArgAsDouble( i ) );
else
printf("Unknown datatype\n");
values.push_back(value);
}
rv.addData(address, values);
}
rv.update();
}
//--------------------------------------------------------------
void ofApp::draw(){
ofBackgroundGradient(ofColor(0,0,0), ofColor(10,10,10));
rv.draw();
}
//--------------------------------------------------------------
void ofApp::keyPressed(int key){
if(key == 'h'){
guiHide = !guiHide;
rv.setGuiHidden(guiHide);
}
if(key == 'c'){
rv.reset();
}
if(key == 'm'){
// Show main menu
}
}
//--------------------------------------------------------------
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){
rv.setSize(ofVec2f(w, h));
}
//--------------------------------------------------------------
void ofApp::gotMessage(ofMessage msg){
}
//--------------------------------------------------------------
void ofApp::dragEvent(ofDragInfo dragInfo){
}
#pragma once
#include "ofMain.h"
#include "ofxOsc.h"
#include "RapidVisualization.hpp"
#define PORT 8338
#define NUM_MSG_STRINGS 20
class ofApp : public ofBaseApp{
public:
void setup();
void update();
void draw();
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);
private:
bool guiHide = false;
RapidVisualization rv;
ofxOscReceiver receiver;
int current_msg_string;
std::string msg_strings[NUM_MSG_STRINGS];
float timers[NUM_MSG_STRINGS];
};