topical media & game development
lib-of-vs-addons-ofxOsc-examples-oscSenderExample-src-testApp.cpp / cpp
include <testApp.h>
//--------------------------------------------------------------
void testApp::setup(){
ofBackground( 40, 100, 40 );
// open an outgoing connection to HOST:PORT
sender.setup( HOST, PORT );
}
//--------------------------------------------------------------
void testApp::update(){
}
//--------------------------------------------------------------
void testApp::draw(){
// display instructions
string buf;
buf = "sending osc messages to" + string( HOST ) + ofToString( PORT );
ofDrawBitmapString( buf, 10, 20 );
ofDrawBitmapString( "move the mouse to send osc message [/mouse/position <x> <y>]", 10, 50 );
ofDrawBitmapString( "click to send osc message [/mouse/button <button> <\"up\"|\"down\">]", 10, 65 );
ofDrawBitmapString( "press A to send osc message [/test 1 3.5 hello <time>]", 10, 80 );
}
//--------------------------------------------------------------
void testApp::keyPressed (int key){
if ( key =='a' || key == 'A' )
{
ofxOscMessage m;
m.setAddress( "/test" );
m.addIntArg( 1 );
m.addFloatArg( 3.5f );
m.addStringArg( "hello" );
m.addFloatArg( ofGetElapsedTimef() );
sender.sendMessage( m );
}
}
//--------------------------------------------------------------
void testApp::mouseMoved(int x, int y ){
ofxOscMessage m;
m.setAddress( "/mouse/position" );
m.addIntArg( x );
m.addIntArg( y );
sender.sendMessage( m );
}
//--------------------------------------------------------------
void testApp::mouseDragged(int x, int y, int button){
}
//--------------------------------------------------------------
void testApp::mousePressed(int x, int y, int button){
ofxOscMessage m;
m.setAddress( "/mouse/button" );
m.addStringArg( "down" );
sender.sendMessage( m );
}
//--------------------------------------------------------------
void testApp::mouseReleased(int x, int y, int button){
ofxOscMessage m;
m.setAddress( "/mouse/button" );
m.addStringArg( "up" );
sender.sendMessage( m );
}
//--------------------------------------------------------------
void testApp::windowResized(int w, int h){
}
(C) Æliens
04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.