#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup(){ shader.load("shader"); backgroundImage.load("../../../gui/bin/data/funfair/IMG_2893.JPG"); foregroundImage.load("../../../gui/bin/data/funfair/IMG_2890.JPG"); maskFbo.allocate(ofGetWidth(), ofGetHeight()); // Clear the FBO's // otherwise it will bring some junk with it from the memory maskFbo.begin(); ofClear(0,0,0,255); maskFbo.end(); keyMinDist=0.1f; keyMaxDist=0.2f; keyColour=ofColor(200,40,0); } //-------------------------------------------------------------- void ofApp::update(){ } //-------------------------------------------------------------- void ofApp::draw(){ ofSetColor(255); //better to scale first then mask, or visa versa? shader.begin(); shader.setUniform4f("keyColour",keyColour); shader.setUniform1f("keyMinDist",keyMinDist); shader.setUniform1f("keyMaxDist",keyMaxDist); shader.setUniform1f("time",2.0f+sin(ofGetElapsedTimef())); shader.setUniformTexture("backgroundTex", backgroundImage.getTexture(), 1 ); shader.setUniformTexture("foregroundTex", foregroundImage.getTexture(), 2 ); foregroundImage.draw(0, 0,ofGetWidth(),ofGetHeight()); //seems to make no difference if we draw foreground or background image shader.end(); } //-------------------------------------------------------------- void ofApp::keyPressed(int key){ } //-------------------------------------------------------------- void ofApp::keyReleased(int key){ } //-------------------------------------------------------------- void ofApp::mouseMoved(int x, int y ){ } //-------------------------------------------------------------- void ofApp::mouseDragged(int x, int y, int button){ } //-------------------------------------------------------------- void ofApp::mousePressed(int x, int y, int button){ keyColour = foregroundImage.getColor( x*(foregroundImage.getWidth()/ofGetWidth()), y*(foregroundImage.getHeight()/ofGetHeight()) ); } //-------------------------------------------------------------- void ofApp::mouseReleased(int x, int y, int button){ } //-------------------------------------------------------------- void ofApp::mouseEntered(int x, int y){ } //-------------------------------------------------------------- void ofApp::mouseExited(int x, int y){ } //-------------------------------------------------------------- void ofApp::windowResized(int w, int h){ } //-------------------------------------------------------------- void ofApp::gotMessage(ofMessage msg){ } //-------------------------------------------------------------- void ofApp::dragEvent(ofDragInfo dragInfo){ }