this is what I used 2 years ago with Processing 1.5.1, it does still works with that version but not with v.2.
Don't know why...
you can then use any Syphon client anywhere:
import javax.media.opengl.;
import processing.opengl.;
import jsyphon.*; // Syphon
JSyphonServer mySyphon;
PGraphicsOpenGL pgl;
GL gl;
int[] texID;
void setup() {
size(640, 480, OPENGL);
pgl = (PGraphicsOpenGL) g;
gl = pgl.gl;
initSyphon(gl,"processing");
strokeWeight(0.5);
stroke(255, 50);
background(0);
}
void draw() {
line(width/2, height/2, random(0, width), random(0, height));
renderTexture(pgl.gl);
}
void initSyphon(GL gl, String theName) {
if(mySyphon!=null) {
mySyphon.stop();
}
mySyphon = new JSyphonServer();
mySyphon.test();
mySyphon.initWithName(theName);
// copy to texture, to send to Syphon.
texID = new int[1];
gl.glGenTextures(1, texID, 0);
gl.glBindTexture(gl.GL_TEXTURE_RECTANGLE_EXT, texID[0]);
gl.glTexImage2D(gl.GL_TEXTURE_RECTANGLE_EXT, 0, gl.GL_RGBA8, width, height, 0, gl.GL_RGBA, gl.GL_UNSIGNED_BYTE, null);
}
void renderTexture(GL gl) {
gl.glBindTexture(gl.GL_TEXTURE_RECTANGLE_EXT, texID[0]);
gl.glCopyTexSubImage2D(gl.GL_TEXTURE_RECTANGLE_EXT, 0, 0, 0, 0, 0, width, height);
mySyphon.publishFrameTexture(texID[0], gl.GL_TEXTURE_RECTANGLE_EXT, 0, 0, width, height, width, height, false);
}
public void stop() {
dispose();
}
void dispose() {
println("\n\nabout to stop sketch ...");
println("deleting textures");
gl.glDeleteTextures(1, texID, 0);
if(mySyphon!=null) {
println("stopping the syphon server");
mySyphon.stop();
}
println("sketch stopped, done.");
}