@@ -13,26 +13,21 @@ void ofApp::setup(){
13
13
}
14
14
#endif
15
15
16
- backgroundImage.loadImage (" A.jpg" );
17
- foregroundImage.loadImage (" B.jpg" );
18
- brushImage.loadImage (" brush.png" );
16
+ backgroundImage.load (" A.jpg" );
17
+ foregroundImage.load (" B.jpg" );
18
+ brushImage.load (" brush.png" );
19
19
20
20
int width = backgroundImage.getWidth ();
21
21
int height = backgroundImage.getHeight ();
22
22
23
23
maskFbo.allocate (width, height);
24
- fbo.allocate (width, height);
25
24
26
25
// Clear the FBO's
27
26
// otherwise it will bring some junk with it from the memory
28
27
maskFbo.begin ();
29
28
ofClear (0 ,0 ,0 ,255 );
30
29
maskFbo.end ();
31
-
32
- fbo.begin ();
33
- ofClear (0 ,0 ,0 ,255 );
34
- fbo.end ();
35
-
30
+
36
31
bBrushDown = false ;
37
32
}
38
33
@@ -61,26 +56,17 @@ void ofApp::draw(){
61
56
62
57
// ----------------------------------------------------------
63
58
// HERE the shader-masking happends
64
- fbo.begin ();
65
- // Cleaning everthing with alpha mask on 0 in order to make it transparent by default
66
- ofClear (0 , 0 , 0 , 0 );
67
-
59
+
68
60
shader.begin ();
69
61
// here is where the fbo is passed to the shader
70
- shader.setUniformTexture (" maskTex" , maskFbo.getTextureReference (), 1 );
71
-
72
- backgroundImage.draw (0 , 0 );
62
+ shader.setUniformTexture (" maskTex" , maskFbo.getTexture (), 1 );
63
+ shader.setUniformTexture (" foregroundTex" , foregroundImage.getTexture (), 2 );
64
+
65
+ backgroundImage.draw (0 , 0 );
73
66
74
67
shader.end ();
75
- fbo.end ();
76
-
77
- // ----------------------------------------------------------
78
- // FIRST draw the background image
79
- foregroundImage.draw (0 ,0 );
80
-
81
- // THEN draw the masked fbo on top
82
- fbo.draw (0 ,0 );
83
-
68
+
69
+
84
70
// ----------------------------------------------------------
85
71
ofDrawBitmapString (" Drag the Mouse to draw" , 15 ,15 );
86
72
ofDrawBitmapString (" Press spacebar to clear" , 15 , 30 );
0 commit comments