// By Scott Brown 12 October 2009 // http://kodama.angrypixel.org // // Multi-screen output from Andres Colubri's 'TextureWindow' import processing.opengl.*; import codeanticode.glgraphics.*; import codeanticode.gsvideo.*; GLTexture _sample, _fx01, _fx02, _fx03, _fx04, _fx05, _fx06; GLTextureFilter posterize, gaussBlur, pixelate, edgeDetect, pulseEmboss, extractBloom; GLTextureWindow texWin; GSCapture cam; PImage sample; PFont font; boolean cam01 = false; boolean cam02 = false; boolean fx01 = false; boolean fx02 = false; boolean fx03 = false; boolean fx04 = false; boolean fx05 = false; boolean fx06 = false; void setup() { size(1100, 850, GLConstants.GLGRAPHICS); background(175); // Images sample = loadImage("sample.jpg"); _sample = new GLTexture(this, "sample.jpg"); _fx01 = new GLTexture(this, _sample.width, _sample.height); _fx02 = new GLTexture(this, _sample.width, _sample.height); _fx03 = new GLTexture(this, _sample.width, _sample.height); _fx04 = new GLTexture(this, _sample.width, _sample.height); _fx05 = new GLTexture(this, _sample.width, _sample.height); _fx06 = new GLTexture(this, _sample.width, _sample.height); // Filters posterize = new GLTextureFilter(this, "posterize.xml"); gaussBlur = new GLTextureFilter(this, "gaussBlur.xml"); pixelate = new GLTextureFilter(this, "pixelate.xml"); edgeDetect = new GLTextureFilter(this, "edgeDetect.xml"); pulseEmboss = new GLTextureFilter(this, "pulsatingEmboss.xml"); extractBloom = new GLTextureFilter(this, "ExtractBloom.xml"); // For labels font = loadFont("Helvetica-18.vlw"); textFont(font); // Start camera cam = new GSCapture(this, 400, 300); // The window is located at (0, 0) and has a size of (400, 400). // Important: the texture window has be be created before creating any // texture, filter or any other OpenGL-related element. texWin = new GLTextureWindow(this, 0, 0, 400, 300); // A call to init() is required at the end of setup. texWin.init(); // If setting the override property of the texture window to // false, then it won't be drawn automatically. In this case, // it can be manually updated after the main draw is finished // using the post event (uncomment the post() function at the // bottom of this example): texWin.setOverride(true); registerPost(this); } void draw() { noStroke(); noFill(); // Camera windows if (cam01) { fill(255, 0, 0); rect(98, 48, 404, 304); text("Camera 01", 100, 370); } else { fill(0); rect(98, 48, 404, 304); text("Camera 01", 100, 370); } if (cam02) { fill(255, 0, 0); rect(98, 398, 404, 304); text("Camera 02", 100, 720); } else { fill(0); rect(98, 398, 404, 304); text("Camera 02", 100, 720); } // Effect windows fill(0); rect(598, 48, 404, 304); text("Effect Ouput", 600, 370); _sample.filter(posterize, _fx01); _sample.filter(gaussBlur, _fx02); _sample.filter(pixelate, _fx03); _sample.filter(edgeDetect, _fx04); _sample.filter(pulseEmboss, _fx05); _sample.filter(extractBloom, _fx06); if (fx01) { fill(255, 0, 0); rect(598, 423, 104, 104); text("Posterize", 600, 545); _fx01.render(600, 425, 100, 100); } else { fill(0); rect(598, 423, 104, 104); text("Posterize", 600, 545); _fx01.render(600, 425, 100, 100); } if (fx02) { fill(255, 0, 0); rect(748, 423, 104, 104); text("Gauss Blur", 750, 545); _fx02.render(750, 425, 100, 100); } else { fill(0); rect(748, 423, 104, 104); text("Gauss Blur", 750, 545); _fx02.render(750, 425, 100, 100); } if (fx03) { fill(255, 0, 0); rect(898, 423, 104, 104); text("Pixelate", 900, 545); _fx03.render(900, 425, 100, 100); } else { fill(0); rect(898, 423, 104, 104); text("Pixelate", 900, 545); _fx03.render(900, 425, 100, 100); } if (fx04) { fill(255, 0, 0); rect(598, 573, 104, 104); text("Edge Detect", 600, 695); _fx04.render(600, 575, 100, 100); } else { fill(0); rect(598, 573, 104, 104); text("Edge Detect", 600, 695); _fx04.render(600, 575, 100, 100); } if (fx05) { fill(255, 0, 0); rect(748, 573, 104, 104); text("Pulse Emboss", 750, 695); _fx05.render(750, 575, 100, 100); } else { fill(0); rect(748, 573, 104, 104); text("Pulse Emboss", 750, 695); _fx05.render(750, 575, 100, 100); } if (fx06) { fill(255, 0, 0); rect(898, 573, 104, 104); text("Bloom", 900, 695); _fx06.render(900, 575, 100, 100); } else { fill(0); rect(898, 573, 104, 104); text("Bloom", 900, 695); _fx06.render(900, 575, 100, 100); } // Slider stroke(0); strokeWeight(3); line(100, 775, 1000, 775); if (cam.available() == true) { cam.read(); set(100, 50, cam); } } void mousePressed() { if (mouseX > 100 && mouseX < 500 && mouseY > 50 && mouseY < 350 && mousePressed) { cam01 = !cam01; if (cam01) { cam02 = false; } } if (mouseX > 100 && mouseX < 500 && mouseY > 400 && mouseY < 700 && mousePressed) { cam02 = !cam02; if (cam02) { cam01 = false; } } if (mouseX > 600 && mouseX < 700 && mouseY > 425 && mouseY < 525 && mousePressed) { fx01 = !fx01; } if (mouseX > 750 && mouseX < 850 && mouseY > 425 && mouseY < 525 && mousePressed) { fx02 = !fx02; } if (mouseX > 900 && mouseX < 1000 && mouseY > 425 && mouseY < 525 && mousePressed) { fx03 = !fx03; } if (mouseX > 600 && mouseX < 700 && mouseY > 575 && mouseY < 675 && mousePressed) { fx04 = !fx04; } if (mouseX > 750 && mouseX < 850 && mouseY > 575 && mouseY < 675 && mousePressed) { fx05 = !fx05; } if (mouseX > 900 && mouseX < 1000 && mouseY > 575 && mouseY < 675 && mousePressed) { fx06 = !fx06; } } void post() { texWin.render(); }