summaryrefslogtreecommitdiff
path: root/keyshade/src/ofApp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'keyshade/src/ofApp.cpp')
-rw-r--r--keyshade/src/ofApp.cpp102
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){
+
+}