Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

TODO: freacking bug assigning ids at patchs

  • Loading branch information...
commit 28d43246bcf6633cbdb8eb9ef1c2f8f51dc4f660 1 parent c643762
Patricio Gonzalez Vivo authored
36 src/ofxComposer.cpp
@@ -23,6 +23,8 @@ string helpScreen = "\n \
23 23 - r: reset mask path\n \
24 24 \n \
25 25 - F4: Reset surface coorners\n \
  26 + - F5: Add ofxGLEditor (temporal!!!)\n \
  27 + - F6: Add ofVideoGrabber (temporal!!!)\n \
26 28 - F7: Turn ON/OFF the fullscreen-mode\n \
27 29 \n \
28 30 Mouse and Coorners: \n \
@@ -91,10 +93,10 @@ void ofxComposer::load(string _fileConfig){
91 93 nPatch->setTexture( editorFbo.getTextureReference(), 0);
92 94 bGLEditorPatch = true;
93 95 }
94   -
  96 + /*
95 97 if (nPatch->getType() == "input"){
96 98 nPatch->setTexture( editorFbo.getTextureReference(), 0);
97   - }
  99 + }*/
98 100
99 101 // Listen to close bottom on the titleBar
100 102 //
@@ -138,7 +140,7 @@ void ofxComposer::load(string _fileConfig){
138 140 }
139 141 }
140 142
141   -bool ofxComposer::addPatch(string _filePath, ofPoint _position){
  143 +bool ofxComposer::addPatchFromFile(string _filePath, ofPoint _position){
142 144 bool loaded = false;
143 145
144 146 ofxPatch *nPatch = new ofxPatch();
@@ -155,6 +157,28 @@ bool ofxComposer::addPatch(string _filePath, ofPoint _position){
155 157 return loaded;
156 158 }
157 159
  160 +bool ofxComposer::addPatchWithOutFile(string _type, ofPoint _position){
  161 + bool loaded = false;
  162 +
  163 + ofxPatch *nPatch = new ofxPatch();
  164 + loaded = nPatch->loadType( _type, "config.xml" );
  165 +
  166 + if ( loaded ){
  167 + nPatch->move( _position );
  168 + nPatch->scale(0.5);
  169 + nPatch->saveSettings();
  170 + ofAddListener( nPatch->title->close , this, &ofxComposer::closePatch);
  171 +
  172 + if (nPatch->getType() == "ofxGLEditor"){
  173 + nPatch->setTexture( editorFbo.getTextureReference(), 0);
  174 + }
  175 +
  176 + patches[nPatch->getId()] = nPatch;
  177 + }
  178 +
  179 + return loaded;
  180 +}
  181 +
158 182 bool ofxComposer::connect( int _fromID, int _toID, int nTexture ){
159 183 bool connected = false;
160 184
@@ -307,8 +331,10 @@ void ofxComposer::_keyPressed(ofKeyEventArgs &e){
307 331 } else if ((e.key == OF_KEY_F3 ) || (e.key == OF_KEY_F4 ) ){
308 332 // Special keys reserved for Patch Events
309 333 //
310   - } else if ((e.key == OF_KEY_F5 ) || (e.key == OF_KEY_F6 ) ){
311   -
  334 + } else if (e.key == OF_KEY_F5 ){
  335 + bGLEditorPatch = addPatchWithOutFile("ofxGLEditor", ofPoint(ofGetMouseX(),ofGetMouseY()));
  336 + } else if ( e.key == OF_KEY_F6 ){
  337 + addPatchWithOutFile("ofVideoGrabber", ofPoint(ofGetMouseX(),ofGetMouseY()));
312 338 } else if (e.key == OF_KEY_F7){
313 339 ofToggleFullscreen();
314 340 editor.reShape();
3  src/ofxComposer.h
@@ -23,7 +23,8 @@ class ofxComposer {
23 23 ofxComposer();
24 24
25 25 void load(string _fileConfig = "default");
26   - bool addPatch(string _filePath, ofPoint _position);
  26 + bool addPatchFromFile(string _filePath, ofPoint _position);
  27 + bool addPatchWithOutFile(string _type, ofPoint _position);
27 28
28 29 ofxPatch* operator[](int _nID){ if ( (_nID != -1) && (patches[_nID] != NULL) ) return patches[_nID]; };
29 30
67 src/ofxPatch.cpp
@@ -283,7 +283,7 @@ void ofxPatch::draw(){
283 283
284 284 if ( bEditMode || bVisible ) {
285 285
286   - if (bActive || !bEditMode)
  286 + if (bActive || !bEditMode || (type == "ofxGLEditor"))
287 287 color.lerp(ofColor(255,255), 0.1);
288 288 else
289 289 color.lerp(ofColor(200,200), 0.1);
@@ -1064,6 +1064,71 @@ bool ofxPatch::loadFile(string _filePath, string _configFile){
1064 1064 return loaded;
1065 1065 }
1066 1066
  1067 +bool ofxPatch::loadType(string _type, string _configFile){
  1068 + bool loaded = false;
  1069 +
  1070 + if (_configFile != "none")
  1071 + configFile = _configFile;
  1072 +
  1073 + // Load General setup variables
  1074 + //
  1075 + ofxXmlSettings XML;
  1076 + if (XML.loadFile(configFile)){
  1077 + if (XML.getValue("general:fullscreen", false ) == true){
  1078 + width = ofGetScreenWidth();
  1079 + height = ofGetScreenHeight();
  1080 + } else {
  1081 + width = XML.getValue("general:width", 640 );
  1082 + height = XML.getValue("general:height", 480 );
  1083 + }
  1084 + }
  1085 +
  1086 + if ( _type == "ofxGLEditor"){
  1087 + type = _type;
  1088 + title->setTitle( type );
  1089 + loaded = true;
  1090 + } else if ( _type == "ofVideoGrabber"){
  1091 + type = _type;
  1092 + videoGrabber = new ofVideoGrabber();
  1093 + videoGrabber->setDeviceID( 0 );
  1094 +
  1095 + title->setTitle(ofToString(nId) + ":" + type );
  1096 + loaded = videoGrabber->initGrabber(width, height);
  1097 +
  1098 + if (loaded){
  1099 + width = videoGrabber->getWidth();
  1100 + height = videoGrabber->getHeight();
  1101 + }
  1102 + }
  1103 +
  1104 + if ( loaded ){
  1105 +
  1106 + float offSet = 0.0;
  1107 +
  1108 + if (title != NULL)
  1109 + offSet = 15;
  1110 +
  1111 + if (type == "ofxGLEditor"){
  1112 + textureCorners[0].set(0.0, height + offSet);
  1113 + textureCorners[1].set(width, height + offSet);
  1114 + textureCorners[2].set(width, offSet);
  1115 + textureCorners[3].set(0.0, offSet);
  1116 + } else {
  1117 + textureCorners[0].set(0.0, offSet);
  1118 + textureCorners[1].set(width, offSet);
  1119 + textureCorners[2].set(width, height + offSet);
  1120 + textureCorners[3].set(0.0, height + offSet);
  1121 + }
  1122 +
  1123 + title->setTitle( type );
  1124 +
  1125 + bUpdateMask = true;
  1126 + bUpdateCoord = true;
  1127 + }
  1128 +
  1129 + return loaded;
  1130 +}
  1131 +
1067 1132 bool ofxPatch::loadSettings( int _nTag, string _configFile){
1068 1133 bool loaded = false;
1069 1134
3  src/ofxPatch.h
@@ -38,7 +38,8 @@ class ofxPatch{
38 38 ~ofxPatch();
39 39
40 40 bool loadFile(string _filePath, string _configFile = "none");
41   -
  41 + bool loadType(string _type, string _configFile = "none");
  42 +
42 43 bool loadSettings(int _nTag, string _configFile = "none");
43 44 bool saveSettings(string _configFile = "none");
44 45
6 tools/gaussH.fs → tools/Gauss.fs
... ... @@ -1,17 +1,15 @@
1 1 uniform sampler2DRect tex0;
2   -float direction = 0.0;
3   -float kernel_size = 9.0;
4 2 float size_cx = 1.0;
5 3 float size_cy = 1.0;
6 4
7 5 void main (void) {
8 6 float rho = 20.0;
9 7
10   -
  8 + float direction = 0.0;
  9 + float kernel_size = 9.0;
11 10 vec2 dir = direction < 0.5 ? vec2(1.0,0.0) : vec2(0.0,1.0);
12 11
13 12 float dx = 1.0 / size_cx;
14   -
15 13 float dy = 1.0 / size_cy;
16 14 vec2 st = gl_TexCoord [0].st;
17 15
28 tools/gaussV.fs
... ... @@ -1,28 +0,0 @@
1   -uniform sampler2DRect tex0;
2   -float direction = 0.0;
3   -float kernel_size = 9.0;
4   -float size_cx = 1.0;
5   -float size_cy = 1.0;
6   -
7   -void main (void) {
8   - float kernel_size = 2.0;
9   - float rho = 20.0;
10   -
11   - vec2 direction = vec2(0.0,1.0);
12   -
13   - float dx = 1.0 / size_cx;
14   -
15   - float dy = 1.0 / size_cy;
16   - vec2 st = gl_TexCoord [0].st;
17   -
18   - vec4 color = vec4 (0.0, 0.0, 0.0, 0.0);
19   - float weight = 0.0;
20   -
21   - for (float i = -1.0*kernel_size; i <= kernel_size ; i+=1.0) {
22   - float fac = exp (-(i * i) / (2.0 * rho * rho));
23   - weight += fac;
24   - color += texture2DRect(tex0, st + vec2 (dx*i, dy*i) * direction) * fac;
25   - }
26   -
27   - gl_FragColor = color / weight;
28   -}

0 comments on commit 28d4324

Please sign in to comment.
Something went wrong with that request. Please try again.