Syphon

edited October 2013 in Library Questions

Hello, I try to fiobd a way to use Syphon with processing 203, I find this solution on the old Forum

` import javax.media.opengl.GL2; import jsyphon.*;

class SyphonServer2{ protected JSyphonServer syphon; protected GL2 gl; protected int[] texID; protected int[] syphonFBO;

public SyphonServer2(String name){ syphon = new JSyphonServer(); syphon.initWithName(name); println("Starting the syphon server:"+name); try { gl = ((PGraphicsOpenGL)g).pgl.gl.getGL2(); } catch (javax.media.opengl.GLException e) { println("OpenGL 2 not supported!"); }

texID = new int[1];
gl.glGenTextures(1, texID, 0);
gl.glBindTexture(GL2.GL_TEXTURE_RECTANGLE, texID[0]);
gl.glTexImage2D(GL2.GL_TEXTURE_RECTANGLE, 0, GL2.GL_RGBA8, width, height, 0, GL2.GL_RGBA, GL2.GL_UNSIGNED_BYTE, null);

int[] defaultFBO = new int[1];
gl.glGetIntegerv(GL2.GL_FRAMEBUFFER_BINDING, defaultFBO, 0);

syphonFBO = new int[1];
gl.glGenFramebuffers(1, syphonFBO, 0);
gl.glBindFramebuffer(GL2.GL_FRAMEBUFFER, syphonFBO[0]);
gl.glFramebufferTexture2D(GL2.GL_FRAMEBUFFER, GL2.GL_COLOR_ATTACHMENT0, GL2.GL_TEXTURE_RECTANGLE, texID[0], 0);
gl.glBindFramebuffer(GL2.GL_FRAMEBUFFER, defaultFBO[0]);

}

public void send(){ int[] defaultFBO = new int[1]; gl.glGetIntegerv(GL2.GL_FRAMEBUFFER_BINDING, defaultFBO, 0); //println("fbo="+defaultFBO[0]);

gl.glBindFramebuffer(GL2.GL_READ_FRAMEBUFFER, defaultFBO[0]);
gl.glBindFramebuffer(GL2.GL_DRAW_FRAMEBUFFER, syphonFBO[0]);
gl.glBlitFramebuffer(0, 0, width, height, 
                     0, 0, width, height, 
                     GL2.GL_COLOR_BUFFER_BIT, GL2.GL_LINEAR);

syphon.publishFrameTexture(texID[0], GL2.GL_TEXTURE_RECTANGLE, 0, 0, width, height, width, height, false);
gl.glBindFramebuffer(GL2.GL_FRAMEBUFFER, defaultFBO[0]);

}

public void stop(){ println("deleting textures"); gl.glDeleteTextures(1, texID, 0); gl.glDeleteFramebuffers(1, syphonFBO, 0); if(syphon!=null) { println("stopping the syphon server"); syphon.stop(); } } } SyphonServer2 syphon;

void setup() {

size(300,300) ;

syphon = new SyphonServer2("Test server"); }

int bg ; void draw() {

bg += 1 ; if (bg > 250) bg = 30 ; syphon.fill(bg) ; syphon.rect(0,0,width, height) ;

syphon.send(); }

void dispose() { syphon.stop(); } `

But that's don't work with fill() the debuger say fill(int) is undefined fo the type sketchName.SyphonServer2

and when I comment the line Syphon.fill() and syphon.rect(,,,) the debuger write ClassCastException processingCore/JAVA2D Cannot be cast to processing.openGL.PGraphic2DOpenGL. gl cannot be resolved to a variable

So if anybody have an idea.

Thanks

Tagged:

Comments

Sign In or Register to comment.