ruby-processing syphon support
in
Processing with Other Languages
•
1 year ago
syphon is a library for sharing opengl content between apps on mac.
i want to include syphon for java in my ruby-processing sketches.
however i have trouble to do so as its pretty beta right now to do anything in java with syphon.
syphon.jar and other files taken from the jsyphon library of the syphon-implementations google code site.
get the files from andres' link to a
zip file posted further up here earlier.
To get the jsyphon package recognized by processing, create the following folder structure inside your contributes libraries folder, which is located inside your sketchbook.
~/Documents/Processing/libraries/
jsyphon/
library/
jsyphon.jar
libJSyphon.jnilib
Syphon.framework
here the processing code:
- import javax.media.opengl.*;
- import processing.opengl.*;
- import jsyphon.*; // Syphon
- JSyphonServer mySyphon;
- PGraphicsOpenGL pgl;
- GL gl;
- int[] texID;
- float col=0;
- float rot=0;
- float len=0;
- void setup() {
- frameRate(240);
- size(600,600, OPENGL);
- pgl = (PGraphicsOpenGL) g;
- gl = pgl.gl;
- initSyphon(gl,"processing");
- strokeWeight(0.5);
- //stroke(255, 50);
- noStroke();
- background(0);
- col=random(100);
- }
- void draw() {
- colorMode(HSB,100);
- col=col+random(-5,5);
- col=constrain(col,0,100);
- rot+=0.03;
- len=len+(noise(millis()/100)-0.5)*20;
- len=constrain(len,50,width/2);
- stroke(col,100,100,100);
- //blend(0,0,width,height,0,0,width,height,DIFFERENCE);
- pushMatrix();
- translate(width/2,height/2);
- rotate(rot);
- line(sin(millis()/1000)*100+50,0,len,0);
- popMatrix();
- //ellipse(width-((width/100)*col),col,50,50);
- 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.");
- }
from
here
however i don't know how to do this in ruby-processing.
i know it should be possible.
can anybody help on this matter?
1