Syphon / Processing

Syphon Implementation for Processing
Other
137 stars 33 forks source link

Send screen frame in Processing Syphon #3

Closed codeanticode closed 11 years ago

codeanticode commented 11 years ago

Right now, the frames sent out from Processing when using the SyphonServer object need to be drawn to an offscreen PGraphics buffer. It would be neat to just be able to do:

void draw() {
  background(127);
  lights();
  translate(width/2, height/2);
  rotateX(frameCount * 0.01);
  rotateY(frameCount * 0.01);  
  box(150);
  server.sendScreen();
}

This requires the server object getting the internal back buffer that the renderer uses to draw the main screen to. It is certainly possible, since this is what the filter(PShader) method does under the scenes.

[ported from issue report in googlecode: https://code.google.com/p/syphon-implementations/issues/detail?id=27]

vade commented 11 years ago

We do this in the Quartz Composer plugin, using glCopyTexImage2D to get the current read buffer's content into a texture. Something similar should be possible with direct to context drawing, no?

https://github.com/Syphon/Quartz-Composer/blob/master/SyphonQC/SyphonQC/SyphonServerQCPlugIn.m#L223

vade commented 11 years ago

(note that code incorrectly assumes GL_FRONT is the right read buffer but, fwiw, the technique is sound)

codeanticode commented 11 years ago

Yes I agree, thanks for the link, I will try to add this functionality for the 1.0 release.

codeanticode commented 11 years ago

Implemented in https://github.com/Syphon/Processing/commit/fc8ea6541d432091572d5db3f7c35fd6fc07d37d