diff options
| author | Tim Redfern <tim@getdrop.com> | 2017-10-16 16:24:04 +0100 |
|---|---|---|
| committer | Tim Redfern <tim@getdrop.com> | 2017-10-16 16:24:04 +0100 |
| commit | a3c99df80c201e56a32eb5fe650d45e9a9ccaee2 (patch) | |
| tree | 5e070309793bf11d04e05919a3fb07b1e1157f62 /keyshade/src/ofApp.cpp | |
| parent | 5116dea8815de81ddaef299fdcae15f56ae3a87b (diff) | |
shader compiles
Diffstat (limited to 'keyshade/src/ofApp.cpp')
| -rw-r--r-- | keyshade/src/ofApp.cpp | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/keyshade/src/ofApp.cpp b/keyshade/src/ofApp.cpp new file mode 100644 index 0000000..9adae87 --- /dev/null +++ b/keyshade/src/ofApp.cpp @@ -0,0 +1,102 @@ +#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_2894.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.2f; + keyMaxDist=0.3f; + 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.setUniform4f("keyMaxDist",keyMaxDist); + shader.setUniformTexture("backgroundTex", backgroundImage.getTexture(), 1 ); + shader.setUniformTexture("foregroundTex", foregroundImage.getTexture(), 2 ); + + backgroundImage.draw(0, 0,ofGetWidth(),ofGetHeight()); + + 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 = backgroundImage.getColor( + x*(backgroundImage.getWidth()/ofGetWidth()), + y*(backgroundImage.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){ + +} |
