I must have missed something...
- import processing.opengl.*;
- import codeanticode.glgraphics.*;
- import codeanticode.gsvideo.*;
- GSCapture cam;
- GLTexture bottomLayer, topLayer, resultLayer;
- GLTextureFilter blendFilter;
- ScalarParam opacity;
- class ScalarParam {
- float value;
- float minValue;
- float maxValue;
- float step;
- ScalarParam(float v,float mn, float mx, float s) {
- value = v;
- minValue = mn;
- maxValue = mx;
- step = s;
- }
- void Increment() {
- value += step;
- if (value > maxValue) value=maxValue;
- }
- void Decrement() {
- value -= step;
- if (value < minValue) value=minValue;
- }
- }
- void setup()
- {
- size(640, 480, GLConstants.GLGRAPHICS);
- cam = new GSCapture(this, 640, 480);
- blendFilter = new GLTextureFilter(this, "BlendDifference.xml");
- opacity = new ScalarParam(1.0,0.0,1.0,0.01);
- bottomLayer = new GLTexture(this, "background.jpg");
- topLayer = new GLTexture(this);
- cam.setPixelDest(topLayer);
- cam.start();
- resultLayer = new GLTexture(this, topLayer.width,topLayer.height);
- }
- void draw()
- {
- blendFilter.setParameterValue("Opacity", opacity.value);
- blendFilter.apply(new GLTexture[] {bottomLayer, topLayer}, resultLayer);
- resultLayer.render(0, 0);
- //image(resultLayer, 0, 0);
- }
- void keyPressed()
- {
- if (key == CODED) {
- if (keyCode == UP) opacity.Increment();
- else if (keyCode == DOWN) opacity.Decrement();
- }
- }
- void captureEvent(GSCapture cam) {
- cam.read();
- }