We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello all,
I try to send to the syphon an image with a particular background with transparency and in my case I use camera too. But I have a problem with the background when I use the syphon library. I prepare a code to understand the problem, but the problem stay and i don't find the solution. To illustrate the problem i make a boolean with syphon and other one without syphon. I test with Processing 2.0.3 and 2.1, on mac 10.7.5.
//SYPHON
import codeanticode.syphon.*;
PGraphics miroir ;
SyphonServer server ;
boolean syphon ;
void setup() {
size(800,800,P3D) ;
// Create syhpon server to send frames out.
backgroundP3Dsetup() ;
miroir = createGraphics(800, 800, P3D);
server = new SyphonServer(this, "Processing Syphon");
}
int c ;
int deep ;
void draw() {
c += 1 ;
if (c>255) c = 0 ;
color colorBG = color(c, 10) ;
deep += 10 ;
if(deep>500) deep = -500 ;
//to activate the syphon or not
syphon = true ;
if(syphon) {
println("Syphon on") ;
//syphon
miroir.beginDraw() ;
//background
backgroundSyphonP3D(colorBG) ;
//camera
pushMatrix() ;
miroir.camera() ;
miroir.beginCamera() ;
//transformation
miroir.translate(width/2, height/2,deep) ;
miroir.rotateX(radians(mouseY)) ;
miroir.rotateY(radians(mouseX)) ;
//drawing
miroir.strokeWeight(1) ;
miroir.stroke(255) ;
miroir.fill(0) ;
miroir.box(200) ;
//camera stop
popMatrix() ;
miroir.endCamera() ;
//syphon stop
miroir.endDraw() ;
//display the result
image(miroir,0,0) ;
//send to syphon
server.sendImage(miroir);
} else {
println("Syphon off") ;
//background
backgroundP3D(colorBG) ;
//camera
pushMatrix() ;
camera() ;
beginCamera() ;
//tranformation
translate(width/2, height/2,deep) ;
rotateX(radians(mouseY)) ;
rotateY(radians(mouseX)) ;
//drawing
strokeWeight(1) ;
stroke(255) ;
fill(0) ;
box(200) ;
//stop camera
popMatrix() ;
endCamera() ;
}
}
//P3D
//BACKGROUND
////////////
PVector sizeBG ;
void backgroundP3Dsetup() {
float ratio = 100 ;
sizeBG = new PVector(width *ratio, height *ratio, height *7) ;
}
//syphon background
void backgroundSyphonP3D(color c) {
miroir.fill(c) ;
miroir.noStroke() ;
pushMatrix() ;
miroir.translate(-sizeBG.x *.5,-sizeBG.y *.5 , -sizeBG.z) ;
miroir.rect(0,0, sizeBG.x,sizeBG.y) ;
popMatrix() ;
}
//classic
void backgroundP3D(color c) {
fill(c) ;
noStroke() ;
pushMatrix() ;
translate(-sizeBG.x *.5,-sizeBG.y *.5 , -sizeBG.z) ;
rect(0,0, sizeBG.x,sizeBG.y) ;
popMatrix() ;
}
Answers
The problem with the syphon code is that you are not calling push/popMatrix on the PGraphics object:
Thanks for the answer, sorry I'm very late to answer, but I don't receive notification from the forum. The problem is resolve now.