Permalink
Browse files

TODO: freacking bug assigning ids at patchs

  • Loading branch information...
1 parent c643762 commit 28d43246bcf6633cbdb8eb9ef1c2f8f51dc4f660 @patriciogonzalezvivo committed May 13, 2012
Showing with 103 additions and 40 deletions.
  1. +31 −5 src/ofxComposer.cpp
  2. +2 −1 src/ofxComposer.h
  3. +66 −1 src/ofxPatch.cpp
  4. +2 −1 src/ofxPatch.h
  5. +2 −4 tools/{gaussH.fs → Gauss.fs}
  6. +0 −28 tools/gaussV.fs
View
36 src/ofxComposer.cpp
@@ -23,6 +23,8 @@ string helpScreen = "\n \
- r: reset mask path\n \
\n \
- F4: Reset surface coorners\n \
+ - F5: Add ofxGLEditor (temporal!!!)\n \
+ - F6: Add ofVideoGrabber (temporal!!!)\n \
- F7: Turn ON/OFF the fullscreen-mode\n \
\n \
Mouse and Coorners: \n \
@@ -91,10 +93,10 @@ void ofxComposer::load(string _fileConfig){
nPatch->setTexture( editorFbo.getTextureReference(), 0);
bGLEditorPatch = true;
}
-
+ /*
if (nPatch->getType() == "input"){
nPatch->setTexture( editorFbo.getTextureReference(), 0);
- }
+ }*/
// Listen to close bottom on the titleBar
//
@@ -138,7 +140,7 @@ void ofxComposer::load(string _fileConfig){
}
}
-bool ofxComposer::addPatch(string _filePath, ofPoint _position){
+bool ofxComposer::addPatchFromFile(string _filePath, ofPoint _position){
bool loaded = false;
ofxPatch *nPatch = new ofxPatch();
@@ -155,6 +157,28 @@ bool ofxComposer::addPatch(string _filePath, ofPoint _position){
return loaded;
}
+bool ofxComposer::addPatchWithOutFile(string _type, ofPoint _position){
+ bool loaded = false;
+
+ ofxPatch *nPatch = new ofxPatch();
+ loaded = nPatch->loadType( _type, "config.xml" );
+
+ if ( loaded ){
+ nPatch->move( _position );
+ nPatch->scale(0.5);
+ nPatch->saveSettings();
+ ofAddListener( nPatch->title->close , this, &ofxComposer::closePatch);
+
+ if (nPatch->getType() == "ofxGLEditor"){
+ nPatch->setTexture( editorFbo.getTextureReference(), 0);
+ }
+
+ patches[nPatch->getId()] = nPatch;
+ }
+
+ return loaded;
+}
+
bool ofxComposer::connect( int _fromID, int _toID, int nTexture ){
bool connected = false;
@@ -307,8 +331,10 @@ void ofxComposer::_keyPressed(ofKeyEventArgs &e){
} else if ((e.key == OF_KEY_F3 ) || (e.key == OF_KEY_F4 ) ){
// Special keys reserved for Patch Events
//
- } else if ((e.key == OF_KEY_F5 ) || (e.key == OF_KEY_F6 ) ){
-
+ } else if (e.key == OF_KEY_F5 ){
+ bGLEditorPatch = addPatchWithOutFile("ofxGLEditor", ofPoint(ofGetMouseX(),ofGetMouseY()));
+ } else if ( e.key == OF_KEY_F6 ){
+ addPatchWithOutFile("ofVideoGrabber", ofPoint(ofGetMouseX(),ofGetMouseY()));
} else if (e.key == OF_KEY_F7){
ofToggleFullscreen();
editor.reShape();
View
3 src/ofxComposer.h
@@ -23,7 +23,8 @@ class ofxComposer {
ofxComposer();
void load(string _fileConfig = "default");
- bool addPatch(string _filePath, ofPoint _position);
+ bool addPatchFromFile(string _filePath, ofPoint _position);
+ bool addPatchWithOutFile(string _type, ofPoint _position);
ofxPatch* operator[](int _nID){ if ( (_nID != -1) && (patches[_nID] != NULL) ) return patches[_nID]; };
View
67 src/ofxPatch.cpp
@@ -283,7 +283,7 @@ void ofxPatch::draw(){
if ( bEditMode || bVisible ) {
- if (bActive || !bEditMode)
+ if (bActive || !bEditMode || (type == "ofxGLEditor"))
color.lerp(ofColor(255,255), 0.1);
else
color.lerp(ofColor(200,200), 0.1);
@@ -1064,6 +1064,71 @@ bool ofxPatch::loadFile(string _filePath, string _configFile){
return loaded;
}
+bool ofxPatch::loadType(string _type, string _configFile){
+ bool loaded = false;
+
+ if (_configFile != "none")
+ configFile = _configFile;
+
+ // Load General setup variables
+ //
+ ofxXmlSettings XML;
+ if (XML.loadFile(configFile)){
+ if (XML.getValue("general:fullscreen", false ) == true){
+ width = ofGetScreenWidth();
+ height = ofGetScreenHeight();
+ } else {
+ width = XML.getValue("general:width", 640 );
+ height = XML.getValue("general:height", 480 );
+ }
+ }
+
+ if ( _type == "ofxGLEditor"){
+ type = _type;
+ title->setTitle( type );
+ loaded = true;
+ } else if ( _type == "ofVideoGrabber"){
+ type = _type;
+ videoGrabber = new ofVideoGrabber();
+ videoGrabber->setDeviceID( 0 );
+
+ title->setTitle(ofToString(nId) + ":" + type );
+ loaded = videoGrabber->initGrabber(width, height);
+
+ if (loaded){
+ width = videoGrabber->getWidth();
+ height = videoGrabber->getHeight();
+ }
+ }
+
+ if ( loaded ){
+
+ float offSet = 0.0;
+
+ if (title != NULL)
+ offSet = 15;
+
+ if (type == "ofxGLEditor"){
+ textureCorners[0].set(0.0, height + offSet);
+ textureCorners[1].set(width, height + offSet);
+ textureCorners[2].set(width, offSet);
+ textureCorners[3].set(0.0, offSet);
+ } else {
+ textureCorners[0].set(0.0, offSet);
+ textureCorners[1].set(width, offSet);
+ textureCorners[2].set(width, height + offSet);
+ textureCorners[3].set(0.0, height + offSet);
+ }
+
+ title->setTitle( type );
+
+ bUpdateMask = true;
+ bUpdateCoord = true;
+ }
+
+ return loaded;
+}
+
bool ofxPatch::loadSettings( int _nTag, string _configFile){
bool loaded = false;
View
3 src/ofxPatch.h
@@ -38,7 +38,8 @@ class ofxPatch{
~ofxPatch();
bool loadFile(string _filePath, string _configFile = "none");
-
+ bool loadType(string _type, string _configFile = "none");
+
bool loadSettings(int _nTag, string _configFile = "none");
bool saveSettings(string _configFile = "none");
View
6 tools/gaussH.fs → tools/Gauss.fs
@@ -1,17 +1,15 @@
uniform sampler2DRect tex0;
-float direction = 0.0;
-float kernel_size = 9.0;
float size_cx = 1.0;
float size_cy = 1.0;
void main (void) {
float rho = 20.0;
-
+ float direction = 0.0;
+ float kernel_size = 9.0;
vec2 dir = direction < 0.5 ? vec2(1.0,0.0) : vec2(0.0,1.0);
float dx = 1.0 / size_cx;
-
float dy = 1.0 / size_cy;
vec2 st = gl_TexCoord [0].st;
View
28 tools/gaussV.fs
@@ -1,28 +0,0 @@
-uniform sampler2DRect tex0;
-float direction = 0.0;
-float kernel_size = 9.0;
-float size_cx = 1.0;
-float size_cy = 1.0;
-
-void main (void) {
- float kernel_size = 2.0;
- float rho = 20.0;
-
- vec2 direction = vec2(0.0,1.0);
-
- float dx = 1.0 / size_cx;
-
- float dy = 1.0 / size_cy;
- vec2 st = gl_TexCoord [0].st;
-
- vec4 color = vec4 (0.0, 0.0, 0.0, 0.0);
- float weight = 0.0;
-
- for (float i = -1.0*kernel_size; i <= kernel_size ; i+=1.0) {
- float fac = exp (-(i * i) / (2.0 * rho * rho));
- weight += fac;
- color += texture2DRect(tex0, st + vec2 (dx*i, dy*i) * direction) * fac;
- }
-
- gl_FragColor = color / weight;
-}

0 comments on commit 28d4324

Please sign in to comment.