summaryrefslogtreecommitdiff
path: root/keyshade/src/ofApp.cpp
blob: 588557a4b87d0122a4da0f28e0dd1783a60496ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#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 );

	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 = 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){ 

}